From 75c022c49f96e9a1a8d61c847174cd6819cbc046 Mon Sep 17 00:00:00 2001 From: TingPing Date: Wed, 4 Feb 2015 21:38:45 -0500 Subject: Implement OSX notification backend --- src/fe-gtk/Makefile.am | 5 +++ src/fe-gtk/notifications/notification-osx.m | 54 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/fe-gtk/notifications/notification-osx.m (limited to 'src/fe-gtk') 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 +#include + +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; +} -- cgit 1.4.1