[d2a4534] | 1 | #include "owl.h" |
---|
| 2 | |
---|
| 3 | void owl_mainpanel_init(owl_mainpanel *mp) |
---|
| 4 | { |
---|
| 5 | /* Create windows */ |
---|
| 6 | mp->panel = owl_window_new(NULL); |
---|
[4eee948] | 7 | /* HACK for now: the sepwin must be drawn /after/ the recwin for |
---|
| 8 | * lastdisplayed to work */ |
---|
[d2a4534] | 9 | mp->sepwin = owl_window_new(mp->panel); |
---|
[4eee948] | 10 | mp->recwin = owl_window_new(mp->panel); |
---|
[d2a4534] | 11 | mp->msgwin = owl_window_new(mp->panel); |
---|
| 12 | mp->typwin = owl_window_new(mp->panel); |
---|
| 13 | |
---|
| 14 | /* Set up sizing hooks */ |
---|
[853f397] | 15 | owl_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_window_fill_parent_cb), mp->panel, 0); |
---|
[908de44] | 16 | g_signal_connect_swapped(mp->panel, "resized", G_CALLBACK(owl_mainpanel_layout_contents), mp); |
---|
[d2a4534] | 17 | |
---|
| 18 | /* Bootstrap the sizes and go */ |
---|
[853f397] | 19 | owl_window_fill_parent_cb(owl_window_get_screen(), mp->panel); |
---|
[d2a4534] | 20 | owl_window_show_all(mp->panel); |
---|
| 21 | } |
---|
| 22 | |
---|
[908de44] | 23 | void owl_mainpanel_layout_contents(owl_mainpanel *mp) |
---|
[d2a4534] | 24 | { |
---|
| 25 | int lines, cols, typwin_lines; |
---|
| 26 | |
---|
[908de44] | 27 | /* skip if we haven't been initialized */ |
---|
| 28 | if (!mp->panel) return; |
---|
| 29 | |
---|
| 30 | owl_window_get_position(mp->panel, &lines, &cols, NULL, NULL); |
---|
[d2a4534] | 31 | typwin_lines = owl_global_get_typwin_lines(&g); |
---|
| 32 | |
---|
| 33 | /* set the new window sizes */ |
---|
| 34 | mp->recwinlines=lines-(typwin_lines+2); |
---|
| 35 | if (mp->recwinlines<0) { |
---|
| 36 | /* gotta deal with this */ |
---|
| 37 | mp->recwinlines=0; |
---|
[135d24b] | 38 | typwin_lines = lines - 2; |
---|
[d2a4534] | 39 | } |
---|
| 40 | |
---|
| 41 | /* resize all the windows */ |
---|
| 42 | owl_window_set_position(mp->recwin, mp->recwinlines, cols, 0, 0); |
---|
| 43 | owl_window_set_position(mp->sepwin, 1, cols, mp->recwinlines, 0); |
---|
| 44 | owl_window_set_position(mp->msgwin, 1, cols, mp->recwinlines+1, 0); |
---|
| 45 | owl_window_set_position(mp->typwin, typwin_lines, cols, mp->recwinlines+2, 0); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | void owl_mainpanel_cleanup(owl_mainpanel *mp) |
---|
| 49 | { |
---|
| 50 | owl_window_unlink(mp->panel); |
---|
| 51 | g_object_unref(mp->panel); |
---|
| 52 | g_object_unref(mp->recwin); |
---|
| 53 | g_object_unref(mp->sepwin); |
---|
| 54 | g_object_unref(mp->msgwin); |
---|
| 55 | g_object_unref(mp->typwin); |
---|
[e294783] | 56 | mp->panel = mp->recwin = mp->sepwin = mp->msgwin = mp->typwin = NULL; |
---|
[d2a4534] | 57 | } |
---|