[gtk-mac-integration] Clean up some deprecations and warnings
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-mac-integration] Clean up some deprecations and warnings
- Date: Fri, 4 Oct 2013 23:16:15 +0000 (UTC)
commit 246d74560c5c8886ae89743c67e744f36c184372
Author: John Ralls <jralls ceridwen us>
Date: Fri Oct 4 16:15:56 2013 -0700
Clean up some deprecations and warnings
configure.ac | 20 ++++++++++++++------
src/gtk-mac-dock.c | 2 +-
src/gtk-mac-menu.c | 4 +++-
src/gtkosxapplication_quartz.c | 39 +++++++++++++++++++++++++++++----------
src/test-integration.c | 2 +-
5 files changed, 48 insertions(+), 19 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b489df0..89279d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,11 +37,17 @@ AC_PROG_OBJC
AM_PROG_CC_C_O
AM_PATH_GLIB_2_0([2.14.0])
-AC_MSG_CHECKING([for GLib >= 2.31.0])
-if $PKG_CONFIG 'glib-2.0 >= 2.32.0'
+AC_MSG_CHECKING([GLib Version])
+if $PKG_CONFIG 'glib-2.0 >= 2.38.0'
then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_GLIB_2_31,1,[System has GLib 2.31.0 or newer])
+ 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])
@@ -83,9 +89,11 @@ 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]))
+ [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]))],)
+ AC_DEFINE([HAVE_GTK_310], 1, [Gtk version 3.9 or higher]))],)],)])
GTK_PYTHON_CHECK
diff --git a/src/gtk-mac-dock.c b/src/gtk-mac-dock.c
index b7e0fb7..3be1243 100644
--- a/src/gtk-mac-dock.c
+++ b/src/gtk-mac-dock.c
@@ -296,7 +296,7 @@ mac_dock_handle_open_documents (const AppleEvent *inAppleEvent,
if (status != noErr)
continue;
- FSRefMakePath (&ref, (char *) path, MAXPATHLEN);
+ FSRefMakePath (&ref, (unsigned char *) path, MAXPATHLEN);
/* FIXME: Add to a list, then emit the open-documents
* signal.
diff --git a/src/gtk-mac-menu.c b/src/gtk-mac-menu.c
index 4f8d362..93ce5f0 100644
--- a/src/gtk-mac-menu.c
+++ b/src/gtk-mac-menu.c
@@ -974,8 +974,10 @@ 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_IS_TEAROFF_MENU_ITEM (menu_item))
continue;
+#endif
if (toplevel && (g_object_get_data (G_OBJECT (menu_item),
"gtk-empty-menu-item")
|| GTK_IS_SEPARATOR_MENU_ITEM (menu_item)))
@@ -1367,4 +1369,4 @@ gtk_mac_menu_sync (GtkMenuShell *menu_shell)
carbon_menu->toplevel, DEBUG_SYNC);
}
-#endif __x86_64__
+#endif /* __x86_64__ */
diff --git a/src/gtkosxapplication_quartz.c b/src/gtkosxapplication_quartz.c
index 38c8615..4e90132 100644
--- a/src/gtkosxapplication_quartz.c
+++ b/src/gtkosxapplication_quartz.c
@@ -31,6 +31,7 @@
#import "GNSMenuBar.h"
#import "GNSMenuItem.h"
+#include <config.h>
#include "gtkosxapplication.h"
#include "gtkosxapplicationprivate.h"
#include "cocoa_menu_item.h"
@@ -183,7 +184,7 @@ get_application_name (void)
NSString *bundlep = [bundle bundlePath];
appname = [[NSFileManager defaultManager]
displayNameAtPath: bundlep];
- g_info ("[get_application_name]: no bundle name key in Info.plist\n");
+ g_message ("[get_application_name]: no bundle name key in Info.plist\n");
}
}
else
@@ -337,16 +338,26 @@ gtkosx_application_constructor (GType gtype,
GObjectConstructParam *properties)
{
static GObject *self = NULL;
+#ifdef HAVE_GLIB_2_32
+ static GMutex mutex;
+ g_mutex_init (&mutex);
+ g_mutex_lock (&mutex);
+#else
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
g_static_mutex_lock (&mutex);
+#endif
if (self == NULL)
{
self = G_OBJECT_CLASS (gtkosx_application_parent_class)->constructor (gtype, n_properties, properties);
g_object_add_weak_pointer (self, (gpointer) &self);
}
+#ifdef HAVE_GLIB_2_32
+ g_mutex_unlock (&mutex);
+ g_mutex_clear (&mutex);
+#else
g_static_mutex_unlock (&mutex);
-
+#endif
return g_object_ref (self);
}
@@ -481,19 +492,28 @@ global_event_filter_func (gpointer windowing_event, GdkEvent *event,
GtkosxApplication* app = user_data;
/* Handle menu events with no window, since they won't go through
- * the regular event processing. We have to release the gdk mutex so
- * that we can recquire it when we invoke the gtk handler. Note well
- * that handlers need to wrap any calls into gtk in
- * gdk_threads_enter() and gdk_threads_leave() in a multi-threaded
- * environment!
+ * the regular event processing. When using Gtk before 3.6, we have
+ * to release the gdk mutex so that we can recquire it when we
+ * invoke the gtk handler. Note well that handlers need to wrap any
+ * calls into gtk in gdk_threads_enter() and gdk_threads_leave() in
+ * a multi-threaded environment!
+ *
+ * With Gtk 3.6 and later, all Gtk calls must be made from the main
+ * thread, so be sure that handlers aren't invoked on a worker
+ * thread; use an idle or timer event to start the handler if
+ * necessary.
*/
if ([nsevent type] == NSKeyDown &&
gtkosx_application_use_quartz_accelerators (app) )
{
gboolean result;
+#ifndef HAVE_GTK_36
gdk_threads_leave ();
result = [[NSApp mainMenu] performKeyEquivalent: nsevent];
gdk_threads_enter ();
+#else
+ result = [[NSApp mainMenu] performKeyEquivalent: nsevent];
+#endif
if (result) return GDK_FILTER_TRANSLATE;
}
return GDK_FILTER_CONTINUE;
@@ -792,10 +812,9 @@ gtkosx_application_insert_app_menu_item (GtkosxApplication* self,
if (index == 0)
{
GtkWidget *widgetLabel = NULL;
- gchar *label = get_menu_label_text (item, &widgetLabel);
- gchar *appname;
+ const gchar *label = get_menu_label_text (item, &widgetLabel);
NSString *nsappname = get_application_name ();
- appname = [nsappname UTF8String];
+ const gchar *appname = [nsappname UTF8String];
gtk_menu_item_set_label (GTK_MENU_ITEM (item), g_strdup_printf ("%s %s", label, appname));
}
diff --git a/src/test-integration.c b/src/test-integration.c
index 448d535..58c1e9f 100644
--- a/src/test-integration.c
+++ b/src/test-integration.c
@@ -809,7 +809,7 @@ main (int argc, char **argv)
#ifdef GTKOSXAPPLICATION
GtkosxApplication *theApp;
#endif //GTKOSXAPPLICATION
-#ifndef HAVE_GLIB_2_31
+#ifndef HAVE_GLIB_2_32
g_thread_init (NULL);
#endif
#if ! GTK_CHECK_VERSION(3, 0, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]