Tue Jun 4 15:48:53 EDT 2002
(KainX) Updated E-Disk to display throughput in bytes, kB, MB, or GB instead of just kB. Added a new epplet, E-Bandwidth, which does network usage in a manner similar to E-Disk. SVN revision: 6301
This commit is contained in:
parent
4fba517cbc
commit
867febee8c
12
ChangeLog
12
ChangeLog
|
@ -2254,3 +2254,15 @@ Sun Oct 14 11:13:21 PDT 2001
|
|||
Added the ability to specify a timezone for E-Time.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Tue Jun 4 15:48:53 EDT 2002
|
||||
(KainX)
|
||||
|
||||
Updated E-Disk to display throughput in bytes, kB, MB, or GB instead of just
|
||||
kB.
|
||||
|
||||
Added a new epplet, E-Bandwidth, which does network usage in a manner similar
|
||||
to E-Disk.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
dnl# $Id$
|
||||
|
||||
AC_INIT(api/epplet.c)
|
||||
AM_INIT_AUTOMAKE(epplets, 0.6)
|
||||
AM_INIT_AUTOMAKE(epplets, 0.7)
|
||||
|
||||
dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
|
||||
if test ! -z "${CFLAGS}" -o ! -z "${CCOPTS}"; then
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
Summary: Enlightenment Epplets
|
||||
Name: epplets
|
||||
Version: 0.6
|
||||
Release: 3
|
||||
Version: 0.7
|
||||
Release: 0.1
|
||||
Copyright: BSD
|
||||
Group: User Interface/X
|
||||
URL: http://www.enlightenment.org
|
||||
|
|
|
@ -48,6 +48,20 @@ static void in_cb(void *data, Window w);
|
|||
static void out_cb(void *data, Window w);
|
||||
static void parse_conf(void);
|
||||
|
||||
static void
|
||||
show_size(unsigned long n, char *buff)
|
||||
{
|
||||
if (n < 1024) {
|
||||
sprintf(buff, "%lu b", n);
|
||||
} else if (n < 1024 * 1024) {
|
||||
sprintf(buff, "%lu k", n / 1024);
|
||||
} else if (n < 1024 * 1024 * 1024) {
|
||||
sprintf(buff, "%lu M", n / (1024 * 1024));
|
||||
} else {
|
||||
sprintf(buff, "%lu G", n / (1024 * 1024 * 1024));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
timer_cb(void *data) {
|
||||
|
||||
|
@ -93,7 +107,9 @@ 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);
|
||||
Esnprintf(buff, sizeof(buff), "I: %lu K/s", in_blks / 4);
|
||||
sprintf(buff, "I: ");
|
||||
show_size(in_blks * 512, buff + 3);
|
||||
strcat(buff, "/s");
|
||||
Epplet_change_label(in_label, buff);
|
||||
}
|
||||
in_delta = in_blks;
|
||||
|
@ -110,7 +126,9 @@ 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);
|
||||
Esnprintf(buff, sizeof(buff), "O: %lu K/s", out_blks / 4);
|
||||
sprintf(buff, "O: ");
|
||||
show_size(out_blks * 512, buff + 3);
|
||||
strcat(buff, "/s");
|
||||
Epplet_change_label(out_label, buff);
|
||||
}
|
||||
out_delta = out_blks;
|
||||
|
@ -118,7 +136,7 @@ timer_cb(void *data) {
|
|||
last_out += out_blks;
|
||||
|
||||
Esync();
|
||||
Epplet_timer(timer_cb, NULL, 0.5, "TIMER");
|
||||
Epplet_timer(timer_cb, NULL, 1.0, "TIMER");
|
||||
return;
|
||||
data = NULL;
|
||||
}
|
||||
|
@ -201,22 +219,22 @@ main(int argc, char **argv) {
|
|||
prio = getpriority(PRIO_PROCESS, getpid());
|
||||
setpriority(PRIO_PROCESS, getpid(), prio + 10);
|
||||
atexit(Epplet_cleanup);
|
||||
Epplet_Init("E-Disk", "0.1", "Enlightenment Disk I/O Monitor Epplet", 3, 3, argc, argv, 0);
|
||||
Epplet_Init("E-Disk", "0.2", "Enlightenment Disk I/O Monitor Epplet", 3, 3, argc, argv, 0);
|
||||
Epplet_load_config();
|
||||
parse_conf();
|
||||
|
||||
title = Epplet_create_label(3, 3, "Disk I/O", 1);
|
||||
if (show_title) {
|
||||
/* New arrangement */
|
||||
in_label = Epplet_create_label(3, 13, "I: 0 K/s", 1);
|
||||
out_label = Epplet_create_label(3, 30, "O: 0 K/s", 1);
|
||||
in_label = Epplet_create_label(3, 13, "I: 0 b/s", 1);
|
||||
out_label = Epplet_create_label(3, 30, "O: 0 b/s", 1);
|
||||
in_bar = Epplet_create_hbar(3, 22, 42, 7, 0, &in_val);
|
||||
out_bar = Epplet_create_hbar(3, 39, 42, 7, 0, &out_val);
|
||||
Epplet_gadget_show(title);
|
||||
} else {
|
||||
/* Old arrangement */
|
||||
in_label = Epplet_create_label(4, 4, "I: 0 K/s", 1);
|
||||
out_label = Epplet_create_label(4, 24, "O: 0 K/s", 1);
|
||||
in_label = Epplet_create_label(4, 4, "I: 0 b/s", 1);
|
||||
out_label = Epplet_create_label(4, 24, "O: 0 b/s", 1);
|
||||
in_bar = Epplet_create_hbar(4, 14, 40, 8, 0, &in_val);
|
||||
out_bar = Epplet_create_hbar(4, 36, 40, 8, 0, &out_val);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ E-Toolbox.epplet E-NetFlame.epplet E-Sys.epplet E-ScreenShoot.epplet \
|
|||
E-Slides.epplet E-Xss.epplet E-Mountbox.epplet E-Exec.epplet @ESD_PROGS@ \
|
||||
@PLAYCD_PROGS@ E-ScreenSave.epplet E-NetGraph.epplet E-MoonClock.epplet \
|
||||
E-UrlWatch.epplet E-LoadMeter.epplet E-GtkRc.epplet E-Pinger.epplet \
|
||||
E-Pants.epplet
|
||||
E-Pants.epplet E-Bandwidth.epplet
|
||||
|
||||
|
||||
EXTRA_PROGRAMS = EppletTest.epplet EppletConfigTest.epplet E-Mixer.epplet \
|
||||
|
@ -90,6 +90,10 @@ E_Areas_epplet_SOURCES = E-Areas.c
|
|||
E_Areas_epplet_DEPENDENCIES = $(top_builddir)/api/libepplet.la
|
||||
E_Areas_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
||||
|
||||
E_Bandwidth_epplet_SOURCES = E-Bandwidth.c net.c net.h
|
||||
E_Bandwidth_epplet_DEPENDENCIES = $(top_builddir)/api/libepplet.la
|
||||
E_Bandwidth_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
||||
|
||||
E_Net_epplet_SOURCES = E-Net.c net.c net.h
|
||||
E_Net_epplet_DEPENDENCIES = $(top_builddir)/api/libepplet.la
|
||||
E_Net_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
# include <kstat.h>
|
||||
# include <sys/sysinfo.h>
|
||||
#endif
|
||||
#ifdef linux
|
||||
# include <linux/version.h>
|
||||
#endif
|
||||
#include "epplet.h"
|
||||
#include "net.h"
|
||||
|
||||
|
@ -133,7 +136,7 @@ net_get_bytes_inout(const char *device, double *in_bytes, double *out_bytes) {
|
|||
if (colon) {
|
||||
*colon = ' ';
|
||||
}
|
||||
# if LINUX_VERSION_CODE < 0x020100
|
||||
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
|
||||
sscanf(buff, "%s %s %*s %*s %*s %*s %s", dev, in_str, out_str);
|
||||
# else
|
||||
sscanf(buff, "%s %s %*s %*s %*s %*s %*s %*s %*s %s", dev, in_str, out_str);
|
||||
|
|
Loading…
Reference in New Issue