Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
/*
|
|
|
|
* notification.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Sun Microsystems, Inc.
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
* Copyright (C) 2006 Christian Persch
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c,
2005-04-25 Glynn Foster <glynn.foster@sun.com>
* COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c,
* src/entry.c, src/fileselection.c, src/main.c, src/msg.c,
* src/notification.c, src/option.c, src/progress.c,
* src/text.c, src/tree.c, src/util.c: Update the FSF address
to point to 51 Franklin Street, Fifth Floor as per forwarded
mail from Alvaro Lopez Ortega.
2005-04-25 03:20:45 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
*
|
|
|
|
* Authors: Glynn Foster <glynn.foster@sun.com>
|
|
|
|
*/
|
|
|
|
|
2005-07-06 20:13:11 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
#include <gtk/gtk.h>
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
#include <time.h>
|
2005-07-06 20:13:11 +00:00
|
|
|
#include <string.h>
|
2011-06-02 17:12:33 +00:00
|
|
|
#ifdef HAVE_LIBNOTIFY
|
2006-03-23 03:43:23 +00:00
|
|
|
#include <libnotify/notify.h>
|
|
|
|
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
#include "zenity.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2013-02-14 00:08:56 +00:00
|
|
|
#define MAX_HINTS 16
|
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
static char *icon_file;
|
2013-02-14 00:08:56 +00:00
|
|
|
static GHashTable *notification_hints;
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
|
2004-09-30 11:25:37 +00:00
|
|
|
static void
|
2010-10-09 08:59:44 +00:00
|
|
|
on_notification_default_action (NotifyNotification *n,
|
|
|
|
const char *action,
|
|
|
|
void *user_data)
|
2004-09-30 11:25:37 +00:00
|
|
|
{
|
2010-10-09 08:59:44 +00:00
|
|
|
ZenityData *zen_data;
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
zen_data = (ZenityData *)user_data;
|
|
|
|
notify_notification_close (n, NULL);
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
2013-02-14 00:08:56 +00:00
|
|
|
static GHashTable *
|
|
|
|
zenity_notification_parse_hints_array (gchar **hints)
|
|
|
|
{
|
|
|
|
GHashTable *result;
|
|
|
|
gchar** pair;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
result = g_hash_table_new_full (g_str_hash,
|
|
|
|
g_str_equal,
|
|
|
|
g_free,
|
|
|
|
g_free);
|
|
|
|
|
|
|
|
for(i = 0; i < g_strv_length (hints); i++) {
|
|
|
|
pair = g_strsplit (hints[i], ":", 2);
|
|
|
|
g_hash_table_replace (result, g_strdup (pair[0]), g_strdup (pair[1]));
|
|
|
|
g_strfreev (pair);
|
|
|
|
}
|
|
|
|
if (g_hash_table_size (result) == 0) {
|
|
|
|
g_hash_table_unref (result);
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GHashTable *
|
|
|
|
zenity_notification_parse_hints (gchar *hints)
|
|
|
|
{
|
|
|
|
GHashTable *result;
|
|
|
|
gchar** hint_array;
|
|
|
|
|
|
|
|
hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS);
|
|
|
|
result = zenity_notification_parse_hints_array (hint_array);
|
|
|
|
g_strfreev (hint_array);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zenity_notification_set_hint(gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
|
|
|
NotifyNotification *notification;
|
|
|
|
gchar *hint_name;
|
|
|
|
GVariant *hint_value;
|
|
|
|
|
|
|
|
gchar *string_value;
|
|
|
|
gboolean boolean_value;
|
|
|
|
gint32 int_value;
|
|
|
|
guchar byte_value;
|
|
|
|
|
|
|
|
hint_name = (gchar *) key;
|
|
|
|
string_value = (gchar *) value;
|
|
|
|
notification = (NotifyNotification *) user_data;
|
|
|
|
|
|
|
|
if ((g_ascii_strcasecmp ("action-icons", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("resident", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("suppress-sound", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("transient", hint_name) == 0)) {
|
|
|
|
/* boolean hints */
|
|
|
|
if (g_ascii_strcasecmp ("true", string_value) == 0) {
|
|
|
|
boolean_value = TRUE;
|
|
|
|
} else if (g_ascii_strcasecmp ("false", string_value) == 0) {
|
|
|
|
boolean_value = FALSE;
|
|
|
|
} else {
|
|
|
|
g_printerr (_("Invalid value for a boolean typed hint.\nSupported values are 'true' or 'false'.\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hint_value = g_variant_new_boolean (boolean_value);
|
|
|
|
} else if ((g_ascii_strcasecmp ("category", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("desktop-entry", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("image-path", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("image_path", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("sound-file", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("sound-name", hint_name) == 0)) {
|
|
|
|
/* string hints */
|
|
|
|
hint_value = g_variant_new_string (string_value);
|
|
|
|
} else if ((g_ascii_strcasecmp ("image-data", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("image_data", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("icon-data", hint_name) == 0)) {
|
|
|
|
/* (iibiiay) */
|
|
|
|
g_printerr (_("Unsupported hint. Skipping.\n"));
|
|
|
|
return;
|
|
|
|
} else if ((g_ascii_strcasecmp ("x", hint_name) == 0)
|
|
|
|
|| (g_ascii_strcasecmp ("y", hint_name) == 0)) {
|
|
|
|
/* int hints */
|
|
|
|
int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0);
|
|
|
|
hint_value = g_variant_new_int32 (int_value);
|
|
|
|
} else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) {
|
|
|
|
/* byte hints */
|
|
|
|
byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0);
|
|
|
|
hint_value = g_variant_new_byte (byte_value);
|
|
|
|
} else {
|
|
|
|
/* unknown hints */
|
|
|
|
g_printerr (_("Unknown hint name. Skipping.\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
notify_notification_set_hint (notification,
|
|
|
|
hint_name,
|
|
|
|
hint_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zenity_notification_set_hints (NotifyNotification *notification, GHashTable *hints)
|
|
|
|
{
|
|
|
|
if (hints == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_foreach (hints, zenity_notification_set_hint, notification);
|
|
|
|
}
|
|
|
|
|
2004-09-16 09:28:09 +00:00
|
|
|
static gboolean
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
zenity_notification_handle_stdin (GIOChannel *channel,
|
2004-09-16 09:28:09 +00:00
|
|
|
GIOCondition condition,
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
gpointer user_data)
|
2004-09-16 09:28:09 +00:00
|
|
|
{
|
|
|
|
ZenityData *zen_data;
|
|
|
|
|
|
|
|
zen_data = (ZenityData *)user_data;
|
|
|
|
|
|
|
|
if ((condition & G_IO_IN) != 0) {
|
|
|
|
GString *string;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
string = g_string_new (NULL);
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
while (channel->is_readable == FALSE)
|
2004-09-16 09:28:09 +00:00
|
|
|
;
|
|
|
|
do {
|
|
|
|
gint status;
|
|
|
|
gchar *command, *value, *colon;
|
|
|
|
|
|
|
|
do {
|
|
|
|
status = g_io_channel_read_line_string (channel, string, NULL, &error);
|
|
|
|
while (gdk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
|
|
|
|
} while (status == G_IO_STATUS_AGAIN);
|
|
|
|
|
|
|
|
if (status != G_IO_STATUS_NORMAL) {
|
|
|
|
if (error) {
|
|
|
|
g_warning ("zenity_notification_handle_stdin () : %s",
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
zenity_util_strip_newline (string->str);
|
|
|
|
colon = strchr(string->str, ':');
|
|
|
|
if (colon == NULL) {
|
2012-11-12 20:57:07 +00:00
|
|
|
g_printerr (_("Could not parse command from stdin\n"));
|
2004-09-16 09:28:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* split off the command and value */
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
command = g_strstrip (g_strndup (string->str, colon - string->str));
|
2004-09-16 09:28:09 +00:00
|
|
|
|
|
|
|
value = colon + 1;
|
|
|
|
while (*value && g_ascii_isspace (*value)) value++;
|
|
|
|
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
if (!g_ascii_strcasecmp (command, "icon")) {
|
|
|
|
g_free (icon_file);
|
|
|
|
icon_file = g_strdup (value);
|
2013-02-14 00:08:56 +00:00
|
|
|
} else if (!g_ascii_strcasecmp (command, "hints")) {
|
|
|
|
if (notification_hints != NULL) {
|
|
|
|
g_hash_table_unref (notification_hints);
|
|
|
|
}
|
|
|
|
notification_hints = zenity_notification_parse_hints (value);
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
} else if (!g_ascii_strcasecmp (command, "message")) {
|
|
|
|
/* display a notification bubble */
|
|
|
|
if (!g_utf8_validate (value, -1, NULL)) {
|
|
|
|
g_warning ("Invalid UTF-8 in input!");
|
2010-10-09 08:59:44 +00:00
|
|
|
} else {
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
NotifyNotification *notif;
|
2009-08-09 23:08:14 +00:00
|
|
|
gchar **message;
|
2007-05-14 21:26:08 +00:00
|
|
|
error = NULL;
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
|
2009-08-09 23:08:14 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
notif = notify_notification_new (message[0] /* title */,
|
|
|
|
message[1] /* summary */,
|
|
|
|
icon_file);
|
2009-08-09 23:08:14 +00:00
|
|
|
|
|
|
|
g_strfreev (message);
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
|
2013-02-14 00:08:56 +00:00
|
|
|
zenity_notification_set_hints (notif, notification_hints);
|
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
notify_notification_show (notif, &error);
|
|
|
|
if (error) {
|
|
|
|
g_warning ("Error showing notification: %s", error->message);
|
|
|
|
g_error_free (error);
|
2011-01-25 23:49:01 +00:00
|
|
|
error = NULL;
|
2010-10-09 08:59:44 +00:00
|
|
|
}
|
2006-03-23 03:43:23 +00:00
|
|
|
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
g_object_unref (notif);
|
2010-10-09 08:59:44 +00:00
|
|
|
}
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
} else if (!g_ascii_strcasecmp (command, "tooltip")) {
|
2010-10-09 08:59:44 +00:00
|
|
|
if (!g_utf8_validate (value, -1, NULL)) {
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
g_warning ("Invalid UTF-8 in input!");
|
2010-10-09 08:59:44 +00:00
|
|
|
} else {
|
|
|
|
NotifyNotification *notif;
|
|
|
|
|
|
|
|
notif = notify_notification_new (value,
|
|
|
|
NULL,
|
|
|
|
icon_file);
|
2013-02-14 00:08:56 +00:00
|
|
|
|
|
|
|
zenity_notification_set_hints (notif, notification_hints);
|
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
notify_notification_show (notif, &error);
|
|
|
|
if (error) {
|
|
|
|
g_warning ("Error showing notification: %s", error->message);
|
|
|
|
g_error_free (error);
|
2011-01-25 23:49:01 +00:00
|
|
|
error = NULL;
|
2010-10-09 08:59:44 +00:00
|
|
|
}
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
}
|
|
|
|
} else if (!g_ascii_strcasecmp (command, "visible")) {
|
2010-10-09 08:59:44 +00:00
|
|
|
|
2004-09-16 09:28:09 +00:00
|
|
|
} else {
|
|
|
|
g_warning ("Unknown command '%s'", command);
|
|
|
|
}
|
|
|
|
g_free (command);
|
|
|
|
|
|
|
|
} while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);
|
|
|
|
g_string_free (string, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((condition & G_IO_HUP) != 0) {
|
|
|
|
g_io_channel_shutdown (channel, TRUE, NULL);
|
|
|
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
|
|
|
gtk_main_quit ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zenity_notification_listen_on_stdin (ZenityData *data)
|
|
|
|
{
|
|
|
|
GIOChannel *channel;
|
|
|
|
|
|
|
|
channel = g_io_channel_unix_new (0);
|
|
|
|
g_io_channel_set_encoding (channel, NULL, NULL);
|
|
|
|
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
|
|
|
g_io_add_watch (channel, G_IO_IN | G_IO_HUP,
|
|
|
|
zenity_notification_handle_stdin, data);
|
|
|
|
}
|
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
void
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
zenity_notification (ZenityData *data, ZenityNotificationData *notification_data)
|
|
|
|
{
|
2010-10-09 08:59:44 +00:00
|
|
|
GError *error;
|
|
|
|
NotifyNotification *notification;
|
2013-02-14 00:08:56 +00:00
|
|
|
GHashTable *notification_hints;
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
/* create the notification widget */
|
|
|
|
if (!notify_is_initted ()) {
|
|
|
|
notify_init (_("Zenity notification"));
|
|
|
|
}
|
2010-10-09 08:59:44 +00:00
|
|
|
|
2004-09-16 09:28:09 +00:00
|
|
|
if (notification_data->listen) {
|
|
|
|
zenity_notification_listen_on_stdin (data);
|
|
|
|
} else {
|
2010-10-09 08:59:44 +00:00
|
|
|
if (notification_data->notification_text == NULL) {
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
notification = notify_notification_new (notification_data->notification_text, NULL, data->window_icon);
|
|
|
|
if (notification == NULL) {
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we aren't listening for changes, then close on default action */
|
|
|
|
notify_notification_add_action (notification,
|
|
|
|
"default",
|
|
|
|
"Do Default Action",
|
|
|
|
(NotifyActionCallback) on_notification_default_action,
|
|
|
|
data,
|
|
|
|
NULL);
|
|
|
|
|
2013-02-14 00:08:56 +00:00
|
|
|
/* set the notification hints for the displayed notification */
|
|
|
|
notification_hints = zenity_notification_parse_hints_array (notification_data->notification_hints);
|
|
|
|
zenity_notification_set_hints(notification, notification_hints);
|
|
|
|
g_hash_table_unref (notification_hints);
|
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
/* Show icon and wait */
|
|
|
|
error = NULL;
|
|
|
|
if (!notify_notification_show (notification, &error)) {
|
|
|
|
if (error != NULL) {
|
|
|
|
g_warning ("Error showing notification: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
exit (1);
|
|
|
|
}
|
2004-09-16 09:28:09 +00:00
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
}
|
2007-08-13 20:36:29 +00:00
|
|
|
|
2010-10-09 08:59:44 +00:00
|
|
|
if (data->timeout_delay > 0) {
|
2009-10-30 18:51:16 +00:00
|
|
|
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL);
|
2007-08-13 20:36:29 +00:00
|
|
|
}
|
|
|
|
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
gtk_main ();
|
|
|
|
}
|
2013-02-14 00:08:56 +00:00
|
|
|
|
2010-11-04 19:12:52 +00:00
|
|
|
#endif
|