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
This commit is contained in:
Arx Cruz 2015-06-03 13:32:32 +02:00
parent d44ca59780
commit abf0777b35

View File

@ -40,6 +40,25 @@
static char *icon_file; static char *icon_file;
static GHashTable *notification_hints; 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 static void
on_notification_default_action (NotifyNotification *n, on_notification_default_action (NotifyNotification *n,
const char *action, const char *action,
@ -229,24 +248,11 @@ zenity_notification_handle_stdin (GIOChannel *channel,
g_warning ("Invalid UTF-8 in input!"); g_warning ("Invalid UTF-8 in input!");
} else { } else {
NotifyNotification *notif; NotifyNotification *notif;
gchar **message;
error = NULL; error = NULL;
/* message[1] (the summary) will be NULL in case there's notif = zenity_notification_new (value, icon_file);
* no \n in the string. In which case only the title is if (notif == NULL)
* defined */ continue;
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);
zenity_notification_set_hints (notif, notification_hints); zenity_notification_set_hints (notif, notification_hints);
@ -264,10 +270,9 @@ zenity_notification_handle_stdin (GIOChannel *channel,
g_warning ("Invalid UTF-8 in input!"); g_warning ("Invalid UTF-8 in input!");
} else { } else {
NotifyNotification *notif; NotifyNotification *notif;
notif = zenity_notification_new (value, icon_file);
notif = notify_notification_new (value, if (notif == NULL)
NULL, continue;
icon_file);
zenity_notification_set_hints (notif, notification_hints); zenity_notification_set_hints (notif, notification_hints);
@ -315,7 +320,6 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data
GError *error; GError *error;
NotifyNotification *notification; NotifyNotification *notification;
GHashTable *notification_hints; GHashTable *notification_hints;
gchar **message;
/* create the notification widget */ /* create the notification widget */
if (!notify_is_initted ()) { if (!notify_is_initted ()) {
@ -330,15 +334,9 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data
exit (1); exit (1);
} }
message = g_strsplit (g_strcompress (notification_data->notification_text), "\n", 2); notification = zenity_notification_new (notification_data->notification_text,
if (*message == NULL) {
g_printerr (_("Could not parse message\n"));
exit (1);
}
notification = notify_notification_new (message[0], /* title */
message[1], /* summary */
data->window_icon); data->window_icon);
if (notification == NULL) { if (notification == NULL) {
exit (1); exit (1);
} }