[Xfce4-commits] <xfce4-notifyd:master> Close the daemon if it is idle for 10 minutes.
Jérôme Guelfucci
noreply at xfce.org
Wed Nov 17 22:38:01 CET 2010
Updating branch refs/heads/master
to ff65228af4e9665f1cac6c45c0c852ca6c4bf4a0 (commit)
from 4e12936b2e31c0e28750e10326baee9ff7ed38ba (commit)
commit ff65228af4e9665f1cac6c45c0c852ca6c4bf4a0
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date: Wed Nov 17 22:34:42 2010 +0100
Close the daemon if it is idle for 10 minutes.
Launching the daemon is not really ressource intensive so we can close
it if it is not used. We could maybe even put a shorter delay.
xfce4-notifyd/xfce-notify-daemon.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index 6452cb4..c54358b 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -63,6 +63,8 @@ struct _XfceNotifyDaemon
gint changed_screen;
+ guint close_timeout;
+
guint32 last_notification_id;
};
@@ -104,6 +106,8 @@ static void xfce_gdk_rectangle_largest_box(GdkRectangle *src1,
static void xfce_notify_daemon_get_workarea(GdkScreen *screen,
guint monitor,
GdkRectangle *rect);
+static gboolean xfce_notify_daemon_close_timeout(gpointer data);
+
static gboolean notify_get_capabilities(XfceNotifyDaemon *xndaemon,
gchar ***OUT_capabilities,
GError *error);
@@ -307,6 +311,10 @@ xfce_notify_daemon_init(XfceNotifyDaemon *xndaemon)
NULL, NULL,
(GDestroyNotify)gtk_widget_destroy);
xndaemon->last_notification_id = 1;
+
+ xndaemon->close_timeout =
+ g_timeout_add_seconds(600, (GSourceFunc) xfce_notify_daemon_close_timeout,
+ xndaemon);
}
static void
@@ -773,6 +781,14 @@ xfce_notify_daemon_update_reserved_rectangles(gpointer key,
static gboolean
+xfce_notify_daemon_close_timeout(gpointer data)
+{
+ notify_quit(XFCE_NOTIFY_DAEMON(data), NULL);
+
+ return FALSE;
+}
+
+static gboolean
notify_get_capabilities(XfceNotifyDaemon *xndaemon,
gchar ***OUT_capabilities,
GError *error)
@@ -921,6 +937,14 @@ notify_notify(XfceNotifyDaemon *xndaemon,
gtk_widget_realize(GTK_WIDGET(window));
+ /* Set a timeout to close xfce4-notifyd if it is idle for 10 minutes */
+ if(xndaemon->close_timeout)
+ g_source_remove(xndaemon->close_timeout);
+
+ xndaemon->close_timeout =
+ g_timeout_add_seconds(600, (GSourceFunc) xfce_notify_daemon_close_timeout,
+ xndaemon);
+
return TRUE;
}
More information about the Xfce4-commits
mailing list