diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp index 9b1c62a560ee..9b9a479e9cd5 100644 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp @@ -16,10 +16,13 @@ #include "nsIObserverService.h" #include "nsIURI.h" #include "nsCRT.h" +#include "mozilla/XREAppData.h" #include #include +extern const mozilla::StaticXREAppData* gAppData; + static bool gHasActions = false; static bool gHasCaps = false; @@ -33,6 +36,7 @@ nsAlertsIconListener::notify_notification_show_t nsAlertsIconListener::notify_no nsAlertsIconListener::notify_notification_set_icon_from_pixbuf_t nsAlertsIconListener::notify_notification_set_icon_from_pixbuf = nullptr; nsAlertsIconListener::notify_notification_add_action_t nsAlertsIconListener::notify_notification_add_action = nullptr; nsAlertsIconListener::notify_notification_close_t nsAlertsIconListener::notify_notification_close = nullptr; +nsAlertsIconListener::notify_notification_set_hint_t nsAlertsIconListener::notify_notification_set_hint = nullptr; static void notify_action_cb(NotifyNotification *notification, gchar *action, gpointer user_data) @@ -111,6 +115,7 @@ nsAlertsIconListener::nsAlertsIconListener(nsSystemAlertsService* aBackend, notify_notification_set_icon_from_pixbuf = (notify_notification_set_icon_from_pixbuf_t)dlsym(libNotifyHandle, "notify_notification_set_icon_from_pixbuf"); notify_notification_add_action = (notify_notification_add_action_t)dlsym(libNotifyHandle, "notify_notification_add_action"); notify_notification_close = (notify_notification_close_t)dlsym(libNotifyHandle, "notify_notification_close"); + notify_notification_set_hint = (notify_notification_set_hint_t)dlsym(libNotifyHandle, "notify_notification_set_hint"); if (!notify_is_initted || !notify_init || !notify_get_server_caps || !notify_notification_new || !notify_notification_show || !notify_notification_set_icon_from_pixbuf || !notify_notification_add_action || !notify_notification_close) { dlclose(libNotifyHandle); libNotifyHandle = nullptr; @@ -175,6 +180,20 @@ nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf) notify_action_cb, this, nullptr); } + if (notify_notification_set_hint) { + // If MOZ_DESKTOP_FILE_NAME variable is set, use it as the application id, + // otherwise use gAppData->name + if (getenv("MOZ_DESKTOP_FILE_NAME")) { + // Send the desktop name to identify the application + // The desktop-entry is the part before the .desktop + notify_notification_set_hint(mNotification, "desktop-entry", + g_variant_new("s", getenv("MOZ_DESKTOP_FILE_NAME"))); + } else { + notify_notification_set_hint(mNotification, "desktop-entry", + g_variant_new("s", gAppData->remotingName)); + } + } + // Fedora 10 calls NotifyNotification "closed" signal handlers with a // different signature, so a marshaller is used instead of a C callback to // get the user_data (this) in a parseable format. |closure| is created diff --git a/toolkit/system/gnome/nsAlertsIconListener.h b/toolkit/system/gnome/nsAlertsIconListener.h index f3a745d33061..4aa921accdb4 100644 --- a/toolkit/system/gnome/nsAlertsIconListener.h +++ b/toolkit/system/gnome/nsAlertsIconListener.h @@ -57,6 +57,7 @@ protected: typedef void (*notify_notification_set_icon_from_pixbuf_t)(void*, GdkPixbuf*); typedef void (*notify_notification_add_action_t)(void*, const char*, const char*, NotifyActionCallback, gpointer, GFreeFunc); typedef bool (*notify_notification_close_t)(void*, GError**); + typedef void (*notify_notification_set_hint_t)(NotifyNotification*, const char*, GVariant*); nsCOMPtr mIconRequest; nsCString mAlertTitle; @@ -80,6 +81,7 @@ protected: static notify_notification_set_icon_from_pixbuf_t notify_notification_set_icon_from_pixbuf; static notify_notification_add_action_t notify_notification_add_action; static notify_notification_close_t notify_notification_close; + static notify_notification_set_hint_t notify_notification_set_hint; NotifyNotification* mNotification; gulong mClosureHandler;