formatting

lot of mixed spaces/tabs here made the code unreadable
This commit is contained in:
Mike Blumenkrantz 2017-08-29 15:20:05 -04:00
parent f5e19a7721
commit b5e75eb264
36 changed files with 1270 additions and 1152 deletions

View File

@ -4,11 +4,11 @@ typedef struct _Instance Instance;
struct _Instance struct _Instance
{ {
Evas_Object *o_main; Evas_Object *o_main;
Evas_Object *o_backlight, *o_table, *o_slider; Evas_Object *o_backlight, *o_table, *o_slider;
Evas_Object *popup, *box; Evas_Object *popup, *box;
E_Gadget_Site_Orient orient; E_Gadget_Site_Orient orient;
double val; double val;
}; };
static Eina_List *ginstances = NULL; static Eina_List *ginstances = NULL;
@ -25,7 +25,8 @@ _backlight_gadget_update(Instance *inst)
else else
msg.val = inst->val; msg.val = inst->val;
if (msg.val < 0.0) msg.val = 0.0; if (msg.val < 0.0) msg.val = 0.0;
else if (msg.val > 1.0) msg.val = 1.0; else if (msg.val > 1.0)
msg.val = 1.0;
edje_object_message_send(elm_layout_edje_get(inst->o_backlight), EDJE_MESSAGE_FLOAT, 0, &msg); edje_object_message_send(elm_layout_edje_get(inst->o_backlight), EDJE_MESSAGE_FLOAT, 0, &msg);
} }
@ -221,35 +222,35 @@ _backlight_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA
if (inst->o_main) if (inst->o_main)
{ {
e_gadget_configure_cb_set(inst->o_main, _backlight_gadget_configure); e_gadget_configure_cb_set(inst->o_main, _backlight_gadget_configure);
inst->o_backlight = elm_layout_add(inst->o_main); inst->o_backlight = elm_layout_add(inst->o_main);
E_EXPAND(inst->o_backlight); E_EXPAND(inst->o_backlight);
E_FILL(inst->o_backlight); E_FILL(inst->o_backlight);
if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL) if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_theme_edje_object_set(inst->o_backlight, e_theme_edje_object_set(inst->o_backlight,
"base/theme/gadget/backlight", "base/theme/gadget/backlight",
"e/gadget/backlight/main_vert"); "e/gadget/backlight/main_vert");
else else
e_theme_edje_object_set(inst->o_backlight, e_theme_edje_object_set(inst->o_backlight,
"base/theme/gadget/backlight", "base/theme/gadget/backlight",
"e/gadget/backlight/main"); "e/gadget/backlight/main");
evas_object_event_callback_add(inst->o_backlight, evas_object_event_callback_add(inst->o_backlight,
EVAS_CALLBACK_MOUSE_DOWN, EVAS_CALLBACK_MOUSE_DOWN,
_backlight_cb_mouse_down, _backlight_cb_mouse_down,
inst); inst);
evas_object_event_callback_add(inst->o_backlight, evas_object_event_callback_add(inst->o_backlight,
EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_MOUSE_WHEEL,
_backlight_cb_mouse_wheel, _backlight_cb_mouse_wheel,
inst); inst);
evas_object_event_callback_add(inst->o_backlight, evas_object_event_callback_add(inst->o_backlight,
EVAS_CALLBACK_RESIZE, EVAS_CALLBACK_RESIZE,
_backlight_resize_cb, _backlight_resize_cb,
inst); inst);
elm_box_pack_end(inst->o_main, inst->o_backlight); elm_box_pack_end(inst->o_main, inst->o_backlight);
evas_object_show(inst->o_backlight); evas_object_show(inst->o_backlight);
if (!EINA_FLT_EQ(inst->val, -1.0)) if (!EINA_FLT_EQ(inst->val, -1.0))
inst->val = e_backlight_level_get(e_zone_current_get()); inst->val = e_backlight_level_get(e_zone_current_get());
_backlight_gadget_update(inst); _backlight_gadget_update(inst);
} }
evas_object_smart_callback_del_full(obj, "gadget_created", _backlight_gadget_created_cb, data); evas_object_smart_callback_del_full(obj, "gadget_created", _backlight_gadget_created_cb, data);
} }
@ -312,3 +313,4 @@ backlight_shutdown(void)
} }
E_FREE_LIST(handlers, ecore_event_handler_del); E_FREE_LIST(handlers, ecore_event_handler_del);
} }

View File

@ -2,11 +2,11 @@
#define VOLUME_STEP 5 #define VOLUME_STEP 5
#define BARRIER_CHECK(old_val, new_val) \ #define BARRIER_CHECK(old_val, new_val) \
(old_val > EMIX_VOLUME_BARRIER - 20) && \ (old_val > EMIX_VOLUME_BARRIER - 20) && \
(old_val <= EMIX_VOLUME_BARRIER) && \ (old_val <= EMIX_VOLUME_BARRIER) && \
(new_val > EMIX_VOLUME_BARRIER) && \ (new_val > EMIX_VOLUME_BARRIER) && \
(new_val < EMIX_VOLUME_BARRIER + 20) (new_val < EMIX_VOLUME_BARRIER + 20)
static Eina_Bool init; static Eina_Bool init;
static Eina_List *_client_sinks = NULL; static Eina_List *_client_sinks = NULL;
@ -16,17 +16,18 @@ static Eina_List *_client_handlers = NULL;
typedef struct _Context Context; typedef struct _Context Context;
struct _Context struct _Context
{ {
char *theme; char *theme;
Ecore_Exe *emixer; Ecore_Exe *emixer;
Ecore_Event_Handler *desklock_handler; Ecore_Event_Handler *desklock_handler;
Ecore_Event_Handler *emix_event_handler; Ecore_Event_Handler *emix_event_handler;
const Emix_Sink *sink_default; const Emix_Sink *sink_default;
E_Module *module; E_Module *module;
Eina_List *instances; Eina_List *instances;
E_Menu *menu; E_Menu *menu;
unsigned int notification_id; unsigned int notification_id;
struct { struct
{
E_Action *incr; E_Action *incr;
E_Action *decr; E_Action *decr;
E_Action *mute; E_Action *mute;
@ -39,15 +40,15 @@ struct _Context
typedef struct _Instance Instance; typedef struct _Instance Instance;
struct _Instance struct _Instance
{ {
int id; int id;
Evas_Object *o_main; Evas_Object *o_main;
Evas_Object *o_mixer; Evas_Object *o_mixer;
Evas_Object *popup; Evas_Object *popup;
Evas_Object *list; Evas_Object *list;
Evas_Object *slider; Evas_Object *slider;
Evas_Object *check; Evas_Object *check;
E_Gadget_Site_Orient orient; E_Gadget_Site_Orient orient;
Eina_Bool mute; Eina_Bool mute;
}; };
typedef struct _Client_Mixer Client_Mixer; typedef struct _Client_Mixer Client_Mixer;
@ -56,9 +57,9 @@ struct _Client_Mixer
Evas_Object *win; Evas_Object *win;
Evas_Object *volume; Evas_Object *volume;
Evas_Object *mute; Evas_Object *mute;
E_Client *ec; E_Client *ec;
Evas_Object *bx; Evas_Object *bx;
Eina_List *sinks; Eina_List *sinks;
}; };
static Context *gmixer_context = NULL; static Context *gmixer_context = NULL;
@ -144,7 +145,7 @@ _mixer_gadget_update(void)
msg->val[2] = msg->val[1]; msg->val[2] = msg->val[1];
if (inst->popup) if (inst->popup)
_mixer_popup_update(inst, gmixer_context->sink_default->mute, _mixer_popup_update(inst, gmixer_context->sink_default->mute,
msg->val[1]); msg->val[1]);
} }
edje_object_message_send(elm_layout_edje_get(inst->o_mixer), EDJE_MESSAGE_INT_SET, 0, msg); edje_object_message_send(elm_layout_edje_get(inst->o_mixer), EDJE_MESSAGE_INT_SET, 0, msg);
elm_layout_signal_emit(inst->o_mixer, "e,action,volume,change", "e"); elm_layout_signal_emit(inst->o_mixer, "e,action,volume,change", "e");
@ -369,7 +370,7 @@ _emixer_del_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
{ {
gmixer_context->emixer = NULL; gmixer_context->emixer = NULL;
if (gmixer_context->emix_event_handler) if (gmixer_context->emix_event_handler)
ecore_event_handler_del(gmixer_context->emix_event_handler); ecore_event_handler_del(gmixer_context->emix_event_handler);
return EINA_TRUE; return EINA_TRUE;
} }
@ -384,9 +385,9 @@ _emixer_exec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
gmixer_context->emixer = ecore_exe_run("emixer", NULL); gmixer_context->emixer = ecore_exe_run("emixer", NULL);
if (gmixer_context->emix_event_handler) if (gmixer_context->emix_event_handler)
ecore_event_handler_del(gmixer_context->emix_event_handler); ecore_event_handler_del(gmixer_context->emix_event_handler);
gmixer_context->emix_event_handler = gmixer_context->emix_event_handler =
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _emixer_del_cb, NULL); ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _emixer_del_cb, NULL);
} }
static void static void
@ -399,7 +400,7 @@ _check_changed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
emix_config_save_state_get(); emix_config_save_state_get();
if (emix_config_save_get()) e_config_save_queue(); if (emix_config_save_get()) e_config_save_queue();
/* /*
*TODO: is it really necessary ? or it will be update * TODO: is it really necessary ? or it will be update
* with the sink changed hanlder * with the sink changed hanlder
*/ */
_mixer_gadget_update(); _mixer_gadget_update();
@ -528,8 +529,8 @@ _popup_new(Instance *inst)
evas_object_show(button); evas_object_show(button);
evas_object_size_hint_min_set(list, 208, 208); evas_object_size_hint_min_set(list, 208, 208);
e_gadget_util_ctxpopup_place(inst->o_main, inst->popup, inst->o_mixer); e_gadget_util_ctxpopup_place(inst->o_main, inst->popup, inst->o_mixer);
evas_object_show(inst->popup); evas_object_show(inst->popup);
if (default_it) if (default_it)
@ -611,24 +612,24 @@ _mixer_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNU
inst->o_mixer = elm_layout_add(inst->o_main); inst->o_mixer = elm_layout_add(inst->o_main);
E_EXPAND(inst->o_mixer); E_EXPAND(inst->o_mixer);
E_FILL(inst->o_mixer); E_FILL(inst->o_mixer);
if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL) if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_theme_edje_object_set(inst->o_mixer, e_theme_edje_object_set(inst->o_mixer,
"base/theme/gadget/mixer", "base/theme/gadget/mixer",
"e/gadget/mixer/main_vert"); "e/gadget/mixer/main_vert");
else else
e_theme_edje_object_set(inst->o_mixer, e_theme_edje_object_set(inst->o_mixer,
"base/theme/gadget/mixer", "base/theme/gadget/mixer",
"e/gadget/mixer/main"); "e/gadget/mixer/main");
evas_object_event_callback_add(inst->o_mixer, EVAS_CALLBACK_MOUSE_DOWN, evas_object_event_callback_add(inst->o_mixer, EVAS_CALLBACK_MOUSE_DOWN,
_mouse_down_cb, inst); _mouse_down_cb, inst);
evas_object_event_callback_add(inst->o_mixer, EVAS_CALLBACK_MOUSE_WHEEL, evas_object_event_callback_add(inst->o_mixer, EVAS_CALLBACK_MOUSE_WHEEL,
_mouse_wheel_cb, inst); _mouse_wheel_cb, inst);
evas_object_event_callback_add(inst->o_mixer, EVAS_CALLBACK_RESIZE, evas_object_event_callback_add(inst->o_mixer, EVAS_CALLBACK_RESIZE,
_mixer_resize_cb, inst); _mixer_resize_cb, inst);
elm_box_pack_end(inst->o_main, inst->o_mixer); elm_box_pack_end(inst->o_main, inst->o_mixer);
evas_object_show(inst->o_mixer); evas_object_show(inst->o_mixer);
if (inst->id != -1) if (inst->id != -1)
gmixer_context->instances = eina_list_append(gmixer_context->instances, inst); gmixer_context->instances = eina_list_append(gmixer_context->instances, inst);
if (inst->id == -1) if (inst->id == -1)
{ {
Edje_Message_Int_Set *msg; Edje_Message_Int_Set *msg;
@ -642,7 +643,7 @@ _mixer_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNU
elm_layout_signal_emit(inst->o_mixer, "e,action,volume,change", "e"); elm_layout_signal_emit(inst->o_mixer, "e,action,volume,change", "e");
} }
else else
_mixer_gadget_update(); _mixer_gadget_update();
} }
evas_object_smart_callback_del_full(obj, "gadget_created", _mixer_gadget_created_cb, data); evas_object_smart_callback_del_full(obj, "gadget_created", _mixer_gadget_created_cb, data);
} }
@ -672,7 +673,7 @@ mixer_gadget_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient)
inst->o_main = elm_box_add(parent); inst->o_main = elm_box_add(parent);
inst->orient = orient; inst->orient = orient;
inst->id = *id; inst->id = *id;
evas_object_show(inst->o_main); evas_object_show(inst->o_main);
evas_object_smart_callback_add(parent, "gadget_created", _mixer_gadget_created_cb, inst); evas_object_smart_callback_add(parent, "gadget_created", _mixer_gadget_created_cb, inst);
if (*id != -1) if (*id != -1)
@ -719,10 +720,10 @@ _sink_event(int type, void *info)
DBG("Sink added"); DBG("Sink added");
} }
/* /*
Only safe the state if we are not in init mode, Only safe the state if we are not in init mode,
If we are in init mode, this is a result of the restore call. If we are in init mode, this is a result of the restore call.
Restore iterates over a list of sinks which would get deleted in the Restore iterates over a list of sinks which would get deleted in the
save_state_get call. save_state_get call.
*/ */
if (!init) if (!init)
{ {
@ -872,51 +873,53 @@ _sink_input_event(int type, Emix_Sink_Input *input)
switch (type) switch (type)
{ {
case EMIX_SINK_INPUT_ADDED_EVENT: case EMIX_SINK_INPUT_ADDED_EVENT:
pid = input->pid; pid = input->pid;
while (42) while (42)
{ {
if (pid <= 1 || pid == getpid()) return; if (pid <= 1 || pid == getpid()) return;
clients = e_client_focus_stack_get(); clients = e_client_focus_stack_get();
EINA_LIST_FOREACH(clients, l, ec) EINA_LIST_FOREACH(clients, l, ec)
{ {
if ((ec->netwm.pid == pid) && (!ec->parent)) if ((ec->netwm.pid == pid) && (!ec->parent))
{ {
DBG("Sink found the client %s", DBG("Sink found the client %s",
e_client_util_name_get(ec)); e_client_util_name_get(ec));
sink = e_client_volume_sink_new(_sink_input_get, sink = e_client_volume_sink_new(_sink_input_get,
_sink_input_set, _sink_input_set,
_sink_input_min_get, _sink_input_min_get,
_sink_input_max_get, _sink_input_max_get,
_sink_input_name_get, _sink_input_name_get,
input); input);
e_client_volume_sink_append(ec, sink); e_client_volume_sink_append(ec, sink);
_client_sinks = eina_list_append(_client_sinks, sink); _client_sinks = eina_list_append(_client_sinks, sink);
return; return;
} }
} }
pid = _get_ppid(pid); pid = _get_ppid(pid);
} }
break; break;
case EMIX_SINK_INPUT_REMOVED_EVENT: case EMIX_SINK_INPUT_REMOVED_EVENT:
EINA_LIST_FOREACH(_client_sinks, l, sink) EINA_LIST_FOREACH(_client_sinks, l, sink)
{ {
if (sink->data == input) if (sink->data == input)
{ {
e_client_volume_sink_del(sink); e_client_volume_sink_del(sink);
_client_sinks = eina_list_remove_list(_client_sinks, l); _client_sinks = eina_list_remove_list(_client_sinks, l);
break; break;
} }
} }
break; break;
case EMIX_SINK_INPUT_CHANGED_EVENT: case EMIX_SINK_INPUT_CHANGED_EVENT:
EINA_LIST_FOREACH(_client_sinks, l, sink) EINA_LIST_FOREACH(_client_sinks, l, sink)
{ {
if (sink->data == input) if (sink->data == input)
{ {
e_client_volume_sink_update(sink); e_client_volume_sink_update(sink);
} }
} }
break; break;
} }
} }
@ -928,22 +931,25 @@ _events_cb(void *data EINA_UNUSED, enum Emix_Event type, void *event_info)
case EMIX_SINK_ADDED_EVENT: case EMIX_SINK_ADDED_EVENT:
case EMIX_SINK_CHANGED_EVENT: case EMIX_SINK_CHANGED_EVENT:
case EMIX_SINK_REMOVED_EVENT: case EMIX_SINK_REMOVED_EVENT:
_sink_event(type, event_info); _sink_event(type, event_info);
break; break;
case EMIX_DISCONNECTED_EVENT: case EMIX_DISCONNECTED_EVENT:
_disconnected(); _disconnected();
break; break;
case EMIX_READY_EVENT: case EMIX_READY_EVENT:
_ready(); _ready();
break; break;
case EMIX_SINK_INPUT_ADDED_EVENT: case EMIX_SINK_INPUT_ADDED_EVENT:
case EMIX_SINK_INPUT_REMOVED_EVENT: case EMIX_SINK_INPUT_REMOVED_EVENT:
case EMIX_SINK_INPUT_CHANGED_EVENT: case EMIX_SINK_INPUT_CHANGED_EVENT:
_sink_input_event(type, event_info); _sink_input_event(type, event_info);
break; break;
default: default:
break; break;
} }
} }
@ -1083,7 +1089,6 @@ _bd_hook_sink_volume_drag_stop(void *data, Evas_Object *obj, void *event_info EI
elm_check_state_set(check, mute); elm_check_state_set(check, mute);
} }
static void static void
_bd_hook_sink_mute_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) _bd_hook_sink_mute_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{ {
@ -1296,7 +1301,7 @@ mixer_init(void)
gmixer_context = E_NEW(Context, 1); gmixer_context = E_NEW(Context, 1);
gmixer_context->desklock_handler = gmixer_context->desklock_handler =
ecore_event_handler_add(E_EVENT_DESKLOCK, _desklock_cb, NULL); ecore_event_handler_add(E_EVENT_DESKLOCK, _desklock_cb, NULL);
snprintf(buf, sizeof(buf), "%s/mixer.edj", snprintf(buf, sizeof(buf), "%s/mixer.edj",
e_module_dir_get(gmixer_context->module)); e_module_dir_get(gmixer_context->module));
gmixer_context->theme = strdup(buf); gmixer_context->theme = strdup(buf);
@ -1307,13 +1312,13 @@ mixer_init(void)
backend = emix_config_backend_get(); backend = emix_config_backend_get();
if (backend && emix_backend_set(backend)) if (backend && emix_backend_set(backend))
backend_loaded = EINA_TRUE; backend_loaded = EINA_TRUE;
else else
{ {
if (backend) if (backend)
WRN("Could not load %s, trying another one ...", backend); WRN("Could not load %s, trying another one ...", backend);
EINA_LIST_FOREACH((Eina_List *)emix_backends_available(), l, EINA_LIST_FOREACH((Eina_List *)emix_backends_available(), l,
backend) backend)
{ {
if (emix_backend_set(backend) == EINA_TRUE) if (emix_backend_set(backend) == EINA_TRUE)
{ {
@ -1373,7 +1378,7 @@ mixer_shutdown(void)
E_FREE(gmixer_context); E_FREE(gmixer_context);
} }
EINA_LIST_FREE(_client_sinks, sink) EINA_LIST_FREE(_client_sinks, sink)
e_client_volume_sink_del(sink); e_client_volume_sink_del(sink);
emix_event_callback_del(_events_cb); emix_event_callback_del(_events_cb);
} }

View File

@ -7,30 +7,30 @@
typedef struct _Config_Objects Config_Objects; typedef struct _Config_Objects Config_Objects;
struct _Config_Objects struct _Config_Objects
{ {
Evas_Object *general_page; Evas_Object *general_page;
Evas_Object *popup_page; Evas_Object *popup_page;
Evas_Object *urgent_page; Evas_Object *urgent_page;
Evas_Object *style_page; Evas_Object *style_page;
Evas_Object *o_popup; Evas_Object *o_popup;
Evas_Object *o_popup_speed; Evas_Object *o_popup_speed;
Evas_Object *o_popup_urgent; Evas_Object *o_popup_urgent;
Evas_Object *o_popup_urgent_stick; Evas_Object *o_popup_urgent_stick;
Evas_Object *o_popup_urgent_focus; Evas_Object *o_popup_urgent_focus;
Evas_Object *o_popup_urgent_speed; Evas_Object *o_popup_urgent_speed;
Evas_Object *o_show_desk_names; Evas_Object *o_show_desk_names;
Evas_Object *o_popup_act_height; Evas_Object *o_popup_act_height;
Evas_Object *o_popup_height; Evas_Object *o_popup_height;
Evas_Object *o_drag_resist; Evas_Object *o_drag_resist;
Evas_Object *o_btn_drag; Evas_Object *o_btn_drag;
Evas_Object *o_btn_noplace; Evas_Object *o_btn_noplace;
Evas_Object *o_btn_desk; Evas_Object *o_btn_desk;
Evas_Object *o_btn_virtual; Evas_Object *o_btn_virtual;
Evas_Object *o_flip_desk; Evas_Object *o_flip_desk;
Evas_Object *o_permanent; Evas_Object *o_permanent;
Evas_Object *o_plain; Evas_Object *o_plain;
E_Grab_Dialog *grab_dia; E_Grab_Dialog *grab_dia;
int grab_btn; int grab_btn;
int w, h; int w, h;
}; };
Config_Objects *pager_gadget_config_objects = NULL; Config_Objects *pager_gadget_config_objects = NULL;
@ -82,27 +82,27 @@ _config_value_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
{ {
Eina_Bool val, changed = EINA_FALSE; Eina_Bool val, changed = EINA_FALSE;
pager_config->popup = pager_config->popup =
elm_check_state_get(pager_gadget_config_objects->o_popup); elm_check_state_get(pager_gadget_config_objects->o_popup);
pager_config->popup_speed = pager_config->popup_speed =
elm_slider_value_get(pager_gadget_config_objects->o_popup_speed); elm_slider_value_get(pager_gadget_config_objects->o_popup_speed);
pager_config->flip_desk = pager_config->flip_desk =
elm_check_state_get(pager_gadget_config_objects->o_flip_desk); elm_check_state_get(pager_gadget_config_objects->o_flip_desk);
pager_config->popup_urgent = pager_config->popup_urgent =
elm_check_state_get(pager_gadget_config_objects->o_popup_urgent); elm_check_state_get(pager_gadget_config_objects->o_popup_urgent);
pager_config->popup_urgent_stick = pager_config->popup_urgent_stick =
elm_check_state_get(pager_gadget_config_objects->o_popup_urgent_stick); elm_check_state_get(pager_gadget_config_objects->o_popup_urgent_stick);
pager_config->popup_urgent_focus = pager_config->popup_urgent_focus =
elm_check_state_get(pager_gadget_config_objects->o_popup_urgent_focus); elm_check_state_get(pager_gadget_config_objects->o_popup_urgent_focus);
pager_config->popup_urgent_speed = pager_config->popup_urgent_speed =
elm_slider_value_get(pager_gadget_config_objects->o_popup_urgent_speed); elm_slider_value_get(pager_gadget_config_objects->o_popup_urgent_speed);
pager_config->show_desk_names = pager_config->show_desk_names =
elm_check_state_get(pager_gadget_config_objects->o_show_desk_names); elm_check_state_get(pager_gadget_config_objects->o_show_desk_names);
pager_config->popup_height = pager_config->popup_height =
elm_slider_value_get(pager_gadget_config_objects->o_popup_height); elm_slider_value_get(pager_gadget_config_objects->o_popup_height);
pager_config->popup_act_height = pager_config->popup_act_height =
elm_slider_value_get(pager_gadget_config_objects->o_popup_act_height); elm_slider_value_get(pager_gadget_config_objects->o_popup_act_height);
pager_config->drag_resist = pager_config->drag_resist =
elm_slider_value_get(pager_gadget_config_objects->o_drag_resist); elm_slider_value_get(pager_gadget_config_objects->o_drag_resist);
val = elm_check_state_get(pager_gadget_config_objects->o_permanent); val = elm_check_state_get(pager_gadget_config_objects->o_permanent);
if (val != pager_config->permanent_plain) if (val != pager_config->permanent_plain)
changed = EINA_TRUE; changed = EINA_TRUE;
@ -116,17 +116,17 @@ _config_value_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
e_config_save_queue(); e_config_save_queue();
elm_object_disabled_set(pager_gadget_config_objects->o_popup_speed, elm_object_disabled_set(pager_gadget_config_objects->o_popup_speed,
!pager_config->popup); !pager_config->popup);
elm_object_disabled_set(pager_gadget_config_objects->o_popup_act_height, elm_object_disabled_set(pager_gadget_config_objects->o_popup_act_height,
!pager_config->popup); !pager_config->popup);
elm_object_disabled_set(pager_gadget_config_objects->o_popup_height, elm_object_disabled_set(pager_gadget_config_objects->o_popup_height,
!pager_config->popup); !pager_config->popup);
elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_stick, elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_stick,
!pager_config->popup_urgent); !pager_config->popup_urgent);
elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_focus, elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_focus,
!pager_config->popup_urgent); !pager_config->popup_urgent);
elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_speed, elm_object_disabled_set(pager_gadget_config_objects->o_popup_urgent_speed,
!pager_config->popup_urgent); !pager_config->popup_urgent);
} }
static void static void
@ -141,6 +141,7 @@ _config_update_btn(Evas_Object *button, const int mouse_button)
case 0: case 0:
snprintf(lbl, sizeof(lbl), _("Click to set")); snprintf(lbl, sizeof(lbl), _("Click to set"));
break; break;
case 1: case 1:
if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT) if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
{ {
@ -158,10 +159,12 @@ _config_update_btn(Evas_Object *button, const int mouse_button)
icon = "preferences-desktop-mouse-extra"; icon = "preferences-desktop-mouse-extra";
} }
break; break;
case 2: case 2:
snprintf(lbl, sizeof(lbl), _("Middle button")); snprintf(lbl, sizeof(lbl), _("Middle button"));
icon = "preferences-desktop-mouse-middle"; icon = "preferences-desktop-mouse-middle";
break; break;
case 3: case 3:
if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT) if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
{ {
@ -179,6 +182,7 @@ _config_update_btn(Evas_Object *button, const int mouse_button)
icon = "preferences-desktop-mouse-extra"; icon = "preferences-desktop-mouse-extra";
} }
break; break;
default: default:
snprintf(lbl, sizeof(lbl), _("Button %i"), mouse_button); snprintf(lbl, sizeof(lbl), _("Button %i"), mouse_button);
icon = "preferences-desktop-mouse-extra"; icon = "preferences-desktop-mouse-extra";
@ -278,7 +282,7 @@ _config_grab_window_show(void *data, Evas_Object *obj EINA_UNUSED, void *event_i
pager_gadget_config_objects->grab_btn = 2; pager_gadget_config_objects->grab_btn = 2;
pager_gadget_config_objects->grab_dia = e_grab_dialog_show(NULL, EINA_TRUE, pager_gadget_config_objects->grab_dia = e_grab_dialog_show(NULL, EINA_TRUE,
_config_grab_cb_key_down, _config_grab_cb_mouse_down, NULL, NULL); _config_grab_cb_key_down, _config_grab_cb_mouse_down, NULL, NULL);
e_object_del_attach_func_set(E_OBJECT(pager_gadget_config_objects->grab_dia), _config_grab_window_del); e_object_del_attach_func_set(E_OBJECT(pager_gadget_config_objects->grab_dia), _config_grab_window_del);
} }
@ -314,7 +318,7 @@ _config_create_pages(Evas_Object *parent)
ow = elm_button_add(tb); ow = elm_button_add(tb);
elm_object_text_set(ow, _("Configure virtual deskstops")); elm_object_text_set(ow, _("Configure virtual deskstops"));
evas_object_smart_callback_add(ow, "clicked", evas_object_smart_callback_add(ow, "clicked",
_config_virtual_desks_show, NULL); _config_virtual_desks_show, NULL);
elm_table_pack(tb, ow, 0, 0, 1, 1); elm_table_pack(tb, ow, 0, 0, 1, 1);
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
@ -330,7 +334,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_flip_desk = ow; pager_gadget_config_objects->o_flip_desk = ow;
@ -342,7 +346,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_show_desk_names = ow; pager_gadget_config_objects->o_show_desk_names = ow;
@ -362,7 +366,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "delay,changed", evas_object_smart_callback_add(ow, "delay,changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_drag_resist = ow; pager_gadget_config_objects->o_drag_resist = ow;
@ -378,7 +382,7 @@ _config_create_pages(Evas_Object *parent)
ow = elm_button_add(tb); ow = elm_button_add(tb);
elm_object_text_set(ow, _("Click to set")); elm_object_text_set(ow, _("Click to set"));
evas_object_smart_callback_add(ow, "clicked", evas_object_smart_callback_add(ow, "clicked",
_config_grab_window_show, (void *)BUTTON_DRAG); _config_grab_window_show, (void *)BUTTON_DRAG);
elm_table_pack(tb, ow, 0, row, 1, 1); elm_table_pack(tb, ow, 0, row, 1, 1);
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
@ -398,7 +402,7 @@ _config_create_pages(Evas_Object *parent)
ow = elm_button_add(tb); ow = elm_button_add(tb);
elm_object_text_set(ow, _("Click to set")); elm_object_text_set(ow, _("Click to set"));
evas_object_smart_callback_add(ow, "clicked", evas_object_smart_callback_add(ow, "clicked",
_config_grab_window_show, (void *)BUTTON_NOPLACE); _config_grab_window_show, (void *)BUTTON_NOPLACE);
elm_table_pack(tb, ow, 0, row, 1, 1); elm_table_pack(tb, ow, 0, row, 1, 1);
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
@ -417,7 +421,7 @@ _config_create_pages(Evas_Object *parent)
ow = elm_button_add(tb); ow = elm_button_add(tb);
elm_object_text_set(ow, _("Click to set")); elm_object_text_set(ow, _("Click to set"));
evas_object_smart_callback_add(ow, "clicked", evas_object_smart_callback_add(ow, "clicked",
_config_grab_window_show, (void *)BUTTON_DESK); _config_grab_window_show, (void *)BUTTON_DESK);
elm_table_pack(tb, ow, 0, row, 1, 1); elm_table_pack(tb, ow, 0, row, 1, 1);
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
@ -449,7 +453,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup = ow; pager_gadget_config_objects->o_popup = ow;
@ -471,10 +475,10 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "delay,changed", evas_object_smart_callback_add(ow, "delay,changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_height = ow; pager_gadget_config_objects->o_popup_height = ow;
ow = elm_label_add(m); ow = elm_label_add(m);
elm_object_text_set(ow, _("Popup duration")); elm_object_text_set(ow, _("Popup duration"));
elm_object_disabled_set(ow, !pager_config->popup); elm_object_disabled_set(ow, !pager_config->popup);
@ -493,7 +497,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "delay,changed", evas_object_smart_callback_add(ow, "delay,changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_speed = ow; pager_gadget_config_objects->o_popup_speed = ow;
@ -515,7 +519,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "delay,changed", evas_object_smart_callback_add(ow, "delay,changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_act_height = ow; pager_gadget_config_objects->o_popup_act_height = ow;
@ -542,7 +546,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_urgent = ow; pager_gadget_config_objects->o_popup_urgent = ow;
@ -555,7 +559,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_urgent_stick = ow; pager_gadget_config_objects->o_popup_urgent_stick = ow;
@ -568,7 +572,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_urgent_focus = ow; pager_gadget_config_objects->o_popup_urgent_focus = ow;
@ -590,7 +594,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "delay,changed", evas_object_smart_callback_add(ow, "delay,changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_popup_urgent_speed = ow; pager_gadget_config_objects->o_popup_urgent_speed = ow;
@ -617,7 +621,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_permanent = ow; pager_gadget_config_objects->o_permanent = ow;
@ -629,7 +633,7 @@ _config_create_pages(Evas_Object *parent)
E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL); E_ALIGN(ow, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(ow, EVAS_HINT_EXPAND, 0); E_WEIGHT(ow, EVAS_HINT_EXPAND, 0);
evas_object_smart_callback_add(ow, "changed", evas_object_smart_callback_add(ow, "changed",
_config_value_changed, NULL); _config_value_changed, NULL);
evas_object_show(ow); evas_object_show(ow);
pager_gadget_config_objects->o_plain = ow; pager_gadget_config_objects->o_plain = ow;
@ -672,19 +676,19 @@ config_pager(E_Zone *zone)
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS); elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_scroller_content_min_limit(list, 1, 1); elm_scroller_content_min_limit(list, 1, 1);
it = elm_list_item_append(list, _("General"), NULL, NULL, it = elm_list_item_append(list, _("General"), NULL, NULL,
_config_show_general, NULL); _config_show_general, NULL);
elm_list_item_selected_set(it, 1); elm_list_item_selected_set(it, 1);
it = elm_list_item_append(list, _("Popup"), NULL, NULL, it = elm_list_item_append(list, _("Popup"), NULL, NULL,
_config_show_popup, NULL); _config_show_popup, NULL);
it = elm_list_item_append(list, _("Urgent"), NULL, NULL, it = elm_list_item_append(list, _("Urgent"), NULL, NULL,
_config_show_urgent, NULL); _config_show_urgent, NULL);
it = elm_list_item_append(list, _("Style"), NULL, NULL, it = elm_list_item_append(list, _("Style"), NULL, NULL,
_config_show_style, NULL); _config_show_style, NULL);
elm_list_go(list); elm_list_go(list);
evas_object_show(list); evas_object_show(list);
elm_table_pack(tb, elm_table_pack(tb,
_config_create_pages(tb), 1, 1, 1, 1); _config_create_pages(tb), 1, 1, 1, 1);
_config_show_general(NULL, NULL, NULL); _config_show_general(NULL, NULL, NULL);
popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE); popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);

View File

@ -105,3 +105,4 @@ e_modapi_gadget_save(E_Module *m EINA_UNUSED)
e_config_domain_save("module.pager", conf_edd, pager_config); e_config_domain_save("module.pager", conf_edd, pager_config);
return 1; return 1;
} }

