1 | #include "owl.h" |
---|
2 | |
---|
3 | static void owl_mainpanel_size(owl_window *parent, void *user_data); |
---|
4 | |
---|
5 | void owl_mainpanel_init(owl_mainpanel *mp) |
---|
6 | { |
---|
7 | /* Create windows */ |
---|
8 | mp->panel = owl_window_new(NULL); |
---|
9 | mp->recwin = owl_window_new(mp->panel); |
---|
10 | mp->sepwin = owl_window_new(mp->panel); |
---|
11 | mp->msgwin = owl_window_new(mp->panel); |
---|
12 | mp->typwin = owl_window_new(mp->panel); |
---|
13 | |
---|
14 | /* Set up sizing hooks */ |
---|
15 | owl_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_mainpanel_size), mp->panel, 0); |
---|
16 | g_signal_connect_swapped(mp->panel, "resized", G_CALLBACK(owl_mainpanel_layout_contents), mp); |
---|
17 | |
---|
18 | /* Bootstrap the sizes and go */ |
---|
19 | owl_mainpanel_size(owl_window_get_screen(), mp->panel); |
---|
20 | owl_window_show_all(mp->panel); |
---|
21 | } |
---|
22 | |
---|
23 | static void owl_mainpanel_size(owl_window *parent, void *user_data) |
---|
24 | { |
---|
25 | int lines, cols; |
---|
26 | owl_window *panel = user_data; |
---|
27 | |
---|
28 | /* Make this panel full-screen */ |
---|
29 | owl_window_get_position(parent, &lines, &cols, NULL, NULL); |
---|
30 | owl_window_set_position(panel, lines, cols, 0, 0); |
---|
31 | } |
---|
32 | |
---|
33 | void owl_mainpanel_layout_contents(owl_mainpanel *mp) |
---|
34 | { |
---|
35 | int lines, cols, typwin_lines; |
---|
36 | |
---|
37 | /* skip if we haven't been initialized */ |
---|
38 | if (!mp->panel) return; |
---|
39 | |
---|
40 | owl_window_get_position(mp->panel, &lines, &cols, NULL, NULL); |
---|
41 | typwin_lines = owl_global_get_typwin_lines(&g); |
---|
42 | |
---|
43 | /* set the new window sizes */ |
---|
44 | mp->recwinlines=lines-(typwin_lines+2); |
---|
45 | if (mp->recwinlines<0) { |
---|
46 | /* gotta deal with this */ |
---|
47 | mp->recwinlines=0; |
---|
48 | } |
---|
49 | |
---|
50 | /* resize all the windows */ |
---|
51 | owl_window_set_position(mp->recwin, mp->recwinlines, cols, 0, 0); |
---|
52 | owl_window_set_position(mp->sepwin, 1, cols, mp->recwinlines, 0); |
---|
53 | owl_window_set_position(mp->msgwin, 1, cols, mp->recwinlines+1, 0); |
---|
54 | owl_window_set_position(mp->typwin, typwin_lines, cols, mp->recwinlines+2, 0); |
---|
55 | |
---|
56 | /* TEMPORARY */ |
---|
57 | owl_global_set_relayout_pending(&g); |
---|
58 | } |
---|
59 | |
---|
60 | void owl_mainpanel_cleanup(owl_mainpanel *mp) |
---|
61 | { |
---|
62 | owl_window_unlink(mp->panel); |
---|
63 | g_object_unref(mp->panel); |
---|
64 | g_object_unref(mp->recwin); |
---|
65 | g_object_unref(mp->sepwin); |
---|
66 | g_object_unref(mp->msgwin); |
---|
67 | g_object_unref(mp->typwin); |
---|
68 | } |
---|