[zenity] Bug #638582 - zenity --notification --listen can't show multi line tooltip
- From: Arx Henrique Pereira da Cruz <arxcruz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [zenity] Bug #638582 - zenity --notification --listen can't show multi line tooltip
- Date: Wed, 3 Jun 2015 11:33:48 +0000 (UTC)
commit abf0777b35e70c23688a4c29dc1a0fb241b770c6
Author: Arx Cruz <arxcruz gnome org>
Date: Wed Jun 3 13:32:32 2015 +0200
Bug #638582 - zenity --notification --listen can't show multi line tooltip
This create a new function to call the notify_notification_new handling
properly the multi line parser
src/notification.c | 56 +++++++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/src/notification.c b/src/notification.c
index 8086be6..9bbd6ce 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -40,6 +40,25 @@
static char *icon_file;
static GHashTable *notification_hints;
+static NotifyNotification *
+zenity_notification_new(gchar *message, gchar *icon_file)
+{
+ NotifyNotification *notif;
+ gchar **text;
+
+ text = g_strsplit (g_strcompress (message), "\n", 2);
+ if (*text == NULL) {
+ g_printerr (_("Could not parse message\n"));
+ return NULL;
+ }
+
+ notif = notify_notification_new (text[0], /* title */
+ text[1], /* summary */
+ icon_file);
+ g_strfreev (text);
+ return notif;
+}
+
static void
on_notification_default_action (NotifyNotification *n,
const char *action,
@@ -229,24 +248,11 @@ zenity_notification_handle_stdin (GIOChannel *channel,
g_warning ("Invalid UTF-8 in input!");
} else {
NotifyNotification *notif;
- gchar **message;
error = NULL;
- /* message[1] (the summary) will be NULL in case there's
- * no \n in the string. In which case only the title is
- * defined */
- message = g_strsplit (g_strcompress (value), "\n", 2);
-
- if (*message == NULL) {
- g_printerr (_("Could not parse message from stdin\n"));
- continue;
- }
-
- notif = notify_notification_new (message[0] /* title */,
- message[1] /* summary */,
- icon_file);
-
- g_strfreev (message);
+ notif = zenity_notification_new (value, icon_file);
+ if (notif == NULL)
+ continue;
zenity_notification_set_hints (notif, notification_hints);
@@ -264,10 +270,9 @@ zenity_notification_handle_stdin (GIOChannel *channel,
g_warning ("Invalid UTF-8 in input!");
} else {
NotifyNotification *notif;
-
- notif = notify_notification_new (value,
- NULL,
- icon_file);
+ notif = zenity_notification_new (value, icon_file);
+ if (notif == NULL)
+ continue;
zenity_notification_set_hints (notif, notification_hints);
@@ -315,7 +320,6 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data
GError *error;
NotifyNotification *notification;
GHashTable *notification_hints;
- gchar **message;
/* create the notification widget */
if (!notify_is_initted ()) {
@@ -329,16 +333,10 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data
if (notification_data->notification_text == NULL) {
exit (1);
}
-
- message = g_strsplit (g_strcompress (notification_data->notification_text), "\n", 2);
- if (*message == NULL) {
- g_printerr (_("Could not parse message\n"));
- exit (1);
- }
- notification = notify_notification_new (message[0], /* title */
- message[1], /* summary */
+ notification = zenity_notification_new (notification_data->notification_text,
data->window_icon);
+
if (notification == NULL) {
exit (1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]