[Xfce4-commits] <xfce4-cpugraph-plugin:master> Fix the border

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


Updating branch refs/heads/master
         to b3e6892eb8a2eda35c13ac2a10e0a9a2791fe227 (commit)
       from e1d75ed7673c6624e24f41b954fbb28bdf4e8af8 (commit)

commit b3e6892eb8a2eda35c13ac2a10e0a9a2791fe227
Author: Florian <frivoal at gmail.com>
Date:   Thu Mar 11 10:24:42 2010 +0900

    Fix the border
    
    Put the border on the right component, and use the right size, to match
    the visual style of other xfce pannel plugins. On the other hand, the
    border takes space. Making it optional allows for more efficient use of
    screen real estate if wanted. This resolves bug 6257 and the first issue
    of bug 5433.

 panel-plugin/cpu.c        |    8 ++++++--
 panel-plugin/cpu.h        |    2 ++
 panel-plugin/properties.c |    7 +++++++
 panel-plugin/settings.c   |    5 +++++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index cfbe4df..125350a 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -115,8 +115,6 @@ static gboolean size_cb( XfcePanelPlugin *plugin, int size, CPUGraph *base )
 	gint i;
 	gint frame_h, frame_v, bar_h, bar_v, history;
 
-	gtk_container_set_border_width( GTK_CONTAINER( base->m_FrameWidget ), MIN( size ,base->size ) > 26 ? 2 : 0 );
-
 	if( xfce_panel_plugin_get_orientation( plugin ) == GTK_ORIENTATION_HORIZONTAL )
 	{
 		frame_h = base->size;
@@ -273,6 +271,12 @@ void set_command( CPUGraph *base, const gchar *command )
 	base->command = g_strdup( command );
 }
 
+void set_border( CPUGraph *base, gboolean border )
+{
+	base->border = border;
+	gtk_container_set_border_width( GTK_CONTAINER( base->m_Box ), border ? BORDER / 2 : 0 );
+}
+
 void set_frame( CPUGraph *base, gboolean frame )
 {
 	base->frame = frame;
diff --git a/panel-plugin/cpu.h b/panel-plugin/cpu.h
index a7c8986..4937f60 100644
--- a/panel-plugin/cpu.h
+++ b/panel-plugin/cpu.h
@@ -38,6 +38,7 @@ typedef struct
 	int mode;
 	int color_mode;
 	gboolean frame;
+	gboolean border;
 	gchar  *command;
 	GdkColor colors[4];
 
@@ -52,6 +53,7 @@ typedef struct
 } CPUGraph;
 
 void set_command( CPUGraph *base, const gchar *command );
+void set_border( CPUGraph *base, gboolean border);
 void set_frame( CPUGraph *base, gboolean frame );
 void set_nonlinear_time( CPUGraph *base, gboolean nonlinear );
 void set_update_rate( CPUGraph *base, int rate );
diff --git a/panel-plugin/properties.c b/panel-plugin/properties.c
index cd00b74..00e6d93 100644
--- a/panel-plugin/properties.c
+++ b/panel-plugin/properties.c
@@ -24,6 +24,7 @@ static void change_mode( GtkOptionMenu *om, CPUGraph *base );
 static void change_color_mode( GtkOptionMenu *om, CPUGraph *base );
 static void response_cb( GtkWidget *dlg, int response, CPUGraph *base );
 static void change_frame( GtkToggleButton *button, CPUGraph *base );
+static void change_border( GtkToggleButton *button, CPUGraph *base );
 static void change_size( GtkSpinButton *sb, CPUGraph *base );
 static void change_time_scale( GtkToggleButton *button, CPUGraph *base );
 static void change_update( GtkOptionMenu *om, CPUGraph *base );
@@ -65,6 +66,7 @@ void create_options( XfcePanelPlugin *plugin, CPUGraph *base )
 	setup_size_option( vbox, sg, plugin, base );
 	create_check_box( vbox, sg, _("Non-linear time-scale"), base->non_linear, change_time_scale, base );
 	create_check_box( vbox, sg, _("Show frame"), base->frame, change_frame, base );
+	create_check_box( vbox, sg, _("Border"), base->border, change_border, base );
 	setup_command_option( vbox, sg, base );
 
 	vbox2 = create_tab();
@@ -311,6 +313,11 @@ static void change_frame( GtkToggleButton * button, CPUGraph * base )
 	set_frame( base, gtk_toggle_button_get_active( button ) );
 }
 
+static void change_border( GtkToggleButton * button, CPUGraph * base )
+{
+	set_border( base, gtk_toggle_button_get_active( button ) );
+}
+
 static void change_size( GtkSpinButton * sb, CPUGraph *base)
 {
 	set_size( base, gtk_spin_button_get_value_as_int( sb ) );
diff --git a/panel-plugin/settings.c b/panel-plugin/settings.c
index 6e1e1a3..8673262 100644
--- a/panel-plugin/settings.c
+++ b/panel-plugin/settings.c
@@ -14,6 +14,7 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 	int mode = 0;
 	int color_mode = 0;
 	gboolean frame = FALSE;
+	gboolean border = TRUE;
 	const gchar  *associated_command = DEFAULT_COMMAND;
 
 	GdkColor foreground1;
@@ -51,6 +52,7 @@ 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 );
+			border = xfce_rc_read_int_entry( rc, "Border", border );
 
 			if( (value = xfce_rc_read_entry( rc, "Foreground1", NULL )) )
 				gdk_color_parse( value, &foreground1 );
@@ -72,6 +74,7 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
 	set_color_mode( base, color_mode );
 	set_frame( base, frame );
 	set_command( base, associated_command );
+	set_border( base, border);
 	set_color( base, 1, foreground1 );
 	set_color( base, 2, foreground2 );
 	set_color( base, 3, foreground3 );
@@ -103,6 +106,8 @@ void write_settings( XfcePanelPlugin *plugin, CPUGraph *base )
 
 	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, "ColorMode", base->color_mode );



More information about the Xfce4-commits mailing list