summaryrefslogtreecommitdiff
path: root/src/modules/sysinfo/cpuclock/cpuclock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/sysinfo/cpuclock/cpuclock.c')
-rw-r--r--src/modules/sysinfo/cpuclock/cpuclock.c95
1 files changed, 71 insertions, 24 deletions
diff --git a/src/modules/sysinfo/cpuclock/cpuclock.c b/src/modules/sysinfo/cpuclock/cpuclock.c
index e786fe6..83890bf 100644
--- a/src/modules/sysinfo/cpuclock/cpuclock.c
+++ b/src/modules/sysinfo/cpuclock/cpuclock.c
@@ -272,7 +272,7 @@ _cpuclock_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UN
272 E_FREE_FUNC(obj, evas_object_del); 272 E_FREE_FUNC(obj, evas_object_del);
273 273
274 inst->cfg->cpuclock.popup = NULL; 274 inst->cfg->cpuclock.popup = NULL;
275 inst->cfg->cpuclock.popup_label = NULL; 275 inst->cfg->cpuclock.popup_pbar = NULL;
276} 276}
277 277
278static void 278static void
@@ -285,9 +285,9 @@ _cpuclock_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
285static Evas_Object * 285static Evas_Object *
286_cpuclock_popup_create(Instance *inst) 286_cpuclock_popup_create(Instance *inst)
287{ 287{
288 Evas_Object *popup, *box, *label; 288 Evas_Object *popup, *table, *label, *pbar;
289 double f = inst->cfg->cpuclock.status->cur_frequency; 289 double f = inst->cfg->cpuclock.status->cur_frequency;
290 char buf[100], *u; 290 char buf[4096], text[4096], *u;
291 291
292 if (f < 1000000) 292 if (f < 1000000)
293 { 293 {
@@ -309,19 +309,33 @@ _cpuclock_popup_create(Instance *inst)
309 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, 309 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
310 _cpuclock_popup_deleted, inst); 310 _cpuclock_popup_deleted, inst);
311 311
312 box = elm_box_add(popup); 312 table = elm_table_add(popup);
313 elm_box_horizontal_set(box, EINA_FALSE); 313 E_EXPAND(table);
314 E_EXPAND(box); E_FILL(box); 314 E_FILL(table);
315 elm_object_content_set(popup, box); 315 elm_object_content_set(popup, table);
316 evas_object_show(box); 316 evas_object_show(table);
317 317
318 label = elm_label_add(box); 318 snprintf(text, sizeof(text), "<big><b>%s</b></big>", _("Frequency"));
319 elm_object_style_set(label, "marker"); 319
320 snprintf(buf, 100, "%s: %1.1f %s", _("Frequency"), f, u); 320 label = elm_label_add(table);
321 elm_object_text_set(label, buf); 321 E_EXPAND(label);
322 elm_box_pack_end(box, label); 322 E_ALIGN(label, 0.5, 0.5);
323 evas_object_show(label); 323 elm_object_text_set(label, text);
324 inst->cfg->cpuclock.popup_label = label; 324 elm_table_pack(table, label, 0, 0, 2, 1);
325 evas_object_show(label);
326
327 snprintf(buf, sizeof(buf), "%1.1f %s (%d %%)", f, u,
328 inst->cfg->cpuclock.percent);
329
330 pbar = elm_progressbar_add(table);
331 E_EXPAND(pbar);
332 E_FILL(pbar);
333 elm_progressbar_span_size_set(pbar, 200 * e_scale);
334 elm_progressbar_value_set(pbar, (float)inst->cfg->cpuclock.percent / 100);
335 elm_progressbar_unit_format_set(pbar, buf);
336 elm_table_pack(table, pbar, 0, 1, 2, 1);
337 evas_object_show(pbar);
338 inst->cfg->cpuclock.popup_pbar = pbar;
325 339
326 e_gadget_util_ctxpopup_place(inst->o_main, popup, 340 e_gadget_util_ctxpopup_place(inst->o_main, popup,
327 inst->cfg->cpuclock.o_gadget); 341 inst->cfg->cpuclock.o_gadget);
@@ -416,7 +430,31 @@ _cpuclock_face_update_current(Instance *inst)
416 edje_object_message_send(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), EDJE_MESSAGE_INT_SET, 3, 430 edje_object_message_send(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), EDJE_MESSAGE_INT_SET, 3,
417 frequency_msg); 431 frequency_msg);
418 E_FREE(frequency_msg); 432 E_FREE(frequency_msg);
419 433 if (inst->cfg->cpuclock.tot_min_frequency == 0)
434 inst->cfg->cpuclock.tot_min_frequency = inst->cfg->cpuclock.status->cur_frequency;
435 if (inst->cfg->cpuclock.status->cur_frequency >
436 inst->cfg->cpuclock.tot_max_frequency)
437 {
438 inst->cfg->cpuclock.tot_max_frequency = inst->cfg->cpuclock.status->cur_frequency;
439 inst->cfg->cpuclock.percent = 100;
440 }
441 if (inst->cfg->cpuclock.status->cur_frequency <
442 inst->cfg->cpuclock.tot_min_frequency)
443 {
444 inst->cfg->cpuclock.tot_min_frequency = inst->cfg->cpuclock.status->cur_frequency;
445 inst->cfg->cpuclock.percent = 0;
446 }
447 if ((inst->cfg->cpuclock.tot_min_frequency > 0) &&
448 (inst->cfg->cpuclock.tot_max_frequency >=
449 inst->cfg->cpuclock.tot_min_frequency))
450 {
451 inst->cfg->cpuclock.percent = ((double)(inst->cfg->cpuclock.status->cur_frequency -
452 inst->cfg->cpuclock.tot_min_frequency) /
453 (double)(inst->cfg->cpuclock.tot_max_frequency -
454 inst->cfg->cpuclock.tot_min_frequency)) * 100;
455 }
456 else
457 inst->cfg->cpuclock.percent = 0;
420 /* BSD crashes here without the if-condition 458 /* BSD crashes here without the if-condition
421 * since it has no governors (yet) */ 459 * since it has no governors (yet) */
422 if (inst->cfg->cpuclock.status->cur_governor) 460 if (inst->cfg->cpuclock.status->cur_governor)
@@ -429,7 +467,7 @@ _cpuclock_face_update_current(Instance *inst)
429 if (inst->cfg->cpuclock.popup) 467 if (inst->cfg->cpuclock.popup)
430 { 468 {
431 double f = inst->cfg->cpuclock.status->cur_frequency; 469 double f = inst->cfg->cpuclock.status->cur_frequency;
432 char buf[100], *u; 470 char buf[4096], *u;
433 471
434 if (f < 1000000) 472 if (f < 1000000)
435 { 473 {
@@ -443,8 +481,11 @@ _cpuclock_face_update_current(Instance *inst)
443 f /= 1000000; 481 f /= 1000000;
444 u = _("GHz"); 482 u = _("GHz");
445 } 483 }
446 snprintf(buf, 100, "%s: %1.1f %s", _("Frequency"), f, u); 484 snprintf(buf, sizeof(buf), "%1.1f %s (%d %%)", f, u,
447 elm_object_text_set(inst->cfg->cpuclock.popup_label, buf); 485 inst->cfg->cpuclock.percent);
486 elm_progressbar_unit_format_set(inst->cfg->cpuclock.popup_pbar, buf);
487 elm_progressbar_value_set(inst->cfg->cpuclock.popup_pbar,
488 (float)inst->cfg->cpuclock.percent / 100);
448 } 489 }
449} 490}
450 491
@@ -954,8 +995,8 @@ _cpuclock_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
954 995
955 if (inst->o_main != event_data) return; 996 if (inst->o_main != event_data) return;
956 997
957 if (inst->cfg->cpuclock.popup_label) 998 if (inst->cfg->cpuclock.popup_pbar)
958 E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del); 999 E_FREE_FUNC(inst->cfg->cpuclock.popup_pbar, evas_object_del);
959 if (inst->cfg->cpuclock.popup) 1000 if (inst->cfg->cpuclock.popup)
960 E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del); 1001 E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
961 if (inst->cfg->cpuclock.configure) 1002 if (inst->cfg->cpuclock.configure)
@@ -988,8 +1029,8 @@ sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
988 Instance *inst = data; 1029 Instance *inst = data;
989 Ecore_Event_Handler *handler; 1030 Ecore_Event_Handler *handler;
990 1031
991 if (inst->cfg->cpuclock.popup_label) 1032 if (inst->cfg->cpuclock.popup_pbar)
992 E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del); 1033 E_FREE_FUNC(inst->cfg->cpuclock.popup_pbar, evas_object_del);
993 if (inst->cfg->cpuclock.popup) 1034 if (inst->cfg->cpuclock.popup)
994 E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del); 1035 E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
995 if (inst->cfg->cpuclock.configure) 1036 if (inst->cfg->cpuclock.configure)
@@ -1017,6 +1058,9 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
1017 1058
1018 if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1; 1059 if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1;
1019 if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101; 1060 if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101;
1061 inst->cfg->cpuclock.percent = 0;
1062 inst->cfg->cpuclock.tot_min_frequency = 0;
1063 inst->cfg->cpuclock.tot_max_frequency = 0;
1020 1064
1021 inst->cfg->cpuclock.o_gadget = elm_layout_add(inst->o_main); 1065 inst->cfg->cpuclock.o_gadget = elm_layout_add(inst->o_main);
1022 if (orient == E_GADGET_SITE_ORIENT_VERTICAL) 1066 if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
@@ -1070,6 +1114,9 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
1070 1114
1071 if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1; 1115 if (inst->cfg->cpuclock.pstate_min == 0) inst->cfg->cpuclock.pstate_min = 1;
1072 if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101; 1116 if (inst->cfg->cpuclock.pstate_max == 0) inst->cfg->cpuclock.pstate_max = 101;
1117 inst->cfg->cpuclock.percent = 0;
1118 inst->cfg->cpuclock.tot_min_frequency = 0;
1119 inst->cfg->cpuclock.tot_max_frequency = 0;
1073 1120
1074 inst->cfg->cpuclock.o_gadget = elm_layout_add(parent); 1121 inst->cfg->cpuclock.o_gadget = elm_layout_add(parent);
1075 e_theme_edje_object_set(inst->cfg->cpuclock.o_gadget, "base/theme/gadget/cpuclock", 1122 e_theme_edje_object_set(inst->cfg->cpuclock.o_gadget, "base/theme/gadget/cpuclock",