Enlightenment: Sysinfo Gadget - Show real time data in popups and fix sizing of memusage and cpumonitor.

This commit is contained in:
Stephen 'Okra' Houston 2017-01-26 14:06:56 -06:00
parent f1b0cfcdea
commit c06e36fa2a
4 changed files with 54 additions and 89 deletions

View File

@ -26,6 +26,12 @@ _cpumonitor_face_update(Instance *inst)
usage_msg);
free(usage_msg);
}
if (inst->cfg->cpumonitor.popup)
{
char text[4096];
snprintf(text, sizeof(text), "%s: %d%%", _("Total CPU Usage"), inst->cfg->cpumonitor.percent);
elm_object_text_set(inst->cfg->cpumonitor.popup_label, text);
}
}
static Evas_Object *
@ -81,7 +87,8 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
elm_object_text_set(label, text);
elm_object_content_set(popup, label);
evas_object_show(label);
inst->cfg->cpumonitor.popup_label = 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);
@ -103,6 +110,16 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
}
}
static void
_cpumonitor_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
{
Evas_Coord w, h;
Instance *inst = data;
evas_object_geometry_get(inst->cfg->cpumonitor.o_gadget, 0, 0, &w, &h);
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
}
static void
_cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th)
{
@ -243,52 +260,6 @@ sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
}
}
static void
_cpumonitor_eval_instance_aspect(Instance *inst)
{
Evas_Coord w, h;
Evas_Coord sw = 1, sh = 1;
Evas_Object *owner, *ed;
CPU_Core *first_core;
int num_cores = eina_list_count(inst->cfg->cpumonitor.cores);
if (num_cores < 1)
return;
if (!inst->o_main)
return;
owner = e_gadget_site_get(inst->o_main);
if (!owner)
return;
switch (e_gadget_site_orient_get(owner))
{
case E_GADGET_SITE_ORIENT_HORIZONTAL:
case E_GADGET_SITE_ORIENT_NONE:
evas_object_geometry_get(owner, NULL, NULL, NULL, &sh);
break;
case E_GADGET_SITE_ORIENT_VERTICAL:
evas_object_geometry_get(owner, NULL, NULL, &sw, NULL);
break;
default:
sw = sh = 48;
break;
}
first_core = eina_list_nth(inst->cfg->cpumonitor.cores, 0);
evas_object_resize(first_core->layout, sw, sh);
ed = elm_layout_edje_get(first_core->layout);
edje_object_parts_extends_calc(ed, NULL, NULL, &w, &h);
if (e_gadget_site_orient_get(owner) == E_GADGET_SITE_ORIENT_VERTICAL)
h *= num_cores;
else
w *= num_cores;
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
}
static void
_cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
{
@ -299,6 +270,7 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
inst->cfg->cpumonitor.o_gadget = elm_box_add(inst->o_main);
elm_box_padding_set(inst->cfg->cpumonitor.o_gadget, 0, 0);
elm_box_homogeneous_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE);
if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_FALSE);
else
@ -307,10 +279,10 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
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_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_RESIZE, _cpumonitor_resize_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);
_cpumonitor_eval_instance_aspect(inst);
}
Evas_Object *
@ -318,12 +290,12 @@ sysinfo_cpumonitor_create(Evas_Object *parent, Instance *inst)
{
inst->cfg->cpumonitor.o_gadget = elm_box_add(parent);
elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE);
elm_box_homogeneous_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);
return inst->cfg->cpumonitor.o_gadget;
}

View File

@ -23,6 +23,14 @@ _memusage_face_update(Instance *inst, int mem, int swap)
edje_object_message_send(elm_layout_edje_get(inst->cfg->memusage.o_gadget),
EDJE_MESSAGE_INT_SET, 1, msg);
free(msg);
if (inst->cfg->memusage.popup)
{
char text[4096];
snprintf(text, sizeof(text), "%s: %d%%<br>%s: %d%%", _("Total Memory Usage"),
inst->cfg->memusage.real, _("Total Swap Usage"), inst->cfg->memusage.swap);
elm_object_text_set(inst->cfg->memusage.popup_label, text);
}
}
static Evas_Object *
@ -79,6 +87,7 @@ _memusage_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
elm_object_text_set(label, text);
elm_object_content_set(popup, label);
evas_object_show(label);
inst->cfg->memusage.popup_label = label;
e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
evas_object_show(popup);
@ -101,6 +110,17 @@ _memusage_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
}
}
static void
_memusage_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
{
Evas_Coord w, h;
Instance *inst = data;
evas_object_geometry_get(inst->cfg->memusage.o_gadget, 0, 0, &w, &h);
if (inst->cfg->esm == E_SYSINFO_MODULE_MEMUSAGE)
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
}
static void
_memusage_cb_usage_check_main(void *data, Ecore_Thread *th)
{
@ -196,44 +216,6 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
}
}
static void
_memusage_eval_instance_aspect(Instance *inst)
{
Evas_Coord w, h;
Evas_Coord sw = 0, sh = 0;
Evas_Object *owner, *ed;
if (!inst->o_main)
return;
owner = e_gadget_site_get(inst->o_main);
if (!owner)
return;
switch (e_gadget_site_orient_get(owner))
{
case E_GADGET_SITE_ORIENT_HORIZONTAL:
case E_GADGET_SITE_ORIENT_NONE:
evas_object_geometry_get(owner, NULL, NULL, NULL, &sh);
sw = sh;
break;
case E_GADGET_SITE_ORIENT_VERTICAL:
evas_object_geometry_get(owner, NULL, NULL, &sw, NULL);
sh = sw;
break;
default:
sw = sh = 48;
break;
}
evas_object_resize(inst->cfg->memusage.o_gadget, sw, sh);
ed = elm_layout_edje_get(inst->cfg->memusage.o_gadget);
edje_object_parts_extends_calc(ed, NULL, NULL, &w, &h);
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
}
static void
_memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
{
@ -256,9 +238,9 @@ _memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
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_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_RESIZE, _memusage_resize_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);
_memusage_config_updated(inst);
}
@ -271,8 +253,8 @@ sysinfo_memusage_create(Evas_Object *parent, Instance *inst)
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_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_RESIZE, _memusage_resize_cb, inst);
evas_object_show(inst->cfg->memusage.o_gadget);
_memusage_eval_instance_aspect(inst);
_memusage_config_updated(inst);
return inst->cfg->memusage.o_gadget;

View File

@ -27,6 +27,13 @@ _netstatus_face_update(Instance *inst)
edje_object_message_send(elm_layout_edje_get(inst->cfg->netstatus.o_gadget),
EDJE_MESSAGE_INT_SET, 1, msg);
free(msg);
if (inst->cfg->netstatus.popup)
{
char text[4096];
snprintf(text, sizeof(text), "%s<br>%s", inst->cfg->netstatus.instring, inst->cfg->netstatus.outstring);
elm_object_text_set(inst->cfg->netstatus.popup_label, text);
}
}
static Evas_Object *
@ -82,6 +89,7 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
elm_object_text_set(label, text);
elm_object_content_set(popup, label);
evas_object_show(label);
inst->cfg->netstatus.popup_label = label;
e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
evas_object_show(popup);

View File

@ -189,6 +189,7 @@ struct _Config_Item
{
Evas_Object *o_gadget;
Evas_Object *popup;
Evas_Object *popup_label;
Evas_Object *configure;
int poll_interval;
int percent;
@ -202,6 +203,7 @@ struct _Config_Item
{
Evas_Object *o_gadget;
Evas_Object *popup;
Evas_Object *popup_label;
Evas_Object *configure;
int poll_interval;
int real;
@ -212,6 +214,7 @@ struct _Config_Item
{
Evas_Object *o_gadget;
Evas_Object *popup;
Evas_Object *popup_label;
Evas_Object *configure;
Eina_Bool automax;
Netstatus_Unit receive_units;