source: mainpanel.c @ 840032d

release-1.10release-1.7release-1.8release-1.9
Last change on this file since 840032d was 853f397, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Make mainpanel's fill_parent_cb also generic
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[d2a4534]1#include "owl.h"
2
3void owl_mainpanel_init(owl_mainpanel *mp)
4{
5  /* Create windows */
6  mp->panel = owl_window_new(NULL);
7  mp->recwin = owl_window_new(mp->panel);
8  mp->sepwin = owl_window_new(mp->panel);
9  mp->msgwin = owl_window_new(mp->panel);
10  mp->typwin = owl_window_new(mp->panel);
11
12  /* Set up sizing hooks */
[853f397]13  owl_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_window_fill_parent_cb), mp->panel, 0);
[908de44]14  g_signal_connect_swapped(mp->panel, "resized", G_CALLBACK(owl_mainpanel_layout_contents), mp);
[d2a4534]15
16  /* Bootstrap the sizes and go */
[853f397]17  owl_window_fill_parent_cb(owl_window_get_screen(), mp->panel);
[d2a4534]18  owl_window_show_all(mp->panel);
19}
20
[908de44]21void owl_mainpanel_layout_contents(owl_mainpanel *mp)
[d2a4534]22{
23  int lines, cols, typwin_lines;
24
[908de44]25  /* skip if we haven't been initialized */
26  if (!mp->panel) return;
27
28  owl_window_get_position(mp->panel, &lines, &cols, NULL, NULL);
[d2a4534]29  typwin_lines = owl_global_get_typwin_lines(&g);
30
31  /* set the new window sizes */
32  mp->recwinlines=lines-(typwin_lines+2);
33  if (mp->recwinlines<0) {
34    /* gotta deal with this */
35    mp->recwinlines=0;
[135d24b]36    typwin_lines = lines - 2;
[d2a4534]37  }
38
39  /* resize all the windows */
40  owl_window_set_position(mp->recwin, mp->recwinlines, cols, 0, 0);
41  owl_window_set_position(mp->sepwin, 1, cols, mp->recwinlines, 0);
42  owl_window_set_position(mp->msgwin, 1, cols, mp->recwinlines+1, 0);
43  owl_window_set_position(mp->typwin, typwin_lines, cols, mp->recwinlines+2, 0);
44}
45
46void owl_mainpanel_cleanup(owl_mainpanel *mp)
47{
48  owl_window_unlink(mp->panel);
49  g_object_unref(mp->panel);
50  g_object_unref(mp->recwin);
51  g_object_unref(mp->sepwin);
52  g_object_unref(mp->msgwin);
53  g_object_unref(mp->typwin);
[e294783]54  mp->panel = mp->recwin = mp->sepwin = mp->msgwin = mp->typwin = NULL;
[d2a4534]55}
Note: See TracBrowser for help on using the repository browser.