diff options
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/ChangeLog | 11 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.c | 90 |
2 files changed, 58 insertions, 43 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 0b20ef91ab..c4e2f0d5ed 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,5 +1,16 @@ 2002-07-02 Ettore Perazzoli <ettore@ximian.com> + * e-search-bar.c (update_sensitivity): Removed. + (set_find_now_sensitive): New. + (entry_changed_cb): Always make the "Find Now" button and menu + item sensitive here. + (emit_search_activated): ...And here, always insensitive. + (setup_standard_verbs): Always start up insensitive. + (activate_button_clicked_cb): Make the entry grab the focus. + (clear_button_clicked_cb): Likewise. + +2002-07-02 Ettore Perazzoli <ettore@ximian.com> + * e-search-bar.c (subitem_activated_cb): Don't emit "search_activated" here. (e_search_bar_set_subitem_id): And not here either. diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c index 52df481f1b..ec7891f770 100644 --- a/widgets/misc/e-search-bar.c +++ b/widgets/misc/e-search-bar.c @@ -67,58 +67,27 @@ enum { }; -/* Signals. */ - -static void -emit_query_changed (ESearchBar *esb) -{ - gtk_signal_emit (GTK_OBJECT (esb), - esb_signals [QUERY_CHANGED]); -} +/* Forward decls. */ -static void -emit_search_activated (ESearchBar *esb) -{ - if (esb->pending_activate) { - gtk_idle_remove (esb->pending_activate); - esb->pending_activate = 0; - } - - gtk_signal_emit (GTK_OBJECT (esb), - esb_signals [SEARCH_ACTIVATED]); -} - -static void -emit_menu_activated (ESearchBar *esb, int item) -{ - gtk_signal_emit (GTK_OBJECT (esb), - esb_signals [MENU_ACTIVATED], - item); -} +static void emit_search_activated (ESearchBar *esb); /* Utility functions. */ static void -update_sensitivity (ESearchBar *search_bar) +set_find_now_sensitive (ESearchBar *search_bar, + gboolean sensitive) { const char *text; text = gtk_entry_get_text (GTK_ENTRY (search_bar->entry)); - if (text != NULL && text[0] != '\0') { - if (search_bar->ui_component != NULL) - bonobo_ui_component_set_prop (search_bar->ui_component, - "/commands/ESearchBar:FindNow", - "sensitive", "1", NULL); - gtk_widget_set_sensitive (search_bar->activate_button, TRUE); - } else { - if (search_bar->ui_component != NULL) - bonobo_ui_component_set_prop (search_bar->ui_component, - "/commands/ESearchBar:FindNow", - "sensitive", "0", NULL); - gtk_widget_set_sensitive (search_bar->activate_button, FALSE); - } + if (search_bar->ui_component != NULL) + bonobo_ui_component_set_prop (search_bar->ui_component, + "/commands/ESearchBar:FindNow", + "sensitive", sensitive ? "1" : "0", NULL); + + gtk_widget_set_sensitive (search_bar->activate_button, sensitive); } static char * @@ -178,6 +147,37 @@ free_menu_items (ESearchBar *esb) } +/* Signals. */ + +static void +emit_query_changed (ESearchBar *esb) +{ + gtk_signal_emit (GTK_OBJECT (esb), + esb_signals [QUERY_CHANGED]); +} + +static void +emit_search_activated (ESearchBar *esb) +{ + if (esb->pending_activate) { + gtk_idle_remove (esb->pending_activate); + esb->pending_activate = 0; + } + + gtk_signal_emit (GTK_OBJECT (esb), esb_signals [SEARCH_ACTIVATED]); + + set_find_now_sensitive (esb, FALSE); +} + +static void +emit_menu_activated (ESearchBar *esb, int item) +{ + gtk_signal_emit (GTK_OBJECT (esb), + esb_signals [MENU_ACTIVATED], + item); +} + + /* Callbacks -- Standard verbs. */ static void @@ -211,7 +211,7 @@ setup_standard_verbs (ESearchBar *search_bar) search_now_verb_cb, search_bar); /* Make sure the entries are created with the correct sensitivity. */ - update_sensitivity (search_bar); + set_find_now_sensitive (search_bar, FALSE); } /* Callbacks -- The verbs for all the definable items. */ @@ -245,7 +245,7 @@ static void entry_changed_cb (GtkWidget *widget, ESearchBar *esb) { - update_sensitivity (esb); + set_find_now_sensitive (esb, TRUE); } static void @@ -415,6 +415,8 @@ activate_button_clicked_cb (GtkWidget *widget, ESearchBar *esb) { emit_search_activated (esb); + + gtk_widget_grab_focus (esb->entry); } static void @@ -422,6 +424,8 @@ clear_button_clicked_cb (GtkWidget *widget, ESearchBar *esb) { clear_search (esb); + + gtk_widget_grab_focus (esb->entry); } |