aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/ChangeLog9
-rw-r--r--widgets/misc/e-search-bar.c37
2 files changed, 46 insertions, 0 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index b2880a8559..9ec923e5ab 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,5 +1,14 @@
2002-03-18 Ettore Perazzoli <ettore@ximian.com>
+ * e-search-bar.c (update_sensitivity): New halper function to
+ update the sensitivity of the commands.
+ (entry_changed_cb): New callback to make the activate_button and
+ the "Find Now" verb sensitive only if the entry has some contents.
+ (activate_by_subitems): Connect the callback here.
+ (setup_standard_verbs): Call update_sensitivity() here.
+
+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.
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index d70db2b9cc..b8bda3888c 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -96,6 +96,31 @@ emit_menu_activated (ESearchBar *esb, int item)
item);
}
+
+/* Utility functions. */
+
+static void
+update_sensitivity (ESearchBar *search_bar)
+{
+ 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:SearchNow",
+ "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:SearchNow",
+ "sensitive", "0", NULL);
+ gtk_widget_set_sensitive (search_bar->activate_button, FALSE);
+ }
+}
+
/* This implements the "clear" action, i.e. clears the text and then emits
* ::search_activated. */
@@ -138,6 +163,9 @@ setup_standard_verbs (ESearchBar *search_bar)
clear_verb_cb, search_bar);
bonobo_ui_component_add_verb (search_bar->ui_component, "ESearchBar:SearchNow",
search_now_verb_cb, search_bar);
+
+ /* Make sure the entries are created with the correct sensitivity. */
+ update_sensitivity (search_bar);
}
/* Callbacks -- The verbs for all the definable items. */
@@ -168,6 +196,13 @@ entry_activated_cb (GtkWidget *widget,
}
static void
+entry_changed_cb (GtkWidget *widget,
+ ESearchBar *esb)
+{
+ update_sensitivity (esb);
+}
+
+static void
subitem_activated_cb (GtkWidget *widget, ESearchBar *esb)
{
gint id, subid;
@@ -199,6 +234,8 @@ activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems
esb->entry = gtk_entry_new();
gtk_widget_set_usize (esb->entry, 4, -1);
gtk_object_ref (GTK_OBJECT (esb->entry));
+ gtk_signal_connect (GTK_OBJECT (esb->entry), "changed",
+ GTK_SIGNAL_FUNC (entry_changed_cb), esb);
gtk_signal_connect (GTK_OBJECT (esb->entry), "activate",
GTK_SIGNAL_FUNC (entry_activated_cb), esb);
gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry);