aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/ChangeLog19
-rw-r--r--widgets/misc/e-filter-bar.c85
-rw-r--r--widgets/misc/e-search-bar.c3
-rw-r--r--widgets/misc/e-search-bar.h5
4 files changed, 74 insertions, 38 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index dab760980f..434dfb2a86 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,22 @@
+2002-07-22 Peter Williams <peterw@ximian.com>
+
+ * e-filter-bar.c (do_advanced): Break out the code for creating
+ the advanced rule editor into a separate function, so that...
+ (menubar_activated): ... can also create an Advanced dialog;
+ needed when the Search menu's advanced button is used.
+ (option_changed): Change this to call the function instead of
+ having all the code to itself.
+
+ * e-search-bar.h: Add id's for the FIND_NOW and CLEAR actions
+ so that other code (eg, EFilterBar) doesn't get confused by
+ an old id being used when the search-activated signal gets
+ emitted.
+
+ * e-search-bar.c (clear_search): Set the item_id to CLEAR
+ before emitting the signal.
+ (search_now_verb_cb): Just make this emit query_changed,
+ as the button in the toolbar does.
+
2002-07-17 Ettore Perazzoli <ettore@ximian.com>
[Fix #27854, spurious warnings from ESearchBar.]
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index 9863b8f294..261147d03c 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -132,6 +132,48 @@ rule_advanced_clicked (GtkWidget *dialog, int button, void *data)
}
static void
+do_advanced (ESearchBar *esb)
+{
+ EFilterBar *efb = (EFilterBar *)esb;
+
+ d(printf("Advanced search!\n"));
+
+ if (!efb->save_dialogue && !efb->setquery) {
+ GtkWidget *w, *gd;
+ FilterRule *rule;
+
+ if (efb->current_query)
+ rule = filter_rule_clone (efb->current_query);
+ else
+ rule = filter_rule_new ();
+
+ w = filter_rule_get_widget (rule, efb->context);
+ filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
+ gd = gnome_dialog_new (_("Advanced Search"),
+ GNOME_STOCK_BUTTON_OK,
+ _("Save"),
+ GNOME_STOCK_BUTTON_CANCEL,
+ NULL);
+ efb->save_dialogue = gd;
+ gnome_dialog_set_default (GNOME_DIALOG (gd), 0);
+
+ gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (gd), 600, 300);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0);
+ gtk_widget_show (gd);
+ gtk_object_ref (GTK_OBJECT (rule));
+ gtk_object_set_data_full (GTK_OBJECT (gd), "rule", rule, (GtkDestroyNotify)gtk_object_unref);
+ gtk_signal_connect (GTK_OBJECT (gd), "clicked", rule_advanced_clicked, efb);
+ gtk_signal_connect (GTK_OBJECT (gd), "destroy", 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 (gd);
+ }
+}
+
+static void
menubar_activated (ESearchBar *esb, int id, void *data)
{
EFilterBar *efb = (EFilterBar *)esb;
@@ -181,6 +223,9 @@ menubar_activated (ESearchBar *esb, int id, void *data)
d(printf("Save menu\n"));
break;
+ case E_FILTERBAR_ADVANCED_ID:
+ do_advanced (esb);
+ break;
default:
if (id >= efb->menu_base && id < efb->menu_base + efb->menu_rules->len) {
GString *out = g_string_new ("");
@@ -214,43 +259,9 @@ option_changed (ESearchBar *esb, void *data)
d(printf("option changed, id = %d\n", id));
switch (id) {
- case E_FILTERBAR_ADVANCED_ID: {
- d(printf("Advanced search!\n"));
-
- if (!efb->save_dialogue && !efb->setquery) {
- GtkWidget *w, *gd;
- FilterRule *rule;
-
- if (efb->current_query)
- rule = filter_rule_clone (efb->current_query);
- else
- rule = filter_rule_new ();
-
- w = filter_rule_get_widget (rule, efb->context);
- filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
- gd = gnome_dialog_new (_("Advanced Search"),
- GNOME_STOCK_BUTTON_OK,
- _("Save"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- efb->save_dialogue = gd;
- gnome_dialog_set_default (GNOME_DIALOG (gd), 0);
-
- gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE);
- gtk_window_set_default_size (GTK_WINDOW (gd), 600, 300);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0);
- gtk_widget_show (gd);
- gtk_object_ref (GTK_OBJECT (rule));
- gtk_object_set_data_full (GTK_OBJECT (gd), "rule", rule, (GtkDestroyNotify)gtk_object_unref);
- gtk_signal_connect (GTK_OBJECT (gd), "clicked", rule_advanced_clicked, efb);
- gtk_signal_connect (GTK_OBJECT (gd), "destroy", 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 (gd);
- }
- } break;
+ case E_FILTERBAR_ADVANCED_ID:
+ do_advanced (esb);
+ break;
default:
if (id >= efb->option_base && id < efb->option_base + efb->option_rules->len) {
efb->current_query = (FilterRule *)efb->option_rules->pdata[id - efb->option_base];
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index 93896a1a72..8da8863d65 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -103,6 +103,7 @@ static void
clear_search (ESearchBar *esb)
{
e_search_bar_set_text (esb, "");
+ e_search_bar_set_item_id (esb, E_SEARCHBAR_CLEAR_ID);
emit_search_activated (esb);
}
@@ -188,7 +189,7 @@ search_now_verb_cb (BonoboUIComponent *ui_component,
ESearchBar *esb;
esb = E_SEARCH_BAR (data);
- emit_search_activated (esb);
+ emit_query_changed (esb);
}
static void
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index f50f487b8d..e7d3830735 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -102,6 +102,11 @@ struct _ESearchBarClass
void (*menu_activated) (ESearchBar *search, int item);
};
+enum {
+ E_SEARCHBAR_FIND_NOW_ID = 0,
+ E_SEARCHBAR_CLEAR_ID = 1
+};
+
GtkType e_search_bar_get_type (void);
void e_search_bar_construct (ESearchBar *search_bar,