pidgin: e9363e30: Make the combobox a tiny bit friendlier.

sadrul at pidgin.im sadrul at pidgin.im
Mon Jul 5 11:03:46 EDT 2010


----------------------------------------------------------------------
Revision: e9363e30ba5a1c8546cada146cb3670926a89674
Parent:   1fffc4e22ae02e60efdb045e11841769fa2bf063
Author:   sadrul at pidgin.im
Date:     07/05/10 11:01:56
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e9363e30ba5a1c8546cada146cb3670926a89674

Changelog: 

Make the combobox a tiny bit friendlier.

Pressing the first letter of an item will now jump to that item (and
popup the dropdown first if necessary). Add some API in libgnt in the
process.

Changes against parent 1fffc4e22ae02e60efdb045e11841769fa2bf063

  patched  ChangeLog.API
  patched  configure.ac
  patched  finch/libgnt/configure.ac
  patched  finch/libgnt/gntcombobox.c
  patched  finch/libgnt/gnttree.c
  patched  finch/libgnt/gnttree.h

-------------- next part --------------
============================================================
--- configure.ac	33ec0e7e1dab4bf9eb143dff0cd9b219f4634f32
+++ configure.ac	13c79283f02c76407e0fb381eaec5f0eaf9b54db
@@ -52,10 +52,10 @@ m4_define([purple_display_version], purp
           [purple_major_version.purple_minor_version.purple_micro_version])
 m4_define([purple_display_version], purple_version[]m4_ifdef([purple_version_suffix],[purple_version_suffix]))
 
-m4_define([gnt_lt_current], [7])
+m4_define([gnt_lt_current], [8])
 m4_define([gnt_major_version], [2])
-m4_define([gnt_minor_version], [7])
-m4_define([gnt_micro_version], [2])
+m4_define([gnt_minor_version], [8])
+m4_define([gnt_micro_version], [0])
 m4_define([gnt_version_suffix], [devel])
 m4_define([gnt_version],
           [gnt_major_version.gnt_minor_version.gnt_micro_version])
============================================================
--- ChangeLog.API	634ca71057bc5f56eb91b4cdf58217be4d7db2bc
+++ ChangeLog.API	ad4d2158b18809b9627b9f0d5c87003b305c9d42
@@ -6,6 +6,7 @@ version 2.7.2 (??/??/????):
 		* purple_account_[gs]et_public_alias no longer crash when
 		  called for a protocol that doesn't support the underlying
 		  calls and the caller does not specify a failure callback.
+
 	Pidgin:
 		Changed:
 		* Changing the visibility (gtk_widget_hide/show) of
@@ -13,6 +14,12 @@ version 2.7.2 (??/??/????):
 		  the visibility of the entries in the 'lean' view
 		  (the default toolbar view).
 
+	libgnt:
+		Added:
+		* gnt_tree_row_get_key, gnt_tree_row_get_next,
+		  gnt_tree_row_get_prev, gnt_tree_row_get_child and
+		  gnt_tree_row_get_parent.
+
 version 2.7.1 (05/29/2010):
 	* No changes
 
============================================================
--- finch/libgnt/gnttree.c	9a67dd86759ceb0b59bb05db653b8cf76911d9e2
+++ finch/libgnt/gnttree.c	40a9fe05c0da9243dc7f5cf3d807532e0dd008c5
@@ -1926,3 +1926,33 @@ gpointer gnt_tree_get_parent_key(GntTree
 	return (row && row->parent) ? row->parent->key : NULL;
 }
 
+gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->key;
+}
+
+GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->next;
+}
+
+GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->prev;
+}
+
+GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->child;
+}
+
+GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->parent;
+}
+
============================================================
--- finch/libgnt/gnttree.h	d745133267692bbbff436aae9cac1b6e25049161
+++ finch/libgnt/gnttree.h	110d428b05032d351b156e55cf10016f5bb0c40a
@@ -222,6 +222,61 @@ GList * gnt_tree_get_row_text_list(GntTr
 GList * gnt_tree_get_row_text_list(GntTree *tree, gpointer key);
 
 /**
+ * Get the key of a row.
+ *
+ * @param tree   The tree
+ * @param row    The GntTreeRow object
+ *
+ * @return The key of the row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the next row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The next row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the previous row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The previous row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the child row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The child row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the parent row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The parent row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row);
+
+/**
  * Get a list of text of the current row.
  *
  * @param tree  The tree
============================================================
--- finch/libgnt/configure.ac	58e07786572c6f190bd0116cb5e16ee37a800121
+++ finch/libgnt/configure.ac	25dde2449e2b39807547ca72fef495179ae995ff
@@ -24,9 +24,9 @@ AC_PREREQ([2.50])
 # Make sure to update ../../configure.ac with libgnt version changes.
 #
 
-m4_define([gnt_lt_current], [7])
+m4_define([gnt_lt_current], [8])
 m4_define([gnt_major_version], [2])
-m4_define([gnt_minor_version], [7])
+m4_define([gnt_minor_version], [8])
 m4_define([gnt_micro_version], [0])
 m4_define([gnt_version_suffix], [devel])
 m4_define([gnt_version],
============================================================
--- finch/libgnt/gntcombobox.c	99d6791e47a44852d6c5734f18f492fc7cad11fa
+++ finch/libgnt/gntcombobox.c	c874fe05cb0d0f7d5244a912d4f2ee8f30a64341
@@ -150,7 +150,9 @@ gnt_combo_box_key_pressed(GntWidget *wid
 gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
 {
 	GntComboBox *box = GNT_COMBO_BOX(widget);
-	if (GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED)) {
+	gboolean showing = !!GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED);
+
+	if (showing) {
 		if (text[1] == 0) {
 			switch (text[0]) {
 				case '\r':
@@ -166,11 +168,41 @@ gnt_combo_box_key_pressed(GntWidget *wid
 	}
 
 	if (gnt_widget_key_pressed(box->dropdown, text)) {
-		if (!GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED))
+		if (!showing)
 			popup_dropdown(box);
 		return TRUE;
 	}
 
+	{
+#define SEARCH_IN_RANGE(start, end) do { \
+		GntTreeRow *row; \
+		for (row = start; row != end; \
+				row = gnt_tree_row_get_next(tree, row)) { \
+			gpointer key = gnt_tree_row_get_key(tree, row); \
+			GList *list = gnt_tree_get_row_text_list(tree, key); \
+			gboolean found = FALSE; \
+			found = (list->data && g_ascii_strncasecmp(text, list->data, len) == 0); \
+			g_list_foreach(list, (GFunc)g_free, NULL); \
+			g_list_free(list); \
+			if (found) { \
+				if (!showing) \
+					popup_dropdown(box); \
+				gnt_tree_set_selected(tree, key); \
+				return TRUE; \
+			} \
+		} \
+} while (0)
+
+		int len = strlen(text);
+		GntTree *tree = GNT_TREE(box->dropdown);
+		GntTreeRow *current = tree->current;
+
+		SEARCH_IN_RANGE(gnt_tree_row_get_next(tree, current), NULL);
+		SEARCH_IN_RANGE(tree->top, current);
+
+#undef SEARCH_IN_RANGE
+	}
+
 	return FALSE;
 }
 


More information about the Commits mailing list