[Xfce4-commits] <xfce4-diskperf-plugin:master> Always update the progress bars even when stats are unavailable.
Landry Breuil
noreply at xfce.org
Tue May 8 14:28:02 CEST 2012
Updating branch refs/heads/master
to 6ab7dbf56c8ce498164a3c6f9eca56dea83d8dc1 (commit)
from 1bbd0ee93d90f6b7dda5de5006ccdebe4c01fde5 (commit)
commit 6ab7dbf56c8ce498164a3c6f9eca56dea83d8dc1
Author: Harald Judt <h.judt at gmx.at>
Date: Mon May 7 12:12:38 2012 +0200
Always update the progress bars even when stats are unavailable.
In case of an error (e.g. a device gets removed or some
misdetection by the kernel), stats may become unavailable,
but the progress bars still show the old values, and the
plugin may seem frozen. Because we don't like it to appear
frozen, always update the bars and set their values to 0
when no stats are available.
Signed-off-by: Landry Breuil <landry at xfce.org>
panel-plugin/main.c | 35 +++++++++++++++++++++++------------
1 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/panel-plugin/main.c b/panel-plugin/main.c
index 3672f03..eea4f8a 100644
--- a/panel-plugin/main.c
+++ b/panel-plugin/main.c
@@ -143,6 +143,27 @@ typedef struct diskperf_t {
static int timerNeedsUpdate = 0;
+static void UpdateProgressBars(struct diskperf_t *p_poPlugin, uint64_t rw, uint64_t r, uint64_t w) {
+ /* Update combined or separate progress bars with actual data */
+ struct monitor_t *poMonitor = &(p_poPlugin->oMonitor);
+ struct param_t *poConf = &(p_poPlugin->oConf.oParam);
+ struct perfbar_t *poPerf = poMonitor->aoPerfBar;
+
+ if (poConf->fRW_DataCombined)
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
+ (*(poPerf[RW_DATA].pwBar)),
+ rw);
+ else {
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
+ (*(poPerf[R_DATA].pwBar)),
+ r);
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
+ (*(poPerf[W_DATA].pwBar)),
+ w);
+ }
+}
+
+
static int DisplayPerf (struct diskperf_t *p_poPlugin)
/* Get the last disk perfomance data, compute the statistics and update
the panel-docked monitor bars */
@@ -179,6 +200,7 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
if (status == -1) {
snprintf (acToolTips, sizeof(acToolTips), _("%s: Device statistics unavailable."),
poConf->acTitle);
+ UpdateProgressBars(p_poPlugin, 0, 0, 0);
gtk_tooltips_set_tip (s_poToolTips, GTK_WIDGET (poMonitor->wEventBox),
acToolTips, 0);
return (-1);
@@ -263,18 +285,7 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
else if (*pr < 0)
*pr = 0;
}
- if (poConf->fRW_DataCombined)
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
- (*(poPerf[RW_DATA].pwBar)),
- prData[RW_DATA]);
- else {
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
- (*(poPerf[R_DATA].pwBar)),
- prData[R_DATA]);
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
- (*(poPerf[W_DATA].pwBar)),
- prData[W_DATA]);
- }
+ UpdateProgressBars(p_poPlugin, prData[RW_DATA], prData[R_DATA], prData[W_DATA]);
return (0);
} /* DisplayPerf() */
More information about the Xfce4-commits
mailing list