View File

@ -9,26 +9,26 @@ typedef struct _Pager_Popup Pager_Popup;
struct _Instance struct _Instance
{ {
Evas_Object *o_pager; /* table */ Evas_Object *o_pager; /* table */
Pager *pager; Pager *pager;
Pager_Popup *popup; Pager_Popup *popup;
}; };
struct _Pager struct _Pager
{ {
Instance *inst; Instance *inst;
Pager_Popup *popup; Pager_Popup *popup;
Evas_Object *o_table; Evas_Object *o_table;
E_Zone *zone; E_Zone *zone;
int xnum, ynum; int xnum, ynum;
Eina_List *desks; Eina_List *desks;
Pager_Desk *active_pd; Pager_Desk *active_pd;
unsigned char dragging : 1; unsigned char dragging : 1;
unsigned char just_dragged : 1; unsigned char just_dragged : 1;
E_Client *active_drag_client; E_Client *active_drag_client;
Ecore_Job *recalc; Ecore_Job *recalc;
Eina_Bool invert : 1; Eina_Bool invert : 1;
Eina_Bool plain : 1; Eina_Bool plain : 1;
}; };
struct _Pager_Desk struct _Pager_Desk
@ -77,75 +77,75 @@ struct _Pager_Popup
unsigned char urgent : 1; unsigned char urgent : 1;
}; };
static void _pager_cb_mirror_add(Pager_Desk *pd, Evas_Object *obj, Evas_Object *mirror); static void _pager_cb_mirror_add(Pager_Desk *pd, Evas_Object *obj, Evas_Object *mirror);
static void _pager_cb_obj_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED); static void _pager_cb_obj_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
static void _pager_cb_obj_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED); static void _pager_cb_obj_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
static void _button_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _button_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static Evas_Object *_pager_gadget_configure(Evas_Object *g); static Evas_Object *_pager_gadget_configure(Evas_Object *g);
static Eina_Bool _pager_cb_event_powersave_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_powersave_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_desk_name_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_desk_name_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_compositor_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_compositor_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_iconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_iconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_uniconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_uniconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_stick(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_stick(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_unstick(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_unstick(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_desk_set(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_desk_set(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_stack(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_stack(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_icon_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_icon_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_focus_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_focus_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_focus_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_focus_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_property(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_cb_event_client_property(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_cb_event_client_urgent_change(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Property *ev); static Eina_Bool _pager_cb_event_client_urgent_change(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Property *ev);
static void _pager_window_move(Pager_Win *pw); static void _pager_window_move(Pager_Win *pw);
static void _pager_window_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED); static void _pager_window_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
static void _pager_window_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_window_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static void _pager_window_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_window_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static void _pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static void *_pager_window_cb_drag_convert(E_Drag *drag, const char *type); static void *_pager_window_cb_drag_convert(E_Drag *drag, const char *type);
static void _pager_window_cb_drag_finished(E_Drag *drag, int dropped); static void _pager_window_cb_drag_finished(E_Drag *drag, int dropped);
static void _pager_drop_cb_enter(void *data, const char *type EINA_UNUSED, void *event_info); static void _pager_drop_cb_enter(void *data, const char *type EINA_UNUSED, void *event_info);
static void _pager_drop_cb_move(void *data, const char *type EINA_UNUSED, void *event_info); static void _pager_drop_cb_move(void *data, const char *type EINA_UNUSED, void *event_info);
static void _pager_drop_cb_leave(void *data, const char *type EINA_UNUSED, void *event_info EINA_UNUSED); static void _pager_drop_cb_leave(void *data, const char *type EINA_UNUSED, void *event_info EINA_UNUSED);
static void _pager_drop_cb_drop(void *data, const char *type, void *event_info); static void _pager_drop_cb_drop(void *data, const char *type, void *event_info);
static void _pager_update_drop_position(Pager *p, Pager_Desk *pd, Evas_Coord x, Evas_Coord y); static void _pager_update_drop_position(Pager *p, Pager_Desk *pd, Evas_Coord x, Evas_Coord y);
static void _pager_desk_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_desk_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static void _pager_desk_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_desk_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static void _pager_desk_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_desk_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static void _pager_desk_cb_drag_finished(E_Drag *drag, int dropped); static void _pager_desk_cb_drag_finished(E_Drag *drag, int dropped);
static void _pager_desk_cb_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _pager_desk_cb_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info);
static Eina_Bool _pager_popup_cb_timeout(void *data); static Eina_Bool _pager_popup_cb_timeout(void *data);
static Pager *_pager_new(Evas *evas, Eina_Bool popup); static Pager *_pager_new(Evas *evas, Eina_Bool popup);
static void _pager_free(Pager *p); static void _pager_free(Pager *p);
static void _pager_fill(Pager *p); static void _pager_fill(Pager *p);
static void _pager_orient(Instance *inst, E_Gadget_Site_Orient orient); static void _pager_orient(Instance *inst, E_Gadget_Site_Orient orient);
static void _pager_empty(Pager *p); static void _pager_empty(Pager *p);
static Pager_Desk *_pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos, Eina_Bool invert); static Pager_Desk *_pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos, Eina_Bool invert);
static void _pager_desk_free(Pager_Desk *pd); static void _pager_desk_free(Pager_Desk *pd);
static void _pager_desk_select(Pager_Desk *pd); static void _pager_desk_select(Pager_Desk *pd);
static Pager_Desk *_pager_desk_find(Pager *p, E_Desk *desk); static Pager_Desk *_pager_desk_find(Pager *p, E_Desk *desk);
static void _pager_desk_switch(Pager_Desk *pd1, Pager_Desk *pd2); static void _pager_desk_switch(Pager_Desk *pd1, Pager_Desk *pd2);
static Pager_Win *_pager_window_new(Pager_Desk *pd, Evas_Object *mirror, E_Client *client); static Pager_Win *_pager_window_new(Pager_Desk *pd, Evas_Object *mirror, E_Client *client);
static void _pager_window_free(Pager_Win *pw); static void _pager_window_free(Pager_Win *pw);
static Pager_Popup *pager_popup_new(int keyaction); static Pager_Popup *pager_popup_new(int keyaction);
static void _pager_popup_free(Pager_Popup *pp); static void _pager_popup_free(Pager_Popup *pp);
static Pager_Popup *_pager_popup_find(E_Zone *zone); static Pager_Popup *_pager_popup_find(E_Zone *zone);
/* functions for pager popup on key actions */ /* functions for pager popup on key actions */
static int _pager_popup_show(void); static int _pager_popup_show(void);
static void _pager_popup_hide(int switch_desk); static void _pager_popup_hide(int switch_desk);
static Eina_Bool _pager_popup_cb_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_popup_cb_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static void _pager_popup_desk_switch(int x, int y); static void _pager_popup_desk_switch(int x, int y);
static void _pager_popup_modifiers_set(int mod); static void _pager_popup_modifiers_set(int mod);
static Eina_Bool _pager_popup_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_popup_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _pager_popup_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); static Eina_Bool _pager_popup_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static void _pager_popup_cb_action_show(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED, Ecore_Event_Key *ev EINA_UNUSED); static void _pager_popup_cb_action_show(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED, Ecore_Event_Key *ev EINA_UNUSED);
static void _pager_popup_cb_action_switch(E_Object *obj EINA_UNUSED, const char *params, Ecore_Event_Key *ev); static void _pager_popup_cb_action_switch(E_Object *obj EINA_UNUSED, const char *params, Ecore_Event_Key *ev);
/* variables for pager popup on key actions */ /* variables for pager popup on key actions */
static Ecore_Window input_window = 0; static Ecore_Window input_window = 0;
@ -178,9 +178,11 @@ _pager_location_get(Instance *inst)
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_HORIZONTAL:
s = "top"; s = "top";
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL: case E_GADGET_SITE_ORIENT_VERTICAL:
s = "left"; s = "left";
break; break;
case E_GADGET_SITE_ORIENT_NONE: case E_GADGET_SITE_ORIENT_NONE:
s = "left"; s = "left";
break; break;
@ -193,9 +195,11 @@ _pager_location_get(Instance *inst)
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_HORIZONTAL:
s = "bottom"; s = "bottom";
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL: case E_GADGET_SITE_ORIENT_VERTICAL:
s = "left"; s = "left";
break; break;
case E_GADGET_SITE_ORIENT_NONE: case E_GADGET_SITE_ORIENT_NONE:
s = "left"; s = "left";
break; break;
@ -213,9 +217,11 @@ _pager_location_get(Instance *inst)
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_HORIZONTAL:
s = "top"; s = "top";
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL: case E_GADGET_SITE_ORIENT_VERTICAL:
s = "right"; s = "right";
break; break;
case E_GADGET_SITE_ORIENT_NONE: case E_GADGET_SITE_ORIENT_NONE:
s = "right"; s = "right";
break; break;
@ -228,9 +234,11 @@ _pager_location_get(Instance *inst)
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_HORIZONTAL:
s = "bottom"; s = "bottom";
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL: case E_GADGET_SITE_ORIENT_VERTICAL:
s = "right"; s = "right";
break; break;
case E_GADGET_SITE_ORIENT_NONE: case E_GADGET_SITE_ORIENT_NONE:
s = "right"; s = "right";
break; break;
@ -250,9 +258,11 @@ _pager_location_get(Instance *inst)
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_HORIZONTAL:
s = "bottom"; s = "bottom";
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL: case E_GADGET_SITE_ORIENT_VERTICAL:
s = "left"; s = "left";
break; break;
default: default:
s = "bottom"; s = "bottom";
break; break;
@ -316,7 +326,6 @@ _pager_gadget_anchor_change_cb(void *data, Evas_Object *obj, void *event_info EI
} }
} }
static void static void
_pager_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) _pager_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{ {
@ -329,7 +338,7 @@ _pager_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNU
_pager_orient(inst, e_gadget_site_orient_get(obj)); _pager_orient(inst, e_gadget_site_orient_get(obj));
_pager_empty(inst->pager); _pager_empty(inst->pager);
_pager_fill(inst->pager); _pager_fill(inst->pager);
EINA_LIST_FOREACH(inst->pager->desks, l, pd) EINA_LIST_FOREACH(inst->pager->desks, l, pd)
{ {
if (!pd->drop_handler) if (!pd->drop_handler)
@ -341,9 +350,9 @@ _pager_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNU
}; };
pd->drop_handler = pd->drop_handler =
e_gadget_drop_handler_add(inst->o_pager, pd, e_gadget_drop_handler_add(inst->o_pager, pd,
_pager_drop_cb_enter, _pager_drop_cb_move, _pager_drop_cb_enter, _pager_drop_cb_move,
_pager_drop_cb_leave, _pager_drop_cb_drop, _pager_drop_cb_leave, _pager_drop_cb_drop,
drop, 3); drop, 3);
//edje_object_part_swallow(pd->o_desk, "e.swallow.drop", pd->drop_handler); //edje_object_part_swallow(pd->o_desk, "e.swallow.drop", pd->drop_handler);
evas_object_show(pd->drop_handler); evas_object_show(pd->drop_handler);
} }
@ -361,15 +370,16 @@ _pager_orient(Instance *inst, E_Gadget_Site_Orient orient)
{ {
switch (orient) switch (orient)
{ {
case E_GADGET_SITE_ORIENT_HORIZONTAL:
inst->pager->invert = EINA_FALSE;
break;
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_VERTICAL:
inst->pager->invert = EINA_FALSE; inst->pager->invert = EINA_TRUE;
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL:
inst->pager->invert = EINA_TRUE; default:
break; inst->pager->invert = EINA_FALSE;
default:
inst->pager->invert = EINA_FALSE;
} }
} }
if (inst->pager->zone) if (inst->pager->zone)
@ -442,17 +452,20 @@ _pager_new(Evas *evas, Eina_Bool popup)
{ {
switch (e_powersave_mode_get()) switch (e_powersave_mode_get())
{ {
case E_POWERSAVE_MODE_HIGH: case E_POWERSAVE_MODE_HIGH:
p->plain = EINA_TRUE; p->plain = EINA_TRUE;
break; break;
case E_POWERSAVE_MODE_EXTREME:
p->plain = EINA_TRUE; case E_POWERSAVE_MODE_EXTREME:
break; p->plain = EINA_TRUE;
case E_POWERSAVE_MODE_FREEZE: break;
p->plain = EINA_TRUE;
break; case E_POWERSAVE_MODE_FREEZE:
default: p->plain = EINA_TRUE;
p->plain = EINA_FALSE; break;
default:
p->plain = EINA_FALSE;
} }
} }
p->o_table = elm_table_add(e_win_evas_win_get(evas)); p->o_table = elm_table_add(e_win_evas_win_get(evas));
@ -488,22 +501,23 @@ _pager_fill(Pager *p)
orient = e_gadget_site_orient_get(e_gadget_site_get(p->inst->o_pager)); orient = e_gadget_site_orient_get(e_gadget_site_get(p->inst->o_pager));
switch (orient) switch (orient)
{ {
case E_GADGET_SITE_ORIENT_HORIZONTAL:
p->invert = EINA_FALSE;
break;
case E_GADGET_SITE_ORIENT_HORIZONTAL: case E_GADGET_SITE_ORIENT_VERTICAL:
p->invert = EINA_FALSE; p->invert = EINA_TRUE;
break; break;
case E_GADGET_SITE_ORIENT_VERTICAL:
p->invert = EINA_TRUE; default:
break; p->invert = EINA_FALSE;
default:
p->invert = EINA_FALSE;
} }
} }
e_zone_desk_count_get(p->zone, &(p->xnum), &(p->ynum)); e_zone_desk_count_get(p->zone, &(p->xnum), &(p->ynum));
if (p->ynum != 1) p->invert = EINA_FALSE; if (p->ynum != 1) p->invert = EINA_FALSE;
for (x = 0; x < p->xnum; x++) for (x = 0; x < p->xnum; x++)
{ {
if ((p->plain) || (pager_config->permanent_plain)) if ((p->plain) || (pager_config->permanent_plain))
{ {
if (!eina_list_count(phandlers)) if (!eina_list_count(phandlers))
{ {
@ -626,18 +640,18 @@ _pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos, Eina_Bool invert)
pd->o_layout = e_layout_add(e); pd->o_layout = e_layout_add(e);
e_layout_virtual_size_set(pd->o_layout, desk->zone->w, desk->zone->h); e_layout_virtual_size_set(pd->o_layout, desk->zone->w, desk->zone->h);
edje_object_part_swallow(pd->o_desk, "e.swallow.content", pd->o_layout); edje_object_part_swallow(pd->o_desk, "e.swallow.content", pd->o_layout);
evas_object_show(pd->o_layout); evas_object_show(pd->o_layout);
E_CLIENT_FOREACH(ec) E_CLIENT_FOREACH(ec)
{ {
Pager_Win *pw; Pager_Win *pw;
if (e_client_util_ignored_get(ec)) continue; if (e_client_util_ignored_get(ec)) continue;
if ((ec->new_client) || (ec->zone != desk->zone) || if ((ec->new_client) || (ec->zone != desk->zone) ||
((ec->desk != desk) && (!ec->sticky))) ((ec->desk != desk) && (!ec->sticky)))
continue; continue;
pw = _pager_window_new(pd, NULL, ec); pw = _pager_window_new(pd, NULL, ec);
if (pw) pd->wins = eina_list_append(pd->wins, pw); if (pw) pd->wins = eina_list_append(pd->wins, pw);
} }
} }
else else
{ {
@ -662,10 +676,10 @@ _pager_desk_new(Pager *p, E_Desk *desk, int xpos, int ypos, Eina_Bool invert)
if (pd->pager->inst) if (pd->pager->inst)
{ {
pd->drop_handler = pd->drop_handler =
e_gadget_drop_handler_add(p->inst->o_pager, pd, e_gadget_drop_handler_add(p->inst->o_pager, pd,
_pager_drop_cb_enter, _pager_drop_cb_move, _pager_drop_cb_enter, _pager_drop_cb_move,
_pager_drop_cb_leave, _pager_drop_cb_drop, _pager_drop_cb_leave, _pager_drop_cb_drop,
drop, 3); drop, 3);
edje_object_part_swallow(pd->o_desk, "e.swallow.drop", pd->drop_handler); edje_object_part_swallow(pd->o_desk, "e.swallow.drop", pd->drop_handler);
evas_object_show(pd->drop_handler); evas_object_show(pd->drop_handler);
} }
@ -677,7 +691,7 @@ static void
_pager_desk_free(Pager_Desk *pd) _pager_desk_free(Pager_Desk *pd)
{ {
Pager_Win *w; Pager_Win *w;
if (pd->drop_handler) if (pd->drop_handler)
evas_object_del(pd->drop_handler); evas_object_del(pd->drop_handler);
pd->drop_handler = NULL; pd->drop_handler = NULL;
@ -702,7 +716,7 @@ _pager_desk_select(Pager_Desk *pd)
} }
pd->current = 1; pd->current = 1;
evas_object_raise(pd->o_desk); evas_object_raise(pd->o_desk);
if (s) if (s)
snprintf(ori, sizeof(ori), "e,state,selected,%s", s); snprintf(ori, sizeof(ori), "e,state,selected,%s", s);
else else
snprintf(ori, sizeof(ori), "e,state,selected,bottom"); snprintf(ori, sizeof(ori), "e,state,selected,bottom");
@ -842,11 +856,11 @@ _pager_window_new(Pager_Desk *pd, Evas_Object *mirror, E_Client *client)
pw->skip_winlist = client->netwm.state.skip_pager; pw->skip_winlist = client->netwm.state.skip_pager;
o = edje_object_add(evas_object_evas_get(pd->pager->o_table)); o = edje_object_add(evas_object_evas_get(pd->pager->o_table));
pw->o_window = o; pw->o_window = o;
e_theme_edje_object_set(o, "base/theme/gadgets/pager", e_theme_edje_object_set(o, "base/theme/gadgets/pager",
"e/gadget/pager/plain/window"); "e/gadget/pager/plain/window");
if (visible) evas_object_show(o); if (visible) evas_object_show(o);
e_layout_pack(pd->o_layout, pw->o_window); e_layout_pack(pd->o_layout, pw->o_window);
e_layout_child_raise(pw->o_window); e_layout_child_raise(pw->o_window);
o = e_client_icon_add(client, evas_object_evas_get(pd->pager->o_table)); o = e_client_icon_add(client, evas_object_evas_get(pd->pager->o_table));
if (o) if (o)
@ -860,13 +874,13 @@ _pager_window_new(Pager_Desk *pd, Evas_Object *mirror, E_Client *client)
pw->client->y - pw->client->zone->y); pw->client->y - pw->client->zone->y);
e_layout_child_resize(pw->o_window, pw->client->w, pw->client->h); e_layout_child_resize(pw->o_window, pw->client->w, pw->client->h);
evas_object_show(o); evas_object_show(o);
o = pw->o_window; o = pw->o_window;
} }
else else
{ {
pw->o_mirror = mirror; pw->o_mirror = mirror;
o = mirror; o = mirror;
} }
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_pager_window_cb_mouse_down, pw); _pager_window_cb_mouse_down, pw);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
@ -902,7 +916,7 @@ _pager_window_free(Pager_Win *pw)
o = pw->o_window; o = pw->o_window;
if (o) if (o)
evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL, evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
_pager_window_cb_del, pw); _pager_window_cb_del, pw);
if (pw->o_icon) evas_object_del(pw->o_icon); if (pw->o_icon) evas_object_del(pw->o_icon);
if (pw->o_window) evas_object_del(pw->o_window); if (pw->o_window) evas_object_del(pw->o_window);
free(pw); free(pw);
@ -933,7 +947,7 @@ pager_popup_new(int keyaction)
/* Show popup */ /* Show popup */
pp->pager = _pager_new(e_comp->evas, EINA_TRUE); pp->pager = _pager_new(e_comp->evas, EINA_TRUE);
pp->pager->popup = pp; pp->pager->popup = pp;
pp->urgent = 0; pp->urgent = 0;
@ -1016,23 +1030,23 @@ _pager_popup_find(E_Zone *zone)
static void static void
_pager_cb_obj_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) _pager_cb_obj_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{ {
Instance *inst = data; Instance *inst = data;
Eina_List *l; Eina_List *l;
Pager_Desk *pd; Pager_Desk *pd;
EINA_LIST_FOREACH(inst->pager->desks, l, pd) EINA_LIST_FOREACH(inst->pager->desks, l, pd)
edje_object_signal_emit(pd->o_desk, "e,state,hidden", "e"); edje_object_signal_emit(pd->o_desk, "e,state,hidden", "e");
} }
static void static void
_pager_cb_obj_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) _pager_cb_obj_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{ {
Instance *inst = data; Instance *inst = data;
Eina_List *l; Eina_List *l;
Pager_Desk *pd; Pager_Desk *pd;
EINA_LIST_FOREACH(inst->pager->desks, l, pd) EINA_LIST_FOREACH(inst->pager->desks, l, pd)
edje_object_signal_emit(pd->o_desk, "e,state,visible", "e"); edje_object_signal_emit(pd->o_desk, "e,state,visible", "e");
} }
static void static void
@ -1040,7 +1054,7 @@ _pager_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
{ {
Instance *inst = data; Instance *inst = data;
Pager *p = inst->pager; Pager *p = inst->pager;
E_Zone *zone = e_comp_object_util_zone_get(p->o_table); E_Zone *zone = e_comp_object_util_zone_get(p->o_table);
if (zone != p->zone) if (zone != p->zone)
{ {
p->zone = zone; p->zone = zone;
@ -1066,7 +1080,7 @@ _button_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
if (_pager_check_modifiers(ev->modifiers)) return; if (_pager_check_modifiers(ev->modifiers)) return;
if (ev->button != 3) return; if (ev->button != 3) return;
if(!pager_config) return; if (!pager_config) return;
if (cfg_dialog) return; if (cfg_dialog) return;
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
e_gadget_configure(inst->o_pager); e_gadget_configure(inst->o_pager);
@ -1087,17 +1101,20 @@ _pager_cb_config_gadget_updated(Eina_Bool style_changed)
{ {
switch (e_powersave_mode_get()) switch (e_powersave_mode_get())
{ {
case E_POWERSAVE_MODE_HIGH: case E_POWERSAVE_MODE_HIGH:
p->plain = EINA_TRUE; p->plain = EINA_TRUE;
break; break;
case E_POWERSAVE_MODE_EXTREME:
p->plain = EINA_TRUE; case E_POWERSAVE_MODE_EXTREME:
break; p->plain = EINA_TRUE;
case E_POWERSAVE_MODE_FREEZE: break;
p->plain = EINA_TRUE;
break; case E_POWERSAVE_MODE_FREEZE:
default: p->plain = EINA_TRUE;
p->plain = EINA_FALSE; break;
default:
p->plain = EINA_FALSE;
} }
} }
_pager_empty(p); _pager_empty(p);
@ -1382,8 +1399,8 @@ _pager_window_desk_change(Pager *pager, E_Client *ec)
/* and this pager zone is for this client */ /* and this pager zone is for this client */
/* see if the window is in this pager at all */ /* see if the window is in this pager at all */
pw = _pager_window_find(pager, ec); pw = _pager_window_find(pager, ec);
if (pw) if (pw) /* is it sticky */
{ /* is it sticky */ {
if (ec->sticky) if (ec->sticky)
{ {
/* if its sticky and in this pager - its already everywhere, so abort /* if its sticky and in this pager - its already everywhere, so abort
@ -1734,7 +1751,6 @@ _pager_cb_event_client_property(void *data EINA_UNUSED, int type EINA_UNUSED, vo
return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON;
} }
static Eina_Bool static Eina_Bool
_pager_cb_event_zone_desk_count_set(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Zone_Desk_Count_Set *ev) _pager_cb_event_zone_desk_count_set(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Zone_Desk_Count_Set *ev)
{ {
@ -1785,7 +1801,7 @@ _pager_cb_event_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *ev
ecore_timer_loop_reset(pp->timer); ecore_timer_loop_reset(pp->timer);
else else
pp->timer = ecore_timer_loop_add(pager_config->popup_speed, pp->timer = ecore_timer_loop_add(pager_config->popup_speed,
_pager_popup_cb_timeout, pp); _pager_popup_cb_timeout, pp);
} }
return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON;
@ -1832,8 +1848,8 @@ _pager_cb_event_client_urgent_change(void *data EINA_UNUSED, int type EINA_UNUSE
if (!eina_list_count(pagers)) return ECORE_CALLBACK_RENEW; if (!eina_list_count(pagers)) return ECORE_CALLBACK_RENEW;
if (pager_config->popup_urgent && (!e_client_util_desk_visible(ev->ec, e_desk_current_get(ev->ec->zone))) && if (pager_config->popup_urgent && (!e_client_util_desk_visible(ev->ec, e_desk_current_get(ev->ec->zone))) &&
(pager_config->popup_urgent_focus || (pager_config->popup_urgent_focus ||
(!pager_config->popup_urgent_focus && (!ev->ec->focused) && (!ev->ec->want_focus)))) (!pager_config->popup_urgent_focus && (!ev->ec->focused) && (!ev->ec->want_focus))))
{ {
Pager_Popup *pp; Pager_Popup *pp;
@ -1846,7 +1862,7 @@ _pager_cb_event_client_urgent_change(void *data EINA_UNUSED, int type EINA_UNUSE
if (!pager_config->popup_urgent_stick) if (!pager_config->popup_urgent_stick)
pp->timer = ecore_timer_loop_add(pager_config->popup_urgent_speed, pp->timer = ecore_timer_loop_add(pager_config->popup_urgent_speed,
_pager_popup_cb_timeout, pp); _pager_popup_cb_timeout, pp);
pp->urgent = 1; pp->urgent = 1;
} }
} }
@ -1865,8 +1881,8 @@ _pager_cb_event_client_urgent_change(void *data EINA_UNUSED, int type EINA_UNUSE
{ {
if ((pd->pager) && (pd->pager->inst) && if ((pd->pager) && (pd->pager->inst) &&
(!pager_config->popup_urgent)) (!pager_config->popup_urgent))
edje_object_signal_emit(pd->o_desk, edje_object_signal_emit(pd->o_desk,
"e,state,urgent", "e"); "e,state,urgent", "e");
} }
edje_object_signal_emit(pw->o_window, edje_object_signal_emit(pw->o_window,
"e,state,urgent", "e"); "e,state,urgent", "e");
@ -2029,7 +2045,7 @@ _pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EI
evas_object_hide(pw->o_window); evas_object_hide(pw->o_window);
} }
else else
{ {
evas_object_geometry_get(pw->o_mirror, &x, &y, &w, &h); evas_object_geometry_get(pw->o_mirror, &x, &y, &w, &h);
evas_object_hide(pw->o_mirror); evas_object_hide(pw->o_mirror);
} }
@ -2041,7 +2057,7 @@ _pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EI
{ {
o = edje_object_add(drag->evas); o = edje_object_add(drag->evas);
e_theme_edje_object_set(o, "base/theme/gadgets/pager/plain", e_theme_edje_object_set(o, "base/theme/gadgets/pager/plain",
"e/gadget/pager/plain/window"); "e/gadget/pager/plain/window");
evas_object_show(o); evas_object_show(o);
oo = e_client_icon_add(pw->client, drag->evas); oo = e_client_icon_add(pw->client, drag->evas);
@ -2049,7 +2065,7 @@ _pager_window_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EI
{ {
evas_object_show(oo); evas_object_show(oo);
edje_object_part_swallow(o, "e.swallow.icon", oo); edje_object_part_swallow(o, "e.swallow.icon", oo);
} }
} }
else else
{ {
@ -2129,7 +2145,6 @@ _pager_window_cb_drag_finished(E_Drag *drag, int dropped)
else y = 0; else y = 0;
evas_object_move(pw->client->frame, x, y); evas_object_move(pw->client->frame, x, y);
if (!(pw->client->lock_user_stacking)) if (!(pw->client->lock_user_stacking))
evas_object_raise(pw->client->frame); evas_object_raise(pw->client->frame);
evas_object_focus_set(pw->client->frame, 1); evas_object_focus_set(pw->client->frame, 1);
@ -2302,24 +2317,24 @@ _pager_drop_cb_drop(void *data, const char *type, void *event_info)
if (ec->maximized) if (ec->maximized)
e_client_unmaximize(ec, E_MAXIMIZE_BOTH); e_client_unmaximize(ec, E_MAXIMIZE_BOTH);
if (fullscreen) e_client_unfullscreen(ec); if (fullscreen) e_client_unfullscreen(ec);
ec->hidden = 0; ec->hidden = 0;
e_client_desk_set(ec, pd->desk); e_client_desk_set(ec, pd->desk);
evas_object_raise(ec->frame); evas_object_raise(ec->frame);
if ((!max) && (!fullscreen)) if ((!max) && (!fullscreen))
{ {
int zx, zy, zw, zh, mx, my; int zx, zy, zw, zh, mx, my;
if ((pd->pager->plain) || (pager_config->permanent_plain)) if ((pd->pager->plain) || (pager_config->permanent_plain))
{ {
e_layout_coord_canvas_to_virtual(pd->o_layout, ev->x + dx, ev->y + dy, e_layout_coord_canvas_to_virtual(pd->o_layout, ev->x + dx, ev->y + dy,
&nx, &ny); &nx, &ny);
} }
else else
{ {
e_deskmirror_coord_canvas_to_virtual(pd->o_layout, e_deskmirror_coord_canvas_to_virtual(pd->o_layout,
ev->x + dx, ev->x + dx,
ev->y + dy, ev->y + dy,
&nx, &ny); &nx, &ny);
} }
e_zone_useful_geometry_get(pd->desk->zone, e_zone_useful_geometry_get(pd->desk->zone,
&zx, &zy, &zw, &zh); &zx, &zy, &zw, &zh);
@ -2448,7 +2463,7 @@ _pager_desk_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
{ {
o = edje_object_add(drag->evas); o = edje_object_add(drag->evas);
e_theme_edje_object_set(o, "base/theme/gadgets/pager", e_theme_edje_object_set(o, "base/theme/gadgets/pager",
"e/gadget/pager/plain/desk"); "e/gadget/pager/plain/desk");
evas_object_show(o); evas_object_show(o);
} }
else else
@ -2566,8 +2581,8 @@ _pager_popup_show(void)
Pager_Popup *pp; Pager_Popup *pp;
//const char *drop[] = //const char *drop[] =
//{ //{
//"enlightenment/pager_win", "enlightenment/border", //"enlightenment/pager_win", "enlightenment/border",
//"enlightenment/vdesktop" //"enlightenment/vdesktop"
//}; //};
if ((act_popup) || (input_window)) return 0; if ((act_popup) || (input_window)) return 0;
@ -2767,7 +2782,7 @@ _pager_popup_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve
if (pp) if (pp)
{ {
E_Desk *desk; E_Desk *desk;
desk = e_desk_at_xy_get(pp->pager->zone, desk = e_desk_at_xy_get(pp->pager->zone,
current_desk->x, current_desk->y); current_desk->x, current_desk->y);
if (desk) e_desk_show(desk); if (desk) e_desk_show(desk);

View File

@ -202,16 +202,16 @@ _batman_update(Instance *inst, int full, int time_left, Eina_Bool have_battery,
{ {
if (have_power && (full < 100)) if (have_power && (full < 100))
elm_layout_signal_emit(inst->cfg->batman.o_gadget, elm_layout_signal_emit(inst->cfg->batman.o_gadget,
"e,state,charging", "e,state,charging",
"e"); "e");
else else
{ {
elm_layout_signal_emit(inst->cfg->batman.o_gadget, elm_layout_signal_emit(inst->cfg->batman.o_gadget,
"e,state,discharging", "e,state,discharging",
"e"); "e");
if (inst->popup_battery) if (inst->popup_battery)
elm_layout_signal_emit(inst->popup_battery, elm_layout_signal_emit(inst->popup_battery,
"e,state,discharging", "e"); "e,state,discharging", "e");
} }
} }
if (have_battery) if (have_battery)
@ -357,7 +357,7 @@ _screensaver_on(void *data)
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
Instance *inst = data; Instance *inst = data;
#else #else
(void) data; (void)data;
#endif #endif
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
@ -417,7 +417,8 @@ _batman_config_updated(Instance *inst)
} }
} }
static void _warning_popup_dismissed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) static void
_warning_popup_dismissed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{ {
Instance *inst = data; Instance *inst = data;
@ -425,7 +426,6 @@ static void _warning_popup_dismissed(void *data, Evas_Object *obj EINA_UNUSED, v
E_FREE_FUNC(inst->warning, evas_object_del); E_FREE_FUNC(inst->warning, evas_object_del);
} }
static Eina_Bool static Eina_Bool
_batman_cb_warning_popup_timeout(void *data) _batman_cb_warning_popup_timeout(void *data)
{ {
@ -521,7 +521,7 @@ _batman_warning_popup(Instance *inst, int t, double percent)
elm_layout_content_set(popup_bg, "battery", inst->popup_battery); elm_layout_content_set(popup_bg, "battery", inst->popup_battery);
elm_layout_text_set(popup_bg, "e.text.title", elm_layout_text_set(popup_bg, "e.text.title",
_("Your battery is low!")); _("Your battery is low!"));
elm_layout_text_set(popup_bg, "e.text.label", buf); elm_layout_text_set(popup_bg, "e.text.label", buf);
evas_object_show(inst->popup_battery); evas_object_show(inst->popup_battery);
evas_object_show(popup_bg); evas_object_show(popup_bg);
@ -533,7 +533,7 @@ _batman_warning_popup(Instance *inst, int t, double percent)
evas_object_geometry_get(inst->warning, &x, &y, &w, &h); evas_object_geometry_get(inst->warning, &x, &y, &w, &h);
evas_object_event_callback_add(inst->warning, EVAS_CALLBACK_MOUSE_DOWN, evas_object_event_callback_add(inst->warning, EVAS_CALLBACK_MOUSE_DOWN,
_batman_cb_warning_popup_hide, inst); _batman_cb_warning_popup_hide, inst);
_batman_face_level_set(inst->popup_battery, percent); _batman_face_level_set(inst->popup_battery, percent);
edje_object_signal_emit(inst->popup_battery, "e,state,discharging", "e"); edje_object_signal_emit(inst->popup_battery, "e,state,discharging", "e");
@ -543,7 +543,7 @@ _batman_warning_popup(Instance *inst, int t, double percent)
{ {
inst->cfg->batman.alert_timer = inst->cfg->batman.alert_timer =
ecore_timer_loop_add(inst->cfg->batman.alert_timeout, ecore_timer_loop_add(inst->cfg->batman.alert_timeout,
_batman_cb_warning_popup_timeout, inst); _batman_cb_warning_popup_timeout, inst);
} }
} }
@ -613,13 +613,13 @@ sysinfo_batman_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
_batman_udev_stop(inst); _batman_udev_stop(inst);
#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
(void) inst; (void)inst;
_batman_sysctl_stop(); _batman_sysctl_stop();
#elif defined(upower) #elif defined(upower)
(void) inst; (void)inst;
_batman_upower_stop(); _batman_upower_stop();
#else #else
(void) inst; (void)inst;
_batman_fallback_stop(); _batman_fallback_stop();
#endif #endif
} }
@ -689,7 +689,7 @@ sysinfo_batman_create(Evas_Object *parent, Instance *inst)
_batman_config_updated(inst); _batman_config_updated(inst);
return inst->cfg->batman.o_gadget; return inst->cfg->batman.o_gadget;
} }
static Config_Item * static Config_Item *
@ -707,7 +707,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;
@ -746,7 +746,7 @@ batman_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_UNU
evas_object_smart_callback_add(parent, "gadget_created", _batman_created_cb, inst); evas_object_smart_callback_add(parent, "gadget_created", _batman_created_cb, inst);
evas_object_smart_callback_add(parent, "gadget_removed", _batman_removed_cb, inst); evas_object_smart_callback_add(parent, "gadget_removed", _batman_removed_cb, inst);
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_batman_remove, inst); evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, sysinfo_batman_remove, inst);
evas_object_show(inst->o_main); evas_object_show(inst->o_main);
if (inst->cfg->id < 0) return inst->o_main; if (inst->cfg->id < 0) return inst->o_main;
@ -755,3 +755,4 @@ batman_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_UNU
return inst->o_main; return inst->o_main;
} }

View File

@ -137,17 +137,20 @@ _suspend_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
switch (value) switch (value)
{ {
case 0: case 0:
inst->cfg->batman.suspend_method = SUSPEND; inst->cfg->batman.suspend_method = SUSPEND;
break; break;
case 1:
inst->cfg->batman.suspend_method = HIBERNATE; case 1:
break; inst->cfg->batman.suspend_method = HIBERNATE;
case 2: break;
inst->cfg->batman.suspend_method = SHUTDOWN;
break; case 2:
default: inst->cfg->batman.suspend_method = SHUTDOWN;
inst->cfg->batman.suspend_method = SUSPEND; break;
default:
inst->cfg->batman.suspend_method = SUSPEND;
} }
e_config_save_queue(); e_config_save_queue();
@ -163,23 +166,28 @@ _poll_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
switch (value) switch (value)
{ {
case 0: case 0:
inst->cfg->batman.poll_interval = 4; inst->cfg->batman.poll_interval = 4;
break; break;
case 1:
inst->cfg->batman.poll_interval = 8; case 1:
break; inst->cfg->batman.poll_interval = 8;
case 2: break;
inst->cfg->batman.poll_interval = 32;
break; case 2:
case 3: inst->cfg->batman.poll_interval = 32;
inst->cfg->batman.poll_interval = 64; break;
break;
case 4: case 3:
inst->cfg->batman.poll_interval = 256; inst->cfg->batman.poll_interval = 64;
break; break;
default:
inst->cfg->batman.poll_interval = 32; case 4:
inst->cfg->batman.poll_interval = 256;
break;
default:
inst->cfg->batman.poll_interval = 32;
} }
e_config_save_queue(); e_config_save_queue();
@ -210,7 +218,7 @@ _icon_theme_file_set(Evas_Object *img, const char *icon)
if (!path) if (!path)
{ {
if (e_util_strcmp(e_config->icon_theme, "hicolor")) if (e_util_strcmp(e_config->icon_theme, "hicolor"))
path = efreet_icon_path_find("hicolor", icon, 48); path = efreet_icon_path_find("hicolor", icon, 48);
} }
} }
else if (ecore_file_exists(icon)) else if (ecore_file_exists(icon))
@ -228,20 +236,20 @@ _icon_theme_file_set(Evas_Object *img, const char *icon)
else else
{ {
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"); path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
k = "e/icons/unknown"; k = "e/icons/unknown";
} }
} }
else if (!path && !icon) else if (!path && !icon)
{ {
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"); path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
k = "e/icons/unknown"; k = "e/icons/unknown";
} }
if (path && icon) if (path && icon)
{ {
len = strlen(icon); len = strlen(icon);
if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj"))) if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj")))
k = "icon"; k = "icon";
} }
elm_image_file_set(img, path, k); elm_image_file_set(img, path, k);
} }
@ -288,12 +296,12 @@ batman_configure(Instance *inst)
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS); elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_scroller_content_min_limit(list, 1, 1); elm_scroller_content_min_limit(list, 1, 1);
it = elm_list_item_append(list, _("General"), NULL, NULL, it = elm_list_item_append(list, _("General"), NULL, NULL,
_config_show_general, bc); _config_show_general, bc);
elm_list_item_selected_set(it, 1); elm_list_item_selected_set(it, 1);
it = elm_list_item_append(list, _("Alert"), NULL, NULL, it = elm_list_item_append(list, _("Alert"), NULL, NULL,
_config_show_alert, bc); _config_show_alert, bc);
it = elm_list_item_append(list, _("Power"), NULL, NULL, it = elm_list_item_append(list, _("Power"), NULL, NULL,
_config_show_power, bc); _config_show_power, bc);
elm_list_go(list); elm_list_go(list);
evas_object_show(list); evas_object_show(list);
@ -367,25 +375,30 @@ batman_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _poll_changed, bc); evas_object_smart_callback_add(o, "changed", _poll_changed, bc);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->batman.poll_interval) switch (inst->cfg->batman.poll_interval)
{ {
case 4: case 4:
elm_radio_value_set(group, 0); elm_radio_value_set(group, 0);
break; break;
case 8:
elm_radio_value_set(group, 1); case 8:
break; elm_radio_value_set(group, 1);
case 32: break;
elm_radio_value_set(group, 2);
break; case 32:
case 64: elm_radio_value_set(group, 2);
elm_radio_value_set(group, 3); break;
break;
case 256: case 64:
elm_radio_value_set(group, 4); elm_radio_value_set(group, 3);
break; break;
default:
elm_radio_value_set(group, 2); case 256:
elm_radio_value_set(group, 4);
break;
default:
elm_radio_value_set(group, 2);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);
@ -534,19 +547,22 @@ batman_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _suspend_changed, bc); evas_object_smart_callback_add(o, "changed", _suspend_changed, bc);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->batman.suspend_method) switch (inst->cfg->batman.suspend_method)
{ {
case SUSPEND: case SUSPEND:
elm_radio_value_set(groupy, 0); elm_radio_value_set(groupy, 0);
break; break;
case HIBERNATE:
elm_radio_value_set(groupy, 1); case HIBERNATE:
break; elm_radio_value_set(groupy, 1);
case SHUTDOWN: break;
elm_radio_value_set(groupy, 2);
break; case SHUTDOWN:
default: elm_radio_value_set(groupy, 2);
elm_radio_value_set(groupy, 0); break;
default:
elm_radio_value_set(groupy, 0);
} }
slider = elm_slider_add(box); slider = elm_slider_add(box);

View File

@ -555,7 +555,7 @@ linux_sys_class_power_supply_check(void)
} }
/* FIXME: do we get a uevent on going from charging to full? /* FIXME: do we get a uevent on going from charging to full?
* if so, move this to init */ * if so, move this to init */
snprintf(buf, sizeof(buf), "%s/%s/status", dir, name); snprintf(buf, sizeof(buf), "%s/%s/status", dir, name);
tmp = str_file_get(buf); tmp = str_file_get(buf);
if (tmp) if (tmp)
@ -720,17 +720,16 @@ linux_acpi_cb_delay_check(void *data EINA_UNUSED)
} }
static Eina_Bool static Eina_Bool
linux_acpi_cb_acpid_add(void *data EINA_UNUSED, linux_acpi_cb_acpid_add(void *data EINA_UNUSED,
int type EINA_UNUSED, int type EINA_UNUSED,
void *event EINA_UNUSED) void *event EINA_UNUSED)
{ {
return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON;
} }
static Eina_Bool static Eina_Bool
linux_acpi_cb_acpid_del(void *data EINA_UNUSED, linux_acpi_cb_acpid_del(void *data EINA_UNUSED,
int type EINA_UNUSED, int type EINA_UNUSED,
void *event EINA_UNUSED) void *event EINA_UNUSED)
{ {
ecore_con_server_del(acpid); ecore_con_server_del(acpid);
@ -745,8 +744,8 @@ linux_acpi_cb_acpid_del(void *data EINA_UNUSED,
} }
static Eina_Bool static Eina_Bool
linux_acpi_cb_acpid_data(void *data EINA_UNUSED, linux_acpi_cb_acpid_data(void *data EINA_UNUSED,
int type EINA_UNUSED, int type EINA_UNUSED,
void *event EINA_UNUSED) void *event EINA_UNUSED)
{ {
if (delay_check) ecore_timer_del(delay_check); if (delay_check) ecore_timer_del(delay_check);
@ -755,7 +754,7 @@ linux_acpi_cb_acpid_data(void *data EINA_UNUSED,
} }
static Eina_Bool static Eina_Bool
linux_acpi_cb_event_fd_active(void *data EINA_UNUSED, linux_acpi_cb_event_fd_active(void *data EINA_UNUSED,
Ecore_Fd_Handler *fd_handler) Ecore_Fd_Handler *fd_handler)
{ {
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
@ -1229,7 +1228,7 @@ _batman_fallback_poll_cb(void *data)
#endif #endif
_batman_update(inst, battery_full, time_left, have_battery, have_power); _batman_update(inst, battery_full, time_left, have_battery, have_power);
return EINA_TRUE; return EINA_TRUE;
} }

View File

@ -29,7 +29,7 @@ _batman_sysctl_start(Instance *inst)
size_t len; size_t len;
#endif #endif
#if defined(__OpenBSD__) || defined(__NetBSD__) #if defined(__OpenBSD__) || defined(__NetBSD__)
for (devn = 0;; devn++) for (devn = 0;; devn++)
{ {
mib[2] = devn; mib[2] = devn;
if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1) if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1)
@ -62,21 +62,21 @@ _batman_sysctl_start(Instance *inst)
_batman_sysctl_battery_update_poll, inst); _batman_sysctl_battery_update_poll, inst);
batman_device_batteries = eina_list_append(batman_device_batteries, bat); batman_device_batteries = eina_list_append(batman_device_batteries, bat);
++i; ++i;
} }
if (!strcmp("acpiac0", snsrdev.xname)) if (!strcmp("acpiac0", snsrdev.xname))
{ {
Ac_Adapter *ac = E_NEW(Ac_Adapter, 1); Ac_Adapter *ac = E_NEW(Ac_Adapter, 1);
if (!ac) return 0; if (!ac) return 0;
ac->inst = inst; ac->inst = inst;
ac->udi = eina_stringshare_add("acpiac0"); ac->udi = eina_stringshare_add("acpiac0");
ac->mib = malloc(sizeof(int) * 5); ac->mib = malloc(sizeof(int) * 5);
if (!ac->mib) return 0; if (!ac->mib) return 0;
ac->mib[0] = mib[0]; ac->mib[0] = mib[0];
ac->mib[1] = mib[1]; ac->mib[1] = mib[1];
ac->mib[2] = mib[2]; ac->mib[2] = mib[2];
batman_device_ac_adapters = eina_list_append(batman_device_ac_adapters, ac); batman_device_ac_adapters = eina_list_append(batman_device_ac_adapters, ac);
} }
} }
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
if ((sysctlbyname("hw.acpi.battery.life", NULL, &len, NULL, 0)) != -1) if ((sysctlbyname("hw.acpi.battery.life", NULL, &len, NULL, 0)) != -1)
@ -87,18 +87,18 @@ _batman_sysctl_start(Instance *inst)
bat->inst = inst; bat->inst = inst;
bat->mib = malloc(sizeof(int) * 4); bat->mib = malloc(sizeof(int) * 4);
if (!bat->mib) return 0; if (!bat->mib) return 0;
sysctlnametomib("hw.acpi.battery.life", bat->mib, &len); sysctlnametomib("hw.acpi.battery.life", bat->mib, &len);
bat->mib_state = malloc(sizeof(int) * 4); bat->mib_state = malloc(sizeof(int) * 4);
if (!bat->mib_state) return 0; if (!bat->mib_state) return 0;
sysctlnametomib("hw.acpi.battery.state", bat->mib_state, &len); sysctlnametomib("hw.acpi.battery.state", bat->mib_state, &len);
bat->mib_time = malloc(sizeof(int) * 4); bat->mib_time = malloc(sizeof(int) * 4);
if (!bat->mib_time) return 0; if (!bat->mib_time) return 0;
sysctlnametomib("hw.acpi.battery.time", bat->mib_time, &len); sysctlnametomib("hw.acpi.battery.time", bat->mib_time, &len);
bat->mib_units = malloc(sizeof(int) * 4); bat->mib_units = malloc(sizeof(int) * 4);
if(!bat->mib_units) return 0; if (!bat->mib_units) return 0;
sysctlnametomib("hw.acpi.battery.units", bat->mib_units, &len); sysctlnametomib("hw.acpi.battery.units", bat->mib_units, &len);
bat->last_update = ecore_time_get(); bat->last_update = ecore_time_get();
@ -108,8 +108,8 @@ _batman_sysctl_start(Instance *inst)
bat->vendor = eina_stringshare_add("Unknown"); bat->vendor = eina_stringshare_add("Unknown");
bat->poll = ecore_poller_add(ECORE_POLLER_CORE, bat->poll = ecore_poller_add(ECORE_POLLER_CORE,
inst->cfg->batman.poll_interval, inst->cfg->batman.poll_interval,
_batman_sysctl_battery_update_poll, inst); _batman_sysctl_battery_update_poll, inst);
batman_device_batteries = eina_list_append(batman_device_batteries, bat); batman_device_batteries = eina_list_append(batman_device_batteries, bat);
} }
@ -118,13 +118,13 @@ _batman_sysctl_start(Instance *inst)
{ {
Ac_Adapter *ac = E_NEW(Ac_Adapter, 1); Ac_Adapter *ac = E_NEW(Ac_Adapter, 1);
if (!ac) if (!ac)
return 0; return 0;
ac->inst = inst; ac->inst = inst;
ac->mib = malloc(sizeof(int) * 3); ac->mib = malloc(sizeof(int) * 3);
if (!ac->mib) return 0; if (!ac->mib) return 0;
len = sizeof(ac->mib); len = sizeof(ac->mib);
sysctlnametomib("hw.acpi.acline", ac->mib, &len); sysctlnametomib("hw.acpi.acline", ac->mib, &len);
ac->udi = eina_stringshare_add("hw.acpi.acline"); ac->udi = eina_stringshare_add("hw.acpi.acline");
batman_device_ac_adapters = eina_list_append(batman_device_ac_adapters, ac); batman_device_ac_adapters = eina_list_append(batman_device_ac_adapters, ac);
@ -141,13 +141,13 @@ _batman_sysctl_stop(void)
Battery *bat; Battery *bat;
Ac_Adapter *ac; Ac_Adapter *ac;
EINA_LIST_FREE(batman_device_ac_adapters, ac) EINA_LIST_FREE(batman_device_ac_adapters, ac)
{ {
E_FREE_FUNC(ac->udi, eina_stringshare_del); E_FREE_FUNC(ac->udi, eina_stringshare_del);
E_FREE(ac->mib); E_FREE(ac->mib);
E_FREE(ac); E_FREE(ac);
} }
EINA_LIST_FREE(batman_device_batteries, bat) EINA_LIST_FREE(batman_device_batteries, bat)
{ {
E_FREE_FUNC(bat->udi, eina_stringshare_del); E_FREE_FUNC(bat->udi, eina_stringshare_del);
@ -175,6 +175,7 @@ _batman_sysctl_battery_update_poll(void *data)
return EINA_TRUE; return EINA_TRUE;
} }
#endif #endif
static int static int
@ -196,16 +197,16 @@ _batman_sysctl_battery_update(Instance *inst)
{ {
/* update the poller interval */ /* update the poller interval */
ecore_poller_poller_interval_set(bat->poll, ecore_poller_poller_interval_set(bat->poll,
inst->cfg->batman.poll_interval); inst->cfg->batman.poll_interval);
#if defined(__OpenBSD__) || defined(__NetBSD__) #if defined(__OpenBSD__) || defined(__NetBSD__)
/* last full capacity */ /* last full capacity */
bat->mib[3] = 7; bat->mib[3] = 7;
bat->mib[4] = 0; bat->mib[4] = 0;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
bat->last_full_charge = (double)s.value; bat->last_full_charge = (double)s.value;
} }
/* remaining capacity */ /* remaining capacity */
bat->mib[3] = 7; bat->mib[3] = 7;
bat->mib[4] = 3; bat->mib[4] = 3;
@ -213,119 +214,118 @@ _batman_sysctl_battery_update(Instance *inst)
{ {
charge = (double)s.value; charge = (double)s.value;
} }
/* This is a workaround because there's an ACPI bug */ /* This is a workaround because there's an ACPI bug */
if ((EINA_FLT_EQ(charge, 0.0)) || (EINA_FLT_EQ(bat->last_full_charge, 0.0))) if ((EINA_FLT_EQ(charge, 0.0)) || (EINA_FLT_EQ(bat->last_full_charge, 0.0)))
{ {
/* last full capacity */ /* last full capacity */
bat->mib[3] = 8; bat->mib[3] = 8;
bat->mib[4] = 0; bat->mib[4] = 0;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
bat->last_full_charge = (double)s.value; bat->last_full_charge = (double)s.value;
if (bat->last_full_charge < 0) return EINA_TRUE; if (bat->last_full_charge < 0) return EINA_TRUE;
} }
/* remaining capacity */ /* remaining capacity */
bat->mib[3] = 8; bat->mib[3] = 8;
bat->mib[4] = 3; bat->mib[4] = 3;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
charge = (double)s.value; charge = (double)s.value;
} }
} }
bat->got_prop = 1;
_time = ecore_time_get();
if ((bat->got_prop) && (!EINA_FLT_EQ(charge, bat->current_charge)))
bat->charge_rate = ((charge - bat->current_charge) / (_time - bat->last_update));
bat->last_update = _time;
bat->current_charge = charge;
bat->percent = 100 * (bat->current_charge / bat->last_full_charge);
if (bat->current_charge >= bat->last_full_charge)
bat->percent = 100;
if (bat->got_prop) bat->got_prop = 1;
{
if (bat->charge_rate > 0) _time = ecore_time_get();
{ if ((bat->got_prop) && (!EINA_FLT_EQ(charge, bat->current_charge)))
if (inst->cfg->batman.fuzzy && (++inst->cfg->batman.fuzzcount <= 10) && (bat->time_full > 0)) bat->charge_rate = ((charge - bat->current_charge) / (_time - bat->last_update));
bat->time_full = (((bat->last_full_charge - bat->current_charge) / bat->charge_rate) + bat->time_full) / 2; bat->last_update = _time;
else bat->current_charge = charge;
bat->time_full = (bat->last_full_charge - bat->current_charge) / bat->charge_rate; bat->percent = 100 * (bat->current_charge / bat->last_full_charge);
bat->time_left = -1; if (bat->current_charge >= bat->last_full_charge)
} bat->percent = 100;
else
{ if (bat->got_prop)
if (inst->cfg->batman.fuzzy && (inst->cfg->batman.fuzzcount <= 10) && (bat->time_left > 0)) {
bat->time_left = (((0 - bat->current_charge) / bat->charge_rate) + bat->time_left) / 2; if (bat->charge_rate > 0)
else {
bat->time_left = (0 - bat->current_charge) / bat->charge_rate; if (inst->cfg->batman.fuzzy && (++inst->cfg->batman.fuzzcount <= 10) && (bat->time_full > 0))
bat->time_full = -1; bat->time_full = (((bat->last_full_charge - bat->current_charge) / bat->charge_rate) + bat->time_full) / 2;
} else
} bat->time_full = (bat->last_full_charge - bat->current_charge) / bat->charge_rate;
else bat->time_left = -1;
{ }
bat->time_full = -1; else
bat->time_left = -1; {
} if (inst->cfg->batman.fuzzy && (inst->cfg->batman.fuzzcount <= 10) && (bat->time_left > 0))
bat->time_left = (((0 - bat->current_charge) / bat->charge_rate) + bat->time_left) / 2;
/* battery state 1: discharge, 2: charge */ else
bat->mib[3] = 10; bat->time_left = (0 - bat->current_charge) / bat->charge_rate;
bat->mib[4] = 0; bat->time_full = -1;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) == -1) }
{ }
if (s.value == 2) else
bat->charging = 1; {
else bat->time_full = -1;
bat->charging = 0; bat->time_left = -1;
} }
_batman_device_update(bat->inst);
/* battery state 1: discharge, 2: charge */
bat->mib[3] = 10;
bat->mib[4] = 0;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) == -1)
{
if (s.value == 2)
bat->charging = 1;
else
bat->charging = 0;
}
_batman_device_update(bat->inst);
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
len = sizeof(value); len = sizeof(value);
if ((sysctl(bat->mib, 4, &value, &len, NULL, 0)) == -1) if ((sysctl(bat->mib, 4, &value, &len, NULL, 0)) == -1)
{ {
return EINA_FALSE; return EINA_FALSE;
} }
bat->percent = value;
_time = ecore_time_get(); bat->percent = value;
bat->last_update = _time;
len = sizeof(value); _time = ecore_time_get();
if ((sysctl(bat->mib_state, 4, &value, &len, NULL, 0)) == -1) bat->last_update = _time;
{
len = sizeof(value);
if ((sysctl(bat->mib_state, 4, &value, &len, NULL, 0)) == -1)
{
return EINA_FALSE; return EINA_FALSE;
} }
bat->charging = !value; bat->charging = !value;
bat->got_prop = 1; bat->got_prop = 1;
bat->time_full = -1; bat->time_full = -1;
bat->time_left = -1; bat->time_left = -1;
len = sizeof(bat->time_min); len = sizeof(bat->time_min);
if ((sysctl(bat->mib_time, 4, &bat->time_min, &len, NULL, 0)) == -1) if ((sysctl(bat->mib_time, 4, &bat->time_min, &len, NULL, 0)) == -1)
{ {
bat->time_min = -1; bat->time_min = -1;
} }
len = sizeof(bat->batteries);
if ((sysctl(bat->mib_units, 4, &bat->batteries, &len, NULL, 0)) == -1)
{
bat->batteries = 1;
}
if (bat->time_min >= 0) bat->time_left = bat->time_min * 60; len = sizeof(bat->batteries);
if (bat->batteries == 1) bat->time_left = -1; if ((sysctl(bat->mib_units, 4, &bat->batteries, &len, NULL, 0)) == -1)
_batman_device_update(inst); {
#endif bat->batteries = 1;
}
if (bat->time_min >= 0) bat->time_left = bat->time_min * 60;
if (bat->batteries == 1) bat->time_left = -1;
_batman_device_update(inst);
#endif
} }
EINA_LIST_FOREACH(batman_device_ac_adapters, l, ac)
EINA_LIST_FOREACH(batman_device_ac_adapters, l, ac)
{ {
#if defined(__OpenBSD__) || defined(__NetBSD__) #if defined(__OpenBSD__) || defined(__NetBSD__)
/* AC State */ /* AC State */
@ -345,10 +345,8 @@ _batman_sysctl_battery_update(Instance *inst)
ac->present = value; ac->present = value;
} }
#endif #endif
} }
return EINA_TRUE; return EINA_TRUE;
} }

