]> spindle.queued.net Git - midori/commitdiff
Move GTK+3 built-in CSS to gtk3.css
authorChristian Dywan <christian@twotoasts.de>
Fri, 13 Jul 2012 22:25:03 +0000 (00:25 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sat, 14 Jul 2012 22:13:43 +0000 (00:13 +0200)
data/gtk3.css [new file with mode: 0644]
midori/midori-app.c
midori/midori-locationaction.c
midori/midori-view.c
wscript

diff --git a/data/gtk3.css b/data/gtk3.css
new file mode 100644 (file)
index 0000000..01ad05c
--- /dev/null
@@ -0,0 +1,39 @@
+.notebook tab .button {
+    -GtkButton-default-border: 0;
+    -GtkButton-default-outside-border: 0;
+    -GtkButton-inner-border: 0;
+    -GtkWidget-focus-line-width: 0;
+    -GtkWidget-focus-padding: 0;
+    padding: 0;
+}
+
+.entry.progressbar {
+    background-image: -gtk-gradient(linear,
+        left top, left bottom, from (@selected_bg_color), to (@selected_bg_color));
+    color: @selected_fg_color;
+}
+
+.entry.security_unknown {
+    background-image: -gtk-gradient(linear,
+        left top, left bottom, from (#ef7070), to(#ef7070));
+    color: #000;
+}
+
+.entry.security_trusted {
+    background-image: -gtk-gradient(linear,
+        left top, left bottom, from (#d1eeb9), to(#d1eeb9));
+    color: #000;
+}
+
+GtkOverlay > * {
+    padding: 4px;
+    border-style: solid;
+    border-radius: 0 5px 0 0;
+    border-width: 1px 1px 0 0;
+}
+
+GtkOverlay MidoriFindbar {
+    border-radius: 0 0 0 5px;
+    border-width: 0 0 1px 1px; /* top right bottom left */
+}
+
index 0215a8f502dcb463931715a20e1d9cd34126c05c..4e8eb8be84124a0a3ab146e5e77f85259725b772 100644 (file)
@@ -228,6 +228,32 @@ _midori_app_add_browser (MidoriApp*     app,
 
     katze_array_add_item (app->browsers, browser);
 
+    #if GTK_CHECK_VERSION (3, 0, 0)
+    if (app->browser == NULL)
+    {
+        gchar* filename;
+        if ((filename = midori_app_find_res_filename ("gtk3.css")))
+        {
+            GtkCssProvider* css_provider = gtk_css_provider_new ();
+            GError* error = NULL;
+            gtk_css_provider_load_from_path (css_provider, filename, &error);
+            if (error == NULL)
+            {
+                gtk_style_context_add_provider_for_screen (
+                    gtk_widget_get_screen (GTK_WIDGET (browser)),
+                    GTK_STYLE_PROVIDER (css_provider),
+                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+            }
+            else
+            {
+                g_warning ("Failed to load \"%s\": %s", filename, error->message);
+                g_error_free (error);
+            }
+            g_free (filename);
+        }
+    }
+    #endif
+
     app->browser = browser;
     #if HAVE_UNIQUE
     /* We *do not* let unique watch windows because that includes
index ec377bdbd1cd1c509ff71730e4033e8ecb010445..5ded1a33a4c4108bea874a308ba9f6bf3a3e050f 100644 (file)
@@ -851,30 +851,6 @@ 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;
 }
 
index 50447cead4e37062eb4d6c7d689597269bda8fe0..a4757633893601269e2c488f7761a50fd600ceb2 100644 (file)
@@ -3272,10 +3272,14 @@ midori_view_init (MidoriView* view)
     gtk_box_pack_start (GTK_BOX (view), view->overlay, TRUE, TRUE, 0);
 
     /* Overlays must be created before showing GtkOverlay as of GTK+ 3.2 */
+    {
+    GtkWidget* frame = gtk_frame_new (NULL);
     view->overlay_label = gtk_label_new (NULL);
-    gtk_widget_set_halign (view->overlay_label, GTK_ALIGN_START);
-    gtk_widget_set_valign (view->overlay_label, GTK_ALIGN_END);
-    gtk_overlay_add_overlay (GTK_OVERLAY (view->overlay), view->overlay_label);
+    gtk_container_add (GTK_CONTAINER (frame), view->overlay_label);
+    gtk_widget_set_halign (frame, GTK_ALIGN_START);
+    gtk_widget_set_valign (frame, GTK_ALIGN_END);
+    gtk_overlay_add_overlay (GTK_OVERLAY (view->overlay), frame);
+    }
     view->overlay_find = g_object_new (MIDORI_TYPE_FINDBAR, NULL);
     gtk_widget_set_halign (view->overlay_find, GTK_ALIGN_END);
     gtk_widget_set_valign (view->overlay_find, GTK_ALIGN_START);
@@ -4445,11 +4449,11 @@ midori_view_set_overlay_text (MidoriView*  view,
 
     #if GTK_CHECK_VERSION (3, 2, 0)
     if (text == NULL)
-        gtk_widget_hide (view->overlay_label);
+        gtk_widget_hide (gtk_widget_get_parent (view->overlay_label));
     else
     {
         gtk_label_set_text (GTK_LABEL (view->overlay_label), text);
-        gtk_widget_show (view->overlay_label);
+        gtk_widget_show (gtk_widget_get_parent (view->overlay_label));
     }
     #endif
 }
@@ -5063,19 +5067,8 @@ midori_view_get_proxy_tab_label (MidoriView* view)
 {
     GtkWidget* event_box;
     GtkWidget* hbox;
+    #if !GTK_CHECK_VERSION (3, 0, 0)
     static const gchar style_fixup[] =
-    #if GTK_CHECK_VERSION (3, 0, 0)
-        "* {\n"
-        "-GtkButton-default-border : 0;\n"
-        "-GtkButton-default-outside-border : 0;\n"
-        "-GtkButton-inner-border: 0;\n"
-        "-GtkWidget-focus-line-width : 0;\n"
-        "-GtkWidget-focus-padding : 0;\n"
-        "padding: 0;\n"
-        "}";
-    GtkStyleContext* context;
-    GtkCssProvider* css_provider;
-    #else
         "style \"midori-close-button-style\"\n"
         "{\n"
         "GtkWidget::focus-padding = 0\n"
@@ -5109,13 +5102,7 @@ midori_view_get_proxy_tab_label (MidoriView* view)
         view->tab_close = gtk_button_new ();
         gtk_button_set_relief (GTK_BUTTON (view->tab_close), GTK_RELIEF_NONE);
         gtk_button_set_focus_on_click (GTK_BUTTON (view->tab_close), FALSE);
-        #if GTK_CHECK_VERSION (3, 0, 0)
-        context = gtk_widget_get_style_context (view->tab_close);
-        css_provider = gtk_css_provider_new ();
-        gtk_css_provider_load_from_data (css_provider, style_fixup, -1, NULL);
-        gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider),
-                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-        #else
+        #if !GTK_CHECK_VERSION (3, 0, 0)
         gtk_rc_parse_string (style_fixup);
         gtk_widget_set_name (view->tab_close, "midori-close-button");
         g_signal_connect (view->tab_close, "style-set",
diff --git a/wscript b/wscript
index dfe53ab336efdb4b011f8b779286c74dcbc3a6b1..7123886478d94766a02a2f96a7f3e5683f819c14 100644 (file)
--- a/wscript
+++ b/wscript
@@ -518,7 +518,7 @@ def build (bld):
         else:
             Utils.pprint ('BLUE', "logo-shade could not be rasterized.")
 
-    for res_file in ['about.css', 'error.html', 'close.png', 'speeddial-head.html']:
+    for res_file in ['about.css', 'error.html', 'close.png', 'gtk3.css', 'speeddial-head.html']:
         bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/' + res_file)
 
     if bld.env['addons']: