[Xfce4-commits] <xfce4-cpugraph-plugin:master> Work on the click command

Florian noreply at xfce.org
Sat Apr 17 16:16:41 CEST 2010


Updating branch refs/heads/master
         to 9f7574bbd0e41f6980db58445bffd907a24e2c6d (commit)
       from 8228669b2e2c132ef7fb99e55039ab1aee5a2635 (commit)

commit 9f7574bbd0e41f6980db58445bffd907a24e2c6d
Author: Florian <frivoal at gmail.com>
Date:   Sat Mar 13 00:39:28 2010 +0900

    Work on the click command
    
    Add the option to run the command launched when the plugin is
    clicked in a terminal, and to use startup notifications for it. Also
    replace top by xfce4-taskmanager as the default command.

 panel-plugin/cpu.c        |   12 +++++++++++-
 panel-plugin/cpu.h        |    4 ++++
 panel-plugin/properties.c |   14 ++++++++++++++
 panel-plugin/settings.c   |   23 +++++++++--------------
 4 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index 2831ca2..f329cea 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -283,11 +283,21 @@ static gboolean command_cb( GtkWidget *w,GdkEventButton *event, CPUGraph *base )
 {
 	if( event->button == 1 && base->command )
 	{
-		xfce_exec( base->command, FALSE, FALSE, NULL );
+		xfce_exec( base->command, base->in_terminal, base->startup_notification, NULL );
 	}
 	return FALSE;
 }
 
+void set_startup_notification( CPUGraph *base, gboolean startup_notification )
+{
+	base->startup_notification = startup_notification;
+}
+
+void set_in_terminal( CPUGraph *base, gboolean in_terminal )
+{
+	base->in_terminal = in_terminal;
+}
+
 void set_command( CPUGraph *base, const gchar *command )
 {
 	g_free( base->command );
diff --git a/panel-plugin/cpu.h b/panel-plugin/cpu.h
index 25d7d4f..e4ce617 100644
--- a/panel-plugin/cpu.h
+++ b/panel-plugin/cpu.h
@@ -41,6 +41,8 @@ typedef struct
 	gboolean border;
 	gboolean bars;
 	gchar  *command;
+	gboolean in_terminal;
+	gboolean startup_notification;
 	GdkColor colors[4];
 
 	/* Runtime data */
@@ -53,6 +55,8 @@ typedef struct
 
 } CPUGraph;
 
+void set_startup_notification( CPUGraph *base, gboolean startup_notification );
+void set_in_terminal( CPUGraph *base, gboolean in_terminal );
 void set_command( CPUGraph *base, const gchar *command );
 void set_bars( CPUGraph * base, gboolean bars);
 void set_border( CPUGraph *base, gboolean border);
diff --git a/panel-plugin/properties.c b/panel-plugin/properties.c
index c4c9099..bcf9702 100644
--- a/panel-plugin/properties.c
+++ b/panel-plugin/properties.c
@@ -14,6 +14,8 @@ static void setup_color_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base,
 static void setup_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base );
 static void setup_color_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base );
 
+static void change_in_terminal( GtkToggleButton *button, CPUGraph *base );
+static void change_startup_notification( GtkToggleButton *button, CPUGraph *base );
 static void change_command( GtkEntry *entry, CPUGraph *base );
 static void change_color_0( GtkColorButton *button, CPUGraph *base );
 static void change_color_1( GtkColorButton * button, CPUGraph * base );
@@ -70,6 +72,8 @@ void create_options( XfcePanelPlugin *plugin, CPUGraph *base )
 	create_check_box( vbox, sg, _("Border"), base->border, change_border, base );
 	create_check_box( vbox, sg, _("Show Bar(s)"), base->bars, change_bars, base );
 	setup_command_option( vbox, sg, base );
+	create_check_box( vbox, sg, _("Run in terminal"), base->in_terminal, change_in_terminal, base );
+	create_check_box( vbox, sg, _("Use startup notification"), base->bars, change_startup_notification, base );
 
 	vbox2 = create_tab();
 	setup_color_option( vbox2, sg, base, 1, _("Color 1:"), G_CALLBACK( change_color_1 ) );
@@ -246,6 +250,16 @@ static void setup_color_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *b
 	create_drop_down( vbox, sg, _("Color mode: "), items, nb_items, base->color_mode, change_color_mode, base);
 }
 
+static void change_in_terminal( GtkToggleButton *button, CPUGraph *base )
+{
+	set_in_terminal( base, gtk_toggle_button_get_active( button ) );
+}
+
+static void change_startup_notification( GtkToggleButton *button, CPUGraph *base )
+{
+	set_startup_notification( base, gtk_toggle_button_get_active( button ) );
+}
+
 static void change_command( GtkEntry *entry, CPUGraph * base )
 {
 	set_command( base, gtk_entry_get_text( entry ) );
diff --git a/panel-plugin/settings.c b/panel-plugin/settings.c
index 0e97d2c..93c450e 100644
--- a/panel-plugin/settings.c
+++ b/panel-plugin/settings.c
@@ -1,7 +1,5 @@
 #include "settings.h"
 
-#define DEFAULT_COMMAND "exo-open --launch TerminalEmulator top"
-
 void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 {
 	const char *value;
@@ -16,7 +14,9 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 	gboolean frame = FALSE;
 	gboolean border = TRUE;
 	gboolean bars = TRUE;
-	const gchar  *associated_command = DEFAULT_COMMAND;
+	const gchar  *associated_command = "xfce4-taskmanager";
+	gboolean in_terminal = FALSE;
+	gboolean startup_notification = TRUE;
 
 	GdkColor foreground1;
 	GdkColor foreground2;
@@ -53,6 +53,8 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 			color_mode = xfce_rc_read_int_entry( rc, "ColorMode", color_mode );
 			frame = xfce_rc_read_int_entry( rc, "Frame", frame );
 			associated_command = xfce_rc_read_entry( rc, "AssociateCommand", associated_command );
+			in_terminal = xfce_rc_read_int_entry( rc, "InTerminal", in_terminal );
+			startup_notification = xfce_rc_read_int_entry( rc, "StartupNotification", startup_notification );
 			border = xfce_rc_read_int_entry( rc, "Border", border );
 			bars = xfce_rc_read_int_entry( rc, "Bars", bars );
 
@@ -76,6 +78,8 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 	set_color_mode( base, color_mode );
 	set_frame( base, frame );
 	set_command( base, associated_command );
+	set_in_terminal( base, in_terminal);
+	set_startup_notification( base, startup_notification );
 	set_border( base, border);
 	set_bars( base, bars);
 	set_color( base, 1, foreground1 );
@@ -100,32 +104,23 @@ void write_settings( XfcePanelPlugin *plugin, CPUGraph *base )
 		return;
 
 	xfce_rc_write_int_entry( rc, "UpdateInterval", base->update_interval );
-
 	xfce_rc_write_int_entry( rc, "TimeScale", base->non_linear );
-
 	xfce_rc_write_int_entry( rc, "Size", base->size );
-
 	xfce_rc_write_int_entry( rc, "Mode", base->mode );
-
 	xfce_rc_write_int_entry( rc, "Frame", base->frame );
-
 	xfce_rc_write_int_entry( rc, "Border", base->border );
-
 	xfce_rc_write_entry( rc, "AssociateCommand", base->command ? base->command : "" );
-
+	xfce_rc_write_int_entry( rc, "InTerminal", base->in_terminal );
+	xfce_rc_write_int_entry( rc, "StartupNotification", base->startup_notification );
 	xfce_rc_write_int_entry( rc, "ColorMode", base->color_mode );
 
 	g_snprintf( value, 8, "#%02X%02X%02X", base->colors[1].red >> 8, base->colors[1].green >> 8, base->colors[1].blue >> 8 );
 	xfce_rc_write_entry( rc, "Foreground1", value );
-
 	g_snprintf( value, 8, "#%02X%02X%02X", base->colors[2].red >> 8, base->colors[2].green >> 8, base->colors[2].blue >> 8 );
 	xfce_rc_write_entry( rc, "Foreground2", value );
-
 	g_snprintf( value, 8, "#%02X%02X%02X", base->colors[0].red >> 8, base->colors[0].green >> 8, base->colors[0].blue >> 8 );
 	xfce_rc_write_entry( rc, "Background", value );
-
 	g_snprintf( value, 8, "#%02X%02X%02X", base->colors[3].red >> 8, base->colors[3].green >> 8, base->colors[3].blue >> 8 );
 	xfce_rc_write_entry( rc, "Foreground3", value );
-
 	xfce_rc_close( rc );
 }



More information about the Xfce4-commits mailing list