View File

@ -1,14 +1,14 @@
#include "batman.h" #include "batman.h"
static void _batman_udev_event_battery(const char *syspath, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch); static void _batman_udev_event_battery(const char *syspath, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch);
static void _batman_udev_event_ac(const char *syspath, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch); static void _batman_udev_event_ac(const char *syspath, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch);
static void _batman_udev_battery_add(const char *syspath, Instance *inst); static void _batman_udev_battery_add(const char *syspath, Instance *inst);
static void _batman_udev_ac_add(const char *syspath, Instance *inst); static void _batman_udev_ac_add(const char *syspath, Instance *inst);
static void _batman_udev_battery_del(const char *syspath, Instance *inst); static void _batman_udev_battery_del(const char *syspath, Instance *inst);
static void _batman_udev_ac_del(const char *syspath, Instance *inst); static void _batman_udev_ac_del(const char *syspath, Instance *inst);
static Eina_Bool _batman_udev_battery_update_poll(void *data); static Eina_Bool _batman_udev_battery_update_poll(void *data);
static void _batman_udev_battery_update(const char *syspath, Battery *bat, Instance *inst); static void _batman_udev_battery_update(const char *syspath, Battery *bat, Instance *inst);
static void _batman_udev_ac_update(const char *syspath, Ac_Adapter *ac, Instance *inst); static void _batman_udev_ac_update(const char *syspath, Ac_Adapter *ac, Instance *inst);
EINTERN extern Eina_List *batman_device_batteries; EINTERN extern Eina_List *batman_device_batteries;
EINTERN extern Eina_List *batman_device_ac_adapters; EINTERN extern Eina_List *batman_device_ac_adapters;
@ -54,10 +54,10 @@ _batman_udev_stop(Instance *inst)
} }
EINA_LIST_FREE(batman_device_batteries, bat) EINA_LIST_FREE(batman_device_batteries, bat)
{ {
eina_stringshare_del(bat->udi); eina_stringshare_del(bat->udi);
eina_stringshare_del(bat->technology); eina_stringshare_del(bat->technology);
eina_stringshare_del(bat->model); eina_stringshare_del(bat->model);
eina_stringshare_del(bat->vendor); eina_stringshare_del(bat->vendor);
E_FREE_FUNC(bat->poll, ecore_poller_del); E_FREE_FUNC(bat->poll, ecore_poller_del);
E_FREE(bat); E_FREE(bat);
} }
@ -126,9 +126,9 @@ _batman_udev_battery_add(const char *syspath, Instance *inst)
bat->inst = inst; bat->inst = inst;
bat->last_update = ecore_time_get(); bat->last_update = ecore_time_get();
bat->udi = eina_stringshare_add(syspath); bat->udi = eina_stringshare_add(syspath);
bat->poll = ecore_poller_add(ECORE_POLLER_CORE, bat->poll = ecore_poller_add(ECORE_POLLER_CORE,
bat->inst->cfg->batman.poll_interval, bat->inst->cfg->batman.poll_interval,
_batman_udev_battery_update_poll, bat); _batman_udev_battery_update_poll, bat);
batman_device_batteries = eina_list_append(batman_device_batteries, bat); batman_device_batteries = eina_list_append(batman_device_batteries, bat);
_batman_udev_battery_update(syspath, bat, inst); _batman_udev_battery_update(syspath, bat, inst);
} }
@ -205,7 +205,7 @@ _batman_udev_ac_del(const char *syspath, Instance *inst)
if (!eina_list_count(adapters)) if (!eina_list_count(adapters))
{ {
eina_stringshare_del(syspath); eina_stringshare_del(syspath);
return; return;
} }
EINA_LIST_FOREACH(batman_device_ac_adapters, l, ac) EINA_LIST_FOREACH(batman_device_ac_adapters, l, ac)
@ -221,7 +221,7 @@ _batman_udev_ac_del(const char *syspath, Instance *inst)
eina_list_free(adapters); eina_list_free(adapters);
} }
static Eina_Bool static Eina_Bool
_batman_udev_battery_update_poll(void *data) _batman_udev_battery_update_poll(void *data)
{ {
Battery *bat = data; Battery *bat = data;
@ -231,16 +231,16 @@ _batman_udev_battery_update_poll(void *data)
return EINA_TRUE; return EINA_TRUE;
} }
#define GET_NUM(TYPE, VALUE, PROP) \ #define GET_NUM(TYPE, VALUE, PROP) \
do \ do \
{ \ { \
test = eeze_udev_syspath_get_property(TYPE->udi, #PROP); \ test = eeze_udev_syspath_get_property(TYPE->udi, #PROP); \
if (test) \ if (test) \
{ \ { \
TYPE->VALUE = strtod(test, NULL); \ TYPE->VALUE = strtod(test, NULL); \
eina_stringshare_del(test); \ eina_stringshare_del(test); \
} \ } \
} \ } \
while (0) while (0)
#define GET_STR(TYPE, VALUE, PROP) TYPE->VALUE = eeze_udev_syspath_get_property(TYPE->udi, #PROP) #define GET_STR(TYPE, VALUE, PROP) TYPE->VALUE = eeze_udev_syspath_get_property(TYPE->udi, #PROP)
@ -285,11 +285,11 @@ _batman_udev_battery_update(const char *syspath, Battery *bat, Instance *inst)
if ((bat->got_prop) && (!eina_dbl_exact(charge, bat->current_charge)) && (!eina_dbl_exact(bat->current_charge, 0))) if ((bat->got_prop) && (!eina_dbl_exact(charge, bat->current_charge)) && (!eina_dbl_exact(bat->current_charge, 0)))
charge_rate = ((charge - bat->current_charge) / (t - bat->last_update)); charge_rate = ((charge - bat->current_charge) / (t - bat->last_update));
if ((!eina_dbl_exact(charge_rate, 0)) || eina_dbl_exact(bat->last_update, 0) || eina_dbl_exact(bat->current_charge, 0)) if ((!eina_dbl_exact(charge_rate, 0)) || eina_dbl_exact(bat->last_update, 0) || eina_dbl_exact(bat->current_charge, 0))
{ {
bat->last_update = t; bat->last_update = t;
bat->current_charge = charge; bat->current_charge = charge;
bat->charge_rate = charge_rate; bat->charge_rate = charge_rate;
} }
bat->percent = 100 * (bat->current_charge / bat->last_full_charge); bat->percent = 100 * (bat->current_charge / bat->last_full_charge);
if (bat->got_prop) if (bat->got_prop)
{ {
@ -342,8 +342,8 @@ _batman_udev_ac_update(const char *syspath, Ac_Adapter *ac, Instance *inst)
if (!ac) if (!ac)
{ {
_batman_udev_ac_add(syspath, inst); _batman_udev_ac_add(syspath, inst);
return; return;
} }
GET_NUM(ac, present, POWER_SUPPLY_ONLINE); GET_NUM(ac, present, POWER_SUPPLY_ONLINE);

View File

@ -1,7 +1,7 @@
#include "batman.h" #include "batman.h"
#define BUS "org.freedesktop.UPower" #define BUS "org.freedesktop.UPower"
#define PATH "/org/freedesktop/UPower" #define PATH "/org/freedesktop/UPower"
#define IFACE "org.freedesktop.UPower" #define IFACE "org.freedesktop.UPower"
EINTERN extern Eina_List *batman_device_batteries; EINTERN extern Eina_List *batman_device_batteries;
@ -15,7 +15,7 @@ typedef struct _Upower_Data Upower_Data;
struct _Upower_Data struct _Upower_Data
{ {
Eldbus_Proxy *proxy; Eldbus_Proxy *proxy;
Instance *inst; Instance *inst;
}; };
static void static void
@ -123,25 +123,25 @@ _bat_get_all_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending E
{ {
const char *key; const char *key;
union union
{ {
Eina_Bool b; Eina_Bool b;
int64_t i64; int64_t i64;
unsigned u; unsigned u;
double d; double d;
const char *s; const char *s;
} val; } val;
if (!eldbus_message_iter_arguments_get(dict, "sv", &key, &variant)) if (!eldbus_message_iter_arguments_get(dict, "sv", &key, &variant))
continue; continue;
if (!strcmp(key, "IsPresent")) if (!strcmp(key, "IsPresent"))
{ {
eldbus_message_iter_arguments_get(variant, "b", &val.b); eldbus_message_iter_arguments_get(variant, "b", &val.b);
bat->present = val.b; bat->present = val.b;
} }
else if (!strcmp(key, "TimeToEmpty")) else if (!strcmp(key, "TimeToEmpty"))
{ {
eldbus_message_iter_arguments_get(variant, "x", &val.i64); eldbus_message_iter_arguments_get(variant, "x", &val.i64);
bat->time_left = (int) val.i64; bat->time_left = (int)val.i64;
if (bat->time_left > 0) if (bat->time_left > 0)
bat->charging = EINA_FALSE; bat->charging = EINA_FALSE;
else else
@ -150,27 +150,27 @@ _bat_get_all_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending E
else if (!strcmp(key, "Percentage")) else if (!strcmp(key, "Percentage"))
{ {
eldbus_message_iter_arguments_get(variant, "d", &val.d); eldbus_message_iter_arguments_get(variant, "d", &val.d);
bat->percent = (int) val.d; bat->percent = (int)val.d;
} }
else if (!strcmp(key, "Energy")) else if (!strcmp(key, "Energy"))
{ {
eldbus_message_iter_arguments_get(variant, "d", &val.d); eldbus_message_iter_arguments_get(variant, "d", &val.d);
bat->current_charge = (int) val.d; bat->current_charge = (int)val.d;
} }
else if (!strcmp(key, "EnergyFullDesign")) else if (!strcmp(key, "EnergyFullDesign"))
{ {
eldbus_message_iter_arguments_get(variant, "d", &val.d); eldbus_message_iter_arguments_get(variant, "d", &val.d);
bat->design_charge = (int) val.d; bat->design_charge = (int)val.d;
} }
else if (!strcmp(key, "EnergyFull")) else if (!strcmp(key, "EnergyFull"))
{ {
eldbus_message_iter_arguments_get(variant, "d", &val.d); eldbus_message_iter_arguments_get(variant, "d", &val.d);
bat->last_full_charge = (int) val.d; bat->last_full_charge = (int)val.d;
} }
else if (!strcmp(key, "TimeToFull")) else if (!strcmp(key, "TimeToFull"))
{ {
eldbus_message_iter_arguments_get(variant, "x", &val.i64); eldbus_message_iter_arguments_get(variant, "x", &val.i64);
bat->time_full = (int) val.i64; bat->time_full = (int)val.i64;
} }
else if (!strcmp(key, "Technology")) else if (!strcmp(key, "Technology"))
{ {
@ -395,3 +395,4 @@ _batman_upower_stop(void)
E_FREE_FUNC(obj, eldbus_object_unref); E_FREE_FUNC(obj, eldbus_object_unref);
E_FREE_FUNC(conn, eldbus_connection_unref); E_FREE_FUNC(conn, eldbus_connection_unref);
} }

View File

@ -14,8 +14,8 @@ EINTERN void _cpuclock_poll_interval_update(Instance *inst);
typedef struct _Thread_Config Thread_Config; typedef struct _Thread_Config Thread_Config;
struct _Thread_Config struct _Thread_Config
{ {
int interval; int interval;
Instance *inst; Instance *inst;
E_Powersave_Sleeper *sleeper; E_Powersave_Sleeper *sleeper;
}; };
@ -23,9 +23,9 @@ typedef struct _Pstate_Config Pstate_Config;
struct _Pstate_Config struct _Pstate_Config
{ {
Instance *inst; Instance *inst;
int min; int min;
int max; int max;
int turbo; int turbo;
}; };
static Cpu_Status * static Cpu_Status *
@ -83,6 +83,7 @@ _cpuclock_set_thread_done(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED)
{ {
return; return;
} }
#endif #endif
void void
@ -230,6 +231,7 @@ _cpuclock_event_cb_powersave(void *data, int type, void *event)
eina_stringshare_del(inst->cfg->cpuclock.status->orig_governor); eina_stringshare_del(inst->cfg->cpuclock.status->orig_governor);
inst->cfg->cpuclock.status->orig_governor = NULL; inst->cfg->cpuclock.status->orig_governor = NULL;
break; break;
case E_POWERSAVE_MODE_MEDIUM: case E_POWERSAVE_MODE_MEDIUM:
case E_POWERSAVE_MODE_HIGH: case E_POWERSAVE_MODE_HIGH:
if ((inst->cfg->cpuclock.powersave_governor) || (has_conservative)) if ((inst->cfg->cpuclock.powersave_governor) || (has_conservative))
@ -241,7 +243,7 @@ _cpuclock_event_cb_powersave(void *data, int type, void *event)
break; break;
} }
EINA_FALLTHROUGH; EINA_FALLTHROUGH;
/* no break */ /* no break */
case E_POWERSAVE_MODE_EXTREME: case E_POWERSAVE_MODE_EXTREME:
default: default:
@ -291,13 +293,13 @@ _cpuclock_popup_create(Instance *inst)
{ {
f += 500; f += 500;
f /= 1000; f /= 1000;
u = _("MHz"); u = _("MHz");
} }
else else
{ {
f += 50000; f += 50000;
f /= 1000000; f /= 1000000;
u = _("GHz"); u = _("GHz");
} }
popup = elm_ctxpopup_add(e_comp->elm); popup = elm_ctxpopup_add(e_comp->elm);
@ -433,7 +435,7 @@ _cpuclock_face_update_current(Instance *inst)
{ {
f += 500; f += 500;
f /= 1000; f /= 1000;
u = _("MHz"); u = _("MHz");
} }
else else
{ {
@ -452,7 +454,7 @@ _cpuclock_status_check_available(Cpu_Status *s)
#if !defined(__OpenBSD__) #if !defined(__OpenBSD__)
char buf[4096]; char buf[4096];
Eina_List *l; Eina_List *l;
#endif #endif
// FIXME: this assumes all cores accept the same freqs/ might be wrong // FIXME: this assumes all cores accept the same freqs/ might be wrong
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
@ -574,15 +576,15 @@ _cpuclock_status_check_available(Cpu_Status *s)
eina_list_free(s->frequencies); eina_list_free(s->frequencies);
s->frequencies = NULL; s->frequencies = NULL;
} }
#define CPUFREQ_ADDF(filename) \ #define CPUFREQ_ADDF(filename) \
f = fopen(CPUFREQ_SYSFSDIR filename, "r"); \ f = fopen(CPUFREQ_SYSFSDIR filename, "r"); \
if (f) \ if (f) \
{ \ { \
if (fgets(buf, sizeof(buf), f) != NULL) \ if (fgets(buf, sizeof(buf), f) != NULL) \
s->frequencies = eina_list_append(s->frequencies, \ s->frequencies = eina_list_append(s->frequencies, \
(void *)(long)(atoi(buf))); \ (void *)(long)(atoi(buf))); \
fclose(f); \ fclose(f); \
} }
CPUFREQ_ADDF("/cpuinfo_min_freq"); CPUFREQ_ADDF("/cpuinfo_min_freq");
CPUFREQ_ADDF("/cpuinfo_max_freq"); CPUFREQ_ADDF("/cpuinfo_max_freq");
} }
@ -827,7 +829,7 @@ static void
_cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th) _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
for (;;) for (;; )
{ {
Cpu_Status *status; Cpu_Status *status;
@ -845,8 +847,8 @@ _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th)
static void static void
_cpuclock_cb_frequency_check_notify(void *data, _cpuclock_cb_frequency_check_notify(void *data,
Ecore_Thread *th EINA_UNUSED, Ecore_Thread *th EINA_UNUSED,
void *msg) void *msg)
{ {
Cpu_Status *status = msg; Cpu_Status *status = msg;
Eina_Bool freq_changed = EINA_FALSE; Eina_Bool freq_changed = EINA_FALSE;
@ -860,12 +862,12 @@ _cpuclock_cb_frequency_check_notify(void *data,
if ((thc->inst->cfg->cpuclock.status) && (status) && if ((thc->inst->cfg->cpuclock.status) && (status) &&
( (
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
(status->cur_percent != thc->inst->cfg->cpuclock.status->cur_percent ) || (status->cur_percent != thc->inst->cfg->cpuclock.status->cur_percent) ||
#endif #endif
(status->cur_frequency != thc->inst->cfg->cpuclock.status->cur_frequency ) || (status->cur_frequency != thc->inst->cfg->cpuclock.status->cur_frequency) ||
(status->cur_min_frequency != thc->inst->cfg->cpuclock.status->cur_min_frequency) || (status->cur_min_frequency != thc->inst->cfg->cpuclock.status->cur_min_frequency) ||
(status->cur_max_frequency != thc->inst->cfg->cpuclock.status->cur_max_frequency) || (status->cur_max_frequency != thc->inst->cfg->cpuclock.status->cur_max_frequency) ||
(status->can_set_frequency != thc->inst->cfg->cpuclock.status->can_set_frequency))) (status->can_set_frequency != thc->inst->cfg->cpuclock.status->can_set_frequency)))
freq_changed = EINA_TRUE; freq_changed = EINA_TRUE;
E_FREE_FUNC(thc->inst->cfg->cpuclock.status, _cpuclock_status_free); E_FREE_FUNC(thc->inst->cfg->cpuclock.status, _cpuclock_status_free);
thc->inst->cfg->cpuclock.status = status; thc->inst->cfg->cpuclock.status = status;
@ -910,7 +912,7 @@ _cpuclock_poll_interval_update(Instance *inst)
if (thc) if (thc)
{ {
thc->inst = inst; thc->inst = inst;
thc->sleeper = e_powersave_sleeper_new(); thc->sleeper = e_powersave_sleeper_new();
thc->interval = inst->cfg->cpuclock.poll_interval; thc->interval = inst->cfg->cpuclock.poll_interval;
inst->cfg->cpuclock.frequency_check_thread = inst->cfg->cpuclock.frequency_check_thread =
ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main, ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main,
@ -967,7 +969,7 @@ _cpuclock_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
{ {
ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread); ecore_thread_cancel(inst->cfg->cpuclock.frequency_check_thread);
inst->cfg->cpuclock.frequency_check_thread = NULL; inst->cfg->cpuclock.frequency_check_thread = NULL;
return; return;
} }
if (inst->cfg->cpuclock.governor) if (inst->cfg->cpuclock.governor)
eina_stringshare_del(inst->cfg->cpuclock.governor); eina_stringshare_del(inst->cfg->cpuclock.governor);
@ -1002,7 +1004,6 @@ sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
if (inst->cfg->cpuclock.governor) if (inst->cfg->cpuclock.governor)
eina_stringshare_del(inst->cfg->cpuclock.governor); eina_stringshare_del(inst->cfg->cpuclock.governor);
E_FREE_FUNC(inst->cfg->cpuclock.status, _cpuclock_status_free); E_FREE_FUNC(inst->cfg->cpuclock.status, _cpuclock_status_free);
} }
static void static void
@ -1058,7 +1059,7 @@ _cpuclock_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
_cpuclock_set_governor(inst->cfg->cpuclock.governor); _cpuclock_set_governor(inst->cfg->cpuclock.governor);
break; break;
} }
} }
} }
} }
@ -1089,7 +1090,7 @@ sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst)
inst->cfg->cpuclock.status = _cpuclock_status_new(); inst->cfg->cpuclock.status = _cpuclock_status_new();
_cpuclock_status_check_available(inst->cfg->cpuclock.status); _cpuclock_status_check_available(inst->cfg->cpuclock.status);
E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst);
E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst);
E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_POWERSAVE_UPDATE, _cpuclock_event_cb_powersave, inst); E_LIST_HANDLER_APPEND(inst->cfg->cpuclock.handlers, E_EVENT_POWERSAVE_UPDATE, _cpuclock_event_cb_powersave, inst);
@ -1125,7 +1126,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;
@ -1166,3 +1167,4 @@ cpuclock_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_U
return inst->o_main; return inst->o_main;
} }

