From: Christian Dywan Date: Sat, 17 Dec 2011 09:46:03 +0000 (+0100) Subject: Use style classes for location entry in GTK+3 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1126ec1088acd2f9ec10c8fa396ebb6d61222006;p=midori Use style classes for location entry in GTK+3 The classes are .security_trusted and .security_unknown. --- diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index f380b6dd..698d9e9a 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -763,6 +763,30 @@ midori_location_action_create_tool_item (GtkAction* action) gtk_widget_show (entry); gtk_container_add (GTK_CONTAINER (alignment), entry); + #if GTK_CHECK_VERSION (3, 0, 0) + { + static const gchar default_style[] = + ".security_unknown {\n" + "background-image: none;\n" + "background-color: #ef7070;\n" + "color: #000;\n" + "}\n" + ".security_trusted {\n" + "background-image: none;\n" + "background-color: #d1eeb9;\n" + "color: #000;\n" + "}\n"; + GtkCssProvider* css_provider; + GtkStyleContext* context; + + css_provider = gtk_css_provider_new (); + context = gtk_widget_get_style_context (entry); + gtk_css_provider_load_from_data (css_provider, default_style, -1, NULL); + gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider), + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); + } + #endif + return toolitem; } @@ -1677,13 +1701,22 @@ midori_location_action_set_security_hint (MidoriLocationAction* location_action, { #if GTK_CHECK_VERSION (3, 0, 0) - GdkRGBA color = { 0 }; - if (bg_color) gdk_rgba_parse (&color, bg_color); - gtk_widget_override_background_color (entry, - GTK_STATE_FLAG_NORMAL, bg_color ? &color : NULL); - if (fg_color) gdk_rgba_parse (&color, fg_color); - gtk_widget_override_color (entry, - GTK_STATE_FLAG_NORMAL, fg_color ? &color : NULL); + GtkStyleContext* context = gtk_widget_get_style_context (entry); + if (hint == MIDORI_SECURITY_UNKNOWN) + { + gtk_style_context_add_class (context, "security_unknown"); + gtk_style_context_remove_class (context, "security_trusted"); + } + else if (hint == MIDORI_SECURITY_TRUSTED) + { + gtk_style_context_add_class (context, "security_trusted"); + gtk_style_context_remove_class (context, "security_unknown"); + } + else if (hint == MIDORI_SECURITY_NONE) + { + gtk_style_context_remove_class (context, "security_unknown"); + gtk_style_context_remove_class (context, "security_trusted"); + } #else GdkColor color = { 0 }; if (bg_color) gdk_color_parse (bg_color, &color);