From 78d75ff68d461b59653ea2fa471a415d98f56de9 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Mon, 28 May 2012 11:06:00 +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/netload.c | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c index a45fa86..2e738a4 100644 --- a/panel-plugin/netload.c +++ b/panel-plugin/netload.c @@ -161,6 +161,30 @@ static void setup_monitor(t_global_monitor *global, gboolean supress_warnings); /* ---------------------------------------------------------------------------------------------- */ +/* 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 gboolean update_monitors(t_global_monitor *global) { char buffer[SUM+1][BUFSIZ]; @@ -440,7 +464,7 @@ static t_global_monitor * monitor_new(XfcePanelPlugin *plugin) /* Create widget containers */ global->box = xfce_hvbox_new(orientation, FALSE, 0); gtk_widget_show(GTK_WIDGET(global->box)); - gtk_container_set_border_width(GTK_CONTAINER(global->box), BORDER / 2); + gtk_container_set_border_width(GTK_CONTAINER(global->box), get_optimal_border(plugin)); /* Create the title label */ global->monitor->label = gtk_label_new(global->monitor->options.label_text); @@ -746,6 +770,8 @@ static gboolean monitor_set_size(XfcePanelPlugin *plugin, int size, t_global_mon } PRINT_DBG("monitor_set_size"); + gtk_container_set_border_width(GTK_CONTAINER(global->box), get_optimal_border(plugin)); + return TRUE; } -- 1.7.8.6