From: Christian Dywan Date: Wed, 26 Oct 2011 17:46:50 +0000 (+0200) Subject: Avoid GTK+3 #ifdef and #define GTK_DIALOG_DESTROY_WITH_PARENT X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b33fd2c7d99f7b9267fc152019bb978ae4a792a;p=midori Avoid GTK+3 #ifdef and #define GTK_DIALOG_DESTROY_WITH_PARENT --- diff --git a/extensions/adblock.c b/extensions/adblock.c index ecb491c8..6e8b3f7f 100644 --- a/extensions/adblock.c +++ b/extensions/adblock.c @@ -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); diff --git a/extensions/addons.c b/extensions/addons.c index b6cf5396..8709e824 100644 --- a/extensions/addons.c +++ b/extensions/addons.c @@ -15,7 +15,6 @@ #include #include -#include #include #include "config.h" diff --git a/extensions/feed-panel/main.c b/extensions/feed-panel/main.c index 39b2e602..89567d5e 100644 --- a/extensions/feed-panel/main.c +++ b/extensions/feed-panel/main.c @@ -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); diff --git a/extensions/shortcuts.c b/extensions/shortcuts.c index c399868a..f10ba985 100644 --- a/extensions/shortcuts.c +++ b/extensions/shortcuts.c @@ -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); diff --git a/katze/gtk3-compat.h b/katze/gtk3-compat.h index b1b3b103..5858a731 100644 --- a/katze/gtk3-compat.h +++ b/katze/gtk3-compat.h @@ -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 diff --git a/katze/katze-http-auth.c b/katze/katze-http-auth.c index 62ca99ae..fbd321ce 100644 --- a/katze/katze-http-auth.c +++ b/katze/katze-http-auth.c @@ -14,16 +14,13 @@ #endif #include "katze-http-auth.h" +#include "gtk3-compat.h" #include #include #include #include -#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); diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 7f1eaecd..8a0514ea 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -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)); diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c index d7a2efc7..6c7acbcc 100644 --- a/midori/midori-searchaction.c +++ b/midori/midori-searchaction.c @@ -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,