changeset 17722:15988e2bd270

Mostly whitespace changes. Look for the rebinding-window in the class, instead of going over to the field and asking everyone about it.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 08 Jun 2007 05:43:29 +0000
parents 3ee6ea8a66f8
children c918d59d5936
files finch/libgnt/gntbindable.c finch/libgnt/gntwm.c
diffstat 2 files changed, 32 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntbindable.c	Fri Jun 08 04:14:56 2007 +0000
+++ b/finch/libgnt/gntbindable.c	Fri Jun 08 05:43:29 2007 +0000
@@ -65,15 +65,15 @@
 gnt_bindable_rebinding_rebind(GntBindable *bindable, gpointer data)
 {
 
-	if(rebind_info.keys){
+	if(rebind_info.keys) {
 		gnt_bindable_register_binding(rebind_info.klass,
-																	NULL,
-																	rebind_info.okeys,
-																	rebind_info.params);
+				NULL,
+				rebind_info.okeys,
+				rebind_info.params);
 		gnt_bindable_register_binding(rebind_info.klass,
-																	rebind_info.name,
-																	rebind_info.keys,
-																	rebind_info.params);
+				rebind_info.name,
+				rebind_info.keys,
+				rebind_info.params);
 	}
 	gnt_bindable_free_rebind_info();
 
@@ -189,8 +189,8 @@
 }
 
 typedef struct {
-GHashTable *hash;
-GntTree *tree;
+	GHashTable *hash;
+	GntTree *tree;
 } BindingView;
 
 static void
@@ -211,13 +211,10 @@
 static void
 add_action(gpointer key, gpointer value, gpointer data)
 {
-BindingView *bv = data;
-g_hash_table_insert(bv->hash, value, key);
+	BindingView *bv = data;
+	g_hash_table_insert(bv->hash, value, key);
 }
 
-
-
-				
 static void
 gnt_bindable_class_init(GntBindableClass *klass)
 {
@@ -462,6 +459,12 @@
 	return tree;
 }
 
+static void
+reset_binding_window(GntBindableClass *klass)
+{
+	klass->help_window = NULL;
+}
+
 gboolean
 gnt_bindable_build_help_window(GntBindable *bindable)
 {
@@ -471,20 +474,20 @@
 	char *title;
 
 	tree = GNT_WIDGET(gnt_bindable_bindings_view(bindable));
-	g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(gnt_bindable_rebinding_activate), bindable);
-	
+
 	klass->help_window = GNT_BINDABLE(gnt_window_new());
 	title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(bindable)));
 	gnt_box_set_title(GNT_BOX(klass->help_window), title);
-	if (tree)
+	if (tree) {
+		g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(gnt_bindable_rebinding_activate), bindable);
 		gnt_box_add_widget(GNT_BOX(klass->help_window), tree);
-	else
+	} else
 		gnt_box_add_widget(GNT_BOX(klass->help_window), gnt_label_new("This widget has no customizable bindings."));
 
+	g_signal_connect(G_OBJECT(klass->help_window), "destroy", G_CALLBACK(reset_binding_window), klass);
 	gnt_widget_show(GNT_WIDGET(klass->help_window));
+	g_free(title);
 
 	return TRUE;
-
 }
 
-
--- a/finch/libgnt/gntwm.c	Fri Jun 08 04:14:56 2007 +0000
+++ b/finch/libgnt/gntwm.c	Fri Jun 08 05:43:29 2007 +0000
@@ -1016,7 +1016,8 @@
 }
 
 static gboolean
-ignore_keys_start(GntBindable *bindable, GList *n){
+ignore_keys_start(GntBindable *bindable, GList *n)
+{
 	GntWM *wm = GNT_WM(bindable);
 
 	if(!wm->menu && !wm->_list.window && wm->mode == GNT_KP_MODE_NORMAL){
@@ -1027,38 +1028,22 @@
 }
 
 static gboolean
-ignore_keys_end(GntBindable *bindable, GList *n){
-	return ignore_keys ? !(ignore_keys = FALSE) : FALSE;
-}
-
-static GntBox *
-check_for_window_exist(GntWM *wm, const char *title)
+ignore_keys_end(GntBindable *bindable, GList *n)
 {
-	GList *iter;
-	for(iter = wm->list;iter;iter = iter->next){
-		GntBox *box = GNT_BOX(iter->data);
-		if(!strcmp(box->title,title))
-			return box;
-	}
-	return NULL;
+	return ignore_keys ? !(ignore_keys = FALSE) : FALSE;
 }
 
 static gboolean
 help_for_bindable(GntWM *wm, GntBindable *bindable)
 {
-	GntBox *box;
-	char * title;
 	gboolean ret = TRUE;
+	GntBindableClass *klass = GNT_BINDABLE_GET_CLASS(bindable);
  
-	title = g_strdup_printf("Bindings for %s",g_type_name(G_OBJECT_TYPE(bindable)));
-
-	if((box = check_for_window_exist(wm,title))){
-		gnt_wm_raise_window(wm,GNT_WIDGET(box));
-	}
-	else{
+	if (klass->help_window) {
+		gnt_wm_raise_window(wm, GNT_WIDGET(klass->help_window));
+	} else {
 		ret =  gnt_bindable_build_help_window(bindable);
 	}
-	g_free(title);
 	return ret;
 
 }
@@ -1082,7 +1067,7 @@
 	if (!GNT_IS_BOX(widget))
 		return TRUE;
 
-	return help_for_bindable(wm,GNT_BINDABLE(GNT_BOX(widget)->active));
+	return help_for_bindable(wm, GNT_BINDABLE(GNT_BOX(widget)->active));
 
 }