[frogr] Don't use gtk-mac-integration. Check the platform by means of GTK's backend



commit 08c9b88eaa86bafb19327c145f2431b4b8a5bff7
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Mon Nov 26 22:50:15 2012 +0100

    Don't use gtk-mac-integration. Check the platform by means of GTK's backend
    
    Rely in GTK+ 3.4's bundle-in support for application menus instead of
    having Mac specific code for that, relying in GtkOSXApplication.

 configure.ac            |   18 ++----------
 src/Makefile.am         |    4 ++-
 src/frogr-file-loader.c |   10 +++---
 src/frogr-main-view.c   |   72 ++---------------------------------------------
 src/frogr-util.c        |   12 ++++----
 src/frogr-util.h        |    2 +-
 6 files changed, 21 insertions(+), 97 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7c89a7b..ab77f66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,25 +58,13 @@ else
 fi
 
 # Select target platform to make platform-dependant decisions
-
-if $PKG_CONFIG --exists ige-mac-integration; then
+GTK_CHECK_BACKEND([quartz], [3.0], [osx=yes], [osx=no])
+if test "x$osx" = "xyes"; then
    platform=MacOSX
 else
    platform=GNOME
 fi
-
-if test "x$platform" = "xMacOSX"; then
-   echo "Compiling for Mac OSX..."
-
-   IGE_MAC_INTEGRATION_MIN_VERSION=0.9.7
-   PKG_CHECK_MODULES(IGE_MAC_INTEGRATION, ige-mac-integration >= $IGE_MAC_INTEGRATION_MIN_VERSION)
-   FROGR_CFLAGS="$FROGR_CFLAGS $IGE_MAC_INTEGRATION_CFLAGS"
-   FROGR_LIBS="$FROGR_LIBS $IGE_MAC_INTEGRATION_LIBS"
-else
-   echo "Compiling for GNOME..."
-fi
-
-AM_CONDITIONAL([HAVE_MAC_INTEGRATION],[test "x$platform" = "xMacOSX"])
+AM_CONDITIONAL([PLATFORM_MAC],[test "x$osx" = "xyes"])
 
 # Decide whether to use libsoup or libsoup-gnome (if available)
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 5d9780d..c5bdf27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,7 +27,9 @@ frogr_LDADD = \
 frogr_CFLAGS = $(FROGR_CFLAGS) \
 	-DDATA_DIR=\"$(DATA_DIR)\"
 
-if !HAVE_MAC_INTEGRATION
+if PLATFORM_MAC
+frogr_CFLAGS += -DPLATFORM_MAC
+else
 frogr_LDFLAGS = -export-dynamic
 endif
 
diff --git a/src/frogr-file-loader.c b/src/frogr-file-loader.c
index dd9a061..1c3e306 100644
--- a/src/frogr-file-loader.c
+++ b/src/frogr-file-loader.c
@@ -188,7 +188,7 @@ _load_current_file (FrogrFileLoader *self)
                                      G_FILE_QUERY_INFO_NONE,
                                      NULL,
                                      NULL);
-#ifndef MAC_INTEGRATION
+#ifndef PLATFORM_MAC
       const gchar *mime_type;
       gint i;
 
