source: mainpanel.c @ cb5a9f3

release-1.7release-1.8release-1.9
Last change on this file since cb5a9f3 was d2a4534, checked in by David Benjamin <davidben@mit.edu>, 11 years ago
Maintain an owl_mainpanel structure This structure will contain all the other windows.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1#include "owl.h"
2
3static void owl_mainpanel_size(owl_window *parent, void *user_data);
4static void owl_mainpanel_layout_contents(owl_window *parent, void *user_data);
5
6void owl_mainpanel_init(owl_mainpanel *mp)
7{
8  /* Create windows */
9  mp->panel = owl_window_new(NULL);
10  mp->recwin = owl_window_new(mp->panel);
11  mp->sepwin = owl_window_new(mp->panel);
12  mp->msgwin = owl_window_new(mp->panel);
13  mp->typwin = owl_window_new(mp->panel);
14
15  /* Set up sizing hooks */
16  owl_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_mainpanel_size), mp->panel, 0);
17  g_signal_connect(mp->panel, "resized", G_CALLBACK(owl_mainpanel_layout_contents), mp);
18
19  /* Bootstrap the sizes and go */
20  owl_mainpanel_size(owl_window_get_screen(), mp->panel);
21  owl_window_show_all(mp->panel);
22}
23
24static void owl_mainpanel_size(owl_window *parent, void *user_data)
25{
26  int lines, cols;
27  owl_window *panel = user_data;
28
29  /* Make this panel full-screen */
30  owl_window_get_position(parent, &lines, &cols, NULL, NULL);
31  owl_window_set_position(panel, lines, cols, 0, 0);
32}
33
34static void owl_mainpanel_layout_contents(owl_window *panel, void *user_data)
35{
36  int lines, cols, typwin_lines;
37  owl_mainpanel *mp = user_data;
38
39  owl_window_get_position(panel, &lines, &cols, NULL, NULL);
40  typwin_lines = owl_global_get_typwin_lines(&g);
41
42  /* set the new window sizes */
43  mp->recwinlines=lines-(typwin_lines+2);
44  if (mp->recwinlines<0) {
45    /* gotta deal with this */
46    mp->recwinlines=0;
47  }
48
49  /* resize all the windows */
50  owl_window_set_position(mp->recwin, mp->recwinlines, cols, 0, 0);
51  owl_window_set_position(mp->sepwin, 1, cols, mp->recwinlines, 0);
52  owl_window_set_position(mp->msgwin, 1, cols, mp->recwinlines+1, 0);
53  owl_window_set_position(mp->typwin, typwin_lines, cols, mp->recwinlines+2, 0);
54}
55
56void owl_mainpanel_cleanup(owl_mainpanel *mp)
57{
58  owl_window_unlink(mp->panel);
59  g_object_unref(mp->panel);
60  g_object_unref(mp->recwin);
61  g_object_unref(mp->sepwin);
62  g_object_unref(mp->msgwin);
63  g_object_unref(mp->typwin);
64}
Note: See TracBrowser for help on using the repository browser.