diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-08-21 13:57:39 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-08-21 13:57:39 +0800 |
commit | a4b0eedd516cbbe651f36ea8e25259fe9f48df13 (patch) | |
tree | eb77d87bf1e97583c1aa58f5bbdc73894c543d62 /widgets | |
parent | e64e7f2d389061ad7454ea81957abac2bbdbf32e (diff) | |
download | gsoc2013-evolution-a4b0eedd516cbbe651f36ea8e25259fe9f48df13.tar.gz gsoc2013-evolution-a4b0eedd516cbbe651f36ea8e25259fe9f48df13.tar.zst gsoc2013-evolution-a4b0eedd516cbbe651f36ea8e25259fe9f48df13.zip |
fixes a lot of search issues.
svn path=/trunk/; revision=32605
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/ChangeLog | 12 | ||||
-rw-r--r-- | widgets/misc/e-filter-bar.c | 26 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.c | 108 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.h | 3 |
4 files changed, 109 insertions, 40 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 7809589164..99adcbd354 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,5 +1,17 @@ 2006-08-21 Srinivasa Ragavan <sragavan@novell.com> + * e-filter-bar.c: (rule_editor_destroyed), + (rule_advanced_response), (do_advanced), (save_search_dialog), + (menubar_activated), (option_changed), (set_property): + * e-search-bar.[ch]: (clear_search), (clear_verb_cb), + (paint_search_text), (entry_focus_out_cb), (entry_changed_cb), + (scopeoption_changed_cb), (set_option), (class_init), (init), + (e_search_bar_construct), (e_search_bar_set_scopeoption), + (e_search_bar_set_item_id), (e_search_bar_get_text), + (e_search_bar_scope_enable): Fixes a lot of search issue. + +2006-08-21 Srinivasa Ragavan <sragavan@novell.com> + ** Fix for bug 347430 * e-cell-date-edit.c: (e_cell_date_edit_update_cell): commit the text diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c index a67554b29a..363a0127ae 100644 --- a/widgets/misc/e-filter-bar.c +++ b/widgets/misc/e-filter-bar.c @@ -67,7 +67,6 @@ rule_editor_destroyed (EFilterBar *efb, GObject *deadbeef) { efb->save_dialog = NULL; e_search_bar_set_menu_sensitive (E_SEARCH_BAR (efb), E_FILTERBAR_SAVE_ID, TRUE); - gtk_widget_set_sensitive (E_SEARCH_BAR (efb)->entry, TRUE); } /* FIXME: need to update the popup menu to match any edited rules, sigh */ @@ -125,7 +124,10 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data) gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); - gtk_widget_show (esb->clear_button); + gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); + gtk_widget_modify_base (esb->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); + e_search_bar_set_text (esb,_("Advanced Search")); + gtk_widget_set_sensitive (esb->clear_button, TRUE); if (response == GTK_RESPONSE_APPLY) { if (!rule_context_find_rule (efb->context, rule->name, rule->source)) @@ -134,6 +136,8 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data) rule_context_save (efb->context, efb->userrules); } } + } else { + e_search_bar_set_item_id (esb, esb->last_search_option); } if (response != GTK_RESPONSE_APPLY) @@ -183,7 +187,6 @@ do_advanced (ESearchBar *esb) g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb); e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE); - gtk_widget_set_sensitive (esb->entry, FALSE); gtk_widget_show (dialog); } @@ -228,7 +231,6 @@ save_search_dialog (ESearchBar *esb) g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb); e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE); - gtk_widget_set_sensitive (esb->entry, FALSE); gtk_widget_show (dialog); } @@ -277,9 +279,7 @@ menubar_activated (ESearchBar *esb, int id, void *data) e_search_bar_set_item_id (esb, E_FILTERBAR_ADVANCED_ID); efb->setquery = FALSE; - gtk_widget_set_sensitive (esb->entry, FALSE); } else { - gtk_widget_set_sensitive (esb->entry, TRUE); return; } } @@ -316,12 +316,10 @@ option_changed (ESearchBar *esb, void *data) efb->config (efb, efb->current_query, id, query, efb->config_data); g_free (query); } - gtk_widget_set_sensitive (esb->entry, TRUE); } else { gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL); gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL); - - gtk_widget_set_sensitive (esb->entry, id == E_SEARCHBAR_CLEAR_ID); + gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL); efb->current_query = NULL; } } @@ -662,12 +660,15 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe rule = filter_rule_new (); if (filter_rule_xml_decode (rule, node, efb->context) != 0) { gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL); g_object_unref (rule); rule = NULL; } else { gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); + gtk_widget_modify_base (((ESearchBar *)efb)->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); g_object_set_data_full (object, "rule", rule, (GDestroyNotify) g_object_unref); } } @@ -690,9 +691,12 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe if (text && *text) { gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED])); + gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); + gtk_widget_modify_base (((ESearchBar *)efb)->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED])); } else { gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL); + gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL); } xmlFree (text); diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c index 7257c161d3..430b12aa2f 100644 --- a/widgets/misc/e-search-bar.c +++ b/widgets/misc/e-search-bar.c @@ -106,9 +106,11 @@ verb_name_from_id (int id) static void clear_search (ESearchBar *esb) { + if (esb->item_id < 0) + e_search_bar_set_item_id (esb, esb->last_search_option); + e_search_bar_set_text (esb, ""); e_search_bar_set_viewitem_id (esb, 0); - emit_search_activated (esb); } @@ -209,6 +211,7 @@ clear_verb_cb (BonoboUIComponent *ui_component, gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL); clear_search (esb); + gtk_widget_grab_focus (esb->entry); } static void @@ -286,30 +289,43 @@ entry_focus_in_cb (GtkWidget *widget, } static gboolean -entry_focus_out_cb (GtkWidget *widget, - GdkEventFocus *event, - ESearchBar *esb) +paint_search_text (GtkWidget *widget, ESearchBar *esb) { GtkStyle *style = gtk_widget_get_default_style (); const gchar *text = NULL; - - if (!GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu)))) - return FALSE; + GtkWidget *menu_widget = esb->option_menu; text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (!(text && *text)) { - /* no query in search entry .. so set the current option */ - text = get_selected_item_label (esb->option_menu); - if (text && *text) { - gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE])); - gtk_entry_set_text (GTK_ENTRY (esb->entry), text); - gtk_tooltips_set_tip (esb->tooltips, esb->option_button, text, "Search type"); - gtk_widget_hide (esb->clear_button); - } + if (text && *text) + return FALSE; + + if (!GTK_WIDGET_SENSITIVE (esb->option_button)) { + menu_widget = esb->scopeoption_menu; + text = g_object_get_data (gtk_menu_get_active ( GTK_MENU (esb->scopeoption_menu)),"string"); + } else if (!GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu)))) + return FALSE; + else /* no query in search entry .. so set the current option */ + text = get_selected_item_label (menu_widget); + + + if (text && *text) { + gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE])); + gtk_entry_set_text (GTK_ENTRY (esb->entry), text); + gtk_tooltips_set_tip (esb->tooltips, esb->option_button, text, "Search type"); + gtk_widget_set_sensitive (esb->clear_button, FALSE); } + return FALSE; } +static gboolean +entry_focus_out_cb (GtkWidget *widget, + GdkEventFocus *event, + ESearchBar *esb) +{ + return paint_search_text (widget, esb); +} + static void entry_activated_cb (GtkWidget *widget, ESearchBar *esb) @@ -343,11 +359,11 @@ entry_changed_cb (GtkWidget *widget, if (text && *text) if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) - gtk_widget_hide (esb->clear_button); + gtk_widget_set_sensitive (esb->clear_button, FALSE); else - gtk_widget_show (esb->clear_button); + gtk_widget_set_sensitive (esb->clear_button, TRUE); else - gtk_widget_hide (esb->clear_button); + gtk_widget_set_sensitive (esb->clear_button, FALSE); } static void @@ -468,6 +484,13 @@ clear_button_clicked_cb (GtkWidget *widget, GdkEventButton *event, static void scopeoption_changed_cb (GtkWidget *option_menu, ESearchBar *search_bar) { + const gchar *text = NULL; + GtkStyle *style = gtk_widget_get_default_style (); + + text = e_search_bar_get_text (search_bar); + if (!(text && *text)) + gtk_widget_grab_focus (search_bar->entry); + emit_query_changed (search_bar); } @@ -667,7 +690,7 @@ set_option (ESearchBar *esb, ESearchBarItem *items) } gtk_widget_show_all (menu); - + g_object_set_data (esb->option_menu, "group", group); entry_focus_out_cb (esb->entry, NULL, esb); } @@ -829,6 +852,14 @@ class_init (ESearchBarClass *klass) e_util_marshal_NONE__NONE, G_TYPE_NONE, 0); + esb_signals [SEARCH_CLEARED] = + g_signal_new ("search_cleared", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ESearchBarClass, search_cleared), + NULL, NULL, + e_util_marshal_NONE__NONE, + G_TYPE_NONE, 0); } static void @@ -856,6 +887,7 @@ init (ESearchBar *esb) esb->item_id = 0; esb->scopeitem_id = 0; + esb->last_search_option = 0; } @@ -912,7 +944,7 @@ e_search_bar_construct (ESearchBar *search_bar, gtk_box_pack_start (GTK_BOX(search_bar->entry_box), search_bar->icon_entry, FALSE, FALSE, 0); gtk_widget_show_all (search_bar->entry_box); - gtk_widget_hide (search_bar->clear_button); + gtk_widget_set_sensitive (search_bar->clear_button, FALSE); /* Current View filter */ search_bar->viewoption_box = gtk_hbox_new (0, FALSE); @@ -1130,7 +1162,7 @@ e_search_bar_set_scopeoption (ESearchBar *search_bar, ESearchBarItem *scopeitems char *str; str = string_without_underscores (scopeitems[i].text); menu_item = gtk_menu_item_new_with_label (str); - g_free (str); + g_object_set_data_full (G_OBJECT (menu_item), "string",str, g_free); } else { menu_item = gtk_menu_item_new (); gtk_widget_set_sensitive (menu_item, FALSE); @@ -1150,7 +1182,6 @@ e_search_bar_set_scopeoption (ESearchBar *search_bar, ESearchBarItem *scopeitems gtk_option_menu_set_menu (GTK_OPTION_MENU (search_bar->scopeoption), menu); } - /** * e_search_bar_set_scopeoption_menu: * @search_bar: A search bar. @@ -1281,7 +1312,9 @@ e_search_bar_set_item_id (ESearchBar *search_bar, int id) row = find_id (search_bar->option_menu, id, "EsbItemId", NULL); g_return_if_fail (row != -1); - + + if (id>=0) + search_bar->last_search_option = id; search_bar->item_id = id; gtk_menu_set_active (search_bar->option_menu, row); @@ -1450,10 +1483,29 @@ e_search_bar_get_text (ESearchBar *search_bar) entry_style = gtk_widget_get_style (search_bar->entry); default_style = gtk_widget_get_default_style (); - if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) { - gtk_entry_set_text (GTK_ENTRY (search_bar->entry), ""); - gtk_widget_modify_text (search_bar->entry, GTK_STATE_NORMAL, NULL); - } + if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) + return g_strdup (""); return g_strdup (gtk_entry_get_text (GTK_ENTRY (search_bar->entry))); } + +void e_search_bar_scope_enable (ESearchBar *esb, int did, gboolean state) +{ + GtkWidget *widget=NULL; + GList *l = GTK_MENU_SHELL (esb->scopeoption_menu)->children; + int row = -1, i = 0, id; + + while (l) { + id = GPOINTER_TO_INT (g_object_get_data (l->data, "EsbItemId")); + if (id == did) { + row = i; + widget = l->data; + break; + } + i++; + l = l->next; + } + + if (widget) + gtk_widget_set_sensitive (widget, state); +} diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h index 3cb8af0d96..3693b8055d 100644 --- a/widgets/misc/e-search-bar.h +++ b/widgets/misc/e-search-bar.h @@ -100,6 +100,7 @@ struct _ESearchBar int item_id; int viewitem_id; /* Current View Id */ int scopeitem_id; /* Scope of search */ + int last_search_option; }; struct _ESearchBarClass @@ -177,7 +178,7 @@ int e_search_bar_get_search_scope (ESearchBar *search_bar); void e_search_bar_set_text (ESearchBar *search_bar, const char *text); char *e_search_bar_get_text (ESearchBar *search_bar); - +void e_search_bar_scope_enable (ESearchBar *search_bar, int did, gboolean state); G_END_DECLS |