Implement OSX notification backend

This commit is contained in:
TingPing 2015-02-04 21:38:45 -05:00
parent f4f27e438b
commit 75c022c49f
3 changed files with 62 additions and 0 deletions

View File

@ -206,6 +206,8 @@ dnl *********************************************************************
_gdk_tgt=`$PKG_CONFIG --variable=target gdk-2.0`
if test "x$_gdk_tgt" = xquartz; then
AC_PROG_OBJC
PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration-gtk2, [
GUI_LIBS="$GUI_LIBS $GTK_MAC_LIBS"
GUI_CFLAGS="$GUI_CFLAGS $GTK_MAC_CFLAGS"
@ -597,6 +599,7 @@ AM_CONDITIONAL(DO_SYSINFO, test "x$sysinfo" = "xyes")
AM_CONDITIONAL(DO_STATIC_ANALYSIS, test "x$analyze" = "xyes")
AM_CONDITIONAL(USE_DBUS, test "x$dbus" = "xyes")
AM_CONDITIONAL(HAVE_ISO_CODES, test "x$isocodes" = "xyes")
AM_CONDITIONAL(HAVE_GTK_MAC, test "x$_gdk_tgt" = xquartz)
AM_CONDITIONAL(WITH_TM, test "x$theme_manager" != "xno")
dnl *********************************************************************

View File

@ -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 \

View File

@ -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;
}