[Xfce4-commits] [apps/xfdashboard] 01/01: Rewrote application class and main() function to make use of main loop in g_application_run() which is needed since Glib 2.47.4+ because it will deregister application from D-BUS as soon as this function exits. So the old implementation does not "see" any running instance (regardless if running as daemon or not) anymore and cannot neither quit nor restart the running instance. So several instances can run simultaneously, e.g. two daemon instances, instead of toggling the state of application.

noreply at xfce.org noreply at xfce.org
Thu Mar 10 22:08:48 CET 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 748e6d280724391e505e3b9f7295aaf1c0a79205
Author: Stephan Haller <nomad at froevel.de>
Date:   Thu Mar 10 22:05:13 2016 +0100

    Rewrote application class and main() function to make use of main loop in g_application_run() which is needed since Glib 2.47.4+ because it will deregister application from D-BUS as soon as this function exits. So the old implementation does not "see" any running instance (regardless if running as daemon or not) anymore and cannot neither quit nor restart the running instance. So several instances can run simultaneously, e.g. two daemon instances, instead of toggling the state of appl [...]
    
    This commit should fix GH #116
---
 libxfdashboard/application.c | 293 ++++++++++++++++++++++++++++++++-----------
 xfdashboard/main.c           | 110 ++++++----------
 2 files changed, 257 insertions(+), 146 deletions(-)

diff --git a/libxfdashboard/application.c b/libxfdashboard/application.c
index 91a0eeb..78a2cfc 100644
--- a/libxfdashboard/application.c
+++ b/libxfdashboard/application.c
@@ -68,7 +68,7 @@ struct _XfdashboardApplicationPrivate
 	gchar							*themeName;
 
 	/* Instance related */
-	gboolean						inited;
+	gboolean						initialized;
 	gboolean						isQuitting;
 
 	XfconfChannel					*xfconfChannel;
@@ -165,7 +165,7 @@ static void _xfdashboard_application_quit(XfdashboardApplication *self, gboolean
 		priv->isQuitting=TRUE;
 
 		/* If application is told to quit, set the restart style to something
-		 * where it won't restart itself.
+		 * when it won't restart itself.
 		 */
 		if(priv->sessionManagementClient &&
 			XFCE_IS_SM_CLIENT(priv->sessionManagementClient))
@@ -182,7 +182,13 @@ static void _xfdashboard_application_quit(XfdashboardApplication *self, gboolean
 		g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_QUIT], 0);
 
 		/* Really quit application here and now */
-		if(priv->inited) clutter_main_quit();
+		if(priv->initialized)
+		{
+			/* Release extra reference on application which causes g_application_run()
+			 * to exit when returning.
+			 */
+			g_application_release(G_APPLICATION(self));
+		}
 	}
 		/* ... otherwise emit "suspend" signal */
 		else
@@ -299,7 +305,8 @@ static void _xfdashboard_application_set_theme_name(XfdashboardApplication *self
 }
 
 /* Perform full initialization of this application instance */
-static gboolean _xfdashboard_application_initialize_full(XfdashboardApplication *self, XfdashboardStage **outStage)
+static gboolean _xfdashboard_application_initialize_full(XfdashboardApplication *self,
+															XfdashboardStage **outStage)
 {
 	XfdashboardApplicationPrivate	*priv;
 	GError							*error;
@@ -512,59 +519,33 @@ static void _xfdashboard_application_switch_to_view(XfdashboardApplication *self
 	}
 }
 
-/* IMPLEMENTATION: GApplication */
-
-/* Received "activate" signal on primary instance */
-static void _xfdashboard_application_activate(GApplication *inApplication)
-{
-	XfdashboardApplication			*self;
-	XfdashboardApplicationPrivate	*priv;
-
-	g_return_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication));
-
-	self=XFDASHBOARD_APPLICATION(inApplication);
-	priv=self->priv;
-
-	/* Emit "resume" signal */
-	g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_RESUME], 0);
-
-	/* Unset flag for suspension */
-	if(priv->isSuspended)
-	{
-		priv->isSuspended=FALSE;
-		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_SUSPENDED]);
-	}
-}
-
 /* Handle command-line on primary instance */
-static int _xfdashboard_application_command_line(GApplication *inApplication, GApplicationCommandLine *inCommandLine)
+static gint _xfdashboard_application_handle_command_line_arguments(XfdashboardApplication *self,
+																	gint inArgc,
+																	gchar **inArgv)
 {
-	XfdashboardApplication			*self;
 	XfdashboardApplicationPrivate	*priv;
 	XfdashboardStage				*stage;
 	GOptionContext					*context;
 	gboolean						result;
-	gint							argc;
-	gchar							**argv;
 	GError							*error;
 	gboolean						optionDaemonize;
 	gboolean						optionQuit;
 	gboolean						optionRestart;
 	gboolean						optionToggle;
 	gchar							*optionSwitchToView;
-	GOptionEntry					XfdashboardApplicationOptions[]=
+	GOptionEntry					entries[]=
 									{
 										{ "daemonize", 'd', 0, G_OPTION_ARG_NONE, &optionDaemonize, N_("Fork to background"), NULL },
 										{ "quit", 'q', 0, G_OPTION_ARG_NONE, &optionQuit, N_("Quit running instance"), NULL },
 										{ "restart", 'r', 0, G_OPTION_ARG_NONE, &optionRestart, N_("Restart running instance"), NULL },
 										{ "toggle", 't', 0, G_OPTION_ARG_NONE, &optionToggle, N_("Toggles suspend/resume state if running instance was started in daemon mode otherwise it quits running non-daemon instance"), NULL },
-										{ "view", 0, 0, G_OPTION_ARG_STRING, &optionSwitchToView, N_(""), NULL },
+										{ "view", 0, 0, G_OPTION_ARG_STRING, &optionSwitchToView, N_("The view to switch to on startup or resume"), NULL },
 										{ NULL }
 									};
 
-	g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication), 1);
+	g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(self), XFDASHBOARD_APPLICATION_ERROR_FAILED);
 
-	self=XFDASHBOARD_APPLICATION(inApplication);
 	priv=self->priv;
 	error=NULL;
 	stage=NULL;
@@ -576,15 +557,12 @@ 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);
+	g_option_context_add_group(context, xfce_sm_client_get_option_group(inArgc, inArgv));
+	g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
 
 #ifdef DEBUG
 	/* I always forget the name of the environment variable to get the debug
@@ -592,58 +570,100 @@ static int _xfdashboard_application_command_line(GApplication *inApplication, GA
 	 * if application was compiled with debug enabled.
 	 */
 	g_print("** To get debug messages set environment variable G_MESSAGES_DEBUG to %s\n", PACKAGE_NAME);
-	g_print("** e.g.: G_MESSAGES_DEBUG=%s %s\n", PACKAGE_NAME, argv[0]);
+	g_print("** e.g.: G_MESSAGES_DEBUG=%s %s\n", PACKAGE_NAME, inArgv[0]);
 #endif
 
-	result=g_option_context_parse(context, &argc, &argv, &error);
-	g_strfreev(argv);
-	g_option_context_free(context);
-	if(result==FALSE)
+	if(!g_option_context_parse(context, &inArgc, &inArgv, &error))
 	{
 		/* Show error */
-		g_print(N_("%s\n"), (error && error->message) ? error->message : _("unknown error"));
-		if(error) g_error_free(error);
+		g_print(N_("%s\n"),
+				(error && error->message) ? error->message : _("unknown error"));
+		if(error)
+		{
+			g_error_free(error);
+			error=NULL;
+		}
 
 		/* Release allocated resources */
 		if(optionSwitchToView) g_free(optionSwitchToView);
+		if(context) g_option_context_free(context);
 
 		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
 	}
 
