[Xfce4-commits] <xfdesktop:master> Delay notification initialization until we show one.
Nick Schermer
noreply at xfce.org
Wed Nov 17 20:56:01 CET 2010
Updating branch refs/heads/master
to 934c5c612e9f0e07876f0f256264bb5a4981c1b0 (commit)
from 379abcd6991650fdcba6d36ce813ac6177a4288f (commit)
commit 934c5c612e9f0e07876f0f256264bb5a4981c1b0
Author: Nick Schermer <nick at xfce.org>
Date: Wed Nov 17 20:54:27 2010 +0100
Delay notification initialization until we show one.
src/main.c | 8 ++++++++
src/xfdesktop-notify.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/xfdesktop-notify.h | 3 +--
3 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
index 6187944..5d96207 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,6 +66,10 @@
#include "menu.h"
#include "windowlist.h"
+#ifdef HAVE_LIBNOTIFY
+#include "xfdesktop-notify.h"
+#endif
+
static XfceSMClient *sm_client = NULL;
static void
@@ -398,6 +402,10 @@ main(int argc, char **argv)
g_free(desktops);
xfconf_shutdown();
+
+#ifdef HAVE_LIBNOTIFY
+ xfdesktop_notify_uninit();
+#endif
return 0;
}
diff --git a/src/xfdesktop-notify.c b/src/xfdesktop-notify.c
index d1386e1..c91103b 100644
--- a/src/xfdesktop-notify.c
+++ b/src/xfdesktop-notify.c
@@ -36,6 +36,34 @@
+static gboolean xfdesktop_notify_initted = FALSE;
+
+
+
+static gboolean
+xfdesktop_notify_init (void)
+{
+ gchar *spec_version = NULL;
+
+ if (!xfdesktop_notify_initted
+ && notify_init (PACKAGE_NAME))
+ {
+ /* we do this to work around bugs in libnotify < 0.6.0. Older
+ * versions crash in notify_uninit() when no notifications are
+ * displayed before. These versions also segfault when the
+ * ret_spec_version parameter of notify_get_server_info is
+ * NULL... */
+ notify_get_server_info (NULL, NULL, NULL, &spec_version);
+ g_free (spec_version);
+
+ xfdesktop_notify_initted = TRUE;
+ }
+
+ return xfdesktop_notify_initted;
+}
+
+
+
void
xfdesktop_notify_unmount (GMount *mount)
{
@@ -53,6 +81,9 @@ xfdesktop_notify_unmount (GMount *mount)
g_return_if_fail (G_IS_MOUNT (mount));
+ if (!xfdesktop_notify_init ())
+ return;
+
mount_point = g_mount_get_root (mount);
info = g_file_query_info (mount_point, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
@@ -163,6 +194,9 @@ xfdesktop_notify_eject (GVolume *volume)
g_return_if_fail (G_IS_VOLUME (volume));
+ if (!xfdesktop_notify_init ())
+ return;
+
mount = g_volume_get_mount (volume);
if (mount != NULL)
{
@@ -255,3 +289,13 @@ xfdesktop_notify_eject_finish (GVolume *volume)
g_object_set_data (G_OBJECT (volume), "xfdesktop-notification", NULL);
}
}
+
+
+
+void
+xfdesktop_notify_uninit (void)
+{
+ if (xfdesktop_notify_initted
+ && notify_is_initted ())
+ notify_uninit ();
+}
diff --git a/src/xfdesktop-notify.h b/src/xfdesktop-notify.h
index 5361290..a547b65 100644
--- a/src/xfdesktop-notify.h
+++ b/src/xfdesktop-notify.h
@@ -24,14 +24,13 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libnotify/notify.h>
-
G_BEGIN_DECLS
void xfdesktop_notify_unmount (GMount *mount);
void xfdesktop_notify_unmount_finish (GMount *mount);
void xfdesktop_notify_eject (GVolume *volume);
void xfdesktop_notify_eject_finish (GVolume *volume);
+void xfdesktop_notify_uninit (void);
G_END_DECLS
More information about the Xfce4-commits
mailing list