forked from enlightenment/enlightenment
Sysinfo - Cpuclock: Add the left click info and right click config popup.
This commit is contained in:
parent
ae26e913ca
commit
d03c254f5e
|
@ -25,6 +25,7 @@ src_modules_sysinfo_module_la_SOURCES = src/modules/sysinfo/mod.c \
|
|||
src/modules/sysinfo/cpuclock/cpuclock.h \
|
||||
src/modules/sysinfo/cpuclock/cpuclock.c \
|
||||
src/modules/sysinfo/cpuclock/cpuclock_sysfs.c \
|
||||
src/modules/sysinfo/cpuclock/cpuclock_config.c \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor.h \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor.c \
|
||||
src/modules/sysinfo/cpumonitor/cpumonitor_config.c \
|
||||
|
|
|
@ -120,7 +120,7 @@ _cpuclock_set_governor(const char *governor)
|
|||
ecore_thread_run(_cpuclock_set_thread_governor, _cpuclock_set_thread_done, NULL, governor);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
_cpuclock_set_frequency(int frequency)
|
||||
{
|
||||
char buf[4096];
|
||||
|
@ -259,6 +259,106 @@ _cpuclock_event_cb_powersave(void *data, int type, void *event)
|
|||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_cpuclock_configure_cb(Evas_Object *g)
|
||||
{
|
||||
Instance *inst = evas_object_data_get(g, "Instance");
|
||||
|
||||
if (!sysinfo_config) return NULL;
|
||||
if (inst->cfg->cpuclock.popup) return NULL;
|
||||
return cpuclock_configure(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_cpuclock_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
|
||||
inst->cfg->cpuclock.popup = NULL;
|
||||
inst->cfg->cpuclock.popup_label = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_cpuclock_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
inst->cfg->cpuclock.popup = NULL;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_cpuclock_popup_create(Instance *inst)
|
||||
{
|
||||
Evas_Object *popup, *box, *label;
|
||||
double f = inst->cfg->cpuclock.status->cur_frequency;
|
||||
char buf[100];
|
||||
|
||||
if (f < 1000000)
|
||||
{
|
||||
f += 500;
|
||||
f /= 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
f += 50000;
|
||||
f /= 1000000;
|
||||
}
|
||||
|
||||
popup = elm_ctxpopup_add(e_comp->elm);
|
||||
elm_object_style_set(popup, "noblock");
|
||||
evas_object_smart_callback_add(popup, "dismissed",
|
||||
_cpuclock_popup_dismissed, 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);
|
||||
|
||||
label = elm_label_add(box);
|
||||
elm_object_style_set(label, "marker");
|
||||
snprintf(buf, 100, "%s: %1.1f", _("Frequency"), f);
|
||||
elm_object_text_set(label, buf);
|
||||
elm_box_pack_end(box, label);
|
||||
evas_object_show(label);
|
||||
inst->cfg->cpuclock.popup_label = label;
|
||||
|
||||
e_gadget_util_ctxpopup_place(inst->o_main, popup,
|
||||
inst->cfg->cpuclock.o_gadget);
|
||||
evas_object_show(popup);
|
||||
|
||||
return popup;
|
||||
}
|
||||
|
||||
static void
|
||||
_cpuclock_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
||||
{
|
||||
Evas_Event_Mouse_Down *ev = event_data;
|
||||
Instance *inst = data;
|
||||
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button != 3)
|
||||
{
|
||||
if (inst->cfg->cpuclock.popup)
|
||||
elm_ctxpopup_dismiss(inst->cfg->cpuclock.popup);
|
||||
else
|
||||
inst->cfg->cpuclock.popup = _cpuclock_popup_create(inst);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inst->cfg->cpuclock.popup)
|
||||
elm_ctxpopup_dismiss(inst->cfg->cpuclock.popup);
|
||||
if (!sysinfo_config) return;
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
if (inst->cfg->esm != E_SYSINFO_MODULE_CPUCLOCK)
|
||||
cpuclock_configure(inst);
|
||||
else
|
||||
e_gadget_configure(inst->o_main);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_cpuclock_config_updated(Instance *inst)
|
||||
{
|
||||
|
@ -318,6 +418,25 @@ _cpuclock_face_update_current(Instance *inst)
|
|||
edje_object_message_send(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), EDJE_MESSAGE_STRING, 4,
|
||||
&governor_msg);
|
||||
}
|
||||
|
||||
if (inst->cfg->cpuclock.popup)
|
||||
{
|
||||
double f = inst->cfg->cpuclock.status->cur_frequency;
|
||||
char buf[100];
|
||||
|
||||
if (f < 1000000)
|
||||
{
|
||||
f += 500;
|
||||
f /= 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
f += 50000;
|
||||
f /= 1000000;
|
||||
}
|
||||
snprintf(buf, 100, "%s: %1.1f", _("Frequency"), f);
|
||||
elm_object_text_set(inst->cfg->cpuclock.popup_label, buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -792,6 +911,14 @@ _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)
|
||||
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
|
||||
|
||||
if (inst->cfg->cpuclock.configure)
|
||||
E_FREE_FUNC(inst->cfg->cpuclock.configure, evas_object_del);
|
||||
|
||||
if (inst->cfg->cpuclock.handler)
|
||||
ecore_event_handler_del(inst->cfg->cpuclock.handler);
|
||||
|
||||
|
@ -816,6 +943,14 @@ sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
|
|||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->cfg->cpuclock.popup_label)
|
||||
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
|
||||
if (inst->cfg->cpuclock.popup)
|
||||
E_FREE_FUNC(inst->cfg->cpuclock.popup, evas_object_del);
|
||||
|
||||
if (inst->cfg->cpuclock.configure)
|
||||
E_FREE_FUNC(inst->cfg->cpuclock.configure, evas_object_del);
|
||||
|
||||
if (inst->cfg->cpuclock.handler)
|
||||
ecore_event_handler_del(inst->cfg->cpuclock.handler);
|
||||
|
||||
|
@ -835,6 +970,9 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|||
{
|
||||
Instance *inst = data;
|
||||
E_Gadget_Site_Orient orient = e_gadget_site_orient_get(e_gadget_site_get(inst->o_main));
|
||||
Eina_List *l = NULL;
|
||||
|
||||
e_gadget_configure_cb_set(inst->o_main, _cpuclock_configure_cb);
|
||||
|
||||
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;
|
||||
|
@ -857,6 +995,9 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|||
_cpuclock_face_cb_set_frequency, inst);
|
||||
evas_object_event_callback_add(inst->cfg->cpuclock.o_gadget, EVAS_CALLBACK_RESIZE, _cpuclock_resize_cb, inst);
|
||||
elm_box_pack_end(inst->o_main, inst->cfg->cpuclock.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->cpuclock.o_gadget,
|
||||
EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_cpuclock_mouse_down_cb, inst);
|
||||
evas_object_show(inst->cfg->cpuclock.o_gadget);
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created", _cpuclock_created_cb, data);
|
||||
inst->cfg->cpuclock.status = _cpuclock_status_new();
|
||||
|
@ -865,11 +1006,24 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|||
inst->cfg->cpuclock.handler = ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE,
|
||||
_cpuclock_event_cb_powersave, inst);
|
||||
_cpuclock_config_updated(inst);
|
||||
if ((inst->cfg->cpuclock.restore_governor) && (inst->cfg->cpuclock.governor))
|
||||
{
|
||||
for (l = inst->cfg->cpuclock.status->governors; l; l = l->next)
|
||||
{
|
||||
if (!strcmp(l->data, inst->cfg->cpuclock.governor))
|
||||
{
|
||||
_cpuclock_set_governor(inst->cfg->cpuclock.governor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
|
||||
{
|
||||
Eina_List *l = NULL;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -878,6 +1032,9 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
|
|||
"e/gadget/cpuclock/main");
|
||||
E_EXPAND(inst->cfg->cpuclock.o_gadget);
|
||||
E_FILL(inst->cfg->cpuclock.o_gadget);
|
||||
evas_object_event_callback_add(inst->cfg->cpuclock.o_gadget,
|
||||
EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_cpuclock_mouse_down_cb, inst);
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), "e,action,governor,next", "*",
|
||||
_cpuclock_face_cb_set_governor, inst);
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(inst->cfg->cpuclock.o_gadget), "e,action,frequency,increase", "*",
|
||||
|
@ -892,6 +1049,17 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
|
|||
inst->cfg->cpuclock.handler = ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE,
|
||||
_cpuclock_event_cb_powersave, inst);
|
||||
_cpuclock_config_updated(inst);
|
||||
if ((inst->cfg->cpuclock.restore_governor) && (inst->cfg->cpuclock.governor))
|
||||
{
|
||||
for (l = inst->cfg->cpuclock.status->governors; l; l = l->next)
|
||||
{
|
||||
if (!strcmp(l->data, inst->cfg->cpuclock.governor))
|
||||
{
|
||||
_cpuclock_set_governor(inst->cfg->cpuclock.governor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inst->cfg->cpuclock.o_gadget;
|
||||
}
|
||||
|
@ -923,6 +1091,7 @@ _conf_item_get(int *id)
|
|||
ci->cpuclock.governor = NULL;
|
||||
ci->cpuclock.pstate_min = 1;
|
||||
ci->cpuclock.pstate_max = 101;
|
||||
ci->cpuclock.configure = NULL;
|
||||
|
||||
sysinfo_config->items = eina_list_append(sysinfo_config->items, ci);
|
||||
|
||||
|
@ -939,6 +1108,7 @@ cpuclock_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_U
|
|||
*id = inst->cfg->id;
|
||||
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", _cpuclock_created_cb, inst);
|
||||
evas_object_smart_callback_add(parent, "gadget_removed", _cpuclock_removed_cb, inst);
|
||||
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_cpuclock_remove, inst);
|
||||
|
|
|
@ -3,7 +3,29 @@
|
|||
|
||||
#include "../sysinfo.h"
|
||||
|
||||
typedef struct _Cpuclock_Config Cpuclock_Config;
|
||||
|
||||
struct _Cpuclock_Config
|
||||
{
|
||||
Instance *inst;
|
||||
Evas_Object *max;
|
||||
Evas_Object *min;
|
||||
Evas_Object *general;
|
||||
Evas_Object *policy;
|
||||
Evas_Object *saving;
|
||||
Evas_Object *freq;
|
||||
Evas_Object *ps;
|
||||
Eina_List *powersaves;
|
||||
Eina_Bool frequencies;
|
||||
Eina_Bool pstate;
|
||||
};
|
||||
|
||||
|
||||
Evas_Object *cpuclock_configure(Instance *inst);
|
||||
void _cpuclock_config_updated(Instance *inst);
|
||||
void _cpuclock_set_governor(const char *governor);
|
||||
void _cpuclock_set_frequency(int frequency);
|
||||
void _cpuclock_set_pstate(int min, int max, int turbo);
|
||||
int _cpuclock_sysfs_setall(const char *control, const char *value);
|
||||
int _cpuclock_sysfs_set(const char *control, const char *value);
|
||||
int _cpuclock_sysfs_pstate(int min, int max, int turbo);
|
||||
|
|
|
@ -0,0 +1,617 @@
|
|||
#include "cpuclock.h"
|
||||
|
||||
static void
|
||||
_config_close(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
|
||||
E_FREE_FUNC(inst->cfg->cpuclock.configure, evas_object_del);
|
||||
E_FREE_FUNC(cc->powersaves, eina_list_free);
|
||||
E_FREE_FUNC(cc, free);
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_config_show_general(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
|
||||
evas_object_hide(cc->policy);
|
||||
evas_object_hide(cc->saving);
|
||||
if (cc->pstate)
|
||||
evas_object_hide(cc->ps);
|
||||
if (cc->frequencies)
|
||||
evas_object_hide(cc->freq);
|
||||
evas_object_show(cc->general);
|
||||
}
|
||||
|
||||
static void
|
||||
_config_show_policy(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
|
||||
evas_object_hide(cc->general);
|
||||
evas_object_hide(cc->saving);
|
||||
if (cc->pstate)
|
||||
evas_object_hide(cc->ps);
|
||||
if (cc->frequencies)
|
||||
evas_object_hide(cc->freq);
|
||||
evas_object_show(cc->policy);
|
||||
}
|
||||
|
||||
static void
|
||||
_config_show_saving(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
|
||||
evas_object_hide(cc->general);
|
||||
evas_object_hide(cc->policy);
|
||||
if (cc->pstate)
|
||||
evas_object_hide(cc->ps);
|
||||
if (cc->frequencies)
|
||||
evas_object_hide(cc->freq);
|
||||
evas_object_show(cc->saving);
|
||||
}
|
||||
|
||||
static void
|
||||
_config_show_frequencies(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
|
||||
evas_object_hide(cc->general);
|
||||
evas_object_hide(cc->policy);
|
||||
evas_object_hide(cc->saving);
|
||||
if (cc->pstate)
|
||||
evas_object_hide(cc->ps);
|
||||
evas_object_show(cc->freq);
|
||||
}
|
||||
|
||||
static void
|
||||
_config_show_pstate(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
|
||||
evas_object_hide(cc->general);
|
||||
evas_object_hide(cc->policy);
|
||||
evas_object_hide(cc->saving);
|
||||
if (cc->frequencies)
|
||||
evas_object_hide(cc->freq);
|
||||
evas_object_show(cc->ps);
|
||||
}
|
||||
|
||||
static void
|
||||
_update_max_power(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
int value = elm_slider_value_get(cc->max);
|
||||
|
||||
inst->cfg->cpuclock.pstate_max = value;
|
||||
_cpuclock_set_pstate(inst->cfg->cpuclock.pstate_min - 1,
|
||||
inst->cfg->cpuclock.pstate_max - 1, inst->cfg->cpuclock.status->pstate_turbo);
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_update_min_power(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
int value = elm_slider_value_get(cc->min);
|
||||
|
||||
inst->cfg->cpuclock.pstate_min = value;
|
||||
_cpuclock_set_pstate(inst->cfg->cpuclock.pstate_min - 1,
|
||||
inst->cfg->cpuclock.pstate_max - 1, inst->cfg->cpuclock.status->pstate_turbo);
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_auto_powersave(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
Eina_List *l = NULL;
|
||||
Evas_Object *o = NULL;
|
||||
|
||||
inst->cfg->cpuclock.auto_powersave = elm_check_state_get(obj);
|
||||
EINA_LIST_FOREACH(cc->powersaves, l, o)
|
||||
elm_object_disabled_set(o, inst->cfg->cpuclock.auto_powersave);
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_restore_governor(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
|
||||
inst->cfg->cpuclock.restore_governor = elm_check_state_get(obj);
|
||||
if ((!inst->cfg->cpuclock.governor) ||
|
||||
(strcmp(inst->cfg->cpuclock.status->cur_governor, inst->cfg->cpuclock.governor)))
|
||||
{
|
||||
eina_stringshare_replace(&inst->cfg->cpuclock.governor, inst->cfg->cpuclock.status->cur_governor);
|
||||
}
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_frequency_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *value = elm_object_text_get(obj);
|
||||
int frequency = atol(value);
|
||||
|
||||
if (frequency > 0)
|
||||
_cpuclock_set_frequency(frequency);
|
||||
}
|
||||
|
||||
static void
|
||||
_powersave_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
const char *value = elm_object_text_get(obj);
|
||||
|
||||
if (value)
|
||||
eina_stringshare_replace(&inst->cfg->cpuclock.powersave_governor, value);
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_governor_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
const char *value = elm_object_text_get(obj);
|
||||
|
||||
if (value)
|
||||
{
|
||||
eina_stringshare_replace(&inst->cfg->cpuclock.governor, value);
|
||||
_cpuclock_set_governor(inst->cfg->cpuclock.governor);
|
||||
}
|
||||
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_poll_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Cpuclock_Config *cc = data;
|
||||
Instance *inst = cc->inst;
|
||||
int value = elm_radio_value_get(obj);
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
inst->cfg->cpuclock.poll_interval = 4;
|
||||
break;
|
||||
case 1:
|
||||
inst->cfg->cpuclock.poll_interval = 8;
|
||||
break;
|
||||
case 2:
|
||||
inst->cfg->cpuclock.poll_interval = 32;
|
||||
break;
|
||||
case 3:
|
||||
inst->cfg->cpuclock.poll_interval = 64;
|
||||
break;
|
||||
case 4:
|
||||
inst->cfg->cpuclock.poll_interval = 256;
|
||||
break;
|
||||
default:
|
||||
inst->cfg->cpuclock.poll_interval = 32;
|
||||
}
|
||||
|
||||
e_config_save_queue();
|
||||
_cpuclock_config_updated(inst);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
cpuclock_configure(Instance *inst)
|
||||
{
|
||||
Evas_Object *popup, *tb, *frame, *box, *o, *group, *lbl, *slider, *list, *check;
|
||||
Evas_Object *groupg = NULL, *groups = NULL, *groupf = NULL;
|
||||
Elm_Object_Item *it;
|
||||
E_Zone *zone = e_zone_current_get();
|
||||
Eina_List *l = NULL;
|
||||
Cpuclock_Config *cc = E_NEW(Cpuclock_Config, 1);
|
||||
int i = 0, value = 0;
|
||||
|
||||
cc->inst = inst;
|
||||
cc->powersaves = NULL;
|
||||
cc->frequencies = EINA_FALSE;
|
||||
cc->pstate = EINA_FALSE;
|
||||
|
||||
if ((inst->cfg->cpuclock.status->frequencies) &&
|
||||
(inst->cfg->cpuclock.status->can_set_frequency) &&
|
||||
(!inst->cfg->cpuclock.status->pstate))
|
||||
{
|
||||
cc->frequencies = EINA_TRUE;
|
||||
}
|
||||
if ((inst->cfg->cpuclock.status) && (inst->cfg->cpuclock.status->pstate))
|
||||
{
|
||||
cc->pstate = EINA_TRUE;
|
||||
}
|
||||
|
||||
popup = elm_popup_add(e_comp->elm);
|
||||
E_EXPAND(popup);
|
||||
elm_popup_allow_events_set(popup, 1);
|
||||
elm_popup_scrollable_set(popup, 1);
|
||||
|
||||
tb = elm_table_add(popup);
|
||||
E_EXPAND(tb);
|
||||
evas_object_show(tb);
|
||||
elm_object_content_set(popup, tb);
|
||||
|
||||
lbl = elm_label_add(tb);
|
||||
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, _("CpuClock Configuration"));
|
||||
elm_table_pack(tb, lbl, 0, 0, 2, 1);
|
||||
evas_object_show(lbl);
|
||||
|
||||
list = elm_list_add(tb);
|
||||
E_ALIGN(list, 0, EVAS_HINT_FILL);
|
||||
E_WEIGHT(list, 0, EVAS_HINT_EXPAND);
|
||||
elm_table_pack(tb, list, 0, 1, 1, 1);
|
||||
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
|
||||
elm_scroller_content_min_limit(list, 1, 1);
|
||||
it = elm_list_item_append(list, _("General"), NULL, NULL,
|
||||
_config_show_general, cc);
|
||||
elm_list_item_selected_set(it, 1);
|
||||
it = elm_list_item_append(list, _("Power Policy"), NULL, NULL,
|
||||
_config_show_policy, cc);
|
||||
it = elm_list_item_append(list, _("Power Saving"), NULL, NULL,
|
||||
_config_show_saving, cc);
|
||||
if (cc->pstate)
|
||||
it = elm_list_item_append(list, _("Power State"), NULL, NULL,
|
||||
_config_show_pstate, cc);
|
||||
if (cc->frequencies)
|
||||
it = elm_list_item_append(list, _("Frequencies"), NULL, NULL,
|
||||
_config_show_frequencies, cc);
|
||||
elm_list_go(list);
|
||||
evas_object_show(list);
|
||||
|
||||
frame = elm_frame_add(tb);
|
||||
elm_object_text_set(frame, _("General"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_table_pack(tb, frame, 1, 1, 1, 1);
|
||||
evas_object_show(frame);
|
||||
cc->general = frame;
|
||||
|
||||
box = elm_box_add(frame);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
lbl = elm_label_add(tb);
|
||||
E_ALIGN(lbl, 0.0, 0.0);
|
||||
E_WEIGHT(lbl, EVAS_HINT_EXPAND, 0);
|
||||
elm_object_text_set(lbl, _("Update Poll Interval"));
|
||||
elm_box_pack_end(box, lbl);
|
||||
evas_object_show(lbl);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 0);
|
||||
E_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
elm_object_text_set(o, _("Fast (4 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _poll_changed, cc);
|
||||
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_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
elm_object_text_set(o, _("Medium (8 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _poll_changed, cc);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 2);
|
||||
elm_radio_group_add(o, group);
|
||||
E_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
elm_object_text_set(o, _("Normal (32 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _poll_changed, cc);
|
||||
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, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
elm_object_text_set(o, _("Slow (64 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _poll_changed, cc);
|
||||
evas_object_show(o);
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, 4);
|
||||
elm_radio_group_add(o, group);
|
||||
E_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
elm_object_text_set(o, _("Very Slow (256 ticks)"));
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _poll_changed, cc);
|
||||
evas_object_show(o);
|
||||
|
||||
switch(inst->cfg->cpuclock.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);
|
||||
|
||||
frame = elm_frame_add(tb);
|
||||
elm_object_text_set(frame, _("Power Policy"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_table_pack(tb, frame, 1, 1, 1, 1);
|
||||
evas_object_show(frame);
|
||||
cc->policy = frame;
|
||||
|
||||
box = elm_box_add(frame);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
i = 0;
|
||||
for (l = inst->cfg->cpuclock.status->governors; l; l = l->next)
|
||||
{
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, i);
|
||||
E_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
if (!strcmp(l->data, "ondemand"))
|
||||
elm_object_text_set(o, _("Automatic"));
|
||||
else if (!strcmp(l->data, "conservative"))
|
||||
elm_object_text_set(o, _("Lower Power Automatic"));
|
||||
else if (!strcmp(l->data, "interactive"))
|
||||
elm_object_text_set(o, _("Automatic Interactive"));
|
||||
else if (!strcmp(l->data, "powersave"))
|
||||
elm_object_text_set(o, _("Minimum Speed"));
|
||||
else if (!strcmp(l->data, "performance"))
|
||||
elm_object_text_set(o, _("Maximum Speed"));
|
||||
else
|
||||
elm_object_text_set(o, l->data);
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _governor_changed, cc);
|
||||
evas_object_show(o);
|
||||
|
||||
if (!strcmp(inst->cfg->cpuclock.status->cur_governor, l->data))
|
||||
value = i;
|
||||
|
||||
if (!groupg)
|
||||
groupg = o;
|
||||
else
|
||||
elm_radio_group_add(o, groupg);
|
||||
i++;
|
||||
}
|
||||
if (groupg)
|
||||
elm_radio_value_set(groupg, value);
|
||||
|
||||
check = elm_check_add(box);
|
||||
elm_object_text_set(check, _("Restore CPU Power Policy"));
|
||||
elm_check_state_set(check, inst->cfg->cpuclock.restore_governor);
|
||||
E_ALIGN(check, 0.0, 0.0);
|
||||
E_WEIGHT(check, EVAS_HINT_EXPAND, 0);
|
||||
evas_object_smart_callback_add(check, "changed", _restore_governor, cc);
|
||||
elm_box_pack_end(box, check);
|
||||
evas_object_show(check);
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
|
||||
frame = elm_frame_add(tb);
|
||||
elm_object_text_set(frame, _("Power Saving"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_table_pack(tb, frame, 1, 1, 1, 1);
|
||||
evas_object_show(frame);
|
||||
cc->saving = frame;
|
||||
|
||||
box = elm_box_add(frame);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
check = elm_check_add(box);
|
||||
elm_object_text_set(check, _("Automatic Powersaving"));
|
||||
elm_check_state_set(check, inst->cfg->cpuclock.auto_powersave);
|
||||
E_ALIGN(check, 0.0, 0.0);
|
||||
E_WEIGHT(check, EVAS_HINT_EXPAND, 0);
|
||||
evas_object_smart_callback_add(check, "changed", _auto_powersave, cc);
|
||||
elm_box_pack_end(box, check);
|
||||
evas_object_show(check);
|
||||
|
||||
i = 0;
|
||||
for (l = inst->cfg->cpuclock.status->governors; l; l = l->next)
|
||||
{
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, i);
|
||||
E_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
if (!strcmp(l->data, "ondemand"))
|
||||
elm_object_text_set(o, _("Automatic"));
|
||||
else if (!strcmp(l->data, "conservative"))
|
||||
elm_object_text_set(o, _("Lower Power Automatic"));
|
||||
else if (!strcmp(l->data, "interactive"))
|
||||
elm_object_text_set(o, _("Automatic Interactive"));
|
||||
else if (!strcmp(l->data, "powersave"))
|
||||
elm_object_text_set(o, _("Minimum Speed"));
|
||||
else if (!strcmp(l->data, "performance"))
|
||||
elm_object_text_set(o, _("Maximum Speed"));
|
||||
else
|
||||
elm_object_text_set(o, l->data);
|
||||
elm_object_disabled_set(o, inst->cfg->cpuclock.auto_powersave);
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _powersave_changed, cc);
|
||||
evas_object_show(o);
|
||||
cc->powersaves = eina_list_append(cc->powersaves, o);
|
||||
|
||||
if (inst->cfg->cpuclock.powersave_governor && !strcmp(inst->cfg->cpuclock.powersave_governor, l->data))
|
||||
value = i;
|
||||
|
||||
if (!groups)
|
||||
groups = o;
|
||||
else
|
||||
elm_radio_group_add(o, groups);
|
||||
i++;
|
||||
}
|
||||
if (groups)
|
||||
elm_radio_value_set(groups, value);
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
|
||||
if (cc->pstate)
|
||||
{
|
||||
frame = elm_frame_add(tb);
|
||||
elm_object_text_set(frame, _("Power State"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_table_pack(tb, frame, 1, 1, 1, 1);
|
||||
evas_object_show(frame);
|
||||
cc->ps = frame;
|
||||
|
||||
box = elm_box_add(frame);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
slider = elm_slider_add(box);
|
||||
elm_object_text_set(slider, _("Maximum Power State:"));
|
||||
elm_slider_unit_format_set(slider, "%3.0f");
|
||||
elm_slider_indicator_format_set(slider, "%3.0f");
|
||||
elm_slider_min_max_set(slider, 2, 100);
|
||||
elm_slider_value_set(slider, inst->cfg->cpuclock.pstate_max);
|
||||
elm_slider_step_set(slider, 1);
|
||||
elm_slider_span_size_set(slider, 100);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _update_max_power, cc);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
cc->max = slider;
|
||||
|
||||
slider = elm_slider_add(box);
|
||||
elm_object_text_set(slider, _("Minimum Power State:"));
|
||||
elm_slider_unit_format_set(slider, "%3.0f");
|
||||
elm_slider_indicator_format_set(slider, "%3.0f");
|
||||
elm_slider_min_max_set(slider, 0, 100);
|
||||
elm_slider_value_set(slider, inst->cfg->cpuclock.pstate_min);
|
||||
elm_slider_step_set(slider, 1);
|
||||
elm_slider_span_size_set(slider, 100);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _update_min_power, cc);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
cc->min = slider;
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
}
|
||||
if (cc->frequencies)
|
||||
{
|
||||
frame = elm_frame_add(tb);
|
||||
elm_object_text_set(frame, _("Frequencies"));
|
||||
E_EXPAND(frame);
|
||||
E_FILL(frame);
|
||||
elm_table_pack(tb, frame, 1, 1, 1, 1);
|
||||
evas_object_show(frame);
|
||||
cc->freq = frame;
|
||||
|
||||
box = elm_box_add(frame);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
E_EXPAND(box);
|
||||
evas_object_show(box);
|
||||
|
||||
i = 0;
|
||||
for (l = inst->cfg->cpuclock.status->frequencies; l; l = l->next)
|
||||
{
|
||||
char buf[4096];
|
||||
int frequency;
|
||||
|
||||
frequency = (long)l->data;
|
||||
|
||||
o = elm_radio_add(box);
|
||||
elm_radio_state_value_set(o, i);
|
||||
E_ALIGN(o, 0.0, 0.0);
|
||||
E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
|
||||
#ifdef __OpenBSD__
|
||||
snprintf(buf, sizeof(buf), "%i %%", frequency);
|
||||
#else
|
||||
if (frequency < 1000000)
|
||||
snprintf(buf, sizeof(buf), _("%i MHz"), frequency / 1000);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), _("%'.1f GHz"),
|
||||
frequency / 1000000.);
|
||||
#endif
|
||||
elm_object_text_set(o, buf);
|
||||
elm_box_pack_end(box, o);
|
||||
evas_object_smart_callback_add(o, "changed", _frequency_changed, cc);
|
||||
evas_object_show(o);
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
if (inst->cfg->cpuclock.status->cur_percent == frequency)
|
||||
value = i;
|
||||
#else
|
||||
if (inst->cfg->cpuclock.status->cur_frequency == frequency)
|
||||
value = i;
|
||||
#endif
|
||||
if (!groupf)
|
||||
groupf = o;
|
||||
else
|
||||
elm_radio_group_add(o, groupf);
|
||||
i++;
|
||||
}
|
||||
if (groupf)
|
||||
elm_radio_value_set(groupf, value);
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
evas_object_hide(cc->freq);
|
||||
}
|
||||
if (cc->pstate)
|
||||
evas_object_hide(cc->ps);
|
||||
evas_object_hide(cc->policy);
|
||||
evas_object_hide(cc->saving);
|
||||
evas_object_show(cc->general);
|
||||
|
||||
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, cc);
|
||||
|
||||
return inst->cfg->cpuclock.configure = popup;
|
||||
}
|
||||
|
|
@ -104,7 +104,8 @@ sysinfo_init(void)
|
|||
ci->cpuclock.governor = NULL;
|
||||
ci->cpuclock.pstate_min = 1;
|
||||
ci->cpuclock.pstate_max = 101;
|
||||
ci->cpumonitor.poll_interval = 32;
|
||||
ci->cpuclock.configure = NULL;
|
||||
ci->cpumonitor.poll_interval = 32;
|
||||
ci->cpumonitor.total = 0;
|
||||
ci->cpumonitor.idle = 0;
|
||||
ci->cpumonitor.percent = 0;
|
||||
|
|
|
@ -112,6 +112,8 @@ _conf_item_get(int *id)
|
|||
ci->cpuclock.governor = NULL;
|
||||
ci->cpuclock.pstate_min = 1;
|
||||
ci->cpuclock.pstate_max = 101;
|
||||
ci->cpuclock.popup = NULL;
|
||||
ci->cpuclock.configure = NULL;
|
||||
ci->cpumonitor.poll_interval = 32;
|
||||
ci->cpumonitor.total = 0;
|
||||
ci->cpumonitor.idle = 0;
|
||||
|
|
|
@ -173,6 +173,9 @@ struct _Config_Item
|
|||
struct
|
||||
{
|
||||
Evas_Object *o_gadget;
|
||||
Evas_Object *popup;
|
||||
Evas_Object *popup_label;
|
||||
Evas_Object *configure;
|
||||
int poll_interval;
|
||||
int restore_governor;
|
||||
int auto_powersave;
|
||||
|
|
Loading…
Reference in New Issue