This commit is contained in:
Perberos
2011-11-07 16:46:58 -03:00
commit 528c1e5ff5
532 changed files with 709826 additions and 0 deletions

23
gedit/osx/Makefile.am Executable file
View File

@@ -0,0 +1,23 @@
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_srcdir)/gedit \
-I$(top_builddir)/gedit \
$(GEDIT_CFLAGS) \
$(IGE_MAC_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS)
noinst_LTLIBRARIES = libosx.la
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 \
gedit-osx-delegate.m \
gedit-osx-delegate.h
-include $(top_srcdir)/git.mk

16
gedit/osx/gedit-osx-delegate.h Executable file
View File

@@ -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_ */

84
gedit/osx/gedit-osx-delegate.m Executable file
View File

@@ -0,0 +1,84 @@
#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>
#include <gedit/gedit-commands.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

94
gedit/osx/gedit-osx.c Executable file
View File

@@ -0,0 +1,94 @@
#include "gedit-osx.h"
#include <gdk/gdkquartz.h>
#include <Carbon/Carbon.h>
#import "gedit-osx-delegate.h"
void
gedit_osx_set_window_title (GeditWindow *window,
gchar const *title,
GeditDocument *document)
{
NSWindow *native;
g_return_if_fail (GEDIT_IS_WINDOW (window));
if (GTK_WIDGET (window)->window == NULL)
{
return;
}
native = gdk_quartz_window_get_nswindow (GTK_WIDGET (window)->window);
if (document)
{
bool ismodified;
if (gedit_document_is_untitled (document))
{
[native setRepresentedURL:nil];
}
else
{
const gchar *uri = gedit_document_get_uri (document);
NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
[native setRepresentedURL:nsurl];
}
ismodified = !gedit_document_is_untouched (document);
[native setDocumentEdited:ismodified];
}
else
{
[native setRepresentedURL:nil];
[native setDocumentEdited:false];
}
gtk_window_set_title (GTK_WINDOW (window), title);
}
gboolean
gedit_osx_show_url (const gchar *url)
{
return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
}
gboolean
gedit_osx_show_help (const gchar *link_id)
{
gchar *link;
gboolean ret;
if (link_id)
{
link = g_strdup_printf ("http://library.mate.org/users/gedit/stable/%s",
link_id);
}
else
{
link = g_strdup ("http://library.mate.org/users/gedit/stable/");
}
ret = gedit_osx_show_url (link);
g_free (link);
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);
}

17
gedit/osx/gedit-osx.h Executable file
View File

@@ -0,0 +1,17 @@
#ifndef __GEDIT_OSX_H__
#define __GEDIT_OSX_H__
#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,
GeditDocument *document);
gboolean gedit_osx_show_url (const gchar *url);
gboolean gedit_osx_show_help (const gchar *link_id);
#endif /* __GEDIT_OSX_H__ */