+	/* If this application instance is a remote instance do not handle any
+	 * command-line argument. The arguments will be sent to the primary instance,
+	 * handled there and the exit code will be sent back to the remote instance.
+	 * We can check for remote instance with g_application_get_is_remote() because
+	 * the application was tried to get registered either by local_command_line
+	 * signal handler or by g_application_run().
+	 */
+	if(g_application_get_is_remote(G_APPLICATION(self)))
+	{
+		g_debug("Do not handle command-line parameters on remote application instance");
+
+		/* Release allocated resources */
+		if(optionSwitchToView) g_free(optionSwitchToView);
+		if(context) g_option_context_free(context);
+
+		/* No errors so far and no errors will happen as we do not handle
+		 * any command-line arguments here.
+		 */
+		return(XFDASHBOARD_APPLICATION_ERROR_NONE);
+	}
+	g_debug("Handling command-line parameters on primary application instance");
+
 	/* Handle options: restart
-	 * - Only handle option if application was inited already
+	 *
+	 * First handle option 'restart' to quit this application early. Also return
+	 * immediately with status XFDASHBOARD_APPLICATION_ERROR_RESTART to tell
+	 * remote instance to perform a restart and to become the new primary instance.
+	 * This option requires that application was initialized.
 	 */
-	if(priv->inited && optionRestart)
+	if(optionRestart &&
+		priv->initialized)
 	{
-		/* Return state to restart this applicationa */
+		/* Quit existing instance for restart */
 		g_debug("Received request to restart application!");
+		_xfdashboard_application_quit(self, TRUE);
 
 		/* Release allocated resources */
 		if(optionSwitchToView) g_free(optionSwitchToView);
+		if(context) g_option_context_free(context);
 
+		/* Return state to restart this applicationa */
 		return(XFDASHBOARD_APPLICATION_ERROR_RESTART);
 	}
 
-	/* Handle options: quit */
+	/* Handle options: quit
+	 *
+	 * Now check for the next application stopping option 'quit'. We check for it
+	 * to quit this application early and to prevent further and unnecessary check
+	 * for other options.
+	 */
 	if(optionQuit)
 	{
 		/* Quit existing instance */
-		g_debug("Quitting running instance!");
+		g_debug("Received request to quit running instance!");
 		_xfdashboard_application_quit(self, TRUE);
 
 		/* Release allocated resources */
 		if(optionSwitchToView) g_free(optionSwitchToView);
+		if(context) g_option_context_free(context);
 
 		return(XFDASHBOARD_APPLICATION_ERROR_QUIT);
 	}
 
 	/* Handle options: toggle
-	 * - If application was not inited yet, perform normal start-up as usual
-	 *   with command-line options given
-	 * - If running in daemon mode, resume if suspended otherwise suspend
-	 * - If not running in daemon mode, quit application
+	 *
+	 * Now check if we should toggle the state of application. That means
+	 * if application is running daemon mode, resume it if suspended otherwise
+	 * suspend it. If application is running but not in daemon just quit the
+	 * application. If application was not inited yet, skip toggling state and
+	 * perform a normal start-up.
 	 */