View File

@ -89,7 +89,7 @@ _update_max_power(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EIN
inst->cfg->cpuclock.pstate_max = value; inst->cfg->cpuclock.pstate_max = value;
_cpuclock_set_pstate(inst->cfg->cpuclock.pstate_min - 1, _cpuclock_set_pstate(inst->cfg->cpuclock.pstate_min - 1,
inst->cfg->cpuclock.pstate_max - 1, inst->cfg->cpuclock.status->pstate_turbo); inst->cfg->cpuclock.pstate_max - 1, inst->cfg->cpuclock.status->pstate_turbo);
e_config_save_queue(); e_config_save_queue();
_cpuclock_config_updated(inst); _cpuclock_config_updated(inst);
} }
@ -103,7 +103,7 @@ _update_min_power(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EIN
inst->cfg->cpuclock.pstate_min = value; inst->cfg->cpuclock.pstate_min = value;
_cpuclock_set_pstate(inst->cfg->cpuclock.pstate_min - 1, _cpuclock_set_pstate(inst->cfg->cpuclock.pstate_min - 1,
inst->cfg->cpuclock.pstate_max - 1, inst->cfg->cpuclock.status->pstate_turbo); inst->cfg->cpuclock.pstate_max - 1, inst->cfg->cpuclock.status->pstate_turbo);
e_config_save_queue(); e_config_save_queue();
_cpuclock_config_updated(inst); _cpuclock_config_updated(inst);
} }
@ -130,7 +130,7 @@ _restore_governor(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
Instance *inst = cc->inst; Instance *inst = cc->inst;
inst->cfg->cpuclock.restore_governor = elm_check_state_get(obj); inst->cfg->cpuclock.restore_governor = elm_check_state_get(obj);
if ((!inst->cfg->cpuclock.governor) || if ((!inst->cfg->cpuclock.governor) ||
(strcmp(inst->cfg->cpuclock.status->cur_governor, 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); eina_stringshare_replace(&inst->cfg->cpuclock.governor, inst->cfg->cpuclock.status->cur_governor);
@ -188,23 +188,28 @@ _poll_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
switch (value) switch (value)
{ {
case 0: case 0:
inst->cfg->cpuclock.poll_interval = 4; inst->cfg->cpuclock.poll_interval = 4;
break; break;
case 1:
inst->cfg->cpuclock.poll_interval = 8; case 1:
break; inst->cfg->cpuclock.poll_interval = 8;
case 2: break;
inst->cfg->cpuclock.poll_interval = 32;
break; case 2:
case 3: inst->cfg->cpuclock.poll_interval = 32;
inst->cfg->cpuclock.poll_interval = 64; break;
break;
case 4: case 3:
inst->cfg->cpuclock.poll_interval = 256; inst->cfg->cpuclock.poll_interval = 64;
break; break;
default:
inst->cfg->cpuclock.poll_interval = 32; case 4:
inst->cfg->cpuclock.poll_interval = 256;
break;
default:
inst->cfg->cpuclock.poll_interval = 32;
} }
e_config_save_queue(); e_config_save_queue();
@ -263,18 +268,18 @@ cpuclock_configure(Instance *inst)
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS); elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_scroller_content_min_limit(list, 1, 1); elm_scroller_content_min_limit(list, 1, 1);
it = elm_list_item_append(list, _("General"), NULL, NULL, it = elm_list_item_append(list, _("General"), NULL, NULL,
_config_show_general, cc); _config_show_general, cc);
elm_list_item_selected_set(it, 1); elm_list_item_selected_set(it, 1);
it = elm_list_item_append(list, _("Power Policy"), NULL, NULL, it = elm_list_item_append(list, _("Power Policy"), NULL, NULL,
_config_show_policy, cc); _config_show_policy, cc);
it = elm_list_item_append(list, _("Power Saving"), NULL, NULL, it = elm_list_item_append(list, _("Power Saving"), NULL, NULL,
_config_show_saving, cc); _config_show_saving, cc);
if (cc->pstate) if (cc->pstate)
it = elm_list_item_append(list, _("Power State"), NULL, NULL, it = elm_list_item_append(list, _("Power State"), NULL, NULL,
_config_show_pstate, cc); _config_show_pstate, cc);
if (cc->frequencies) if (cc->frequencies)
it = elm_list_item_append(list, _("Frequencies"), NULL, NULL, it = elm_list_item_append(list, _("Frequencies"), NULL, NULL,
_config_show_frequencies, cc); _config_show_frequencies, cc);
elm_list_go(list); elm_list_go(list);
evas_object_show(list); evas_object_show(list);
@ -348,25 +353,30 @@ cpuclock_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _poll_changed, cc); evas_object_smart_callback_add(o, "changed", _poll_changed, cc);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->cpuclock.poll_interval) switch (inst->cfg->cpuclock.poll_interval)
{ {
case 4: case 4:
elm_radio_value_set(group, 0); elm_radio_value_set(group, 0);
break; break;
case 8:
elm_radio_value_set(group, 1); case 8:
break; elm_radio_value_set(group, 1);
case 32: break;
elm_radio_value_set(group, 2);
break; case 32:
case 64: elm_radio_value_set(group, 2);
elm_radio_value_set(group, 3); break;
break;
case 256: case 64:
elm_radio_value_set(group, 4); elm_radio_value_set(group, 3);
break; break;
default:
elm_radio_value_set(group, 2); case 256:
elm_radio_value_set(group, 4);
break;
default:
elm_radio_value_set(group, 2);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);
@ -389,7 +399,7 @@ cpuclock_configure(Instance *inst)
{ {
o = elm_radio_add(box); o = elm_radio_add(box);
elm_radio_state_value_set(o, i); elm_radio_state_value_set(o, i);
E_ALIGN(o, 0.0, 0.0); E_ALIGN(o, 0.0, 0.0);
E_WEIGHT(o, EVAS_HINT_EXPAND, 0); E_WEIGHT(o, EVAS_HINT_EXPAND, 0);
if (!strcmp(l->data, "ondemand")) if (!strcmp(l->data, "ondemand"))
elm_object_text_set(o, _("Automatic")); elm_object_text_set(o, _("Automatic"));
@ -403,17 +413,17 @@ cpuclock_configure(Instance *inst)
elm_object_text_set(o, _("Maximum Speed")); elm_object_text_set(o, _("Maximum Speed"));
else else
elm_object_text_set(o, l->data); elm_object_text_set(o, l->data);
evas_object_data_set(o, "governor", strdup(l->data)); evas_object_data_set(o, "governor", strdup(l->data));
elm_box_pack_end(box, o); elm_box_pack_end(box, o);
evas_object_smart_callback_add(o, "changed", _governor_changed, cc); evas_object_smart_callback_add(o, "changed", _governor_changed, cc);
evas_object_show(o); evas_object_show(o);
if (!strcmp(inst->cfg->cpuclock.status->cur_governor, l->data)) if (!strcmp(inst->cfg->cpuclock.status->cur_governor, l->data))
value = i; value = i;
if (!groupg) if (!groupg)
groupg = o; groupg = o;
else else
elm_radio_group_add(o, groupg); elm_radio_group_add(o, groupg);
i++; i++;
} }
@ -473,8 +483,8 @@ cpuclock_configure(Instance *inst)
else else
elm_object_text_set(o, l->data); elm_object_text_set(o, l->data);
elm_object_disabled_set(o, inst->cfg->cpuclock.auto_powersave); elm_object_disabled_set(o, inst->cfg->cpuclock.auto_powersave);
evas_object_data_set(o, "governor", strdup(l->data)); evas_object_data_set(o, "governor", strdup(l->data));
elm_box_pack_end(box, o); elm_box_pack_end(box, o);
evas_object_smart_callback_add(o, "changed", _powersave_changed, cc); evas_object_smart_callback_add(o, "changed", _powersave_changed, cc);
evas_object_show(o); evas_object_show(o);
cc->powersaves = eina_list_append(cc->powersaves, o); cc->powersaves = eina_list_append(cc->powersaves, o);
@ -555,7 +565,7 @@ cpuclock_configure(Instance *inst)
E_EXPAND(box); E_EXPAND(box);
evas_object_show(box); evas_object_show(box);
i = 0; i = 0;
for (l = inst->cfg->cpuclock.status->frequencies; l; l = l->next) for (l = inst->cfg->cpuclock.status->frequencies; l; l = l->next)
{ {
char buf[4096]; char buf[4096];
@ -574,7 +584,7 @@ cpuclock_configure(Instance *inst)
snprintf(buf, sizeof(buf), _("%i MHz"), frequency / 1000); snprintf(buf, sizeof(buf), _("%i MHz"), frequency / 1000);
else else
snprintf(buf, sizeof(buf), _("%'.1f GHz"), snprintf(buf, sizeof(buf), _("%'.1f GHz"),
frequency / 1000000.); frequency / 1000000.);
#endif #endif
elm_object_text_set(o, buf); elm_object_text_set(o, buf);
elm_box_pack_end(box, o); elm_box_pack_end(box, o);
@ -588,7 +598,7 @@ cpuclock_configure(Instance *inst)
if (inst->cfg->cpuclock.status->cur_frequency == frequency) if (inst->cfg->cpuclock.status->cur_frequency == frequency)
value = i; value = i;
#endif #endif
if (!groupf) if (!groupf)
groupf = o; groupf = o;
else else
elm_radio_group_add(o, groupf); elm_radio_group_add(o, groupf);

View File

@ -9,7 +9,6 @@
# include <sys/sysctl.h> # include <sys/sysctl.h>
#endif #endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
int int
_cpuclock_sysctl_frequency(int new_perf) _cpuclock_sysctl_frequency(int new_perf)
@ -19,16 +18,18 @@ _cpuclock_sysctl_frequency(int new_perf)
if (sysctl(mib, 2, NULL, 0, &new_perf, len) == -1) if (sysctl(mib, 2, NULL, 0, &new_perf, len) == -1)
return 1; return 1;
return 0; return 0;
} }
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
int int
_cpuclock_sysctl_frequency(int new_perf) _cpuclock_sysctl_frequency(int new_perf)
{ {
if (sysctlbyname("dev.cpu.0.freq", NULL, NULL, &new_perf, sizeof(new_perf)) == -1) if (sysctlbyname("dev.cpu.0.freq", NULL, NULL, &new_perf, sizeof(new_perf)) == -1)
return 1; return 1;
return 0; return 0;
} }
#endif #endif

View File

@ -51,7 +51,7 @@ main(int argc, char *argv[])
else if (!strcmp(argv[1], "pstate")) else if (!strcmp(argv[1], "pstate"))
{ {
int min, max, turbo; int min, max, turbo;
if (argc < 5) if (argc < 5)
{ {
fprintf(stderr, "Invalid number of arguments.\n"); fprintf(stderr, "Invalid number of arguments.\n");
@ -134,16 +134,17 @@ sys_cpu_pstate(int min, int max, int turbo)
if (!f) return 0; if (!f) return 0;
fprintf(f, "%i\n", min); fprintf(f, "%i\n", min);
fclose(f); fclose(f);
f = fopen("/sys/devices/system/cpu/intel_pstate/max_perf_pct", "w"); f = fopen("/sys/devices/system/cpu/intel_pstate/max_perf_pct", "w");
if (!f) return 0; if (!f) return 0;
fprintf(f, "%i\n", max); fprintf(f, "%i\n", max);
fclose(f); fclose(f);
f = fopen("/sys/devices/system/cpu/intel_pstate/no_turbo", "w"); f = fopen("/sys/devices/system/cpu/intel_pstate/no_turbo", "w");
if (!f) return 0; if (!f) return 0;
fprintf(f, "%i\n", turbo ? 0 : 1); fprintf(f, "%i\n", turbo ? 0 : 1);
fclose(f); fclose(f);
return 1; return 1;
} }

View File

@ -4,14 +4,14 @@ typedef struct _Thread_Config Thread_Config;
struct _Thread_Config struct _Thread_Config
{ {
int interval; int interval;
int num_cores; int num_cores;
int percent; int percent;
unsigned long total; unsigned long total;
unsigned long idle; unsigned long idle;
Instance *inst; Instance *inst;
E_Powersave_Sleeper *sleeper; E_Powersave_Sleeper *sleeper;
Eina_List *cores; Eina_List *cores;
}; };
static void static void
@ -28,7 +28,7 @@ _cpumonitor_face_update(Thread_Config *thc)
usage_msg->count = 1; usage_msg->count = 1;
usage_msg->val[0] = core->percent; usage_msg->val[0] = core->percent;
edje_object_message_send(elm_layout_edje_get(core->layout), EDJE_MESSAGE_INT_SET, 1, edje_object_message_send(elm_layout_edje_get(core->layout), EDJE_MESSAGE_INT_SET, 1,
usage_msg); usage_msg);
E_FREE(usage_msg); E_FREE(usage_msg);
} }
if (thc->inst->cfg->cpumonitor.popup) if (thc->inst->cfg->cpumonitor.popup)
@ -81,7 +81,7 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
} }
popup = elm_ctxpopup_add(e_comp->elm); popup = elm_ctxpopup_add(e_comp->elm);
elm_object_style_set(popup, "noblock"); elm_object_style_set(popup, "noblock");
evas_object_smart_callback_add(popup, "dismissed", _cpumonitor_popup_dismissed, inst); evas_object_smart_callback_add(popup, "dismissed", _cpumonitor_popup_dismissed, inst);
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _cpumonitor_popup_deleted, inst); evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _cpumonitor_popup_deleted, inst);
box = elm_box_add(popup); box = elm_box_add(popup);
@ -95,7 +95,7 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
elm_object_text_set(label, text); elm_object_text_set(label, text);
elm_box_pack_end(box, label); elm_box_pack_end(box, label);
evas_object_show(label); evas_object_show(label);
pbar = elm_progressbar_add(box); pbar = elm_progressbar_add(box);
E_EXPAND(pbar); E_FILL(pbar); E_EXPAND(pbar); E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale); elm_progressbar_span_size_set(pbar, 200 * e_scale);
@ -163,25 +163,25 @@ static void
_cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th) _cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
for (;;) for (;; )
{ {
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
_cpumonitor_sysctl_getusage(&thc->total, &thc->idle, &thc->percent, thc->cores); _cpumonitor_sysctl_getusage(&thc->total, &thc->idle, &thc->percent, thc->cores);
#else #else
_cpumonitor_proc_getusage(&thc->total, &thc->idle, &thc->percent, thc->cores); _cpumonitor_proc_getusage(&thc->total, &thc->idle, &thc->percent, thc->cores);
#endif #endif
ecore_thread_feedback(th, NULL); ecore_thread_feedback(th, NULL);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
e_powersave_sleeper_sleep(thc->sleeper, thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
static void static void
_cpumonitor_cb_usage_check_notify(void *data, _cpumonitor_cb_usage_check_notify(void *data,
Ecore_Thread *th EINA_UNUSED, Ecore_Thread *th EINA_UNUSED,
void *msg EINA_UNUSED) void *msg EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
@ -240,7 +240,7 @@ _screensaver_on(void *data)
{ {
_cpumonitor_del_layouts(inst); _cpumonitor_del_layouts(inst);
ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread); ecore_thread_cancel(inst->cfg->cpumonitor.usage_check_thread);
inst->cfg->cpumonitor.usage_check_thread = NULL; inst->cfg->cpumonitor.usage_check_thread = NULL;
} }
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
@ -261,7 +261,7 @@ _cpumonitor_config_updated(Instance *inst)
Thread_Config *thc; Thread_Config *thc;
CPU_Core *core; CPU_Core *core;
int i = 0; int i = 0;
if (inst->cfg->id == -1) if (inst->cfg->id == -1)
{ {
int percent = 15; int percent = 15;
@ -284,14 +284,14 @@ _cpumonitor_config_updated(Instance *inst)
core->total = 0; core->total = 0;
core->idle = 0; core->idle = 0;
thc->cores = eina_list_append(thc->cores, core); thc->cores = eina_list_append(thc->cores, core);
percent += 15; percent += 15;
} }
_cpumonitor_face_update(thc); _cpumonitor_face_update(thc);
EINA_LIST_FREE(thc->cores, core) EINA_LIST_FREE(thc->cores, core)
E_FREE(core); E_FREE(core);
E_FREE(thc); E_FREE(thc);
} }
return; return;
} }
if (!ecore_thread_check(inst->cfg->cpumonitor.usage_check_thread)) if (!ecore_thread_check(inst->cfg->cpumonitor.usage_check_thread))
{ {
@ -474,7 +474,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;

View File

@ -15,30 +15,35 @@ _config_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
Instance *inst = data; Instance *inst = data;
int value = elm_radio_value_get(obj); int value = elm_radio_value_get(obj);
switch(value) switch (value)
{ {
case 0: case 0:
inst->cfg->cpumonitor.poll_interval = 4; inst->cfg->cpumonitor.poll_interval = 4;
break; break;
case 1:
inst->cfg->cpumonitor.poll_interval = 8; case 1:
break; inst->cfg->cpumonitor.poll_interval = 8;
case 2: break;
inst->cfg->cpumonitor.poll_interval = 32;
break; case 2:
case 3: inst->cfg->cpumonitor.poll_interval = 32;
inst->cfg->cpumonitor.poll_interval = 64; break;
break;
case 4: case 3:
inst->cfg->cpumonitor.poll_interval = 256; inst->cfg->cpumonitor.poll_interval = 64;
break; break;
default:
inst->cfg->cpumonitor.poll_interval = 32; case 4:
inst->cfg->cpumonitor.poll_interval = 256;
break;
default:
inst->cfg->cpumonitor.poll_interval = 32;
} }
e_config_save_queue(); e_config_save_queue();
_cpumonitor_config_updated(inst); _cpumonitor_config_updated(inst);
} }
Evas_Object * Evas_Object *
cpumonitor_configure(Instance *inst) cpumonitor_configure(Instance *inst)
{ {
@ -126,25 +131,30 @@ cpumonitor_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _config_changed, inst); evas_object_smart_callback_add(o, "changed", _config_changed, inst);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->cpumonitor.poll_interval) switch (inst->cfg->cpumonitor.poll_interval)
{ {
case 4: case 4:
elm_radio_value_set(group, 0); elm_radio_value_set(group, 0);
break; break;
case 8:
elm_radio_value_set(group, 1); case 8:
break; elm_radio_value_set(group, 1);
case 32: break;
elm_radio_value_set(group, 2);
break; case 32:
case 64: elm_radio_value_set(group, 2);
elm_radio_value_set(group, 3); break;
break;
case 256: case 64:
elm_radio_value_set(group, 4); elm_radio_value_set(group, 3);
break; break;
default:
elm_radio_value_set(group, 2); case 256:
elm_radio_value_set(group, 4);
break;
default:
elm_radio_value_set(group, 2);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);

View File

@ -22,7 +22,7 @@ _cpumonitor_proc_getcores(void)
} }
i++; i++;
} }
fclose (f); fclose(f);
} }
return cores; return cores;
} }
@ -50,7 +50,7 @@ _cpumonitor_proc_getusage(unsigned long *prev_total,
char *line, *tok; char *line, *tok;
int i = 0; int i = 0;
line = strchr(buf, ' ')+1; line = strchr(buf, ' ') + 1;
tok = strtok(line, " "); tok = strtok(line, " ");
while (tok) while (tok)
{ {
@ -66,7 +66,8 @@ _cpumonitor_proc_getusage(unsigned long *prev_total,
if (total_change != 0) if (total_change != 0)
percent = 100 * (1 - ((float)idle_change / (float)total_change)); percent = 100 * (1 - ((float)idle_change / (float)total_change));
if (percent > 100) percent = 100; if (percent > 100) percent = 100;
else if (percent < 0) percent = 0; else if (percent < 0)
percent = 0;
*prev_total = total; *prev_total = total;
*prev_idle = idle; *prev_idle = idle;
*prev_percent = percent; *prev_percent = percent;
@ -98,7 +99,8 @@ _cpumonitor_proc_getusage(unsigned long *prev_total,
if (total_change != 0) if (total_change != 0)
percent = 100 * (1 - ((float)idle_change / (float)total_change)); percent = 100 * (1 - ((float)idle_change / (float)total_change));
if (percent > 100) percent = 100; if (percent > 100) percent = 100;
else if (percent < 0) percent = 0; else if (percent < 0)
percent = 0;
core->percent = percent; core->percent = percent;
core->total = total; core->total = total;
core->idle = idle; core->idle = idle;

View File

@ -11,7 +11,7 @@
# define CPU_STATES 6 # define CPU_STATES 6
#endif #endif
int int
_cpumonitor_sysctl_getcores(void) _cpumonitor_sysctl_getcores(void)
{ {
int cores = 0; int cores = 0;
@ -20,12 +20,11 @@ _cpumonitor_sysctl_getcores(void)
int mib[2] = { CTL_HW, HW_NCPU }; int mib[2] = { CTL_HW, HW_NCPU };
len = sizeof(cores); len = sizeof(cores);
if (sysctl(mib, 2, &cores, &len, NULL, 0) < 0) return 0; if (sysctl(mib, 2, &cores, &len, NULL, 0) < 0) return 0;
#endif #endif
return cores; return cores;
} }
void void
_cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle, int *prev_percent, Eina_List *cores) _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle, int *prev_percent, Eina_List *cores)
{ {
@ -36,19 +35,19 @@ _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle,
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
int ncpu = _cpumonitor_sysctl_getcores(); int ncpu = _cpumonitor_sysctl_getcores();
if (!ncpu) return; if (!ncpu) return;
size = sizeof(unsigned long) * (CPU_STATES * ncpu); size = sizeof(unsigned long) * (CPU_STATES * ncpu);
unsigned long cpu_times[ncpu][CPU_STATES]; unsigned long cpu_times[ncpu][CPU_STATES];
if (sysctlbyname("kern.cp_times", cpu_times, &size, NULL, 0) < 0) if (sysctlbyname("kern.cp_times", cpu_times, &size, NULL, 0) < 0)
return; return;
for (i = 0; i < ncpu; i++) for (i = 0; i < ncpu; i++)
{ {
unsigned long *cpu = cpu_times[i]; unsigned long *cpu = cpu_times[i];
double total = 0; double total = 0;
for (j = 0; j < CPU_STATES; j++) for (j = 0; j < CPU_STATES; j++)
total += cpu[j]; total += cpu[j];
core = eina_list_nth(cores, i); core = eina_list_nth(cores, i);
@ -61,22 +60,22 @@ _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle,
unsigned long used = diff_total - diff_idle; unsigned long used = diff_total - diff_idle;
int percent = used / ratio; int percent = used / ratio;
if (percent > 100) if (percent > 100)
percent = 100; percent = 100;
else if (percent < 0) else if (percent < 0)
percent = 0; percent = 0;
core->percent = percent; core->percent = percent;
core->total = total; core->total = total;
core->idle = cpu[4]; core->idle = cpu[4];
percent_all += (int) percent; percent_all += (int)percent;
total_all += total; total_all += total;
idle_all += core->idle; idle_all += core->idle;
} }
*prev_total = total_all / ncpu; *prev_total = total_all / ncpu;
*prev_idle = idle_all / ncpu; *prev_idle = idle_all / ncpu;
*prev_percent = (int) (percent_all / ncpu); *prev_percent = (int)(percent_all / ncpu);
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__)
int ncpu = _cpumonitor_sysctl_getcores(); int ncpu = _cpumonitor_sysctl_getcores();
if (!ncpu) return; if (!ncpu) return;
@ -91,7 +90,7 @@ _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle,
unsigned long total = 0; unsigned long total = 0;
for (j = 0; j < CPU_STATES - 1; j++) for (j = 0; j < CPU_STATES - 1; j++)
total += cpu_times[j]; total += cpu_times[j];
unsigned long idle = cpu_times[4]; unsigned long idle = cpu_times[4];
int diff_total = total - *prev_total; int diff_total = total - *prev_total;
@ -106,14 +105,14 @@ _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle,
percent = 100; percent = 100;
else if (percent < 0) else if (percent < 0)
percent = 0; percent = 0;
*prev_total = total; *prev_total = total;
*prev_idle = idle; // cpu_times[3]; *prev_idle = idle; // cpu_times[3];
*prev_percent = (int) percent; *prev_percent = (int)percent;
} }
else if (ncpu > 1) else if (ncpu > 1)
{ {
for (i = 0; i < ncpu; i++) for (i = 0; i < ncpu; i++)
{ {
unsigned long cpu_times[CPU_STATES]; unsigned long cpu_times[CPU_STATES];
size = CPU_STATES * sizeof(unsigned long); size = CPU_STATES * sizeof(unsigned long);
@ -125,10 +124,10 @@ _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle,
unsigned long total = 0; unsigned long total = 0;
for (j = 0; j < CPU_STATES - 1; j++) for (j = 0; j < CPU_STATES - 1; j++)
total += cpu_times[j]; total += cpu_times[j];
core = eina_list_nth(cores, i); core = eina_list_nth(cores, i);
int diff_total = total - core->total; int diff_total = total - core->total;
int diff_idle = cpu_times[4] - core->idle; int diff_idle = cpu_times[4] - core->idle;
core->total = total; core->total = total;
core->idle = cpu_times[4]; core->idle = cpu_times[4];
@ -140,13 +139,13 @@ _cpumonitor_sysctl_getusage(unsigned long *prev_total, unsigned long *prev_idle,
core->percent = percent; core->percent = percent;
percent_all += (int) percent; percent_all += (int)percent;
total_all += total; total_all += total;
idle_all += core->idle; idle_all += core->idle;
} }
*prev_total = (total_all / ncpu); *prev_total = (total_all / ncpu);
*prev_idle = (idle_all / ncpu); *prev_idle = (idle_all / ncpu);
*prev_percent = (percent_all / ncpu) + (percent_all % ncpu); *prev_percent = (percent_all / ncpu) + (percent_all % ncpu);
} }
#endif #endif

View File

@ -4,17 +4,17 @@ typedef struct _Thread_Config Thread_Config;
struct _Thread_Config struct _Thread_Config
{ {
int interval; int interval;
Instance *inst; Instance *inst;
int mem_percent; int mem_percent;
int swp_percent; int swp_percent;
unsigned long mem_total; unsigned long mem_total;
unsigned long mem_used; unsigned long mem_used;
unsigned long mem_cached; unsigned long mem_cached;
unsigned long mem_buffers; unsigned long mem_buffers;
unsigned long mem_shared; unsigned long mem_shared;
unsigned long swp_total; unsigned long swp_total;
unsigned long swp_used; unsigned long swp_used;
E_Powersave_Sleeper *sleeper; E_Powersave_Sleeper *sleeper;
}; };
@ -275,18 +275,18 @@ static void
_memusage_cb_usage_check_main(void *data, Ecore_Thread *th) _memusage_cb_usage_check_main(void *data, Ecore_Thread *th)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
for (;;) for (;; )
{ {
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
_memusage_sysctl_getusage(&thc->mem_total, &thc->mem_used, _memusage_sysctl_getusage(&thc->mem_total, &thc->mem_used,
&thc->mem_cached, &thc->mem_buffers, &thc->mem_shared, &thc->mem_cached, &thc->mem_buffers, &thc->mem_shared,
&thc->swp_total, &thc->swp_used); &thc->swp_total, &thc->swp_used);
#else #else
_memusage_proc_getusage(&thc->mem_total, &thc->mem_used, _memusage_proc_getusage(&thc->mem_total, &thc->mem_used,
&thc->mem_cached, &thc->mem_buffers, &thc->mem_shared, &thc->mem_cached, &thc->mem_buffers, &thc->mem_shared,
&thc->swp_total, &thc->swp_used); &thc->swp_total, &thc->swp_used);
#endif #endif
if (thc->mem_total > 0) if (thc->mem_total > 0)
thc->mem_percent = 100 * ((float)thc->mem_used / (float)thc->mem_total); thc->mem_percent = 100 * ((float)thc->mem_used / (float)thc->mem_total);
if (thc->swp_total > 0) if (thc->swp_total > 0)
@ -309,8 +309,8 @@ _memusage_cb_usage_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
static void static void
_memusage_cb_usage_check_notify(void *data, _memusage_cb_usage_check_notify(void *data,
Ecore_Thread *th EINA_UNUSED, Ecore_Thread *th EINA_UNUSED,
void *msg EINA_UNUSED) void *msg EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
@ -363,7 +363,7 @@ _memusage_config_updated(Instance *inst)
inst->cfg->memusage.mem_percent = 75; inst->cfg->memusage.mem_percent = 75;
inst->cfg->memusage.swp_percent = 30; inst->cfg->memusage.swp_percent = 30;
_memusage_face_update(inst); _memusage_face_update(inst);
return; return;
} }
if (inst->cfg->memusage.usage_check_thread) if (inst->cfg->memusage.usage_check_thread)
{ {
@ -395,7 +395,6 @@ _memusage_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
if (inst->o_main != event_data) return; if (inst->o_main != event_data) return;
if (inst->cfg->memusage.popup) if (inst->cfg->memusage.popup)
E_FREE_FUNC(inst->cfg->memusage.popup, evas_object_del); E_FREE_FUNC(inst->cfg->memusage.popup, evas_object_del);
if (inst->cfg->memusage.configure) if (inst->cfg->memusage.configure)
@ -502,7 +501,6 @@ sysinfo_memusage_create(Evas_Object *parent, Instance *inst)
_memusage_resize_cb, inst); _memusage_resize_cb, inst);
evas_object_show(inst->cfg->memusage.o_gadget); evas_object_show(inst->cfg->memusage.o_gadget);
E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst); E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_ON, _screensaver_on, inst);
E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst); E_LIST_HANDLER_APPEND(inst->cfg->memusage.handlers, E_EVENT_SCREENSAVER_OFF, _screensaver_off, inst);
@ -526,7 +524,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;

View File

@ -15,30 +15,35 @@ _config_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
Instance *inst = data; Instance *inst = data;
int value = elm_radio_value_get(obj); int value = elm_radio_value_get(obj);
switch(value) switch (value)
{ {
case 0: case 0:
inst->cfg->memusage.poll_interval = 4; inst->cfg->memusage.poll_interval = 4;
break; break;
case 1:
inst->cfg->memusage.poll_interval = 8; case 1:
break; inst->cfg->memusage.poll_interval = 8;
case 2: break;
inst->cfg->memusage.poll_interval = 32;
break; case 2:
case 3: inst->cfg->memusage.poll_interval = 32;
inst->cfg->memusage.poll_interval = 64; break;
break;
case 4: case 3:
inst->cfg->memusage.poll_interval = 256; inst->cfg->memusage.poll_interval = 64;
break; break;
default:
inst->cfg->memusage.poll_interval = 32; case 4:
inst->cfg->memusage.poll_interval = 256;
break;
default:
inst->cfg->memusage.poll_interval = 32;
} }
e_config_save_queue(); e_config_save_queue();
_memusage_config_updated(inst); _memusage_config_updated(inst);
} }
Evas_Object * Evas_Object *
memusage_configure(Instance *inst) memusage_configure(Instance *inst)
{ {
@ -126,25 +131,30 @@ memusage_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _config_changed, inst); evas_object_smart_callback_add(o, "changed", _config_changed, inst);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->memusage.poll_interval) switch (inst->cfg->memusage.poll_interval)
{ {
case 4: case 4:
elm_radio_value_set(group, 0); elm_radio_value_set(group, 0);
break; break;
case 8:
elm_radio_value_set(group, 1); case 8:
break; elm_radio_value_set(group, 1);
case 32: break;
elm_radio_value_set(group, 2);
break; case 32:
case 64: elm_radio_value_set(group, 2);
elm_radio_value_set(group, 3); break;
break;
case 256: case 64:
elm_radio_value_set(group, 4); elm_radio_value_set(group, 3);
break; break;
default:
elm_radio_value_set(group, 2); case 256:
elm_radio_value_set(group, 4);
break;
default:
elm_radio_value_set(group, 2);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);

View File

@ -1,23 +1,25 @@
#include "memusage.h" #include "memusage.h"
unsigned long
unsigned long _line_parse(const char *line) _line_parse(const char *line)
{ {
char *p, *tok; char *p, *tok;
p = strchr(line, ':') + 1; p = strchr(line, ':') + 1;
while(isspace(*p)) p++; while (isspace(*p))
p++;
tok = strtok(p, " "); tok = strtok(p, " ");
return atol(tok); return atol(tok);
} }
void _memusage_proc_getusage(unsigned long *mem_total, void
unsigned long *mem_used, _memusage_proc_getusage(unsigned long *mem_total,
unsigned long *mem_cached, unsigned long *mem_used,
unsigned long *mem_buffers, unsigned long *mem_cached,
unsigned long *mem_shared, unsigned long *mem_buffers,
unsigned long *swp_total, unsigned long *mem_shared,
unsigned long *swp_used) unsigned long *swp_total,
unsigned long *swp_used)
{ {
char line[256]; char line[256];
int found = 0; int found = 0;
@ -39,7 +41,7 @@ void _memusage_proc_getusage(unsigned long *mem_total,
f = fopen("/proc/meminfo", "r"); f = fopen("/proc/meminfo", "r");
if (!f) return; if (!f) return;
while(fgets(line, sizeof(line), f) != NULL) while (fgets(line, sizeof(line), f) != NULL)
{ {
if (!strncmp("MemTotal:", line, 9)) if (!strncmp("MemTotal:", line, 9))
{ {
@ -93,3 +95,4 @@ void _memusage_proc_getusage(unsigned long *mem_total,
*swp_total = tmp_swp_total; *swp_total = tmp_swp_total;
*swp_used = tmp_swp_total - tmp_swp_free; *swp_used = tmp_swp_total - tmp_swp_free;
} }

View File

@ -11,35 +11,38 @@
# include <sys/sysctl.h> # include <sys/sysctl.h>
# include <sys/swap.h> # include <sys/swap.h>
# include <sys/mount.h> # include <sys/mount.h>
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static long int static long int
_sysctlfromname(const char *name, void *mib, int depth, size_t *len) _sysctlfromname(const char *name, void *mib, int depth, size_t *len)
{ {
long int result; long int result;
if (sysctlnametomib(name, mib, len) < 0) return -1;
*len = sizeof(result); if (sysctlnametomib(name, mib, len) < 0) return -1;
if (sysctl(mib, depth, &result, len, NULL, 0) < 0) return -1;
return result; *len = sizeof(result);
if (sysctl(mib, depth, &result, len, NULL, 0) < 0) return -1;
return result;
} }
#endif #endif
void _memsize_bytes_to_kb(unsigned long *bytes) void
_memsize_bytes_to_kb(unsigned long *bytes)
{ {
*bytes = (unsigned int) *bytes >> 10; *bytes = (unsigned int)*bytes >> 10;
} }
void _memusage_sysctl_getusage(unsigned long *mem_total, void
unsigned long *mem_used, _memusage_sysctl_getusage(unsigned long *mem_total,
unsigned long *mem_cached, unsigned long *mem_used,
unsigned long *mem_buffers, unsigned long *mem_cached,
unsigned long *mem_shared, unsigned long *mem_buffers,
unsigned long *swp_total, unsigned long *mem_shared,
unsigned long *swp_used) unsigned long *swp_total,
unsigned long *swp_used)
{ {
size_t len; size_t len;
int i = 0; int i = 0;
@ -53,7 +56,7 @@ void _memusage_sysctl_getusage(unsigned long *mem_total,
int *mib = malloc(sizeof(int) * 4); int *mib = malloc(sizeof(int) * 4);
if (mib == NULL) return; if (mib == NULL) return;
mib[0] = CTL_HW; mib[1] = HW_PHYSMEM; mib[0] = CTL_HW; mib[1] = HW_PHYSMEM;
len = sizeof(*mem_total); len = sizeof(*mem_total);
if (sysctl(mib, 2, mem_total, &len, NULL, 0) == -1) if (sysctl(mib, 2, mem_total, &len, NULL, 0) == -1)
return; return;
@ -65,10 +68,10 @@ void _memusage_sysctl_getusage(unsigned long *mem_total,
free_pages = _sysctlfromname("vm.stats.vm.v_free_count", mib, 4, &len); free_pages = _sysctlfromname("vm.stats.vm.v_free_count", mib, 4, &len);
if (free_pages < 0) return; if (free_pages < 0) return;
inactive_pages = _sysctlfromname("vm.stats.vm.v_inactive_count", mib, 4, &len); inactive_pages = _sysctlfromname("vm.stats.vm.v_inactive_count", mib, 4, &len);
if (inactive_pages < 0) return; if (inactive_pages < 0) return;
*mem_used = (total_pages - free_pages - inactive_pages) * page_size; *mem_used = (total_pages - free_pages - inactive_pages) * page_size;
_memsize_bytes_to_kb(mem_used); _memsize_bytes_to_kb(mem_used);
result = _sysctlfromname("vfs.bufspace", mib, 2, &len); result = _sysctlfromname("vfs.bufspace", mib, 2, &len);
@ -76,7 +79,7 @@ void _memusage_sysctl_getusage(unsigned long *mem_total,
*mem_buffers = (result); *mem_buffers = (result);
_memsize_bytes_to_kb(mem_buffers); _memsize_bytes_to_kb(mem_buffers);
result = _sysctlfromname("vm.stats.vm.v_active_count", mib, 4, &len); result = _sysctlfromname("vm.stats.vm.v_active_count", mib, 4, &len);
if (result < 0) return; if (result < 0) return;
*mem_cached = (result * page_size); *mem_cached = (result * page_size);
_memsize_bytes_to_kb(mem_cached); _memsize_bytes_to_kb(mem_cached);
@ -93,7 +96,7 @@ void _memusage_sysctl_getusage(unsigned long *mem_total,
struct xswdev xsw; struct xswdev xsw;
// previous mib is important for this one... // previous mib is important for this one...
while (i++) while (i++)
{ {
mib[2] = i; mib[2] = i;
len = sizeof(xsw); len = sizeof(xsw);
@ -117,11 +120,11 @@ void _memusage_sysctl_getusage(unsigned long *mem_total,
len = sizeof(*mem_total); len = sizeof(*mem_total);
if (sysctl(mib, 2, mem_total, &len, NULL, 0) == -1) if (sysctl(mib, 2, mem_total, &len, NULL, 0) == -1)
return; return;
len = sizeof(uvmexp); len = sizeof(uvmexp);
if (sysctl(uvmexp_mib, 2, &uvmexp, &len, NULL, 0) == -1) if (sysctl(uvmexp_mib, 2, &uvmexp, &len, NULL, 0) == -1)
return; return;
len = sizeof(bcstats); len = sizeof(bcstats);
if (sysctl(bcstats_mib, 3, &bcstats, &len, NULL, 0) == -1) if (sysctl(bcstats_mib, 3, &bcstats, &len, NULL, 0) == -1)
return; return;
@ -129,30 +132,30 @@ void _memusage_sysctl_getusage(unsigned long *mem_total,
// Don't fail if there's not swap! // Don't fail if there's not swap!
nswap = swapctl(SWAP_NSWAP, 0, 0); nswap = swapctl(SWAP_NSWAP, 0, 0);
if (nswap == 0) goto swap_out; if (nswap == 0) goto swap_out;
swdev = calloc(nswap, sizeof(*swdev)); swdev = calloc(nswap, sizeof(*swdev));
if (swdev == NULL) goto swap_out; if (swdev == NULL) goto swap_out;
rnswap = swapctl(SWAP_STATS, swdev, nswap); rnswap = swapctl(SWAP_STATS, swdev, nswap);
if (rnswap == -1) goto swap_out; if (rnswap == -1) goto swap_out;
for (i = 0; i < nswap; i++)// nswap; i++) for (i = 0; i < nswap; i++) // nswap; i++)
{ {
if (swdev[i].se_flags & SWF_ENABLE) if (swdev[i].se_flags & SWF_ENABLE)
{ {
*swp_used += (swdev[i].se_inuse / (1024 / DEV_BSIZE)); *swp_used += (swdev[i].se_inuse / (1024 / DEV_BSIZE));
*swp_total += (swdev[i].se_nblks / (1024 / DEV_BSIZE)); *swp_total += (swdev[i].se_nblks / (1024 / DEV_BSIZE));
} }
} }
swap_out: swap_out:
if (swdev) E_FREE(swdev); if (swdev) E_FREE(swdev);
*mem_total /= 1024; *mem_total /= 1024;
*mem_cached = (uvmexp.pagesize * bcstats.numbufpages); *mem_cached = (uvmexp.pagesize * bcstats.numbufpages);
_memsize_bytes_to_kb(mem_cached); _memsize_bytes_to_kb(mem_cached);
*mem_used = (uvmexp.active * uvmexp.pagesize); *mem_used = (uvmexp.active * uvmexp.pagesize);
_memsize_bytes_to_kb(mem_used); _memsize_bytes_to_kb(mem_used);
*mem_buffers = (uvmexp.pagesize * (uvmexp.npages - uvmexp.free)); *mem_buffers = (uvmexp.pagesize * (uvmexp.npages - uvmexp.free));
@ -160,5 +163,6 @@ swap_out:
*mem_shared = (uvmexp.pagesize * uvmexp.wired); *mem_shared = (uvmexp.pagesize * uvmexp.wired);
_memsize_bytes_to_kb(mem_shared); _memsize_bytes_to_kb(mem_shared);
#endif #endif
} }

View File

@ -98,7 +98,7 @@ sysinfo_init(void)
ci->thermal.units = CELSIUS; ci->thermal.units = CELSIUS;
ci->thermal.popup = NULL; ci->thermal.popup = NULL;
ci->thermal.configure = NULL; ci->thermal.configure = NULL;
ci->cpuclock.poll_interval = 32; ci->cpuclock.poll_interval = 32;
ci->cpuclock.restore_governor = 0; ci->cpuclock.restore_governor = 0;
ci->cpuclock.auto_powersave = 1; ci->cpuclock.auto_powersave = 1;
ci->cpuclock.powersave_governor = NULL; ci->cpuclock.powersave_governor = NULL;
@ -106,8 +106,8 @@ sysinfo_init(void)
ci->cpuclock.pstate_min = 1; ci->cpuclock.pstate_min = 1;
ci->cpuclock.pstate_max = 101; ci->cpuclock.pstate_max = 101;
ci->cpuclock.popup = NULL; ci->cpuclock.popup = NULL;
ci->cpuclock.configure = NULL; ci->cpuclock.configure = NULL;
ci->cpumonitor.poll_interval = 32; ci->cpumonitor.poll_interval = 32;
ci->cpumonitor.percent = 0; ci->cpumonitor.percent = 0;
ci->cpumonitor.popup = NULL; ci->cpumonitor.popup = NULL;
ci->cpumonitor.configure = NULL; ci->cpumonitor.configure = NULL;
@ -120,7 +120,7 @@ sysinfo_init(void)
ci->netstatus.automax = EINA_TRUE; ci->netstatus.automax = EINA_TRUE;
ci->netstatus.inmax = 0; ci->netstatus.inmax = 0;
ci->netstatus.outmax = 0; ci->netstatus.outmax = 0;
ci->netstatus.receive_units = NETSTATUS_UNIT_BYTES; ci->netstatus.receive_units = NETSTATUS_UNIT_BYTES;
ci->netstatus.send_units = NETSTATUS_UNIT_BYTES; ci->netstatus.send_units = NETSTATUS_UNIT_BYTES;
ci->netstatus.instring = NULL; ci->netstatus.instring = NULL;
ci->netstatus.outstring = NULL; ci->netstatus.outstring = NULL;

View File

@ -4,19 +4,19 @@ typedef struct _Thread_Config Thread_Config;
struct _Thread_Config struct _Thread_Config
{ {
int interval; int interval;
Instance *inst; Instance *inst;
Eina_Bool automax; Eina_Bool automax;
int inpercent; int inpercent;
unsigned long in; unsigned long in;
unsigned long incurrent; unsigned long incurrent;
unsigned long inmax; unsigned long inmax;
Eina_Stringshare *instring; Eina_Stringshare *instring;
int outpercent; int outpercent;
unsigned long out; unsigned long out;
unsigned long outcurrent; unsigned long outcurrent;
unsigned long outmax; unsigned long outmax;
Eina_Stringshare *outstring; Eina_Stringshare *outstring;
E_Powersave_Sleeper *sleeper; E_Powersave_Sleeper *sleeper;
}; };
@ -137,7 +137,7 @@ static void
_netstatus_cb_usage_check_main(void *data, Ecore_Thread *th) _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
for (;;) for (;; )
{ {
char rin[4096], rout[4096]; char rin[4096], rout[4096];
@ -145,7 +145,7 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
_netstatus_sysctl_getrstatus(thc->automax, &thc->in, &thc->incurrent, &thc->inmax, &thc->inpercent); _netstatus_sysctl_getrstatus(thc->automax, &thc->in, &thc->incurrent, &thc->inmax, &thc->inpercent);
_netstatus_sysctl_gettstatus(thc->automax, &thc->out, &thc->outcurrent, &thc->outmax, &thc->outpercent); _netstatus_sysctl_gettstatus(thc->automax, &thc->out, &thc->outcurrent, &thc->outmax, &thc->outpercent);
#else #else
_netstatus_proc_getrstatus(thc->automax, &thc->in, &thc->incurrent, &thc->inmax, &thc->inpercent); _netstatus_proc_getrstatus(thc->automax, &thc->in, &thc->incurrent, &thc->inmax, &thc->inpercent);
_netstatus_proc_gettstatus(thc->automax, &thc->out, &thc->outcurrent, &thc->outmax, &thc->outpercent); _netstatus_proc_gettstatus(thc->automax, &thc->out, &thc->outcurrent, &thc->outmax, &thc->outpercent);
#endif #endif
@ -177,7 +177,7 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
snprintf(rout, sizeof(rout), "%s: %lu B/s", _("Sending"), thc->outcurrent); snprintf(rout, sizeof(rout), "%s: %lu B/s", _("Sending"), thc->outcurrent);
} }
eina_stringshare_replace(&thc->outstring, rout); eina_stringshare_replace(&thc->outstring, rout);
ecore_thread_feedback(th, NULL); ecore_thread_feedback(th, NULL);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
e_powersave_sleeper_sleep(thc->sleeper, thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
@ -186,16 +186,16 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
static void static void
_netstatus_cb_usage_check_notify(void *data, _netstatus_cb_usage_check_notify(void *data,
Ecore_Thread *th EINA_UNUSED, Ecore_Thread *th EINA_UNUSED,
void *msg EINA_UNUSED) void *msg EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
if (!thc->inst->cfg) return; if (!thc->inst->cfg) return;
if (thc->inst->cfg->esm != E_SYSINFO_MODULE_NETSTATUS && thc->inst->cfg->esm != E_SYSINFO_MODULE_SYSINFO) return; if (thc->inst->cfg->esm != E_SYSINFO_MODULE_NETSTATUS && thc->inst->cfg->esm != E_SYSINFO_MODULE_SYSINFO) return;
eina_stringshare_replace(&thc->inst->cfg->netstatus.instring, thc->instring); eina_stringshare_replace(&thc->inst->cfg->netstatus.instring, thc->instring);
eina_stringshare_replace(&thc->inst->cfg->netstatus.outstring, thc->outstring); eina_stringshare_replace(&thc->inst->cfg->netstatus.outstring, thc->outstring);
_netstatus_face_update(thc); _netstatus_face_update(thc);
} }
@ -247,7 +247,7 @@ _netstatus_config_updated(Instance *inst)
thc->outpercent = 30; thc->outpercent = 30;
_netstatus_face_update(thc); _netstatus_face_update(thc);
E_FREE(thc); E_FREE(thc);
} }
return; return;
} }
if (inst->cfg->netstatus.usage_check_thread) if (inst->cfg->netstatus.usage_check_thread)
@ -272,7 +272,7 @@ _netstatus_config_updated(Instance *inst)
thc->outpercent = 0; thc->outpercent = 0;
thc->outstring = NULL; thc->outstring = NULL;
thc->automax = inst->cfg->netstatus.automax; thc->automax = inst->cfg->netstatus.automax;
inst->cfg->netstatus.usage_check_thread = inst->cfg->netstatus.usage_check_thread =
ecore_thread_feedback_run(_netstatus_cb_usage_check_main, ecore_thread_feedback_run(_netstatus_cb_usage_check_main,
_netstatus_cb_usage_check_notify, _netstatus_cb_usage_check_notify,
_netstatus_cb_usage_check_end, _netstatus_cb_usage_check_end,
@ -406,7 +406,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;

View File

@ -18,25 +18,30 @@ _poll_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
Instance *inst = nc->inst; Instance *inst = nc->inst;
int value = elm_radio_value_get(obj); int value = elm_radio_value_get(obj);
switch(value) switch (value)
{ {
case 0: case 0:
inst->cfg->netstatus.poll_interval = 4; inst->cfg->netstatus.poll_interval = 4;
break; break;
case 1:
inst->cfg->netstatus.poll_interval = 8; case 1:
break; inst->cfg->netstatus.poll_interval = 8;
case 2: break;
inst->cfg->netstatus.poll_interval = 32;
break; case 2:
case 3: inst->cfg->netstatus.poll_interval = 32;
inst->cfg->netstatus.poll_interval = 64; break;
break;
case 4: case 3:
inst->cfg->netstatus.poll_interval = 256; inst->cfg->netstatus.poll_interval = 64;
break; break;
default:
inst->cfg->netstatus.poll_interval = 32; case 4:
inst->cfg->netstatus.poll_interval = 256;
break;
default:
inst->cfg->netstatus.poll_interval = 32;
} }
e_config_save_queue(); e_config_save_queue();
@ -244,25 +249,30 @@ netstatus_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _poll_changed, nc); evas_object_smart_callback_add(o, "changed", _poll_changed, nc);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->netstatus.poll_interval) switch (inst->cfg->netstatus.poll_interval)
{ {
case 4: case 4:
elm_radio_value_set(group, 0); elm_radio_value_set(group, 0);
break; break;
case 8:
elm_radio_value_set(group, 1); case 8:
break; elm_radio_value_set(group, 1);
case 32: break;
elm_radio_value_set(group, 2);
break; case 32:
case 64: elm_radio_value_set(group, 2);
elm_radio_value_set(group, 3); break;
break;
case 256: case 64:
elm_radio_value_set(group, 4); elm_radio_value_set(group, 3);
break; break;
default:
elm_radio_value_set(group, 2); case 256:
elm_radio_value_set(group, 4);
break;
default:
elm_radio_value_set(group, 2);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);

View File

@ -16,12 +16,12 @@ _netstatus_proc_getrstatus(Eina_Bool automax,
f = fopen("/proc/net/dev", "r"); f = fopen("/proc/net/dev", "r");
if (f) if (f)
{ {
while(fgets(buf, sizeof(buf), f) != NULL) while (fgets(buf, sizeof(buf), f) != NULL)
{ {
if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu " if (sscanf(buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu\n", dummys, &in, &dummy, &dummy, "%lu %lu %lu %lu\n", dummys, &in, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17) &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
continue; continue;
tot_in += in; tot_in += in;
} }
@ -42,7 +42,8 @@ _netstatus_proc_getrstatus(Eina_Bool automax,
if (*prev_inmax > 0) if (*prev_inmax > 0)
percent = 100 * ((float)*prev_incurrent / (float)*prev_inmax); percent = 100 * ((float)*prev_incurrent / (float)*prev_inmax);
if (percent > 100) percent = 100; if (percent > 100) percent = 100;
else if (percent < 0) percent = 0; else if (percent < 0)
percent = 0;
*prev_inpercent = percent; *prev_inpercent = percent;
} }
} }
@ -63,12 +64,12 @@ _netstatus_proc_gettstatus(Eina_Bool automax,
f = fopen("/proc/net/dev", "r"); f = fopen("/proc/net/dev", "r");
if (f) if (f)
{ {
while(fgets(buf, sizeof(buf), f) != NULL) while (fgets(buf, sizeof(buf), f) != NULL)
{ {
if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu " if (sscanf(buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu\n", dummys, &dummy, &dummy, &dummy, "%lu %lu %lu %lu\n", dummys, &dummy, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &out, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &out, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17) &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
continue; continue;
tot_out += out; tot_out += out;
} }
@ -89,7 +90,8 @@ _netstatus_proc_gettstatus(Eina_Bool automax,
if (*prev_outcurrent > 0) if (*prev_outcurrent > 0)
percent = 100 * ((float)*prev_outcurrent / (float)*prev_outmax); percent = 100 * ((float)*prev_outcurrent / (float)*prev_outmax);
if (percent > 100) percent = 100; if (percent > 100) percent = 100;
else if (percent < 0) percent = 0; else if (percent < 0)
percent = 0;
*prev_outpercent = percent; *prev_outpercent = percent;
} }
} }

View File

@ -15,7 +15,7 @@
# include <net/if.h> # include <net/if.h>
# include <net/if_types.h> # include <net/if_types.h>
# include <ifaddrs.h> # include <ifaddrs.h>
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
@ -47,17 +47,17 @@ _freebsd_generic_network_status(unsigned long int *in, unsigned long int *out)
len = sizeof(count); len = sizeof(count);
if (sysctlbyname("net.link.generic.system.ifcount", &count, &len, NULL, 0) < 0) if (sysctlbyname("net.link.generic.system.ifcount", &count, &len, NULL, 0) < 0)
return; return;
ifmd = malloc(sizeof(struct ifmibdata)); ifmd = malloc(sizeof(struct ifmibdata));
if (!ifmd) if (!ifmd)
return; return;
for (i = 1; i <= count; i++) for (i = 1; i <= count; i++)
{ {
get_ifmib_general(i, ifmd); get_ifmib_general(i, ifmd);
*in += ifmd->ifmd_data.ifi_ibytes; *in += ifmd->ifmd_data.ifi_ibytes;
*out += ifmd->ifmd_data.ifi_obytes; *out += ifmd->ifmd_data.ifi_obytes;
} }
free(ifmd); free(ifmd);
} }
@ -69,26 +69,26 @@ static void
_openbsd_generic_network_status(unsigned long int *in, unsigned long int *out) _openbsd_generic_network_status(unsigned long int *in, unsigned long int *out)
{ {
struct ifaddrs *interfaces, *ifa; struct ifaddrs *interfaces, *ifa;
if (getifaddrs(&interfaces) < 0) if (getifaddrs(&interfaces) < 0)
return; return;
int sock = socket(AF_INET, SOCK_STREAM, 0); int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) if (sock < 0)
return; return;
for (ifa = interfaces; ifa; ifa = ifa->ifa_next) for (ifa = interfaces; ifa; ifa = ifa->ifa_next)
{ {
struct ifreq ifreq; struct ifreq ifreq;
struct if_data if_data; struct if_data if_data;
ifreq.ifr_data = (void *)&if_data; ifreq.ifr_data = (void *)&if_data;
strncpy(ifreq.ifr_name, ifa->ifa_name, IFNAMSIZ-1); strncpy(ifreq.ifr_name, ifa->ifa_name, IFNAMSIZ - 1);
if (ioctl(sock, SIOCGIFDATA, &ifreq) < 0) if (ioctl(sock, SIOCGIFDATA, &ifreq) < 0)
return; return;
struct if_data * const ifi = &if_data; struct if_data *const ifi = &if_data;
if (ifi->ifi_type == IFT_ETHER || ifi->ifi_type == IFT_IEEE80211) if (ifi->ifi_type == IFT_ETHER || ifi->ifi_type == IFT_IEEE80211)
{ {
if (ifi->ifi_ibytes) if (ifi->ifi_ibytes)
*in += ifi->ifi_ibytes; *in += ifi->ifi_ibytes;
@ -99,18 +99,19 @@ _openbsd_generic_network_status(unsigned long int *in, unsigned long int *out)
*out += ifi->ifi_obytes; *out += ifi->ifi_obytes;
else else
*out += 0; *out += 0;
} }
} }
close(sock); close(sock);
} }
#endif #endif
void void
_netstatus_sysctl_getrstatus(Eina_Bool automax, _netstatus_sysctl_getrstatus(Eina_Bool automax,
unsigned long *prev_in, unsigned long *prev_in,
unsigned long *prev_incurrent, unsigned long *prev_incurrent,
unsigned long *prev_inmax, unsigned long *prev_inmax,
int *prev_inpercent) int *prev_inpercent)
{ {
unsigned long tot_in = 0, diffin; unsigned long tot_in = 0, diffin;
int percent = 0; int percent = 0;
@ -137,17 +138,18 @@ _netstatus_sysctl_getrstatus(Eina_Bool automax,
if (*prev_inmax > 0) if (*prev_inmax > 0)
percent = 100 * ((float)*prev_incurrent / (float)*prev_inmax); percent = 100 * ((float)*prev_incurrent / (float)*prev_inmax);
if (percent > 100) percent = 100; if (percent > 100) percent = 100;
else if (percent < 0) percent = 0; else if (percent < 0)
percent = 0;
*prev_inpercent = percent; *prev_inpercent = percent;
} }
} }
void void
_netstatus_sysctl_gettstatus(Eina_Bool automax, _netstatus_sysctl_gettstatus(Eina_Bool automax,
unsigned long *prev_out, unsigned long *prev_out,
unsigned long *prev_outcurrent, unsigned long *prev_outcurrent,
unsigned long *prev_outmax, unsigned long *prev_outmax,
int *prev_outpercent) int *prev_outpercent)
{ {
unsigned long tot_out = 0, diffout; unsigned long tot_out = 0, diffout;
int percent = 0; int percent = 0;
@ -174,7 +176,8 @@ _netstatus_sysctl_gettstatus(Eina_Bool automax,
if (*prev_outcurrent > 0) if (*prev_outcurrent > 0)
percent = 100 * ((float)*prev_outcurrent / (float)*prev_outmax); percent = 100 * ((float)*prev_outcurrent / (float)*prev_outmax);
if (percent > 100) percent = 100; if (percent > 100) percent = 100;
else if (percent < 0) percent = 0; else if (percent < 0)
percent = 0;
*prev_outpercent = percent; *prev_outpercent = percent;
} }
} }

View File

@ -83,7 +83,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;

View File

@ -11,7 +11,8 @@ _thermal_thread_free(Tempthread *tth)
eina_stringshare_del(tth->sensor_name); eina_stringshare_del(tth->sensor_name);
eina_stringshare_del(tth->sensor_path); eina_stringshare_del(tth->sensor_path);
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
EINA_LIST_FREE(tth->tempdevs, s) eina_stringshare_del(s); EINA_LIST_FREE(tth->tempdevs, s)
eina_stringshare_del(s);
#endif #endif
e_powersave_sleeper_free(tth->sleeper); e_powersave_sleeper_free(tth->sleeper);
E_FREE(tth->extn); E_FREE(tth->extn);
@ -24,7 +25,8 @@ _thermal_face_level_set(Instance *inst, double level)
Edje_Message_Float msg; Edje_Message_Float msg;
if (level < 0.0) level = 0.0; if (level < 0.0) level = 0.0;
else if (level > 1.0) level = 1.0; else if (level > 1.0)
level = 1.0;
msg.val = level; msg.val = level;
edje_object_message_send(elm_layout_edje_get(inst->cfg->thermal.o_gadget), EDJE_MESSAGE_FLOAT, 1, &msg); edje_object_message_send(elm_layout_edje_get(inst->cfg->thermal.o_gadget), EDJE_MESSAGE_FLOAT, 1, &msg);
} }
@ -32,7 +34,6 @@ _thermal_face_level_set(Instance *inst, double level)
static void static void
_thermal_apply(Instance *inst, int temp) _thermal_apply(Instance *inst, int temp)
{ {
if (inst->cfg->thermal.temp == temp) return; if (inst->cfg->thermal.temp == temp) return;
inst->cfg->thermal.temp = temp; inst->cfg->thermal.temp = temp;
if (temp != -999) if (temp != -999)
@ -47,8 +48,8 @@ _thermal_apply(Instance *inst, int temp)
} }
_thermal_face_level_set(inst, _thermal_face_level_set(inst,
(double)(temp - inst->cfg->thermal.low) / (double)(temp - inst->cfg->thermal.low) /
(double)(inst->cfg->thermal.high - inst->cfg->thermal.low)); (double)(inst->cfg->thermal.high - inst->cfg->thermal.low));
} }
else else
{ {
@ -69,7 +70,7 @@ _thermal_apply(Instance *inst, int temp)
else else
snprintf(buf, 100, "%s: %d C", _("Temperature"), inst->cfg->thermal.temp); snprintf(buf, 100, "%s: %d C", _("Temperature"), inst->cfg->thermal.temp);
elm_object_text_set(inst->cfg->thermal.popup_label, buf); elm_object_text_set(inst->cfg->thermal.popup_label, buf);
} }
} }
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
@ -82,6 +83,7 @@ _thermal_udev_poll(void *data)
_thermal_apply(tth->inst, temp); _thermal_apply(tth->inst, temp);
return EINA_TRUE; return EINA_TRUE;
} }
#endif #endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
@ -91,16 +93,17 @@ _thermal_check_sysctl(void *data, Ecore_Thread *th)
Tempthread *tth = data; Tempthread *tth = data;
int ptemp = -500, temp; int ptemp = -500, temp;
for (;;) for (;; )
{ {
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
temp = thermal_sysctl_get(tth); temp = thermal_sysctl_get(tth);
if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp)); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp));
ptemp = temp; ptemp = temp;
e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval); e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
#endif #endif
#if !defined(HAVE_EEZE) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) #if !defined(HAVE_EEZE) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
@ -109,16 +112,17 @@ _thermal_check_fallback(void *data, Ecore_Thread *th)
{ {
Tempthread *tth = data; Tempthread *tth = data;
int ptemp = -500, temp; int ptemp = -500, temp;
for (;;) for (;; )
{ {
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
temp = thermal_fallback_get(tth); temp = thermal_fallback_get(tth);
if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp)); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp));
ptemp = temp; ptemp = temp;
e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval); e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
#endif #endif
#if !defined(HAVE_EEZE) #if !defined(HAVE_EEZE)
@ -136,8 +140,8 @@ _thermal_check_done(void *data, Ecore_Thread *th EINA_UNUSED)
{ {
Tempthread *tth = data; Tempthread *tth = data;
_thermal_thread_free(tth); _thermal_thread_free(tth);
} }
#endif #endif
static Evas_Object * static Evas_Object *
@ -230,6 +234,7 @@ _thermal_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
e_gadget_configure(inst->o_main); e_gadget_configure(inst->o_main);
} }
} }
static Eina_Bool static Eina_Bool
_screensaver_on(void *data) _screensaver_on(void *data)
{ {
@ -253,7 +258,6 @@ _screensaver_off(void *data)
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
void void
_thermal_config_updated(Instance *inst) _thermal_config_updated(Instance *inst)
{ {
@ -277,20 +281,20 @@ _thermal_config_updated(Instance *inst)
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
_thermal_udev_poll(tth); _thermal_udev_poll(tth);
inst->cfg->thermal.poller = ecore_poller_add(ECORE_POLLER_CORE, inst->cfg->thermal.poll_interval, inst->cfg->thermal.poller = ecore_poller_add(ECORE_POLLER_CORE, inst->cfg->thermal.poll_interval,
_thermal_udev_poll, tth); _thermal_udev_poll, tth);
inst->cfg->thermal.tth = tth; inst->cfg->thermal.tth = tth;
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
inst->cfg->thermal.th = ecore_thread_feedback_run(_thermal_check_sysctl, inst->cfg->thermal.th = ecore_thread_feedback_run(_thermal_check_sysctl,
_thermal_check_notify, _thermal_check_notify,
_thermal_check_done, _thermal_check_done,
_thermal_check_done, _thermal_check_done,
tth, EINA_TRUE); tth, EINA_TRUE);
#else #else
inst->cfg->thermal.th = ecore_thread_feedback_run(_thermal_check_fallback, inst->cfg->thermal.th = ecore_thread_feedback_run(_thermal_check_fallback,
_thermal_check_notify, _thermal_check_notify,
_thermal_check_done, _thermal_check_done,
_thermal_check_done, _thermal_check_done,
tth, EINA_TRUE); tth, EINA_TRUE);
#endif #endif
} }
@ -367,12 +371,12 @@ sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
if (inst->cfg->thermal.configure) if (inst->cfg->thermal.configure)
E_FREE_FUNC(inst->cfg->thermal.configure, evas_object_del); E_FREE_FUNC(inst->cfg->thermal.configure, evas_object_del);
EINA_LIST_FREE(inst->cfg->thermal.handlers, handler) EINA_LIST_FREE(inst->cfg->thermal.handlers, handler)
ecore_event_handler_del(handler); ecore_event_handler_del(handler);
if (inst->cfg->thermal.th) if (inst->cfg->thermal.th)
{ {
ecore_thread_cancel(inst->cfg->thermal.th); ecore_thread_cancel(inst->cfg->thermal.th);
inst->cfg->thermal.th = NULL; inst->cfg->thermal.th = NULL;
} }
_thermal_face_shutdown(inst); _thermal_face_shutdown(inst);
} }
@ -390,11 +394,11 @@ _thermal_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
inst->cfg->thermal.o_gadget = elm_layout_add(inst->o_main); inst->cfg->thermal.o_gadget = elm_layout_add(inst->o_main);
if (orient == E_GADGET_SITE_ORIENT_VERTICAL) if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_theme_edje_object_set(inst->cfg->thermal.o_gadget, e_theme_edje_object_set(inst->cfg->thermal.o_gadget,
"base/theme/gadget/thermal", "base/theme/gadget/thermal",
"e/gadget/thermal/main_vert"); "e/gadget/thermal/main_vert");
else else
e_theme_edje_object_set(inst->cfg->thermal.o_gadget, "base/theme/gadget/thermal", e_theme_edje_object_set(inst->cfg->thermal.o_gadget, "base/theme/gadget/thermal",
"e/gadget/thermal/main"); "e/gadget/thermal/main");
E_EXPAND(inst->cfg->thermal.o_gadget); E_EXPAND(inst->cfg->thermal.o_gadget);
E_FILL(inst->cfg->thermal.o_gadget); E_FILL(inst->cfg->thermal.o_gadget);
elm_box_pack_end(inst->o_main, inst->cfg->thermal.o_gadget); elm_box_pack_end(inst->o_main, inst->cfg->thermal.o_gadget);
@ -451,7 +455,7 @@ _conf_item_get(int *id)
ci = E_NEW(Config_Item, 1); ci = E_NEW(Config_Item, 1);
if (*id != -1) if (*id != -1)
ci->id = eina_list_count(sysinfo_config->items)+1; ci->id = eina_list_count(sysinfo_config->items) + 1;
else else
ci->id = -1; ci->id = -1;

