aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-21 18:11:44 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-21 18:11:44 +0800
commit3775df17d1da447c5ba486928aad07390bda9d82 (patch)
treecebdcfe0a3fbad7b35b7df4a70f2854e7cf40e4f /shell
parent1d92d306fe094c667c3f33e70cdb93163e4a97d0 (diff)
downloadgsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.tar
gsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.tar.gz
gsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.tar.bz2
gsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.tar.lz
gsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.tar.xz
gsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.tar.zst
gsoc2013-evolution-3775df17d1da447c5ba486928aad07390bda9d82.zip
Bug #685808 - Search bar entry background does not change on search
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-searchbar.c70
1 files changed, 60 insertions, 10 deletions
diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c
index 4c7e670881..46fbdf2963 100644
--- a/shell/e-shell-searchbar.c
+++ b/shell/e-shell-searchbar.c
@@ -62,6 +62,7 @@ struct _EShellSearchbarPrivate {
GtkRadioAction *search_option;
EFilterRule *search_rule;
+ GtkCssProvider *css_provider;
/* Child Widgets (not referenced) */
GtkWidget *filter_combo_box;
@@ -253,17 +254,27 @@ shell_searchbar_update_search_widgets (EShellSearchbar *searchbar)
(e_shell_view_get_search_rule (shell_view) != NULL);
if (sensitive) {
- GtkStyle *style;
- const GdkColor *color;
-
- style = gtk_widget_get_style (widget);
- color = &style->mid[GTK_STATE_SELECTED];
-
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
- gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
+ GtkStyleContext *style;
+ GdkRGBA bg, fg;
+ gchar *css;
+
+ style = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &bg);
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &fg);
+
+ css = g_strdup_printf ("GtkEntry#searchbar_searchentry_active { "
+ " background:none; "
+ " background-color:#%06x; "
+ " color:#%06x; "
+ "}",
+ e_rgba_to_value (&bg),
+ e_rgba_to_value (&fg));
+ gtk_css_provider_load_from_data (searchbar->priv->css_provider, css, -1, NULL);
+ g_free (css);
+
+ gtk_widget_set_name (widget, "searchbar_searchentry_active");
} else {
- /* Text color will be updated when we move the focus. */
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, NULL);
+ gtk_widget_set_name (widget, "searchbar_searchentry");
}
action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
@@ -568,6 +579,27 @@ shell_searchbar_resize_idle_cb (gpointer user_data)
return FALSE;
}
+static gboolean
+shell_searchbar_entry_focus_in_cb (GtkWidget *entry,
+ GdkEvent *event,
+ EShellSearchbar *searchbar)
+{
+ /* to not change background when user changes search entry content */
+ gtk_widget_set_name (entry, "searchbar_searchentry");
+
+ return FALSE;
+}
+
+static gboolean
+shell_searchbar_entry_focus_out_cb (GtkWidget *entry,
+ GdkEvent *event,
+ EShellSearchbar *searchbar)
+{
+ shell_searchbar_update_search_widgets (searchbar);
+
+ return FALSE;
+}
+
static void
shell_searchbar_set_shell_view (EShellSearchbar *searchbar,
EShellView *shell_view)
@@ -771,6 +803,11 @@ shell_searchbar_dispose (GObject *object)
priv->state_group = NULL;
}
+ if (priv->css_provider) {
+ g_object_unref (priv->css_provider);
+ priv->css_provider = NULL;
+ }
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_shell_searchbar_parent_class)->dispose (object);
}
@@ -815,7 +852,10 @@ shell_searchbar_constructed (GObject *object)
shell_view, (GClosureNotify) NULL,
G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+ searchbar->priv->css_provider = gtk_css_provider_new ();
widget = searchbar->priv->search_entry;
+ gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (searchbar->priv->css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
@@ -1196,6 +1236,16 @@ e_shell_searchbar_init (EShellSearchbar *searchbar)
G_CALLBACK (shell_searchbar_entry_key_press_cb),
searchbar);
+ g_signal_connect (
+ widget, "focus-in-event",
+ G_CALLBACK (shell_searchbar_entry_focus_in_cb),
+ searchbar);
+
+ g_signal_connect (
+ widget, "focus-out-event",
+ G_CALLBACK (shell_searchbar_entry_focus_out_cb),
+ searchbar);
+
/* Scope Combo Widgets */
grid = GTK_GRID (searchbar);