aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/ChangeLog17
-rw-r--r--widgets/misc/e-filter-bar.c7
-rw-r--r--widgets/misc/e-filter-bar.h11
-rw-r--r--widgets/misc/e-search-bar.c69
4 files changed, 74 insertions, 30 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index a568847879..4081b8c66a 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,20 @@
+2002-03-18 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-search-bar.c (clear_verb_cb): New.
+ (setup_standard_verbs): New.
+ (e_search_bar_set_ui_component): Call it if a new
+ BonoboUIComponent is set.
+ (append_xml_menu_item): New helper function.
+ (update_bonobo_menus): Use it. Also add a "Clear" menu item.
+ (e_search_bar_construct): @menu_items can be NULL now.
+ (e_search_bar_new): Same here.
+ (set_menu): Work with NULL items.
+
+ * e-filter-bar.c (menubar_activated): Don't handle
+ E_FILTERBAR_RESET_ID anymore.
+
+ * e-filter-bar.h: Remove `E_FILTERBAR_RESET_ID' and `E_FILTERBAR_RESET'.
+
2002-03-15 Ettore Perazzoli <ettore@ximian.com>
* e-search-bar.c (init): Init various members to NULL.
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index f32a2c0ad9..91fb195779 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -137,13 +137,6 @@ menubar_activated (ESearchBar *esb, int id, void *data)
EFilterBar *efb = (EFilterBar *)esb;
switch (id) {
- case E_FILTERBAR_RESET_ID:
- d(printf("Reset menu\n"));
- efb->current_query = NULL;
- e_search_bar_set_item_id (esb, efb->option_base);
- e_search_bar_set_text (esb, NULL);
- gtk_widget_set_sensitive (esb->entry, TRUE);
- break;
case E_FILTERBAR_EDIT_ID:
if (!efb->save_dialogue) {
GnomeDialog *gd;
diff --git a/widgets/misc/e-filter-bar.h b/widgets/misc/e-filter-bar.h
index 7577236ee3..d0a81d3b55 100644
--- a/widgets/misc/e-filter-bar.h
+++ b/widgets/misc/e-filter-bar.h
@@ -81,25 +81,20 @@ struct _EFilterBarClass
/* "preset" items */
enum {
/* preset menu options */
- E_FILTERBAR_RESET_ID = -2,
- E_FILTERBAR_SAVE_ID = -3,
- E_FILTERBAR_EDIT_ID = -4,
+ E_FILTERBAR_SAVE_ID = -2,
+ E_FILTERBAR_EDIT_ID = -3,
/* preset option options */
- E_FILTERBAR_ADVANCED_ID = -5,
-
- E_FILTERBAR_LAST_ID = -6,
+ E_FILTERBAR_ADVANCED_ID = -4,
};
#define E_FILTERBAR_SAVE { N_("Add to Saved Searches"), E_FILTERBAR_SAVE_ID, NULL }
-#define E_FILTERBAR_RESET { N_("Clear"), E_FILTERBAR_RESET_ID, NULL }
#define E_FILTERBAR_EDIT { N_("Edit..."), E_FILTERBAR_EDIT_ID, NULL }
#define E_FILTERBAR_ADVANCED { N_("Advanced..."), E_FILTERBAR_ADVANCED_ID, NULL }
#ifdef JUST_FOR_TRANSLATORS
const char * strings[] = {
N_("Save As..."),
- N_("Show All"),
N_("Edit..."),
N_("Advanced...")
};
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index ffca59e9a5..9254732905 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -97,7 +97,29 @@ emit_menu_activated (ESearchBar *esb, int item)
}
-/* Callbacks. */
+/* Callbacks -- Standard verbs. */
+
+static void
+clear_verb_cb (BonoboUIComponent *ui_component,
+ void *data,
+ const char *verb_name)
+{
+ ESearchBar *esb;
+
+ esb = E_SEARCH_BAR (data);
+ e_search_bar_set_text (esb, "");
+
+ emit_search_activated (esb);
+}
+
+static void
+setup_standard_verbs (ESearchBar *search_bar)
+{
+ bonobo_ui_component_add_verb (search_bar->ui_component, "ESearchBar:Clear",
+ clear_verb_cb, search_bar);
+}
+
+/* Callbacks -- The verbs for all the definable items. */
static void
search_verb_cb (BonoboUIComponent *ui_component,
@@ -310,6 +332,26 @@ copy_subitems (ESearchBarSubitem *subitems)
}
static void
+append_xml_menu_item (GString *xml,
+ const char *name,
+ const char *label,
+ const char *verb,
+ const char *accelerator)
+{
+ char *encoded_label;
+
+ encoded_label = bonobo_ui_util_encode_str (label);
+ g_string_sprintfa (xml, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"",
+ name, verb, encoded_label);
+ g_free (encoded_label);
+
+ if (accelerator != NULL)
+ g_string_sprintfa (xml, " accel=\"%s\"", accelerator);
+
+ g_string_sprintfa (xml, "/>");
+}
+
+static void
update_bonobo_menus (ESearchBar *esb)
{
GString *xml;
@@ -318,6 +360,8 @@ update_bonobo_menus (ESearchBar *esb)
xml = g_string_new ("<placeholder name=\"SearchBar\">");
+ append_xml_menu_item (xml, "Clear", _("Clear"), "ESearchBar:Clear", "*Control**Shift*b");
+
for (p = esb->menu_items; p != NULL; p = p->next) {
const ESearchBarItem *item;
@@ -326,16 +370,12 @@ update_bonobo_menus (ESearchBar *esb)
verb_name = g_strdup_printf ("ESearchBar:Activate:%d", item->id);
bonobo_ui_component_add_verb (esb->ui_component, verb_name, search_verb_cb, esb);
- if (item->text == NULL) {
+ if (item->text == NULL)
g_string_append (xml, "<separator/>");
- } else {
- char *encoded_label;
+ else
+ append_xml_menu_item (xml, verb_name, item->text, verb_name, NULL);
- encoded_label = bonobo_ui_util_encode_str (item->text);
- g_string_sprintfa (xml, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"/>",
- verb_name, verb_name, encoded_label);
- g_free (encoded_label);
- }
+ g_free (verb_name);
}
g_string_sprintfa (xml, "</placeholder>");
@@ -343,7 +383,6 @@ update_bonobo_menus (ESearchBar *esb)
bonobo_ui_component_set (esb->ui_component, "/menu/Search", xml->str, NULL);
g_string_free (xml, TRUE);
- g_free (verb_name);
}
static void
@@ -351,7 +390,10 @@ set_menu (ESearchBar *esb,
ESearchBarItem *items)
{
int i;
-
+
+ if (items == NULL)
+ return;
+
for (i = 0; items[i].id != -1; i++) {
ESearchBarItem *new_item;
@@ -678,7 +720,6 @@ e_search_bar_construct (ESearchBar *search_bar,
{
g_return_if_fail (search_bar != NULL);
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
- g_return_if_fail (menu_items != NULL);
g_return_if_fail (option_items != NULL);
gtk_box_set_spacing (GTK_BOX (search_bar), 1);
@@ -713,7 +754,6 @@ e_search_bar_set_menu (ESearchBar *search_bar, ESearchBarItem *menu_items)
{
g_return_if_fail (search_bar != NULL);
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
- g_return_if_fail (menu_items != NULL);
((ESearchBarClass *)((GtkObject *)search_bar)->klass)->set_menu (search_bar, menu_items);
}
@@ -723,7 +763,6 @@ e_search_bar_add_menu (ESearchBar *search_bar, ESearchBarItem *menu_item)
{
g_return_if_fail (search_bar != NULL);
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
- g_return_if_fail (menu_item != NULL);
set_menu (search_bar, menu_item);
}
@@ -788,7 +827,6 @@ e_search_bar_new (ESearchBarItem *menu_items,
{
GtkWidget *widget;
- g_return_val_if_fail (menu_items != NULL, NULL);
g_return_val_if_fail (option_items != NULL, NULL);
widget = GTK_WIDGET (gtk_type_new (e_search_bar_get_type ()));
@@ -810,6 +848,7 @@ e_search_bar_set_ui_component (ESearchBar *search_bar,
search_bar->ui_component = ui_component;
if (ui_component != NULL) {
bonobo_object_ref (BONOBO_OBJECT (ui_component));
+ setup_standard_verbs (search_bar);
update_bonobo_menus (search_bar);
}
}