View File

@ -36,7 +36,6 @@ _update_low_temperature(void *data, Evas_Object *obj EINA_UNUSED, void *event_in
inst->cfg->thermal.low = value; inst->cfg->thermal.low = value;
e_config_save_queue(); e_config_save_queue();
_thermal_config_updated(inst); _thermal_config_updated(inst);
} }
static void static void
@ -48,14 +47,16 @@ _units_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
switch (value) switch (value)
{ {
case 0: case 0:
inst->cfg->thermal.units = CELSIUS; inst->cfg->thermal.units = CELSIUS;
break; break;
case 1:
inst->cfg->thermal.units = FAHRENHEIT; case 1:
break; inst->cfg->thermal.units = FAHRENHEIT;
default: break;
inst->cfg->thermal.units = CELSIUS;
default:
inst->cfg->thermal.units = CELSIUS;
} }
if (inst->cfg->thermal.units == FAHRENHEIT) if (inst->cfg->thermal.units == FAHRENHEIT)
{ {
@ -67,7 +68,7 @@ _units_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
elm_slider_value_set(tc->high, ceil(CEL_2_FAR(val))); elm_slider_value_set(tc->high, ceil(CEL_2_FAR(val)));
elm_slider_unit_format_set(tc->high, "%1.0f F"); elm_slider_unit_format_set(tc->high, "%1.0f F");
elm_slider_indicator_format_set(tc->high, "%1.0f F"); elm_slider_indicator_format_set(tc->high, "%1.0f F");
elm_slider_unit_format_set(tc->low, "%1.0f F"); elm_slider_unit_format_set(tc->low, "%1.0f F");
elm_slider_indicator_format_set(tc->low, "%1.0f F"); elm_slider_indicator_format_set(tc->low, "%1.0f F");
} }
else else
@ -78,7 +79,7 @@ _units_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
elm_slider_value_set(tc->high, ceil(FAR_2_CEL(val))); elm_slider_value_set(tc->high, ceil(FAR_2_CEL(val)));
elm_slider_unit_format_set(tc->low, "%1.0f C"); elm_slider_unit_format_set(tc->low, "%1.0f C");
elm_slider_indicator_format_set(tc->low, "%1.0f C"); elm_slider_indicator_format_set(tc->low, "%1.0f C");
elm_slider_unit_format_set(tc->high, "%1.0f C"); elm_slider_unit_format_set(tc->high, "%1.0f C");
elm_slider_indicator_format_set(tc->high, "%1.0f C"); elm_slider_indicator_format_set(tc->high, "%1.0f C");
elm_slider_min_max_set(tc->low, 0, 95); elm_slider_min_max_set(tc->low, 0, 95);
elm_slider_min_max_set(tc->high, 0, 110); elm_slider_min_max_set(tc->high, 0, 110);
@ -100,23 +101,28 @@ _poll_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
switch (value) switch (value)
{ {
case 0: case 0:
inst->cfg->thermal.poll_interval = 4; inst->cfg->thermal.poll_interval = 4;
break; break;
case 1:
inst->cfg->thermal.poll_interval = 8; case 1:
break; inst->cfg->thermal.poll_interval = 8;
case 2: break;
inst->cfg->thermal.poll_interval = 32;
break; case 2:
case 3: inst->cfg->thermal.poll_interval = 32;
inst->cfg->thermal.poll_interval = 64; break;
break;
case 4: case 3:
inst->cfg->thermal.poll_interval = 256; inst->cfg->thermal.poll_interval = 64;
break; break;
default:
inst->cfg->thermal.poll_interval = 32; case 4:
inst->cfg->thermal.poll_interval = 256;
break;
default:
inst->cfg->thermal.poll_interval = 32;
} }
e_config_save_queue(); e_config_save_queue();
@ -182,16 +188,18 @@ thermal_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _units_changed, tc); evas_object_smart_callback_add(o, "changed", _units_changed, tc);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->thermal.units) switch (inst->cfg->thermal.units)
{ {
case CELSIUS: case CELSIUS:
elm_radio_value_set(groupu, 0); elm_radio_value_set(groupu, 0);
break; break;
case FAHRENHEIT:
elm_radio_value_set(groupu, 1); case FAHRENHEIT:
break; elm_radio_value_set(groupu, 1);
default: break;
elm_radio_value_set(groupu, 0);
default:
elm_radio_value_set(groupu, 0);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);
@ -258,25 +266,30 @@ thermal_configure(Instance *inst)
evas_object_smart_callback_add(o, "changed", _poll_changed, tc); evas_object_smart_callback_add(o, "changed", _poll_changed, tc);
evas_object_show(o); evas_object_show(o);
switch(inst->cfg->thermal.poll_interval) switch (inst->cfg->thermal.poll_interval)
{ {
case 4: case 4:
elm_radio_value_set(group, 0); elm_radio_value_set(group, 0);
break; break;
case 8:
elm_radio_value_set(group, 1); case 8:
break; elm_radio_value_set(group, 1);
case 32: break;
elm_radio_value_set(group, 2);
break; case 32:
case 64: elm_radio_value_set(group, 2);
elm_radio_value_set(group, 3); break;
break;
case 256: case 64:
elm_radio_value_set(group, 4); elm_radio_value_set(group, 3);
break; break;
default:
elm_radio_value_set(group, 2); case 256:
elm_radio_value_set(group, 4);
break;
default:
elm_radio_value_set(group, 2);
} }
elm_object_content_set(frame, box); elm_object_content_set(frame, box);

View File

@ -193,6 +193,7 @@ init(Tempthread *tth)
{ {
case SENSOR_TYPE_NONE: case SENSOR_TYPE_NONE:
break; break;
case SENSOR_TYPE_OMNIBOOK: case SENSOR_TYPE_OMNIBOOK:
tth->sensor_path = eina_stringshare_add("/proc/omnibook/temperature"); tth->sensor_path = eina_stringshare_add("/proc/omnibook/temperature");
break; break;

View File

@ -17,22 +17,22 @@
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
typedef struct typedef struct
{ {
int mib[CTL_MAXNAME]; int mib[CTL_MAXNAME];
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
unsigned int miblen; unsigned int miblen;
#endif #endif
int dummy; int dummy;
} Extn; } Extn;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static const char *sources[] = static const char *sources[] =
{ {
"hw.acpi.thermal.tz0.temperature", "hw.acpi.thermal.tz0.temperature",
"dev.cpu.0.temperature", "dev.cpu.0.temperature",
"dev.aibs.0.temp.0", "dev.aibs.0.temp.0",
"dev.lm75.0.temperature", "dev.lm75.0.temperature",
NULL NULL
}; };
#endif #endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
@ -187,7 +187,7 @@ check(Tempthread *tth)
goto error; goto error;
#endif #endif
} }
if (ret) return temp; if (ret) return temp;
return -999; return -999;
error: error:
@ -208,4 +208,5 @@ thermal_sysctl_get(Tempthread *tth)
temp = check(tth); temp = check(tth);
return temp; return temp;
} }
#endif #endif

