[Xfce4-commits] [apps/xfdashboard] 02/02: Add simple '--version' command-line parameter to determine the version of xfdashboard running.

noreply at xfce.org noreply at xfce.org
Tue Oct 24 18:30:36 CEST 2017


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

n   o   m   a   d       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfdashboard.

commit 42d4d0567b5bb5e28f6ba353fcb6ed76cfd136eb
Author: Stephan Haller <nomad at froevel.de>
Date:   Tue Oct 24 18:27:06 2017 +0200

    Add simple '--version' command-line parameter to determine the version of xfdashboard running.
    
    * If this option is used and no instance is running, show version and quit
    * If this option is used and an instance is running (usually the daemon) then show version of xfdashboard executed with this option is the terminal where it is executed and the daemon is show in the terminal (or in ~/.xsession-errors) where the daemon is runnning
    
    It is really a very simple version requesting option.
---
 libxfdashboard/application.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/libxfdashboard/application.c b/libxfdashboard/application.c
index 6f6b997..f99f0ae 100644
--- a/libxfdashboard/application.c
+++ b/libxfdashboard/application.c
@@ -574,6 +574,7 @@ static gint _xfdashboard_application_handle_command_line_arguments(XfdashboardAp
 	gboolean						optionRestart;
 	gboolean						optionToggle;
 	gchar							*optionSwitchToView;
+	gboolean						optionVersion;
 	GOptionEntry					entries[]=
 									{
 										{ "daemonize", 'd', 0, G_OPTION_ARG_NONE, &optionDaemonize, N_("Fork to background"), NULL },
@@ -581,6 +582,7 @@ static gint _xfdashboard_application_handle_command_line_arguments(XfdashboardAp
 										{ "restart", 'r', 0, G_OPTION_ARG_NONE, &optionRestart, N_("Restart running instance"), NULL },
 										{ "toggle", 't', 0, G_OPTION_ARG_NONE, &optionToggle, N_("Toggles visibility 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_("The ID of view to switch to on startup or resume"), "ID" },
+										{ "version", 'v', 0, G_OPTION_ARG_NONE, &optionVersion, N_("Show version"), NULL },
 										{ NULL }
 									};
 
@@ -595,6 +597,7 @@ static gint _xfdashboard_application_handle_command_line_arguments(XfdashboardAp
 	optionRestart=FALSE;
 	optionToggle=FALSE;
 	optionSwitchToView=NULL;
+	optionVersion=FALSE;
 
 	/* Setup command-line options */
 	context=g_option_context_new(N_(""));
@@ -686,6 +689,12 @@ static gint _xfdashboard_application_handle_command_line_arguments(XfdashboardAp
 	{
 		XFDASHBOARD_DEBUG(self, MISC, "Do not handle command-line parameters on remote application instance");
 
+		/* One exception is "--version" */
+		if(optionVersion)
+		{
+			g_print("Remote instance: %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
+		}
+
 		/* Release allocated resources */
 		if(optionSwitchToView) g_free(optionSwitchToView);
 		if(context) g_option_context_free(context);
@@ -809,6 +818,23 @@ static gint _xfdashboard_application_handle_command_line_arguments(XfdashboardAp
 			}
 	}
 
+	/* Handle options: version
+	 *
+	 * Show the version of this (maybe daemonized) instance.
+	 */
+	if(optionVersion)
+	{
+		if(priv->isDaemon)
+		{
+			g_print("Daemon instance: %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
+		}
+			else
+			{
+				g_print("Version: %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
+				return(XFDASHBOARD_APPLICATION_ERROR_QUIT);
+			}
+	}
+
 	/* Check if this instance needs to be initialized fully */
 	if(!priv->initialized)
 	{

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


More information about the Xfce4-commits mailing list