]> spindle.queued.net Git - midori/commitdiff
Avoid GTK+3 #ifdef and #define GTK_DIALOG_DESTROY_WITH_PARENT
authorChristian Dywan <christian@twotoasts.de>
Wed, 26 Oct 2011 17:46:50 +0000 (19:46 +0200)
committerChristian Dywan <christian@twotoasts.de>
Wed, 26 Oct 2011 18:07:11 +0000 (20:07 +0200)
extensions/adblock.c
extensions/addons.c
extensions/feed-panel/main.c
extensions/shortcuts.c
katze/gtk3-compat.h
katze/katze-http-auth.c
midori/midori-browser.c
midori/midori-searchaction.c

index ecb491c8b963ecf582cddf6afa89379016696a2f..6e8b3f7f4f35b4d0dd26157be3d04a1571db7605 100644 (file)
@@ -394,6 +394,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
     GtkWidget* browser;
     const gchar* dialog_title;
     GtkWidget* dialog;
+    GtkWidget* content_area;
     gint width, height;
     GtkWidget* xfce_heading;
     GtkWidget* hbox;
@@ -417,11 +418,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
 
     dialog_title = _("Configure Advertisement filters");
     dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         #if !HAVE_OSX
         #if !HAVE_HILDON
         GTK_STOCK_HELP, GTK_RESPONSE_HELP,
@@ -429,6 +426,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
         #endif
         NULL);
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
     g_signal_connect (dialog, "destroy",
                       G_CALLBACK (gtk_widget_destroyed), &dialog);
     gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
@@ -442,19 +440,9 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
     /* TODO: We need mnemonics */
     if ((xfce_heading = sokoke_xfce_header_new (
         gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
-#if GTK_CHECK_VERSION(3,0,0)
-        gtk_box_pack_start (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
-                            xfce_heading, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (content_area), xfce_heading, FALSE, FALSE, 0);
     hbox = gtk_hbox_new (FALSE, 0);
-    gtk_box_pack_start (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), hbox,
-                                 TRUE, TRUE, 12);
-#else
-        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
-                            xfce_heading, FALSE, FALSE, 0);
-    hbox = gtk_hbox_new (FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
-                                 TRUE, TRUE, 12);
-#endif
+    gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 12);
     vbox = gtk_vbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 4);
     button = gtk_label_new (NULL);
@@ -565,19 +553,10 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
         G_CALLBACK (adblock_preferences_help_clicked_cb), dialog); */
     gtk_box_pack_end (GTK_BOX (hbox),
         button, FALSE, FALSE, 4);
-#if GTK_CHECK_VERSION(3,0,0)
-    gtk_box_pack_end (gtk_dialog_get_content_area(GTK_DIALOG (dialog)),
+    gtk_box_pack_end (GTK_BOX (content_area),
         hbox, FALSE, FALSE, 0);
-#else
-    gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox),
-        hbox, FALSE, FALSE, 0);
-#endif
     #endif
-#if GTK_CHECK_VERSION(3,0,0)
-    gtk_widget_show_all (gtk_dialog_get_content_area(GTK_DIALOG (dialog)));
-#else
-    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
-#endif
+    gtk_widget_show_all (content_area);
 
     g_object_unref (browser);
 
@@ -831,6 +810,7 @@ adblock_custom_block_image_cb (GtkWidget*       widget,
     MidoriApp* app;
     GtkWidget* browser;
     GtkWidget* dialog;
+    GtkWidget* content_area;
     GtkSizeGroup* sizegroup;
     GtkWidget* hbox;
     GtkWidget* label;
@@ -842,21 +822,14 @@ adblock_custom_block_image_cb (GtkWidget*       widget,
 
     title = _("Edit rule");
     dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (browser),
-#if GTK_CHECK_VERSION(3,0,0)
-            GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
             GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
             GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
             NULL);
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
     gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
     gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-#if GTK_CHECK_VERSION(3,0,0)
-    gtk_container_set_border_width (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), 5);
-#else
-    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
-#endif
+    gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
     sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
     hbox = gtk_hbox_new (FALSE, 8);
@@ -869,11 +842,7 @@ adblock_custom_block_image_cb (GtkWidget*       widget,
     gtk_entry_set_text (GTK_ENTRY (entry),
                         g_object_get_data (G_OBJECT (widget), "uri"));
     gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
-    gtk_container_add (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), hbox);
-#else
-    gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
-#endif
+    gtk_container_add (GTK_CONTAINER (content_area), hbox);
     gtk_widget_show_all (hbox);
 
     gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
