mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1438051 - [Linux/GNOME] Use notify_notification_set_hint() to pair Firefox with a system notification, r=stransky
Based on patch by Corentin Noël <corentin@elementary.io>
This commit is contained in:
parent
da07964ec2
commit
72c748fd1d
@ -16,10 +16,13 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozilla/XREAppData.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
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
|
||||
|
@ -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<nsICancelable> 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user