Implement the "message" command on notification icon with libnotify

2006-03-22  Lucas Rocha  <lucasr@gnome.org>

	Implement the "message" command on notification icon
	with libnotify bubbles. Patch from Davyd Madeley
	<davyd@madeley.id.au>.

	* configure.in: add libnotify checking.
	* src/notification.c (zenity_notification_handle_stdin,
	zenity_notification): initialize libnotify and implement
	"message" command.
This commit is contained in:
Lucas Rocha 2006-03-23 03:43:23 +00:00 committed by Lucas Almeida Rocha
parent 168e2625b9
commit e919741e64
3 changed files with 64 additions and 2 deletions

View File

@ -1,8 +1,19 @@
2006-03-22 Lucas Rocha <lucasr@gnome.org>
Implement the "message" command on notification icon
with libnotify bubbles. Patch from Davyd Madeley
<davyd@madeley.id.au>.
* configure.in: add libnotify checking.
* src/notification.c (zenity_notification_handle_stdin,
zenity_notification): initialize libnotify and implement
"message" command.
2006-03-21 Gora Mohanty <gmohanty@cvs.gnome.org> 2006-03-21 Gora Mohanty <gmohanty@cvs.gnome.org>
* configure.in: Added or (Oriya) to ALL_LINGUAS. * configure.in: Added or (Oriya) to ALL_LINGUAS.
2005-03-13 Lucas Rocha <lucasr@gnome.org> 2006-03-13 Lucas Rocha <lucasr@gnome.org>
* configure.in: Post release bump, for unstable * configure.in: Post release bump, for unstable
2.15.x development. 2.15.x development.

View File

@ -66,6 +66,20 @@ dnl *******************************
AC_PATH_PROG(PERL,perl,) AC_PATH_PROG(PERL,perl,)
dnl *******************************
dnl libnotify check
dnl *******************************
PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.3.2,
HAVE_LIBNOTIFY="yes", HAVE_LIBNOTIFY="no")
if test "x$HAVE_LIBNOTIFY" = "xyes"; then
ZENITY_CFLAGS="$ZENITY_CFLAGS $LIBNOTIFY_CFLAGS"
ZENITY_LIBS="$ZENITY_LIBS $LIBNOTIFY_LIBS"
AC_SUBST(ZENITY_CFLAGS)
AC_SUBST(ZENITY_LIBS)
AC_DEFINE(HAVE_LIBNOTIFY, 1, [libnotify is available on this machine])
fi
dnl ******************************* dnl *******************************
dnl Internationalization dnl Internationalization
dnl ******************************* dnl *******************************

View File

@ -26,6 +26,11 @@
#include <glade/glade.h> #include <glade/glade.h>
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
#endif
#include "zenity.h" #include "zenity.h"
#include "eggtrayicon.h" #include "eggtrayicon.h"
#include "util.h" #include "util.h"
@ -182,7 +187,33 @@ zenity_notification_handle_stdin (GIOChannel *channel,
g_warning ("Could not load notification icon : %s", value); g_warning ("Could not load notification icon : %s", value);
} }
} else if (!strcmp (command, "message")) { } else if (!strcmp (command, "message")) {
g_warning ("haven't implemented message support yet"); #ifdef HAVE_LIBNOTIFY
/* display a notification bubble */
if (notify_is_initted ()) {
GError *error = NULL;
NotifyNotification *n;
GdkPixbuf *icon;
n = notify_notification_new (g_strcompress (value), NULL, NULL,
GTK_WIDGET (tray_icon));
icon = gtk_image_get_pixbuf (GTK_IMAGE (icon_image));
notify_notification_set_icon_from_pixbuf (n, icon);
notify_notification_show (n, &error);
if (error) {
g_warning (error->message);
g_error_free (error);
}
g_object_unref (G_OBJECT (n));
} else {
#else
{ /* this brace is for balance */
#endif
g_warning ("Notification framework not available");
}
} else if (!strcmp (command, "tooltip")) { } else if (!strcmp (command, "tooltip")) {
gtk_tooltips_set_tip (tooltips, icon_event_box, value, value); gtk_tooltips_set_tip (tooltips, icon_event_box, value, value);
} else if (!strcmp (command, "visible")) { } else if (!strcmp (command, "visible")) {
@ -275,6 +306,12 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data
G_CALLBACK (zenity_notification_icon_press_callback), data); G_CALLBACK (zenity_notification_icon_press_callback), data);
} }
#ifdef HAVE_LIBNOTIFY
/* create the notification widget */
if (!notify_is_initted ())
notify_init (_("Zenity notification"));
#endif
gtk_widget_show_all (GTK_WIDGET (tray_icon)); gtk_widget_show_all (GTK_WIDGET (tray_icon));
/* Does nothing at the moment */ /* Does nothing at the moment */