View File

@ -48,3 +48,4 @@ thermal_udev_get(Tempthread *tth)
} }
return -999; return -999;
} }

View File

@ -26,3 +26,4 @@ e_modapi_gadget_save(E_Module *m EINA_UNUSED)
{ {
return 1; return 1;
} }

View File

@ -2,11 +2,11 @@
typedef struct _Instance typedef struct _Instance
{ {
Evas_Object *o_main; Evas_Object *o_main;
Evas_Object *o_xkbswitch; Evas_Object *o_xkbswitch;
Evas_Object *o_xkbflag; Evas_Object *o_xkbflag;
Evas_Object *menu; Evas_Object *menu;
Evas_Object *popup; Evas_Object *popup;
E_Gadget_Site_Orient orient; E_Gadget_Site_Orient orient;
E_Config_XKB_Layout *layout; E_Config_XKB_Layout *layout;
} Instance; } Instance;
@ -202,8 +202,8 @@ _xkbg_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
Instance *inst = data; Instance *inst = data;
/* This does not work properly yet /* This does not work properly yet
edje_object_parts_extends_calc(elm_layout_edje_get(inst->o_xkbswitch), 0, 0, &w, &h); edje_object_parts_extends_calc(elm_layout_edje_get(inst->o_xkbswitch), 0, 0, &w, &h);
evas_object_size_hint_aspect_set(inst->o_xkbswitch, EVAS_ASPECT_CONTROL_BOTH, w, h);*/ evas_object_size_hint_aspect_set(inst->o_xkbswitch, EVAS_ASPECT_CONTROL_BOTH, w, h);*/
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1, 1); evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
} }
@ -225,26 +225,26 @@ _xkbg_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUS
{ {
if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL) if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_theme_edje_object_set(inst->o_xkbswitch, e_theme_edje_object_set(inst->o_xkbswitch,
"base/theme/gadget/xkbswitch", "base/theme/gadget/xkbswitch",
"e/gadget/xkbswitch/noflag_vert"); "e/gadget/xkbswitch/noflag_vert");
else else
e_theme_edje_object_set(inst->o_xkbswitch, e_theme_edje_object_set(inst->o_xkbswitch,
"base/theme/gadget/xkbswitch", "base/theme/gadget/xkbswitch",
"e/gadget/xkbswitch/noflag"); "e/gadget/xkbswitch/noflag");
} }
else else
{ {
if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL) if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_theme_edje_object_set(inst->o_xkbswitch, e_theme_edje_object_set(inst->o_xkbswitch,
"base/theme/gadget/xkbswitch", "base/theme/gadget/xkbswitch",
"e/gadget/xkbswitch/main_vert"); "e/gadget/xkbswitch/main_vert");
else else
e_theme_edje_object_set(inst->o_xkbswitch, e_theme_edje_object_set(inst->o_xkbswitch,
"base/theme/gadget/xkbswitch", "base/theme/gadget/xkbswitch",
"e/gadget/xkbswitch/main"); "e/gadget/xkbswitch/main");
} }
elm_layout_text_set(inst->o_xkbswitch, "e.text.label", elm_layout_text_set(inst->o_xkbswitch, "e.text.label",
inst->layout ? e_xkb_layout_name_reduce(inst->layout->name) : _("NONE")); inst->layout ? e_xkb_layout_name_reduce(inst->layout->name) : _("NONE"));
if (inst->layout && (!e_config->xkb.only_label)) if (inst->layout && (!e_config->xkb.only_label))
{ {
inst->o_xkbflag = e_icon_add(evas_object_evas_get(inst->o_xkbswitch)); inst->o_xkbflag = e_icon_add(evas_object_evas_get(inst->o_xkbswitch));
@ -256,7 +256,7 @@ _xkbg_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUS
evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_MOUSE_DOWN, evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_MOUSE_DOWN,
_xkbg_cb_mouse_down, inst); _xkbg_cb_mouse_down, inst);
evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_RESIZE, evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_RESIZE,
_xkbg_resize_cb, inst); _xkbg_resize_cb, inst);
elm_box_pack_end(inst->o_main, inst->o_xkbswitch); elm_box_pack_end(inst->o_main, inst->o_xkbswitch);
evas_object_show(inst->o_xkbswitch); evas_object_show(inst->o_xkbswitch);
} }