forked from enlightenment/enlightenment
Enlightenment: Sysinfo Gadget - Add an informative popup, as well as a config panel to memusage, cpumonitor, and netstatus.
Left click will give you some informative detail and right click will show the config panel with t he option to configure how often to poll.
This commit is contained in:
parent
bae6700f8c
commit
58a9333580
|
@ -25,12 +25,15 @@ src_modules_sysinfo_module_la_SOURCES = src/modules/sysinfo/mod.c \
|
|||
src/modules/sysinfo/cpuclock/cpuclock_sysfs.c \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor.h \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor.c \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor_config.c \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor_proc.c \
|
||||
src/modules/sysinfo/memusage/memusage.h \
|
||||
src/modules/sysinfo/memusage/memusage.c \
|
||||
src/modules/sysinfo/memusage/memusage_config.c \
|
||||
src/modules/sysinfo/memusage/memusage_proc.c \
|
||||
src/modules/sysinfo/netstatus/netstatus.h \
|
||||
src/modules/sysinfo/netstatus/netstatus.c \
|
||||
src/modules/sysinfo/netstatus/netstatus_config.c \
|
||||
src/modules/sysinfo/netstatus/netstatus_proc.c \
|
||||
src/modules/sysinfo/sysinfo.c
|
||||
if HAVE_EEZE
|
||||
|
|
|
@ -84,7 +84,8 @@ _bar_gadget_configure(Evas_Object *g)
|
|||
return config_luncher(e_zone_current_get(), inst, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void _bar_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
static void
|
||||
_bar_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,71 @@ _cpumonitor_face_update(Instance *inst)
|
|||
}
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_cpumonitor_configure_cb(Evas_Object *g)
|
||||
{
|
||||
Instance *inst = evas_object_data_get(g, "Instance");
|
||||
|
||||
if (!sysinfo_config) return NULL;
|
||||
if (inst->cfg->cpumonitor.popup) return NULL;
|
||||
return cpumonitor_configure(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_cpumonitor_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
}
|
||||
|
||||
static void
|
||||
_cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
||||
{
|
||||
Evas_Object *label, *popup;
|
||||
Evas_Event_Mouse_Down *ev = event_data;
|
||||
Instance *inst = data;
|
||||
char text[4096];
|
||||
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button != 3)
|
||||
{
|
||||
if (inst->cfg->cpumonitor.popup)
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->cfg->cpumonitor.popup);
|
||||
inst->cfg->cpumonitor.popup = NULL;
|
||||
return;
|
||||
}
|
||||
popup = elm_ctxpopup_add(e_comp->elm);
|
||||
elm_object_style_set(popup, "noblock");
|
||||
evas_object_smart_callback_add(popup, "dismissed", _cpumonitor_popup_dismissed, NULL);
|
||||
|
||||
snprintf(text, sizeof(text), "%s: %d%%", _("Total CPU Usage"), inst->cfg->cpumonitor.percent);
|
||||
label = elm_label_add(popup);
|
||||
elm_object_style_set(label, "marker");
|
||||
elm_object_text_set(label, text);
|
||||
elm_object_content_set(popup, label);
|
||||
evas_object_show(label);
|
||||
|
||||
e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
|
||||
evas_object_show(popup);
|
||||
e_gadget_util_ctxpopup_place(inst->o_main, popup, inst->cfg->cpumonitor.o_gadget);
|
||||
inst->cfg->cpumonitor.popup = popup;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst->cfg->cpumonitor.popup)
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->cfg->cpumonitor.popup);
|
||||
inst->cfg->cpumonitor.popup = NULL;
|
||||
}
|
||||
if (!sysinfo_config) return;
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
if (inst->cfg->esm != E_SYSINFO_MODULE_CPUMONITOR)
|
||||
cpumonitor_configure(inst);
|
||||
else
|
||||
e_gadget_configure(inst->o_main);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th)
|
||||
{
|
||||
|
@ -126,6 +191,10 @@ _cpumonitor_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_dat
|
|||
|
||||
if (inst->o_main != event_data) return;
|
||||
|
||||
if (inst->cfg->cpumonitor.popup)
|
||||
E_FREE_FUNC(inst->cfg->cpumonitor.popup, evas_object_del);
|
||||
if (inst->cfg->cpumonitor.configure)
|
||||
E_FREE_FUNC(inst->cfg->cpumonitor.configure, evas_object_del);
|
||||
if (inst->cfg->cpumonitor.usage_check_thread)
|
||||
{
|
||||
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
|
||||
|
@ -148,6 +217,10 @@ sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
|
|||
Instance *inst = data;
|
||||
CPU_Core *core;
|
||||
|
||||
if (inst->cfg->cpumonitor.popup)
|
||||
E_FREE_FUNC(inst->cfg->cpumonitor.popup, evas_object_del);
|
||||
if (inst->cfg->cpumonitor.configure)
|
||||
E_FREE_FUNC(inst->cfg->cpumonitor.configure, evas_object_del);
|
||||
if (inst->cfg->cpumonitor.usage_check_thread)
|
||||
{
|
||||
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
|
||||
|
@ -212,6 +285,8 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
|
|||
Instance *inst = data;
|
||||
int orient = e_gadget_site_orient_get(e_gadget_site_get(inst->o_main));
|
||||
|
||||
e_gadget_configure_cb_set(inst->o_main, _cpumonitor_configure_cb);
|
||||
|
||||
inst->cfg->cpumonitor.o_gadget = elm_box_add(inst->o_main);
|
||||
if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
|
||||
elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_FALSE);
|
||||
|
@ -220,6 +295,7 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
|
|||
E_EXPAND(inst->cfg->cpumonitor.o_gadget);
|
||||
E_FILL(inst->cfg->cpumonitor.o_gadget);
|
||||
elm_box_pack_end(inst->o_main, inst->cfg->cpumonitor.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _cpumonitor_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->cpumonitor.o_gadget);
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created", _cpumonitor_created_cb, data);
|
||||
_cpumonitor_config_updated(inst);
|
||||
|
@ -233,6 +309,7 @@ sysinfo_cpumonitor_create(Evas_Object *parent, Instance *inst)
|
|||
elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE);
|
||||
E_EXPAND(inst->cfg->cpumonitor.o_gadget);
|
||||
E_FILL(inst->cfg->cpumonitor.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _cpumonitor_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->cpumonitor.o_gadget);
|
||||
_cpumonitor_config_updated(inst);
|
||||
_cpumonitor_eval_instance_aspect(inst);
|
||||
|
@ -262,8 +339,10 @@ _conf_item_get(int *id)
|
|||
ci->esm = E_SYSINFO_MODULE_CPUMONITOR;
|
||||
ci->cpumonitor.poll_interval = 32;
|
||||
ci->cpumonitor.total = 0;
|
||||
ci->cpumonitor.percent = 0;
|
||||
ci->cpumonitor.idle = 0;
|
||||
|
||||
ci->cpumonitor.popup = NULL;
|
||||
ci->cpumonitor.configure = NULL;
|
||||
sysinfo_config->items = eina_list_append(sysinfo_config->items, ci);
|
||||
|
||||
return ci;
|
||||
|
@ -279,8 +358,12 @@ cpumonitor_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA
|
|||
*id = inst->cfg->id;
|
||||
inst->cfg->cpumonitor.total = 0;
|
||||
inst->cfg->cpumonitor.idle = 0;
|
||||
inst->cfg->cpumonitor.percent = 0;
|
||||
inst->cfg->cpumonitor.popup = NULL;
|
||||
inst->cfg->cpumonitor.configure = NULL;
|
||||
inst->o_main = elm_box_add(parent);
|
||||
E_EXPAND(inst->o_main);
|
||||
evas_object_data_set(inst->o_main, "Instance", inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_created", _cpumonitor_created_cb, inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_removed", _cpumonitor_removed_cb, inst);
|
||||
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_cpumonitor_remove, inst);
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "../sysinfo.h"
|
||||
|
||||
void _cpuclock_config_updated(Instance *inst);
|
||||
void _cpumonitor_config_updated(Instance *inst);
|
||||
int _cpumonitor_proc_getcores(void);
|
||||
void _cpumonitor_proc_getusage(Instance *inst);
|
||||
|
||||
Evas_Object *cpumonitor_configure(Instance *inst);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
#include "cpumonitor.h"
|
||||
|
||||
static void
|
||||
_config_close(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
E_FREE_FUNC(inst->cfg->cpumonitor.configure, evas_object_del);
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_config_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
int value = elm_radio_value_get(obj);
|
||||
|
||||
switch(value)
|
||||
{
|
||||
case 0:
|
||||
inst->cfg->cpumonitor.poll_interval = 4;
|
||||
break;
|
||||
case 1:
|
||||
inst->cfg->cpumonitor.poll_interval = 8;
|
||||
break;
|
||||
case 2:
|
||||
inst->cfg->cpumonitor.poll_interval = 32;
|
||||
break;
|
||||
case 3:
|
||||
inst->cfg->cpumonitor.poll_interval = 64;
|
||||
break;
|
||||
case 4:
|
||||
inst->cfg->cpumonitor.poll_interval = 256;
|
||||
break;
|
||||
default:
|
||||
inst->cfg->cpumonitor.poll_interval = 32;
|
||||
}
|
||||
e_config_save_queue();
|
||||
_cpumonitor_config_updated(inst);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
cpumonitor_configure(Instance *inst)
|
||||
{
|
||||
Evas_Object *popup, *frame, *box, *o, *group, *lbl;
|
||||
E_Zone *zone = e_zone_current_get();
|
||||
|
||||
popup = elm_popup_add(e_comp->elm);
|
||||
E_EXPAND(popup);
|
||||
elm_popup_allow_events_set(popup, 1);
|
||||
elm_popup_scrollable_set(popup, 1);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
E_FILL(box);
|
||||
evas_object_show(box);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
lbl = elm_label_add(box);
|
||||
evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_style_set(lbl, "marker");
|
||||
elm_object_text_set(lbl, _("CpuMonitor Configuration"));
|
||||
elm_box_pack_end(box, lbl);
|
||||
evas_object_show(lbl);
|
||||
|
||||
frame = elm_frame_add(box);
|
||||
elm_object_text_set(frame, _("Update Poll Interval"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_box_pack_end(box, frame);
|
||||
evas_object_show(frame);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 0);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Fast (4 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
group = o;
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 1);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Medium (8 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 2);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Normal (32 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 3);
|
||||
elm_radio_group_add(o, group);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Slow (64 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 4);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Very Slow (256 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
switch(inst->cfg->cpumonitor.poll_interval)
|
||||
{
|
||||
case 4:
|
||||
elm_radio_value_set(group, 0);
|
||||
break;
|
||||
case 8:
|
||||
elm_radio_value_set(group, 1);
|
||||
break;
|
||||
case 32:
|
||||
elm_radio_value_set(group, 2);
|
||||
break;
|
||||
case 64:
|
||||
elm_radio_value_set(group, 3);
|
||||
break;
|
||||
case 256:
|
||||
elm_radio_value_set(group, 4);
|
||||
break;
|
||||
default:
|
||||
elm_radio_value_set(group, 2);
|
||||
}
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
|
||||
evas_object_layer_set(popup, E_LAYER_POPUP);
|
||||
evas_object_resize(popup, zone->w / 4, zone->h / 3);
|
||||
e_comp_object_util_center_on_zone(popup, zone);
|
||||
evas_object_show(popup);
|
||||
e_comp_object_util_autoclose(popup, NULL, e_comp_object_util_autoclose_on_escape, NULL);
|
||||
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _config_close, inst);
|
||||
|
||||
return inst->cfg->cpumonitor.configure = popup;
|
||||
}
|
||||
|
|
@ -40,6 +40,34 @@ _cpumonitor_proc_getusage(Instance *inst)
|
|||
{
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
if (k == 0)
|
||||
{
|
||||
long total = 0, idle = 0, use = 0, total_change = 0, idle_change = 0;
|
||||
int percent = 0;
|
||||
char *line, *tok;
|
||||
int i = 0;
|
||||
|
||||
line = strchr(buf, ' ')+1;
|
||||
tok = strtok(line, " ");
|
||||
while (tok)
|
||||
{
|
||||
use = atol(tok);
|
||||
total += use;
|
||||
i++;
|
||||
if (i == 4)
|
||||
idle = use;
|
||||
tok = strtok(NULL, " ");
|
||||
}
|
||||
total_change = total - inst->cfg->cpumonitor.total;
|
||||
idle_change = idle - inst->cfg->cpumonitor.idle;
|
||||
if (total_change != 0)
|
||||
percent = 100 * (1 - ((float)idle_change / (float)total_change));
|
||||
if (percent > 100) percent = 100;
|
||||
else if (percent < 0) percent = 0;
|
||||
inst->cfg->cpumonitor.total = total;
|
||||
inst->cfg->cpumonitor.idle = idle;
|
||||
inst->cfg->cpumonitor.percent = percent;
|
||||
}
|
||||
if (k > 0)
|
||||
{
|
||||
long total = 0, idle = 0, use = 0, total_change = 0, idle_change = 0;
|
||||
|
|
|
@ -25,6 +25,72 @@ _memusage_face_update(Instance *inst, int mem, int swap)
|
|||
free(msg);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_memusage_configure_cb(Evas_Object *g)
|
||||
{
|
||||
Instance *inst = evas_object_data_get(g, "Instance");
|
||||
|
||||
if (!sysinfo_config) return NULL;
|
||||
if (inst->cfg->memusage.popup) return NULL;
|
||||
return memusage_configure(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_memusage_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
}
|
||||
|
||||
static void
|
||||
_memusage_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
||||
{
|
||||
Evas_Object *label, *popup;
|
||||
Evas_Event_Mouse_Down *ev = event_data;
|
||||
Instance *inst = data;
|
||||
char text[4096];
|
||||
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button != 3)
|
||||
{
|
||||
if (inst->cfg->memusage.popup)
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->cfg->memusage.popup);
|
||||
inst->cfg->memusage.popup = NULL;
|
||||
return;
|
||||
}
|
||||
popup = elm_ctxpopup_add(e_comp->elm);
|
||||
elm_object_style_set(popup, "noblock");
|
||||
evas_object_smart_callback_add(popup, "dismissed", _memusage_popup_dismissed, NULL);
|
||||
|
||||
snprintf(text, sizeof(text), "%s: %d%%<br>%s: %d%%", _("Total Memory Usage"),
|
||||
inst->cfg->memusage.real, _("Total Swap Usage"), inst->cfg->memusage.swap);
|
||||
label = elm_label_add(popup);
|
||||
elm_object_style_set(label, "marker");
|
||||
elm_object_text_set(label, text);
|
||||
elm_object_content_set(popup, label);
|
||||
evas_object_show(label);
|
||||
|
||||
e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
|
||||
evas_object_show(popup);
|
||||
e_gadget_util_ctxpopup_place(inst->o_main, popup, inst->cfg->memusage.o_gadget);
|
||||
inst->cfg->memusage.popup = popup;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst->cfg->memusage.popup)
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->cfg->memusage.popup);
|
||||
inst->cfg->memusage.popup = NULL;
|
||||
}
|
||||
if (!sysinfo_config) return;
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
if (inst->cfg->esm != E_SYSINFO_MODULE_MEMUSAGE)
|
||||
memusage_configure(inst);
|
||||
else
|
||||
e_gadget_configure(inst->o_main);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_memusage_cb_usage_check_main(void *data, Ecore_Thread *th)
|
||||
{
|
||||
|
@ -52,6 +118,8 @@ _memusage_cb_usage_check_notify(void *data,
|
|||
if (!inst->cfg) return;
|
||||
if (inst->cfg->esm != E_SYSINFO_MODULE_MEMUSAGE && inst->cfg->esm != E_SYSINFO_MODULE_SYSINFO) return;
|
||||
|
||||
inst->cfg->memusage.real = thc->memstatus;
|
||||
inst->cfg->memusage.swap = thc->swapstatus;
|
||||
_memusage_face_update(inst, thc->memstatus, thc->swapstatus);
|
||||
}
|
||||
|
||||
|
@ -87,6 +155,10 @@ _memusage_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
|
|||
|
||||
if (inst->o_main != event_data) return;
|
||||
|
||||
if (inst->cfg->memusage.popup)
|
||||
E_FREE_FUNC(inst->cfg->memusage.popup, evas_object_del);
|
||||
if (inst->cfg->memusage.configure)
|
||||
E_FREE_FUNC(inst->cfg->memusage.configure, evas_object_del);
|
||||
if (inst->cfg->memusage.usage_check_thread)
|
||||
{
|
||||
ecore_thread_cancel(inst->cfg->memusage.usage_check_thread);
|
||||
|
@ -103,6 +175,10 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
|
|||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->cfg->memusage.popup)
|
||||
E_FREE_FUNC(inst->cfg->memusage.popup, evas_object_del);
|
||||
if (inst->cfg->memusage.configure)
|
||||
E_FREE_FUNC(inst->cfg->memusage.configure, evas_object_del);
|
||||
if (inst->cfg->memusage.usage_check_thread)
|
||||
{
|
||||
ecore_thread_cancel(inst->cfg->memusage.usage_check_thread);
|
||||
|
@ -154,6 +230,8 @@ _memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|||
Instance *inst = data;
|
||||
int orient = e_gadget_site_orient_get(e_gadget_site_get(inst->o_main));
|
||||
|
||||
e_gadget_configure_cb_set(inst->o_main, _memusage_configure_cb);
|
||||
|
||||
inst->cfg->memusage.o_gadget = elm_layout_add(inst->o_main);
|
||||
if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
|
||||
e_theme_edje_object_set(inst->cfg->memusage.o_gadget,
|
||||
|
@ -167,6 +245,7 @@ _memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|||
E_EXPAND(inst->cfg->memusage.o_gadget);
|
||||
E_FILL(inst->cfg->memusage.o_gadget);
|
||||
elm_box_pack_end(inst->o_main, inst->cfg->memusage.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _memusage_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->memusage.o_gadget);
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created", _memusage_created_cb, data);
|
||||
_memusage_eval_instance_aspect(inst);
|
||||
|
@ -181,6 +260,7 @@ sysinfo_memusage_create(Evas_Object *parent, Instance *inst)
|
|||
"e/modules/memusage/main");
|
||||
E_EXPAND(inst->cfg->memusage.o_gadget);
|
||||
E_FILL(inst->cfg->memusage.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _memusage_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->memusage.o_gadget);
|
||||
_memusage_eval_instance_aspect(inst);
|
||||
_memusage_config_updated(inst);
|
||||
|
@ -209,6 +289,10 @@ _conf_item_get(int *id)
|
|||
|
||||
ci->esm = E_SYSINFO_MODULE_MEMUSAGE;
|
||||
ci->memusage.poll_interval = 32;
|
||||
ci->memusage.real = 0;
|
||||
ci->memusage.swap = 0;
|
||||
ci->memusage.popup = NULL;
|
||||
ci->memusage.configure = NULL;
|
||||
|
||||
sysinfo_config->items = eina_list_append(sysinfo_config->items, ci);
|
||||
|
||||
|
@ -223,8 +307,13 @@ memusage_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_U
|
|||
inst = E_NEW(Instance, 1);
|
||||
inst->cfg = _conf_item_get(id);
|
||||
*id = inst->cfg->id;
|
||||
inst->cfg->memusage.real = 0;
|
||||
inst->cfg->memusage.swap = 0;
|
||||
inst->cfg->memusage.popup = NULL;
|
||||
inst->cfg->memusage.configure = NULL;
|
||||
inst->o_main = elm_box_add(parent);
|
||||
E_EXPAND(inst->o_main);
|
||||
evas_object_data_set(inst->o_main, "Instance", inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_created", _memusage_created_cb, inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_removed", _memusage_removed_cb, inst);
|
||||
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_memusage_remove, inst);
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
void _memusage_config_updated(Instance *inst);
|
||||
int _memusage_proc_getmemusage();
|
||||
int _memusage_proc_getswapusage();
|
||||
|
||||
Evas_Object *memusage_configure(Instance *inst);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
#include "memusage.h"
|
||||
|
||||
static void
|
||||
_config_close(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
E_FREE_FUNC(inst->cfg->memusage.configure, evas_object_del);
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_config_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
int value = elm_radio_value_get(obj);
|
||||
|
||||
switch(value)
|
||||
{
|
||||
case 0:
|
||||
inst->cfg->memusage.poll_interval = 4;
|
||||
break;
|
||||
case 1:
|
||||
inst->cfg->memusage.poll_interval = 8;
|
||||
break;
|
||||
case 2:
|
||||
inst->cfg->memusage.poll_interval = 32;
|
||||
break;
|
||||
case 3:
|
||||
inst->cfg->memusage.poll_interval = 64;
|
||||
break;
|
||||
case 4:
|
||||
inst->cfg->memusage.poll_interval = 256;
|
||||
break;
|
||||
default:
|
||||
inst->cfg->memusage.poll_interval = 32;
|
||||
}
|
||||
e_config_save_queue();
|
||||
_memusage_config_updated(inst);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
memusage_configure(Instance *inst)
|
||||
{
|
||||
Evas_Object *popup, *frame, *box, *o, *group, *lbl;
|
||||
E_Zone *zone = e_zone_current_get();
|
||||
|
||||
popup = elm_popup_add(e_comp->elm);
|
||||
E_EXPAND(popup);
|
||||
elm_popup_allow_events_set(popup, 1);
|
||||
elm_popup_scrollable_set(popup, 1);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
E_FILL(box);
|
||||
evas_object_show(box);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
lbl = elm_label_add(box);
|
||||
evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_style_set(lbl, "marker");
|
||||
elm_object_text_set(lbl, _("MemUsage Configuration"));
|
||||
elm_box_pack_end(box, lbl);
|
||||
evas_object_show(lbl);
|
||||
|
||||
frame = elm_frame_add(box);
|
||||
elm_object_text_set(frame, _("Update Poll Interval"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_box_pack_end(box, frame);
|
||||
evas_object_show(frame);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 0);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Fast (4 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
group = o;
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 1);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Medium (8 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 2);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Normal (32 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 3);
|
||||
elm_radio_group_add(o, group);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Slow (64 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 4);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Very Slow (256 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
switch(inst->cfg->memusage.poll_interval)
|
||||
{
|
||||
case 4:
|
||||
elm_radio_value_set(group, 0);
|
||||
break;
|
||||
case 8:
|
||||
elm_radio_value_set(group, 1);
|
||||
break;
|
||||
case 32:
|
||||
elm_radio_value_set(group, 2);
|
||||
break;
|
||||
case 64:
|
||||
elm_radio_value_set(group, 3);
|
||||
break;
|
||||
case 256:
|
||||
elm_radio_value_set(group, 4);
|
||||
break;
|
||||
default:
|
||||
elm_radio_value_set(group, 2);
|
||||
}
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
|
||||
evas_object_layer_set(popup, E_LAYER_POPUP);
|
||||
evas_object_resize(popup, zone->w / 4, zone->h / 3);
|
||||
e_comp_object_util_center_on_zone(popup, zone);
|
||||
evas_object_show(popup);
|
||||
e_comp_object_util_autoclose(popup, NULL, e_comp_object_util_autoclose_on_escape, NULL);
|
||||
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _config_close, inst);
|
||||
|
||||
return inst->cfg->memusage.configure = popup;
|
||||
}
|
||||
|
|
@ -93,10 +93,21 @@ sysinfo_init(void)
|
|||
ci->cpumonitor.poll_interval = 32;
|
||||
ci->cpumonitor.total = 0;
|
||||
ci->cpumonitor.idle = 0;
|
||||
ci->cpumonitor.percent = 0;
|
||||
ci->cpumonitor.popup = NULL;
|
||||
ci->cpumonitor.configure = NULL;
|
||||
ci->memusage.poll_interval = 32;
|
||||
ci->memusage.real = 0;
|
||||
ci->memusage.swap = 0;
|
||||
ci->memusage.popup = NULL;
|
||||
ci->memusage.configure = NULL;
|
||||
ci->netstatus.poll_interval = 32;
|
||||
ci->netstatus.in = 0;
|
||||
ci->netstatus.out = 0;
|
||||
ci->netstatus.instring = NULL;
|
||||
ci->netstatus.outstring = NULL;
|
||||
ci->netstatus.popup = NULL;
|
||||
ci->netstatus.configure = NULL;
|
||||
|
||||
E_CONFIG_LIMIT(ci->batman.poll_interval, 4, 4096);
|
||||
E_CONFIG_LIMIT(ci->batman.alert, 0, 60);
|
||||
|
|
|
@ -16,22 +16,83 @@ _netstatus_face_update(Instance *inst, Eina_Bool trans, const char *status)
|
|||
if (!trans && status)
|
||||
{
|
||||
elm_layout_signal_emit(inst->cfg->netstatus.o_gadget, "e,state,received,active", "e");
|
||||
elm_layout_text_set(inst->cfg->netstatus.o_gadget, "e.text.received", status);
|
||||
}
|
||||
else if (trans && status)
|
||||
{
|
||||
elm_layout_signal_emit(inst->cfg->netstatus.o_gadget, "e,state,transmitted,active", "e");
|
||||
elm_layout_text_set(inst->cfg->netstatus.o_gadget, "e.text.transmitted", status);
|
||||
}
|
||||
else if (!trans && !status)
|
||||
{
|
||||
elm_layout_signal_emit(inst->cfg->netstatus.o_gadget, "e,state,received,idle", "e");
|
||||
elm_layout_text_set(inst->cfg->netstatus.o_gadget, "e.text.received", "Rx: 0");
|
||||
}
|
||||
else if (trans && !status)
|
||||
{
|
||||
elm_layout_signal_emit(inst->cfg->netstatus.o_gadget, "e,state,transmitted,idle", "e");
|
||||
elm_layout_text_set(inst->cfg->netstatus.o_gadget, "e.text.transmitted", "Tx: 0");
|
||||
}
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_netstatus_configure_cb(Evas_Object *g)
|
||||
{
|
||||
Instance *inst = evas_object_data_get(g, "Instance");
|
||||
|
||||
if (!sysinfo_config) return NULL;
|
||||
if (inst->cfg->netstatus.popup) return NULL;
|
||||
return netstatus_configure(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_netstatus_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
}
|
||||
|
||||
static void
|
||||
_netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
||||
{
|
||||
Evas_Object *label, *popup;
|
||||
Evas_Event_Mouse_Down *ev = event_data;
|
||||
Instance *inst = data;
|
||||
char text[4096];
|
||||
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button != 3)
|
||||
{
|
||||
if (inst->cfg->netstatus.popup)
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->cfg->netstatus.popup);
|
||||
inst->cfg->netstatus.popup = NULL;
|
||||
return;
|
||||
}
|
||||
popup = elm_ctxpopup_add(e_comp->elm);
|
||||
elm_object_style_set(popup, "noblock");
|
||||
evas_object_smart_callback_add(popup, "dismissed", _netstatus_popup_dismissed, NULL);
|
||||
|
||||
snprintf(text, sizeof(text), "%s<br>%s", inst->cfg->netstatus.instring, inst->cfg->netstatus.outstring);
|
||||
label = elm_label_add(popup);
|
||||
elm_object_style_set(label, "marker");
|
||||
elm_object_text_set(label, text);
|
||||
elm_object_content_set(popup, label);
|
||||
evas_object_show(label);
|
||||
|
||||
e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
|
||||
evas_object_show(popup);
|
||||
e_gadget_util_ctxpopup_place(inst->o_main, popup, inst->cfg->netstatus.o_gadget);
|
||||
inst->cfg->netstatus.popup = popup;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst->cfg->netstatus.popup)
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->cfg->netstatus.popup);
|
||||
inst->cfg->netstatus.popup = NULL;
|
||||
}
|
||||
if (!sysinfo_config) return;
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
if (inst->cfg->esm != E_SYSINFO_MODULE_NETSTATUS)
|
||||
netstatus_configure(inst);
|
||||
else
|
||||
e_gadget_configure(inst->o_main);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +127,8 @@ _netstatus_cb_usage_check_notify(void *data,
|
|||
if (!inst->cfg) return;
|
||||
if (inst->cfg->esm != E_SYSINFO_MODULE_NETSTATUS && inst->cfg->esm != E_SYSINFO_MODULE_SYSINFO) return;
|
||||
|
||||
eina_stringshare_replace(&inst->cfg->netstatus.instring, thc->rstatus);
|
||||
eina_stringshare_replace(&inst->cfg->netstatus.outstring, thc->tstatus);
|
||||
_netstatus_face_update(inst, EINA_FALSE, thc->rstatus);
|
||||
_netstatus_face_update(inst, EINA_TRUE, thc->tstatus);
|
||||
}
|
||||
|
@ -100,11 +163,17 @@ _netstatus_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data
|
|||
|
||||
if (inst->o_main != event_data) return;
|
||||
|
||||
if (inst->cfg->netstatus.popup)
|
||||
E_FREE_FUNC(inst->cfg->netstatus.popup, evas_object_del);
|
||||
if (inst->cfg->netstatus.configure)
|
||||
E_FREE_FUNC(inst->cfg->netstatus.configure, evas_object_del);
|
||||
if (inst->cfg->netstatus.usage_check_thread)
|
||||
{
|
||||
ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread);
|
||||
inst->cfg->netstatus.usage_check_thread = NULL;
|
||||
}
|
||||
E_FREE_FUNC(inst->cfg->netstatus.instring, eina_stringshare_del);
|
||||
E_FREE_FUNC(inst->cfg->netstatus.outstring, eina_stringshare_del);
|
||||
evas_object_event_callback_del_full(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_netstatus_remove, data);
|
||||
|
||||
sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg);
|
||||
|
@ -116,11 +185,17 @@ sysinfo_netstatus_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
|
|||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->cfg->netstatus.popup)
|
||||
E_FREE_FUNC(inst->cfg->netstatus.popup, evas_object_del);
|
||||
if (inst->cfg->netstatus.configure)
|
||||
E_FREE_FUNC(inst->cfg->netstatus.configure, evas_object_del);
|
||||
if (inst->cfg->netstatus.usage_check_thread)
|
||||
{
|
||||
ecore_thread_cancel(inst->cfg->netstatus.usage_check_thread);
|
||||
inst->cfg->netstatus.usage_check_thread = NULL;
|
||||
}
|
||||
E_FREE_FUNC(inst->cfg->netstatus.instring, eina_stringshare_del);
|
||||
E_FREE_FUNC(inst->cfg->netstatus.outstring, eina_stringshare_del);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -128,12 +203,15 @@ _netstatus_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED
|
|||
{
|
||||
Instance *inst = data;
|
||||
|
||||
e_gadget_configure_cb_set(inst->o_main, _netstatus_configure_cb);
|
||||
|
||||
inst->cfg->netstatus.o_gadget = elm_layout_add(inst->o_main);
|
||||
e_theme_edje_object_set(inst->cfg->netstatus.o_gadget, "base/theme/modules/netstatus",
|
||||
"e/modules/netstatus/main");
|
||||
E_EXPAND(inst->cfg->netstatus.o_gadget);
|
||||
E_FILL(inst->cfg->netstatus.o_gadget);
|
||||
elm_box_pack_end(inst->o_main, inst->cfg->netstatus.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->netstatus.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _netstatus_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->netstatus.o_gadget);
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created", _netstatus_created_cb, data);
|
||||
_netstatus_config_updated(inst);
|
||||
|
@ -147,6 +225,7 @@ sysinfo_netstatus_create(Evas_Object *parent, Instance *inst)
|
|||
"e/modules/netstatus/main");
|
||||
E_EXPAND(inst->cfg->netstatus.o_gadget);
|
||||
E_FILL(inst->cfg->netstatus.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->netstatus.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _netstatus_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->netstatus.o_gadget);
|
||||
_netstatus_config_updated(inst);
|
||||
|
||||
|
@ -176,6 +255,10 @@ _conf_item_get(int *id)
|
|||
ci->netstatus.poll_interval = 32;
|
||||
ci->netstatus.in = 0;
|
||||
ci->netstatus.out = 0;
|
||||
ci->netstatus.instring = NULL;
|
||||
ci->netstatus.outstring = NULL;
|
||||
ci->netstatus.popup = NULL;
|
||||
ci->netstatus.configure = NULL;
|
||||
sysinfo_config->items = eina_list_append(sysinfo_config->items, ci);
|
||||
|
||||
return ci;
|
||||
|
@ -191,8 +274,12 @@ netstatus_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_
|
|||
*id = inst->cfg->id;
|
||||
inst->cfg->netstatus.in = 0;
|
||||
inst->cfg->netstatus.out = 0;
|
||||
inst->cfg->netstatus.instring = NULL;
|
||||
inst->cfg->netstatus.outstring = NULL;
|
||||
inst->cfg->netstatus.popup = NULL;
|
||||
inst->o_main = elm_box_add(parent);
|
||||
E_EXPAND(inst->o_main);
|
||||
evas_object_data_set(inst->o_main, "Instance", inst);
|
||||
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
||||
evas_object_smart_callback_add(parent, "gadget_created", _netstatus_created_cb, inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_removed", _netstatus_removed_cb, inst);
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
void _netstatus_config_updated(Instance *inst);
|
||||
const char *_netstatus_proc_getrstatus(Instance *inst);
|
||||
const char *_netstatus_proc_gettstatus(Instance *inst);
|
||||
|
||||
Evas_Object *netstatus_configure(Instance *inst);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
#include "netstatus.h"
|
||||
|
||||
static void
|
||||
_config_close(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
E_FREE_FUNC(inst->cfg->netstatus.configure, evas_object_del);
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_config_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
int value = elm_radio_value_get(obj);
|
||||
|
||||
switch(value)
|
||||
{
|
||||
case 0:
|
||||
inst->cfg->netstatus.poll_interval = 4;
|
||||
break;
|
||||
case 1:
|
||||
inst->cfg->netstatus.poll_interval = 8;
|
||||
break;
|
||||
case 2:
|
||||
inst->cfg->netstatus.poll_interval = 32;
|
||||
break;
|
||||
case 3:
|
||||
inst->cfg->netstatus.poll_interval = 64;
|
||||
break;
|
||||
case 4:
|
||||
inst->cfg->netstatus.poll_interval = 256;
|
||||
break;
|
||||
default:
|
||||
inst->cfg->netstatus.poll_interval = 32;
|
||||
}
|
||||
e_config_save_queue();
|
||||
_netstatus_config_updated(inst);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
netstatus_configure(Instance *inst)
|
||||
{
|
||||
Evas_Object *popup, *frame, *box, *o, *group, *lbl;
|
||||
E_Zone *zone = e_zone_current_get();
|
||||
|
||||
popup = elm_popup_add(e_comp->elm);
|
||||
E_EXPAND(popup);
|
||||
elm_popup_allow_events_set(popup, 1);
|
||||
elm_popup_scrollable_set(popup, 1);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
E_FILL(box);
|
||||
evas_object_show(box);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
lbl = elm_label_add(box);
|
||||
evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_style_set(lbl, "marker");
|
||||
elm_object_text_set(lbl, _("NetStatus Configuration"));
|
||||
elm_box_pack_end(box, lbl);
|
||||
evas_object_show(lbl);
|
||||
|
||||
frame = elm_frame_add(box);
|
||||
elm_object_text_set(frame, _("Update Poll Interval"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_box_pack_end(box, frame);
|
||||
evas_object_show(frame);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 0);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Fast (4 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
group = o;
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 1);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Medium (8 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 2);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Normal (32 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 3);
|
||||
elm_radio_group_add(o, group);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Slow (64 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 4);
|
||||
elm_radio_group_add(o, group);
|
||||
E_EXPAND(o);
|
||||
E_ALIGN(o, 0, 0);
|
||||
elm_object_text_set(o, _("Very Slow (256 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _config_changed, inst);
|
||||
evas_object_show(o);
|
||||
|
||||
switch(inst->cfg->netstatus.poll_interval)
|
||||
{
|
||||
case 4:
|
||||
elm_radio_value_set(group, 0);
|
||||
break;
|
||||
case 8:
|
||||
elm_radio_value_set(group, 1);
|
||||
break;
|
||||
case 32:
|
||||
elm_radio_value_set(group, 2);
|
||||
break;
|
||||
case 64:
|
||||
elm_radio_value_set(group, 3);
|
||||
break;
|
||||
case 256:
|
||||
elm_radio_value_set(group, 4);
|
||||
break;
|
||||
default:
|
||||
elm_radio_value_set(group, 2);
|
||||
}
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
|
||||
evas_object_layer_set(popup, E_LAYER_POPUP);
|
||||
evas_object_resize(popup, zone->w / 4, zone->h / 3);
|
||||
e_comp_object_util_center_on_zone(popup, zone);
|
||||
evas_object_show(popup);
|
||||
e_comp_object_util_autoclose(popup, NULL, e_comp_object_util_autoclose_on_escape, NULL);
|
||||
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _config_close, inst);
|
||||
|
||||
return inst->cfg->netstatus.configure = popup;
|
||||
}
|
||||
|
|
@ -24,16 +24,20 @@ _netstatus_proc_getrstatus(Instance *inst)
|
|||
}
|
||||
diffin = tot_in - inst->cfg->netstatus.in;
|
||||
inst->cfg->netstatus.in = tot_in;
|
||||
if (!diffin) return NULL;
|
||||
if (!diffin)
|
||||
{
|
||||
snprintf(rin, sizeof(rin), "%s: 0 B/s", _("Receiving"));
|
||||
return eina_stringshare_add(rin);
|
||||
}
|
||||
else
|
||||
{
|
||||
diffin /= 0.5;
|
||||
if (diffin > 1048576)
|
||||
snprintf(rin, sizeof(rin), "Rx: %.2f MB/s", ((float)diffin / 1048576));
|
||||
snprintf(rin, sizeof(rin), "%s: %.2f MB/s", _("Receiving"), ((float)diffin / 1048576));
|
||||
else if ((diffin > 1024) && (diffin < 1048576))
|
||||
snprintf(rin, sizeof(rin), "Rx: %lu KB/s", (diffin / 1024));
|
||||
snprintf(rin, sizeof(rin), "%s: %lu KB/s", _("Receiving"), (diffin / 1024));
|
||||
else
|
||||
snprintf(rin, sizeof(rin), "Rx: %lu B/s", diffin);
|
||||
snprintf(rin, sizeof(rin), "%s: %lu B/s", _("Receiving"), diffin);
|
||||
}
|
||||
return eina_stringshare_add(rin);
|
||||
}
|
||||
|
@ -62,16 +66,20 @@ const char *
|
|||
}
|
||||
diffout = tot_out - inst->cfg->netstatus.out;
|
||||
inst->cfg->netstatus.out = tot_out;
|
||||
if (!diffout) return NULL;
|
||||
if (!diffout)
|
||||
{
|
||||
snprintf(rout, sizeof(rout), "%s: 0 B/s", _("Sending"));
|
||||
return eina_stringshare_add(rout);
|
||||
}
|
||||
else
|
||||
{
|
||||
diffout /= 0.5;
|
||||
if (diffout > 1048576)
|
||||
snprintf(rout, sizeof(rout), "Tx: %.2f MB/s", ((float)diffout / 1048576));
|
||||
snprintf(rout, sizeof(rout), "%s: %.2f MB/s", _("Sending"), ((float)diffout / 1048576));
|
||||
else if ((diffout > 1024) && (diffout < 1048576))
|
||||
snprintf(rout, sizeof(rout), "Tx: %lu KB/s", (diffout / 1024));
|
||||
snprintf(rout, sizeof(rout), "%s: %lu KB/s", _("Sending"), (diffout / 1024));
|
||||
else
|
||||
snprintf(rout, sizeof(rout), "Tx: %lu B/s", diffout);
|
||||
snprintf(rout, sizeof(rout), "%s: %lu B/s", _("Sending"), diffout);
|
||||
}
|
||||
return eina_stringshare_add(rout);
|
||||
}
|
||||
|
|
|
@ -114,10 +114,21 @@ _conf_item_get(int *id)
|
|||
ci->cpumonitor.poll_interval = 32;
|
||||
ci->cpumonitor.total = 0;
|
||||
ci->cpumonitor.idle = 0;
|
||||
ci->cpumonitor.percent = 0;
|
||||
ci->cpumonitor.popup = NULL;
|
||||
ci->cpumonitor.configure = NULL;
|
||||
ci->memusage.poll_interval = 32;
|
||||
ci->memusage.real = 0;
|
||||
ci->memusage.swap = 0;
|
||||
ci->memusage.popup = NULL;
|
||||
ci->memusage.configure = NULL;
|
||||
ci->netstatus.poll_interval = 32;
|
||||
ci->netstatus.in = 0;
|
||||
ci->netstatus.out = 0;
|
||||
ci->netstatus.instring = NULL;
|
||||
ci->netstatus.outstring = NULL;
|
||||
ci->netstatus.popup = NULL;
|
||||
ci->netstatus.configure = NULL;
|
||||
|
||||
sysinfo_config->items = eina_list_append(sysinfo_config->items, ci);
|
||||
|
||||
|
|
|
@ -178,24 +178,36 @@ struct _Config_Item
|
|||
struct
|
||||
{
|
||||
Evas_Object *o_gadget;
|
||||
Evas_Object *popup;
|
||||
Evas_Object *configure;
|
||||
int poll_interval;
|
||||
int percent;
|
||||
long total;
|
||||
long idle;
|
||||
|
||||
Ecore_Thread *usage_check_thread;
|
||||
Eina_List *cores;
|
||||
} cpumonitor;
|
||||
struct
|
||||
{
|
||||
Evas_Object *o_gadget;
|
||||
Evas_Object *popup;
|
||||
Evas_Object *configure;
|
||||
int poll_interval;
|
||||
int real;
|
||||
int swap;
|
||||
Ecore_Thread *usage_check_thread;
|
||||
} memusage;
|
||||
struct
|
||||
{
|
||||
Evas_Object *o_gadget;
|
||||
Evas_Object *popup;
|
||||
Evas_Object *configure;
|
||||
int poll_interval;
|
||||
long in;
|
||||
long out;
|
||||
Eina_Stringshare *instring;
|
||||
Eina_Stringshare *outstring;
|
||||
Ecore_Thread *usage_check_thread;
|
||||
} netstatus;
|
||||
struct {
|
||||
|
|
Loading…
Reference in New Issue