renaming from gedit to pluma
This commit is contained in:
23
pluma/osx/Makefile.am
Executable file
23
pluma/osx/Makefile.am
Executable file
@@ -0,0 +1,23 @@
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/pluma \
|
||||
-I$(top_builddir)/pluma \
|
||||
$(PLUMA_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 = \
|
||||
pluma-osx.c \
|
||||
pluma-osx.h \
|
||||
pluma-osx-delegate.m \
|
||||
pluma-osx-delegate.h
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
16
pluma/osx/pluma-osx-delegate.h
Executable file
16
pluma/osx/pluma-osx-delegate.h
Executable file
@@ -0,0 +1,16 @@
|
||||
#ifndef PLUMA_OSX_DELEGATE_H_
|
||||
#define PLUMA_OSX_DELEGATE_H_
|
||||
|
||||
#import <Foundation/NSAppleEventManager.h>
|
||||
|
||||
@interface PlumaOSXDelegate : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
-(id) init;
|
||||
-(void) openFiles:(NSAppleEventDescriptor*)event
|
||||
withReply:(NSAppleEventDescriptor*)reply;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* PLUMA_OSX_DELEGATE_H_ */
|
84
pluma/osx/pluma-osx-delegate.m
Executable file
84
pluma/osx/pluma-osx-delegate.m
Executable file
@@ -0,0 +1,84 @@
|
||||
#import "pluma-osx-delegate.h"
|
||||
#import <Foundation/NSAppleEventManager.h>
|
||||
#import <Foundation/NSAppleEventDescriptor.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#include <glib.h>
|
||||
#include <pluma/pluma-app.h>
|
||||
#include <pluma/pluma-commands.h>
|
||||
|
||||
@implementation PlumaOSXDelegate
|
||||
-(id)init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
|
||||
|
||||
[em setEventHandler:self
|
||||
andSelector:@selector(openFiles:withReply:)
|
||||
forEventClass:kCoreEventClass
|
||||
andEventID:kAEOpenDocuments];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static PlumaWindow *
|
||||
get_window(NSAppleEventDescriptor *event)
|
||||
{
|
||||
PlumaApp *app = pluma_app_get_default ();
|
||||
return pluma_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)
|
||||
{
|
||||
PlumaWindow *window = get_window (event);
|
||||
pluma_commands_load_uris (window, uris, NULL, 0);
|
||||
|
||||
g_slist_foreach (uris, (GFunc)g_free, NULL);
|
||||
g_slist_free (uris);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
94
pluma/osx/pluma-osx.c
Executable file
94
pluma/osx/pluma-osx.c
Executable file
@@ -0,0 +1,94 @@
|
||||
#include "pluma-osx.h"
|
||||
#include <gdk/gdkquartz.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#import "pluma-osx-delegate.h"
|
||||
|
||||
void
|
||||
pluma_osx_set_window_title (PlumaWindow *window,
|
||||
gchar const *title,
|
||||
PlumaDocument *document)
|
||||
{
|
||||
NSWindow *native;
|
||||
|
||||
g_return_if_fail (PLUMA_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 (pluma_document_is_untitled (document))
|
||||
{
|
||||
[native setRepresentedURL:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
const gchar *uri = pluma_document_get_uri (document);
|
||||
NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
|
||||
|
||||
[native setRepresentedURL:nsurl];
|
||||
}
|
||||
|
||||
ismodified = !pluma_document_is_untouched (document);
|
||||
[native setDocumentEdited:ismodified];
|
||||
}
|
||||
else
|
||||
{
|
||||
[native setRepresentedURL:nil];
|
||||
[native setDocumentEdited:false];
|
||||
}
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), title);
|
||||
}
|
||||
|
||||
gboolean
|
||||
pluma_osx_show_url (const gchar *url)
|
||||
{
|
||||
return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
|
||||
}
|
||||
|
||||
gboolean
|
||||
pluma_osx_show_help (const gchar *link_id)
|
||||
{
|
||||
gchar *link;
|
||||
gboolean ret;
|
||||
|
||||
if (link_id)
|
||||
{
|
||||
link = g_strdup_printf ("http://library.gnome.org/users/pluma/stable/%s",
|
||||
link_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
link = g_strdup ("http://library.gnome.org/users/pluma/stable/");
|
||||
}
|
||||
|
||||
ret = pluma_osx_show_url (link);
|
||||
g_free (link);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_delegate (PlumaOSXDelegate *delegate)
|
||||
{
|
||||
[delegate dealloc];
|
||||
}
|
||||
|
||||
void
|
||||
pluma_osx_init(PlumaApp *app)
|
||||
{
|
||||
PlumaOSXDelegate *delegate = [[PlumaOSXDelegate alloc] init];
|
||||
|
||||
g_object_set_data_full (G_OBJECT (app),
|
||||
"PlumaOSXDelegate",
|
||||
delegate,
|
||||
(GDestroyNotify)destroy_delegate);
|
||||
}
|
17
pluma/osx/pluma-osx.h
Executable file
17
pluma/osx/pluma-osx.h
Executable file
@@ -0,0 +1,17 @@
|
||||
#ifndef __PLUMA_OSX_H__
|
||||
#define __PLUMA_OSX_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <pluma/pluma-window.h>
|
||||
#include <pluma/pluma-app.h>
|
||||
|
||||
void pluma_osx_init (PlumaApp *app);
|
||||
|
||||
void pluma_osx_set_window_title (PlumaWindow *window,
|
||||
gchar const *title,
|
||||
PlumaDocument *document);
|
||||
|
||||
gboolean pluma_osx_show_url (const gchar *url);
|
||||
gboolean pluma_osx_show_help (const gchar *link_id);
|
||||
|
||||
#endif /* __PLUMA_OSX_H__ */
|
Reference in New Issue
Block a user