[gedit] Implemented file open support on OS X
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gedit] Implemented file open support on OS X
- Date: Sun, 8 Nov 2009 19:53:06 +0000 (UTC)
commit 6f113b5a97dcd19f1efa8d0b675200f063f84c66
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Nov 8 20:46:14 2009 +0100
Implemented file open support on OS X
This fixes bug #585503 and #585506
configure.ac | 2 +
gedit/gedit.c | 7 +-
gedit/osx/Makefile.am | 10 +-
gedit/osx/gedit-osx-delegate.h | 16 +++
gedit/osx/gedit-osx-delegate.m | 83 ++++++++++++
gedit/osx/gedit-osx.c | 19 +++
gedit/osx/gedit-osx.h | 3 +
osx/Info.plist | 280 ++++++++++++++++++++++++++++++++++++----
osx/gedit.bundle | 1 +
osx/launcher.sh | 7 +-
10 files changed, 393 insertions(+), 35 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cfd3693..cedd260 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,6 +132,8 @@ if test "$os_osx" = "yes"; then
AC_SUBST(IGE_MAC_CFLAGS)
AC_SUBST(IGE_MAC_LIBS)
+
+ AC_PROG_OBJC
fi
dnl ===============================================================
diff --git a/gedit/gedit.c b/gedit/gedit.c
index 217e4b4..f07d45d 100644
--- a/gedit/gedit.c
+++ b/gedit/gedit.c
@@ -73,6 +73,7 @@
#ifdef OS_OSX
#include <ige-mac-dock.h>
+#include "osx/gedit-osx.h"
#endif
static guint32 startup_timestamp = 0;
@@ -732,7 +733,11 @@ main (int argc, char *argv[])
free_command_line_data ();
}
- gedit_debug_message (DEBUG_APP, "Start gtk-main");
+ gedit_debug_message (DEBUG_APP, "Start gtk-main");
+
+#ifdef OS_OSX
+ gedit_osx_init(gedit_app_get_default ());
+#endif
gtk_main();
#ifndef G_OS_WIN32
diff --git a/gedit/osx/Makefile.am b/gedit/osx/Makefile.am
index f085115..4d73416 100644
--- a/gedit/osx/Makefile.am
+++ b/gedit/osx/Makefile.am
@@ -10,12 +10,14 @@ INCLUDES = \
noinst_LTLIBRARIES = libosx.la
-libosx_la_LDFLAGS = -framework Carbon -framework ApplicationServices
+libosx_la_LDFLAGS = -framework Carbon -framework ApplicationServices -framework Cocoa
libosx_la_LIBADD = -lobjc
libosx_la_CFLAGS = -xobjective-c
-libosx_la_SOURCES = \
- gedit-osx.c \
- gedit-osx.h
+libosx_la_SOURCES = \
+ gedit-osx.c \
+ gedit-osx.h \
+ gedit-osx-delegate.m \
+ gedit-osx-delegate.h
-include $(top_srcdir)/git.mk
diff --git a/gedit/osx/gedit-osx-delegate.h b/gedit/osx/gedit-osx-delegate.h
new file mode 100644
index 0000000..0b4411e
--- /dev/null
+++ b/gedit/osx/gedit-osx-delegate.h
@@ -0,0 +1,16 @@
+#ifndef GEDIT_OSX_DELEGATE_H_
+#define GEDIT_OSX_DELEGATE_H_
+
+#import <Foundation/NSAppleEventManager.h>
+
+ interface GeditOSXDelegate : NSObject
+{
+}
+
+-(id) init;
+-(void) openFiles:(NSAppleEventDescriptor*)event
+ withReply:(NSAppleEventDescriptor*)reply;
+
+ end
+
+#endif /* GEDIT_OSX_DELEGATE_H_ */
diff --git a/gedit/osx/gedit-osx-delegate.m b/gedit/osx/gedit-osx-delegate.m
new file mode 100644
index 0000000..f7a90f2
--- /dev/null
+++ b/gedit/osx/gedit-osx-delegate.m
@@ -0,0 +1,83 @@
+#import "gedit-osx-delegate.h"
+#import <Foundation/NSAppleEventManager.h>
+#import <Foundation/NSAppleEventDescriptor.h>
+#import <Foundation/NSData.h>
+#include <glib.h>
+#include <gedit/gedit-app.h>
+
+ implementation GeditOSXDelegate
+-(id)init
+{
+ if ((self = [super init]))
+ {
+ NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
+
+ [em setEventHandler:self
+ andSelector:@selector(openFiles:withReply:)
+ forEventClass:kCoreEventClass
+ andEventID:kAEOpenDocuments];
+ }
+
+ return self;
+}
+
+static GeditWindow *
+get_window(NSAppleEventDescriptor *event)
+{
+ GeditApp *app = gedit_app_get_default ();
+ return gedit_app_get_active_window (app);
+}
+
+- (void)openFiles:(NSAppleEventDescriptor*)event
+ withReply:(NSAppleEventDescriptor*)reply
+{
+ NSAppleEventDescriptor *fileList = [event paramDescriptorForKeyword:keyDirectObject];
+ NSInteger i;
+ GSList *uris = NULL;
+
+ if (!fileList)
+ {
+ return;
+ }
+
+ for (i = 1; i <= [fileList numberOfItems]; ++i)
+ {
+ NSAppleEventDescriptor *fileAliasDesc = [fileList descriptorAtIndex:i];
+ NSAppleEventDescriptor *fileURLDesc;
+ NSData *fileURLData;
+ gchar *url;
+
+ if (!fileAliasDesc)
+ {
+ continue;
+ }
+
+ fileURLDesc = [fileAliasDesc coerceToDescriptorType:typeFileURL];
+
+ if (!fileURLDesc)
+ {
+ continue;
+ }
+
+ fileURLData = [fileURLDesc data];
+
+ if (!fileURLData)
+ {
+ continue;
+ }
+
+ url = g_strndup([fileURLData bytes], [fileURLData length]);
+ uris = g_slist_prepend (uris, url);
+ }
+
+ if (uris != NULL)
+ {
+ GeditWindow *window = get_window (event);
+ gedit_commands_load_uris (window, uris, NULL, 0);
+
+ g_slist_foreach (uris, (GFunc)g_free, NULL);
+ g_slist_free (uris);
+ }
+}
+
+ end
\ No newline at end of file
diff --git a/gedit/osx/gedit-osx.c b/gedit/osx/gedit-osx.c
index 397cee3..9f150e2 100644
--- a/gedit/osx/gedit-osx.c
+++ b/gedit/osx/gedit-osx.c
@@ -2,6 +2,8 @@
#include <gdk/gdkquartz.h>
#include <Carbon/Carbon.h>
+#import "gedit-osx-delegate.h"
+
void
gedit_osx_set_window_title (GeditWindow *window,
gchar const *title,
@@ -73,3 +75,20 @@ gedit_osx_show_help (const gchar *link_id)
return ret;
}
+
+static void
+destroy_delegate (GeditOSXDelegate *delegate)
+{
+ [delegate dealloc];
+}
+
+void
+gedit_osx_init(GeditApp *app)
+{
+ GeditOSXDelegate *delegate = [[GeditOSXDelegate alloc] init];
+
+ g_object_set_data_full (G_OBJECT (app),
+ "GeditOSXDelegate",
+ delegate,
+ (GDestroyNotify)destroy_delegate);
+}
\ No newline at end of file
diff --git a/gedit/osx/gedit-osx.h b/gedit/osx/gedit-osx.h
index 6564837..82f0120 100644
--- a/gedit/osx/gedit-osx.h
+++ b/gedit/osx/gedit-osx.h
@@ -3,6 +3,9 @@
#include <gtk/gtk.h>
#include <gedit/gedit-window.h>
+#include <gedit/gedit-app.h>
+
+void gedit_osx_init (GeditApp *app);
void gedit_osx_set_window_title (GeditWindow *window,
gchar const *title,
diff --git a/osx/Info.plist b/osx/Info.plist
index 413d594..e926859 100644
--- a/osx/Info.plist
+++ b/osx/Info.plist
@@ -1,30 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>gedit</string>
- <key>CFBundleGetInfoString</key>
- <string>2.26.2 Copyright 2009, gedit</string>
- <key>CFBundleIconFile</key>
- <string>gedit.icns</string>
- <key>CFBundleIdentifier</key>
- <string>org.gnome.gedit</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>2.26.2</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>2.26.2</string>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright 2009 gedit, GNU General Public License.</string>
- <key>LSMinimumSystemVersion</key>
- <string>10.4</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>gedit</string>
+ <key>CFBundleGetInfoString</key>
+ <string>2.26.2 Copyright 2009, gedit</string>
+ <key>CFBundleIconFile</key>
+ <string>gedit.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.gnome.gedit</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>2.26.2</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>2.26.2</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright 2009 gedit, GNU General Public License.</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.4</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>*</string>
+ <string>F</string>
+ <string>F90</string>
+ <string>Filemaker</string>
+ <string>M</string>
+ <string>act3</string>
+ <string>ada</string>
+ <string>applescript</string>
+ <string>as</string>
+ <string>asm</string>
+ <string>asp</string>
+ <string>awk</string>
+ <string>bak</string>
+ <string>bash</string>
+ <string>b</string>
+ <string>bf</string>
+ <string>brainfuck</string>
+ <string>c</string>
+ <string>cgi</string>
+ <string>c++</string>
+ <string>cfm</string>
+ <string>cob</string>
+ <string>conf</string>
+ <string>cp</string>
+ <string>cpp</string>
+ <string>cs</string>
+ <string>csh</string>
+ <string>css</string>
+ <string>CSS</string>
+ <string>csv</string>
+ <string>custom</string>
+ <string>cxx</string>
+ <string>def</string>
+ <string>default</string>
+ <string>do</string>
+ <string>dtd</string>
+ <string>dxf</string>
+ <string>enc</string>
+ <string>eps</string>
+ <string>err</string>
+ <string>f</string>
+ <string>f90</string>
+ <string>fcgi</string>
+ <string>for</string>
+ <string>fs</string>
+ <string>fscript</string>
+ <string>gcc</string>
+ <string>h</string>
+ <string>hpgl</string>
+ <string>htm</string>
+ <string>HTM</string>
+ <string>html</string>
+ <string>ics</string>
+ <string>idl</string>
+ <string>inc</string>
+ <string>ini</string>
+ <string>java</string>
+ <string>javascript</string>
+ <string>js</string>
+ <string>las</string>
+ <string>lasso</string>
+ <string>latex</string>
+ <string>lgt</string>
+ <string>lisp</string>
+ <string>log</string>
+ <string>ltx</string>
+ <string>lua</string>
+ <string>m</string>
+ <string>m1s</string>
+ <string>mel</string>
+ <string>m4</string>
+ <string>mk</string>
+ <string>mm</string>
+ <string>msl</string>
+ <string>mtl</string>
+ <string>mws</string>
+ <string>mx</string>
+ <string>mxo</string>
+ <string>mysql</string>
+ <string>njs</string>
+ <string>p</string>
+ <string>ps</string>
+ <string>pas</string>
+ <string>pch</string>
+ <string>php</string>
+ <string>php3</string>
+ <string>php4</string>
+ <string>phtml</string>
+ <string>pl</string>
+ <string>plist</string>
+ <string>pm</string>
+ <string>pod</string>
+ <string>postgresql</string>
+ <string>pike</string>
+ <string>pp</string>
+ <string>pro</string>
+ <string>py</string>
+ <string>python</string>
+ <string>pyw</string>
+ <string>r</string>
+ <string>rb</string>
+ <string>rc</string>
+ <string>reb</string>
+ <string>rebol</string>
+ <string>rsp</string>
+ <string>rtf</string>
+ <string>ruby</string>
+ <string>rxp</string>
+ <string>s</string>
+ <string>sgml</string>
+ <string>sh</string>
+ <string>shtm</string>
+ <string>shtml</string>
+ <string>sieve</string>
+ <string>sl</string>
+ <string>strings</string>
+ <string>sty</string>
+ <string>sps</string>
+ <string>spss</string>
+ <string>sql</string>
+ <string>SQL</string>
+ <string>st</string>
+ <string>svg</string>
+ <string>tab</string>
+ <string>tcl</string>
+ <string>tcsh</string>
+ <string>tex</string>
+ <string>text</string>
+ <string>txt</string>
+ <string>types</string>
+ <string>uue</string>
+ <string>v</string>
+ <string>vbs</string>
+ <string>vcard</string>
+ <string>vcs</string>
+ <string>verilog</string>
+ <string>vhd</string>
+ <string>vhdl</string>
+ <string>vrm</string>
+ <string>vrml</string>
+ <string>wmk</string>
+ <string>x</string>
+ <string>xhtml</string>
+ <string>xml</string>
+ <string>xsl</string>
+ <string>xslt</string>
+ <string>yaml</string>
+ </array>
+ <key>CFBundleTypeIconFile</key>
+ <string>geditdoc</string>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>application/base64</string>
+ <string>application/dxf</string>
+ <string>application/php</string>
+ <string>application/plain</string>
+ <string>application/postscript</string>
+ <string>application/rtf</string>
+ <string>application/vnd.hp-hpgl</string>
+ <string>application/x-bsh</string>
+ <string>application/x-csh</string>
+ <string>application/x-javascript</string>
+ <string>application/x-latex</string>
+ <string>application/x-meme</string>
+ <string>application/x-pointplus</string>
+ <string>application/x-rtf</string>
+ <string>application/x-seelogo</string>
+ <string>application/x-sh</string>
+ <string>application/x-shar</string>
+ <string>application/x-tcl</string>
+ <string>application/x-tex</string>
+ <string>application/x-vrml</string>
+ <string>application/xml</string>
+ <string>image/svg+xml</string>
+ <string>image/svg-xml</string>
+ <string>image/vnd.dwg</string>
+ <string>image/x-dwg</string>
+ <string>image/x-xpixmap</string>
+ <string>model/vrml</string>
+ <string>text/asp</string>
+ <string>text/calendar</string>
+ <string>text/css</string>
+ <string>text/directory</string>
+ <string>text/html</string>
+ <string>text/javascript</string>
+ <string>text/pascal</string>
+ <string>text/php</string>
+ <string>text/plain</string>
+ <string>text/richtext</string>
+ <string>text/sgml</string>
+ <string>text/vcard</string>
+ <string>text/x-asm</string>
+ <string>text/x-c</string>
+ <string>text/x-fortran</string>
+ <string>text/x-h</string>
+ <string>text/x-java-source</string>
+ <string>text/x-m</string>
+ <string>text/x-pascal</string>
+ <string>text/x-perl-script</string>
+ <string>text/x-php-script</string>
+ <string>text/x-script.csh</string>
+ <string>text/x-script.perl-module</string>
+ <string>text/x-script.perl</string>
+ <string>text/x-script.phyton</string>
+ <string>text/x-script.sh</string>
+ <string>text/x-script.tcl</string>
+ <string>text/x-script.tcsh</string>
+ <string>text/x-server-parsed-html</string>
+ <string>text/x-sgml</string>
+ <string>text/x-uuencode</string>
+ <string>text/x-vcalendar</string>
+ <string>text/x-vcard</string>
+ <string>text/xml</string>
+ <string>x-world/x-vrml</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>Gedit Document</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>****</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ </dict>
+ </array>
</dict>
</plist>
diff --git a/osx/gedit.bundle b/osx/gedit.bundle
index b35058f..8004911 100644
--- a/osx/gedit.bundle
+++ b/osx/gedit.bundle
@@ -96,6 +96,7 @@
<!-- App icon -->
<data dest="${bundle}/Contents/Resources">${project}/gedit.icns</data>
+ <data dest="${bundle}/Contents/Resources">${project}/geditdoc.icns</data>
<!-- Custom theme settings -->
<data dest="${bundle}/Contents/Resources/etc/gtk-2.0/gtkrc">${project}/gtkrc</data>
diff --git a/osx/launcher.sh b/osx/launcher.sh
index 9f6b4d6..b2ca694 100755
--- a/osx/launcher.sh
+++ b/osx/launcher.sh
@@ -10,11 +10,8 @@ else
EXEC=exec
fi
-name="`basename $0`"
-tmp="`pwd`/$0"
-tmp=`dirname "$tmp"`
-tmp=`dirname "$tmp"`
-bundle=`dirname "$tmp"`
+name=$(basename "$0")
+bundle=$(cd $(dirname "$0")/../../ && pwd)
bundle_contents="$bundle"/Contents
bundle_res="$bundle_contents"/Resources
bundle_lib="$bundle_res"/lib
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]