Mercurial > pidgin.yaz
comparison finch/libgnt/gntutils.c @ 17721:3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Added: If a bindinglist already exists, it isn't brought up again.
Deprecated gnt_widget_bindings_view out of gntutils and moved it to gntbindable
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Fri, 08 Jun 2007 04:14:56 +0000 |
parents | 8410511f4dbb |
children | ac904659104f |
comparison
equal
deleted
inserted
replaced
17720:71df538ed27c | 17721:3ee6ea8a66f8 |
---|---|
28 #include "gntline.h" | 28 #include "gntline.h" |
29 #include "gnttextview.h" | 29 #include "gnttextview.h" |
30 #include "gnttree.h" | 30 #include "gnttree.h" |
31 #include "gntutils.h" | 31 #include "gntutils.h" |
32 #include "gntwindow.h" | 32 #include "gntwindow.h" |
33 #include "gntbindable.h" | |
33 | 34 |
34 #include "config.h" | 35 #include "config.h" |
35 | 36 |
36 #include <stdarg.h> | 37 #include <stdarg.h> |
37 #include <stdlib.h> | 38 #include <stdlib.h> |
182 continue_emission = !signal_handled; | 183 continue_emission = !signal_handled; |
183 | 184 |
184 return continue_emission; | 185 return continue_emission; |
185 } | 186 } |
186 | 187 |
187 typedef struct { | 188 |
188 GHashTable *hash; | 189 GntWidget * gnt_widget_bindings_view(GntWidget *widget){ |
189 GntTree *tree; | 190 return GNT_WIDGET(gnt_bindable_bindings_view(GNT_BINDABLE(widget))); |
190 } BindingView; | 191 } |
191 | 192 |
192 static void | 193 |
193 add_binding(gpointer key, gpointer value, gpointer data) | |
194 { | |
195 BindingView *bv = data; | |
196 GntBindableActionParam *act = value; | |
197 const char *name = g_hash_table_lookup(bv->hash, act->action); | |
198 if (name && *name) { | |
199 const char *k = gnt_key_lookup(key); | |
200 if (!k) | |
201 k = key; | |
202 gnt_tree_add_row_after(bv->tree, (gpointer)k, | |
203 gnt_tree_create_row(bv->tree, k, name), NULL, NULL); | |
204 } | |
205 } | |
206 | |
207 static void | |
208 add_action(gpointer key, gpointer value, gpointer data) | |
209 { | |
210 BindingView *bv = data; | |
211 g_hash_table_insert(bv->hash, value, key); | |
212 } | |
213 | |
214 GntWidget *gnt_widget_bindings_view(GntWidget *widget) | |
215 { | |
216 GntBindable *bind = GNT_BINDABLE(widget); | |
217 GntWidget *tree = gnt_tree_new_with_columns(2); | |
218 GntBindableClass *klass = GNT_BINDABLE_CLASS(GNT_BINDABLE_GET_CLASS(bind)); | |
219 GHashTable *hash = g_hash_table_new(g_direct_hash, g_direct_equal); | |
220 BindingView bv = {hash, GNT_TREE(tree)}; | |
221 | |
222 gnt_tree_set_compare_func(bv.tree, (GCompareFunc)g_utf8_collate); | |
223 g_hash_table_foreach(klass->actions, add_action, &bv); | |
224 g_hash_table_foreach(klass->bindings, add_binding, &bv); | |
225 if (GNT_TREE(tree)->list == NULL) { | |
226 gnt_widget_destroy(tree); | |
227 tree = NULL; | |
228 } else | |
229 gnt_tree_adjust_columns(bv.tree); | |
230 g_hash_table_destroy(hash); | |
231 | |
232 return tree; | |
233 } | |
234 | 194 |
235 #ifndef NO_LIBXML | 195 #ifndef NO_LIBXML |
236 static GntWidget * | 196 static GntWidget * |
237 gnt_widget_from_xmlnode(xmlNode *node, GntWidget **data[]) | 197 gnt_widget_from_xmlnode(xmlNode *node, GntWidget **data[]) |
238 { | 198 { |