Enlightenment CVS committal
Author : devilhorns
Project : e_modules
Module : net
Dir : e_modules/net
Modified Files:
e_mod_config.c e_mod_main.c
Log Message:
Indent
===================================================================
RCS file: /cvs/e/e_modules/net/e_mod_config.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- e_mod_config.c 10 Jul 2006 17:51:33 -0000 1.16
+++ e_mod_config.c 18 Jul 2006 00:00:34 -0000 1.17
@@ -4,203 +4,212 @@
struct _E_Config_Dialog_Data
{
- char *device;
- double poll_time;
- int always_text;
- double max;
- Ecore_List *devs;
- int dev_num;
+ char *device;
+ double poll_time;
+ int always_text;
+ double max;
+ Ecore_List *devs;
+ int dev_num;
};
/* 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(Config_Item *ci, 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 (Config_Item * ci, E_Config_Dialog_Data * cfdata);
+static void _net_config_get_devices (Ecore_List * devs);
/* Config Calls */
void
-_config_net_module(Config_Item *ci)
+_config_net_module (Config_Item * ci)
{
- E_Config_Dialog *cfd;
- E_Config_Dialog_View *v;
- E_Container *con;
- char buf[4096];
-
- v = E_NEW(E_Config_Dialog_View, 1);
-
- v->create_cfdata = _create_data;
- v->free_cfdata = _free_data;
- v->basic.apply_cfdata = _basic_apply_data;
- v->basic.create_widgets = _basic_create_widgets;
-
- snprintf(buf, sizeof(buf), "%s/module.eap",
e_module_dir_get(net_config->module));
- con = e_container_current_get(e_manager_current_get());
- cfd = e_config_dialog_new(con, D_("Net Configuration"), buf, 0, v, ci);
- net_config->config_dialog = cfd;
+ E_Config_Dialog *cfd;
+ E_Config_Dialog_View *v;
+ E_Container *con;
+ char buf[4096];
+
+ v = E_NEW (E_Config_Dialog_View, 1);
+
+ v->create_cfdata = _create_data;
+ v->free_cfdata = _free_data;
+ v->basic.apply_cfdata = _basic_apply_data;
+ v->basic.create_widgets = _basic_create_widgets;
+
+ snprintf (buf, sizeof (buf), "%s/module.eap",
+ e_module_dir_get (net_config->module));
+ con = e_container_current_get (e_manager_current_get ());
+ cfd = e_config_dialog_new (con, D_ ("Net Configuration"), buf, 0, v, ci);
+ net_config->config_dialog = cfd;
}
static void
-_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
+_fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata)
{
- char *tmp;
- int i;
+ char *tmp;
+ int i;
- cfdata->poll_time = ci->poll_time;
- cfdata->always_text = ci->always_text;
- cfdata->max = ci->max;
-
- if (ci->device != NULL)
- cfdata->device = strdup(ci->device);
- else
- cfdata->device = NULL;
-
- if (!cfdata->device)
- return;
-
- cfdata->devs = ecore_list_new();
- _net_config_get_devices(cfdata->devs);
-
- if (!cfdata->devs)
- 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++;
- }
+ cfdata->poll_time = ci->poll_time;
+ cfdata->always_text = ci->always_text;
+ cfdata->max = ci->max;
+
+ if (ci->device != NULL)
+ cfdata->device = strdup (ci->device);
+ else
+ cfdata->device = NULL;
+
+ if (!cfdata->device)
+ return;
+
+ cfdata->devs = ecore_list_new ();
+ _net_config_get_devices (cfdata->devs);
+
+ if (!cfdata->devs)
+ 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++;
+ }
}
static void *
-_create_data(E_Config_Dialog *cfd)
+_create_data (E_Config_Dialog * cfd)
{
- E_Config_Dialog_Data *cfdata;
- Config_Item *ci;
+ E_Config_Dialog_Data *cfdata;
+ Config_Item *ci;
- ci = cfd->data;
- cfdata = E_NEW(E_Config_Dialog_Data, 1);
+ ci = cfd->data;
+ cfdata = E_NEW (E_Config_Dialog_Data, 1);
- _fill_data(ci, cfdata);
- return cfdata;
+ _fill_data (ci, cfdata);
+ return cfdata;
}
static void
-_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
+_free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
{
- if (!net_config)
- return;
- net_config->config_dialog = NULL;
- E_FREE(cfdata->device);
- if (cfdata->devs)
- ecore_list_destroy(cfdata->devs);
- free(cfdata);
- cfdata = NULL;
+ if (!net_config)
+ return;
+ net_config->config_dialog = NULL;
+ E_FREE (cfdata->device);
+ if (cfdata->devs)
+ ecore_list_destroy (cfdata->devs);
+ free (cfdata);
+ cfdata = NULL;
}
static Evas_Object *
-_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
*cfdata)
+_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
+ E_Config_Dialog_Data * cfdata)
{
- Evas_Object *o, *of, *ob, *ot;
- E_Radio_Group *rg;
- char *tmp;
- int i;
-
- o = e_widget_list_add(evas, 0, 0);
-
- of = e_widget_framelist_add(evas, D_("General Settings"), 0);
- rg = e_widget_radio_group_new(&(cfdata->always_text));
- ob = e_widget_radio_add(evas, D_("Always Show Text"), 1, rg);
- e_widget_framelist_object_append(of, ob);
- ob = e_widget_radio_add(evas, D_("Show Text On Mouse Over"), 0, rg);
- e_widget_framelist_object_append(of, ob);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
-
- of = e_widget_framelist_add(evas, D_("Device Settings"), 0);
- ot = e_widget_table_add(evas, 0);
- rg = e_widget_radio_group_new(&(cfdata->dev_num));
- i = 0;
- 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++;
- }
- i++;
- ob = e_widget_label_add(evas, D_("Check Interval:"));
- e_widget_table_object_append(ot, ob, 0, i, 1, 1, 0, 0, 1, 0);
- i++;
- ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 1, 60, 1, 0,
&(cfdata->poll_time), NULL, 150);
- e_widget_table_object_append(ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
- i++;
- ob = e_widget_label_add(evas, D_("Max MTU:"));
- e_widget_table_object_append(ot, ob, 0, i, 1, 1, 0, 0, 1, 0);
- i++;
- ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 100, 1500, 100, 0,
&(cfdata->max), NULL, 150);
- e_widget_table_object_append(ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
- e_widget_framelist_object_append(of, ot);
- e_widget_list_object_append(o, of, 1, 1, 0.5);
+ Evas_Object *o, *of, *ob, *ot;
+ E_Radio_Group *rg;
+ char *tmp;
+ int i;
+
+ o = e_widget_list_add (evas, 0, 0);
+
+ of = e_widget_framelist_add (evas, D_ ("General Settings"), 0);
+ rg = e_widget_radio_group_new (&(cfdata->always_text));
+ ob = e_widget_radio_add (evas, D_ ("Always Show Text"), 1, rg);
+ e_widget_framelist_object_append (of, ob);
+ ob = e_widget_radio_add (evas, D_ ("Show Text On Mouse Over"), 0, rg);
+ e_widget_framelist_object_append (of, ob);
+ e_widget_list_object_append (o, of, 1, 1, 0.5);
+
+ of = e_widget_framelist_add (evas, D_ ("Device Settings"), 0);
+ ot = e_widget_table_add (evas, 0);
+ rg = e_widget_radio_group_new (&(cfdata->dev_num));
+ i = 0;
+ 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++;
+ }
+ i++;
+ ob = e_widget_label_add (evas, D_ ("Check Interval:"));
+ e_widget_table_object_append (ot, ob, 0, i, 1, 1, 0, 0, 1, 0);
+ i++;
+ ob =
+ e_widget_slider_add (evas, 1, 0, _("%1.0f seconds"), 1, 60, 1, 0,
+ &(cfdata->poll_time), NULL, 150);
+ e_widget_table_object_append (ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
+ i++;
+ ob = e_widget_label_add (evas, D_ ("Max MTU:"));
+ e_widget_table_object_append (ot, ob, 0, i, 1, 1, 0, 0, 1, 0);
+ i++;
+ ob =
+ e_widget_slider_add (evas, 1, 0, _("%1.0f"), 100, 1500, 100, 0,
+ &(cfdata->max), NULL, 150);
+ e_widget_table_object_append (ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
+ e_widget_framelist_object_append (of, ot);
+ e_widget_list_object_append (o, of, 1, 1, 0.5);
- return o;
+ return o;
}
static int
-_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
+_basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
{
- char *tmp;
- Config_Item *ci;
+ char *tmp;
+ Config_Item *ci;
- ci = cfd->data;
- tmp = ecore_list_goto_index(cfdata->devs, cfdata->dev_num);
- if (tmp != NULL)
- {
- evas_stringshare_del(ci->device);
- ci->device = evas_stringshare_add(tmp);
- }
-
- ci->poll_time = cfdata->poll_time;
- ci->always_text = cfdata->always_text;
- ci->max = cfdata->max;
-
- e_config_save_queue();
- _net_config_updated(ci->id);
- return 1;
+ ci = cfd->data;
+ tmp = ecore_list_goto_index (cfdata->devs, cfdata->dev_num);
+ if (tmp != NULL)
+ {
+ evas_stringshare_del (ci->device);
+ ci->device = evas_stringshare_add (tmp);
+ }
+
+ ci->poll_time = cfdata->poll_time;
+ ci->always_text = cfdata->always_text;
+ ci->max = cfdata->max;
+
+ e_config_save_queue ();
+ _net_config_updated (ci->id);
+ return 1;
}
static void
-_net_config_get_devices(Ecore_List *devs)
+_net_config_get_devices (Ecore_List * devs)
{
- FILE *stat;
- char dev[64];
- char buf[256];
- unsigned long dummy;
-
- stat = fopen("/proc/net/dev", "r");
- if (!stat)
- return;
-
- while (fgets(buf, 256, stat))
- {
- 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)
- continue;
- ecore_list_append(devs, strdup(dev));
- }
- fclose(stat);
+ FILE *stat;
+ char dev[64];
+ char buf[256];
+ unsigned long dummy;
+
+ stat = fopen ("/proc/net/dev", "r");
+ if (!stat)
+ return;
+
+ while (fgets (buf, 256, stat))
+ {
+ 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)
+ continue;
+ ecore_list_append (devs, strdup (dev));
+ }
+ fclose (stat);
}
===================================================================
RCS file: /cvs/e/e_modules/net/e_mod_main.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- e_mod_main.c 17 Jul 2006 23:24:28 -0000 1.45
+++ e_mod_main.c 18 Jul 2006 00:00:34 -0000 1.46
@@ -6,39 +6,43 @@
struct _Instance
{
- E_Gadcon_Client *gcc;
- Evas_Object *net_obj;
- Net *net;
- Ecore_Timer *check_timer;
- unsigned long old_in;
- unsigned long old_out;
+ E_Gadcon_Client *gcc;
+ Evas_Object *net_obj;
+ Net *net;
+ Ecore_Timer *check_timer;
+ unsigned long old_in;
+ unsigned long old_out;
};
struct _Net
{
- Instance *inst;
- Evas_Object *net_obj;
+ Instance *inst;
+ Evas_Object *net_obj;
};
/* Func Protos for Gadcon */
-static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char
*id, const char *style);
-static void _gc_shutdown(E_Gadcon_Client *gcc);
-static void _gc_orient(E_Gadcon_Client *gcc);
-static char *_gc_label(void);
-static Evas_Object *_gc_icon(Evas *evas);
+static E_Gadcon_Client *_gc_init (E_Gadcon * gc, const char *name,
+ const char *id, const char *style);
+static void _gc_shutdown (E_Gadcon_Client * gcc);
+static void _gc_orient (E_Gadcon_Client * gcc);
+static char *_gc_label (void);
+static Evas_Object *_gc_icon (Evas * evas);
/* Func Protos for Module */
-static void _net_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void
*event_info);
-static void _net_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void
*event_info);
-static void _net_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void
*event_info);
-static void _net_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi);
-static void _net_menu_cb_post(void *data, E_Menu *m);
-static Config_Item *_net_config_item_get(const char *id);
-static Net *_net_new(Evas *evas);
-static void _net_free(Net *net);
-static void _net_update_rx(void *data, int value);
-static void _net_update_tx(void *data, int value);
-static int _net_cb_check(void *data);
+static void _net_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
+ void *event_info);
+static void _net_cb_mouse_in (void *data, Evas * e, Evas_Object * obj,
+ void *event_info);
+static void _net_cb_mouse_out (void *data, Evas * e, Evas_Object * obj,
+ void *event_info);
+static void _net_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi);
+static void _net_menu_cb_post (void *data, E_Menu * m);
+static Config_Item *_net_config_item_get (const char *id);
+static Net *_net_new (Evas * evas);
+static void _net_free (Net * net);
+static void _net_update_rx (void *data, int value);
+static void _net_update_tx (void *data, int value);
+static int _net_cb_check (void *data);
static E_Config_DD *conf_edd = NULL;
static E_Config_DD *conf_item_edd = NULL;
@@ -47,486 +51,528 @@
/* Define the gadcon class and functions provided by this module */
static const E_Gadcon_Client_Class _gc_class = {
- GADCON_CLIENT_CLASS_VERSION,
- "net", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon}
+ GADCON_CLIENT_CLASS_VERSION,
+ "net", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon}
};
static E_Gadcon_Client *
-_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
+_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
{
- E_Gadcon_Client *gcc;
- Evas_Object *o;
- Instance *inst;
- Config_Item *ci;
- Net *net;
+ E_Gadcon_Client *gcc;
+ Evas_Object *o;
+ Instance *inst;
+ Config_Item *ci;
+ Net *net;
+
+ inst = E_NEW (Instance, 1);
+
+ ci = _net_config_item_get (id);
+ if (!ci->id)
+ ci->id = evas_stringshare_add (id);
+
+ net = _net_new (gc->evas);
+ net->inst = inst;
+ inst->net = net;
+
+ o = net->net_obj;
+ gcc = e_gadcon_client_new (gc, name, id, style, o);
+ gcc->data = inst;
+ inst->gcc = gcc;
+ inst->net_obj = o;
+
+ evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_DOWN,
+ _net_cb_mouse_down, inst);
+ evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_MOVE,
+ _net_cb_mouse_in, inst);
+ evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_IN, _net_cb_mouse_in,
+ inst);
+ evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_OUT,
+ _net_cb_mouse_out, inst);
+
+ if (ci->always_text)
+ edje_object_signal_emit (inst->net_obj, "label_active", "");
- inst = E_NEW(Instance, 1);
+ _net_cb_check (inst);
- ci = _net_config_item_get(id);
- if (!ci->id) ci->id = evas_stringshare_add(id);
+ inst->check_timer = ecore_timer_add (ci->poll_time, _net_cb_check, inst);
+ net_config->instances = evas_list_append (net_config->instances, inst);
- net = _net_new(gc->evas);
- net->inst = inst;
- inst->net = net;
-
- o = net->net_obj;
- gcc = e_gadcon_client_new(gc, name, id, style, o);
- gcc->data = inst;
- inst->gcc = gcc;
- inst->net_obj = o;
-
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_net_cb_mouse_down, inst);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
_net_cb_mouse_in, inst);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _net_cb_mouse_in,
inst);
- evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT,
_net_cb_mouse_out, inst);
-
- if (ci->always_text)
- edje_object_signal_emit(inst->net_obj, "label_active", "");
-
- _net_cb_check(inst);
-
- inst->check_timer = ecore_timer_add(ci->poll_time, _net_cb_check, inst);
- net_config->instances = evas_list_append(net_config->instances, inst);
-
- return gcc;
+ return gcc;
}
static void
-_gc_orient(E_Gadcon_Client *gcc)
+_gc_orient (E_Gadcon_Client * gcc)
{
- e_gadcon_client_aspect_set(gcc, 16, 16);
- e_gadcon_client_min_size_set(gcc, 16, 16);
+ e_gadcon_client_aspect_set (gcc, 16, 16);
+ e_gadcon_client_min_size_set (gcc, 16, 16);
}
static char *
-_gc_label(void)
+_gc_label (void)
{
- return D_("Net");
+ return D_ ("Net");
}
static Evas_Object *
-_gc_icon(Evas *evas)
+_gc_icon (Evas * evas)
{
- Evas_Object *o;
- char buf[4096];
+ Evas_Object *o;
+ char buf[4096];
- o = edje_object_add(evas);
- snprintf(buf, sizeof(buf), "%s/module.eap",
e_module_dir_get(net_config->module));
- edje_object_file_set(o, buf, "icon");
- return o;
+ o = edje_object_add (evas);
+ snprintf (buf, sizeof (buf), "%s/module.eap",
+ e_module_dir_get (net_config->module));
+ edje_object_file_set (o, buf, "icon");
+ return o;
}
static void
-_gc_shutdown(E_Gadcon_Client *gcc)
+_gc_shutdown (E_Gadcon_Client * gcc)
{
- Instance *inst;
- Net *net;
-
- inst = gcc->data;
- net = inst->net;
-
- if (inst->check_timer) ecore_timer_del(inst->check_timer);
- net_config->instances = evas_list_remove(net_config->instances, inst);
-
- evas_object_event_callback_del(net->net_obj, EVAS_CALLBACK_MOUSE_DOWN,
_net_cb_mouse_down);
- evas_object_event_callback_del(net->net_obj, EVAS_CALLBACK_MOUSE_MOVE,
_net_cb_mouse_in);
- evas_object_event_callback_del(net->net_obj, EVAS_CALLBACK_MOUSE_IN,
_net_cb_mouse_in);
- evas_object_event_callback_del(net->net_obj, EVAS_CALLBACK_MOUSE_OUT,
_net_cb_mouse_out);
-
- _net_free(net);
- free(inst);
- inst = NULL;
+ Instance *inst;
+ Net *net;
+
+ inst = gcc->data;
+ net = inst->net;
+
+ if (inst->check_timer)
+ ecore_timer_del (inst->check_timer);
+ net_config->instances = evas_list_remove (net_config->instances, inst);
+
+ evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_DOWN,
+ _net_cb_mouse_down);
+ evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_MOVE,
+ _net_cb_mouse_in);
+ evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_IN,
+ _net_cb_mouse_in);
+ evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_OUT,
+ _net_cb_mouse_out);
+
+ _net_free (net);
+ free (inst);
+ inst = NULL;
}
static void
-_net_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_net_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
- Instance *inst;
- Evas_Event_Mouse_Down *ev;
+ Instance *inst;
+ Evas_Event_Mouse_Down *ev;
- inst = data;
- ev = event_info;
- if ((ev->button == 3) && (!net_config->menu))
- {
- E_Menu *mn;
- E_Menu_Item *mi;
- int x, y, w, h;
-
- mn = e_menu_new();
- e_menu_post_deactivate_callback_set(mn, _net_menu_cb_post, inst);
- net_config->menu = mn;
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, D_("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _net_menu_cb_configure, inst);
-
- mi = e_menu_item_new(mn);
- e_menu_item_separator_set(mi, 1);
-
- e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
- e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, &w, &h);
- e_menu_activate_mouse(mn,
- e_util_zone_current_get(e_manager_current_get()),
- x + ev->output.x, y + ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
- evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
EVAS_BUTTON_NONE, ev->timestamp, NULL);
- }
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!net_config->menu))
+ {
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int x, y, w, h;
+
+ mn = e_menu_new ();
+ e_menu_post_deactivate_callback_set (mn, _net_menu_cb_post, inst);
+ net_config->menu = mn;
+
+ mi = e_menu_item_new (mn);
+ e_menu_item_label_set (mi, D_ ("Configuration"));
+ e_util_menu_item_edje_icon_set (mi, "enlightenment/configuration");
+ e_menu_item_callback_set (mi, _net_menu_cb_configure, inst);
+
+ mi = e_menu_item_new (mn);
+ e_menu_item_separator_set (mi, 1);
+
+ e_gadcon_client_util_menu_items_append (inst->gcc, mn, 0);
+ e_gadcon_canvas_zone_geometry_get (inst->gcc->gadcon, &x, &y, &w, &h);
+ e_menu_activate_mouse (mn,
+ e_util_zone_current_get (e_manager_current_get
+ ()), x + ev->output.x,
+ y + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up (inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ }
}
static void
-_net_menu_cb_post(void *data, E_Menu *m)
+_net_menu_cb_post (void *data, E_Menu * m)
{
- if (!net_config->menu) return;
- e_object_del(E_OBJECT(net_config->menu));
- net_config->menu = NULL;
+ if (!net_config->menu)
+ return;
+ e_object_del (E_OBJECT (net_config->menu));
+ net_config->menu = NULL;
}
static void
-_net_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
+_net_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi)
{
- Instance *inst;
- Config_Item *ci;
+ Instance *inst;
+ Config_Item *ci;
- inst = data;
- ci = _net_config_item_get(inst->gcc->id);
- _config_net_module(ci);
+ inst = data;
+ ci = _net_config_item_get (inst->gcc->id);
+ _config_net_module (ci);
}
void
-_net_config_updated(const char *id)
+_net_config_updated (const char *id)
{
- Evas_List *l;
- Config_Item *ci;
+ Evas_List *l;
+ Config_Item *ci;
- if (!net_config) return;
- ci = _net_config_item_get(id);
- for (l = net_config->instances; l; l = l->next)
- {
- Instance *inst;
-
- inst = l->data;
- if (!inst->gcc->id) continue;
- if (!strcmp(inst->gcc->id, ci->id))
- {
- if (inst->check_timer) ecore_timer_del(inst->check_timer);
- inst->check_timer = ecore_timer_add((double)ci->poll_time,
_net_cb_check, inst);
- if (ci->always_text)
- edje_object_signal_emit(inst->net_obj, "label_active", "");
- else
- edje_object_signal_emit(inst->net_obj, "label_passive", "");
-
- break;
- }
- }
+ if (!net_config)
+ return;
+ ci = _net_config_item_get (id);
+ for (l = net_config->instances; l; l = l->next)
+ {
+ Instance *inst;
+
+ inst = l->data;
+ if (!inst->gcc->id)
+ continue;
+ if (!strcmp (inst->gcc->id, ci->id))
+ {
+ if (inst->check_timer)
+ ecore_timer_del (inst->check_timer);
+ inst->check_timer =
+ ecore_timer_add ((double) ci->poll_time, _net_cb_check, inst);
+ if (ci->always_text)
+ edje_object_signal_emit (inst->net_obj, "label_active", "");
+ else
+ edje_object_signal_emit (inst->net_obj, "label_passive", "");
+
+ break;
+ }
+ }
}
static Config_Item *
-_net_config_item_get(const char *id)
+_net_config_item_get (const char *id)
{
- Evas_List *l;
- Config_Item *ci;
+ Evas_List *l;
+ Config_Item *ci;
- for (l = net_config->items; l; l = l->next)
- {
- ci = l->data;
- if (!ci->id) continue;
- if (!strcmp(ci->id, id)) return ci;
- }
- ci = E_NEW(Config_Item, 1);
- ci->id = evas_stringshare_add(id);
- ci->device = evas_stringshare_add("eth0");
- ci->poll_time = 1.0;
- ci->max = 1500.0;
- ci->always_text = 0;
- net_config->items = evas_list_append(net_config->items, ci);
- return ci;
+ for (l = net_config->items; l; l = l->next)
+ {
+ ci = l->data;
+ if (!ci->id)
+ continue;
+ if (!strcmp (ci->id, id))
+ return ci;
+ }
+ ci = E_NEW (Config_Item, 1);
+ ci->id = evas_stringshare_add (id);
+ ci->device = evas_stringshare_add ("eth0");
+ ci->poll_time = 1.0;
+ ci->max = 1500.0;
+ ci->always_text = 0;
+ net_config->items = evas_list_append (net_config->items, ci);
+ return ci;
}
/* Module routines */
EAPI E_Module_Api e_modapi = {
- E_MODULE_API_VERSION,
- "Net"
+ E_MODULE_API_VERSION,
+ "Net"
};
EAPI void *
-e_modapi_init(E_Module *m)
+e_modapi_init (E_Module * m)
{
- bindtextdomain(PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(PACKAGE, "UTF-8");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (PACKAGE, "UTF-8");
- conf_item_edd = E_CONFIG_DD_NEW("Net_Config_Item", Config_Item);
+ conf_item_edd = E_CONFIG_DD_NEW ("Net_Config_Item", Config_Item);
#undef T
#undef D
#define T Config_Item
#define D conf_item_edd
- E_CONFIG_VAL(D, T, id, STR);
- E_CONFIG_VAL(D, T, device, STR);
- E_CONFIG_VAL(D, T, max, DOUBLE);
- E_CONFIG_VAL(D, T, poll_time, DOUBLE);
- E_CONFIG_VAL(D, T, always_text, INT);
+ E_CONFIG_VAL (D, T, id, STR);
+ E_CONFIG_VAL (D, T, device, STR);
+ E_CONFIG_VAL (D, T, max, DOUBLE);
+ E_CONFIG_VAL (D, T, poll_time, DOUBLE);
+ E_CONFIG_VAL (D, T, always_text, INT);
- conf_edd = E_CONFIG_DD_NEW("Net_Config", Config);
+ conf_edd = E_CONFIG_DD_NEW ("Net_Config", Config);
#undef T
#undef D
#define T Config
#define D conf_edd
- E_CONFIG_LIST(D, T, items, conf_item_edd);
+ E_CONFIG_LIST (D, T, items, conf_item_edd);
- net_config = e_config_domain_load("module.net", conf_edd);
- if (!net_config)
- {
- Config_Item *ci;
-
- net_config = E_NEW(Config, 1);
- ci = E_NEW(Config_Item, 1);
-
- ci->id = evas_stringshare_add("0");
- ci->device = evas_stringshare_add("eth0");
- ci->poll_time = 1.0;
- ci->max = 1500.0;
- ci->always_text = 0;
- net_config->items = evas_list_append(net_config->items, ci);
- }
- net_config->module = m;
- e_gadcon_provider_register(&_gc_class);
- return m;
+ net_config = e_config_domain_load ("module.net", conf_edd);
+ if (!net_config)
+ {
+ Config_Item *ci;
+
+ net_config = E_NEW (Config, 1);
+ ci = E_NEW (Config_Item, 1);
+
+ ci->id = evas_stringshare_add ("0");
+ ci->device = evas_stringshare_add ("eth0");
+ ci->poll_time = 1.0;
+ ci->max = 1500.0;
+ ci->always_text = 0;
+ net_config->items = evas_list_append (net_config->items, ci);
+ }
+ net_config->module = m;
+ e_gadcon_provider_register (&_gc_class);
+ return m;
}
EAPI int
-e_modapi_shutdown(E_Module *m)
+e_modapi_shutdown (E_Module * m)
{
- net_config->module = NULL;
- e_gadcon_provider_unregister(&_gc_class);
+ net_config->module = NULL;
+ e_gadcon_provider_unregister (&_gc_class);
- if (net_config->config_dialog)
- e_object_del(E_OBJECT(net_config->config_dialog));
- if (net_config->menu)
- {
- e_menu_post_deactivate_callback_set(net_config->menu, NULL, NULL);
- e_object_del(E_OBJECT(net_config->menu));
- net_config->menu = NULL;
- }
- while (net_config->items)
- {
- Config_Item *ci;
-
- ci = net_config->items->data;
- net_config->items = evas_list_remove_list(net_config->items,
net_config->items);
- if (ci->id) evas_stringshare_del(ci->id);
- free(ci);
- ci = NULL;
- }
- free(net_config);
- net_config = NULL;
- E_CONFIG_DD_FREE(conf_item_edd);
- E_CONFIG_DD_FREE(conf_edd);
- return 1;
+ if (net_config->config_dialog)
+ e_object_del (E_OBJECT (net_config->config_dialog));
+ if (net_config->menu)
+ {
+ e_menu_post_deactivate_callback_set (net_config->menu, NULL, NULL);
+ e_object_del (E_OBJECT (net_config->menu));
+ net_config->menu = NULL;
+ }
+ while (net_config->items)
+ {
+ Config_Item *ci;
+
+ ci = net_config->items->data;
+ net_config->items =
+ evas_list_remove_list (net_config->items, net_config->items);
+ if (ci->id)
+ evas_stringshare_del (ci->id);
+ free (ci);
+ ci = NULL;
+ }
+ free (net_config);
+ net_config = NULL;
+ E_CONFIG_DD_FREE (conf_item_edd);
+ E_CONFIG_DD_FREE (conf_edd);
+ return 1;
}
EAPI int
-e_modapi_save(E_Module *m)
+e_modapi_save (E_Module * m)
{
- Evas_List *l;
+ Evas_List *l;
- for (l = net_config->instances; l; l = l->next)
- {
- Instance *inst;
- Config_Item *ci;
-
- inst = l->data;
- ci = _net_config_item_get(inst->gcc->id);
- if (ci->id) evas_stringshare_del(ci->id);
- ci->id = evas_stringshare_add(inst->gcc->id);
- }
- e_config_domain_save("module.net", conf_edd, net_config);
- return 1;
+ for (l = net_config->instances; l; l = l->next)
+ {
+ Instance *inst;
+ Config_Item *ci;
+
+ inst = l->data;
+ ci = _net_config_item_get (inst->gcc->id);
+ if (ci->id)
+ evas_stringshare_del (ci->id);
+ ci->id = evas_stringshare_add (inst->gcc->id);
+ }
+ e_config_domain_save ("module.net", conf_edd, net_config);
+ return 1;
}
EAPI int
-e_modapi_about(E_Module *m)
+e_modapi_about (E_Module * m)
{
- e_module_dialog_show(m, D_("Enlightenment Network Monitor Module"),
D_("This module is used to monitor a network device."));
- return 1;
+ e_module_dialog_show (m, D_ ("Enlightenment Network Monitor Module"),
+ D_
+ ("This module is used to monitor a network device."));
+ return 1;
}
static Net *
-_net_new(Evas *evas)
+_net_new (Evas * evas)
{
- Net *net;
- char buf[4096];
+ Net *net;
+ char buf[4096];
- net = E_NEW(Net, 1);
- net->net_obj = edje_object_add(evas);
- snprintf(buf, sizeof(buf), "%s/net.edj",
e_module_dir_get(net_config->module));
- if (!e_theme_edje_object_set(net->net_obj, "base/theme/modules/net",
"modules/net/main"))
- edje_object_file_set(net->net_obj, buf, "modules/net/main");
- evas_object_show(net->net_obj);
- return net;
+ net = E_NEW (Net, 1);
+ net->net_obj = edje_object_add (evas);
+ snprintf (buf, sizeof (buf), "%s/net.edj",
+ e_module_dir_get (net_config->module));
+ if (!e_theme_edje_object_set
+ (net->net_obj, "base/theme/modules/net", "modules/net/main"))
+ edje_object_file_set (net->net_obj, buf, "modules/net/main");
+ evas_object_show (net->net_obj);
+ return net;
}
static void
-_net_free(Net *n)
+_net_free (Net * n)
{
- evas_object_del(n->net_obj);
- free(n);
- n = NULL;
+ evas_object_del (n->net_obj);
+ free (n);
+ n = NULL;
}
static void
-_net_update_rx(void *data, int value)
+_net_update_rx (void *data, int value)
{
- Edje_Message_Int_Set *val;
- Instance *inst;
+ Edje_Message_Int_Set *val;
+ Instance *inst;
- inst = data;
- val = malloc(sizeof(Edje_Message_Int_Set) + (1 * sizeof(int)));
- val->count = 1;
- val->val[0] = value;
- edje_object_message_send(inst->net_obj, EDJE_MESSAGE_INT_SET, 1, val);
- free(val);
- val = NULL;
+ inst = data;
+ val = malloc (sizeof (Edje_Message_Int_Set) + (1 * sizeof (int)));
+ val->count = 1;
+ val->val[0] = value;
+ edje_object_message_send (inst->net_obj, EDJE_MESSAGE_INT_SET, 1, val);
+ free (val);
+ val = NULL;
}
static void
-_net_update_tx(void *data, int value)
+_net_update_tx (void *data, int value)
{
- Edje_Message_Int_Set *val;
- Instance *inst;
+ Edje_Message_Int_Set *val;
+ Instance *inst;
- inst = data;
- val = malloc(sizeof(Edje_Message_Int_Set) + (1 * sizeof(int)));
- val->count = 1;
- val->val[0] = value;
- edje_object_message_send(inst->net_obj, EDJE_MESSAGE_INT_SET, 2, val);
- free(val);
- val = NULL;
+ inst = data;
+ val = malloc (sizeof (Edje_Message_Int_Set) + (1 * sizeof (int)));
+ val->count = 1;
+ val->val[0] = value;
+ edje_object_message_send (inst->net_obj, EDJE_MESSAGE_INT_SET, 2, val);
+ free (val);
+ val = NULL;
}
static void
-_net_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_net_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
- Instance *inst;
+ Instance *inst;
- inst = data;
- edje_object_signal_emit(inst->net_obj, "label_active", "");
+ inst = data;
+ edje_object_signal_emit (inst->net_obj, "label_active", "");
}
static void
-_net_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_net_cb_mouse_out (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
- Instance *inst;
- Config_Item *ci;
+ Instance *inst;
+ Config_Item *ci;
- inst = data;
- ci = _net_config_item_get(inst->gcc->id);
- if (!ci->always_text)
- edje_object_signal_emit(inst->net_obj, "label_passive", "");
+ inst = data;
+ ci = _net_config_item_get (inst->gcc->id);
+ if (!ci->always_text)
+ edje_object_signal_emit (inst->net_obj, "label_passive", "");
}
static int
-_net_cb_check(void *data)
+_net_cb_check (void *data)
{
- Instance *inst;
- Config_Item *ci;
- FILE *stat;
- char dev[64];
- char buf[256];
- unsigned long in = 0;
- unsigned long out = 0;
- unsigned long dummy = 0;
- int found;
- long bytes_in, bytes_out;
- char in_str[100];
- char out_str[100];
- double i, o;
-
- inst = data;
- ci = _net_config_item_get(inst->gcc->id);
-
- stat = fopen("/proc/net/dev", "r");
- if (!stat) return 1;
-
- found = 0;
- while (fgets(buf, 256, stat))
- {
- 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)
- continue;
- if (!ci->device) continue;
- if (!strcmp(dev, ci->device))
- {
- found = 1;
- break;
- }
- }
- fclose(stat);
-
- if (!found) return 1;
-
- bytes_in = in - inst->old_in;
- bytes_out = out - inst->old_out;
- bytes_in = bytes_in / ci->poll_time;
- bytes_out = bytes_out / ci->poll_time;
-
- if (bytes_in < 0) bytes_in = 0;
- if (bytes_out < 0) bytes_out = 0;
-
- inst->old_in = in;
- inst->old_out = out;
-
- edje_object_part_text_set(inst->net_obj, "net_label", ci->device);
-
- if (bytes_in <= 0)
- edje_object_part_text_set(inst->net_obj, "rx_label", "Rx: 0 B");
- else
- {
- if (bytes_in > 1048576)
- snprintf(in_str, sizeof(in_str), "Rx: %ld Mb", (bytes_in /
1048576));
- else if (bytes_in > 1024 && bytes_in < 1048576)
- snprintf(in_str, sizeof(in_str), "Rx: %ld Kb", (bytes_in / 1024));
- else
- snprintf(in_str, sizeof(in_str), "Rx: %ld B", bytes_in);
-
- edje_object_part_text_set(inst->net_obj, "rx_label", in_str);
- }
-
- if (bytes_out <= 0)
- edje_object_part_text_set(inst->net_obj, "tx_label", "Tx: 0 B");
- else
- {
- if (bytes_out > 1048576)
- snprintf(out_str, sizeof(out_str), "Tx: %ld Mb", (bytes_out /
1048576));
- else if (bytes_out > 1024 && bytes_out < 1048576)
- snprintf(out_str, sizeof(out_str), "Tx: %ld Kb", (bytes_out /
1024));
- else
- snprintf(out_str, sizeof(out_str), "Tx: %ld B", bytes_out);
-
- edje_object_part_text_set(inst->net_obj, "tx_label", out_str);
- }
-
- i = 0.0;
- if (bytes_in != 0.0)
- i = ((double)bytes_in / (double)ci->max);
-
- o = 0.0;
- if (bytes_out != 0.0)
- o = ((double)bytes_out / (double)ci->max);
-
- if (i < 0.0) i = 0.0;
- if (o < 0.0) o = 0.0;
- if ((i > 0.0) && (i < 1.0)) i = 1.0;
- if ((o > 0.0) && (o < 1.0)) o = 1.0;
+ Instance *inst;
+ Config_Item *ci;
+ FILE *stat;
+ char dev[64];
+ char buf[256];
+ unsigned long in = 0;
+ unsigned long out = 0;
+ unsigned long dummy = 0;
+ int found;
+ long bytes_in, bytes_out;
+ char in_str[100];
+ char out_str[100];
+ double i, o;
+
+ inst = data;
+ ci = _net_config_item_get (inst->gcc->id);
+
+ stat = fopen ("/proc/net/dev", "r");
+ if (!stat)
+ return 1;
+
+ found = 0;
+ while (fgets (buf, 256, stat))
+ {
+ 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)
+ continue;
+ if (!ci->device)
+ continue;
+ if (!strcmp (dev, ci->device))
+ {
+ found = 1;
+ break;
+ }
+ }
+ fclose (stat);
+
+ if (!found)
+ return 1;
+
+ bytes_in = in - inst->old_in;
+ bytes_out = out - inst->old_out;
+ bytes_in = bytes_in / ci->poll_time;
+ bytes_out = bytes_out / ci->poll_time;
+
+ if (bytes_in < 0)
+ bytes_in = 0;
+ if (bytes_out < 0)
+ bytes_out = 0;
+
+ inst->old_in = in;
+ inst->old_out = out;
+
+ edje_object_part_text_set (inst->net_obj, "net_label", ci->device);
+
+ if (bytes_in <= 0)
+ edje_object_part_text_set (inst->net_obj, "rx_label", "Rx: 0 B");
+ else
+ {
+ if (bytes_in > 1048576)
+ snprintf (in_str, sizeof (in_str), "Rx: %ld Mb",
+ (bytes_in / 1048576));
+ else if (bytes_in > 1024 && bytes_in < 1048576)
+ snprintf (in_str, sizeof (in_str), "Rx: %ld Kb", (bytes_in / 1024));
+ else
+ snprintf (in_str, sizeof (in_str), "Rx: %ld B", bytes_in);
+
+ edje_object_part_text_set (inst->net_obj, "rx_label", in_str);
+ }
+
+ if (bytes_out <= 0)
+ edje_object_part_text_set (inst->net_obj, "tx_label", "Tx: 0 B");
+ else
+ {
+ if (bytes_out > 1048576)
+ snprintf (out_str, sizeof (out_str), "Tx: %ld Mb",
+ (bytes_out / 1048576));
+ else if (bytes_out > 1024 && bytes_out < 1048576)
+ snprintf (out_str, sizeof (out_str), "Tx: %ld Kb",
+ (bytes_out / 1024));
+ else
+ snprintf (out_str, sizeof (out_str), "Tx: %ld B", bytes_out);
+
+ edje_object_part_text_set (inst->net_obj, "tx_label", out_str);
+ }
+
+ i = 0.0;
+ if (bytes_in != 0.0)
+ i = ((double) bytes_in / (double) ci->max);
+
+ o = 0.0;
+ if (bytes_out != 0.0)
+ o = ((double) bytes_out / (double) ci->max);
+
+ if (i < 0.0)
+ i = 0.0;
+ if (o < 0.0)
+ o = 0.0;
+ if ((i > 0.0) && (i < 1.0))
+ i = 1.0;
+ if ((o > 0.0) && (o < 1.0))
+ o = 1.0;
- _net_update_rx(inst, i);
- _net_update_tx(inst, o);
+ _net_update_rx (inst, i);
+ _net_update_tx (inst, o);
- return 1;
+ return 1;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs