Mercurial > pidgin
comparison finch/libgnt/gntmenuitem.c @ 21256:e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 20 Oct 2007 05:52:52 +0000 |
parents | b65f1bff6412 |
children | 88d889b54df4 |
comparison
equal
deleted
inserted
replaced
21255:430fd445a053 | 21256:e8b0f224483f |
---|---|
21 */ | 21 */ |
22 | 22 |
23 #include "gntmenu.h" | 23 #include "gntmenu.h" |
24 #include "gntmenuitem.h" | 24 #include "gntmenuitem.h" |
25 | 25 |
26 enum | |
27 { | |
28 SIG_ACTIVATE, | |
29 SIGS | |
30 }; | |
31 static guint signals[SIGS] = { 0 }; | |
32 | |
26 static GObjectClass *parent_class = NULL; | 33 static GObjectClass *parent_class = NULL; |
27 | 34 |
28 static void | 35 static void |
29 gnt_menuitem_destroy(GObject *obj) | 36 gnt_menuitem_destroy(GObject *obj) |
30 { | 37 { |
42 { | 49 { |
43 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | 50 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
44 parent_class = g_type_class_peek_parent(klass); | 51 parent_class = g_type_class_peek_parent(klass); |
45 | 52 |
46 obj_class->dispose = gnt_menuitem_destroy; | 53 obj_class->dispose = gnt_menuitem_destroy; |
54 | |
55 signals[SIG_ACTIVATE] = | |
56 g_signal_new("activate", | |
57 G_TYPE_FROM_CLASS(klass), | |
58 G_SIGNAL_RUN_LAST, | |
59 0, NULL, NULL, | |
60 g_cclosure_marshal_VOID__VOID, | |
61 G_TYPE_NONE, 0); | |
47 } | 62 } |
48 | 63 |
49 static void | 64 static void |
50 gnt_menuitem_init(GTypeInstance *instance, gpointer class) | 65 gnt_menuitem_init(GTypeInstance *instance, gpointer klass) |
51 { | 66 { |
52 } | 67 } |
53 | 68 |
54 /****************************************************************************** | 69 /****************************************************************************** |
55 * GntMenuItem API | 70 * GntMenuItem API |
129 const char * gnt_menuitem_get_id(GntMenuItem *item) | 144 const char * gnt_menuitem_get_id(GntMenuItem *item) |
130 { | 145 { |
131 return item->priv.id; | 146 return item->priv.id; |
132 } | 147 } |
133 | 148 |
149 gboolean gnt_menuitem_activate(GntMenuItem *item) | |
150 { | |
151 g_signal_emit(item, signals[SIG_ACTIVATE], 0); | |
152 if (item->callback) { | |
153 item->callback(item, item->callbackdata); | |
154 return TRUE; | |
155 } | |
156 return FALSE; | |
157 } | |
158 |