Bug 8941: Support new panel mode Deskbar
Bumped dependency to Xfce Panel 4.9, and replaced Orientation code against Mode. Properly support three modes Horizontal, Vertical, and Deskbar by respecting the Panel HIG. Fixes also bug 8959, code sets 1px border width for very small panels, 2px otherwise. Use pixel fixed width (60px) instead of width_chars for labels, because in vertical mode the size is incorrect. Fix 9073, custom colors wasn't working for the progress bars, this has been fixed while rearranging the code.master
parent
1d664b8316
commit
7434a7f1fb
|
@ -6,7 +6,7 @@ dnl Copyright 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de>
|
||||||
dnl Copyright 2010 Florian Rivoal <frivoal@xfce.org>
|
dnl Copyright 2010 Florian Rivoal <frivoal@xfce.org>
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
m4_define([netload_version],[1.1.0])
|
m4_define([netload_version],[1.2.0])
|
||||||
|
|
||||||
AC_INIT([xfce4-netload-plugin], [netload_version],
|
AC_INIT([xfce4-netload-plugin], [netload_version],
|
||||||
[goodies-dev@xfce.org])
|
[goodies-dev@xfce.org])
|
||||||
|
@ -53,10 +53,10 @@ AC_CHECK_LIB(nsl, kstat_open, SOLLIBS="$SOLLIBS -linet_ntop", SOLLIBS="$SOLLIBS"
|
||||||
AC_SUBST(SOLLIBS)
|
AC_SUBST(SOLLIBS)
|
||||||
|
|
||||||
dnl configure the panel plugin
|
dnl configure the panel plugin
|
||||||
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.7.0])
|
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.9.0])
|
||||||
|
|
||||||
dnl configure the libxfcegui4
|
dnl configure the libxfcegui4
|
||||||
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.7.0])
|
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.9.0])
|
||||||
|
|
||||||
dnl Check for i18n support
|
dnl Check for i18n support
|
||||||
XDT_I18N([@LINGUAS@])
|
XDT_I18N([@LINGUAS@])
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
|
|
||||||
#define BORDER 8
|
#define BORDER 8
|
||||||
|
#define LABEL_SIZE 60
|
||||||
|
|
||||||
/* Defaults */
|
/* Defaults */
|
||||||
#define DEFAULT_TEXT "Net"
|
#define DEFAULT_TEXT "Net"
|
||||||
|
@ -283,37 +284,99 @@ static void run_update (t_global_monitor *global)
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
static void monitor_set_orientation (XfcePanelPlugin *plugin, GtkOrientation orientation,
|
static gboolean monitor_set_size(XfcePanelPlugin *plugin, int size, t_global_monitor *global)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
XfcePanelPluginMode mode = xfce_panel_plugin_get_mode (plugin);
|
||||||
|
|
||||||
|
PRINT_DBG("monitor_set_size");
|
||||||
|
|
||||||
|
if (mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
|
||||||
|
{
|
||||||
|
for (i = 0; i < SUM; i++)
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]), BORDER, BORDER);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->rcv_label), -1, -1);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->sent_label), -1, -1);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(plugin), size, -1);
|
||||||
|
}
|
||||||
|
else if (mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL)
|
||||||
|
{
|
||||||
|
for (i = 0; i < SUM; i++)
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]), -1, BORDER);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->rcv_label), -1, LABEL_SIZE);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->sent_label), -1, LABEL_SIZE);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(plugin), size, -1);
|
||||||
|
}
|
||||||
|
else /* mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL */
|
||||||
|
{
|
||||||
|
for (i = 0; i < SUM; i++)
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]), BORDER, -1);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->rcv_label), LABEL_SIZE, -1);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->sent_label), LABEL_SIZE, -1);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(plugin), -1, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_container_set_border_width(GTK_CONTAINER(global->box), size > 26 ? 2 : 1);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
static void monitor_set_mode (XfcePanelPlugin *plugin, XfcePanelPluginMode mode,
|
||||||
t_global_monitor *global)
|
t_global_monitor *global)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
PRINT_DBG("monitor_set_mode");
|
||||||
|
|
||||||
if (global->timeout_id)
|
if (global->timeout_id)
|
||||||
{
|
{
|
||||||
g_source_remove(global->timeout_id);
|
g_source_remove(global->timeout_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfce_hvbox_set_orientation(XFCE_HVBOX(global->box), orientation);
|
if (mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
|
||||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
||||||
{
|
{
|
||||||
gtk_misc_set_alignment(GTK_MISC(global->monitor->rcv_label), 1.0f, 0.5f);
|
xfce_hvbox_set_orientation(XFCE_HVBOX(global->box), GTK_ORIENTATION_VERTICAL);
|
||||||
gtk_misc_set_alignment(GTK_MISC(global->monitor->sent_label), 0.0f, 0.5f);
|
gtk_label_set_angle(GTK_LABEL(global->monitor->label), 0);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(global->monitor->rcv_label), 0.5f, 1.0f);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(global->monitor->sent_label), 0.5f, 0.0f);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->rcv_label), 0);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->sent_label), 0);
|
||||||
for (i = 0; i < SUM; i++)
|
for (i = 0; i < SUM; i++)
|
||||||
{
|
|
||||||
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
|
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
|
||||||
GTK_PROGRESS_BOTTOM_TO_TOP);
|
GTK_PROGRESS_LEFT_TO_RIGHT);
|
||||||
}
|
}
|
||||||
}
|
else if (mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
gtk_misc_set_alignment(GTK_MISC(global->monitor->rcv_label), 1.0f, 0.0f);
|
xfce_hvbox_set_orientation(XFCE_HVBOX(global->box), GTK_ORIENTATION_VERTICAL);
|
||||||
gtk_misc_set_alignment(GTK_MISC(global->monitor->sent_label), 1.0f, 1.0f);
|
gtk_label_set_angle(GTK_LABEL(global->monitor->label), 270);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(global->monitor->rcv_label), 0.5f, 1.0f);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(global->monitor->sent_label), 0.5f, 0.0f);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->rcv_label), 270);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->sent_label), 270);
|
||||||
for (i = 0; i < SUM; i++)
|
for (i = 0; i < SUM; i++)
|
||||||
{
|
{
|
||||||
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
|
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
|
||||||
GTK_PROGRESS_LEFT_TO_RIGHT);
|
GTK_PROGRESS_LEFT_TO_RIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else /* mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL */
|
||||||
|
{
|
||||||
|
xfce_hvbox_set_orientation(XFCE_HVBOX(global->box), GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->label), 0);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(global->monitor->rcv_label), 1.0f, 0.5f);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(global->monitor->sent_label), 0.0f, 0.5f);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->rcv_label), 0);
|
||||||
|
gtk_label_set_angle(GTK_LABEL(global->monitor->sent_label), 0);
|
||||||
|
for (i = 0; i < SUM; i++)
|
||||||
|
{
|
||||||
|
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
|
||||||
|
GTK_PROGRESS_BOTTOM_TO_TOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor_set_size(plugin, xfce_panel_plugin_get_size(plugin), global);
|
||||||
|
|
||||||
run_update( global );
|
run_update( global );
|
||||||
}
|
}
|
||||||
|
@ -405,30 +468,15 @@ static t_global_monitor * monitor_new(XfcePanelPlugin *plugin)
|
||||||
|
|
||||||
/* Create sent and received labels */
|
/* Create sent and received labels */
|
||||||
global->monitor->rcv_label = gtk_label_new("-");
|
global->monitor->rcv_label = gtk_label_new("-");
|
||||||
gtk_label_set_width_chars(GTK_LABEL(global->monitor->rcv_label), 7);
|
|
||||||
global->monitor->sent_label = gtk_label_new("-");
|
global->monitor->sent_label = gtk_label_new("-");
|
||||||
gtk_label_set_width_chars(GTK_LABEL(global->monitor->sent_label), 7);
|
|
||||||
gtk_box_pack_start(GTK_BOX(global->box),
|
gtk_box_pack_start(GTK_BOX(global->box),
|
||||||
GTK_WIDGET(global->monitor->rcv_label),
|
GTK_WIDGET(global->monitor->rcv_label),
|
||||||
TRUE, FALSE, BORDER / 2);
|
TRUE, FALSE, BORDER / 2);
|
||||||
gtk_misc_set_alignment(GTK_MISC(global->monitor->rcv_label), 1.0f, 0.5f);
|
|
||||||
gtk_misc_set_alignment(GTK_MISC(global->monitor->sent_label), 0.0f, 0.5f);
|
|
||||||
|
|
||||||
/* Create the progress bars */
|
/* Create the progress bars */
|
||||||
for (i = 0; i < SUM; i++)
|
for (i = 0; i < SUM; i++)
|
||||||
{
|
{
|
||||||
global->monitor->status[i] = GTK_WIDGET(gtk_progress_bar_new());
|
global->monitor->status[i] = GTK_WIDGET(gtk_progress_bar_new());
|
||||||
gtk_widget_modify_bg(GTK_WIDGET(global->monitor->status[i]),
|
|
||||||
GTK_STATE_PRELIGHT,
|
|
||||||
&global->monitor->options.color[i]);
|
|
||||||
gtk_widget_modify_bg(GTK_WIDGET(global->monitor->status[i]),
|
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
&global->monitor->options.color[i]);
|
|
||||||
gtk_widget_modify_base(GTK_WIDGET(global->monitor->status[i]),
|
|
||||||
GTK_STATE_SELECTED,
|
|
||||||
&global->monitor->options.color[i]);
|
|
||||||
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
|
|
||||||
GTK_PROGRESS_BOTTOM_TO_TOP);
|
|
||||||
gtk_box_pack_start(GTK_BOX(global->box),
|
gtk_box_pack_start(GTK_BOX(global->box),
|
||||||
GTK_WIDGET(global->monitor->status[i]), FALSE, FALSE, 0);
|
GTK_WIDGET(global->monitor->status[i]), FALSE, FALSE, 0);
|
||||||
}
|
}
|
||||||
|
@ -497,6 +545,17 @@ static void setup_monitor(t_global_monitor *global, gboolean supress_warnings)
|
||||||
else
|
else
|
||||||
global->monitor->net_max[i] = global->monitor->options.max[i];
|
global->monitor->net_max[i] = global->monitor->options.max[i];
|
||||||
gtk_widget_show(global->monitor->status[i]);
|
gtk_widget_show(global->monitor->status[i]);
|
||||||
|
|
||||||
|
/* Set bar colors */
|
||||||
|
gtk_widget_modify_bg(GTK_WIDGET(global->monitor->status[i]),
|
||||||
|
GTK_STATE_PRELIGHT,
|
||||||
|
&global->monitor->options.color[i]);
|
||||||
|
gtk_widget_modify_bg(GTK_WIDGET(global->monitor->status[i]),
|
||||||
|
GTK_STATE_SELECTED,
|
||||||
|
&global->monitor->options.color[i]);
|
||||||
|
gtk_widget_modify_base(GTK_WIDGET(global->monitor->status[i]),
|
||||||
|
GTK_STATE_SELECTED,
|
||||||
|
&global->monitor->options.color[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -522,6 +581,8 @@ static void setup_monitor(t_global_monitor *global, gboolean supress_warnings)
|
||||||
}
|
}
|
||||||
global->monitor->options.old_network_device = g_strdup(global->monitor->options.network_device);
|
global->monitor->options.old_network_device = g_strdup(global->monitor->options.network_device);
|
||||||
|
|
||||||
|
monitor_set_mode(global->plugin, xfce_panel_plugin_get_mode(global->plugin), global);
|
||||||
|
|
||||||
run_update( global );
|
run_update( global );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,30 +707,6 @@ static void monitor_write_config(XfcePanelPlugin *plugin, t_global_monitor *glob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
|
||||||
static gboolean monitor_set_size(XfcePanelPlugin *plugin, int size, t_global_monitor *global)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
for (i = 0; i < SUM; i++)
|
|
||||||
{
|
|
||||||
if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL)
|
|
||||||
{
|
|
||||||
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]),
|
|
||||||
BORDER, -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_set_size_request(GTK_WIDGET(global->monitor->status[i]),
|
|
||||||
-1, BORDER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINT_DBG("monitor_set_size");
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
static void monitor_apply_options(t_global_monitor *global)
|
static void monitor_apply_options(t_global_monitor *global)
|
||||||
{
|
{
|
||||||
|
@ -1220,7 +1257,7 @@ static void netload_construct (XfcePanelPlugin *plugin)
|
||||||
|
|
||||||
g_signal_connect (plugin, "size-changed", G_CALLBACK (monitor_set_size), global);
|
g_signal_connect (plugin, "size-changed", G_CALLBACK (monitor_set_size), global);
|
||||||
|
|
||||||
g_signal_connect (plugin, "orientation-changed", G_CALLBACK (monitor_set_orientation), global);
|
g_signal_connect (plugin, "mode-changed", G_CALLBACK (monitor_set_mode), global);
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(plugin), global->ebox);
|
gtk_container_add(GTK_CONTAINER(plugin), global->ebox);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue