[Xfce4-commits] [xfce/libxfce4ui] 01/01: Fix build with --enable-debug=full and GTK3 (bug #11176)

noreply at xfce.org noreply at xfce.org
Wed Feb 18 18:23:40 CET 2015


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository xfce/libxfce4ui.

commit ca1729ba6097d91df02d1bf85fac370a5ac9335a
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Wed Feb 18 17:59:21 2015 +0100

    Fix build with --enable-debug=full and GTK3 (bug #11176)
    
    This patch updates libxfce4ui for all the current deprecation
    warnings when the GTK3 version is built. Mostly that GTK_STOCK
    has been deprecated in 3.10 and dialog_set_image in 3.12.
---
 libxfce4kbd-private/xfce-shortcut-dialog.c   |   10 ++-
 libxfce4kbd-private/xfce-shortcuts-grabber.c |    4 ++
 libxfce4kbd-private/xfce-shortcuts.c         |   21 +++++-
 libxfce4ui/xfce-dialogs.c                    |   88 ++++++++++++++++++++++----
 libxfce4ui/xfce-gtk-extensions.c             |    6 ++
 5 files changed, 114 insertions(+), 15 deletions(-)

diff --git a/libxfce4kbd-private/xfce-shortcut-dialog.c b/libxfce4kbd-private/xfce-shortcut-dialog.c
index 86aea2e..bb29b1e 100644
--- a/libxfce4kbd-private/xfce-shortcut-dialog.c
+++ b/libxfce4kbd-private/xfce-shortcut-dialog.c
@@ -233,13 +233,21 @@ xfce_shortcut_dialog_create_contents (XfceShortcutDialog *dialog,
   /* Create clear button for xfwm4 */
   if (g_utf8_collate (provider, "xfwm4") == 0)
     {
+#if GTK_CHECK_VERSION (3, 10, 0)
+      button = gtk_button_new_from_icon_name ("edit-clear", GTK_ICON_SIZE_BUTTON);
+#else
       button = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
+#endif
       gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_REJECT);
       gtk_widget_show (button);
     }
 
   /* Create cancel button */
+#if GTK_CHECK_VERSION (3, 10, 0)
+  button = gtk_button_new_with_mnemonic (_("_Cancel"));
+#else
   button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+#endif
   gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CANCEL);
   gtk_widget_show (button);
 
@@ -334,7 +342,7 @@ xfce_shortcut_dialog_run (XfceShortcutDialog *dialog,
       if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
         continue;
 
-      if (gdk_device_grab (device, gtk_widget_get_root_window (GTK_WIDGET (dialog)),
+      if (gdk_device_grab (device, gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
                            GDK_OWNERSHIP_WINDOW, TRUE,
                            GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
                            NULL, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
diff --git a/libxfce4kbd-private/xfce-shortcuts-grabber.c b/libxfce4kbd-private/xfce-shortcuts-grabber.c
index b51e0d6..43dfca6 100644
--- a/libxfce4kbd-private/xfce-shortcuts-grabber.c
+++ b/libxfce4kbd-private/xfce-shortcuts-grabber.c
@@ -233,7 +233,11 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
   g_return_if_fail (key != NULL);
 
   display = gdk_display_get_default ();
+#if GTK_CHECK_VERSION (3, 10, 0)
+  screens = 1;
+#else
   screens = gdk_display_get_n_screens (display);
+#endif
   keymap = gdk_keymap_get_default ();
 
   /* Map virtual modifiers to non-virtual modifiers */
diff --git a/libxfce4kbd-private/xfce-shortcuts.c b/libxfce4kbd-private/xfce-shortcuts.c
index be5dd8f..af2b86e 100644
--- a/libxfce4kbd-private/xfce-shortcuts.c
+++ b/libxfce4kbd-private/xfce-shortcuts.c
@@ -153,7 +153,12 @@ xfce_shortcut_conflict_dialog (GtkWindow   *parent,
         owner_button_text = g_strdup_printf (_(conflict_messages[i].owner_button_text), owner_action_name);
         other_button_text = g_strdup_printf (_(conflict_messages[i].other_button_text), other_action_name);
 
-        response = xfce_message_dialog (parent, title, GTK_STOCK_DIALOG_QUESTION,
+        response = xfce_message_dialog (parent, title,
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                                        GTK_STOCK_DIALOG_QUESTION,
+#else
+                                        "dialog-question",
+#endif
                                         title, secondary_text,
                                         XFCE_BUTTON_TYPE_MIXED, NULL, owner_button_text, GTK_RESPONSE_ACCEPT,
                                         XFCE_BUTTON_TYPE_MIXED, NULL, other_button_text, GTK_RESPONSE_REJECT,
@@ -172,9 +177,19 @@ xfce_shortcut_conflict_dialog (GtkWindow   *parent,
 
   if (G_UNLIKELY (!handled))
     {
-      xfce_message_dialog (parent, title, GTK_STOCK_DIALOG_ERROR,
+      xfce_message_dialog (parent, title,
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                           GTK_STOCK_DIALOG_ERROR,
+#else
+                           "dialog-error",
+#endif
                            title, _("This shortcut is already being used for something else."),
-                           GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                           GTK_STOCK_CLOSE,
+#else
+                           "window-close",
+#endif
+                           GTK_RESPONSE_CLOSE, NULL);
       response = GTK_RESPONSE_REJECT;
     }
 
diff --git a/libxfce4ui/xfce-dialogs.c b/libxfce4ui/xfce-dialogs.c
index 9c7502e..2057c1b 100644
--- a/libxfce4ui/xfce-dialogs.c
+++ b/libxfce4ui/xfce-dialogs.c
@@ -255,13 +255,27 @@ xfce_dialog_show_help_with_version (GtkWindow   *parent,
 
   dialog = xfce_message_dialog_new (parent,
                                     _("Online Documentation"),
+#if !GTK_CHECK_VERSION (3, 10, 0)
                                     GTK_STOCK_DIALOG_QUESTION,
+#else
+                                    "dialog-question",
+#endif
                                     primary,
                                     _("You will be redirected to the documentation website "
                                       "where the help pages are maintained and translated."),
-                                    GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                                    GTK_STOCK_CANCEL,
+#else
+                                    "gtk-cancel",
+#endif
+                                    GTK_RESPONSE_NO,
                                     XFCE_BUTTON_TYPE_MIXED,
-                                        GTK_STOCK_HELP, _("_Read Online"),
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                                        GTK_STOCK_HELP,
+#else
+                                        "help-browser",
+#endif
+                                        _("_Read Online"),
                                         GTK_RESPONSE_YES,
                                     NULL);
   g_free (primary);
@@ -317,9 +331,19 @@ xfce_dialog_show_info (GtkWindow   *parent,
   primary_text = g_strdup_vprintf (primary_format, args);
   va_end (args);
 
-  xfce_message_dialog (parent, _("Information"), GTK_STOCK_DIALOG_INFO,
+  xfce_message_dialog (parent, _("Information"),
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                       GTK_STOCK_DIALOG_INFO,
+#else
+                       "dialog-information",
+#endif
                        primary_text, secondary_text,
-                       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                       GTK_STOCK_CLOSE,
+#else
+                       "window-close",
+#endif
+                       GTK_RESPONSE_CLOSE, NULL);
 
   g_free (primary_text);
 }
@@ -350,9 +374,19 @@ xfce_dialog_show_warning (GtkWindow   *parent,
   primary_text = g_strdup_vprintf (primary_format, args);
   va_end (args);
 
-  xfce_message_dialog (parent, _("Warning"), GTK_STOCK_DIALOG_WARNING,
+  xfce_message_dialog (parent, _("Warning"),
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                       GTK_STOCK_DIALOG_WARNING,
+#else
+                       "dialog-warning",
+#endif
                        primary_text, secondary_text,
-                       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                       GTK_STOCK_CLOSE,
+#else
+                       "window-close",
+#endif
+                       GTK_RESPONSE_CLOSE, NULL);
 
   g_free (primary_text);
 }
@@ -384,9 +418,19 @@ xfce_dialog_show_error (GtkWindow    *parent,
   primary_text = g_strdup_vprintf (primary_format, args);
   va_end (args);
 
-  xfce_message_dialog (parent, _("Error"), GTK_STOCK_DIALOG_ERROR,
+  xfce_message_dialog (parent, _("Error"),
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                       GTK_STOCK_DIALOG_ERROR,
+#else
+                       "dialog-error",
+#endif
                        primary_text, error ? error->message : NULL,
-                       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+#if !GTK_CHECK_VERSION (3, 10, 0)
+                       GTK_STOCK_CLOSE,
+#else
+                       "window-close",
+#endif
+                       GTK_RESPONSE_CLOSE, NULL);
 
   g_free (primary_text);
 }
@@ -430,13 +474,29 @@ xfce_dialog_confirm (GtkWindow   *parent,
   va_end (args);
 
   /* whether this will be a yes/no dialog */
-  if (stock_id != NULL && strcmp (stock_id, GTK_STOCK_YES) == 0)
-    no_stock_id = GTK_STOCK_NO;
+  if (stock_id != NULL && (strcmp (stock_id, "gtk-yes") == 0 || strcmp (stock_id, "yes")) == 0)
+    {
+#if GTK_CHECK_VERSION (3, 10, 0)
+      no_stock_id = "gtk-no";
+#else
+      no_stock_id = GTK_STOCK_NO;
+#endif
+    }
   else
-    no_stock_id = GTK_STOCK_CANCEL;
+    {
+#if GTK_CHECK_VERSION (3, 10, 0)
+      no_stock_id = "gtk-cancel";
+#else
+      no_stock_id = GTK_STOCK_CANCEL;
+#endif
+    }
 
   response_id = xfce_message_dialog (parent, _("Question"),
+#if !GTK_CHECK_VERSION (3, 10, 0)
                                      GTK_STOCK_DIALOG_QUESTION,
+#else
+                                     "dialog-question",
+#endif
                                      primary_text, secondary_text,
                                      no_stock_id, GTK_RESPONSE_NO,
                                      XFCE_BUTTON_TYPE_MIXED, stock_id,
@@ -517,8 +577,14 @@ xfce_message_dialog_new_valist (GtkWindow   *parent,
   if (icon_stock_id != NULL)
     {
       /* set dialog and window icon */
+#if GTK_CHECK_VERSION (3, 10, 0)
+      image = gtk_image_new_from_icon_name (icon_stock_id, GTK_ICON_SIZE_DIALOG);
+      gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), image);
+#else
       image = gtk_image_new_from_stock (icon_stock_id, GTK_ICON_SIZE_DIALOG);
       gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
+#endif
+
       gtk_widget_show (image);
       gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_stock_id);
     }
diff --git a/libxfce4ui/xfce-gtk-extensions.c b/libxfce4ui/xfce-gtk-extensions.c
index 194dc31..0857dc2 100644
--- a/libxfce4ui/xfce-gtk-extensions.c
+++ b/libxfce4ui/xfce-gtk-extensions.c
@@ -65,17 +65,23 @@ xfce_gtk_button_new_mixed (const gchar *stock_id,
       if (stock_id != NULL)
         {
           /* create image widget */
+#if !GTK_CHECK_VERSION (3, 10, 0)
           if (g_str_has_prefix (stock_id, "gtk-"))
             image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
           else
+#endif
             image = gtk_image_new_from_icon_name (stock_id, GTK_ICON_SIZE_BUTTON);
           gtk_button_set_image (GTK_BUTTON (button), image);
         }
     }
   else
     {
+#if !GTK_CHECK_VERSION (3, 10, 0)
       /* fall back to a stock button */
       button = gtk_button_new_from_stock (stock_id);
+#else
+      button = gtk_button_new_with_label (label);
+#endif
     }
 
   return button;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list