| 21 |
21 |
| 22 #include "debug.h" |
22 #include "debug.h" |
| 23 |
23 |
| 24 #include "gtkmenutray.h" |
24 #include "gtkmenutray.h" |
| 25 |
25 |
| 26 /****************************************************************************** |
26 struct _PidginMenuTray { |
| 27 * Enums |
27 GtkMenuItem parent; |
| 28 *****************************************************************************/ |
28 |
| |
29 GtkWidget *tray; |
| |
30 }; |
| |
31 |
| 29 enum { |
32 enum { |
| 30 PROP_ZERO = 0, |
33 PROP_ZERO = 0, |
| 31 PROP_BOX |
34 PROP_BOX, |
| |
35 N_PROPERTIES |
| 32 }; |
36 }; |
| 33 |
37 |
| 34 /****************************************************************************** |
38 /****************************************************************************** |
| 35 * Globals |
39 * Globals |
| 36 *****************************************************************************/ |
40 *****************************************************************************/ |
| 37 static GObjectClass *parent_class = NULL; |
41 static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
| 38 /****************************************************************************** |
|
| 39 * Internal Stuff |
|
| 40 *****************************************************************************/ |
|
| 41 |
42 |
| 42 /****************************************************************************** |
43 /****************************************************************************** |
| 43 * Item Stuff |
44 * Item Stuff |
| 44 *****************************************************************************/ |
45 *****************************************************************************/ |
| 45 static void |
46 static void |
| 56 * overridding the select, so it makes sense to override deselect as well. |
57 * overridding the select, so it makes sense to override deselect as well. |
| 57 */ |
58 */ |
| 58 } |
59 } |
| 59 |
60 |
| 60 /****************************************************************************** |
61 /****************************************************************************** |
| 61 * Object Stuff |
62 * GObject Implementation |
| 62 *****************************************************************************/ |
63 *****************************************************************************/ |
| |
64 G_DEFINE_TYPE(PidginMenuTray, pidgin_menu_tray, GTK_TYPE_MENU_ITEM); |
| |
65 |
| 63 static void |
66 static void |
| 64 pidgin_menu_tray_get_property(GObject *obj, guint param_id, GValue *value, |
67 pidgin_menu_tray_get_property(GObject *obj, guint param_id, GValue *value, |
| 65 GParamSpec *pspec) |
68 GParamSpec *pspec) |
| 66 { |
69 { |
| 67 PidginMenuTray *menu_tray = PIDGIN_MENU_TRAY(obj); |
70 PidginMenuTray *menu_tray = PIDGIN_MENU_TRAY(obj); |
| 98 |
101 |
| 99 if(GTK_IS_WIDGET(tray->tray)) |
102 if(GTK_IS_WIDGET(tray->tray)) |
| 100 gtk_widget_destroy(GTK_WIDGET(tray->tray)); |
103 gtk_widget_destroy(GTK_WIDGET(tray->tray)); |
| 101 #endif |
104 #endif |
| 102 |
105 |
| 103 G_OBJECT_CLASS(parent_class)->finalize(obj); |
106 G_OBJECT_CLASS(pidgin_menu_tray_parent_class)->finalize(obj); |
| 104 } |
107 } |
| 105 |
108 |
| 106 static void |
109 static void |
| 107 pidgin_menu_tray_class_init(PidginMenuTrayClass *klass) { |
110 pidgin_menu_tray_class_init(PidginMenuTrayClass *klass) { |
| 108 GObjectClass *object_class = G_OBJECT_CLASS(klass); |
111 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
| 109 GtkMenuItemClass *menu_item_class = GTK_MENU_ITEM_CLASS(klass); |
112 GtkMenuItemClass *menu_item_class = GTK_MENU_ITEM_CLASS(klass); |
| 110 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
113 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
| 111 GParamSpec *pspec; |
114 |
| 112 |
115 obj_class->finalize = pidgin_menu_tray_finalize; |
| 113 parent_class = g_type_class_peek_parent(klass); |
116 obj_class->get_property = pidgin_menu_tray_get_property; |
| 114 |
|
| 115 object_class->finalize = pidgin_menu_tray_finalize; |
|
| 116 object_class->get_property = pidgin_menu_tray_get_property; |
|
| 117 |
117 |
| 118 menu_item_class->select = pidgin_menu_tray_select; |
118 menu_item_class->select = pidgin_menu_tray_select; |
| 119 menu_item_class->deselect = pidgin_menu_tray_deselect; |
119 menu_item_class->deselect = pidgin_menu_tray_deselect; |
| 120 |
120 |
| 121 widget_class->map = pidgin_menu_tray_map; |
121 widget_class->map = pidgin_menu_tray_map; |
| 122 |
122 |
| 123 pspec = g_param_spec_object("box", "The box", |
123 properties[PROP_BOX] = g_param_spec_object("box", "The box", "The box", |
| 124 "The box", |
124 GTK_TYPE_BOX, |
| 125 GTK_TYPE_BOX, |
125 G_PARAM_READABLE); |
| 126 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
126 |
| 127 g_object_class_install_property(object_class, PROP_BOX, pspec); |
127 g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
| 128 } |
128 } |
| 129 |
129 |
| 130 static void |
130 static void |
| 131 pidgin_menu_tray_init(PidginMenuTray *menu_tray) { |
131 pidgin_menu_tray_init(PidginMenuTray *menu_tray) { |
| 132 GtkWidget *widget = GTK_WIDGET(menu_tray); |
132 GtkWidget *widget = GTK_WIDGET(menu_tray); |
| 155 } |
155 } |
| 156 |
156 |
| 157 /****************************************************************************** |
157 /****************************************************************************** |
| 158 * API |
158 * API |
| 159 *****************************************************************************/ |
159 *****************************************************************************/ |
| 160 GType |
|
| 161 pidgin_menu_tray_get_type(void) { |
|
| 162 static GType type = 0; |
|
| 163 |
|
| 164 if(type == 0) { |
|
| 165 static const GTypeInfo info = { |
|
| 166 sizeof(PidginMenuTrayClass), |
|
| 167 NULL, |
|
| 168 NULL, |
|
| 169 (GClassInitFunc)pidgin_menu_tray_class_init, |
|
| 170 NULL, |
|
| 171 NULL, |
|
| 172 sizeof(PidginMenuTray), |
|
| 173 0, |
|
| 174 (GInstanceInitFunc)pidgin_menu_tray_init, |
|
| 175 NULL |
|
| 176 }; |
|
| 177 |
|
| 178 type = g_type_register_static(GTK_TYPE_MENU_ITEM, |
|
| 179 "PidginMenuTray", |
|
| 180 &info, 0); |
|
| 181 } |
|
| 182 |
|
| 183 return type; |
|
| 184 } |
|
| 185 |
|
| 186 GtkWidget * |
160 GtkWidget * |
| 187 pidgin_menu_tray_new() { |
161 pidgin_menu_tray_new() { |
| 188 return g_object_new(PIDGIN_TYPE_MENU_TRAY, NULL); |
162 return g_object_new(PIDGIN_TYPE_MENU_TRAY, NULL); |
| 189 } |
163 } |
| 190 |
164 |