From 115572cfa5e1d0de8465939656719339bb6ff695 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Mon, 28 May 2012 10:42:20 +0200 Subject: Use better border sizes dependent on the panel size. Use 0px on very small panels, which look ugly anyway and where the only concern is to preserve as much space as possible. Use 1px on small panels to optimize for the use of space, while still trying to preserve a good look. Use 2px for bigger panel sizes. Looks pretty and does not waste space unnecessarily. --- panel-plugin/cpu.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c index f72c626..93c24a1 100644 --- a/panel-plugin/cpu.c +++ b/panel-plugin/cpu.c @@ -64,6 +64,28 @@ static gboolean command_cb( GtkWidget *w, GdkEventButton *event, CPUGraph *base XFCE_PANEL_PLUGIN_REGISTER( cpugraph_construct ); +/* Find the optimal border for the current panel size */ +static int get_optimal_border(XfcePanelPlugin *plugin) +{ + int panel_size = xfce_panel_plugin_get_size (plugin); + + /* Use 0px on very small panels, which look ugly anyway and where + the only concern is to preserve as much space as possible. */ + int border = 0; + + /* Use 1px on small panels to optimize for the use of space, while + still trying to preserve a good look. */ + if (panel_size > 20) + border = 1; + + /* Use 2px for bigger panel sizes. Looks pretty and does not waste + space unnecessarily. */ + if (panel_size > 26) + border = 2; + + return border; +} + static void cpugraph_construct( XfcePanelPlugin *plugin ) { CPUGraph *base; @@ -250,6 +272,7 @@ static gboolean size_cb( XfcePanelPlugin *plugin, guint size, CPUGraph *base ) if( base->has_bars ) set_bars_size( base, size, orientation ); + set_border( base, base->has_border ); return TRUE; } @@ -444,7 +467,7 @@ void set_bars( CPUGraph * base, gboolean bars) void set_border( CPUGraph *base, gboolean border ) { base->has_border = border; - gtk_container_set_border_width( GTK_CONTAINER( base->box ), border ? BORDER / 2 : 0 ); + gtk_container_set_border_width( GTK_CONTAINER( base->box ), border ? get_optimal_border(base->plugin) : 0 ); } void set_frame( CPUGraph *base, gboolean frame ) -- 1.7.8.6