Tue Oct 26 13:42:53 PDT 1999
(KainX) First off, I removed some unneeded variables from E-MemWatch. I also fixed a reporting bug in E-Disk. But most importantly, I fixed Epplet_change_label() to avoid changing a label to the exact same string. This is the best place to handle this situation, because it saves resources (we already have both strings to compare) and, due to the nature of epplets, the probability is very high that this function would only (or at least primarily) be called from a timer callback. So it simplifies client code this way too. SVN revision: 983
This commit is contained in:
parent
fb6984b026
commit
94eac0fea1
15
ChangeLog
15
ChangeLog
|
@ -110,3 +110,18 @@ Mon Oct 25 23:43:23 PDT 1999
|
|||
(KainX)
|
||||
|
||||
E-NetFlame was too spiffy for me to not add it. :-)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Tue Oct 26 13:42:53 PDT 1999
|
||||
(KainX)
|
||||
|
||||
First off, I removed some unneeded variables from E-MemWatch. I also fixed a
|
||||
reporting bug in E-Disk.
|
||||
|
||||
But most importantly, I fixed Epplet_change_label() to avoid changing a label
|
||||
to the exact same string. This is the best place to handle this situation,
|
||||
because it saves resources (we already have both strings to compare) and, due
|
||||
to the nature of epplets, the probability is very high that this function
|
||||
would only (or at least primarily) be called from a timer callback. So it
|
||||
simplifies client code this way too.
|
||||
|
|
|
@ -2592,7 +2592,12 @@ Epplet_change_label(Epplet_gadget gadget, char *label)
|
|||
|
||||
g = (GadLabel *)gadget;
|
||||
if (g->label)
|
||||
free(g->label);
|
||||
{
|
||||
if (label && !strcmp(g->label, label))
|
||||
return; /* The labels are identical, so no sense in redrawing */
|
||||
else
|
||||
free(g->label); /* The labels are different. Proceed. */
|
||||
}
|
||||
g->label = Estrdup(label);
|
||||
Epplet_draw_label(gadget, 0);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ timer_cb(void *data) {
|
|||
if (in_blks != in_delta) {
|
||||
in_val = (int) ((((float) in_blks) / max_in) * 100.0);
|
||||
Epplet_gadget_data_changed(in_bar);
|
||||
sprintf(buff, "I: %lu K/s", in_blks / 2);
|
||||
sprintf(buff, "I: %lu K/s", in_blks / 4);
|
||||
Epplet_change_label(in_label, buff);
|
||||
}
|
||||
in_delta = in_blks;
|
||||
|
@ -73,7 +73,7 @@ timer_cb(void *data) {
|
|||
if (out_blks != out_delta) {
|
||||
out_val = (int) ((((float) out_blks) / max_out) * 100.0);
|
||||
Epplet_gadget_data_changed(out_bar);
|
||||
sprintf(buff, "O: %lu K/s", out_blks / 2);
|
||||
sprintf(buff, "O: %lu K/s", out_blks / 4);
|
||||
Epplet_change_label(out_label, buff);
|
||||
}
|
||||
out_delta = out_blks;
|
||||
|
|
|
@ -27,7 +27,7 @@ timer_cb(void *data) {
|
|||
|
||||
FILE *fp;
|
||||
char buff[1024];
|
||||
unsigned long total, used, mfree, shared, buffers, cached;
|
||||
unsigned long total, used, buffers, cached;
|
||||
|
||||
if ((fp = fopen("/proc/meminfo", "r")) == NULL) {
|
||||
D(("Failed to open /proc/meminfo -- %s\n", strerror(errno)));
|
||||
|
@ -35,8 +35,8 @@ timer_cb(void *data) {
|
|||
}
|
||||
fgets(buff, sizeof(buff), fp); /* Ignore the first line */
|
||||
fgets(buff, sizeof(buff), fp);
|
||||
sscanf(buff, "%*s %lu %lu %lu %lu %lu %lu",
|
||||
&total, &used, &mfree, &shared, &buffers, &cached);
|
||||
sscanf(buff, "%*s %lu %lu %*lu %*lu %lu %lu",
|
||||
&total, &used, &buffers, &cached);
|
||||
used -= (buffers + cached);
|
||||
mem_val = (int) ((((float) used) / total) * 100.0);
|
||||
D(("%d = 100 * %lu / %lu\n", (100 * used) / total, used, total));
|
||||
|
|
Loading…
Reference in New Issue