[Xfce4-commits] <midori:master> Use secondary toolbar class for panel title

Christian Dywan noreply at xfce.org
Sat Jul 28 11:14:01 CEST 2012


Updating branch refs/heads/master
         to 96f616a237f23ae389c9384f103bf213d42424b4 (commit)
       from 5bed5082ed6cfb66644dd2a60650d842cc8b4f37 (commit)

commit 96f616a237f23ae389c9384f103bf213d42424b4
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Jul 28 11:06:40 2012 +0200

    Use secondary toolbar class for panel title
    
    Also introduce a utility function to make adding
    the class more readable.
    
    Fixes: https://bugs.launchpad.net/midori/+bug/1026384

 extensions/adblock.c         |    7 ++-----
 katze/katze-preferences.c    |    7 ++-----
 katze/katze-utils.c          |   10 ++++++++++
 katze/katze-utils.h          |    4 ++++
 midori/midori-browser.c      |   16 ++++------------
 midori/midori-panel.c        |    1 +
 midori/midori-searchaction.c |    7 ++-----
 toolbars/midori-findbar.c    |    5 +----
 8 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/extensions/adblock.c b/extensions/adblock.c
index 96d414c..7480f75 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -477,11 +477,8 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
         #endif
         NULL);
-    #if GTK_CHECK_VERSION (3, 0, 0)
-    gtk_style_context_add_class (gtk_widget_get_style_context (
-        gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog),
-            GTK_RESPONSE_HELP)), "help_button");
-    #endif
+    katze_widget_add_class (gtk_dialog_get_widget_for_response (
+        GTK_DIALOG (dialog), GTK_RESPONSE_HELP), "help_button");
     content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
     g_signal_connect (dialog, "destroy",
                       G_CALLBACK (gtk_widget_destroyed), &dialog);
diff --git a/katze/katze-preferences.c b/katze/katze-preferences.c
index cd89ffe..6108fd4 100644
--- a/katze/katze-preferences.c
+++ b/katze/katze-preferences.c
@@ -110,11 +110,8 @@ katze_preferences_init (KatzePreferences* preferences)
     gtk_dialog_add_buttons (GTK_DIALOG (preferences),
         GTK_STOCK_HELP, GTK_RESPONSE_HELP,
         NULL);
-    #if GTK_CHECK_VERSION (3, 0, 0)
-    gtk_style_context_add_class (gtk_widget_get_style_context (
-        gtk_dialog_get_widget_for_response (GTK_DIALOG (preferences),
-            GTK_RESPONSE_HELP)), "help_button");
-    #endif
+    katze_widget_add_class (gtk_dialog_get_widget_for_response (
+        GTK_DIALOG (preferences), GTK_RESPONSE_HELP), "help_button");
 
     gtk_dialog_add_buttons (GTK_DIALOG (preferences),
         #if HAVE_HILDON
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index 6842581..c206923 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -1576,6 +1576,16 @@ katze_uri_entry_new (GtkWidget* other_widget)
     return entry;
 }
 
+void
+katze_widget_add_class (GtkWidget*   widget,
+                        const gchar* class_name)
+{
+    #if GTK_CHECK_VERSION (3,0,0)
+    GtkStyleContext* context = gtk_widget_get_style_context (widget);
+    gtk_style_context_add_class (context, class_name);
+    #endif
+}
+
 /**
  * katze_assert_str_equal:
  * @input: a string
diff --git a/katze/katze-utils.h b/katze/katze-utils.h
index 274aebb..bf97cbf 100644
--- a/katze/katze-utils.h
+++ b/katze/katze-utils.h
@@ -161,6 +161,10 @@ GtkWidget*
 katze_uri_entry_new                  (GtkWidget*      other_widget);
 
 void
+katze_widget_add_class               (GtkWidget*      widget,
+                                      const gchar*    class_name);
+
+void
 katze_assert_str_equal               (const gchar*    input,
                                       const gchar*    result,
                                       const gchar*    expected);
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 5115bcf..4e091a4 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -4798,11 +4798,8 @@ _action_clear_private_data_activate (GtkAction*     action,
             GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
             _("_Clear private data"), GTK_RESPONSE_ACCEPT, NULL);
-        #if GTK_CHECK_VERSION (3, 0, 0)
-        gtk_style_context_add_class (gtk_widget_get_style_context (
-            gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog),
-                GTK_RESPONSE_ACCEPT)), "noundo");
-        #endif
+        katze_widget_add_class (gtk_dialog_get_widget_for_response (
+            GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT), "noundo");
         content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
         gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
         screen = gtk_widget_get_screen (GTK_WIDGET (browser));
@@ -6523,9 +6520,7 @@ midori_browser_init (MidoriBrowser* browser)
     /* Create the navigationbar */
     browser->navigationbar = gtk_ui_manager_get_widget (
         ui_manager, "/toolbar_navigation");
-#if GTK_CHECK_VERSION(3,0,0)
-    gtk_style_context_add_class(gtk_widget_get_style_context(browser->navigationbar), "primary-toolbar");
-#endif
+    katze_widget_add_class (browser->navigationbar, "primary-toolbar");
     /* FIXME: Settings should be connected with screen changes */
     gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
     if (gtk_settings)
@@ -6557,10 +6552,7 @@ midori_browser_init (MidoriBrowser* browser)
 
     /* Bookmarkbar */
     browser->bookmarkbar = gtk_toolbar_new ();
-#if GTK_CHECK_VERSION (3, 0, 0)
-    gtk_style_context_add_class (
-        gtk_widget_get_style_context (browser->bookmarkbar), "secondary-toolbar");
-#endif
+    katze_widget_add_class (browser->bookmarkbar, "secondary-toolbar");
     gtk_widget_set_name (browser->bookmarkbar, "MidoriBookmarkbar");
     gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->bookmarkbar),
                                GTK_ICON_SIZE_MENU);
diff --git a/midori/midori-panel.c b/midori/midori-panel.c
index dd10c8f..61e4ad9 100644
--- a/midori/midori-panel.c
+++ b/midori/midori-panel.c
@@ -300,6 +300,7 @@ midori_panel_init (MidoriPanel* panel)
 
     /* Create the titlebar */
     labelbar = gtk_toolbar_new ();
+    katze_widget_add_class (labelbar, "secondary-toolbar");
     panel->labelbar = labelbar;
     gtk_toolbar_set_icon_size (GTK_TOOLBAR (labelbar), GTK_ICON_SIZE_MENU);
     gtk_toolbar_set_style (GTK_TOOLBAR (labelbar), GTK_TOOLBAR_ICONS);
diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c
index 6164d33..76dbda4 100644
--- a/midori/midori-searchaction.c
+++ b/midori/midori-searchaction.c
@@ -1341,11 +1341,8 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action)
         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
         #endif
         NULL);
-    #if GTK_CHECK_VERSION (3, 0, 0)
-    gtk_style_context_add_class (gtk_widget_get_style_context (
-        gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog),
-            GTK_RESPONSE_HELP)), "help_button");
-    #endif
+    katze_widget_add_class (gtk_dialog_get_widget_for_response (
+        GTK_DIALOG (dialog), GTK_RESPONSE_HELP), "help_button");
     g_signal_connect (dialog, "destroy",
                       G_CALLBACK (gtk_widget_destroyed), &search_action->dialog);
     gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c
index 6e5435f..8bb167e 100644
--- a/toolbars/midori-findbar.c
+++ b/toolbars/midori-findbar.c
@@ -263,10 +263,7 @@ midori_findbar_init (MidoriFindbar* findbar)
     GtkToolItem* toolitem;
 
     gtk_widget_set_name (GTK_WIDGET (findbar), "MidoriFindbar");
-    #if GTK_CHECK_VERSION (3, 0, 0)
-    gtk_style_context_add_class (
-        gtk_widget_get_style_context (GTK_WIDGET (findbar)), "bottom-toolbar");
-    #endif
+    katze_widget_add_class (GTK_WIDGET (findbar), "bottom-toolbar");
     gtk_toolbar_set_icon_size (GTK_TOOLBAR (findbar), GTK_ICON_SIZE_MENU);
     gtk_toolbar_set_style (GTK_TOOLBAR (findbar), GTK_TOOLBAR_BOTH_HORIZ);
     gtk_toolbar_set_show_arrow (GTK_TOOLBAR (findbar), FALSE);


More information about the Xfce4-commits mailing list