aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-03-19 04:37:14 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-03-19 04:37:14 +0800
commitad1e6e7f4427bae086d50c3b31075a96ecf0bd82 (patch)
tree1bf0e7d6eb372ea1757b9369fddc49d52506d265
parent6b5f07ff016b73f5f633604dea76a1f71161ede1 (diff)
downloadgsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.tar
gsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.tar.gz
gsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.tar.bz2
gsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.tar.lz
gsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.tar.xz
gsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.tar.zst
gsoc2013-evolution-ad1e6e7f4427bae086d50c3b31075a96ecf0bd82.zip
Init clear_button to NULL. (add_button): New helper function to add a
* e-search-bar.c (init): Init clear_button to NULL. (add_button): New helper function to add a button to the search bar with the right spacing etc. (clear_search): New helper function. (add_activate_button): Removed. (clear_button_clicked_cb): New. (e_search_bar_construct): Just add the button here using `add_button'. Also add a clear_button. (clear_verb_cb): Rewritten by means of `clear_search()'. * e-search-bar.h (ESearchBar): Add clear_button. svn path=/trunk/; revision=16198
-rw-r--r--widgets/misc/ChangeLog14
-rw-r--r--widgets/misc/e-search-bar.c54
-rw-r--r--widgets/misc/e-search-bar.h1
3 files changed, 54 insertions, 15 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index ff9b1b6ef3..b2880a8559 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,5 +1,19 @@
2002-03-18 Ettore Perazzoli <ettore@ximian.com>
+ * e-search-bar.c (init): Init clear_button to NULL.
+ (add_button): New helper function to add a button to the search
+ bar with the right spacing etc.
+ (clear_search): New helper function.
+ (add_activate_button): Removed.
+ (clear_button_clicked_cb): New.
+ (e_search_bar_construct): Just add the button here using
+ `add_button'. Also add a clear_button.
+ (clear_verb_cb): Rewritten by means of `clear_search()'.
+
+ * e-search-bar.h (ESearchBar): Add clear_button.
+
+2002-03-18 Ettore Perazzoli <ettore@ximian.com>
+
* e-search-bar.c (search_now_verb_cb): New, implementation for a
new "SearchNow" verb.
(setup_standard_verbs): Create verb here.
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index 98b6f8fe0e..d70db2b9cc 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -96,6 +96,16 @@ emit_menu_activated (ESearchBar *esb, int item)
item);
}
+/* This implements the "clear" action, i.e. clears the text and then emits
+ * ::search_activated. */
+
+static void
+clear_search (ESearchBar *esb)
+{
+ e_search_bar_set_text (esb, "");
+ emit_search_activated (esb);
+}
+
/* Callbacks -- Standard verbs. */
@@ -118,9 +128,7 @@ clear_verb_cb (BonoboUIComponent *ui_component,
ESearchBar *esb;
esb = E_SEARCH_BAR (data);
- e_search_bar_set_text (esb, "");
-
- emit_search_activated (esb);
+ clear_search (esb);
}
static void
@@ -295,11 +303,19 @@ option_activated_cb (GtkWidget *widget,
}
static void
-activate_button_clicked_cb (GtkWidget *widget, ESearchBar *esb)
+activate_button_clicked_cb (GtkWidget *widget,
+ ESearchBar *esb)
{
emit_search_activated (esb);
}
+static void
+clear_button_clicked_cb (GtkWidget *widget,
+ ESearchBar *esb)
+{
+ clear_search (esb);
+}
+
/* Widgetry creation. */
@@ -515,30 +531,34 @@ set_option (ESearchBar *esb, ESearchBarItem *items)
gtk_widget_set_sensitive (esb->option, TRUE);
}
-static void
-add_activate_button (ESearchBar *esb)
+static GtkWidget *
+add_button (ESearchBar *esb,
+ const char *text,
+ GtkSignalFunc callback)
{
GtkWidget *label;
GtkWidget *holder;
+ GtkWidget *button;
- label = gtk_label_new (_("Find Now"));
- gtk_misc_set_padding(GTK_MISC(label), 2, 0);
+ label = gtk_label_new (text);
+ gtk_misc_set_padding (GTK_MISC (label), 2, 0);
gtk_widget_show (label);
/* See the comment in `put_in_spacer_widget()' to understand
why we have to do this. */
- esb->activate_button = gtk_button_new ();
- gtk_widget_show (esb->activate_button);
- gtk_container_add (GTK_CONTAINER (esb->activate_button), label);
+ button = gtk_button_new ();
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (button), label);
- holder = put_in_spacer_widget (esb->activate_button);
+ holder = put_in_spacer_widget (button);
gtk_widget_show (holder);
- gtk_signal_connect (GTK_OBJECT (esb->activate_button), "clicked",
- GTK_SIGNAL_FUNC (activate_button_clicked_cb), esb);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked", callback, esb);
gtk_box_pack_start (GTK_BOX (esb), holder, FALSE, FALSE, 0);
+
+ return button;
}
static int
@@ -707,6 +727,7 @@ init (ESearchBar *esb)
esb->suboption_menu = NULL;
esb->dropdown_menu = NULL;
esb->activate_button = NULL;
+ esb->clear_button = NULL;
esb->entry_box = NULL;
esb->pending_activate = 0;
@@ -747,7 +768,10 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_widget_show (search_bar->entry_box);
gtk_box_pack_start (GTK_BOX(search_bar), search_bar->entry_box, TRUE, TRUE, 0);
- add_activate_button (search_bar);
+ search_bar->activate_button = add_button (search_bar, _("Find Now"),
+ GTK_SIGNAL_FUNC (activate_button_clicked_cb));
+ search_bar->clear_button = add_button (search_bar, _("Clear"),
+ GTK_SIGNAL_FUNC (clear_button_clicked_cb));
/*
* If the default choice for the option menu has subitems, then we need to
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index 18c4b370c1..a20f8c4d6a 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -80,6 +80,7 @@ struct _ESearchBar
GtkWidget *suboption_menu;
GtkWidget *dropdown_menu;
GtkWidget *activate_button;
+ GtkWidget *clear_button;
GtkWidget *entry_box;
guint pending_activate;