Sysinfo: Cpuclock, Netstatus, and Thermal now use progressbars in the popups to unify and match all sysinfo gadgets.

This commit is contained in:
Stephen Houston 2017-09-27 17:19:47 -05:00
parent bb4d69519f
commit fdbf49af1b
5 changed files with 233 additions and 78 deletions

View File

@ -272,7 +272,7 @@ _cpuclock_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UN
E_FREE_FUNC(obj, evas_object_del);
inst->cfg->cpuclock.popup = NULL;
inst->cfg->cpuclock.popup_label = NULL;
inst->cfg->cpuclock.popup_pbar = NULL;
}
static void
@ -285,9 +285,9 @@ _cpuclock_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
static Evas_Object *
_cpuclock_popup_create(Instance *inst)
{
Evas_Object *popup, *box, *label;
Evas_Object *popup, *table, *label, *pbar;
double f = inst->cfg->cpuclock.status->cur_frequency;
char buf[100], *u;
char buf[4096], text[4096], *u;
if (f < 1000000)
{
@ -309,19 +309,33 @@ _cpuclock_popup_create(Instance *inst)
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
_cpuclock_popup_deleted, inst);
box = elm_box_add(popup);
elm_box_horizontal_set(box, EINA_FALSE);
E_EXPAND(box); E_FILL(box);
elm_object_content_set(popup, box);
evas_object_show(box);
table = elm_table_add(popup);
E_EXPAND(table);
E_FILL(table);
elm_object_content_set(popup, table);
evas_object_show(table);
label = elm_label_add(box);
elm_object_style_set(label, "marker");
snprintf(buf, 100, "%s: %1.1f %s", _("Frequency"), f, u);
elm_object_text_set(label, buf);
elm_box_pack_end(box, label);
evas_object_show(label);
inst->cfg->cpuclock.popup_label = label;
snprintf(text, sizeof(text), "<big><b>%s</b></big>", _("Frequency"));
label = elm_label_add(table);
E_EXPAND(label);
E_ALIGN(label, 0.5, 0.5);
elm_object_text_set(label, text);
elm_table_pack(table, label, 0, 0, 2, 1);
evas_object_show(label);
snprintf(buf, sizeof(buf), "%1.1f %s (%d %%)", f, u,
inst->cfg->cpuclock.percent);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->cpuclock.percent / 100);
elm_progressbar_unit_format_set(pbar, buf);
elm_table_pack(table, pbar, 0, 1, 2, 1);
evas_object_show(pbar);
inst->cfg->cpuclock.popup_pbar = pbar;
e_gadget_util_ctxpopup_place(inst->o_main, popup,
inst->cfg->cpuclock.o_gadget);
@ -416,7 +430,31 @@ _cpuclock_face_update_current(Instance *inst)
edje_object_message_send(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), EDJE_MESSAGE_INT_SET, 3,
frequency_msg);
E_FREE(frequency_msg);
if (inst->cfg->cpuclock.tot_min_frequency == 0)
inst->cfg->cpuclock.tot_min_frequency = inst->cfg->cpuclock.status->cur_frequency;
if (inst->cfg->cpuclock.status->cur_frequency >
inst->cfg->cpuclock.tot_max_frequency)
{
inst->cfg->cpuclock.tot_max_frequency = inst->cfg->cpuclock.status->cur_frequency;
inst->cfg->cpuclock.percent = 100;
}
if (inst->cfg->cpuclock.status->cur_frequency <
inst->cfg->cpuclock.tot_min_frequency)
{
inst->cfg->cpuclock.tot_min_frequency = inst->cfg->cpuclock.status->cur_frequency;
inst->cfg->cpuclock.percent = 0;
}
if ((inst->cfg->cpuclock.tot_min_frequency > 0) &&
(inst->cfg->cpuclock.tot_max_frequency >=
inst->cfg->cpuclock.tot_min_frequency))
{
inst->cfg->cpuclock.percent = ((double)(inst->cfg->cpuclock.status->cur_frequency -
inst->cfg->cpuclock.tot_min_frequency) /
(double)(inst->cfg->cpuclock.tot_max_frequency -
inst->cfg->cpuclock.tot_min_frequency)) * 100;
}
else
inst->cfg->cpuclock.percent = 0;
/* BSD crashes here without the if-condition
* since it has no governors (yet) */
if (inst->cfg->cpuclock.status->cur_governor)
@ -429,7 +467,7 @@ _cpuclock_face_update_current(Instance *inst)
if (inst->cfg->cpuclock.popup)
{
double f = inst->cfg->cpuclock.status->cur_frequency;
char buf[100], *u;
char buf[4096], *u;
if (f < 1000000)
{
@ -443,8 +481,11 @@ _cpuclock_face_update_current(Instance *inst)
f /= 1000000;
u = _("GHz");
}
snprintf(buf, 100, "%s: %1.1f %s", _("Frequency"), f, u);
elm_object_text_set(inst->cfg->cpuclock.popup_label, buf);
snprintf(buf, sizeof(buf), "%1.1f %s (%d %%)", f, u,
inst->cfg->cpuclock.percent);
elm_progressbar_unit_format_set(inst->cfg->cpuclock.popup_pbar, buf);
elm_progressbar_value_set(inst->cfg->cpuclock.popup_pbar,
(float)inst->cfg->cpuclock.percent / 100);
}
}
@ -954,8 +995,8 @@ _cpuclock_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
if (inst->o_main != event_data) return;
if (inst->cfg->cpuclock.popup_label)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.popup_pbar)
E_FREE_FUNC(inst->cfg->cpuclock.popup_pbar, evas_object_del);
if (inst->cfg->cpuclock.popup)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.configure)
@ -988,8 +1029,8 @@ sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
Instance *inst = data;
Ecore_Event_Handler *handler;
if (inst->cfg->cpuclock.popup_label)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.popup_pbar)
E_FREE_FUNC(inst->cfg->cpuclock.popup_pbar, evas_object_del);
if (inst->cfg->cpuclock.popup)
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
if (inst->cfg->cpuclock.configure)
@ -1017,6 +1058,9 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1;
if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101;
inst->cfg->cpuclock.percent = 0;
inst->cfg->cpuclock.tot_min_frequency = 0;
inst->cfg->cpuclock.tot_max_frequency = 0;
inst->cfg->cpuclock.o_gadget = elm_layout_add(inst->o_main);
if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
@ -1070,6 +1114,9 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1;
if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101;
inst->cfg->cpuclock.percent = 0;
inst->cfg->cpuclock.tot_min_frequency = 0;
inst->cfg->cpuclock.tot_max_frequency = 0;
inst->cfg->cpuclock.o_gadget = elm_layout_add(parent);
e_theme_edje_object_set(inst->cfg->cpuclock.o_gadget, "base/theme/gadget/cpuclock",

View File

@ -139,13 +139,15 @@ _memusage_popup_create(Instance *inst)
_memusage_popup_deleted, inst);
table = elm_table_add(popup);
E_EXPAND(table); E_FILL(table);
E_EXPAND(table);
E_FILL(table);
elm_object_content_set(popup, table);
evas_object_show(table);
snprintf(buf, sizeof(buf), _("Memory usage (available %ld MB)"),
snprintf(buf, sizeof(buf), _("Memory Usage (Available %ld MB)"),
inst->cfg->memusage.mem_total / 1024);
snprintf(buf2, sizeof(buf2), "<big><b>%s</b></big>", buf);
label = elm_label_add(table);
E_EXPAND(label); E_ALIGN(label, 0.5, 0.5);
elm_object_text_set(label, buf2);
@ -157,8 +159,10 @@ _memusage_popup_create(Instance *inst)
elm_object_text_set(label, _("Used"));
elm_table_pack(table, label, 0, 1, 1, 1);
evas_object_show(label);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_table_pack(table, pbar, 1, 1, 1, 1);
evas_object_show(pbar);
@ -169,8 +173,10 @@ _memusage_popup_create(Instance *inst)
elm_object_text_set(label, _("Buffers"));
elm_table_pack(table, label, 0, 2, 1, 1);
evas_object_show(label);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_table_pack(table, pbar, 1, 2, 1, 1);
evas_object_show(pbar);
@ -181,8 +187,10 @@ _memusage_popup_create(Instance *inst)
elm_object_text_set(label, _("Cached"));
elm_table_pack(table, label, 0, 3, 1, 1);
evas_object_show(label);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_table_pack(table, pbar, 1, 3, 1, 1);
evas_object_show(pbar);
@ -193,24 +201,29 @@ _memusage_popup_create(Instance *inst)
elm_object_text_set(label, _("Shared"));
elm_table_pack(table, label, 0, 4, 1, 1);
evas_object_show(label);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_table_pack(table, pbar, 1, 4, 1, 1);
evas_object_show(pbar);
evas_object_data_set(popup, "mem_shared_pbar", pbar);
snprintf(buf, sizeof(buf), _("Swap usage (available %ld MB)"),
snprintf(buf, sizeof(buf), _("Swap Usage (Available %ld MB)"),
inst->cfg->memusage.swp_total / 1024);
snprintf(buf2, sizeof(buf2), "<big><b>%s</b></big>", buf);
label = elm_label_add(table);
E_EXPAND(label); E_ALIGN(label, 0.5, 0.5);
E_EXPAND(label);
E_ALIGN(label, 0.5, 0.5);
elm_object_text_set(label, buf2);
elm_table_pack(table, label, 0, 5, 2, 1);
evas_object_show(label);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
E_EXPAND(pbar);
E_FILL(pbar);
elm_table_pack(table, pbar, 0, 6, 2, 1);
evas_object_show(pbar);
evas_object_data_set(popup, "swap_pbar", pbar);

View File

@ -41,9 +41,20 @@ _netstatus_face_update(Thread_Config *thc)
if (thc->inst->cfg->netstatus.popup)
{
char text[4096];
snprintf(text, sizeof(text), "%s<ps/>%s", thc->instring, thc->outstring);
elm_object_text_set(thc->inst->cfg->netstatus.popup_label, text);
char buf[4096];
snprintf(buf, sizeof(buf), "%s (%d %%)",
thc->inst->cfg->netstatus.instring,
thc->inst->cfg->netstatus.inpercent);
elm_progressbar_value_set(thc->inst->cfg->netstatus.popup_inpbar,
(float)thc->inst->cfg->netstatus.inpercent / 100);
elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_inpbar, buf);
memset(buf, 0x00, sizeof(buf));
snprintf(buf, sizeof(buf), "%s (%d %%)",
thc->inst->cfg->netstatus.outstring,
thc->inst->cfg->netstatus.outpercent);
elm_progressbar_value_set(thc->inst->cfg->netstatus.popup_outpbar,
(float)thc->inst->cfg->netstatus.outpercent / 100);
elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_outpbar, buf);
}
}
@ -75,10 +86,10 @@ _netstatus_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
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_Object *label, *popup, *table, *pbar;
Evas_Event_Mouse_Down *ev = event_data;
Instance *inst = data;
char text[4096];
char text[4096], buf[4096];
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
if (ev->button != 3)
@ -93,13 +104,59 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
evas_object_smart_callback_add(popup, "dismissed", _netstatus_popup_dismissed, inst);
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _netstatus_popup_deleted, inst);
snprintf(text, sizeof(text), "%s<ps/>%s", inst->cfg->netstatus.instring, inst->cfg->netstatus.outstring);
label = elm_label_add(popup);
elm_object_style_set(label, "marker");
table = elm_table_add(popup);
E_EXPAND(table);
E_FILL(table);
elm_object_content_set(popup, table);
evas_object_show(table);
snprintf(text, sizeof(text), "<big><b>%s</b></big>", _("Network Throughput"));
label = elm_label_add(table);
E_EXPAND(label); E_ALIGN(label, 0.5, 0.5);
elm_object_text_set(label, text);
elm_object_content_set(popup, label);
elm_table_pack(table, label, 0, 0, 2, 1);
evas_object_show(label);
inst->cfg->netstatus.popup_label = label;
label = elm_label_add(table);
E_ALIGN(label, 0.0, 0.5);
elm_object_text_set(label, _("Receiving"));
elm_table_pack(table, label, 0, 1, 1, 1);
evas_object_show(label);
snprintf(buf, sizeof(buf), "%s (%d %%)",
inst->cfg->netstatus.instring,
inst->cfg->netstatus.inpercent);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.inpercent / 100);
elm_table_pack(table, pbar, 1, 1, 1, 1);
evas_object_show(pbar);
inst->cfg->netstatus.popup_inpbar = pbar;
label = elm_label_add(table);
E_ALIGN(label, 0.0, 0.5);
elm_object_text_set(label, _("Sending"));
elm_table_pack(table, label, 0, 2, 1, 1);
evas_object_show(label);
memset(buf, 0x00, sizeof(buf));
snprintf(buf, sizeof(buf), "%s (%d %%)",
inst->cfg->netstatus.outstring,
inst->cfg->netstatus.outpercent);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.outpercent / 100);
elm_progressbar_unit_format_set(pbar, buf);
elm_table_pack(table, pbar, 1, 2, 1, 1);
evas_object_show(pbar);
inst->cfg->netstatus.popup_outpbar = pbar;
e_gadget_util_ctxpopup_place(inst->o_main, popup,
inst->cfg->netstatus.o_gadget);
@ -154,30 +211,30 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
#endif
if (!thc->incurrent)
{
snprintf(rin, sizeof(rin), "%s: 0 B/s", _("Receiving"));
snprintf(rin, sizeof(rin), "0 B/s");
}
else
{
if (thc->incurrent > 1048576)
snprintf(rin, sizeof(rin), "%s: %.2f MB/s", _("Receiving"), ((float)thc->incurrent / 1048576));
snprintf(rin, sizeof(rin), "%.2f MB/s", ((float)thc->incurrent / 1048576));
else if ((thc->incurrent > 1024) && (thc->incurrent < 1048576))
snprintf(rin, sizeof(rin), "%s: %lu KB/s", _("Receiving"), (thc->incurrent / 1024));
snprintf(rin, sizeof(rin), "%lu KB/s", (thc->incurrent / 1024));
else
snprintf(rin, sizeof(rin), "%s: %lu B/s", _("Receiving"), thc->incurrent);
snprintf(rin, sizeof(rin), "%lu B/s", thc->incurrent);
}
eina_stringshare_replace(&thc->instring, rin);
if (!thc->outcurrent)
{
snprintf(rout, sizeof(rout), "%s: 0 B/s", _("Sending"));
snprintf(rout, sizeof(rout), "0 B/s");
}
else
{
if (thc->outcurrent > 1048576)
snprintf(rout, sizeof(rout), "%s: %.2f MB/s", _("Sending"), ((float)thc->outcurrent / 1048576));
snprintf(rout, sizeof(rout), "%.2f MB/s", ((float)thc->outcurrent / 1048576));
else if ((thc->outcurrent > 1024) && (thc->outcurrent < 1048576))
snprintf(rout, sizeof(rout), "%s: %lu KB/s", _("Sending"), (thc->outcurrent / 1024));
snprintf(rout, sizeof(rout), "%lu KB/s", (thc->outcurrent / 1024));
else
snprintf(rout, sizeof(rout), "%s: %lu B/s", _("Sending"), thc->outcurrent);
snprintf(rout, sizeof(rout), "%lu B/s", thc->outcurrent);
}
eina_stringshare_replace(&thc->outstring, rout);
ecore_thread_feedback(th, NULL);
@ -199,6 +256,8 @@ _netstatus_cb_usage_check_notify(void *data,
eina_stringshare_replace(&thc->inst->cfg->netstatus.instring, thc->instring);
eina_stringshare_replace(&thc->inst->cfg->netstatus.outstring, thc->outstring);
thc->inst->cfg->netstatus.inpercent = thc->inpercent;
thc->inst->cfg->netstatus.outpercent = thc->outpercent;
_netstatus_face_update(thc);
}
@ -346,8 +405,11 @@ _netstatus_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED
e_gadget_configure_cb_set(inst->o_main, _netstatus_configure_cb);
inst->cfg->netstatus.popup = NULL;
inst->cfg->netstatus.instring = NULL;
inst->cfg->netstatus.outstring = NULL;
inst->cfg->netstatus.inpercent = 0;
inst->cfg->netstatus.outpercent = 0;
inst->cfg->netstatus.o_gadget = elm_layout_add(inst->o_main);
if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
@ -377,6 +439,9 @@ sysinfo_netstatus_create(Evas_Object *parent, Instance *inst)
inst->cfg->netstatus.popup = NULL;
inst->cfg->netstatus.instring = NULL;
inst->cfg->netstatus.outstring = NULL;
inst->cfg->netstatus.inpercent = 0;
inst->cfg->netstatus.outpercent = 0;
inst->cfg->netstatus.o_gadget = elm_layout_add(parent);
e_theme_edje_object_set(inst->cfg->netstatus.o_gadget, "base/theme/gadget/netstatus",
"e/gadget/netstatus/main");

View File

@ -160,11 +160,12 @@ struct _Config_Item
Evas_Object *o_gadget;
Evas_Object *configure;
Evas_Object *popup;
Evas_Object *popup_label;
Evas_Object *popup_pbar;
int poll_interval;
int low, high;
int sensor_type;
int temp;
int percent;
const char *sensor_name;
Unit units;
#if defined(HAVE_EEZE)
@ -182,11 +183,14 @@ struct _Config_Item
{
Evas_Object *o_gadget;
Evas_Object *popup;
Evas_Object *popup_label;
Evas_Object *popup_pbar;
Evas_Object *configure;
int poll_interval;
int restore_governor;
int auto_powersave;
int percent;
int tot_min_frequency;
int tot_max_frequency;
const char *powersave_governor;
const char *governor;
int pstate_min;
@ -232,12 +236,15 @@ struct _Config_Item
{
Evas_Object *o_gadget;
Evas_Object *popup;
Evas_Object *popup_label;
Evas_Object *popup_inpbar;
Evas_Object *popup_outpbar;
Evas_Object *configure;
Eina_Bool automax;
Netstatus_Unit receive_units;
Netstatus_Unit send_units;
int poll_interval;
int inpercent;
int outpercent;
unsigned long inmax;
unsigned long outmax;
Ecore_Thread *usage_check_thread;

View File

@ -27,6 +27,7 @@ _thermal_face_level_set(Instance *inst, double level)
if (level < 0.0) level = 0.0;
else if (level > 1.0)
level = 1.0;
inst->cfg->thermal.percent = level * 100;
msg.val = level;
edje_object_message_send(elm_layout_edje_get(inst->cfg->thermal.o_gadget), EDJE_MESSAGE_FLOAT, 1, &msg);
}
@ -63,13 +64,18 @@ _thermal_apply(Instance *inst, int temp)
}
if (inst->cfg->thermal.popup)
{
char buf[100];
char buf[4096];
if (inst->cfg->thermal.units == FAHRENHEIT)
snprintf(buf, 100, "%s: %d F", _("Temperature"), (int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32));
snprintf(buf, sizeof(buf), "%d F (%d %%)",
(int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32),
inst->cfg->thermal.percent);
else
snprintf(buf, 100, "%s: %d C", _("Temperature"), inst->cfg->thermal.temp);
elm_object_text_set(inst->cfg->thermal.popup_label, buf);
snprintf(buf, sizeof(buf), "%d C (%d %%)",
(int)inst->cfg->thermal.temp,
inst->cfg->thermal.percent);
elm_progressbar_value_set(inst->cfg->thermal.popup_pbar,
(float)inst->cfg->thermal.percent / 100);
}
}
@ -161,7 +167,7 @@ _thermal_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UNU
E_FREE_FUNC(obj, evas_object_del);
inst->cfg->thermal.popup = NULL;
inst->cfg->thermal.popup_label = NULL;
inst->cfg->thermal.popup_pbar = NULL;
}
static void
@ -174,8 +180,8 @@ _thermal_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
static Evas_Object *
_thermal_popup_create(Instance *inst)
{
Evas_Object *popup, *box, *label;
char buf[100];
Evas_Object *popup, *table, *label, *pbar;
char text[4096], buf[100];
popup = elm_ctxpopup_add(e_comp->elm);
elm_object_style_set(popup, "noblock");
@ -184,22 +190,37 @@ _thermal_popup_create(Instance *inst)
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
_thermal_popup_deleted, inst);
box = elm_box_add(popup);
elm_box_horizontal_set(box, EINA_FALSE);
E_EXPAND(box); E_FILL(box);
elm_object_content_set(popup, box);
evas_object_show(box);
table = elm_table_add(popup);
E_EXPAND(table);
E_FILL(table);
elm_object_content_set(popup, table);
evas_object_show(table);
label = elm_label_add(box);
elm_object_style_set(label, "marker");
if (inst->cfg->thermal.units == FAHRENHEIT)
snprintf(buf, 100, "%s: %d F", _("Temperature"), (int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32));
else
snprintf(buf, 100, "%s: %d C", _("Temperature"), inst->cfg->thermal.temp);
elm_object_text_set(label, buf);
elm_box_pack_end(box, label);
snprintf(text, sizeof(text), "<big><b>%s</b></big>", _("Temperature"));
label = elm_label_add(table);
E_EXPAND(label); E_ALIGN(label, 0.5, 0.5);
elm_object_text_set(label, text);
elm_table_pack(table, label, 0, 0, 2, 1);
evas_object_show(label);
inst->cfg->thermal.popup_label = label;
if (inst->cfg->thermal.units == FAHRENHEIT)
snprintf(buf, sizeof(buf), "%d F (%d %%)",
(int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32),
inst->cfg->thermal.percent);
else
snprintf(buf, sizeof(buf), "%d C (%d %%)",
(int)inst->cfg->thermal.temp,
inst->cfg->thermal.percent);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->thermal.percent / 100);
elm_progressbar_unit_format_set(pbar, buf);
elm_table_pack(table, pbar, 0, 1, 2, 1);
evas_object_show(pbar);
inst->cfg->thermal.popup_pbar = pbar;
e_gadget_util_ctxpopup_place(inst->o_main, popup,
inst->cfg->thermal.o_gadget);
@ -334,8 +355,8 @@ _thermal_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
if (inst->o_main != event_data) return;
if (inst->cfg->thermal.popup_label)
E_FREE_FUNC(inst->cfg->thermal.popup_label, evas_object_del);
if (inst->cfg->thermal.popup_pbar)
E_FREE_FUNC(inst->cfg->thermal.popup_pbar, evas_object_del);
if (inst->cfg->thermal.popup)
E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del);
if (inst->cfg->thermal.configure)
@ -364,8 +385,8 @@ sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
Instance *inst = data;
Ecore_Event_Handler *handler;
if (inst->cfg->thermal.popup_label)
E_FREE_FUNC(inst->cfg->thermal.popup_label, evas_object_del);
if (inst->cfg->thermal.popup_pbar)
E_FREE_FUNC(inst->cfg->thermal.popup_pbar, evas_object_del);
if (inst->cfg->thermal.popup)
E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del);
if (inst->cfg->thermal.configure)
@ -389,6 +410,7 @@ _thermal_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
e_gadget_configure_cb_set(inst->o_main, _thermal_configure_cb);
inst->cfg->thermal.temp = 900;
inst->cfg->thermal.percent = 0;
inst->cfg->thermal.have_temp = EINA_FALSE;
inst->cfg->thermal.o_gadget = elm_layout_add(inst->o_main);
@ -419,6 +441,7 @@ Evas_Object *
sysinfo_thermal_create(Evas_Object *parent, Instance *inst)
{
inst->cfg->thermal.temp = 900;
inst->cfg->thermal.percent = 0;
inst->cfg->thermal.have_temp = EINA_FALSE;
inst->cfg->thermal.o_gadget = elm_layout_add(parent);