Avoid GTK+3 #ifdef and #define GTK_DIALOG_DESTROY_WITH_PARENT

This commit is contained in:
Christian Dywan 2011-10-26 19:46:50 +02:00
parent 9738f07429
commit 4b33fd2c7d
8 changed files with 15 additions and 98 deletions

View file

@ -394,6 +394,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
GtkWidget* browser; GtkWidget* browser;
const gchar* dialog_title; const gchar* dialog_title;
GtkWidget* dialog; GtkWidget* dialog;
GtkWidget* content_area;
gint width, height; gint width, height;
GtkWidget* xfce_heading; GtkWidget* xfce_heading;
GtkWidget* hbox; GtkWidget* hbox;
@ -417,11 +418,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
dialog_title = _("Configure Advertisement filters"); dialog_title = _("Configure Advertisement filters");
dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser), 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
#if !HAVE_OSX #if !HAVE_OSX
#if !HAVE_HILDON #if !HAVE_HILDON
GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_HELP, GTK_RESPONSE_HELP,
@ -429,6 +426,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
#endif #endif
NULL); NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
g_signal_connect (dialog, "destroy", g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed), &dialog); G_CALLBACK (gtk_widget_destroyed), &dialog);
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES); 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 */ /* TODO: We need mnemonics */
if ((xfce_heading = sokoke_xfce_header_new ( if ((xfce_heading = sokoke_xfce_header_new (
gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title))) gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
#if GTK_CHECK_VERSION(3,0,0) gtk_box_pack_start (GTK_BOX (content_area), xfce_heading, FALSE, FALSE, 0);
gtk_box_pack_start (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
xfce_heading, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), hbox, gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 12);
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
vbox = gtk_vbox_new (FALSE, 0); vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 4); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 4);
button = gtk_label_new (NULL); button = gtk_label_new (NULL);
@ -565,19 +553,10 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
G_CALLBACK (adblock_preferences_help_clicked_cb), dialog); */ G_CALLBACK (adblock_preferences_help_clicked_cb), dialog); */
gtk_box_pack_end (GTK_BOX (hbox), gtk_box_pack_end (GTK_BOX (hbox),
button, FALSE, FALSE, 4); button, FALSE, FALSE, 4);
#if GTK_CHECK_VERSION(3,0,0) gtk_box_pack_end (GTK_BOX (content_area),
gtk_box_pack_end (gtk_dialog_get_content_area(GTK_DIALOG (dialog)),
hbox, FALSE, FALSE, 0); hbox, FALSE, FALSE, 0);
#else
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox),
hbox, FALSE, FALSE, 0);
#endif
#endif #endif
#if GTK_CHECK_VERSION(3,0,0) gtk_widget_show_all (content_area);
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); g_object_unref (browser);
@ -831,6 +810,7 @@ adblock_custom_block_image_cb (GtkWidget* widget,
MidoriApp* app; MidoriApp* app;
GtkWidget* browser; GtkWidget* browser;
GtkWidget* dialog; GtkWidget* dialog;
GtkWidget* content_area;
GtkSizeGroup* sizegroup; GtkSizeGroup* sizegroup;
GtkWidget* hbox; GtkWidget* hbox;
GtkWidget* label; GtkWidget* label;
@ -842,21 +822,14 @@ adblock_custom_block_image_cb (GtkWidget* widget,
title = _("Edit rule"); title = _("Edit rule");
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (browser), 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
NULL); NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
#if GTK_CHECK_VERSION(3,0,0) gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
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
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
hbox = gtk_hbox_new (FALSE, 8); hbox = gtk_hbox_new (FALSE, 8);
@ -869,11 +842,7 @@ adblock_custom_block_image_cb (GtkWidget* widget,
gtk_entry_set_text (GTK_ENTRY (entry), gtk_entry_set_text (GTK_ENTRY (entry),
g_object_get_data (G_OBJECT (widget), "uri")); g_object_get_data (G_OBJECT (widget), "uri"));
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
#if GTK_CHECK_VERSION(3,0,0) gtk_container_add (GTK_CONTAINER (content_area), hbox);
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_widget_show_all (hbox); gtk_widget_show_all (hbox);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
@ -911,11 +880,7 @@ adblock_populate_popup_cb (WebKitWebView* web_view,
WebKitHitTestResultContext context; WebKitHitTestResultContext context;
WebKitHitTestResult* hit_test; 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); 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.x = x;
event.y = y; event.y = y;
hit_test = webkit_web_view_get_hit_test_result (web_view, &event); hit_test = webkit_web_view_get_hit_test_result (web_view, &event);

View file

@ -15,7 +15,6 @@
#include <midori/midori.h> #include <midori/midori.h>
#include <midori/sokoke.h> #include <midori/sokoke.h>
#include <glib.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include "config.h" #include "config.h"

View file

@ -363,21 +363,13 @@ panel_add_feed_cb (FeedPanel* panel,
dialog = gtk_dialog_new_with_buttons ( dialog = gtk_dialog_new_with_buttons (
_("New feed"), GTK_WINDOW (priv->browser), _("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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
NULL); NULL);
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); 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); 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); sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
hbox = gtk_hbox_new (FALSE, 8); 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_activates_default (GTK_ENTRY (entry), TRUE);
gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_entry_set_text (GTK_ENTRY (entry), "");
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); 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); 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_widget_show_all (hbox);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);

View file

@ -176,11 +176,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
dialog_title = _("Customize Keyboard shortcuts"); dialog_title = _("Customize Keyboard shortcuts");
dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser), 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
#if !HAVE_OSX #if !HAVE_OSX
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
#endif #endif
@ -193,11 +189,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
g_signal_connect (dialog, "response", g_signal_connect (dialog, "response",
G_CALLBACK (shortcuts_preferences_response_cb), NULL); G_CALLBACK (shortcuts_preferences_response_cb), NULL);
#if GTK_CHECK_VERSION(3,0,0)
dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); 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 ( if ((xfce_heading = sokoke_xfce_header_new (
gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title))) gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
gtk_box_pack_start (GTK_BOX (dialog_vbox), gtk_box_pack_start (GTK_BOX (dialog_vbox),
@ -260,11 +252,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
0, GTK_SORT_ASCENDING); 0, GTK_SORT_ASCENDING);
g_object_unref (model); g_object_unref (model);
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_show_all (gtk_dialog_get_content_area(GTK_DIALOG (dialog))); 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); g_object_unref (browser);

View file

@ -58,6 +58,10 @@ G_BEGIN_DECLS
else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED) else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
#endif #endif
#if GTK_CHECK_VERSION (3, 0, 0)
#define GTK_DIALOG_NO_SEPARATOR 0
#endif
#if !GTK_CHECK_VERSION(2, 12, 0) #if !GTK_CHECK_VERSION(2, 12, 0)
void void

View file

@ -14,16 +14,13 @@
#endif #endif
#include "katze-http-auth.h" #include "katze-http-auth.h"
#include "gtk3-compat.h"
#include <libsoup/soup.h> #include <libsoup/soup.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_dialog_get_content_area(dialog) dialog->vbox
#endif
struct _KatzeHttpAuth struct _KatzeHttpAuth
{ {
GObject parent_instance; GObject parent_instance;
@ -212,11 +209,7 @@ katze_http_auth_session_authenticate_cb (SoupSession* session,
dialog = gtk_dialog_new_with_buttons (_("Authentication Required"), dialog = gtk_dialog_new_with_buttons (_("Authentication Required"),
NULL, NULL,
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL); NULL);

View file

@ -791,11 +791,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
title = new_bookmark ? _("New bookmark") : _("Edit bookmark"); title = new_bookmark ? _("New bookmark") : _("Edit bookmark");
dialog = gtk_dialog_new_with_buttons ( dialog = gtk_dialog_new_with_buttons (
title, GTK_WINDOW (browser), 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL); NULL);
@ -4263,11 +4259,7 @@ _action_bookmarks_import_activate (GtkAction* action,
dialog = gtk_dialog_new_with_buttons ( dialog = gtk_dialog_new_with_buttons (
_("Import bookmarks..."), GTK_WINDOW (browser), _("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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Import bookmarks"), GTK_RESPONSE_ACCEPT, _("_Import bookmarks"), GTK_RESPONSE_ACCEPT,
NULL); NULL);
@ -4587,11 +4579,7 @@ _action_clear_private_data_activate (GtkAction* action,
/* i18n: Dialog: Clear Private Data, in the Tools menu */ /* i18n: Dialog: Clear Private Data, in the Tools menu */
dialog = gtk_dialog_new_with_buttons (_("Clear Private Data"), dialog = gtk_dialog_new_with_buttons (_("Clear Private Data"),
GTK_WINDOW (browser), 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Clear private data"), GTK_RESPONSE_ACCEPT, NULL); _("_Clear private data"), GTK_RESPONSE_ACCEPT, NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));

View file

@ -910,11 +910,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action,
dialog = gtk_dialog_new_with_buttons ( dialog = gtk_dialog_new_with_buttons (
new_engine ? _("Add search engine") : _("Edit search engine"), new_engine ? _("Add search engine") : _("Edit search engine"),
toplevel ? GTK_WINDOW (toplevel) : NULL, 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
new_engine ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, new_engine ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL); NULL);
@ -1309,11 +1305,7 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action)
gtk_widget_get_toplevel (search_action->last_proxy) : NULL; gtk_widget_get_toplevel (search_action->last_proxy) : NULL;
dialog = gtk_dialog_new_with_buttons (dialog_title, dialog = gtk_dialog_new_with_buttons (dialog_title,
toplevel ? GTK_WINDOW (toplevel) : NULL, 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, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
#if !HAVE_OSX #if !HAVE_OSX
#if !HAVE_HILDON #if !HAVE_HILDON
GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_HELP, GTK_RESPONSE_HELP,