Skip to content

Commit

Permalink
Proper support for Growl 1.3 notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
fanquake committed Mar 22, 2012
1 parent 31c2fa4 commit da21661
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/qt/notificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
if (status != kLSApplicationNotFoundErr) {
CFBundleRef bundle = CFBundleCreate(0, cfurl);
CFRelease(cfurl);
if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
mode = Growl;
if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
mode = Growl13;
else
mode = Growl12;
}
CFRelease(cfurl);
CFRelease(bundle);
}
#endif
Expand Down Expand Up @@ -226,7 +229,7 @@ void Notificator::notifySystray(Class cls, const QString &title, const QString &
void Notificator::notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon)
{
const QString script(
"tell application \"GrowlHelperApp\"\n"
"tell application \"%5\"\n"
" set the allNotificationsList to {\"Notification\"}\n" // -- Make a list of all the notification types (all)
" set the enabledNotificationsList to {\"Notification\"}\n" // -- Make a list of the notifications (enabled)
" register as application \"%1\" all notifications allNotificationsList default notifications enabledNotificationsList\n" // -- Register our script with Growl
Expand Down Expand Up @@ -265,7 +268,8 @@ void Notificator::notifyGrowl(Class cls, const QString &title, const QString &te
QString quotedTitle(title), quotedText(text);
quotedTitle.replace("\\", "\\\\").replace("\"", "\\");
quotedText.replace("\\", "\\\\").replace("\"", "\\");
qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon), 0);
QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp");
qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0);
}
#endif

Expand Down
3 changes: 2 additions & 1 deletion src/qt/notificator.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public slots:
None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
Freedesktop, /**< Use DBus org.freedesktop.Notifications */
QSystemTray, /**< Use QSystemTray::showMessage */
Growl /**< Use the Growl notification system (Mac only) */
Growl12, /**< Use the Growl 1.2 notification system (Mac only) */
Growl13, /**< Use the Growl 1.3 notification system (Mac only) */
};
QString programName;
Mode mode;
Expand Down

0 comments on commit da21661

Please sign in to comment.