-	if(priv->inited && optionToggle)
+	if(optionToggle &&
+		priv->initialized)
 	{
 		/* If application is running in daemon mode, toggle between suspend/resume ... */
 		if(priv->isDaemon)
@@ -654,7 +674,7 @@ static int _xfdashboard_application_command_line(GApplication *inApplication, GA
 				_xfdashboard_application_switch_to_view(self, optionSwitchToView);
 
 				/* Show application again */
-				_xfdashboard_application_activate(inApplication);
+				_xfdashboard_application_activate(G_APPLICATION(self));
 			}
 				else
 				{
@@ -671,13 +691,20 @@ static int _xfdashboard_application_command_line(GApplication *inApplication, GA
 
 		/* Release allocated resources */
 		if(optionSwitchToView) g_free(optionSwitchToView);
+		if(context) g_option_context_free(context);
 
 		/* Stop here because option was handled and application does not get initialized */
 		return(XFDASHBOARD_APPLICATION_ERROR_NONE);
 	}
 
-	/* Handle options: daemonize */
-	if(!priv->inited)
+	/* Handle options: daemonize
+	 *
+	 * Check if application shoud run in daemon mode. A daemonized instance runs in
+	 * background and does not present the stage initially. The application must not
+	 * be initialized yet as it can only be done on start-up.
+	 */
+	if(optionDaemonize &&
+		!priv->initialized)
 	{
 		priv->isDaemon=optionDaemonize;
 		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_DAEMONIZED]);
@@ -690,7 +717,7 @@ static int _xfdashboard_application_command_line(GApplication *inApplication, GA
 	}
 
 	/* Check if this instance needs to be initialized fully */
-	if(!priv->inited)
+	if(!priv->initialized)
 	{
 		/* Perform full initialization of this application instance */
 		result=_xfdashboard_application_initialize_full(self, &stage);
@@ -701,43 +728,163 @@ static int _xfdashboard_application_command_line(GApplication *inApplication, GA
 
 		/* Show application if not started daemonized */
 		if(!priv->isDaemon) clutter_actor_show(CLUTTER_ACTOR(stage));
+
+		/* Take extra reference on the application to keep application in
+		 * function g_application_run() alive when returning.
+		 */
+		g_application_hold(G_APPLICATION(self));
 	}
 
 	/* Check if this instance need to be activated. Is should only be done
 	 * if instance is initialized
 	 */
-	if(priv->inited)
+	if(priv->initialized)
 	{
 		/* Switch to view if requested */
 		_xfdashboard_application_switch_to_view(self, optionSwitchToView);
 
 		/* Show application */
-		_xfdashboard_application_activate(inApplication);
+		_xfdashboard_application_activate(G_APPLICATION(self));
 	}
 
 	/* Release allocated resources */
 	if(optionSwitchToView) g_free(optionSwitchToView);
+	if(context) g_option_context_free(context);
 
 	/* All done successfully so return status code 0 for success */
-	priv->inited=TRUE;
+	priv->initialized=TRUE;
 	return(XFDASHBOARD_APPLICATION_ERROR_NONE);
 }
 
-#if GLIB_CHECK_VERSION(2, 40, 0)
-/* Override local command-line handling in Glib 2.40 or higher to
- * get old behaviour of command-line handling as in Glib prior to
- * version 2.40 and as it is used in this application.
+/* IMPLEMENTATION: GApplication */
+
+/* Received "activate" signal on primary instance */
+static void _xfdashboard_application_activate(GApplication *inApplication)
+{
+	XfdashboardApplication			*self;
+	XfdashboardApplicationPrivate	*priv;
+
+	g_return_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication));
+
+	self=XFDASHBOARD_APPLICATION(inApplication);
+	priv=self->priv;
+
+	/* Emit "resume" signal */
+	g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_RESUME], 0);
+
+	/* Unset flag for suspension */
+	if(priv->isSuspended)
+	{
+		priv->isSuspended=FALSE;
+		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_SUSPENDED]);
+	}
+}
+
+/* Handle command-line on primary instance */
+static int _xfdashboard_application_command_line(GApplication *inApplication, GApplicationCommandLine *inCommandLine)
+{
+	XfdashboardApplication			*self;
+	gint							argc;
+	gchar							**argv;
+	gint							exitStatus;
+
+	g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication), XFDASHBOARD_APPLICATION_ERROR_FAILED);
+
+	self=XFDASHBOARD_APPLICATION(inApplication);
+
+	/* Get number of command-line arguments and the arguments */
+	argv=g_application_command_line_get_arguments(inCommandLine, &argc);
+
+	/* Parse command-line and get exit status code */
+	exitStatus=_xfdashboard_application_handle_command_line_arguments(self, argc, argv);
+
+	/* Release allocated resources */
+	if(argv) g_strfreev(argv);
+
+	/* Return exit status code */
+	return(exitStatus);
+}
+
+/* Check and handle command-line on local instance regardless if this one
+ * is the primary instance or a remote one. This functions checks for arguments
+ * which can be handled locally, e.g. '--help'. Otherwise they will be send to
+ * the primary instance.
  */
 static gboolean _xfdashboard_application_local_command_line(GApplication *inApplication,
 															gchar ***ioArguments,
 															int *outExitStatus)
 {
+	XfdashboardApplication			*self;
+	GError							*error;
+
+	g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication), TRUE);
+
+	self=XFDASHBOARD_APPLICATION(inApplication);
+	error=NULL;
+
+	/* Set exit status code initially to success result but can be changed later */
+	if(outExitStatus) *outExitStatus=XFDASHBOARD_APPLICATION_ERROR_NONE;
+
+	/* Try to register application to determine early if this instance will be
+	 * the primary application instance or a remote one.
+	 */
+	if(!g_application_register(inApplication, NULL, &error))
+	{
+		g_critical(_("Unable to register application: %s"),
+					(error && error->message) ? error->message : _("Unknown error"));
+		if(error)
+		{
+			g_error_free(error);
+			error=NULL;
+		}
+
+		/* Set error status code */
+		if(outExitStatus) *outExitStatus=XFDASHBOARD_APPLICATION_ERROR_FAILED;
+
+		/* Return TRUE to indicate that command-line does not need further processing */
+		return(TRUE);
+	}
+
+	/* If this is a remote instance we need to parse command-line now */
+	if(g_application_get_is_remote(inApplication))
+	{
+		gint						argc;
+		gchar						**argv;
+		gchar						**originArgv;
+		gint						exitStatus;
+		gint						i;
+
+		/* We have to make a extra copy of the command-line arguments, since
+		 * g_option_context_parse() in command-line argument handling function
+		 * might remove parameters from the arguments list and maybe we need
+		 * them to sent the arguments to primary instance if not handled locally
+		 * like '--help'.
+		 */
+		originArgv=*ioArguments;
+
+		argc=g_strv_length(originArgv);
+		argv=g_new0(gchar*, argc+1);
+		for(i=0; i<=argc; i++) argv[i]=g_strdup(originArgv[i]);
+
+		/* Parse command-line and store exit status code */
+		exitStatus=_xfdashboard_application_handle_command_line_arguments(self, argc, argv);
+		if(outExitStatus) *outExitStatus=exitStatus;
+
+		/* Release allocated resources */
+		if(argv) g_strfreev(argv);
+
+		/* If exit status code indicates an error then return TRUE here to indicate
+		 * that command-line does not need further processing.
+		 */
+		if(exitStatus==XFDASHBOARD_APPLICATION_ERROR_FAILED) return(TRUE);
+	}
+
 	/* Return FALSE to indicate that command-line was not completely handled
-	 * and need further processing.
+	 * and needs further processing, e.g. this is the primary instance or a remote
+	 * instance which could not handle the arguments locally.
 	 */
 	return(FALSE);
 }
