[evolution-patches] (UI) Patch to show a visual cue on a active search



Hi,

I have attached a patch. It tries to set the SELECTED color property in
the entry and text in the search widget, when the search is active. It
also takes care of contacts, calendar, mail, memo and tasks.

I have posted a screenshot of this idea to the evolution list earlier.
-Srini.
Index: e-filter-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-filter-bar.c,v
retrieving revision 1.52
diff -u -p -r1.52 e-filter-bar.c
--- e-filter-bar.c	15 Aug 2005 03:15:06 -0000	1.52
+++ e-filter-bar.c	14 Dec 2005 09:29:47 -0000
@@ -107,18 +107,24 @@ static void
 rule_advanced_response (GtkWidget *dialog, int response, void *data)
 {
 	EFilterBar *efb = data;
+	ESearchBar *esb = efb;
 	FilterRule *rule;
 	
 	if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
 		rule = g_object_get_data ((GObject *) dialog, "rule");
 		if (rule) {
+			GtkStyle *style = gtk_widget_get_default_style ();
+
 			if (!filter_rule_validate (rule))
 				return;
 			
 			efb->current_query = rule;
 			g_object_ref (rule);
 			g_signal_emit_by_name (efb, "query_changed");
-			
+
+			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]));
+				
 			if (response == GTK_RESPONSE_APPLY) {
 				if (!rule_context_find_rule (efb->context, rule->name, rule->source))
 					rule_context_add_rule (efb->context, rule);
@@ -298,6 +304,11 @@ option_changed (ESearchBar *esb, void *d
 			}
 			gtk_widget_set_sensitive (esb->entry, TRUE);
 		} else {
+			GtkStyle *style = gtk_widget_get_default_style ();
+
+			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);
 			efb->current_query = NULL;
 		}
@@ -666,11 +677,17 @@ set_property (GObject *object, guint pro
 					FilterRule *rule = NULL;
 					
 					if ((node = node->children)) {
+						GtkStyle *style = gtk_widget_get_default_style ();
+						
 						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);							
 							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]));
 							g_object_set_data_full (object, "rule", rule, (GDestroyNotify) g_object_unref);
 						}
 					}
@@ -685,10 +702,18 @@ set_property (GObject *object, guint pro
 				} else if (!strcmp (node->name, "search-bar")) {
 					int subitem_id, item_id;
 					char *text;
+					GtkStyle *style = gtk_widget_get_default_style ();
 					
 					/* set the text first (it doesn't emit a signal) */
 					text = xmlGetProp (node, "text");
 					e_search_bar_set_text ((ESearchBar *) efb, text);
+					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]));
+					} else {
+						gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
+						gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);						
+					}
 					xmlFree (text);
 					
 					/* now set the item_id and subitem_id */
Index: e-search-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-search-bar.c,v
retrieving revision 1.88
diff -u -p -r1.88 e-search-bar.c
--- e-search-bar.c	20 Sep 2005 09:34:12 -0000	1.88
+++ e-search-bar.c	14 Dec 2005 09:29:47 -0000
@@ -259,6 +259,17 @@ static void
 entry_activated_cb (GtkWidget *widget,
 		     ESearchBar *esb)
 {
+	const char *text = gtk_entry_get_text (esb->entry);
+	GtkStyle *style = gtk_widget_get_default_style ();
+
+	if (text && *text) {
+		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]));
+	} else {
+		gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
+		gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);		
+	}
+	
 	emit_search_activated (esb);
 }
 
@@ -450,6 +461,16 @@ static void
 activate_button_clicked_cb (GtkWidget *widget,
 			    ESearchBar *esb)
 {
+	const char *text = gtk_entry_get_text (esb->entry);
+	GtkStyle *style = gtk_widget_get_default_style ();
+
+	if (text && *text) {
+		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]));
+	} else {
+		gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
+		gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);		
+	}
 	emit_search_activated (esb);
 
 	gtk_widget_grab_focus (esb->entry);
@@ -459,6 +480,11 @@ static void
 clear_button_clicked_cb (GtkWidget *widget,
 			 ESearchBar *esb)
 {
+	GtkStyle *style = gtk_widget_get_default_style ();
+
+	gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
+	gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
+	
 	clear_search (esb);
 
 	gtk_widget_grab_focus (esb->entry);
Index: gui/search/e-addressbook-search-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/search/e-addressbook-search-dialog.c,v
retrieving revision 1.32
diff -u -p -r1.32 e-addressbook-search-dialog.c
--- gui/search/e-addressbook-search-dialog.c	21 Dec 2004 15:38:27 -0000	1.32
+++ gui/search/e-addressbook-search-dialog.c	14 Dec 2005 09:32:11 -0000
@@ -136,10 +136,15 @@ dialog_response (GtkWidget *widget, int 
 	char *query;
 
 	if (response_id == GTK_RESPONSE_OK) {
+		GtkStyle *style = gtk_widget_get_default_style ();
+		
 		query = get_query(dialog);
 		g_object_set(dialog->view,
 			     "query", query,
 			     NULL);
+		gtk_widget_modify_base (dialog->view->search->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+		gtk_widget_modify_text (dialog->view->search->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
+		
 		g_free(query);
 	}
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]