@@ -911,11 +880,7 @@ adblock_populate_popup_cb (WebKitWebView*   web_view,
     WebKitHitTestResultContext context;
     WebKitHitTestResult* hit_test;
 
-#if GTK_CHECK_VERSION(3,0,0)
     gdk_window_get_pointer (gtk_widget_get_window(GTK_WIDGET (web_view)), &x, &y, NULL);
-#else
-    gdk_window_get_pointer (GTK_WIDGET (web_view)->window, &x, &y, NULL);
-#endif
     event.x = x;
     event.y = y;
     hit_test = webkit_web_view_get_hit_test_result (web_view, &event);
index b6cf5396049250ff7820fc3f63051de85e5a7f4b..8709e8241f93c28480fe3a82fea4830bbf669bde 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <midori/midori.h>
 #include <midori/sokoke.h>
-#include <glib.h>
 #include <glib/gstdio.h>
 
 #include "config.h"
index 39b2e60280ed5ecd13ad831059cc23e111b27bf8..89567d5e57b1f3e7007e32232b7db3d9f5d3fe1c 100644 (file)
@@ -363,21 +363,13 @@ panel_add_feed_cb (FeedPanel*   panel,
 
     dialog = gtk_dialog_new_with_buttons (
             _("New feed"), GTK_WINDOW (priv->browser),
-#if GTK_CHECK_VERSION(3,0,0)
-            GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
             GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
             GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
             NULL);
     gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
     gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-#if GTK_CHECK_VERSION(3,0,0)
     gtk_container_set_border_width (GTK_CONTAINER(gtk_dialog_get_content_area( GTK_DIALOG (dialog))), 5);
-#else
-    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
-#endif
     sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
     hbox = gtk_hbox_new (FALSE, 8);
@@ -389,11 +381,7 @@ panel_add_feed_cb (FeedPanel*   panel,
     gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
     gtk_entry_set_text (GTK_ENTRY (entry), "");
     gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
     gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox);
-#else
-    gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
-#endif
     gtk_widget_show_all (hbox);
 
     gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
index c399868a71f090528213c0c42c68347cd9ccd150..f10ba985a7e5ea1c105ac42d4bfe16eddde73e15 100644 (file)
@@ -176,11 +176,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
 
     dialog_title = _("Customize Keyboard shortcuts");
     dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         #if !HAVE_OSX
         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
         #endif
@@ -193,11 +189,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
     g_signal_connect (dialog, "response",
                       G_CALLBACK (shortcuts_preferences_response_cb), NULL);
 
-#if GTK_CHECK_VERSION(3,0,0)
     dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
-#else
-    dialog_vbox = GTK_DIALOG (dialog)->vbox;
-#endif
     if ((xfce_heading = sokoke_xfce_header_new (
         gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
         gtk_box_pack_start (GTK_BOX (dialog_vbox),
@@ -260,11 +252,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
                                           0, GTK_SORT_ASCENDING);
     g_object_unref (model);
 
-#if GTK_CHECK_VERSION(3,0,0)
     gtk_widget_show_all (gtk_dialog_get_content_area(GTK_DIALOG (dialog)));
-#else
-    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
-#endif
 
     g_object_unref (browser);
 
index b1b3b103a9aead9e68523656ed9bc8ce7b599171..5858a731d2a818572a83ec75458496eb20a9fc43 100644 (file)
@@ -58,6 +58,10 @@ G_BEGIN_DECLS
         else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
 #endif
 
+#if GTK_CHECK_VERSION (3, 0, 0)
+    #define GTK_DIALOG_NO_SEPARATOR 0
+#endif
+
 #if !GTK_CHECK_VERSION(2, 12, 0)
 
 void
index 62ca99ae871d126508994c4f64cd28778250ceaf..fbd321cebb55209c450d14ff6ac1687557d97c20 100644 (file)
 #endif
 
 #include "katze-http-auth.h"
+#include "gtk3-compat.h"
 
 #include <libsoup/soup.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 
-#if !GTK_CHECK_VERSION (2, 14, 0)
-    #define gtk_dialog_get_content_area(dialog) dialog->vbox
-#endif
-
 struct _KatzeHttpAuth
 {
     GObject parent_instance;
@@ -212,11 +209,7 @@ katze_http_auth_session_authenticate_cb (SoupSession*   session,
 
     dialog = gtk_dialog_new_with_buttons (_("Authentication Required"),
         NULL,
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
         GTK_STOCK_OK, GTK_RESPONSE_OK,
         NULL);
index 7f1eaecd59f065de856f7a4b820e92c1b0696ef0..8a0514ea2e531a0d3f5c400db40acd442c319d4c 100644 (file)
@@ -791,11 +791,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
         title = new_bookmark ? _("New bookmark") : _("Edit bookmark");
     dialog = gtk_dialog_new_with_buttons (
         title, GTK_WINDOW (browser),
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
         new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
         NULL);
@@ -4263,11 +4259,7 @@ _action_bookmarks_import_activate (GtkAction*     action,
 
     dialog = gtk_dialog_new_with_buttons (
         _("Import bookmarks..."), GTK_WINDOW (browser),
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
         _("_Import bookmarks"), GTK_RESPONSE_ACCEPT,
         NULL);
@@ -4587,11 +4579,7 @@ _action_clear_private_data_activate (GtkAction*     action,
         /* i18n: Dialog: Clear Private Data, in the Tools menu */
         dialog = gtk_dialog_new_with_buttons (_("Clear Private Data"),
             GTK_WINDOW (browser),
-#if GTK_CHECK_VERSION(3,0,0)
-            GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
             GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
             _("_Clear private data"), GTK_RESPONSE_ACCEPT, NULL);
         content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
index d7a2efc74c3e52d4602e8b71097365ac612e68cc..6c7acbcc6949019b98861dc42aa1c908a04776f6 100644 (file)
@@ -910,11 +910,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action,
     dialog = gtk_dialog_new_with_buttons (
         new_engine ? _("Add search engine") : _("Edit search engine"),
         toplevel ? GTK_WINDOW (toplevel) : NULL,
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
         new_engine ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
         NULL);
@@ -1309,11 +1305,7 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action)
         gtk_widget_get_toplevel (search_action->last_proxy) : NULL;
     dialog = gtk_dialog_new_with_buttons (dialog_title,
         toplevel ? GTK_WINDOW (toplevel) : NULL,
-#if GTK_CHECK_VERSION(3,0,0)
-        GTK_DIALOG_DESTROY_WITH_PARENT,
-#else
         GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
-#endif
         #if !HAVE_OSX
         #if !HAVE_HILDON
         GTK_STOCK_HELP, GTK_RESPONSE_HELP,