[Xfce4-commits] <xfce4-notifyd:master> Show a button in the notification preview (bug #9982).
Jérôme Guelfucci
noreply at xfce.org
Sun Apr 7 11:22:02 CEST 2013
Updating branch refs/heads/master
to e8bd39fc0a0292eba237a55b2c10feec8e97eb13 (commit)
from a9997e5a7282646caeec64f5e5cfb7c58a114a10 (commit)
commit e8bd39fc0a0292eba237a55b2c10feec8e97eb13
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date: Sun Apr 7 11:21:32 2013 +0200
Show a button in the notification preview (bug #9982).
Makefile.am | 6 ++--
NEWS | 4 ++
configure.ac.in | 5 +--
xfce4-notifyd-config/main.c | 67 ++++++++++++++++++++++++++++++-------------
4 files changed, 55 insertions(+), 27 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 747c4c6..4ca28f1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,6 +52,7 @@ xfce4_notifyd_xfce4_notifyd_CFLAGS = \
xfce4_notifyd_config_xfce4_notifyd_config_CFLAGS = \
-DG_LOG_DOMAIN=\"xfce4-notifyd-config\" \
+ $(LIBNOTIFY_CFLAGS) \
$(common_cflags)
common_ldadd = \
@@ -66,7 +67,8 @@ xfce4_notifyd_xfce4_notifyd_LDADD = \
$(LIBX11_LIBS)
xfce4_notifyd_config_xfce4_notifyd_config_LDADD = \
- $(common_ldadd)
+ $(common_ldadd) \
+ $(LIBNOTIFY_LIBS)
servicedir = $(datadir)/dbus-1/services
@@ -238,7 +240,6 @@ release: gpg-sign
-rm $(PACKAGE)-$(VERSION).tar.gz
#Tests
-if HAVE_LIBNOTIFY
noinst_PROGRAMS = \
tests/test-text \
tests/test-positioning \
@@ -262,4 +263,3 @@ tests_test_positioning_LDADD = $(tests_ldadd)
tests_test_text_SOURCES = tests/test-text.c
tests_test_text_CFLAGS = $(tests_cflags)
tests_test_text_LDADD = $(tests_ldadd)
-endif
diff --git a/NEWS b/NEWS
index 17ca979..ea4fac0 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@
Version 0.2.3git:
+ libnotify is now required as a dependency to build a test suite and to
+ show improved notification previews.
+
Features:
* Add a category to the settings dialog for Xfce4 Settings Manager.
* Add widget names to summary ("summary") and body ("body") widgets
@@ -20,6 +23,7 @@ Version 0.2.3git:
* Respect border-width when drawing the notification (bug #9475).
* Do not kill notification daemon to apply new theme. Instead, handle
style updates of existing notifications.
+ * Show a button in the notification preview (bug #9982).
Version 0.2.2 (06 August 2011):
diff --git a/configure.ac.in b/configure.ac.in
index 101e334..7adb83a 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -67,10 +67,7 @@ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [0.1.0svn-r26876])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.0.0])
XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.72])
-
-dnl optionnal
-XDT_CHECK_OPTIONAL_PACKAGE([LIBNOTIFY], [libnotify], [0.7.0], [notifications],
- [Test suite support], [yes])
+XDT_CHECK_PACKAGE([LIBNOTIFY], [libnotify], [0.7.0])
AC_PATH_PROG([DBUS_BINDING_TOOL], [dbus-binding-tool])
AS_IF([test -z "$DBUS_BINDING_TOOL"],
diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index d3a4726..666f338 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -35,9 +35,46 @@
#include <xfconf/xfconf.h>
#include <libxfce4ui/libxfce4ui.h>
+#include <libnotify/notify.h>
#include "xfce4-notifyd-config.ui.h"
+static void
+xfce_notifyd_config_show_notification_callback(NotifyNotification *notification,
+ const char *action,
+ gpointer unused)
+{
+ /* Don't do anything, we just have a button to show its style */
+}
+
+static void
+xfce_notifyd_config_show_notification_preview(GtkWindow *parent_window)
+{
+ NotifyNotification *notification;
+ GError *error = NULL;
+
+ notification =
+ notify_notification_new(_("Notification Preview"),
+ _("This is how notifications will look like"),
+ NULL);
+
+ notify_notification_add_action(notification,
+ "button",
+ _("Button"),
+ (NotifyActionCallback) xfce_notifyd_config_show_notification_callback,
+ NULL,
+ NULL);
+
+ if (!notify_notification_show(notification, &error)) {
+ xfce_dialog_show_error(parent_window, error,
+ _("Notification preview failed"));
+
+ g_error_free(error);
+ }
+
+ g_object_unref(notification);
+}
+
static gchar *
xfce4_notifyd_slider_format_value(GtkScale *slider,
gdouble value,
@@ -87,21 +124,12 @@ xfce4_notifyd_config_theme_changed(XfconfChannel *channel,
{
gtk_tree_model_get(GTK_TREE_MODEL(ls), &iter, 0, &theme, -1);
if(!strcmp(theme, new_theme)) {
- GError *error = NULL;
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(theme_combo),
&iter);
g_free(theme);
- /* TRANSLATORS: notify-send is a command name in the following string,
- * it must not be translated. */
- if(!g_spawn_command_line_async(_("notify-send \"Notification Preview\""
- " \"This is how notifications will look like\""),
- &error)) {
- xfce_dialog_show_error(GTK_WINDOW(gtk_widget_get_toplevel(theme_combo)),
- error, _("Notification preview failed"));
- g_error_free(error);
- }
+ xfce_notifyd_config_show_notification_preview(GTK_WINDOW(gtk_widget_get_toplevel(theme_combo)));
return;
}
@@ -200,15 +228,7 @@ static void
xfce_notifyd_config_preview_clicked(GtkButton *button,
GtkWidget *dialog)
{
- GError *error = NULL;
-
- if(!g_spawn_command_line_async(_("notify-send \"Notification Preview\""
- " \"This is how notifications will look like\""),
- &error)) {
- xfce_dialog_show_error(GTK_WINDOW(dialog),
- error, _("Notification preview failed"));
- g_error_free(error);
- }
+ xfce_notifyd_config_show_notification_preview(GTK_WINDOW(dialog));
}
static GtkWidget *
@@ -317,6 +337,11 @@ main(int argc,
return EXIT_SUCCESS;
}
+ if (!notify_init ("Xfce4-notifyd settings")) {
+ g_error ("Failed to initialize libnotify.");
+ return EXIT_FAILURE;
+ }
+
builder = gtk_builder_new();
gtk_builder_add_from_string(builder, xfce4_notifyd_config_ui, xfce4_notifyd_config_ui_length, NULL);
if(G_UNLIKELY(!builder)) {
@@ -326,7 +351,6 @@ main(int argc,
settings_dialog = xfce4_notifyd_config_setup_dialog(builder);
-
if(opt_socket_id) {
GtkWidget *plug, *plug_child;
@@ -350,5 +374,8 @@ main(int argc,
gtk_dialog_run(GTK_DIALOG(settings_dialog));
}
+ notify_uninit();
+ xfconf_shutdown();
+
return EXIT_SUCCESS;
}
More information about the Xfce4-commits
mailing list