Skip to content
Commits on Source (61)
variables:
DEBIAN_FRONTEND: noninteractive
stages:
- build
build:ubuntu:
stage: build
image: ubuntu:devel
before_script:
- apt-get update &&
- apt-get install -q -y --no-install-recommends
gobject-introspection
gtk-doc-tools
libgdk-pixbuf2.0-dev
libgirepository1.0-dev
libglib2.0-dev
libgtk-3-dev
libpopt-dev
xmlto
ninja-build
python3-pip
python3-setuptools
xsltproc
docbook-xsl-ns
- pip3 install meson
script:
- meson _build -Ddocbook_docs=enabled
- ninja -C _build install
artifacts:
expose_as: "Build artifacts"
paths:
- _build/docs/notification-spec.html
- _build/docs/reference/html
- _build/docs/reference/html/index.html
- _build/meson-logs
New in 0.7.11
=============
* Fix potential build errors with old glib version we require
* notify-send: Add support for boolean hints
* notify-send: Support passing any hint value, by parsing variant strings
* notify-send: Add explicit option to create transient notifications
Contributors:
Marco Trevisan
New in 0.7.10
=============
* notify-send: Support commas in icon filenames [Thorsten; !15]
* notify-send: Give failing exit code if showing notification fails [Ray, !13]
* notify-send: Support for replacing an existing notification [Paul; !17]
* notify-send: Add option to wait until notification has been closed [Ben; !18]
* notify-send: Add support for notification actions and responses [Ben; !18]
* notification: Send the application ID when possible [Corentin; !1]
* notification: Use g_memdup2 when available [Marco; !22]
* notification: Improve SNAP detection and confined desktop ID [Marco; !23]
* notification: Add support for getting actions activation token [Marco; !24]
* notify: Use application ID if any to set the fallback app name [Marco; !18]
* Build fixes and improvements [Marco; !22]
* Docs updates [Boris, David; !14, !20]
Contributors:
Marco Trevisan, Boris Shtrasman, Matthias Sweertvaegher, Thorsten Wißmann,
Ray Strode, Maximiliano Sandoval R, David King, Corentin Noël, Paul Collins,
Matthias Sweertvaegher, Ben Blain
New in 0.7.9
============
* Fixed linking in darwin [Iain, Marco; !5]
......
# libnotify
## Description
libnotify is a library for sending desktop notifications to a notification
daemon, as defined in the [org.freedesktop.Notifications][fdo-spec] Desktop
Specification. These notifications can be used to inform the user about an event
or display some form of information without getting in the user's way.
## Notice
For GLib based applications the [GNotification][gnotif] API should be used
instead.
[fdo-spec]: https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html
[gnotif]: https://docs.gtk.org/gio/class.Notification.html
libnotify (0.7.11-1ubuntu1) kinetic; urgency=medium
* Merge with Debian, remaining changes:
- debian/control.in,
debian/rules:
+ generate the notification-daemon recommends with some hacks,
this allows notification-daemon to be demoted to universe
- debian/test/control:
+ don't Depends on notification-daemon:native, the current tests don't
require a server
* debian: Update references as per ubuntu branching
* debian/upstream/metadata: Restore from debian, lost during previous merge
-- Marco Trevisan (Treviño) <marco@ubuntu.com> Wed, 27 Apr 2022 22:20:44 +0200
libnotify (0.7.11-1) unstable; urgency=medium
* New upstream release:
- notify-send: Support for replacing an existing notification (LP: #257135,
Closes: #559544)
- notify-send: Support commas in icon filenames (LP: #674642)
- notify-send: Give failing exit code if showing notification fails
(LP: #1970647, Closes: #609556, Closes: #679653)
- notify-send: Add support for notification actions and responses
(Closes: #571181)
- notify-send: Add option to wait until notification has been closed
- notify-send: Add support for boolean hints (Closes: #636343)
- docs/notify-send: Add missing --app-name to manpage (Closes: #756151)
* debian/rules: Use DPKG_GENSYMBOLS_CHECK_LEVEL instead of override
* debian: Use debhelper 13, and remove explicit --fail-missing
* debian/control: Update Standards-Version, no change needed
* debian/libnotify4.symbols: Add new symbols
* debian/patches: Add transient option to man
-- Marco Trevisan (Treviño) <marco@ubuntu.com> Wed, 27 Apr 2022 21:47:25 +0200
libnotify (0.7.9-3ubuntu5) jammy; urgency=medium
* Drop libnotify4 Recommends on "gnome-shell | notification-daemon" to
......
......@@ -8,7 +8,7 @@ Section: libs
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
XSBC-Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>
Uploaders: Emilio Pozuelo Monfort <pochu@debian.org>, Laurent Bigonville <bigon@debian.org>, Martin Pitt <mpitt@debian.org>, Michael Biebl <biebl@debian.org>
Build-Depends: debhelper-compat (= 12),
Build-Depends: debhelper-compat (= 13),
docbook-xsl-ns,
libglib2.0-dev (>= 2.26),
libgtk-3-dev (>= 3.0.0),
......@@ -20,7 +20,7 @@ Build-Depends: debhelper-compat (= 12),
meson (>= 0.47),
xmlto,
Rules-Requires-Root: no
Standards-Version: 4.5.1
Standards-Version: 4.6.0.1
XS-Debian-Vcs-Browser: https://salsa.debian.org/gnome-team/libnotify
XS-Debian-Vcs-Git: https://salsa.debian.org/gnome-team/libnotify.git
Vcs-Browser: https://salsa.debian.org/gnome-team/libnotify/tree/ubuntu/master
......
......@@ -4,7 +4,7 @@ Section: libs
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
XSBC-Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>
Uploaders: @GNOME_TEAM@
Build-Depends: debhelper-compat (= 12),
Build-Depends: debhelper-compat (= 13),
docbook-xsl-ns,
libglib2.0-dev (>= 2.26),
libgtk-3-dev (>= 3.0.0),
......@@ -16,7 +16,7 @@ Build-Depends: debhelper-compat (= 12),
meson (>= 0.47),
xmlto,
Rules-Requires-Root: no
Standards-Version: 4.5.1
Standards-Version: 4.6.0.1
XS-Debian-Vcs-Browser: https://salsa.debian.org/gnome-team/libnotify
XS-Debian-Vcs-Git: https://salsa.debian.org/gnome-team/libnotify.git
Vcs-Browser: https://salsa.debian.org/gnome-team/libnotify/tree/ubuntu/master
......
......@@ -11,6 +11,7 @@ libnotify.so.4 libnotify4 #MINVER#
notify_notification_clear_actions@Base 0.7.0
notify_notification_clear_hints@Base 0.7.0
notify_notification_close@Base 0.7.0
notify_notification_get_activation_token@Base 0.7.10
notify_notification_get_closed_reason@Base 0.7.0
notify_notification_get_type@Base 0.7.0
notify_notification_new@Base 0.7.0
......
From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
Date: Wed, 27 Apr 2022 21:25:10 +0200
Subject: docs/notify-send: Add --transient option to manpage
Origin: https://gitlab.gnome.org/GNOME/libnotify/-/commit/997115b45
---
docs/notify-send.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/docs/notify-send.xml b/docs/notify-send.xml
index 041466a..cab6fe9 100644
--- a/docs/notify-send.xml
+++ b/docs/notify-send.xml
@@ -122,6 +122,12 @@
<para>Wait for the notification to be closed before exiting. If the <option>expire-time</option> is set, it will be used as the maximum waiting time.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-e</option>, <option>--transient</option></term>
+ <listitem>
+ <para>Show a transient notification. Transient notifications by-pass the server's persistence capability, if any. And so it won't be preserved until the user acknowledges it.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsection>
<refsection>
docs-notify-send-Add-transient-option-to-manpage.patch
......@@ -2,26 +2,20 @@
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,-z,defs -Wl,--as-needed
export DPKG_GENSYMBOLS_CHECK_LEVEL = 4
%:
dh $@ --with gir,gnome
override_dh_makeshlibs:
dh_makeshlibs -- -c4
override_dh_missing:
dh_missing --fail-missing
# This is needed to keep notification-daemon out of Ubuntu main
# since germinate (?) doesn't handle alternate virtual depends well
# Something like this might be safe for Debian too but why bother if it's not needed?
# gnome-shell isn't currently available on s390x so don't recommend either dependency there
# i386 is partial arch
# i386 is partial arch, and we don't build gnome-shell or notification-daemon for
override_dh_gencontrol:
ifneq ($(shell dpkg-vendor --query vendor),Ubuntu)
dh_gencontrol -- -Vnotification-daemon:Recommends='notification-daemon'
else
ifeq (,$(filter i386 s390x,$(DEB_HOST_ARCH)))
ifeq (,$(filter i386,$(DEB_HOST_ARCH)))
dh_gencontrol -- -Vnotification-daemon:Recommends='gnome-shell | notification-daemon'
else
dh_gencontrol
......
......@@ -3,4 +3,5 @@
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:param name="html.stylesheet" select="'docbook.css'"/>
<xsl:param name="generate.consistent.ids" select="1"/>
</xsl:stylesheet>
......@@ -1272,6 +1272,65 @@
</para>
</note>
</sect3>
<sect3 id="signal-activation-token">
<title><literal>org.freedesktop.Notifications.ActivationToken</literal></title>
<funcsynopsis>
<funcprototype>
<funcdef>
<function>org.freedesktop.Notifications.ActivationToken</function>
</funcdef>
<paramdef>UINT32 <parameter>id</parameter></paramdef>
<paramdef>STRING <parameter>activation_token</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This signal can be emitted before a <literal>ActionInvoked</literal>
signal. It carries an activation token that can be used to activate a
toplevel.
</para>
<table>
<title>ActivationToken Parameters</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody valign="top">
<row>
<entry><parameter>id</parameter></entry>
<entry>UINT32</entry>
<entry>
The ID of the notification emitting the <literal>ActionInvoked</literal>
signal.
</entry>
</row>
<row>
<entry><parameter>activation_token</parameter></entry>
<entry>STRING</entry>
<entry>
An activation token. This can be either an X11-style startup ID (see
<ulink url="https://specifications.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup notification protocol</ulink>)
or a
<ulink url="https://gitlab.freedesktop.org/wayland/wayland-protocols/-/tree/main/staging/xdg-activation">Wayland xdg-activation</ulink>
token.
</entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>
Clients should not assume the server will generate this signal. Some
servers may not support user interaction at all, or may not support
the concept of being able to generate an activation token for a
notification.
</para>
</note>
</sect3>
</sect2>
</sect1>
</article>
......@@ -58,6 +58,18 @@
<para>Show help and exit.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-a</option>, <option>--app-name</option>=<replaceable>APP_NAME</replaceable></term>
<listitem>
<para>Specifies the app name for the notification.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-A</option>, <option>--action</option>=[<replaceable>NAME</replaceable>=]<replaceable>Text...</replaceable></term>
<listitem>
<para>Specifies the actions to display to the user. Implies <option>--wait</option> to wait for user input. May be set multiple times. The <replaceable>NAME</replaceable> of the action is output to <literal>stdout</literal>. If <replaceable>NAME</replaceable> is not specified, the numerical index of the option is used (starting with <literal>1</literal>).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-u</option>, <option>--urgency</option>=<replaceable>LEVEL</replaceable></term>
<listitem>
......@@ -69,11 +81,11 @@
</term>
<listitem>
<para>The duration, in milliseconds, for the notification to appear on screen.</para>
<para>(Ubuntu's Notify OSD and GNOME Shell both ignore this parameter.)</para>
<para>Not all implementations use this parameter. GNOME Shell and Notify OSD always ignore it, while Plasma ignores it for notifications with the critical urgency level.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-i</option>, <option>--icon</option>=<replaceable>ICON</replaceable>[,<replaceable>ICON</replaceable>…]
<term><option>-i</option>, <option>--icon</option>=<replaceable>ICON</replaceable>
</term>
<listitem>
<para>Specifies an icon filename or stock icon to display.</para>
......@@ -89,7 +101,25 @@
<varlistentry>
<term><option>-h</option>, <option>--hint</option>=<replaceable>TYPE</replaceable>:<replaceable>NAME</replaceable>:<replaceable>VALUE</replaceable> </term>
<listitem>
<para>Specifies basic extra data to pass. Valid types are <literal>INT</literal>, <literal>DOUBLE</literal>, <literal>STRING</literal> and <literal>BYTE</literal>.</para>
<para>Specifies basic extra data to pass. Valid types are <literal>BOOLEAN</literal>, <literal>INT</literal>, <literal>DOUBLE</literal>, <literal>STRING</literal>, <literal>BYTE</literal> and <literal>VARIANT</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-p</option>, <option>--print-id</option></term>
<listitem>
<para>Print the notification ID.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-r</option>, <option>--replace-id</option>=<replaceable>REPLACE_ID</replaceable></term>
<listitem>
<para>The ID of the notification to replace.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-w</option>, <option>--wait</option></term>
<listitem>
<para>Wait for the notification to be closed before exiting. If the <option>expire-time</option> is set, it will be used as the maximum waiting time.</para>
</listitem>
</varlistentry>
</variablelist>
......
......@@ -27,6 +27,7 @@ notify_notification_clear_hints
notify_notification_add_action
notify_notification_clear_actions
notify_notification_close
notify_notification_get_activation_token
notify_notification_get_closed_reason
<SUBSECTION Standard>
NotifyNotificationPrivate
......
......@@ -69,8 +69,9 @@ pkgconfig.generate(libnotify_lib,
)
introspection = get_option('introspection')
if not introspection.disabled()
find_program('g-ir-scanner', required: introspection.enabled())
g_ir_scanner = find_program('g-ir-scanner', required: introspection.enabled())
if g_ir_scanner.found() and not introspection.disabled()
gnome.generate_gir(libnotify_lib,
sources: headers + sources + enum_types,
namespace: 'Notify',
......
......@@ -68,6 +68,11 @@ struct _NotifyNotificationPrivate
char *app_name;
char *summary;
char *body;
char *activation_token;
const char *snap_path;
const char *snap_name;
char *snap_app;
/* NULL to use icon data. Anything else to have server lookup icon */
char *icon_name;
......@@ -84,6 +89,7 @@ struct _NotifyNotificationPrivate
GHashTable *hints;
gboolean has_nondefault_actions;
gboolean activating;
gboolean updates_pending;
gulong proxy_signal_handler;
......@@ -350,6 +356,104 @@ destroy_pair (CallbackPair *pair)
g_free (pair);
}
static void
maybe_initialize_snap (NotifyNotification *obj)
{
NotifyNotificationPrivate *priv = obj->priv;
gchar *cgroup_contents = NULL;
priv->snap_path = g_getenv ("SNAP");
if (priv->snap_path == NULL)
return;
if (*priv->snap_path == '\0' ||
!strchr (priv->snap_path, G_DIR_SEPARATOR)) {
priv->snap_path = NULL;
return;
}
priv->snap_name = g_getenv ("SNAP_NAME");
if (priv->snap_name && *priv->snap_name == '\0') {
priv->snap_name = NULL;
}
if (g_file_get_contents ("/proc/self/cgroup", &cgroup_contents,
NULL, NULL)) {
gchar **lines = g_strsplit (cgroup_contents, "\n", -1);
gchar *found_snap_name = NULL;
gint i;
for (i = 0; lines[i]; ++i) {
gchar **parts = g_strsplit (lines[i], ":", 3);
gchar *basename;
gchar **ns;
guint ns_length;
if (g_strv_length (parts) != 3) {
g_strfreev (parts);
continue;
}
basename = g_path_get_basename (parts[2]);
g_strfreev (parts);
if (!basename) {
continue;
}
ns = g_strsplit (basename, ".", -1);
ns_length = g_strv_length (ns);
g_free (basename);
if (ns_length < 2 || !g_str_equal (ns[0], "snap")) {
g_strfreev (ns);
continue;
}
if (priv->snap_name == NULL) {
g_free (found_snap_name);
found_snap_name = g_strdup (ns[1]);
}
if (ns_length < 3) {
g_strfreev (ns);
continue;
}
if (priv->snap_name == NULL) {
priv->snap_name = found_snap_name;
found_snap_name = NULL;
}
if (g_str_equal (ns[1], priv->snap_name)) {
priv->snap_app = g_strdup (ns[2]);
g_strfreev (ns);
break;
}
g_strfreev (ns);
}
if (priv->snap_name == NULL && found_snap_name != NULL) {
priv->snap_name = found_snap_name;
found_snap_name = NULL;
}
g_strfreev (lines);
g_free (found_snap_name);
}
if (priv->snap_app == NULL) {
priv->snap_app = g_strdup (priv->snap_name);
}
g_debug ("SNAP path: %s", priv->snap_path);
g_debug ("SNAP name: %s", priv->snap_name);
g_debug ("SNAP app: %s", priv->snap_app);
g_free (cgroup_contents);
}
static void
notify_notification_init (NotifyNotification *obj)
{
......@@ -365,6 +469,8 @@ notify_notification_init (NotifyNotification *obj)
g_str_equal,
g_free,
(GDestroyNotify) destroy_pair);
maybe_initialize_snap (obj);
}
static void
......@@ -380,6 +486,8 @@ notify_notification_finalize (GObject *object)
g_free (priv->summary);
g_free (priv->body);
g_free (priv->icon_name);
g_free (priv->activation_token);
g_free (priv->snap_app);
if (priv->actions != NULL) {
g_slist_foreach (priv->actions, (GFunc) g_free, NULL);
......@@ -431,30 +539,52 @@ try_prepend_path (const char *base_path,
{
gchar *path_filename;
gchar *path_ret;
gboolean was_uri;
if (!path || *path == '\0')
return NULL;
was_uri = TRUE;
path_ret = NULL;
path_filename = g_filename_from_uri (base_path, NULL, NULL);
if (path_filename == NULL) {
was_uri = FALSE;
if (base_path && base_path[0] == G_DIR_SEPARATOR) {
path_filename = g_strdup (base_path);
} else {
path_filename = realpath (base_path, NULL);
if (path_filename == NULL) {
/* File path is not existing, but let's check
* if it's under the base path before giving up
*/
path_filename = g_strdup (base_path);
}
}
}
g_debug ("Trying to look at file '%s' in the '%s' prefix.",
base_path,
path);
path_ret = g_build_filename (path, path_filename, NULL);
if (g_str_has_prefix (path_filename, path)) {
path_ret = g_strdup (path_filename);
} else {
g_debug ("Trying to look at file '%s' in the '%s' prefix.",
base_path,
path);
path_ret = g_build_filename (path, path_filename, NULL);
}
if (!g_file_test (path_ret, G_FILE_TEST_EXISTS)) {
g_debug ("Nothing found at %s", path_ret);
g_free (path_ret);
path_ret = NULL;
} else if (was_uri) {
gchar *uri = g_filename_to_uri (path_ret, NULL, NULL);
if (uri != NULL) {
g_free (path_ret);
path_ret = uri;
}
}
g_free (path_filename);
......@@ -463,33 +593,33 @@ try_prepend_path (const char *base_path,
}
static gchar *
try_prepend_desktop (const gchar *desktop)
try_prepend_snap_desktop (NotifyNotification *notification,
const gchar *desktop)
{
gchar *ret;
NotifyNotificationPrivate *priv = notification->priv;
gchar *ret = NULL;
/*
* if it's an absolute path, try prepending $SNAP, otherwise try
* $SNAP_NAME_; snap .desktop files are in the format
* ${SNAP_NAME}_; snap .desktop files are in the format
* ${SNAP_NAME}_desktop_file_name
*/
ret = try_prepend_path (desktop, g_getenv ("SNAP"));
if (ret == NULL) {
const gchar *snap_name = g_getenv ("SNAP_NAME");
ret = try_prepend_path (desktop, priv->snap_path);
if (snap_name != NULL && snap_name[0] != '\0') {
ret = g_strdup_printf ("%s_%s", snap_name, desktop);
}
if (ret == NULL && priv->snap_name != NULL &&
strchr (desktop, G_DIR_SEPARATOR) == NULL) {
ret = g_strdup_printf ("%s_%s", priv->snap_name, desktop);
}
return ret;
}
static gchar *
try_prepend_snap (const gchar *value)
try_prepend_snap (NotifyNotification *notification,
const gchar *value)
{
/* hardcoded paths to icons might be relocated under $SNAP */
return try_prepend_path (value, g_getenv ("SNAP"));
return try_prepend_path (value, notification->priv->snap_path);
}
......@@ -524,7 +654,8 @@ notify_notification_update_internal (NotifyNotification *notification,
g_free (notification->priv->icon_name);
notification->priv->icon_name = (icon != NULL
&& *icon != '\0' ? g_strdup (icon) : NULL);
snapped_icon = try_prepend_desktop (notification->priv->icon_name);
snapped_icon = try_prepend_snap_desktop (notification,
notification->priv->icon_name);
if (snapped_icon != NULL) {
g_debug ("Icon updated in snap environment: '%s' -> '%s'\n",
notification->priv->icon_name, snapped_icon);
......@@ -608,8 +739,25 @@ proxy_g_signal_cb (GDBusProxy *proxy,
g_warning ("Received unknown action %s", action);
}
} else {
notification->priv->activating = TRUE;
pair->cb (notification, (char *) action, pair->user_data);
notification->priv->activating = FALSE;
g_free (notification->priv->activation_token);
notification->priv->activation_token = NULL;
}
} else if (g_strcmp0 (signal_name, "ActivationToken") == 0 &&
g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(us)"))) {
guint32 id;
const char *activation_token;
g_variant_get (parameters, "(u&s)", &id, &activation_token);
if (id != notification->priv->id)
return;
g_free (notification->priv->activation_token);
notification->priv->activation_token = g_strdup (activation_token);
}
}
......@@ -634,6 +782,9 @@ notify_notification_show (NotifyNotification *notification,
GHashTableIter iter;
gpointer key, data;
GVariant *result;
#ifdef GLIB_VERSION_2_32
GApplication *application = NULL;
#endif
g_return_val_if_fail (notification != NULL, FALSE);
g_return_val_if_fail (NOTIFY_IS_NOTIFICATION (notification), FALSE);
......@@ -668,6 +819,38 @@ notify_notification_show (NotifyNotification *notification,
g_variant_builder_add (&hints_builder, "{sv}", key, data);
}
if (priv->snap_app &&
g_hash_table_lookup (priv->hints, "desktop-entry") == NULL) {
gchar *snap_desktop;
snap_desktop = g_strdup_printf ("%s_%s",
priv->snap_name,
priv->snap_app);
g_debug ("Using desktop entry: %s", snap_desktop);
g_variant_builder_add (&hints_builder, "{sv}",
"desktop-entry",
g_variant_new_take_string (snap_desktop));
}
#ifdef GLIB_VERSION_2_32
if (!priv->snap_app) {
application = g_application_get_default ();
}
if (application != NULL) {
GVariant *desktop_entry = g_hash_table_lookup (priv->hints, "desktop-entry");
if (desktop_entry == NULL) {
const char *application_id = g_application_get_application_id (application);
g_debug ("Using desktop entry: %s", application_id);
g_variant_builder_add (&hints_builder, "{sv}", "desktop-entry",
g_variant_new_string (application_id));
}
}
#endif
/* TODO: make this nonblocking */
result = g_dbus_proxy_call_sync (proxy,
"Notify",
......@@ -855,13 +1038,20 @@ notify_notification_set_image_from_pixbuf (NotifyNotification *notification,
notify_notification_set_hint (notification, hint_name, value);
}
typedef gchar * (*StringParserFunc) (NotifyNotification *, const gchar *);
static GVariant *
get_parsed_variant (GVariant *variant,
gchar *(*str_parser)(const gchar *))
get_parsed_variant (NotifyNotification *notification,
const char *key,
GVariant *variant,
StringParserFunc str_parser)
{
gchar *parsed = str_parser (g_variant_get_string (variant, NULL));
const char *str = g_variant_get_string (variant, NULL);
gchar *parsed = str_parser (notification, str);
if (parsed != NULL) {
if (parsed != NULL && g_strcmp0 (str, parsed) != 0) {
g_debug ("Hint %s updated in snap environment: '%s' -> '%s'\n",
key, str, parsed);
g_variant_unref (variant);
variant = g_variant_new_take_string (parsed);
}
......@@ -870,18 +1060,28 @@ get_parsed_variant (GVariant *variant,
}
static GVariant *
maybe_parse_snap_hint_value (const gchar *key,
maybe_parse_snap_hint_value (NotifyNotification *notification,
const gchar *key,
GVariant *value)
{
StringParserFunc parse_func = NULL;
if (!notification->priv->snap_path)
return value;
if (g_strcmp0 (key, "desktop-entry") == 0) {
value = get_parsed_variant (value, try_prepend_desktop);
parse_func = try_prepend_snap_desktop;
} else if (g_strcmp0 (key, "image-path") == 0 ||
g_strcmp0 (key, "image_path") == 0 ||
g_strcmp0 (key, "sound-file") == 0) {
value = get_parsed_variant (value, try_prepend_snap);
parse_func = try_prepend_snap;
}
return value;
if (parse_func == NULL) {
return value;
}
return get_parsed_variant (notification, key, value, parse_func);
}
/**
......@@ -906,7 +1106,7 @@ notify_notification_set_hint (NotifyNotification *notification,
g_return_if_fail (key != NULL && *key != '\0');
if (value != NULL) {
value = maybe_parse_snap_hint_value (key, value);
value = maybe_parse_snap_hint_value (notification, key, value);
g_hash_table_insert (notification->priv->hints,
g_strdup (key),
g_variant_ref_sink (value));
......@@ -1038,7 +1238,11 @@ notify_notification_set_hint_byte_array (NotifyNotification *notification,
g_return_if_fail (value != NULL || len == 0);
#ifdef GLIB_VERSION_2_68
value_dup = g_memdup2 (value, len);
#else
value_dup = g_memdup (value, len);
#endif
notify_notification_set_hint (notification, key,
g_variant_new_from_data (G_VARIANT_TYPE ("ay"),
value_dup,
......@@ -1167,6 +1371,29 @@ notify_notification_add_action (NotifyNotification *notification,
}
}
/**
* notify_notification_get_activation_token:
*
* If an an action is currently being activated, return the activation token.
* This function is intended to be used in a #NotifyActionCallback to get
* the activation token for the activated action, if the notification daemon
* supports it.
*
* Return value: (transfer none): The current activation token, or %NULL if none
*
* Since: 0.7.10
*/
const char *
notify_notification_get_activation_token (NotifyNotification *notification)
{
g_return_val_if_fail (NOTIFY_IS_NOTIFICATION (notification), NULL);
if (notification->priv->activating)
return notification->priv->activation_token;
return NULL;
}
gboolean
_notify_notification_has_nondefault_actions (const NotifyNotification *n)
{
......
......@@ -180,6 +180,8 @@ void notify_notification_add_action (NotifyNotificatio
gpointer user_data,
GFreeFunc free_func);
const char *notify_notification_get_activation_token (NotifyNotification *notification);
void notify_notification_clear_actions (NotifyNotification *notification);
gboolean notify_notification_close (NotifyNotification *notification,
GError **error);
......
......@@ -151,9 +151,17 @@ notify_init (const char *app_name)
if (_initted)
return TRUE;
#ifdef GLIB_VERSION_2_32
if (app_name == NULL && g_application_get_default ()) {
GApplication *application = g_application_get_default ();
app_name = g_application_get_application_id (application);
}
#endif
notify_set_app_name (app_name);
#if !GLIB_CHECK_VERSION (2, 36, 0)
#ifndef GLIB_VERSION_2_36
g_type_init ();
#endif
......
project('libnotify',
'c',
version: '0.7.9',
version: '0.7.11',
meson_version: '>= 0.47.0')
gnome = import('gnome')
......@@ -66,7 +66,7 @@ if get_option('man')
'@INPUT@',
]
testrun = run_command(xsltproc, '--nonet', stylesheet)
testrun = run_command(xsltproc, '--nonet', stylesheet, check: false)
if testrun.returncode() != 0
error('DocBook stylesheet for generating man pages not found, you need to install docbook-xsl-ns or similar package.')
......
......@@ -29,7 +29,7 @@ main ()
{
NotifyNotification *n;
#if !GLIB_CHECK_VERSION (2, 36, 0)
#ifndef GLIB_VERSION_2_36
g_type_init ();
#endif
......