Mercurial > pidgin
annotate console/libgnt/gntmenuitem.c @ 15016:6e7184096615
[gaim-migrate @ 17798]
Update the manual.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 21 Nov 2006 02:27:31 +0000 |
parents | 065e7ac30338 |
children | 1c8f1dc50685 |
rev | line source |
---|---|
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntmenu.h" |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gntmenuitem.h" |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 static GObjectClass *parent_class = NULL; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 gnt_menuitem_destroy(GObject *obj) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 GntMenuItem *item = GNT_MENUITEM(obj); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 g_free(item->text); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 item->text = NULL; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 if (item->submenu) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 gnt_widget_destroy(GNT_WIDGET(item->submenu)); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14883
diff
changeset
|
14 parent_class->dispose(obj); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 gnt_menuitem_class_init(GntMenuItemClass *klass) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14883
diff
changeset
|
20 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14883
diff
changeset
|
21 parent_class = g_type_class_peek_parent(klass); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14883
diff
changeset
|
23 obj_class->dispose = gnt_menuitem_destroy; |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 gnt_menuitem_init(GTypeInstance *instance, gpointer class) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 /****************************************************************************** |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 * GntMenuItem API |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 *****************************************************************************/ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 GType |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 gnt_menuitem_get_gtype(void) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 static GType type = 0; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 if(type == 0) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 static const GTypeInfo info = { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 sizeof(GntMenuItemClass), |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 NULL, /* base_init */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 NULL, /* base_finalize */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 (GClassInitFunc)gnt_menuitem_class_init, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 NULL, /* class_finalize */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 NULL, /* class_data */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 sizeof(GntMenuItem), |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 0, /* n_preallocs */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 gnt_menuitem_init, /* instance_init */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 }; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 type = g_type_register_static(G_TYPE_OBJECT, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 "GntMenuItem", |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 &info, 0); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 return type; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
61 GntMenuItem *gnt_menuitem_new(const char *text) |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 GObject *item = g_object_new(GNT_TYPE_MENUITEM, NULL); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 GntMenuItem *menuitem = GNT_MENUITEM(item); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 menuitem->text = g_strdup(text); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
68 return menuitem; |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 item->callback = callback; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 item->callbackdata = data; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 { |
14883
c8cd118653fc
[gaim-migrate @ 17652]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14616
diff
changeset
|
79 if (item->submenu) |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14883
diff
changeset
|
80 gnt_widget_destroy(GNT_WIDGET(item->submenu)); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 item->submenu = menu; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 |