annotate console/libgnt/gntmenuitem.c @ 14883:c8cd118653fc

[gaim-migrate @ 17652] Add a 'Plugins' item in the buddylist menu (ctrl-o). committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 02 Nov 2006 00:18:34 +0000
parents f1f1dcb26d89
children 065e7ac30338
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 }
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 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 gnt_menuitem_class_init(GntMenuItemClass *klass)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 parent_class = G_OBJECT_CLASS(klass);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 parent_class->dispose = gnt_menuitem_destroy;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 gnt_menuitem_init(GTypeInstance *instance, gpointer class)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 }
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 * GntMenuItem API
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 GType
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 gnt_menuitem_get_gtype(void)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 static GType type = 0;
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 if(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 static const GTypeInfo info = {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 sizeof(GntMenuItemClass),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 NULL, /* base_init */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 NULL, /* base_finalize */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 (GClassInitFunc)gnt_menuitem_class_init,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 NULL, /* class_finalize */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 NULL, /* class_data */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 sizeof(GntMenuItem),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 0, /* n_preallocs */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 gnt_menuitem_init, /* instance_init */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 };
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 type = g_type_register_static(G_TYPE_OBJECT,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 "GntMenuItem",
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 &info, 0);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 return type;
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
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
59 GntMenuItem *gnt_menuitem_new(const char *text)
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 GObject *item = g_object_new(GNT_TYPE_MENUITEM, NULL);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 GntMenuItem *menuitem = GNT_MENUITEM(item);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 menuitem->text = g_strdup(text);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
66 return menuitem;
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data)
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 item->callback = callback;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 item->callbackdata = data;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 {
14883
c8cd118653fc [gaim-migrate @ 17652]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14616
diff changeset
77 if (item->submenu)
c8cd118653fc [gaim-migrate @ 17652]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14616
diff changeset
78 gnt_widget_destroy(item->submenu);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 item->submenu = menu;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81