[libnotify] notify-send: Support passing any hint value, by parsing variant strings
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnotify] notify-send: Support passing any hint value, by parsing variant strings
- Date: Wed, 27 Apr 2022 18:58:14 +0000 (UTC)
commit 02f2f91c3dc97a25b9f2cd669e2082c3c7a86d3f
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Apr 27 20:45:06 2022 +0200
notify-send: Support passing any hint value, by parsing variant strings
docs/notify-send.xml | 2 +-
tools/notify-send.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/docs/notify-send.xml b/docs/notify-send.xml
index 0f36fa0..041466a 100644
--- a/docs/notify-send.xml
+++ b/docs/notify-send.xml
@@ -101,7 +101,7 @@
<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>BOOLEAN</literal>,
<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>
diff --git a/tools/notify-send.c b/tools/notify-send.c
index 8d3898d..04eb770 100644
--- a/tools/notify-send.c
+++ b/tools/notify-send.c
@@ -111,6 +111,15 @@ notify_notification_set_hint_variant (NotifyNotification *notification,
notify_notification_set_hint (notification, key,
g_variant_new_boolean (h_boolean));
+ } else if (g_ascii_strcasecmp (type, "variant") == 0) {
+ GVariant *variant = g_variant_parse (NULL, value, NULL, NULL, NULL);
+
+ if (variant != NULL) {
+ notify_notification_set_hint (notification, key, variant);
+ } else {
+ conv_error = TRUE;
+ }
+
} else {
*error = g_error_new (G_OPTION_ERROR,
G_OPTION_ERROR_BAD_VALUE,
@@ -208,7 +217,7 @@ main (int argc, char *argv[])
N_("TYPE[,TYPE...]")},
{"hint", 'h', 0, G_OPTION_ARG_FILENAME_ARRAY, &hints,
N_
- ("Specifies basic extra data to pass. Valid types are boolean, int, double, string and
byte."),
+ ("Specifies basic extra data to pass. Valid types are boolean, int, double, string, byte
and variant."),
N_("TYPE:NAME:VALUE")},
{"print-id", 'p', 0, G_OPTION_ARG_NONE, &print_id,
N_ ("Print the notification ID."), NULL},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]