summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2015-02-04 21:38:45 -0500
committerTingPing <tingping@tingping.se>2015-02-04 21:41:10 -0500
commit75c022c49f96e9a1a8d61c847174cd6819cbc046 (patch)
tree73011ce41b92d8d743b810eaf7f7dea448a746b4 /src/fe-gtk
parentf4f27e438b0791e1c0708c4f031aa80c59d965b1 (diff)
Implement OSX notification backend
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/Makefile.am5
-rw-r--r--src/fe-gtk/notifications/notification-osx.m54
2 files changed, 59 insertions, 0 deletions
diff --git a/src/fe-gtk/Makefile.am b/src/fe-gtk/Makefile.am
index 28c932b1..71179853 100644
--- a/src/fe-gtk/Makefile.am
+++ b/src/fe-gtk/Makefile.am
@@ -32,8 +32,13 @@ endif
 if USE_LIBNOTIFY
 notify_c = notifications/notification-libnotify.c
 else
+if HAVE_GTK_MAC
+notify_c = notifications/notification-osx.m
+hexchat_LDFLAGS = -framework Foundation
+else
 notify_c = notifications/notification-dummy.c
 endif
+endif
 
 hexchat_SOURCES = ascii.c banlist.c chanlist.c chanview.c custom-list.c \
 	dccgui.c editlist.c fe-gtk.c fkeys.c gtkutil.c ignoregui.c joind.c menu.c \
diff --git a/src/fe-gtk/notifications/notification-osx.m b/src/fe-gtk/notifications/notification-osx.m
new file mode 100644
index 00000000..c97c6629
--- /dev/null
+++ b/src/fe-gtk/notifications/notification-osx.m
@@ -0,0 +1,54 @@
+/* HexChat
+ * Copyright (C) 2015 Patrick Griffis.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#import <Cocoa/Cocoa.h>
+#include <gtkosxapplication.h>
+
+void
+notification_backend_show (const char *title, const char *text, int timeout)
+{
+	NSString *str_title = [[NSString alloc] initWithUTF8String:title];
+	NSString *str_text = [[NSString alloc] initWithUTF8String:text];
+
+	NSUserNotification *userNotification = [NSUserNotification new];
+	userNotification.title = str_title;
+	userNotification.informativeText = str_text;
+
+	NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
+	[center scheduleNotification:userNotification];
+
+	[str_title release];
+	[str_text release];
+}
+
+int
+notification_backend_init (void)
+{
+	return 1;
+}
+
+void
+notification_backend_deinit (void)
+{
+}
+
+int
+notification_backend_supported (void)
+{
+	return gtkosx_application_get_bundle_id () != NULL;
+}