changeset 17925:85c6b51d3085

Refactored common code from help_for_widget and help_for_wm. Cleaned up a few const for allocated memory.
author Eric Polino <aluink@pidgin.im>
date Tue, 05 Jun 2007 23:35:26 +0000
parents 1abacdef8205
children 57c508361cff
files finch/libgnt/gntwm.c
diffstat 1 files changed, 28 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntwm.c	Tue Jun 05 19:59:14 2007 +0000
+++ b/finch/libgnt/gntwm.c	Tue Jun 05 23:35:26 2007 +0000
@@ -63,9 +63,9 @@
 
 typedef struct
 {
-	const char * keys; /* Keystrokes being bound to the action */
+	char * keys; /* Keystrokes being bound to the action */
 	GntBindableClass * klass; /* Class of the object that's getting keys rebound */
-	const char * name; /* The name of the action */
+	char * name; /* The name of the action */
 	GList * params; /* The list of paramaters */
 	
 } RebindInfo;
@@ -638,25 +638,16 @@
 }
 
 static gboolean
-help_for_widget(GntBindable *bindable, GList *null)
-{
-	GntWM *wm = GNT_WM(bindable);
-	GntWidget *widget, *tree, *win, *active;
+build_help_window(GntWidget *widget){
+
+	GntWidget *tree,*win;
 	char *title;
 
-	if (!wm->ordered)
-		return TRUE;
-
-	widget = wm->ordered->data;
-	if (!GNT_IS_BOX(widget))
-		return TRUE;
-	active = GNT_BOX(widget)->active;
-
-	tree = gnt_widget_bindings_view(active);
-	g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(help_for_widget_activate), active);
+	tree = gnt_widget_bindings_view(widget);
+	g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(help_for_widget_activate), widget);
 
 	win = gnt_window_new();
-	title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(active)));
+	title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(widget)));
 	gnt_box_set_title(GNT_BOX(win), title);
 	if (tree)
 		gnt_box_add_widget(GNT_BOX(win), tree);
@@ -666,29 +657,31 @@
 	gnt_widget_show(win);
 
 	return TRUE;
+
+}
+
+static gboolean
+help_for_widget(GntBindable *bindable, GList *null)
+{
+	GntWM *wm = GNT_WM(bindable);
+	GntWidget *widget;
+
+	if (!wm->ordered)
+		return TRUE;
+
+	widget = wm->ordered->data;
+	if (!GNT_IS_BOX(widget))
+		return TRUE;
+	
+	return build_help_window(GNT_BOX(widget)->active);
+
+
 }
 
 static gboolean
 help_for_wm(GntBindable *bindable, GList *null){
-	GntWM *wm = GNT_WM(bindable);
-	GntWidget *widget, *tree, *win;
-	char *title;
 
-	tree = gnt_widget_bindings_view(GNT_WIDGET(wm));
-
-	g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(help_for_widget_activate), wm);
-
-	win = gnt_window_new();
-	title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(wm)));
-	gnt_box_set_title(GNT_BOX(win), title);
-	if (tree)
-		gnt_box_add_widget(GNT_BOX(win), tree);
-	else
-		gnt_box_add_widget(GNT_BOX(win), gnt_label_new("This widget has no customizable bindings."));
-
-	gnt_widget_show(win);
-
-	return TRUE;
+	return build_help_window(GNT_WIDGET(bindable));
 
 }