xed/pluma/osx/pluma-osx.c

94 lines
1.8 KiB
C
Raw Normal View History

2011-11-07 16:52:18 -06:00
#include "pluma-osx.h"
2011-11-07 13:46:58 -06:00
#include <gdk/gdkquartz.h>
#include <Carbon/Carbon.h>
2011-11-07 16:52:18 -06:00
#import "pluma-osx-delegate.h"
2011-11-07 13:46:58 -06:00
void
2011-11-07 16:52:18 -06:00
pluma_osx_set_window_title (PlumaWindow *window,
2011-11-07 13:46:58 -06:00
gchar const *title,
2011-11-07 16:52:18 -06:00
PlumaDocument *document)
2011-11-07 13:46:58 -06:00
{
NSWindow *native;
2011-11-07 16:52:18 -06:00
g_return_if_fail (PLUMA_IS_WINDOW (window));
2011-11-07 13:46:58 -06:00
if (GTK_WIDGET (window)->window == NULL)
{
return;
}
native = gdk_quartz_window_get_nswindow (GTK_WIDGET (window)->window);
if (document)
{
bool ismodified;
2011-11-07 16:52:18 -06:00
if (pluma_document_is_untitled (document))
2011-11-07 13:46:58 -06:00
{
[native setRepresentedURL:nil];
}
else
{
2011-11-07 16:52:18 -06:00
const gchar *uri = pluma_document_get_uri (document);
2011-11-07 13:46:58 -06:00
NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
[native setRepresentedURL:nsurl];
}
2011-11-07 16:52:18 -06:00
ismodified = !pluma_document_is_untouched (document);
2011-11-07 13:46:58 -06:00
[native setDocumentEdited:ismodified];
}
else
{
[native setRepresentedURL:nil];
[native setDocumentEdited:false];
}
gtk_window_set_title (GTK_WINDOW (window), title);
}
gboolean
2011-11-07 16:52:18 -06:00
pluma_osx_show_url (const gchar *url)
2011-11-07 13:46:58 -06:00
{
return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
}
gboolean
2011-11-07 16:52:18 -06:00
pluma_osx_show_help (const gchar *link_id)
2011-11-07 13:46:58 -06:00
{
gchar *link;
gboolean ret;
if (link_id)
{
2011-11-07 16:52:18 -06:00
link = g_strdup_printf ("http://library.gnome.org/users/pluma/stable/%s",
2011-11-07 13:46:58 -06:00
link_id);
}
else
{
2011-11-07 16:52:18 -06:00
link = g_strdup ("http://library.gnome.org/users/pluma/stable/");
2011-11-07 13:46:58 -06:00
}
2011-11-07 16:52:18 -06:00
ret = pluma_osx_show_url (link);
2011-11-07 13:46:58 -06:00
g_free (link);
return ret;
}
static void
2011-11-07 16:52:18 -06:00
destroy_delegate (PlumaOSXDelegate *delegate)
2011-11-07 13:46:58 -06:00
{
[delegate dealloc];
}
void
2011-11-07 16:52:18 -06:00
pluma_osx_init(PlumaApp *app)
2011-11-07 13:46:58 -06:00
{
2011-11-07 16:52:18 -06:00
PlumaOSXDelegate *delegate = [[PlumaOSXDelegate alloc] init];
2011-11-07 13:46:58 -06:00
g_object_set_data_full (G_OBJECT (app),
2011-11-07 16:52:18 -06:00
"PlumaOSXDelegate",
2011-11-07 13:46:58 -06:00
delegate,
(GDestroyNotify)destroy_delegate);
}