@@ -327,7 +327,7 @@ _load_current_file_cb (GObject *object,
     _finish_task_and_self_destruct (self);
 }
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
 /* The following functions get_char() and _file_matches_pattern() are
    based in code from GTK+'s gtkfilefilter.c and fnmatch.c, licensed
    as GPL version 2 or later (Copyright (C) 1991, 1992, 1993 Free
@@ -483,12 +483,12 @@ _file_matches_pattern (const char *pattern,
 
   return FALSE;
 }
-#endif /* MAC_INTEGRATION */
+#endif /* PLATFORM_MAC */
 
 static gboolean
 _is_video_file (GFile *file)
 {
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
   const gchar * const *supported_videos = NULL;
   gchar *basename = NULL;
   gint i;
@@ -498,7 +498,7 @@ _is_video_file (GFile *file)
 #endif
   gboolean is_video = FALSE;
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
   /* In the Mac we can't use mime types so we match against the list
      of supported file extensions for videos. */
   basename = g_file_get_basename (file);
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 61d60a4..718aced 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -36,8 +36,7 @@
 #include <gdk/gdk.h>
 #include <glib/gi18n.h>
 
-#ifdef MAC_INTEGRATION
-#include <gtkosxapplication.h>
+#ifdef PLATFORM_MAC
 #define GDK_PRIMARY_MODIFIER GDK_META_MASK
 #else
 #define GDK_PRIMARY_MODIFIER GDK_CONTROL_MASK
@@ -156,11 +155,6 @@ void _on_gtk_action_activated (GtkAction *action, gpointer data);
 
 static void _quit_application (FrogrMainView *self);
 
-#ifdef MAC_INTEGRATION
-static gboolean osx_can_activate_cb(GtkWidget* widget, guint signal_id, gpointer data);
-static void _tweak_menu_bar_for_mac (FrogrMainView *self);
-#endif
-
 static void _populate_accounts_submenu (FrogrMainView *self);
 
 static void _initialize_drag_n_drop (FrogrMainView *self);
@@ -520,10 +514,6 @@ _initialize_ui (FrogrMainView *self)
 
   gtk_builder_connect_signals (builder, self);
 
-#ifdef MAC_INTEGRATION
-  _tweak_menu_bar_for_mac (self);
-#endif
-
   /* Update window title */
   _update_window_title (self, FALSE);
 
@@ -808,62 +798,6 @@ _on_gtk_action_activated (GtkAction *action, gpointer data)
     g_assert_not_reached ();
 }
 
