Wed Apr 5 13:48:36 2006 Michael Jennings (mej)
Indent! ---------------------------------------------------------------------- SVN revision: 21859
This commit is contained in:
parent
e7f0a25157
commit
c478ee9a73
|
@ -15,12 +15,12 @@ struct _E_Config_Dialog_Data
|
|||
};
|
||||
|
||||
/* Protos */
|
||||
static void *_create_data (E_Config_Dialog *cfd);
|
||||
static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_data (Net_Face *nf, E_Config_Dialog_Data *cfdata);
|
||||
static void _net_config_get_devices (Ecore_List *devs);
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_data(Net_Face *nf, E_Config_Dialog_Data *cfdata);
|
||||
static void _net_config_get_devices(Ecore_List *devs);
|
||||
|
||||
/* Config Calls */
|
||||
void
|
||||
|
@ -51,29 +51,29 @@ _fill_data(Net_Face *nf, E_Config_Dialog_Data *cfdata)
|
|||
cfdata->show_graph = nf->conf->show_graph;
|
||||
|
||||
if (nf->conf->device != NULL)
|
||||
cfdata->device = strdup(nf->conf->device);
|
||||
cfdata->device = strdup(nf->conf->device);
|
||||
else
|
||||
cfdata->device = NULL;
|
||||
cfdata->device = NULL;
|
||||
|
||||
if (!cfdata->device)
|
||||
return;
|
||||
return;
|
||||
|
||||
cfdata->devs = ecore_list_new();
|
||||
_net_config_get_devices(cfdata->devs);
|
||||
|
||||
if (!cfdata->devs)
|
||||
return;
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
ecore_list_goto_first(cfdata->devs);
|
||||
while ((tmp = ecore_list_next(cfdata->devs)) != NULL)
|
||||
{
|
||||
if (!strcmp(cfdata->device, tmp))
|
||||
{
|
||||
cfdata->dev_num = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
if (!strcmp(cfdata->device, tmp))
|
||||
{
|
||||
cfdata->dev_num = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ _create_data(E_Config_Dialog *cfd)
|
|||
|
||||
nf = cfd->data;
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
|
||||
_fill_data(nf, cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
nf->net->cfd = NULL;
|
||||
E_FREE(cfdata->device);
|
||||
if (cfdata->devs)
|
||||
ecore_list_destroy(cfdata->devs);
|
||||
ecore_list_destroy(cfdata->devs);
|
||||
free(cfdata);
|
||||
}
|
||||
|
||||
|
@ -125,9 +126,9 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
ecore_list_goto_first(cfdata->devs);
|
||||
while ((tmp = ecore_list_next(cfdata->devs)) != NULL)
|
||||
{
|
||||
ob = e_widget_radio_add(evas, tmp, i, rg);
|
||||
e_widget_table_object_append (ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
|
||||
i++;
|
||||
ob = e_widget_radio_add(evas, tmp, i, rg);
|
||||
e_widget_table_object_append(ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
ob = e_widget_label_add(evas, D_("Check Interval:"));
|
||||
|
@ -151,20 +152,20 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
tmp = ecore_list_goto_index(cfdata->devs, cfdata->dev_num);
|
||||
if (tmp != NULL)
|
||||
{
|
||||
if (strcmp(tmp, nf->conf->device))
|
||||
{
|
||||
_net_face_graph_clear(nf);
|
||||
nf->conf->device = (char *)evas_stringshare_add(strdup(tmp));
|
||||
}
|
||||
if (strcmp(tmp, nf->conf->device))
|
||||
{
|
||||
_net_face_graph_clear(nf);
|
||||
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 ();
|
||||
e_config_save_queue();
|
||||
|
||||
if (nf->monitor)
|
||||
ecore_timer_interval_set(nf->monitor, (double)cfdata->check_interval);
|
||||
ecore_timer_interval_set(nf->monitor, (double)cfdata->check_interval);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -179,22 +180,22 @@ _net_config_get_devices(Ecore_List *devs)
|
|||
|
||||
stat = fopen("/proc/net/dev", "r");
|
||||
if (!stat)
|
||||
return;
|
||||
return;
|
||||
|
||||
while (fgets(buf, 256, stat))
|
||||
{
|
||||
int i = 0;
|
||||
for (; buf[i] != 0; i++)
|
||||
{
|
||||
if (buf[i] == ':')
|
||||
buf[i] = ' ';
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
for (; buf[i] != 0; i++)
|
||||
{
|
||||
if (buf[i] == ':')
|
||||
buf[i] = ' ';
|
||||
}
|
||||
if (sscanf(buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
|
||||
"%lu %lu %lu %lu\n", dev, &dummy, &dummy, &dummy,
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 16)
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 16)
|
||||
continue;
|
||||
ecore_list_append(devs, strdup(dev));
|
||||
ecore_list_append(devs, strdup(dev));
|
||||
}
|
||||
fclose(stat);
|
||||
}
|
||||
|
|
477
e_mod_main.c
477
e_mod_main.c
|
@ -3,31 +3,30 @@
|
|||
#include "e_mod_config.h"
|
||||
#include "config.h"
|
||||
|
||||
static Net *_net_init(E_Module *m);
|
||||
static void _net_shutdown(Net *n);
|
||||
static void _net_config_menu_new(Net *n);
|
||||
static Net *_net_init(E_Module *m);
|
||||
static void _net_shutdown(Net *n);
|
||||
static void _net_config_menu_new(Net *n);
|
||||
|
||||
static Net_Face *_net_face_init(Net *n, E_Container *con);
|
||||
static void _net_face_menu_new(Net_Face *nf);
|
||||
static void _net_face_enable(Net_Face *nf);
|
||||
static void _net_face_disable(Net_Face *nf);
|
||||
static void _net_face_free(Net_Face *nf);
|
||||
static void _net_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
|
||||
static void _net_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
||||
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_menu_new(Net_Face *nf);
|
||||
static void _net_face_enable(Net_Face *nf);
|
||||
static void _net_face_disable(Net_Face *nf);
|
||||
static void _net_face_free(Net_Face *nf);
|
||||
static void _net_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
|
||||
static void _net_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
||||
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 int net_count;
|
||||
|
||||
static E_Config_DD *conf_edd;
|
||||
static E_Config_DD *conf_face_edd;
|
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
EAPI E_Module_Api e_modapi = {
|
||||
E_MODULE_API_VERSION,
|
||||
"Net"
|
||||
"Net"
|
||||
};
|
||||
|
||||
EAPI void *
|
||||
|
@ -41,7 +40,7 @@ e_modapi_init(E_Module *m)
|
|||
|
||||
n = _net_init(m);
|
||||
if (!n)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
m->config_menu = n->config_menu;
|
||||
return n;
|
||||
|
@ -54,18 +53,18 @@ e_modapi_shutdown(E_Module *m)
|
|||
|
||||
n = m->data;
|
||||
if (!n)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
if (m->config_menu)
|
||||
{
|
||||
e_menu_deactivate(m->config_menu);
|
||||
e_object_del(E_OBJECT(m->config_menu));
|
||||
m->config_menu = NULL;
|
||||
e_menu_deactivate(m->config_menu);
|
||||
e_object_del(E_OBJECT(m->config_menu));
|
||||
m->config_menu = NULL;
|
||||
}
|
||||
if (n->cfd)
|
||||
{
|
||||
e_object_del(E_OBJECT(n->cfd));
|
||||
n->cfd = NULL;
|
||||
e_object_del(E_OBJECT(n->cfd));
|
||||
n->cfd = NULL;
|
||||
}
|
||||
_net_shutdown(n);
|
||||
return 1;
|
||||
|
@ -78,7 +77,7 @@ e_modapi_save(E_Module *m)
|
|||
|
||||
n = m->data;
|
||||
if (!n)
|
||||
return 0;
|
||||
return 0;
|
||||
e_config_domain_save("module.net", conf_edd, n->conf);
|
||||
return 1;
|
||||
}
|
||||
|
@ -86,15 +85,14 @@ e_modapi_save(E_Module *m)
|
|||
EAPI int
|
||||
e_modapi_info(E_Module *m)
|
||||
{
|
||||
m->icon_file = strdup(PACKAGE_DATA_DIR"/module_icon.png");
|
||||
m->icon_file = strdup(PACKAGE_DATA_DIR "/module_icon.png");
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_about(E_Module *m)
|
||||
{
|
||||
e_module_dialog_show(D_("Enlightenment Network Monitor Module"),
|
||||
D_("This module is used to monitor a network device."));
|
||||
e_module_dialog_show(D_("Enlightenment Network Monitor Module"), D_("This module is used to monitor a network device."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -107,24 +105,24 @@ e_modapi_config(E_Module *m)
|
|||
|
||||
n = m->data;
|
||||
if (!n)
|
||||
return 0;
|
||||
return 0;
|
||||
if (!n->faces)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
for (l = n->faces; l; l = l->next)
|
||||
{
|
||||
Net_Face *nf;
|
||||
Net_Face *nf;
|
||||
|
||||
nf = l->data;
|
||||
if (!nf)
|
||||
continue;
|
||||
nf = l->data;
|
||||
if (!nf)
|
||||
continue;
|
||||
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
if (nf->con == con)
|
||||
{
|
||||
_configure_net_module(nf);
|
||||
break;
|
||||
}
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
if (nf->con == con)
|
||||
{
|
||||
_configure_net_module(nf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -137,14 +135,15 @@ _net_init(E_Module *m)
|
|||
Evas_List *mans, *l, *l2, *fl;
|
||||
|
||||
n = E_NEW(Net, 1);
|
||||
|
||||
if (!n)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
conf_face_edd = E_CONFIG_DD_NEW("Net_Config_Face", Config_Face);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config_Face
|
||||
#define D conf_face_edd
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config_Face
|
||||
#define D conf_face_edd
|
||||
E_CONFIG_VAL(D, T, enabled, UCHAR);
|
||||
E_CONFIG_VAL(D, T, device, STR);
|
||||
E_CONFIG_VAL(D, T, check_interval, INT);
|
||||
|
@ -152,15 +151,16 @@ _net_init(E_Module *m)
|
|||
E_CONFIG_VAL(D, T, show_graph, INT);
|
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("Net_Config", Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config
|
||||
#define D conf_edd
|
||||
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_LIST(D, T, faces, conf_face_edd);
|
||||
|
||||
n->conf = e_config_domain_load("module.net", conf_edd);
|
||||
if (!n->conf)
|
||||
n->conf = E_NEW(Config, 1);
|
||||
n->conf = E_NEW(Config, 1);
|
||||
|
||||
_net_config_menu_new(n);
|
||||
|
||||
|
@ -168,53 +168,54 @@ _net_init(E_Module *m)
|
|||
fl = n->conf->faces;
|
||||
for (l = mans; l; l = l->next)
|
||||
{
|
||||
E_Manager *man;
|
||||
E_Manager *man;
|
||||
|
||||
man = l->data;
|
||||
for (l2 = man->containers; l2; l2 = l2->next)
|
||||
{
|
||||
E_Container *con;
|
||||
Net_Face *nf;
|
||||
man = l->data;
|
||||
for (l2 = man->containers; l2; l2 = l2->next)
|
||||
{
|
||||
E_Container *con;
|
||||
Net_Face *nf;
|
||||
|
||||
con = l2->data;
|
||||
nf = _net_face_init(n, con);
|
||||
if (nf)
|
||||
{
|
||||
if (!fl)
|
||||
{
|
||||
nf->conf = E_NEW(Config_Face, 1);
|
||||
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
|
||||
{
|
||||
nf->conf = fl->data;
|
||||
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);
|
||||
con = l2->data;
|
||||
nf = _net_face_init(n, con);
|
||||
if (nf)
|
||||
{
|
||||
if (!fl)
|
||||
{
|
||||
nf->conf = E_NEW(Config_Face, 1);
|
||||
|
||||
nf->monitor = ecore_timer_add((double)nf->conf->check_interval, _net_face_update_values, nf);
|
||||
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
|
||||
{
|
||||
nf->conf = fl->data;
|
||||
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);
|
||||
|
||||
_net_face_menu_new(nf);
|
||||
nf->monitor = ecore_timer_add((double)nf->conf->check_interval, _net_face_update_values, nf);
|
||||
|
||||
mi = e_menu_item_new(n->config_menu);
|
||||
e_menu_item_label_set(mi, _("Configuration"));
|
||||
e_menu_item_callback_set(mi, _net_face_cb_menu_configure, nf);
|
||||
_net_face_menu_new(nf);
|
||||
|
||||
mi = e_menu_item_new(n->config_menu);
|
||||
e_menu_item_label_set(mi, con->name);
|
||||
e_menu_item_submenu_set(mi, nf->menu);
|
||||
mi = e_menu_item_new(n->config_menu);
|
||||
e_menu_item_label_set(mi, _("Configuration"));
|
||||
e_menu_item_callback_set(mi, _net_face_cb_menu_configure, nf);
|
||||
|
||||
if (!nf->conf->enabled)
|
||||
_net_face_disable(nf);
|
||||
}
|
||||
}
|
||||
mi = e_menu_item_new(n->config_menu);
|
||||
e_menu_item_label_set(mi, con->name);
|
||||
e_menu_item_submenu_set(mi, nf->menu);
|
||||
|
||||
if (!nf->conf->enabled)
|
||||
_net_face_disable(nf);
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
@ -226,7 +227,7 @@ _net_shutdown(Net *n)
|
|||
E_CONFIG_DD_FREE(conf_face_edd);
|
||||
|
||||
while (n->faces)
|
||||
_net_face_free(n->faces->data);
|
||||
_net_face_free(n->faces->data);
|
||||
|
||||
e_object_del(E_OBJECT(n->config_menu));
|
||||
evas_list_free(n->conf->faces);
|
||||
|
@ -252,8 +253,9 @@ _net_face_init(Net *n, E_Container *con)
|
|||
char buf[4096];
|
||||
|
||||
nf = E_NEW(Net_Face, 1);
|
||||
|
||||
if (!nf)
|
||||
return NULL;
|
||||
return NULL;
|
||||
nf->net = n;
|
||||
n->faces = evas_list_append(n->faces, nf);
|
||||
|
||||
|
@ -268,8 +270,8 @@ _net_face_init(Net *n, E_Container *con)
|
|||
|
||||
if (!e_theme_edje_object_set(o, "base/theme/modules/net", "modules/net/main"))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/net.edj");
|
||||
edje_object_file_set(o, buf, "modules/net/main");
|
||||
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR "/net.edj");
|
||||
edje_object_file_set(o, buf, "modules/net/main");
|
||||
}
|
||||
evas_object_show(o);
|
||||
|
||||
|
@ -284,8 +286,8 @@ _net_face_init(Net *n, E_Container *con)
|
|||
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");
|
||||
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);
|
||||
|
@ -296,8 +298,8 @@ _net_face_init(Net *n, E_Container *con)
|
|||
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");
|
||||
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);
|
||||
|
@ -315,11 +317,8 @@ _net_face_init(Net *n, E_Container *con)
|
|||
nf->gmc = e_gadman_client_new(nf->con->gadman);
|
||||
e_gadman_client_domain_set(nf->gmc, "module.net", net_count++);
|
||||
e_gadman_client_policy_set(nf->gmc,
|
||||
E_GADMAN_POLICY_ANYWHERE |
|
||||
E_GADMAN_POLICY_HMOVE |
|
||||
E_GADMAN_POLICY_HSIZE |
|
||||
E_GADMAN_POLICY_VMOVE |
|
||||
E_GADMAN_POLICY_VSIZE);
|
||||
E_GADMAN_POLICY_ANYWHERE |
|
||||
E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_HSIZE | E_GADMAN_POLICY_VMOVE | E_GADMAN_POLICY_VSIZE);
|
||||
//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);
|
||||
|
@ -383,26 +382,26 @@ _net_face_free(Net_Face *nf)
|
|||
e_object_del(E_OBJECT(nf->menu));
|
||||
|
||||
if (nf->monitor)
|
||||
ecore_timer_del(nf->monitor);
|
||||
ecore_timer_del(nf->monitor);
|
||||
if (nf->menu)
|
||||
e_object_del(E_OBJECT(nf->menu));
|
||||
e_object_del(E_OBJECT(nf->menu));
|
||||
if (nf->event_obj)
|
||||
evas_object_del(nf->event_obj);
|
||||
evas_object_del(nf->event_obj);
|
||||
if (nf->net_obj)
|
||||
evas_object_del(nf->net_obj);
|
||||
evas_object_del(nf->net_obj);
|
||||
if (nf->chart_obj)
|
||||
evas_object_del(nf->chart_obj);
|
||||
evas_object_del(nf->chart_obj);
|
||||
if (nf->rtxt_obj)
|
||||
evas_object_del(nf->rtxt_obj);
|
||||
evas_object_del(nf->rtxt_obj);
|
||||
if (nf->ttxt_obj)
|
||||
evas_object_del(nf->ttxt_obj);
|
||||
evas_object_del(nf->ttxt_obj);
|
||||
if (nf->old_rx || nf->old_tx)
|
||||
_net_face_graph_clear(nf);
|
||||
_net_face_graph_clear(nf);
|
||||
|
||||
if (nf->gmc)
|
||||
{
|
||||
e_gadman_client_save(nf->gmc);
|
||||
e_object_del(E_OBJECT(nf->gmc));
|
||||
e_gadman_client_save(nf->gmc);
|
||||
e_object_del(E_OBJECT(nf->gmc));
|
||||
}
|
||||
|
||||
nf->net->faces = evas_list_remove(nf->net->faces, nf);
|
||||
|
@ -421,29 +420,29 @@ _net_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change
|
|||
nf = data;
|
||||
switch (change)
|
||||
{
|
||||
case E_GADMAN_CHANGE_MOVE_RESIZE:
|
||||
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;
|
||||
case E_GADMAN_CHANGE_MOVE_RESIZE:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,10 +456,9 @@ _net_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_in
|
|||
nf = data;
|
||||
if (ev->button == 3)
|
||||
{
|
||||
e_menu_activate_mouse(nf->menu, e_zone_current_get(nf->con),
|
||||
ev->output.x, ev->output.y, 1, 1,
|
||||
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
||||
e_util_container_fake_mouse_up_all_later(nf->con);
|
||||
e_menu_activate_mouse(nf->menu, e_zone_current_get(nf->con),
|
||||
ev->output.x, ev->output.y, 1, 1, E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
||||
e_util_container_fake_mouse_up_all_later(nf->con);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,7 +478,7 @@ _net_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
|
|||
|
||||
nf = data;
|
||||
if (!nf)
|
||||
return;
|
||||
return;
|
||||
|
||||
_configure_net_module(nf);
|
||||
}
|
||||
|
@ -510,50 +508,50 @@ _net_face_update_values(void *data)
|
|||
|
||||
stat = fopen("/proc/net/dev", "r");
|
||||
if (!stat)
|
||||
return 1;
|
||||
return 1;
|
||||
|
||||
found = 0;
|
||||
while (fgets(buf, 256, stat))
|
||||
{
|
||||
int i = 0;
|
||||
for (; buf[i] != 0; i++)
|
||||
{
|
||||
if (buf[i] == ':')
|
||||
buf[i] = ' ';
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
for (; buf[i] != 0; i++)
|
||||
{
|
||||
if (buf[i] == ':')
|
||||
buf[i] = ' ';
|
||||
}
|
||||
if (sscanf(buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
|
||||
"%lu %lu %lu %lu\n", dev, &in, &dummy, &dummy,
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &out, &dummy,
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &out, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
|
||||
continue;
|
||||
if (!strcmp(dev, strdup(nf->conf->device)))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
if (!strcmp(dev, strdup(nf->conf->device)))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(stat);
|
||||
|
||||
if (!found)
|
||||
return 1;
|
||||
return 1;
|
||||
|
||||
if (old_in && old_out)
|
||||
{
|
||||
bytes_in = in - old_in;
|
||||
bytes_out = out - old_out;
|
||||
bytes_in = in - old_in;
|
||||
bytes_out = out - old_out;
|
||||
|
||||
if (bytes_in < 0)
|
||||
bytes_in = 0;
|
||||
if (bytes_out < 0)
|
||||
bytes_out = 0;
|
||||
if (bytes_in < 0)
|
||||
bytes_in = 0;
|
||||
if (bytes_out < 0)
|
||||
bytes_out = 0;
|
||||
|
||||
in_use = (int)((bytes_in * 100L) / max_in);
|
||||
out_use = (int)((bytes_out * 100L) / max_out);
|
||||
in_use = (int)((bytes_in * 100L) / max_in);
|
||||
out_use = (int)((bytes_out * 100L) / max_out);
|
||||
}
|
||||
else
|
||||
{
|
||||
in_use = 0;
|
||||
out_use = 0;
|
||||
in_use = 0;
|
||||
out_use = 0;
|
||||
}
|
||||
|
||||
old_in = in;
|
||||
|
@ -565,44 +563,44 @@ _net_face_update_values(void *data)
|
|||
|
||||
if (!nf->conf->show_text)
|
||||
{
|
||||
edje_object_part_text_set(nf->ttxt_obj, "tx-text", "");
|
||||
edje_object_part_text_set(nf->rtxt_obj, "rx-text", "");
|
||||
edje_object_part_text_set(nf->ttxt_obj, "tx-text", "");
|
||||
edje_object_part_text_set(nf->rtxt_obj, "rx-text", "");
|
||||
}
|
||||
else if ((bytes_in < 0) || (bytes_out < 0))
|
||||
{
|
||||
edje_object_part_text_set(nf->ttxt_obj, "tx-text", "Tx: 0 B");
|
||||
edje_object_part_text_set(nf->rtxt_obj, "rx-text", "Rx: 0 B");
|
||||
edje_object_part_text_set(nf->ttxt_obj, "tx-text", "Tx: 0 B");
|
||||
edje_object_part_text_set(nf->rtxt_obj, "rx-text", "Rx: 0 B");
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (bytes_in > 1048576)
|
||||
{
|
||||
bytes_in = bytes_in / 1048576;
|
||||
snprintf(in_str, sizeof(in_str), "Rx: %d Mb", bytes_in);
|
||||
}
|
||||
else if (bytes_in > 1024 && bytes_in < 1048576)
|
||||
{
|
||||
bytes_in = bytes_in / 1024;
|
||||
snprintf(in_str, sizeof(in_str), "Rx: %d Kb", bytes_in);
|
||||
}
|
||||
else
|
||||
snprintf(in_str, sizeof(in_str), "Rx: %d B", bytes_in);
|
||||
if (bytes_in > 1048576)
|
||||
{
|
||||
bytes_in = bytes_in / 1048576;
|
||||
snprintf(in_str, sizeof(in_str), "Rx: %d Mb", bytes_in);
|
||||
}
|
||||
else if (bytes_in > 1024 && bytes_in < 1048576)
|
||||
{
|
||||
bytes_in = bytes_in / 1024;
|
||||
snprintf(in_str, sizeof(in_str), "Rx: %d Kb", bytes_in);
|
||||
}
|
||||
else
|
||||
snprintf(in_str, sizeof(in_str), "Rx: %d B", bytes_in);
|
||||
|
||||
if (bytes_out > 1048576)
|
||||
{
|
||||
bytes_out = bytes_out / 1048576;
|
||||
snprintf(out_str, sizeof(out_str), "Tx: %d Mb", bytes_out);
|
||||
}
|
||||
else if (bytes_out > 1024 && bytes_out < 1048576)
|
||||
{
|
||||
bytes_out = bytes_out / 1024;
|
||||
snprintf(out_str, sizeof(out_str), "Tx: %d Kb", bytes_out);
|
||||
}
|
||||
else
|
||||
snprintf(out_str, sizeof(out_str), "Tx: %d B", bytes_out);
|
||||
if (bytes_out > 1048576)
|
||||
{
|
||||
bytes_out = bytes_out / 1048576;
|
||||
snprintf(out_str, sizeof(out_str), "Tx: %d Mb", bytes_out);
|
||||
}
|
||||
else if (bytes_out > 1024 && bytes_out < 1048576)
|
||||
{
|
||||
bytes_out = bytes_out / 1024;
|
||||
snprintf(out_str, sizeof(out_str), "Tx: %d Kb", bytes_out);
|
||||
}
|
||||
else
|
||||
snprintf(out_str, sizeof(out_str), "Tx: %d B", bytes_out);
|
||||
|
||||
edje_object_part_text_set(nf->ttxt_obj, "tx-text", out_str);
|
||||
edje_object_part_text_set(nf->rtxt_obj, "rx-text", in_str);
|
||||
edje_object_part_text_set(nf->ttxt_obj, "tx-text", out_str);
|
||||
edje_object_part_text_set(nf->rtxt_obj, "rx-text", in_str);
|
||||
}
|
||||
|
||||
msg.val = in_use;
|
||||
|
@ -612,9 +610,9 @@ _net_face_update_values(void *data)
|
|||
edje_object_message_send(nf->net_obj, EDJE_MESSAGE_FLOAT, 2, &msg);
|
||||
|
||||
if (nf->conf->show_graph)
|
||||
_net_face_graph_values(nf, out_use, in_use);
|
||||
_net_face_graph_values(nf, out_use, in_use);
|
||||
else
|
||||
_net_face_graph_clear(nf);
|
||||
_net_face_graph_clear(nf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -633,9 +631,9 @@ _net_face_graph_values(Net_Face *nf, int tx_val, int rx_val)
|
|||
evas_object_geometry_get(nf->chart_obj, &x, &y, &w, &h);
|
||||
|
||||
if (rx_val > 100)
|
||||
rx_val = 100;
|
||||
rx_val = 100;
|
||||
if (tx_val > 100)
|
||||
tx_val = 100;
|
||||
tx_val = 100;
|
||||
|
||||
rx_val = (int)(((double)rx_val) * (((double)h) / ((double)100)));
|
||||
tx_val = (int)(((double)tx_val) * (((double)h) / ((double)100)));
|
||||
|
@ -644,32 +642,32 @@ _net_face_graph_values(Net_Face *nf, int tx_val, int rx_val)
|
|||
edje_object_part_swallow(nf->chart_obj, "lines", o);
|
||||
evas_object_layer_set(o, 1);
|
||||
if (rx_val == 0)
|
||||
evas_object_hide(o);
|
||||
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);
|
||||
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++)
|
||||
for (i = (x + w); l && ((j - 2) < w); l = l->next, j++)
|
||||
{
|
||||
Evas_Coord oy;
|
||||
Evas_Object *lo;
|
||||
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;
|
||||
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);
|
||||
edje_object_part_unswallow(nf->chart_obj, last);
|
||||
evas_object_del(last);
|
||||
nf->old_rx = evas_list_remove(nf->old_rx, last);
|
||||
edje_object_part_unswallow(nf->chart_obj, last);
|
||||
evas_object_del(last);
|
||||
}
|
||||
|
||||
j = 0;
|
||||
|
@ -678,32 +676,32 @@ _net_face_graph_values(Net_Face *nf, int tx_val, int rx_val)
|
|||
edje_object_part_swallow(nf->chart_obj, "lines", o);
|
||||
evas_object_layer_set(o, 1);
|
||||
if (tx_val == 0)
|
||||
evas_object_hide(o);
|
||||
evas_object_hide(o);
|
||||
else
|
||||
{
|
||||
evas_object_line_xy_set(o, (x + w), y, (x + w), (y + tx_val));
|
||||
evas_object_color_set(o, 0, 255, 0, 100);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
evas_object_line_xy_set(o, (x + w), y, (x + w), (y + tx_val));
|
||||
evas_object_color_set(o, 0, 255, 0, 100);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
}
|
||||
|
||||
nf->old_tx = evas_list_prepend(nf->old_tx, o);
|
||||
l = nf->old_tx;
|
||||
for (i = (x + w); l && ((j -2) < w); l = l->next, j++)
|
||||
for (i = (x + w); l && ((j - 2) < w); l = l->next, j++)
|
||||
{
|
||||
Evas_Coord oy;
|
||||
Evas_Object *lo;
|
||||
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;
|
||||
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_tx = evas_list_remove(nf->old_tx, last);
|
||||
edje_object_part_unswallow(nf->chart_obj, last);
|
||||
evas_object_del(last);
|
||||
nf->old_tx = evas_list_remove(nf->old_tx, last);
|
||||
edje_object_part_unswallow(nf->chart_obj, last);
|
||||
evas_object_del(last);
|
||||
}
|
||||
|
||||
evas_event_thaw(nf->evas);
|
||||
|
@ -718,24 +716,25 @@ _net_face_graph_clear(Net_Face *nf)
|
|||
|
||||
for (l = nf->old_rx; l; l = l->next)
|
||||
{
|
||||
Evas_Object *o;
|
||||
o = evas_list_data(l);
|
||||
edje_object_part_unswallow(nf->chart_obj, o);
|
||||
evas_object_del(o);
|
||||
Evas_Object *o;
|
||||
|
||||
o = evas_list_data(l);
|
||||
edje_object_part_unswallow(nf->chart_obj, o);
|
||||
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);
|
||||
edje_object_part_unswallow(nf->chart_obj, o);
|
||||
evas_object_del(o);
|
||||
Evas_Object *o;
|
||||
|
||||
o = evas_list_data(l);
|
||||
edje_object_part_unswallow(nf->chart_obj, o);
|
||||
evas_object_del(o);
|
||||
}
|
||||
evas_list_free(nf->old_tx);
|
||||
nf->old_tx = NULL;
|
||||
|
||||
evas_event_thaw(nf->evas);
|
||||
}
|
||||
|
||||
|
|
14
e_mod_main.h
14
e_mod_main.h
|
@ -52,13 +52,13 @@ struct _Net_Face
|
|||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init (E_Module *m);
|
||||
EAPI int e_modapi_shutdown (E_Module *m);
|
||||
EAPI int e_modapi_save (E_Module *m);
|
||||
EAPI int e_modapi_info (E_Module *m);
|
||||
EAPI int e_modapi_about (E_Module *m);
|
||||
EAPI int e_modapi_config (E_Module *m);
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
EAPI int e_modapi_info(E_Module *m);
|
||||
EAPI int e_modapi_about(E_Module *m);
|
||||
EAPI int e_modapi_config(E_Module *m);
|
||||
|
||||
void _net_face_graph_clear(Net_Face *nf);
|
||||
void _net_face_graph_clear(Net_Face *nf);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue