pidgin: fc7c355a: Allow rebinding the key to show the drop...

sadrul at pidgin.im sadrul at pidgin.im
Tue Jun 15 15:06:01 EDT 2010


-----------------------------------------------------------------
Revision: fc7c355ab0d2fb25d82bfd4e3847128276915e28
Ancestor: d7d35b64d7c7663c0332d9995109dbd7b12c7f11
Author: sadrul at pidgin.im
Date: 2010-06-15T17:12:48
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/fc7c355ab0d2fb25d82bfd4e3847128276915e28

Modified files:
        ChangeLog doc/finch.1.in finch/libgnt/gntcombobox.c

ChangeLog: 

Allow rebinding the key to show the dropdown menu for comboboxes.

-------------- next part --------------
============================================================
--- ChangeLog	51b7dd202fd70cfb8cefc6e5e69129b60287aa9c
+++ ChangeLog	028fe3743148f69496e4bd22dad8c6a8864e4763
@@ -8,8 +8,10 @@ version 2.7.2 (??/??/????):
 	* Re-focus the input area after clicking the attention toolbar button.
 
 	Finch:
-	* Rebindable suggest-next-page and suggest-prev-page actions for
+	* Rebindable 'suggest-next-page' and 'suggest-prev-page' actions for
 	  textboxes (GntEntry) to scroll through list of suggestions.
+	* Rebindable 'dropdown' action for comboboxes (GntComboBox) to show the
+	  dropdown list of options.
 
 	XMPP:
 	* Allow connecting to servers that only advertise GSSAPI and expect
============================================================
--- doc/finch.1.in	8f2c8c40b918e1237aa63b21eed903882c8e5f16
+++ doc/finch.1.in	86570e8d57dc1b436616e1b84ce97d15bdc9f58a
@@ -305,6 +305,13 @@ left = focus-prev
 left = focus-prev
 
 .br
+[GntComboBox::binding]
+.br
+down = dropdown
+.br
+up = dropdown
+
+.br
 [GntEntry::binding]
 .br
 c-a = cursor-home
============================================================
--- finch/libgnt/gntcombobox.c	6ea4ab3db35c312f0ea8039b41886a2d6c995951
+++ finch/libgnt/gntcombobox.c	5eb790b149b6444fcb4e1647617135e9c0588145
@@ -25,6 +25,7 @@
 #include "gntcombobox.h"
 #include "gnttree.h"
 #include "gntmarshal.h"
+#include "gntstyle.h"
 #include "gntutils.h"
 
 #include <string.h>
@@ -168,18 +169,6 @@ gnt_combo_box_key_pressed(GntWidget *wid
 		if (gnt_widget_key_pressed(box->dropdown, text))
 			return TRUE;
 	}
-	else
-	{
-		if (text[0] == 27)
-		{
-			if (strcmp(text, GNT_KEY_UP) == 0 ||
-					strcmp(text, GNT_KEY_DOWN) == 0)
-			{
-				popup_dropdown(box);
-				return TRUE;
-			}
-		}
-	}
 
 	return FALSE;
 }
@@ -229,9 +218,20 @@ gnt_combo_box_size_changed(GntWidget *wi
 	gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height);
 }
 
+static gboolean
+dropdown_menu(GntBindable *b, GList *null)
+{
+	if (GNT_WIDGET_IS_FLAG_SET(GNT_COMBO_BOX(b)->dropdown->parent, GNT_WIDGET_MAPPED))
+		return FALSE;
+	popup_dropdown(GNT_COMBO_BOX(b));
+	return TRUE;
+}
+
 static void
 gnt_combo_box_class_init(GntComboBoxClass *klass)
 {
+	GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
+
 	parent_class = GNT_WIDGET_CLASS(klass);
 
 	parent_class->destroy = gnt_combo_box_destroy;
@@ -245,7 +245,7 @@ gnt_combo_box_class_init(GntComboBoxClas
 	widget_lost_focus = parent_class->lost_focus;
 	parent_class->lost_focus = gnt_combo_box_lost_focus;
 
-	signals[SIG_SELECTION_CHANGED] = 
+	signals[SIG_SELECTION_CHANGED] =
 		g_signal_new("selection-changed",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -254,6 +254,12 @@ gnt_combo_box_class_init(GntComboBoxClas
 					 gnt_closure_marshal_VOID__POINTER_POINTER,
 					 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
 
+	gnt_bindable_class_register_action(bindable, "dropdown", dropdown_menu,
+			GNT_KEY_DOWN, NULL);
+	gnt_bindable_register_binding(bindable, "dropdown", GNT_KEY_UP, NULL);
+
+	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
+
 	GNTDEBUG;
 }
 
@@ -272,7 +278,7 @@ gnt_combo_box_init(GTypeInstance *instan
 	GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT);
 	gnt_box_set_pad(GNT_BOX(box), 0);
 	gnt_box_add_widget(GNT_BOX(box), combo->dropdown);
-	
+
 	widget->priv.minw = 4;
 	widget->priv.minh = 3;
 	GNTDEBUG;


More information about the Commits mailing list