Mercurial > pidgin.yaz
annotate finch/libgnt/gntmenuitem.c @ 16441:ed4ea63c0b45
pidgin.png -> pidgin, to always find appropriate sizes.
author | Hylke Bons <hylkebons@gmail.com> |
---|---|
date | Thu, 26 Apr 2007 21:51:29 +0000 |
parents | f00f2e283ffb |
children | 8410511f4dbb |
rev | line source |
---|---|
15818 | 1 #include "gntmenu.h" |
2 #include "gntmenuitem.h" | |
3 | |
4 static GObjectClass *parent_class = NULL; | |
5 | |
6 static void | |
7 gnt_menuitem_destroy(GObject *obj) | |
8 { | |
15931
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
9 GntMenuItem *item = GNT_MENU_ITEM(obj); |
15818 | 10 g_free(item->text); |
11 item->text = NULL; | |
12 if (item->submenu) | |
13 gnt_widget_destroy(GNT_WIDGET(item->submenu)); | |
14 parent_class->dispose(obj); | |
15 } | |
16 | |
17 static void | |
18 gnt_menuitem_class_init(GntMenuItemClass *klass) | |
19 { | |
20 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | |
21 parent_class = g_type_class_peek_parent(klass); | |
22 | |
23 obj_class->dispose = gnt_menuitem_destroy; | |
24 } | |
25 | |
26 static void | |
27 gnt_menuitem_init(GTypeInstance *instance, gpointer class) | |
28 { | |
29 } | |
30 | |
31 /****************************************************************************** | |
32 * GntMenuItem API | |
33 *****************************************************************************/ | |
34 GType | |
35 gnt_menuitem_get_gtype(void) | |
36 { | |
37 static GType type = 0; | |
38 | |
39 if(type == 0) | |
40 { | |
41 static const GTypeInfo info = { | |
42 sizeof(GntMenuItemClass), | |
43 NULL, /* base_init */ | |
44 NULL, /* base_finalize */ | |
45 (GClassInitFunc)gnt_menuitem_class_init, | |
46 NULL, /* class_finalize */ | |
47 NULL, /* class_data */ | |
48 sizeof(GntMenuItem), | |
49 0, /* n_preallocs */ | |
50 gnt_menuitem_init, /* instance_init */ | |
51 NULL /* value_table */ | |
52 }; | |
53 | |
54 type = g_type_register_static(G_TYPE_OBJECT, | |
55 "GntMenuItem", | |
56 &info, 0); | |
57 } | |
58 | |
59 return type; | |
60 } | |
61 | |
62 GntMenuItem *gnt_menuitem_new(const char *text) | |
63 { | |
15931
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
64 GObject *item = g_object_new(GNT_TYPE_MENU_ITEM, NULL); |
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15818
diff
changeset
|
65 GntMenuItem *menuitem = GNT_MENU_ITEM(item); |
15818 | 66 |
67 menuitem->text = g_strdup(text); | |
68 | |
69 return menuitem; | |
70 } | |
71 | |
72 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data) | |
73 { | |
74 item->callback = callback; | |
75 item->callbackdata = data; | |
76 } | |
77 | |
78 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu) | |
79 { | |
80 if (item->submenu) | |
81 gnt_widget_destroy(GNT_WIDGET(item->submenu)); | |
82 item->submenu = menu; | |
83 } | |
84 |