[Xfce4-commits] [apps/xfdashboard] 01/01: Add session management to xfdashboard to restart it if it crashes
noreply at xfce.org
noreply at xfce.org
Sat Aug 29 20:39:45 CEST 2015
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit 5285a138aac29a1a696530251ba6e9de461bd3b9
Author: Stephan Haller <nomad at froevel.de>
Date: Sat Aug 29 20:38:29 2015 +0200
Add session management to xfdashboard to restart it if it crashes
This fixes bug report #12143
---
README | 1 +
configure.ac.in | 3 +++
xfdashboard/Makefile.am | 2 ++
xfdashboard/application.c | 54 +++++++++++++++++++++++++++++++++++++++++----
4 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/README b/README
index 5b1198a..d647027 100644
--- a/README
+++ b/README
@@ -17,6 +17,7 @@ dbus-glib >= 0.98
garcon >= 0.2.0
gtk+ >= 3.2
libxfce4util >= 4.10.0
+libxfce4ui >= 4.10.0
... and the dependencies of these libraries of course ;)
diff --git a/configure.ac.in b/configure.ac.in
index 24b3656..038737b 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -28,6 +28,7 @@ m4_define([xcomposite_minimum_version], [0.2])
m4_define([intltool_minimum_version], [0.35])
m4_define([gtk_minimum_version], [3.2])
m4_define([libxfce4util_minimum_version],[4.10.0])
+m4_define([libxfce4ui_minimum_version],[4.10.0])
dnl *******************************************
dnl *** Debugging support for GIT snapshots ***
@@ -194,6 +195,7 @@ XDT_CHECK_PACKAGE([GIO_UNIX], [gio-unix-2.0], [gio_minimum_version])
XDT_CHECK_PACKAGE([GARCON], [garcon-1], [garcon_minimum_version])
XDT_CHECK_PACKAGE([LIBXFCONF], [libxfconf-0], [xfconf_minimum_version])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0],[libxfce4util_minimum_version])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2],[libxfce4ui_minimum_version])
XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [dbus_glib_minimum_version], [
XDT_PROG_PKG_CONFIG()
@@ -275,6 +277,7 @@ echo " gio: $GIO_VERSION"
echo " gio-unix: $GIO_UNIX_VERSION"
echo " garcon: $GARCON_VERSION"
echo " libxconf: $LIBXFCONF_VERSION"
+echo " libxfce4ui: $LIBXFCE4UI_VERSION"
echo " libxfce4util: $LIBXFCE4UTIL_VERSION"
echo " dbus-glib: $DBUS_GLIB_VERSION"
echo
diff --git a/xfdashboard/Makefile.am b/xfdashboard/Makefile.am
index 10afef5..6be4798 100644
--- a/xfdashboard/Makefile.am
+++ b/xfdashboard/Makefile.am
@@ -152,6 +152,7 @@ libxfdashboard_la_CFLAGS = \
$(GARCON_CFLAGS) \
$(LIBXFCONF_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
$(PLATFORM_CFLAGS)
@@ -165,6 +166,7 @@ libxfdashboard_la_LIBADD = \
$(GARCON_LIBS) \
$(LIBXFCONF_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
$(DBUS_GLIB_LIBS) \
$(LIBM)
diff --git a/xfdashboard/application.c b/xfdashboard/application.c
index d163e2e..6895f6e 100644
--- a/xfdashboard/application.c
+++ b/xfdashboard/application.c
@@ -32,6 +32,7 @@
#include <clutter/x11/clutter-x11.h>
#include <gtk/gtk.h>
#include <garcon/garcon.h>
+#include <libxfce4ui/libxfce4ui.h>
#include "stage.h"
#include "types.h"
@@ -80,6 +81,8 @@ struct _XfdashboardApplicationPrivate
XfdashboardApplicationDatabase *appDatabase;
XfdashboardApplicationTracker *appTracker;
+
+ XfceSMClient *sessionManagementClient;
};
/* Properties */
@@ -153,6 +156,15 @@ static void _xfdashboard_application_quit(XfdashboardApplication *self, gboolean
/* Set flag that application is going to quit */
priv->isQuitting=TRUE;
+ /* If application is told to quit, set the restart style to something
+ * where it won't restart itself.
+ */
+ if(priv->sessionManagementClient &&
+ XFCE_IS_SM_CLIENT(priv->sessionManagementClient))
+ {
+ xfce_sm_client_set_restart_style(priv->sessionManagementClient, XFCE_SM_CLIENT_RESTART_NORMAL);
+ }
+
/* Destroy stages */
stages=clutter_stage_manager_list_stages(clutter_stage_manager_get_default());
for(entry=stages; entry!=NULL; entry=g_slist_next(entry)) clutter_actor_destroy(CLUTTER_ACTOR(entry->data));
@@ -180,6 +192,18 @@ static void _xfdashboard_application_quit(XfdashboardApplication *self, gboolean
}
}
+/* The session is going to quit */
+static void _xfdashboard_application_on_session_quit(XfdashboardApplication *self,
+ gpointer inUserData)
+{
+ g_return_if_fail(XFDASHBOARD_IS_APPLICATION(self));
+ g_return_if_fail(XFCE_IS_SM_CLIENT(inUserData));
+
+ /* Force application to quit */
+ g_debug("Received 'quit' from session management client - initiating shutdown");
+ _xfdashboard_application_quit(self, TRUE);
+}
+
/* A stage window should be destroyed */
static gboolean _xfdashboard_application_on_delete_stage(XfdashboardApplication *self,
ClutterEvent *inEvent,
@@ -287,12 +311,25 @@ static gboolean _xfdashboard_application_initialize_full(XfdashboardApplication
garcon_set_environment_xdg(GARCON_ENVIRONMENT_XFCE);
#endif
+ /* Setup the session management */
+ priv->sessionManagementClient=xfce_sm_client_get();
+ xfce_sm_client_set_priority(priv->sessionManagementClient, XFCE_SM_CLIENT_PRIORITY_DEFAULT);
+ xfce_sm_client_set_restart_style(priv->sessionManagementClient, XFCE_SM_CLIENT_RESTART_IMMEDIATELY);
+ g_signal_connect_swapped(priv->sessionManagementClient, "quit", G_CALLBACK(_xfdashboard_application_on_session_quit), self);
+
+ if(!xfce_sm_client_connect(priv->sessionManagementClient, &error))
+ {
+ g_warning("Failed to connect to session manager: %s",
+ (error && error->message) ? error->message : _("unknown error"));
+ g_clear_error(&error);
+ }
+
/* Initialize xfconf */
if(!xfconf_init(&error))
{
g_critical(_("Could not initialize xfconf: %s"),
(error && error->message) ? error->message : _("unknown error"));
- if(error!=NULL) g_error_free(error);
+ if(error) g_error_free(error);
return(FALSE);
}
@@ -500,14 +537,16 @@ static int _xfdashboard_application_command_line(GApplication *inApplication, GA
optionToggle=FALSE;
optionSwitchToView=NULL;
+ /* Parse command-line arguments */
+ argv=g_application_command_line_get_arguments(inCommandLine, &argc);
+
+ /* Setup command-line options */
context=g_option_context_new(N_("- A Gnome Shell like dashboard for Xfce4"));
g_option_context_add_group(context, gtk_get_option_group(TRUE));
g_option_context_add_group(context, clutter_get_option_group_without_init());
+ g_option_context_add_group(context, xfce_sm_client_get_option_group(argc, argv));
g_option_context_add_main_entries(context, XfdashboardApplicationOptions, GETTEXT_PACKAGE);
- /* Parse command-line arguments */
- argv=g_application_command_line_get_arguments(inCommandLine, &argc);
-
#ifdef DEBUG
/* I always forget the name of the environment variable to get the debug
* message display which are emitted with g_debug(). So display a hint
@@ -736,6 +775,12 @@ static void _xfdashboard_application_dispose(GObject *inObject)
priv->appTracker=NULL;
}
+ /* Shutdown session management */
+ if(priv->sessionManagementClient)
+ {
+ priv->sessionManagementClient=NULL;
+ }
+
/* Shutdown xfconf */
priv->xfconfChannel=NULL;
xfconf_shutdown();
@@ -924,6 +969,7 @@ static void xfdashboard_application_init(XfdashboardApplication *self)
priv->theme=NULL;
priv->xfconfThemeChangedSignalID=0L;
priv->isQuitting=FALSE;
+ priv->sessionManagementClient=NULL;
/* Add callable DBUS actions for this application */
action=g_simple_action_new("Quit", NULL);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list