-#ifdef MAC_INTEGRATION
-static gboolean
-osx_can_activate_cb(GtkWidget* widget, guint signal_id, gpointer data)
-{
-  return gtk_widget_is_sensitive(widget);
-}
-
-static void
-_tweak_menu_bar_for_mac (FrogrMainView *self)
-{
-  FrogrMainViewPrivate *priv = NULL;
-  GtkOSXApplication *osx_app = NULL;
-  GtkWidget *menu_item = NULL;
-
-  priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
-
-  /* TODO: check in the Mac */
-
-  osx_app = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
-  gtk_osxapplication_set_menu_bar (osx_app, GTK_MENU_SHELL(priv->menu_bar));
-
-  /* Relocate the 'about' menu item in the app menu */
-  menu_item = GTK_WIDGET (gtk_builder_get_object (priv->builder, "about_menu_item"));
-  gtk_osxapplication_insert_app_menu_item (osx_app, menu_item, 0);
-  gtk_osxapplication_insert_app_menu_item (osx_app, gtk_separator_menu_item_new (), 1);
-  gtk_widget_show_all (menu_item);
-
-  /* Relocate the 'authorize' menu item in the app menu */
-  menu_item = GTK_WIDGET (gtk_builder_get_object (priv->builder, "authorize_menu_item"));
-  gtk_osxapplication_insert_app_menu_item (osx_app, menu_item, 2);
-  gtk_widget_show_all (menu_item);
-
-  /* Relocate the 'accounts' menu item in the app menu */
-  menu_item = GTK_WIDGET (gtk_builder_get_object (priv->builder, "accounts_menu_item"));
-  gtk_osxapplication_insert_app_menu_item (osx_app, menu_item, 3);
-  gtk_osxapplication_insert_app_menu_item (osx_app, gtk_separator_menu_item_new (), 4);
-  gtk_widget_show_all (menu_item);
-
-  /* Relocate the 'preferences' menu item in the app menu */
-  menu_item = GTK_WIDGET (gtk_builder_get_object (priv->builder, "preferences_menu_item"));
-  gtk_osxapplication_insert_app_menu_item (osx_app, menu_item, 5);
-  gtk_osxapplication_insert_app_menu_item (osx_app, gtk_separator_menu_item_new (), 6);
-  gtk_widget_show_all (menu_item);
-
-  /* Hide the traditional application menu that won't be shown in the Mac */
-  menu_item = GTK_WIDGET (gtk_builder_get_object (priv->builder, "frogr_menu_item"));
-  gtk_widget_hide (menu_item);
-
-  /* Make sure accelerators are visible when needed */
-  g_signal_connect(priv->menu_bar, "can-activate-accel",
-                   G_CALLBACK(osx_can_activate_cb), NULL);
-
-  gtk_osxapplication_ready(osx_app);
-}
-#endif
-
 static void
 _populate_accounts_submenu (FrogrMainView *self)
 {
@@ -1389,7 +1323,7 @@ _load_pictures_dialog (FrogrMainView *self)
   GtkFileFilter *video_filter;
   gint i;
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
   const gchar * const *supported_images;
   const gchar * const *supported_videos;
 #else
@@ -1408,7 +1342,7 @@ _load_pictures_dialog (FrogrMainView *self)
   image_filter = gtk_file_filter_new ();
   video_filter = gtk_file_filter_new ();
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
   /* Workaround for Mac OSX, where GNOME VFS daemon won't be running,
      so we can't check filter by mime type (will be text/plain) */
   supported_images = frogr_util_get_supported_images ();
diff --git a/src/frogr-util.c b/src/frogr-util.c
index 4c15177..1222203 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -58,7 +58,7 @@ _spawn_command (const gchar* cmd)
 const gchar *
 _get_data_dir (void)
 {
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
   /* For MacOSX, we return the value of the environment value set by
      the wrapper script running the application */
   static gchar *xdg_data_dir = NULL;
@@ -97,7 +97,7 @@ frogr_util_get_locale_dir (void)
   static const gchar *locale_dir = NULL;
   if (!locale_dir)
     {
-#ifndef MAC_INTEGRATION
+#ifndef PLATFORM_MAC
       /* If not in MacOSX, we trust the defined variable better */
       locale_dir = g_strdup (FROGR_LOCALE_DIR);
 #endif
@@ -151,7 +151,7 @@ _open_uris_with_app_info (GList *uris_list, GAppInfo *app_info)
 
       uris = _get_uris_string_from_list (uris_list);
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
       /* In MacOSX use 'open' instead of 'gnome-open' */
       command = g_strdup_printf ("open %s", uris);
 #else
@@ -183,7 +183,7 @@ frogr_util_open_uri (const gchar *uri)
   if (!uri)
     return;
 
-#ifndef MAC_INTEGRATION
+#ifndef PLATFORM_MAC
   /* Supported network URIs */
   if (g_str_has_prefix (uri, "http:") || g_str_has_prefix (uri, "https:"))
     app_info = g_app_info_get_default_for_uri_scheme ("http");
@@ -561,7 +561,7 @@ frogr_util_get_datasize_string (gulong datasize)
   return result;
 }
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
 const gchar * const *
 frogr_util_get_supported_images (void)
 {
@@ -628,4 +628,4 @@ frogr_util_get_supported_mimetypes (void)
 
   return supported_mimetypes;
 }
-#endif /* MAC_INTEGRATION */
+#endif /* PLATFORM_MAC */
diff --git a/src/frogr-util.h b/src/frogr-util.h
index 048021b..7c3b841 100644
--- a/src/frogr-util.h
+++ b/src/frogr-util.h
@@ -47,7 +47,7 @@ GdkPixbuf *frogr_util_get_pixbuf_from_image_contents (const guchar *contents, gs
 
 gchar *frogr_util_get_datasize_string (gulong datasize);
 
-#ifdef MAC_INTEGRATION
+#ifdef PLATFORM_MAC
 const gchar * const *frogr_util_get_supported_images (void);
 
 const gchar * const *frogr_util_get_supported_videos (void);



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