[devhelp] Convert IgeMacIntegration to GtkOSXApplication
- From: Frederic Peters <fpeters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Convert IgeMacIntegration to GtkOSXApplication
- Date: Sat, 17 Dec 2011 15:53:04 +0000 (UTC)
commit cfb0218a77c8cbb1121720ecd70783eaa3da7b06
Author: Philip Chimento <philip chimento gmail com>
Date: Thu Nov 10 17:47:22 2011 +0100
Convert IgeMacIntegration to GtkOSXApplication
IgeMacIntegration is deprecated and only works on 32-bit Macs;
this change is necessary for Devhelp to build on 64-bit Macs.
https://bugzilla.gnome.org/show_bug.cgi?id=663789
configure.ac | 6 +++---
src/dh-util.c | 51 ++++++++-------------------------------------------
src/dh-window.c | 38 +++++++++++++++++++++++---------------
3 files changed, 34 insertions(+), 61 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6075b41..62288b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,13 +51,13 @@ IGE_PLATFORM_CHECK
if test "x$IGE_PLATFORM" = xx11; then
gconf_pkgconfig="gconf-2.0 >= 2.6.0"
libwnck_pkgconfig=
- igemacintegration_pkgconfig=
+ gtkmacintegration_pkgconfig=
REQUIRES_LIBWNCK=
HAVE_WNCK=no
else
gconf_pkgconfig=
libwnck_pkgconfig=
- igemacintegration_pkgconfig="ige-mac-integration >= 0.8.2"
+ gtkmacintegration_pkgconfig="gtk-mac-integration >= 1.0.0"
REQUIRES_LIBWNCK=
HAVE_WNCK=no
fi
@@ -75,7 +75,7 @@ PKG_CHECK_MODULES(LIBDEVHELP, [
gtk+-3.0 >= 3.0.2
$gconf_pkgconfig
$libwnck_pkgconfig
- $igemacintegration_pkgconfig
+ $gtkmacintegration_pkgconfig
webkitgtk-3.0
])
diff --git a/src/dh-util.c b/src/dh-util.c
index eee64a4..b529567 100644
--- a/src/dh-util.c
+++ b/src/dh-util.c
@@ -24,7 +24,7 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_QUARTZ
-#include <CoreFoundation/CoreFoundation.h>
+#include <gtkosxapplication.h>
#endif
#include "ige-conf.h"
#include "dh-util.h"
@@ -120,34 +120,10 @@ dh_util_builder_connect (GtkBuilder *builder,
#ifdef GDK_WINDOWING_QUARTZ
static gchar *
-cf_string_to_utf8 (CFStringRef str)
-{
- CFIndex len;
- gchar *ret;
-
- len = CFStringGetMaximumSizeForEncoding (CFStringGetLength (str),
- kCFStringEncodingUTF8) + 1;
-
- ret = g_malloc (len);
- ret[len] = '\0';
-
- if (CFStringGetCString (str, ret, len, kCFStringEncodingUTF8))
- return ret;
-
- g_free (ret);
- return NULL;
-}
-
-static gchar *
util_get_mac_data_dir (void)
{
- const gchar *env;
- CFBundleRef cf_bundle;
- UInt32 type;
- UInt32 creator;
- CFURLRef cf_url;
- CFStringRef cf_string;
- gchar *ret, *tmp;
+ const gchar *env, *ret;
+ gchar *tmp;
/* The environment variable overrides all. */
env = g_getenv ("DEVHELP_DATADIR");
@@ -155,25 +131,14 @@ util_get_mac_data_dir (void)
return g_strdup (env);
}
- cf_bundle = CFBundleGetMainBundle ();
- if (!cf_bundle) {
- return NULL;
- }
-
- /* Only point into the bundle if it's an application. */
- CFBundleGetPackageInfo (cf_bundle, &type, &creator);
- if (type != 'APPL') {
+ /* If we are not in a bundle, then follow the normal rules. */
+ if (quartz_application_get_bundle_id () == NULL) {
return NULL;
}
- cf_url = CFBundleCopyBundleURL (cf_bundle);
- cf_string = CFURLCopyFileSystemPath (cf_url, kCFURLPOSIXPathStyle);
- ret = cf_string_to_utf8 (cf_string);
- CFRelease (cf_string);
- CFRelease (cf_url);
-
- tmp = g_build_filename (ret, "Contents", "Resources", NULL);
- g_free (ret);
+ ret = quartz_application_get_resource_path ();
+ tmp = g_strdup (ret);
+ g_printerr("ret: %s\n", tmp);
return tmp;
}
diff --git a/src/dh-window.c b/src/dh-window.c
index a240284..1454760 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -33,7 +33,7 @@
#include <webkit/webkit.h>
#ifdef GDK_WINDOWING_QUARTZ
-#include <ige-mac-integration.h>
+#include <gtkosxapplication.h>
#endif
#include "dh-book-tree.h"
@@ -1082,33 +1082,41 @@ window_populate (DhWindow *window)
#ifdef GDK_WINDOWING_QUARTZ
{
- GtkWidget *widget;
- IgeMacMenuGroup *group;
+ GtkWidget *widget, *sep;
+ GtkOSXApplication *theApp;
/* Hide toolbar labels. */
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
/* Setup menubar. */
- ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (menubar));
+ theApp = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
+ gtk_osxapplication_set_menu_bar (theApp, GTK_MENU_SHELL (menubar));
gtk_widget_hide (menubar);
widget = gtk_ui_manager_get_widget (priv->manager, "/MenuBar/FileMenu/Quit");
- ige_mac_menu_set_quit_menu_item (GTK_MENU_ITEM (widget));
+ gtk_widget_hide (widget);
- group = ige_mac_menu_add_app_menu_group ();
widget = gtk_ui_manager_get_widget (priv->manager, "/MenuBar/HelpMenu/About");
- ige_mac_menu_add_app_menu_item (group, GTK_MENU_ITEM (widget),
- /* i18n: please don't translate
- * "Devhelp", it's a name, not a
- * generic word. */
- _("About Devhelp"));
+ gtk_osxapplication_insert_app_menu_item (theApp, widget, 0);
+ sep = gtk_separator_menu_item_new ();
+ g_object_ref (sep);
+ gtk_osxapplication_insert_app_menu_item (theApp, sep, 1);
- group = ige_mac_menu_add_app_menu_group ();
widget = gtk_ui_manager_get_widget (priv->manager, "/MenuBar/EditMenu/Preferences");
- ige_mac_menu_add_app_menu_item (group, GTK_MENU_ITEM (widget),
- _("Preferencesâ"));
+ gtk_osxapplication_insert_app_menu_item (theApp, widget, 2);
+ sep = gtk_separator_menu_item_new ();
+ g_object_ref (sep);
+ gtk_osxapplication_insert_app_menu_item (theApp, sep, 3);
- ige_mac_menu_set_global_key_handler_enabled (TRUE);
+ widget = gtk_ui_manager_get_widget (priv->manager, "/MenuBar/HelpMenu");
+ gtk_osxapplication_set_help_menu (theApp, GTK_MENU_ITEM (widget));
+
+ g_signal_connect (theApp,
+ "NSApplicationWillTerminate",
+ G_CALLBACK (window_activate_quit),
+ window);
+
+ gtk_osxapplication_ready (theApp);
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]