[gtk-mac-integration] A cleaner way to fix up those deprecations.



commit 63b2d7d67580394057c01dc73f4e5a7a44dfdaa5
Author: John Ralls <jralls ceridwen us>
Date:   Fri Oct 11 12:12:09 2013 -0700

    A cleaner way to fix up those deprecations.

 configure.ac                   |   19 -------------------
 src/cocoa_menu_item.c          |    2 +-
 src/gtk-mac-menu.c             |    2 +-
 src/gtkosxapplication_quartz.c |   10 +++++-----
 src/test-integration.c         |   32 +++++++++++++++++---------------
 5 files changed, 24 insertions(+), 41 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 89279d4..4854ef4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,17 +38,6 @@ AM_PROG_CC_C_O
 
 AM_PATH_GLIB_2_0([2.14.0])
 AC_MSG_CHECKING([GLib Version])
-if $PKG_CONFIG 'glib-2.0 >= 2.38.0'
-then
-    AC_MSG_RESULT(>=2.38)
-    AC_DEFINE(HAVE_GLIB_2_38,1,[System has GLib 2.38.0 or newer])
-    AC_DEFINE(HAVE_GLIB_2_32,1,[System has GLib 2.32.0 or newer])
-
-elif $PKG_CONFIG 'glib-2.0 >= 2.32.0'
-then
-    AC_MSG_RESULT(>=2.32, < 2.38)
-    AC_DEFINE(HAVE_GLIB_2_32,1,[System has GLib 2.32.0 or newer])
-fi
 
 GTK_DOC_CHECK([1.11], [--flavour no-tmpl])
 
@@ -87,14 +76,6 @@ AC_SUBST(GTK_VERSION)
 AC_MSG_RESULT("$GTK_VERSION")
 AM_CONDITIONAL([INTROSPECTION], [test x$GTK_MAJOR = "xgtk+-3.0"])
 
-AS_IF([test "$GTK_MAJOR" = gtk+-3.0],
-        [PKG_CHECK_EXISTS([gtk+-3.0 >= 3.3.0],
-        [AC_DEFINE([HAVE_GTK_34], 1, [Gtk version 3.3 or higher])
-        PKG_CHECK_EXISTS([gtk+-3.0 >= 3.5.0],
-        [AC_DEFINE([HAVE_GTK_36], 1, [Gtk version 3.3 or higher])
-        PKG_CHECK_EXISTS([gtk+-3.0 >= 3.9.0],
-        AC_DEFINE([HAVE_GTK_310], 1, [Gtk version 3.9 or higher]))],)],)])
-
 GTK_PYTHON_CHECK
 
 GOBJECT_INTROSPECTION_CHECK([0.10.1])
diff --git a/src/cocoa_menu_item.c b/src/cocoa_menu_item.c
index 3f57f1f..38dbe71 100644
--- a/src/cocoa_menu_item.c
+++ b/src/cocoa_menu_item.c
@@ -673,7 +673,7 @@ cocoa_menu_item_add_submenu (GtkMenuShell *menu_shell,
         */
        continue;
 
-#ifndef HAVE_GTK_34
+#if ! GTK_CHECK_VERSION (3, 4, 0)
       if (GTK_IS_TEAROFF_MENU_ITEM (menu_item))
         /*Don't want tearoff items at all */
         continue;
diff --git a/src/gtk-mac-menu.c b/src/gtk-mac-menu.c
index 93ce5f0..e3cea97 100644
--- a/src/gtk-mac-menu.c
+++ b/src/gtk-mac-menu.c
@@ -974,7 +974,7 @@ sync_menu_shell (GtkMenuShell *menu_shell, MenuRef carbon_menu,
       MenuAttributes attrs;
       const gchar *label = get_menu_label_text (menu_item, NULL);
 
-#ifndef HAVE_GTK_310
+#if ! GTK_CHECK_VERSION (3, 10, 0)
       if (GTK_IS_TEAROFF_MENU_ITEM (menu_item))
         continue;
 #endif
diff --git a/src/gtkosxapplication_quartz.c b/src/gtkosxapplication_quartz.c
index 4e90132..d51298f 100644
--- a/src/gtkosxapplication_quartz.c
+++ b/src/gtkosxapplication_quartz.c
@@ -338,7 +338,7 @@ gtkosx_application_constructor (GType gtype,
                                 GObjectConstructParam *properties)
 {
   static GObject *self = NULL;
-#ifdef HAVE_GLIB_2_32
+#if GLIB_CHECK_VERSION (2,32,0)
   static GMutex mutex;
   g_mutex_init (&mutex);
   g_mutex_lock (&mutex);
@@ -352,7 +352,7 @@ gtkosx_application_constructor (GType gtype,
       g_object_add_weak_pointer (self, (gpointer) &self);
 
     }
-#ifdef HAVE_GLIB_2_32
+#if GLIB_CHECK_VERSION (2,32,0)
   g_mutex_unlock (&mutex);
   g_mutex_clear (&mutex);
 #else
@@ -507,12 +507,12 @@ global_event_filter_func (gpointer  windowing_event, GdkEvent *event,
       gtkosx_application_use_quartz_accelerators (app) )
     {
       gboolean result;
-#ifndef HAVE_GTK_36
-      gdk_threads_leave ();
+#if GTK_CHECK_VERSION (3, 6, 0)
       result = [[NSApp mainMenu] performKeyEquivalent: nsevent];
-      gdk_threads_enter ();
 #else
+      gdk_threads_leave ();
       result = [[NSApp mainMenu] performKeyEquivalent: nsevent];
+      gdk_threads_enter ();
 #endif
       if (result) return GDK_FILTER_TRANSLATE;
     }
diff --git a/src/test-integration.c b/src/test-integration.c
index 58c1e9f..f7c4c9a 100644
--- a/src/test-integration.c
+++ b/src/test-integration.c
@@ -56,11 +56,14 @@
  * - GtkRadioMenuItems (special case of GtkCheckMenuItems)
  */
 
+#include <gtk/gtk.h>
+#include <stdio.h>
+
 /* Uncomment ONE of these to test menu-mangling: */
 //#define GTKMACINTEGRATION
 #define GTKOSXAPPLICATION
 /* These others are optional */
-#ifndef HAVE_GTK_310
+#if ! GTK_CHECK_VERSION (3, 10, 0)
 //#define BUILT_UI //The built UI uses deprecated functions
 #endif
 //#define QUARTZ_HANDLERS
@@ -73,9 +76,7 @@
 # endif
 #endif //__x86_64__
 
-#include <gtk/gtk.h>
-#include <stdio.h>
-#if GTK_CHECK_VERSION(2,90,7)
+#if GTK_CHECK_VERSION (2, 90, 7)
 #include <gdk/gdkkeysyms-compat.h>
 #else
 #include <gdk/gdkkeysyms.h>
@@ -297,10 +298,10 @@ test_setup_menu (MenuItems *items, GtkAccelGroup *accel)
   gtk_menu_set_accel_group (GTK_MENU (menu), accel);
   gtk_menu_set_accel_path (GTK_MENU (menu), "<test-integration>/File");
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
-#ifndef HAVE_GTK_310
-  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL);
-#else
+#if GTK_CHECK_VERSION (3, 10, 0)
   item = gtk_menu_item_new_with_label ("Open");
+#else
+  item = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL);
 #endif
   items->open_item = item;
   /* We're being fancy with our connection here so that we don't have to
@@ -314,10 +315,10 @@ test_setup_menu (MenuItems *items, GtkAccelGroup *accel)
                          menu_cbdata_new ("open", items->window),
                          (GClosureNotify) menu_cbdata_delete, 0);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-#ifndef HAVE_GTK_310
-  items->quit_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
-#else
+#if GTK_CHECK_VERSION (3, 10, 0)
   items->quit_item = gtk_menu_item_new_with_label ("Quit");
+#else
+  items->quit_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
 #endif
   g_signal_connect (items->quit_item, "activate", G_CALLBACK (gtk_main_quit), NULL);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), items->quit_item);
@@ -367,10 +368,11 @@ test_setup_menu (MenuItems *items, GtkAccelGroup *accel)
   menu = gtk_menu_new ();
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
 
-#ifndef HAVE_GTK_310
-  items->about_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
-#else
+#if GTK_CHECK_VERSION (3, 10, 0)
   items->about_item = gtk_menu_item_new_with_label ("About");
+#else
+  items->about_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT,
+                                                         NULL);
 #endif
   g_signal_connect_data (items->about_item, "activate",
                          G_CALLBACK (menu_item_activate_cb),
@@ -809,10 +811,10 @@ main (int argc, char **argv)
 #ifdef GTKOSXAPPLICATION
   GtkosxApplication *theApp;
 #endif //GTKOSXAPPLICATION
-#ifndef HAVE_GLIB_2_32
+#if ! GLIB_CHECK_VERSION (2, 34, 0)
   g_thread_init (NULL);
 #endif
-#if ! GTK_CHECK_VERSION(3, 0, 0)
+#if ! GTK_CHECK_VERSION (3, 0, 0)
   gdk_threads_init ();
 #endif //not Gtk3
   gtk_init (&argc, &argv);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]