From 5027f2008badcb8d8056190dac1403335754f202 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 11 Jan 2002 07:24:08 +0000 Subject: Handle setting the search bar to "Advanced..." when the alphabet buttons 2002-01-11 Christopher James Lahey * gui/component/addressbook.c (alphabet_state_changed): Handle setting the search bar to "Advanced..." when the alphabet buttons are pushed and back when they're cleared. Fixes Ximian bug #12904. (addressbook_menu_activated): When the user calls Search->clear, set the search to ESB_ANY and "", don't just set the text. This is especially useful when it's set to ESB_ADVANCED. * gui/widgets/e-addressbook-view.c, gui/widgets/e-addressbook-view.h (alphabet_state_change): Added this signal which gets emitted when the alphabet buttons are pushed. (command_state_change): Removed the ref pair here. It's not necessary. gtk_signal_emit refs the object itself. svn path=/trunk/; revision=15295 --- addressbook/gui/component/addressbook.c | 40 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'addressbook/gui/component') diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 619a89cdd5..38d44727ed 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -66,6 +66,7 @@ typedef struct { BonoboPropertyBag *properties; char *uri; char *passwd; + gboolean ignore_search_changes; } AddressbookView; static void addressbook_view_ref (AddressbookView *); @@ -813,24 +814,29 @@ static ESearchBarItem addressbook_search_option_items[] = { { NULL, -1, NULL } }; +static void +alphabet_state_changed (EAddressbookView *eav, gunichar letter, AddressbookView *view) +{ + view->ignore_search_changes = TRUE; + if (letter == 0) { + e_search_bar_set_item_id (view->search, ESB_ANY); + e_search_bar_set_text (view->search, ""); + } else { + e_search_bar_set_item_id (view->search, ESB_ADVANCED); + } + view->ignore_search_changes = FALSE; +} + static void addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view) { switch (id) { case E_FILTERBAR_RESET_ID: /* e_addressbook_view_show_all(view->view); */ - - /* Fix option menu if we are using "Category is" */ - if (e_search_bar_get_item_id (esb) == ESB_CATEGORY) { - - e_search_bar_set_subitem_id (esb, G_MAXINT); - - } else { - - e_search_bar_set_text (esb, ""); - - } - + view->ignore_search_changes = TRUE; + e_search_bar_set_item_id (view->search, ESB_ANY); + view->ignore_search_changes = FALSE; + e_search_bar_set_text (esb, ""); break; } } @@ -843,6 +849,10 @@ addressbook_query_changed (ESearchBar *esb, AddressbookView *view) const char *category_name; int search_type, subid; + if (view->ignore_search_changes) { + return; + } + gtk_object_get(GTK_OBJECT(esb), "text", &search_word, "item_id", &search_type, @@ -1070,6 +1080,7 @@ addressbook_factory_new_control (void) view = g_new0 (AddressbookView, 1); view->refs = 1; + view->ignore_search_changes = FALSE; view->vbox = gtk_vbox_new (FALSE, 0); @@ -1129,6 +1140,11 @@ addressbook_factory_new_control (void) GTK_SIGNAL_FUNC(update_command_state), view); + gtk_signal_connect (GTK_OBJECT (view->view), + "alphabet_state_change", + GTK_SIGNAL_FUNC(alphabet_state_changed), + view); + view->uri = NULL; gtk_signal_connect (GTK_OBJECT (view->control), "activate", -- cgit v1.2.3