Enlightenment CVS committal
Author : devilhorns
Project : e_modules
Module : net
Dir : e_modules/net
Modified Files:
net.edc e_mod_main.h e_mod_main.c e_mod_config.c
Log Message:
Net Module Graphs Now :)
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/net/net.edc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- net.edc 26 Feb 2006 19:24:52 -0000 1.13
+++ net.edc 1 Mar 2006 11:10:35 -0000 1.14
@@ -1,109 +1,156 @@
images
{
- image: "eth_dev.png" COMP;
+ image: "eth_dev.png" COMP;
}
fonts
{
- font: "VeraMono.ttf" "VeraMono";
+ font: "VeraMono.ttf" "VeraMono";
}
collections
{
-group
- {
- name: "modules/net/main";
- parts{
- part {
- name: "net";
- clip_to: "net_clip";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 255 255 255 200;
- aspect: 0.5 2.25;
- rel1 {
- relative: 0.0 0.0;
- }
- rel2 {
- relative: 1.0 1.0;
- }
- image {
- normal: "eth_dev.png";
- }
- fill {
- smooth: 0;
- }
- }
- }
- part {
- name: "out-text";
- type: TEXT;
- clip_to: "net_clip";
- effect: SOFT_SHADOW;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- align: 1.0 0.0;
- rel1 {
- relative: 1.0 0.0;
- }
- rel2 {
- relative: 1.0 0.0;
- }
- color: 51 181 69 255;
- color3: 0 0 0 100;
- text {
- text: "";
- font: "VeraMono";
- size: 8;
- min: 1 1;
- align: 1.0 0.0;
- }
- }
+ group
+ {
+ name: "modules/net/main";
+ parts
+ {
+ part
+ {
+ name: "net_clip";
+ type: RECT;
+ mouse_events: 0;
+ description
+ {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ }
+ }
+ part
+ {
+ name: "net";
+ clip_to: "net_clip";
+ mouse_events: 0;
+ description
+ {
+ state: "default" 0.0;
+ color: 255 255 255 200;
+ //aspect: 0.5 2.25;
+ rel1
+ {
+ relative: 0.0 0.0;
+ }
+ rel2
+ {
+ relative: 1.0 1.0;
+ }
+ image
+ {
+ normal: "eth_dev.png";
+ }
+ fill
+ {
+ smooth: 0;
+ }
+ }
+ }
+ part
+ {
+ name, "lines";
+ mouse_events, 0;
+ type, SWALLOW;
+ clip_to: "net_clip";
+ description
+ {
+ state, "default" 0.0;
+ rel1
+ {
+ relative: 0.0 0.0;
+ }
+ rel2
+ {
+ relative: 1.0 1.0;
+ }
+ color, 0 0 0 0;
+ }
+ }
}
+ }
- part {
- name: "in-text";
- type: TEXT;
- clip_to: "net_clip";
- effect: SOFT_SHADOW;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- align: 1.0 1.0;
- rel1 {
- relative: 1.0 1.0;
- }
- rel2 {
- relative: 1.0 1.0;
- }
- color: 213 91 91 255;
- color3: 0 0 0 100;
- text {
- text: "";
- font: "VeraMono";
- size: 8;
- min: 1 1;
- align: 1.0 1.0;
- }
- }
- }
- part {
- name: "net_clip";
- type: RECT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 255 255 255 255;
- }
- description {
- state: "faded" 0.0;
- color: 255 255 255 128;
- }
- }
-
- }
- }//close group net
+ group
+ {
+ name: "modules/net/tx_text";
+ parts
+ {
+ part
+ {
+ name: "tx-text";
+ type: TEXT;
+ effect: SOFT_SHADOW;
+ mouse_events: 0;
+ description
+ {
+ state: "default" 0.0;
+ align: 1.0 0.0;
+ rel1
+ {
+ relative: 0.0 0.0;
+ }
+ rel2
+ {
+ relative: 1.0 0.0;
+ }
+ color: 51 181 69 255;
+ color3: 0 0 0 100;
+ text
+ {
+ text: "Tx";
+ font: "VeraMono";
+ size: 10;
+ min: 1 1;
+ align: 1.0 0.0;
+ }
+ }
+ }
+ }
+ }
+
+ group
+ {
+ name: "modules/net/rx_text";
+ parts
+ {
+ part
+ {
+ name: "rx-text";
+ type: TEXT;
+ effect: SOFT_SHADOW;
+ mouse_events: 0;
+ description
+ {
+ state: "default" 0.0;
+ align: 1.0 1.0;
+ rel1
+ {
+ relative: 0.0 0.0;
+ }
+ rel2
+ {
+ relative: 1.0 1.0;
+ }
+ color: 255 0 0 255;
+ color3: 0 0 0 100;
+ text
+ {
+ text: "Rx";
+ font: "VeraMono";
+ size: 10;
+ min: 1 1;
+ align: 1.0 1.0;
+ }
+ }
+ }
+ }
+ }
}
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/net/e_mod_main.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- e_mod_main.h 21 Feb 2006 23:56:27 -0000 1.4
+++ e_mod_main.h 1 Mar 2006 11:10:35 -0000 1.5
@@ -16,6 +16,8 @@
unsigned char enabled;
char *device;
int check_interval;
+ int show_text;
+ int show_graph;
};
struct _Net
@@ -32,11 +34,14 @@
E_Container *con;
E_Menu *menu;
Net *net;
-
+ Evas_List *old_rx, *old_tx;
Config_Face *conf;
Evas_Object *net_obj;
Evas_Object *event_obj;
+ Evas_Object *chart_obj;
+ Evas_Object *rtxt_obj;
+ Evas_Object *ttxt_obj;
Ecore_Timer *monitor;
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/net/e_mod_main.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- e_mod_main.c 22 Feb 2006 12:22:48 -0000 1.10
+++ e_mod_main.c 1 Mar 2006 11:10:35 -0000 1.11
@@ -17,6 +17,8 @@
static void _net_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item
*mi);
static void _net_face_cb_menu_configure(void *data, E_Menu *mn,
E_Menu_Item *mi);
static int _net_face_update_values(void *data);
+static void _net_face_graph_values(Net_Face *nf, int tx_val, int rx_val);
+static void _net_face_graph_clear(Net_Face *nf);
static int net_count;
@@ -143,6 +145,8 @@
E_CONFIG_VAL(D, T, enabled, UCHAR);
E_CONFIG_VAL(D, T, device, STR);
E_CONFIG_VAL(D, T, check_interval, INT);
+ E_CONFIG_VAL(D, T, show_text, INT);
+ E_CONFIG_VAL(D, T, show_graph, INT);
conf_edd = E_CONFIG_DD_NEW("Net_Config", Config);
#undef T
@@ -179,6 +183,8 @@
nf->conf->enabled = 1;
nf->conf->device = (char *)evas_stringshare_add("eth0");
nf->conf->check_interval = 30;
+ nf->conf->show_text = 1;
+ nf->conf->show_graph = 1;
n->conf->faces = evas_list_append(n->conf->faces,
nf->conf);
}
else
@@ -187,6 +193,8 @@
fl = fl->next;
}
E_CONFIG_LIMIT(nf->conf->check_interval, 0, 60);
+ E_CONFIG_LIMIT(nf->conf->show_text, 0, 1);
+ E_CONFIG_LIMIT(nf->conf->show_graph, 0, 1);
nf->monitor =
ecore_timer_add((double)nf->conf->check_interval, _net_face_update_values, nf);
@@ -262,9 +270,40 @@
}
evas_object_show(o);
+ o = edje_object_add(nf->evas);
+ nf->chart_obj = o;
+ evas_object_layer_set(o, 1);
+ evas_object_repeat_events_set(o, 1);
+ evas_object_color_set(o, 255, 255, 255, 255);
+ evas_object_show(o);
+
+ o = edje_object_add(nf->evas);
+ nf->rtxt_obj = o;
+ if (!e_theme_edje_object_set(o, "base/theme/modules/net",
"modules/net/rx_text"))
+ {
+ snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/net.edj");
+ edje_object_file_set(o, buf, "modules/net/rx_text");
+ }
+ evas_object_layer_set(o, 2);
+ evas_object_repeat_events_set(o, 1);
+ evas_object_color_set(o, 255, 255, 255, 255);
+ evas_object_show(o);
+
+ o = edje_object_add(nf->evas);
+ nf->ttxt_obj = o;
+ if (!e_theme_edje_object_set(o, "base/theme/modules/net",
"modules/net/tx_text"))
+ {
+ snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/net.edj");
+ edje_object_file_set(o, buf, "modules/net/tx_text");
+ }
+ evas_object_layer_set(o, 2);
+ evas_object_repeat_events_set(o, 1);
+ evas_object_color_set(o, 255, 255, 255, 255);
+ evas_object_show(o);
+
o = evas_object_rectangle_add(nf->evas);
nf->event_obj = o;
- evas_object_layer_set(o, 2);
+ evas_object_layer_set(o, 3);
evas_object_repeat_events_set(o, 1);
evas_object_color_set(o, 0, 0, 0, 0);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_net_face_cb_mouse_down, nf);
@@ -278,11 +317,11 @@
E_GADMAN_POLICY_HSIZE |
E_GADMAN_POLICY_VMOVE |
E_GADMAN_POLICY_VSIZE);
- e_gadman_client_min_size_set(nf->gmc, 4, 4);
+ e_gadman_client_min_size_set(nf->gmc, 40, 40);
e_gadman_client_max_size_set(nf->gmc, 128, 128);
e_gadman_client_auto_size_set(nf->gmc, 40, 40);
e_gadman_client_align_set(nf->gmc, 1.0, 1.0);
- //e_gadman_client_aspect_set(nf->gmc, 1.0, 1.0);
+ e_gadman_client_aspect_set(nf->gmc, 1.0, 1.0);
e_gadman_client_resize(nf->gmc, 40, 40);
e_gadman_client_change_func_set(nf->gmc, _net_face_cb_gmc_change, nf);
e_gadman_client_load(nf->gmc);
@@ -318,6 +357,9 @@
e_config_save_queue();
evas_object_show(nf->net_obj);
evas_object_show(nf->event_obj);
+ evas_object_show(nf->chart_obj);
+ evas_object_show(nf->rtxt_obj);
+ evas_object_show(nf->ttxt_obj);
}
static void
@@ -327,6 +369,9 @@
e_config_save_queue();
evas_object_hide(nf->event_obj);
evas_object_hide(nf->net_obj);
+ evas_object_hide(nf->chart_obj);
+ evas_object_hide(nf->rtxt_obj);
+ evas_object_hide(nf->ttxt_obj);
}
static void
@@ -343,6 +388,15 @@
evas_object_del(nf->event_obj);
if (nf->net_obj)
evas_object_del(nf->net_obj);
+ if (nf->chart_obj)
+ evas_object_del(nf->chart_obj);
+ if (nf->rtxt_obj)
+ evas_object_del(nf->rtxt_obj);
+ if (nf->ttxt_obj)
+ evas_object_del(nf->ttxt_obj);
+ if (nf->old_rx)
+ _net_face_graph_clear(nf);
+
if (nf->gmc)
{
e_gadman_client_save(nf->gmc);
@@ -369,12 +423,22 @@
e_gadman_client_geometry_get(nf->gmc, &x, &y, &w, &h);
evas_object_move(nf->net_obj, x, y);
evas_object_move(nf->event_obj, x, y);
+ evas_object_move(nf->chart_obj, x, y);
+ evas_object_move(nf->rtxt_obj, x, y);
+ evas_object_move(nf->ttxt_obj, x, y);
evas_object_resize(nf->net_obj, w, h);
evas_object_resize(nf->event_obj, w, h);
+ evas_object_resize(nf->chart_obj, w, h);
+ evas_object_resize(nf->rtxt_obj, w, h);
+ evas_object_resize(nf->ttxt_obj, w, h);
+ _net_face_graph_clear(nf);
break;
case E_GADMAN_CHANGE_RAISE:
evas_object_raise(nf->net_obj);
evas_object_raise(nf->event_obj);
+ evas_object_raise(nf->chart_obj);
+ evas_object_raise(nf->rtxt_obj);
+ evas_object_raise(nf->ttxt_obj);
break;
default:
break;
@@ -490,9 +554,98 @@
/* Update the modules text */
char in_str[100];
char out_str[100];
- snprintf(in_str, sizeof(in_str), "Rx: %d B", in_use);
- snprintf(out_str, sizeof(out_str), "Tx: %d B", out_use);
- edje_object_part_text_set(nf->net_obj, "out-text", out_str);
- edje_object_part_text_set(nf->net_obj, "in-text", in_str);
+
+ if (nf->conf->show_text)
+ {
+ snprintf(in_str, sizeof(in_str), "Rx: %d B", in_use);
+ snprintf(out_str, sizeof(out_str), "Tx: %d B", out_use);
+ edje_object_part_text_set(nf->ttxt_obj, "tx-text", out_str);
+ edje_object_part_text_set(nf->rtxt_obj, "rx-text", in_str);
+ }
+ else
+ {
+ edje_object_part_text_set(nf->ttxt_obj, "tx-text", "");
+ edje_object_part_text_set(nf->rtxt_obj, "rx-text", "");
+ }
+
+ if (nf->conf->show_graph)
+ _net_face_graph_values(nf, out_use, in_use);
+ else
+ _net_face_graph_clear(nf);
+
return 1;
}
+
+static void
+_net_face_graph_values(Net_Face *nf, int tx_val, int rx_val)
+{
+ int x, y, w, h;
+ Evas_Object *o;
+ Evas_Object *last = NULL;
+ Evas_List *l;
+ int i, j = 0;
+
+ evas_object_geometry_get(nf->chart_obj, &x, &y, &w, &h);
+
+ if (rx_val > 100)
+ rx_val = 100;
+
+ rx_val = (int)(((double)rx_val) * (((double)h) / ((double)100)));
+
+ o = evas_object_line_add(nf->evas);
+ edje_object_part_swallow(nf->chart_obj, "lines", o);
+ evas_object_layer_set(o, 1);
+ if (rx_val == 0)
+ evas_object_hide(o);
+ else
+ {
+ evas_object_line_xy_set(o, (x + w), (y + h), (x + w), ((y + h) -
rx_val));
+ evas_object_color_set(o, 255, 0, 0, 100);
+ evas_object_pass_events_set(o, 1);
+ evas_object_show(o);
+ }
+
+ nf->old_rx = evas_list_prepend(nf->old_rx, o);
+ l = nf->old_rx;
+ for (i = (x + w); l && (j -2) < w; l = l->next, j++)
+ {
+ Evas_Coord oy;
+ Evas_Object *lo;
+
+ lo = (Evas_Object *)evas_list_data(l);
+ evas_object_geometry_get(lo, NULL, &oy, NULL, NULL);
+ evas_object_move(lo, i--, oy);
+ last = lo;
+ }
+
+ if ((j - 2) >= w)
+ {
+ nf->old_rx = evas_list_remove(nf->old_rx, last);
+ evas_object_del(last);
+ }
+}
+
+static void
+_net_face_graph_clear(Net_Face *nf)
+{
+ Evas_List *l;
+
+ for (l = nf->old_rx; l; l = l->next)
+ {
+ Evas_Object *o;
+ o = evas_list_data(l);
+ evas_object_del(o);
+ }
+ evas_list_free(nf->old_rx);
+ nf->old_rx = NULL;
+
+ for (l = nf->old_tx; l; l = l->next)
+ {
+ Evas_Object *o;
+ o = evas_list_data(l);
+ evas_object_del(o);
+ }
+ evas_list_free(nf->old_tx);
+ nf->old_tx = NULL;
+}
+
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/net/e_mod_config.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- e_mod_config.c 21 Feb 2006 23:56:27 -0000 1.6
+++ e_mod_config.c 1 Mar 2006 11:10:35 -0000 1.7
@@ -7,6 +7,8 @@
{
char *device;
int check_interval;
+ int show_text;
+ int show_graph;
Ecore_List *devs;
int dev_num;
@@ -45,6 +47,8 @@
int i;
cfdata->check_interval = nf->conf->check_interval;
+ cfdata->show_text = nf->conf->show_text;
+ cfdata->show_graph = nf->conf->show_graph;
if (nf->conf->device != NULL)
cfdata->device = strdup(nf->conf->device);
@@ -107,6 +111,13 @@
int i;
o = e_widget_list_add(evas, 0, 0);
+ of = e_widget_framelist_add(evas, _("General Settings"), 0);
+ ob = e_widget_check_add(evas, _("Show Text"), (&(cfdata->show_text)));
+ e_widget_framelist_object_append(of, ob);
+ ob = e_widget_check_add(evas, _("Show Graph"), (&(cfdata->show_graph)));
+ e_widget_framelist_object_append(of, ob);
+ e_widget_list_object_append(o, of, 1, 1, 0.5);
+
of = e_widget_framelist_add(evas, _("Device Settings"), 0);
ot = e_widget_table_add(evas, 0);
rg = e_widget_radio_group_new(&(cfdata->dev_num));
@@ -141,6 +152,8 @@
if (tmp != NULL)
nf->conf->device = (char *)evas_stringshare_add(strdup(tmp));
nf->conf->check_interval = cfdata->check_interval;
+ nf->conf->show_text = cfdata->show_text;
+ nf->conf->show_graph = cfdata->show_graph;
e_config_save_queue ();
if (nf->monitor)
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs