Add the possibility to pass title and the summary to zenity notification

Now you can use zenity --notification --text="Title\nSummary" and it will
use the first string before the first escape \n as the title, and the rest
of the string as summary text.
This commit is contained in:
Arx Cruz 2015-06-03 11:54:52 +02:00
parent 99a34fe7e6
commit d44ca59780

View File

@ -315,6 +315,7 @@ 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,7 +330,15 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data
exit (1);
}
notification = notify_notification_new (notification_data->notification_text, NULL, data->window_icon);
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 */
data->window_icon);
if (notification == NULL) {
exit (1);
}