comparison finch/libgnt/gntwindow.c @ 15817:0e3a8505ebbe

renamed gaim-text to finch
author Sean Egan <seanegan@gmail.com>
date Sun, 18 Mar 2007 19:38:15 +0000
parents
children 3c3fc1432a01 8410511f4dbb
comparison
equal deleted inserted replaced
15816:317e7613e581 15817:0e3a8505ebbe
1 #include "gntstyle.h"
2 #include "gntwindow.h"
3
4 #include <string.h>
5
6 enum
7 {
8 SIGS = 1,
9 };
10
11 static GntBoxClass *parent_class = NULL;
12
13 static void (*org_destroy)(GntWidget *widget);
14
15 static gboolean
16 show_menu(GntBindable *bind, GList *null)
17 {
18 GntWindow *win = GNT_WINDOW(bind);
19 if (win->menu) {
20 gnt_screen_menu_show(win->menu);
21 return TRUE;
22 }
23 return FALSE;
24 }
25
26 static void
27 gnt_window_destroy(GntWidget *widget)
28 {
29 GntWindow *window = GNT_WINDOW(widget);
30 if (window->menu)
31 gnt_widget_destroy(GNT_WIDGET(window->menu));
32 org_destroy(widget);
33 }
34
35 static void
36 gnt_window_class_init(GntWindowClass *klass)
37 {
38 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
39 GntWidgetClass *wid_class = GNT_WIDGET_CLASS(klass);
40 parent_class = GNT_BOX_CLASS(klass);
41
42 org_destroy = wid_class->destroy;
43 wid_class->destroy = gnt_window_destroy;
44
45 gnt_bindable_class_register_action(bindable, "show-menu", show_menu,
46 GNT_KEY_CTRL_O, NULL);
47 gnt_bindable_register_binding(bindable, "show-menu", GNT_KEY_F10, NULL);
48 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
49
50 GNTDEBUG;
51 }
52
53 static void
54 gnt_window_init(GTypeInstance *instance, gpointer class)
55 {
56 GntWidget *widget = GNT_WIDGET(instance);
57 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
58 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
59 GNTDEBUG;
60 }
61
62 /******************************************************************************
63 * GntWindow API
64 *****************************************************************************/
65 GType
66 gnt_window_get_gtype(void)
67 {
68 static GType type = 0;
69
70 if(type == 0)
71 {
72 static const GTypeInfo info = {
73 sizeof(GntWindowClass),
74 NULL, /* base_init */
75 NULL, /* base_finalize */
76 (GClassInitFunc)gnt_window_class_init,
77 NULL, /* class_finalize */
78 NULL, /* class_data */
79 sizeof(GntWindow),
80 0, /* n_preallocs */
81 gnt_window_init, /* instance_init */
82 NULL /* value_table */
83 };
84
85 type = g_type_register_static(GNT_TYPE_BOX,
86 "GntWindow",
87 &info, 0);
88 }
89
90 return type;
91 }
92
93 GntWidget *gnt_window_new()
94 {
95 GntWidget *widget = g_object_new(GNT_TYPE_WINDOW, NULL);
96
97 return widget;
98 }
99
100 GntWidget *gnt_window_box_new(gboolean homo, gboolean vert)
101 {
102 GntWidget *wid = gnt_window_new();
103 GntBox *box = GNT_BOX(wid);
104
105 box->homogeneous = homo;
106 box->vertical = vert;
107 box->alignment = vert ? GNT_ALIGN_LEFT : GNT_ALIGN_MID;
108
109 return wid;
110 }
111
112 void gnt_window_set_menu(GntWindow *window, GntMenu *menu)
113 {
114 /* If a menu already existed, then destroy that first. */
115 if (window->menu)
116 gnt_widget_destroy(GNT_WIDGET(window->menu));
117 window->menu = menu;
118 }
119