Mercurial > pidgin
annotate finch/libgnt/gntmenuitem.c @ 19065:ebae00bbb57e
- Make a rudimentary information button in tls_peers_mgmt
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Wed, 01 Aug 2007 07:24:56 +0000 |
parents | be10fc22d649 |
children | 44b4e8bd759b |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15928
diff
changeset
|
22 |
15817 | 23 #include "gntmenu.h" |
24 #include "gntmenuitem.h" | |
25 | |
26 static GObjectClass *parent_class = NULL; | |
27 | |
28 static void | |
29 gnt_menuitem_destroy(GObject *obj) | |
30 { | |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
31 GntMenuItem *item = GNT_MENU_ITEM(obj); |
15817 | 32 g_free(item->text); |
33 item->text = NULL; | |
34 if (item->submenu) | |
35 gnt_widget_destroy(GNT_WIDGET(item->submenu)); | |
36 parent_class->dispose(obj); | |
37 } | |
38 | |
39 static void | |
40 gnt_menuitem_class_init(GntMenuItemClass *klass) | |
41 { | |
42 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | |
43 parent_class = g_type_class_peek_parent(klass); | |
44 | |
45 obj_class->dispose = gnt_menuitem_destroy; | |
46 } | |
47 | |
48 static void | |
49 gnt_menuitem_init(GTypeInstance *instance, gpointer class) | |
50 { | |
51 } | |
52 | |
53 /****************************************************************************** | |
54 * GntMenuItem API | |
55 *****************************************************************************/ | |
56 GType | |
57 gnt_menuitem_get_gtype(void) | |
58 { | |
59 static GType type = 0; | |
60 | |
61 if(type == 0) | |
62 { | |
63 static const GTypeInfo info = { | |
64 sizeof(GntMenuItemClass), | |
65 NULL, /* base_init */ | |
66 NULL, /* base_finalize */ | |
67 (GClassInitFunc)gnt_menuitem_class_init, | |
68 NULL, /* class_finalize */ | |
69 NULL, /* class_data */ | |
70 sizeof(GntMenuItem), | |
71 0, /* n_preallocs */ | |
72 gnt_menuitem_init, /* instance_init */ | |
73 NULL /* value_table */ | |
74 }; | |
75 | |
76 type = g_type_register_static(G_TYPE_OBJECT, | |
77 "GntMenuItem", | |
78 &info, 0); | |
79 } | |
80 | |
81 return type; | |
82 } | |
83 | |
84 GntMenuItem *gnt_menuitem_new(const char *text) | |
85 { | |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
86 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:
15817
diff
changeset
|
87 GntMenuItem *menuitem = GNT_MENU_ITEM(item); |
15817 | 88 |
89 menuitem->text = g_strdup(text); | |
90 | |
91 return menuitem; | |
92 } | |
93 | |
94 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data) | |
95 { | |
96 item->callback = callback; | |
97 item->callbackdata = data; | |
98 } | |
99 | |
100 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu) | |
101 { | |
102 if (item->submenu) | |
103 gnt_widget_destroy(GNT_WIDGET(item->submenu)); | |
104 item->submenu = menu; | |
105 } | |
106 | |
18440
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
107 void gnt_menuitem_set_trigger(GntMenuItem *item, char trigger) |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
108 { |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
109 item->priv.trigger = trigger; |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
110 } |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
111 |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
112 char gnt_menuitem_get_trigger(GntMenuItem *item) |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
113 { |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
114 return item->priv.trigger; |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
115 } |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18049
diff
changeset
|
116 |