Mercurial > pidgin.yaz
changeset 30673:e1b511df0d3e
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.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 05 Jul 2010 15:01:56 +0000 |
parents | 514ed776e193 |
children | 3fdb8ef0fec7 |
files | ChangeLog.API configure.ac finch/libgnt/configure.ac finch/libgnt/gntcombobox.c finch/libgnt/gnttree.c finch/libgnt/gnttree.h |
diffstat | 6 files changed, 131 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Mon Jul 05 15:00:36 2010 +0000 +++ b/ChangeLog.API Mon Jul 05 15:01:56 2010 +0000 @@ -6,6 +6,7 @@ * 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 @@ 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
--- a/configure.ac Mon Jul 05 15:00:36 2010 +0000 +++ b/configure.ac Mon Jul 05 15:01:56 2010 +0000 @@ -52,10 +52,10 @@ [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])
--- a/finch/libgnt/configure.ac Mon Jul 05 15:00:36 2010 +0000 +++ b/finch/libgnt/configure.ac Mon Jul 05 15:01:56 2010 +0000 @@ -24,9 +24,9 @@ # 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],
--- a/finch/libgnt/gntcombobox.c Mon Jul 05 15:00:36 2010 +0000 +++ b/finch/libgnt/gntcombobox.c Mon Jul 05 15:01:56 2010 +0000 @@ -150,7 +150,9 @@ 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 @@ } 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; }
--- a/finch/libgnt/gnttree.c Mon Jul 05 15:00:36 2010 +0000 +++ b/finch/libgnt/gnttree.c Mon Jul 05 15:01:56 2010 +0000 @@ -1926,3 +1926,33 @@ 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; +} +
--- a/finch/libgnt/gnttree.h Mon Jul 05 15:00:36 2010 +0000 +++ b/finch/libgnt/gnttree.h Mon Jul 05 15:01:56 2010 +0000 @@ -222,6 +222,61 @@ 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