mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Fixing #205 (Memory applet shows negative swap size).
Fixing bug which is related to memory applet in ede-panel, when swap is used, where negative value was never shown.
This commit is contained in:
parent
6f93f25468
commit
0cd54534d1
@ -5,6 +5,7 @@
|
|||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
#include <edelib/Color.h>
|
#include <edelib/Color.h>
|
||||||
#include <edelib/Missing.h>
|
#include <edelib/Missing.h>
|
||||||
|
#include <edelib/Nls.h>
|
||||||
#include "MemMonitor.h"
|
#include "MemMonitor.h"
|
||||||
|
|
||||||
EDELIB_NS_USING(color_rgb_to_fltk)
|
EDELIB_NS_USING(color_rgb_to_fltk)
|
||||||
@ -47,8 +48,8 @@ void MemMonitor::update_status(void) {
|
|||||||
long mem_total, mem_free, swap_total, swap_free;
|
long mem_total, mem_free, swap_total, swap_free;
|
||||||
mem_total = mem_free = swap_total = swap_free = 0;
|
mem_total = mem_free = swap_total = swap_free = 0;
|
||||||
|
|
||||||
char buf[128];
|
static char buf[128];
|
||||||
while(fgets(buf, 128, fd) != 0) {
|
while(fgets(buf, sizeof(buf), fd) != 0) {
|
||||||
if(STR_CMP(buf, "MemTotal:", 9))
|
if(STR_CMP(buf, "MemTotal:", 9))
|
||||||
mem_total = get_number(buf);
|
mem_total = get_number(buf);
|
||||||
else if(STR_CMP(buf, "MemFree:", 8))
|
else if(STR_CMP(buf, "MemFree:", 8))
|
||||||
@ -62,10 +63,10 @@ void MemMonitor::update_status(void) {
|
|||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
mem_usedp = 100 - (int)(((float)mem_free / (float)mem_total) * 100);
|
mem_usedp = 100 - (int)(((float)mem_free / (float)mem_total) * 100);
|
||||||
swap_usedp = 100 - (int)(((float)swap_total / (float)swap_free) * 100);
|
swap_usedp = 100 - (int)(((float)swap_free / (float)swap_total) * 100);
|
||||||
|
|
||||||
static char tip[100];
|
static char tip[100];
|
||||||
snprintf(tip, sizeof(tip), "Memory used: %i%%\nSwap used: %i%%", mem_usedp, swap_usedp);
|
snprintf(tip, sizeof(tip), _("Memory used: %i%%\nSwap used: %i%%"), mem_usedp, swap_usedp);
|
||||||
tooltip(tip);
|
tooltip(tip);
|
||||||
|
|
||||||
redraw();
|
redraw();
|
||||||
|
Loading…
Reference in New Issue
Block a user