diff options
author | Srinivasa Ragavan <sragavan@novell.com> | 2009-07-17 01:51:01 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@novell.com> | 2009-07-17 01:57:42 +0800 |
commit | 52c6958571696c8fcce89e021669725be982bcfc (patch) | |
tree | 1880ca7fb1977b1f7b56d6cc08e1f5b8233f8648 /widgets | |
parent | 6ed8ba1cb10554913fcea2cc3fcccfa63ae0cb82 (diff) | |
download | gsoc2013-evolution-52c6958571696c8fcce89e021669725be982bcfc.tar.gz gsoc2013-evolution-52c6958571696c8fcce89e021669725be982bcfc.tar.zst gsoc2013-evolution-52c6958571696c8fcce89e021669725be982bcfc.zip |
Search bar stuff for Anjal.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-icon-entry.c | 36 | ||||
-rw-r--r-- | widgets/misc/e-icon-entry.h | 2 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.c | 43 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.h | 1 |
4 files changed, 82 insertions, 0 deletions
diff --git a/widgets/misc/e-icon-entry.c b/widgets/misc/e-icon-entry.c index 2ed50e242f..90130ccbd6 100644 --- a/widgets/misc/e-icon-entry.c +++ b/widgets/misc/e-icon-entry.c @@ -375,6 +375,42 @@ e_icon_entry_create_button (const gchar *stock) } GtkWidget * +e_icon_entry_create_text (const gchar *text) +{ + GtkWidget *eventbox; + GtkWidget *image; + + eventbox = gtk_event_box_new (); + gtk_container_set_border_width (GTK_CONTAINER (eventbox), 2); + gtk_event_box_set_visible_window (GTK_EVENT_BOX (eventbox), FALSE); + + image = gtk_label_new (text); + gtk_container_add (GTK_CONTAINER (eventbox), image); + g_object_set_data ((GObject *)eventbox, "lbl", image); + g_signal_connect_after (eventbox, "enter-notify-event", (GCallback) set_cursor, NULL); + g_signal_connect_after (eventbox, "leave-notify-event", (GCallback) set_cursor, NULL); + + return eventbox; +} + + +GtkWidget * +e_icon_entry_create_separator () +{ + GtkWidget *eventbox; + GtkWidget *image; + + eventbox = gtk_event_box_new (); + gtk_container_set_border_width (GTK_CONTAINER (eventbox), 0); + gtk_event_box_set_visible_window (GTK_EVENT_BOX (eventbox), FALSE); + + image = (GtkWidget *)gtk_separator_tool_item_new (); + gtk_container_add (GTK_CONTAINER (eventbox), image); + + return eventbox; +} + +GtkWidget * e_icon_entry_get_entry (EIconEntry *entry) { g_return_val_if_fail (E_IS_ICON_ENTRY (entry), NULL); diff --git a/widgets/misc/e-icon-entry.h b/widgets/misc/e-icon-entry.h index f8e4740d36..cde735ba6f 100644 --- a/widgets/misc/e-icon-entry.h +++ b/widgets/misc/e-icon-entry.h @@ -79,6 +79,8 @@ void e_icon_entry_pack_widget (EIconEntry *entry, GtkWidget *e_icon_entry_get_entry (EIconEntry *entry); GtkWidget *e_icon_entry_create_button (const gchar *stock); +GtkWidget * e_icon_entry_create_text (const gchar *text); +GtkWidget * e_icon_entry_create_separator (void); G_END_DECLS 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); diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h index 82bc1ba0da..5385ebf66a 100644 --- a/widgets/misc/e-search-bar.h +++ b/widgets/misc/e-search-bar.h @@ -85,6 +85,7 @@ struct _ESearchBar GtkWidget *clear_button; GtkWidget *entry_box; GtkWidget *icon_entry; + GtkWidget *label; /* show option widgets */ GtkWidget *viewoption_box; |