Mercurial > pidgin
annotate finch/libgnt/gntmenuitem.c @ 22303:1097406c8f6c
In msimprpl, change to patch from Jaywalker regarding setting
usernames:
If they choose "No", the protocol will not allow them to log in,
so therefore we have to disconnect. The newest patch I added fixes it.
I also made some minor fixes and general cleanup. Improves on #2844.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 16 Feb 2008 20:49:20 +0000 |
parents | e8b0f224483f |
children | 88d889b54df4 |
rev | line source |
---|---|
17928
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
1 /** |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
3 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
6 * source distribution. |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
7 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
11 * (at your option) any later version. |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
12 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
16 * GNU General Public License for more details. |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
17 * |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18440
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
17928
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
21 */ |
8410511f4dbb
applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents:
15928
diff
changeset
|
22 |
15817 | 23 #include "gntmenu.h" |
24 #include "gntmenuitem.h" | |
25 | |
21256
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
26 enum |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
27 { |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
28 SIG_ACTIVATE, |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
29 SIGS |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
30 }; |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
31 static guint signals[SIGS] = { 0 }; |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
32 |
15817 | 33 static GObjectClass *parent_class = NULL; |
34 | |
35 static void | |
36 gnt_menuitem_destroy(GObject *obj) | |
37 { | |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
38 GntMenuItem *item = GNT_MENU_ITEM(obj); |
15817 | 39 g_free(item->text); |
40 item->text = NULL; | |
41 if (item->submenu) | |
42 gnt_widget_destroy(GNT_WIDGET(item->submenu)); | |
21212
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
43 g_free(item->priv.id); |
15817 | 44 parent_class->dispose(obj); |
45 } | |
46 | |
47 static void | |
48 gnt_menuitem_class_init(GntMenuItemClass *klass) | |
49 { | |
50 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | |
51 parent_class = g_type_class_peek_parent(klass); | |
52 | |
53 obj_class->dispose = gnt_menuitem_destroy; | |
21256
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
54 |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
55 signals[SIG_ACTIVATE] = |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
56 g_signal_new("activate", |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
57 G_TYPE_FROM_CLASS(klass), |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
58 G_SIGNAL_RUN_LAST, |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
59 0, NULL, NULL, |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
60 g_cclosure_marshal_VOID__VOID, |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
61 G_TYPE_NONE, 0); |
15817 | 62 } |
63 | |
64 static void | |
21256
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
65 gnt_menuitem_init(GTypeInstance *instance, gpointer klass) |
15817 | 66 { |
67 } | |
68 | |
69 /****************************************************************************** | |
70 * GntMenuItem API | |
71 *****************************************************************************/ | |
72 GType | |
73 gnt_menuitem_get_gtype(void) | |
74 { | |
75 static GType type = 0; | |
76 | |
77 if(type == 0) | |
78 { | |
79 static const GTypeInfo info = { | |
80 sizeof(GntMenuItemClass), | |
81 NULL, /* base_init */ | |
82 NULL, /* base_finalize */ | |
83 (GClassInitFunc)gnt_menuitem_class_init, | |
84 NULL, /* class_finalize */ | |
85 NULL, /* class_data */ | |
86 sizeof(GntMenuItem), | |
87 0, /* n_preallocs */ | |
88 gnt_menuitem_init, /* instance_init */ | |
89 NULL /* value_table */ | |
90 }; | |
91 | |
92 type = g_type_register_static(G_TYPE_OBJECT, | |
93 "GntMenuItem", | |
94 &info, 0); | |
95 } | |
96 | |
97 return type; | |
98 } | |
99 | |
100 GntMenuItem *gnt_menuitem_new(const char *text) | |
101 { | |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
102 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
|
103 GntMenuItem *menuitem = GNT_MENU_ITEM(item); |
15817 | 104 |
105 menuitem->text = g_strdup(text); | |
106 | |
107 return menuitem; | |
108 } | |
109 | |
110 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data) | |
111 { | |
112 item->callback = callback; | |
113 item->callbackdata = data; | |
114 } | |
115 | |
116 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu) | |
117 { | |
118 if (item->submenu) | |
119 gnt_widget_destroy(GNT_WIDGET(item->submenu)); | |
120 item->submenu = menu; | |
121 } | |
122 | |
21212
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
123 GntMenu *gnt_menuitem_get_submenu(GntMenuItem *item) |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
124 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
125 return item->submenu; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
126 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
127 |
18440
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
128 void gnt_menuitem_set_trigger(GntMenuItem *item, char trigger) |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
129 { |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
130 item->priv.trigger = trigger; |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
131 } |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
132 |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
133 char gnt_menuitem_get_trigger(GntMenuItem *item) |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
134 { |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
135 return item->priv.trigger; |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
136 } |
be10fc22d649
Allow trigger keys for menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17928
diff
changeset
|
137 |
21212
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
138 void gnt_menuitem_set_id(GntMenuItem *item, const char *id) |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
139 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
140 g_free(item->priv.id); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
141 item->priv.id = g_strdup(id); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
142 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
143 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
144 const char * gnt_menuitem_get_id(GntMenuItem *item) |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
145 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
146 return item->priv.id; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
147 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
148 |
21256
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
149 gboolean gnt_menuitem_activate(GntMenuItem *item) |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
150 { |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
151 g_signal_emit(item, signals[SIG_ACTIVATE], 0); |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
152 if (item->callback) { |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
153 item->callback(item, item->callbackdata); |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
154 return TRUE; |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
155 } |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
156 return FALSE; |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
157 } |
e8b0f224483f
Add gnt_menuitem_activate, and 'activate' signal for GntMenuItem.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
158 |