[Xfce4-commits] <xfce4-cpugraph-plugin:master> Autodetect the default command.

Florian Rivoal noreply at xfce.org
Mon May 31 13:26:01 CEST 2010


Updating branch refs/heads/master
         to 209f7f249badfbafb2a40308c08ee4f383fa1651 (commit)
       from 16367c76f05cb59dd869c1f3cc0a0d111400c92c (commit)

commit 209f7f249badfbafb2a40308c08ee4f383fa1651
Author: Florian Rivoal <frivoal at gmail.com>
Date:   Sun May 30 19:07:57 2010 +0900

    Autodetect the default command.
    
    xfce4-taskmanager is a better default command than top, but I was using
    top as a default because xfce4-taskmanager isn't guaranteed to be around.
    With this change, xfce4-taskmanaer will be used as a default if
    available, and top will be used instead if not. The autodetection is
    only used when a there are no saved settings, that is, only when adding
    a new cpugraph to the pannel.
    
    Adapted from a patch by Mike Massonnet.

 panel-plugin/settings.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/settings.c b/panel-plugin/settings.c
index 0c90779..d2e3de6 100644
--- a/panel-plugin/settings.c
+++ b/panel-plugin/settings.c
@@ -1,5 +1,23 @@
 #include "settings.h"
 
+static void default_command( const gchar ** command, gboolean * in_terminal, gboolean * startup_notification )
+{
+	gchar * s = g_find_program_in_path( "xfce4-taskmanager");
+	if( s != NULL )
+	{
+		g_free( s );
+		*command = "xfce4-taskmanager";
+		*in_terminal = FALSE;
+		*startup_notification = TRUE;
+	}
+	else
+	{
+		*command = "top";
+		*in_terminal = TRUE;
+		*startup_notification = FALSE;
+	}
+}
+
 void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 {
 	const char *value;
@@ -14,9 +32,9 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 	gboolean frame = TRUE;
 	gboolean border = TRUE;
 	gboolean bars = TRUE;
-	const gchar  *associated_command = "top";
-	gboolean in_terminal = TRUE;
-	gboolean startup_notification = FALSE;
+	const gchar  *associated_command;
+	gboolean in_terminal;
+	gboolean startup_notification;
 
 	GdkColor foreground1;
 	GdkColor foreground2;
@@ -39,6 +57,8 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 	background.green = 65535;
 	background.blue = 65535;
 
+	default_command( &associated_command, &in_terminal, &startup_notification );
+
 	if( (file = xfce_panel_plugin_lookup_rc_file( plugin )) != NULL )
 	{
 		rc = xfce_rc_simple_open( file, TRUE );



More information about the Xfce4-commits mailing list