Date: Tuesday, November 18, 2014 @ 22:04:26 Author: foutrelis Revision: 226369
upgpkg: xfce4-netload-plugin 1.2.3-2 Fix bandwidth display in tooltip (FS#42834). Added: xfce4-netload-plugin/trunk/0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch Modified: xfce4-netload-plugin/trunk/PKGBUILD -----------------------------------------------------------------+ 0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch | 147 ++++++++++ PKGBUILD | 15 - 2 files changed, 159 insertions(+), 3 deletions(-) Added: 0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch =================================================================== --- 0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch (rev 0) +++ 0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch 2014-11-18 21:04:26 UTC (rev 226369) @@ -0,0 +1,147 @@ +From 2e2d905b28d31c6065183ee7a52d238f0be410f5 Mon Sep 17 00:00:00 2001 +From: Mike Massonnet <m...@gandi.net> +Date: Sat, 15 Nov 2014 23:27:36 +0100 +Subject: [PATCH] Add argument as_bits to format_byte_humanreadable function + +--- + panel-plugin/commandline.c | 6 +++--- + panel-plugin/netload.c | 7 ++++--- + panel-plugin/utils.c | 25 +++++++++++++++++-------- + panel-plugin/utils.h | 4 +++- + 4 files changed, 27 insertions(+), 15 deletions(-) + +diff --git a/panel-plugin/commandline.c b/panel-plugin/commandline.c +index 5624845..8dfb4fb 100644 +--- a/panel-plugin/commandline.c ++++ b/panel-plugin/commandline.c +@@ -73,9 +73,9 @@ int main(int argc, char* argv[]) + for (;;) + { + get_current_netload(&data, &in, &out, &tot); +- format_byte_humanreadable(bufIn, 20, (double)in, 0); +- format_byte_humanreadable(bufOut, 20, (double)out, 0); +- format_byte_humanreadable(bufTot, 20, (double)tot, 0); ++ format_byte_humanreadable(bufIn, 20, (double)in, 0, FALSE); ++ format_byte_humanreadable(bufOut, 20, (double)out, 0, FALSE); ++ format_byte_humanreadable(bufTot, 20, (double)tot, 0, FALSE); + printf("Current netload:\nIN : %s\nOUT: %s\nTOT: %s\nIP: %s\n", + bufIn, bufOut, bufTot, get_ip_address(&data)); + sleep(1); +diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c +index 79d6bdb..990a75d 100644 +--- a/panel-plugin/netload.c ++++ b/panel-plugin/netload.c +@@ -27,6 +27,7 @@ + #include "utils.h" + #include "global.h" + ++#include <glib.h> + #include <gtk/gtk.h> + + #include <libxfce4util/libxfce4util.h> +@@ -240,11 +241,11 @@ static gboolean update_monitors(t_global_monitor *global) + if (global->monitor->options.show_bars) + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(global->monitor->status[i]), temp); + +- format_byte_humanreadable( buffer[i], BUFSIZ - 1, display[i], 2 ); +- format_byte_humanreadable( buffer_panel[i], BUFSIZ - 1, display[i], 2 ); ++ format_byte_humanreadable( buffer[i], BUFSIZ - 1, display[i], 2, FALSE ); ++ format_byte_humanreadable( buffer_panel[i], BUFSIZ - 1, display[i], 2, FALSE ); + } + +- format_byte_humanreadable( buffer[TOT], BUFSIZ - 1, (display[IN]+display[OUT]), 2 ); ++ format_byte_humanreadable( buffer[TOT], BUFSIZ - 1, (display[IN]+display[OUT]), 2, FALSE ); + + { + char* ip = get_ip_address(&(global->monitor->data)); +diff --git a/panel-plugin/utils.c b/panel-plugin/utils.c +index c2824ba..c262f87 100644 +--- a/panel-plugin/utils.c ++++ b/panel-plugin/utils.c +@@ -70,19 +70,28 @@ unsigned long max_array( unsigned long array[], int size ) + + + /* ---------------------------------------------------------------------------------------------- */ +-char* format_byte_humanreadable(char* string, int stringsize, double number, int digits) ++char* format_byte_humanreadable(char* string, int stringsize, double number, int digits, gboolean as_bits) + { + char* str = string; + char buffer[BUFSIZ], formatstring[BUFSIZ]; + char* bufptr = buffer; + char* unit_names[] = { N_("B"), N_("KiB"), N_("MiB"), N_("GiB") }; ++ char* unit_names_bits[] = { N_("bps"), N_("Kbps"), N_("Mbps"), N_("Gbps") }; + unsigned int uidx = 0; +- double number_displayed = number / 1024.0; ++ double number_displayed = 0; ++ double thousand_divider = as_bits ? 1000 : 1024; + unsigned int i; + int numberOfIntegerChars, count; + struct lconv* localeinfo = localeconv(); + int grouping = (int)localeinfo->grouping[0] == 0 ? INT_MAX : (int)localeinfo->grouping[0]; + ++ /* Start with kilo and adapt to bits values*/ ++ uidx = 1; ++ number_displayed = number / thousand_divider; ++ if (as_bits) ++ { ++ number_displayed *= 8; ++ } + + /* sensible value for digits */ + if (digits < 0 || digits >= 10) +@@ -90,16 +99,16 @@ char* format_byte_humanreadable(char* string, int stringsize, double number, int + digits = 2; + } + +- /* no digits for values under MiB/s unit size */ +- if (number < 1024.0 * 1024.0) ++ /* 1 digit for values above MiB/s unit size */ ++ if (digits > 1 && number_displayed > thousand_divider * thousand_divider) + { +- digits = 0; ++ digits = 1; + } + + /* calculate number and appropriate unit size for display */ +- while(number_displayed >= 1024.0 && uidx < (sizeof(unit_names) / sizeof(char*) - 1)) ++ while(number_displayed >= thousand_divider && uidx < (sizeof(unit_names) / sizeof(char*) - 1)) + { +- number_displayed /= 1024.0; ++ number_displayed /= thousand_divider; + uidx++; + } + +@@ -148,7 +157,7 @@ char* format_byte_humanreadable(char* string, int stringsize, double number, int + *str = 0; + + /* Add the unit name */ +- g_strlcat(string, _(unit_names[uidx]), stringsize); ++ g_strlcat(string, as_bits ? _(unit_names_bits[uidx]) : _(unit_names[uidx]), stringsize); + + return string; + } +diff --git a/panel-plugin/utils.h b/panel-plugin/utils.h +index 1da6a9b..749de87 100644 +--- a/panel-plugin/utils.h ++++ b/panel-plugin/utils.h +@@ -19,6 +19,8 @@ + #ifndef UTILS_H + #define UTILS_H + ++#include <glib.h> ++ + /** + * Formats the number into a number of the appropriate byte unit with + * a thousands separator, respecting the current locale. It appends +@@ -32,7 +34,7 @@ + * @param digits the number of digits after the decimal point + * @return the string to allow concatening buffers or <code>null</code> + */ +-char* format_byte_humanreadable( char* string, int stringsize, double number, int digits ); ++char* format_byte_humanreadable( char* string, int stringsize, double number, int digits, gboolean as_bits ); + + /** + * Returns the minimum of the array. The array must contain at least one element. +-- +2.1.3 + Modified: PKGBUILD =================================================================== --- PKGBUILD 2014-11-18 18:59:18 UTC (rev 226368) +++ PKGBUILD 2014-11-18 21:04:26 UTC (rev 226369) @@ -4,7 +4,7 @@ pkgname=xfce4-netload-plugin pkgver=1.2.3 -pkgrel=1 +pkgrel=2 pkgdesc="A netload plugin for the Xfce panel" arch=('i686' 'x86_64') url="http://goodies.xfce.org/projects/panel-plugins/xfce4-netload-plugin" @@ -13,9 +13,18 @@ depends=('xfce4-panel') makedepends=('intltool') install=$pkgname.install -source=(http://archive.xfce.org/src/panel-plugins/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.bz2) -sha256sums=('43bd1f291c83143a8a6acbe81f63080da772918c1c9a694793a75b29a2d3ba2c') +source=(http://archive.xfce.org/src/panel-plugins/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.bz2 + 0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch) +sha256sums=('43bd1f291c83143a8a6acbe81f63080da772918c1c9a694793a75b29a2d3ba2c' + '0ac37c6091544a2807090d07c6ca7775ef598ab20292891b80f769650ec2cd6e') +prepare() { + cd "$srcdir/$pkgname-$pkgver" + + # https://bugs.archlinux.org/task/42834 + patch -Np1 -i ../0001-Add-argument-as_bits-to-format_byte_humanreadable-fu.patch +} + build() { cd "$srcdir/$pkgname-$pkgver"