diff options
Diffstat (limited to 'src/modules/sysinfo/thermal/thermal.c')
-rw-r--r-- | src/modules/sysinfo/thermal/thermal.c | 71 |
1 files changed, 47 insertions, 24 deletions
diff --git a/src/modules/sysinfo/thermal/thermal.c b/src/modules/sysinfo/thermal/thermal.c index f09d053..a423d67 100644 --- a/src/modules/sysinfo/thermal/thermal.c +++ b/src/modules/sysinfo/thermal/thermal.c | |||
@@ -27,6 +27,7 @@ _thermal_face_level_set(Instance *inst, double level) | |||
27 | if (level < 0.0) level = 0.0; | 27 | if (level < 0.0) level = 0.0; |
28 | else if (level > 1.0) | 28 | else if (level > 1.0) |
29 | level = 1.0; | 29 | level = 1.0; |
30 | inst->cfg->thermal.percent = level * 100; | ||
30 | msg.val = level; | 31 | msg.val = level; |
31 | edje_object_message_send(elm_layout_edje_get(inst->cfg->thermal.o_gadget), EDJE_MESSAGE_FLOAT, 1, &msg); | 32 | edje_object_message_send(elm_layout_edje_get(inst->cfg->thermal.o_gadget), EDJE_MESSAGE_FLOAT, 1, &msg); |
32 | } | 33 | } |
@@ -63,13 +64,18 @@ _thermal_apply(Instance *inst, int temp) | |||
63 | } | 64 | } |
64 | if (inst->cfg->thermal.popup) | 65 | if (inst->cfg->thermal.popup) |
65 | { | 66 | { |
66 | char buf[100]; | 67 | char buf[4096]; |
67 | 68 | ||
68 | if (inst->cfg->thermal.units == FAHRENHEIT) | 69 | if (inst->cfg->thermal.units == FAHRENHEIT) |
69 | snprintf(buf, 100, "%s: %d F", _("Temperature"), (int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32)); | 70 | snprintf(buf, sizeof(buf), "%d F (%d %%)", |
71 | (int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32), | ||
72 | inst->cfg->thermal.percent); | ||
70 | else | 73 | else |
71 | snprintf(buf, 100, "%s: %d C", _("Temperature"), inst->cfg->thermal.temp); | 74 | snprintf(buf, sizeof(buf), "%d C (%d %%)", |
72 | elm_object_text_set(inst->cfg->thermal.popup_label, buf); | 75 | (int)inst->cfg->thermal.temp, |
76 | inst->cfg->thermal.percent); | ||
77 | elm_progressbar_value_set(inst->cfg->thermal.popup_pbar, | ||
78 | (float)inst->cfg->thermal.percent / 100); | ||
73 | } | 79 | } |
74 | } | 80 | } |
75 | 81 | ||
@@ -161,7 +167,7 @@ _thermal_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UNU | |||
161 | E_FREE_FUNC(obj, evas_object_del); | 167 | E_FREE_FUNC(obj, evas_object_del); |
162 | 168 | ||
163 | inst->cfg->thermal.popup = NULL; | 169 | inst->cfg->thermal.popup = NULL; |
164 | inst->cfg->thermal.popup_label = NULL; | 170 | inst->cfg->thermal.popup_pbar = NULL; |
165 | } | 171 | } |
166 | 172 | ||
167 | static void | 173 | static void |
@@ -174,8 +180,8 @@ _thermal_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN | |||
174 | static Evas_Object * | 180 | static Evas_Object * |
175 | _thermal_popup_create(Instance *inst) | 181 | _thermal_popup_create(Instance *inst) |
176 | { | 182 | { |
177 | Evas_Object *popup, *box, *label; | 183 | Evas_Object *popup, *table, *label, *pbar; |
178 | char buf[100]; | 184 | char text[4096], buf[100]; |
179 | 185 | ||
180 | popup = elm_ctxpopup_add(e_comp->elm); | 186 | popup = elm_ctxpopup_add(e_comp->elm); |
181 | elm_object_style_set(popup, "noblock"); | 187 | elm_object_style_set(popup, "noblock"); |
@@ -184,22 +190,37 @@ _thermal_popup_create(Instance *inst) | |||
184 | evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, | 190 | evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, |
185 | _thermal_popup_deleted, inst); | 191 | _thermal_popup_deleted, inst); |
186 | 192 | ||
187 | box = elm_box_add(popup); | 193 | table = elm_table_add(popup); |
188 | elm_box_horizontal_set(box, EINA_FALSE); | 194 | E_EXPAND(table); |
189 | E_EXPAND(box); E_FILL(box); | 195 | E_FILL(table); |
190 | elm_object_content_set(popup, box); | 196 | elm_object_content_set(popup, table); |
191 | evas_object_show(box); | 197 | evas_object_show(table); |
198 | |||
199 | snprintf(text, sizeof(text), "<big><b>%s</b></big>", _("Temperature")); | ||
200 | |||
201 | label = elm_label_add(table); | ||
202 | E_EXPAND(label); E_ALIGN(label, 0.5, 0.5); | ||
203 | elm_object_text_set(label, text); | ||
204 | elm_table_pack(table, label, 0, 0, 2, 1); | ||
205 | evas_object_show(label); | ||
192 | 206 | ||
193 | label = elm_label_add(box); | ||
194 | elm_object_style_set(label, "marker"); | ||
195 | if (inst->cfg->thermal.units == FAHRENHEIT) | 207 | if (inst->cfg->thermal.units == FAHRENHEIT) |
196 | snprintf(buf, 100, "%s: %d F", _("Temperature"), (int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32)); | 208 | snprintf(buf, sizeof(buf), "%d F (%d %%)", |
209 | (int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32), | ||
210 | inst->cfg->thermal.percent); | ||
197 | else | 211 | else |
198 | snprintf(buf, 100, "%s: %d C", _("Temperature"), inst->cfg->thermal.temp); | 212 | snprintf(buf, sizeof(buf), "%d C (%d %%)", |
199 | elm_object_text_set(label, buf); | 213 | (int)inst->cfg->thermal.temp, |
200 | elm_box_pack_end(box, label); | 214 | inst->cfg->thermal.percent); |
201 | evas_object_show(label); | 215 | |
202 | inst->cfg->thermal.popup_label = label; | 216 | pbar = elm_progressbar_add(table); |
217 | E_EXPAND(pbar); E_FILL(pbar); | ||
218 | elm_progressbar_span_size_set(pbar, 200 * e_scale); | ||
219 | elm_progressbar_value_set(pbar, (float)inst->cfg->thermal.percent / 100); | ||
220 | elm_progressbar_unit_format_set(pbar, buf); | ||
221 | elm_table_pack(table, pbar, 0, 1, 2, 1); | ||
222 | evas_object_show(pbar); | ||
223 | inst->cfg->thermal.popup_pbar = pbar; | ||
203 | 224 | ||
204 | e_gadget_util_ctxpopup_place(inst->o_main, popup, | 225 | e_gadget_util_ctxpopup_place(inst->o_main, popup, |
205 | inst->cfg->thermal.o_gadget); | 226 | inst->cfg->thermal.o_gadget); |
@@ -334,8 +355,8 @@ _thermal_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data) | |||
334 | 355 | ||
335 | if (inst->o_main != event_data) return; | 356 | if (inst->o_main != event_data) return; |
336 | 357 | ||
337 | if (inst->cfg->thermal.popup_label) | 358 | if (inst->cfg->thermal.popup_pbar) |
338 | E_FREE_FUNC(inst->cfg->thermal.popup_label, evas_object_del); | 359 | E_FREE_FUNC(inst->cfg->thermal.popup_pbar, evas_object_del); |
339 | if (inst->cfg->thermal.popup) | 360 | if (inst->cfg->thermal.popup) |
340 | E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del); | 361 | E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del); |
341 | if (inst->cfg->thermal.configure) | 362 | if (inst->cfg->thermal.configure) |
@@ -364,8 +385,8 @@ sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN | |||
364 | Instance *inst = data; | 385 | Instance *inst = data; |
365 | Ecore_Event_Handler *handler; | 386 | Ecore_Event_Handler *handler; |
366 | 387 | ||
367 | if (inst->cfg->thermal.popup_label) | 388 | if (inst->cfg->thermal.popup_pbar) |
368 | E_FREE_FUNC(inst->cfg->thermal.popup_label, evas_object_del); | 389 | E_FREE_FUNC(inst->cfg->thermal.popup_pbar, evas_object_del); |
369 | if (inst->cfg->thermal.popup) | 390 | if (inst->cfg->thermal.popup) |
370 | E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del); | 391 | E_FREE_FUNC(inst->cfg->thermal.popup, evas_object_del); |
371 | if (inst->cfg->thermal.configure) | 392 | if (inst->cfg->thermal.configure) |
@@ -389,6 +410,7 @@ _thermal_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) | |||
389 | e_gadget_configure_cb_set(inst->o_main, _thermal_configure_cb); | 410 | e_gadget_configure_cb_set(inst->o_main, _thermal_configure_cb); |
390 | 411 | ||
391 | inst->cfg->thermal.temp = 900; | 412 | inst->cfg->thermal.temp = 900; |
413 | inst->cfg->thermal.percent = 0; | ||
392 | inst->cfg->thermal.have_temp = EINA_FALSE; | 414 | inst->cfg->thermal.have_temp = EINA_FALSE; |
393 | 415 | ||
394 | inst->cfg->thermal.o_gadget = elm_layout_add(inst->o_main); | 416 | inst->cfg->thermal.o_gadget = elm_layout_add(inst->o_main); |
@@ -419,6 +441,7 @@ Evas_Object * | |||
419 | sysinfo_thermal_create(Evas_Object *parent, Instance *inst) | 441 | sysinfo_thermal_create(Evas_Object *parent, Instance *inst) |
420 | { | 442 | { |
421 | inst->cfg->thermal.temp = 900; | 443 | inst->cfg->thermal.temp = 900; |
444 | inst->cfg->thermal.percent = 0; | ||
422 | inst->cfg->thermal.have_temp = EINA_FALSE; | 445 | inst->cfg->thermal.have_temp = EINA_FALSE; |
423 | 446 | ||
424 | inst->cfg->thermal.o_gadget = elm_layout_add(parent); | 447 | inst->cfg->thermal.o_gadget = elm_layout_add(parent); |