aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-search-bar.c
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@novell.com>2009-07-17 01:51:01 +0800
committerSrinivasa Ragavan <sragavan@novell.com>2009-07-17 01:57:42 +0800
commit52c6958571696c8fcce89e021669725be982bcfc (patch)
tree1880ca7fb1977b1f7b56d6cc08e1f5b8233f8648 /widgets/misc/e-search-bar.c
parent6ed8ba1cb10554913fcea2cc3fcccfa63ae0cb82 (diff)
downloadgsoc2013-evolution-52c6958571696c8fcce89e021669725be982bcfc.tar.gz
gsoc2013-evolution-52c6958571696c8fcce89e021669725be982bcfc.tar.zst
gsoc2013-evolution-52c6958571696c8fcce89e021669725be982bcfc.zip
Search bar stuff for Anjal.
Diffstat (limited to 'widgets/misc/e-search-bar.c')
-rw-r--r--widgets/misc/e-search-bar.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index 1783ebf375..36e0e6dc52 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -75,6 +75,26 @@ static void emit_query_changed (ESearchBar *esb);
/* Utility functions. */
static void
+esb_paint_label (GtkWidget *label, gboolean active)
+{
+ static char *sens = NULL;
+ static char *insens = NULL;
+ char *text;
+
+ if (!label)
+ return;
+
+ if (!sens) {
+ GtkStyle *default_style = gtk_widget_get_default_style ();
+ sens = gdk_color_to_string (&default_style->text[GTK_STATE_SELECTED]);
+ insens = gdk_color_to_string (&default_style->text[GTK_STATE_NORMAL]);
+ }
+ text = g_strdup_printf("<span foreground=\"%s\">%s</span>", active ? sens : insens, _("Search"));
+ gtk_label_set_markup ((GtkLabel *)label, text);
+ g_free(text);
+}
+
+static void
set_find_now_sensitive (ESearchBar *search_bar,
gboolean sensitive)
{
@@ -371,12 +391,14 @@ entry_activated_cb (GtkWidget *widget,
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]));
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
+ esb_paint_label (esb->label, TRUE);
if (!esb->lite)
gtk_widget_modify_base (esb->viewoption, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
} else {
gtk_widget_modify_base (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
+ esb_paint_label (esb->label, FALSE);
if (!esb->lite)
gtk_widget_set_sensitive (esb->clear_button, FALSE);
}
@@ -385,6 +407,13 @@ entry_activated_cb (GtkWidget *widget,
}
static void
+search_entry_press_cb (GtkWidget *w, GdkEventButton *event, ESearchBar *esb)
+{
+ if (event->button == 1)
+ entry_activated_cb (w, esb);
+}
+
+static void
entry_changed_cb (GtkWidget *widget,
ESearchBar *esb)
{
@@ -504,6 +533,7 @@ clear_button_clicked_cb (GtkWidget *widget, GdkEventButton *event,
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
gtk_widget_set_sensitive (esb->clear_button, FALSE);
+ esb_paint_label (esb->label, FALSE);
clear_search (esb);
gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
@@ -955,6 +985,7 @@ idle_activate_hack (gpointer ptr)
return FALSE;
}
+
void
e_search_bar_construct (ESearchBar *search_bar,
ESearchBarItem *menu_items,
@@ -986,6 +1017,18 @@ e_search_bar_construct (ESearchBar *search_bar,
g_signal_connect (search_bar->entry, "key-press-event",
G_CALLBACK (entry_key_press_cb), search_bar);
+ search_bar->label = NULL;
+ if (search_bar->lite) {
+ label = e_icon_entry_create_text (_("Search"));
+ g_signal_connect (G_OBJECT (label), "button-press-event", G_CALLBACK(search_entry_press_cb), search_bar);
+ e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), label, FALSE);
+ search_bar->label = g_object_get_data ((GObject *)label, "lbl");
+ esb_paint_label (search_bar->label, FALSE);
+
+ label = e_icon_entry_create_separator ();
+ e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), label, FALSE);
+ }
+
search_bar->clear_button = e_icon_entry_create_button ("gtk-clear");
g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", G_CALLBACK(clear_button_clicked_cb), search_bar);
e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->clear_button, FALSE);