-#endif
 
 
 /* IMPLEMENTATION: GObject */
@@ -898,9 +1045,7 @@ static void xfdashboard_application_class_init(XfdashboardApplicationClass *klas
 
 	appClass->activate=_xfdashboard_application_activate;
 	appClass->command_line=_xfdashboard_application_command_line;
-#if GLIB_CHECK_VERSION(2, 40, 0)
 	appClass->local_command_line=_xfdashboard_application_local_command_line;
-#endif
 
 	gobjectClass->dispose=_xfdashboard_application_dispose;
 	gobjectClass->set_property=_xfdashboard_application_set_property;
@@ -1034,7 +1179,7 @@ static void xfdashboard_application_init(XfdashboardApplication *self)
 	priv->isDaemon=FALSE;
 	priv->isSuspended=FALSE;
 	priv->themeName=NULL;
-	priv->inited=FALSE;
+	priv->initialized=FALSE;
 	priv->xfconfChannel=NULL;
 	priv->viewManager=NULL;
 	priv->searchManager=NULL;
diff --git a/xfdashboard/main.c b/xfdashboard/main.c
index c87ba0d..5565ceb 100644
--- a/xfdashboard/main.c
+++ b/xfdashboard/main.c
@@ -185,7 +185,6 @@ static gboolean _restart(XfdashboardApplication *inApplication)
 int main(int argc, char **argv)
 {
 	XfdashboardApplication		*app=NULL;
-	GError						*error=NULL;
 	gint						status;
 
 #ifdef ENABLE_NLS
@@ -205,67 +204,8 @@ int main(int argc, char **argv)
 	clutter_set_windowing_backend("x11");
 #endif
 
-	/* Check for running instance (keep only one instance) */
-	app=xfdashboard_application_get_default();
-	if(!app)
-	{
-		g_warning(_("Failed to create application instance"));
-		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
-	}
-
-	g_application_register(G_APPLICATION(app), NULL, &error);
-	if(error!=NULL)
-	{
-		g_warning(_("Unable to register application: %s"), error->message);
-		g_error_free(error);
-		error=NULL;
-		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
-	}
-
-	if(g_application_get_is_remote(G_APPLICATION(app))==TRUE)
-	{
-		/* Handle command-line on primary instance of application
-		 * and activate primary instance if handling command-line
-		 * was successful
-		 */
-		status=g_application_run(G_APPLICATION(app), argc, argv);
-		switch(status)
-		{
-			case XFDASHBOARD_APPLICATION_ERROR_NONE:
-			case XFDASHBOARD_APPLICATION_ERROR_QUIT:
-				/* Do nothing at remote instance */
-				break;
-
-			case XFDASHBOARD_APPLICATION_ERROR_RESTART:
-				/* Try quitting running instance and wait until
-				 * application is stopped. If this fails reset
-				 * application status from restart to failed to
-				 * prevent starting another instance.
-				 */
-				if(!_restart(app)) status=XFDASHBOARD_APPLICATION_ERROR_FAILED;
-				break;
-
-			default:
-				g_error(_("Initializing application failed with status code %d"), status);
-				break;
-		}
-
-		/* Destroy this instance of application and exit if no restart
-		 * was requested.
-		 */
-		if(status!=XFDASHBOARD_APPLICATION_ERROR_RESTART)
-		{
-			g_object_unref(app);
-			return(status);
-		}
-
-		/* If we get here a restart was requested so destroy current
-		 * instance of application and create a new one.
-		 */
-		g_object_unref(app);
-
-		app=xfdashboard_application_get_default();
-	}
+	/* Notify that application has started and main loop will be entered */
+	gdk_notify_startup_complete();
 
 	/* Tell clutter to try to initialize an RGBA visual */
 	clutter_x11_set_use_argb_visual(TRUE);
@@ -278,22 +218,48 @@ int main(int argc, char **argv)
 		return(1);
 	}
 
-	/* Handle command-line on primary instance */
-	status=g_application_run(G_APPLICATION(app), argc, argv);
-	if(status!=XFDASHBOARD_APPLICATION_ERROR_NONE)
+	/* Start application as primary or remote instace */
+	app=xfdashboard_application_get_default();
+	if(!app)
 	{
-		g_object_unref(app);
-		return(status);
+		g_warning(_("Failed to create application instance"));
+		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
 	}
 
-	/* Notify that application has started and main loop will be entered */
-	gdk_notify_startup_complete();
+	status=g_application_run(G_APPLICATION(app), argc, argv);
+	if(status==XFDASHBOARD_APPLICATION_ERROR_RESTART &&
+		g_application_get_is_remote(G_APPLICATION(app)))
+	{
+		/* Wait for existing primary instance to quit */
+		if(_restart(app))
+		{
+			g_debug("Reached clean state to restart application");
 
-	/* Start main loop */
-	clutter_main();
+			/* Destroy remote instance application object for restart */
+			g_object_unref(app);
+			app=NULL;
+
+			/* Create new application instance which should become
+			 * the new primary instance.
+			 */
+			app=xfdashboard_application_get_default();
+			if(!app)
+			{
+				g_warning(_("Failed to create application instance"));
+				return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
+			}
+
+			g_debug("Starting new primary instance");
+			status=g_application_run(G_APPLICATION(app), argc, argv);
+		}
+			else
+			{
+				g_warning(_("Could not restart application because existing instance seems still to be running."));
+			}
+	}
 
 	/* Clean up, release allocated resources */
 	g_object_unref(app);
 
-	return(XFDASHBOARD_APPLICATION_ERROR_NONE);
+	return(status);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list