forked from enlightenment/enlightenment
battery: fix sysctl battery update and naming.
This commit is contained in:
parent
1e4eb55816
commit
39b7896df5
|
@ -73,6 +73,9 @@ static void _battery_cb_warning_popup_hide(void *data, Evas *e, Evas_Object
|
||||||
static void _battery_warning_popup_destroy(Instance *inst);
|
static void _battery_warning_popup_destroy(Instance *inst);
|
||||||
static void _battery_warning_popup(Instance *inst, int time, double percent);
|
static void _battery_warning_popup(Instance *inst, int time, double percent);
|
||||||
|
|
||||||
|
static void _battery_popup_usage_destroy(Instance *inst);
|
||||||
|
static void _battery_popup_usage_new(Instance *inst);
|
||||||
|
|
||||||
static Eina_Bool _powersave_cb_config_update(void *data, int type, void *event);
|
static Eina_Bool _powersave_cb_config_update(void *data, int type, void *event);
|
||||||
|
|
||||||
static E_Config_DD *conf_edd = NULL;
|
static E_Config_DD *conf_edd = NULL;
|
||||||
|
@ -131,6 +134,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
e_object_del(E_OBJECT(inst->warning));
|
e_object_del(E_OBJECT(inst->warning));
|
||||||
inst->popup_battery = NULL;
|
inst->popup_battery = NULL;
|
||||||
}
|
}
|
||||||
|
_battery_popup_usage_destroy(inst);
|
||||||
E_FREE(inst);
|
E_FREE(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +187,7 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_popup_usage_del(Instance *inst)
|
_battery_popup_usage_destroy(Instance *inst)
|
||||||
{
|
{
|
||||||
if (inst->popup_timer) ecore_timer_del(inst->popup_timer);
|
if (inst->popup_timer) ecore_timer_del(inst->popup_timer);
|
||||||
E_FREE_FUNC(inst->popup, e_object_del);
|
E_FREE_FUNC(inst->popup, e_object_del);
|
||||||
|
@ -193,13 +197,13 @@ _popup_usage_del(Instance *inst)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_popup_usage_del_cb(void *obj)
|
_battery_popup_usage_destroy_cb(void *obj)
|
||||||
{
|
{
|
||||||
_popup_usage_del(e_object_data_get(obj));
|
_battery_popup_usage_destroy(e_object_data_get(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_popup_usage_content_update_cb(void *data)
|
_battery_popup_usage_content_update_cb(void *data)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst;
|
||||||
_Popup_Data *pd;
|
_Popup_Data *pd;
|
||||||
|
@ -214,7 +218,7 @@ _popup_usage_content_update_cb(void *data)
|
||||||
|
|
||||||
if (!battery_config->have_battery)
|
if (!battery_config->have_battery)
|
||||||
{
|
{
|
||||||
_popup_usage_del(inst);
|
_battery_popup_usage_destroy(inst);
|
||||||
return ECORE_CALLBACK_CANCEL;
|
return ECORE_CALLBACK_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +256,7 @@ _popup_usage_content_update_cb(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_popup_usage_content_add(Evas_Object *parent, Instance *inst)
|
_battery_popup_usage_content_add(Evas_Object *parent, Instance *inst)
|
||||||
{
|
{
|
||||||
Evas_Object *tb, *tb2, *fr, *lb, *pb, *sep, *rec;
|
Evas_Object *tb, *tb2, *fr, *lb, *pb, *sep, *rec;
|
||||||
_Popup_Data *pd;
|
_Popup_Data *pd;
|
||||||
|
@ -333,22 +337,22 @@ _popup_usage_content_add(Evas_Object *parent, Instance *inst)
|
||||||
elm_table_pack(tb2, sep, 0, 3, 2, 1);
|
elm_table_pack(tb2, sep, 0, 3, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_popup_usage_content_update_cb(pd);
|
_battery_popup_usage_content_update_cb(pd);
|
||||||
|
|
||||||
if (battery_config->have_battery)
|
if (battery_config->have_battery)
|
||||||
inst->popup_timer = ecore_timer_add(10.0, _popup_usage_content_update_cb, pd);
|
inst->popup_timer = ecore_timer_add(10.0, _battery_popup_usage_content_update_cb, pd);
|
||||||
|
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_popup_usage_new(Instance *inst)
|
_battery_popup_usage_new(Instance *inst)
|
||||||
{
|
{
|
||||||
inst->popup = e_gadcon_popup_new(inst->gcc, 0);
|
inst->popup = e_gadcon_popup_new(inst->gcc, 0);
|
||||||
e_gadcon_popup_content_set(inst->popup, _popup_usage_content_add(e_comp->elm, inst));
|
e_gadcon_popup_content_set(inst->popup, _battery_popup_usage_content_add(e_comp->elm, inst));
|
||||||
e_gadcon_popup_show(inst->popup);
|
e_gadcon_popup_show(inst->popup);
|
||||||
e_object_data_set(E_OBJECT(inst->popup),inst);
|
e_object_data_set(E_OBJECT(inst->popup),inst);
|
||||||
E_OBJECT_DEL_SET(inst->popup, _popup_usage_del_cb);
|
E_OBJECT_DEL_SET(inst->popup, _battery_popup_usage_destroy_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -394,9 +398,9 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
_battery_cb_warning_popup_hide(data, e, obj, event_info);
|
_battery_cb_warning_popup_hide(data, e, obj, event_info);
|
||||||
|
|
||||||
if (!inst->popup)
|
if (!inst->popup)
|
||||||
_popup_usage_new(inst);
|
_battery_popup_usage_new(inst);
|
||||||
else
|
else
|
||||||
_popup_usage_del(inst);
|
_battery_popup_usage_destroy(inst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,19 +16,22 @@
|
||||||
# include <sys/sensors.h>
|
# include <sys/sensors.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Eina_Bool _battery_sysctl_battery_update_poll(void *data EINA_UNUSED);
|
static Eina_Bool _battery_sysctl_battery_update_poll(void *data EINA_UNUSED);
|
||||||
static int _battery_sysctl_battery_update();
|
static int _battery_sysctl_battery_update();
|
||||||
|
|
||||||
extern Eina_List *device_batteries;
|
extern Eina_List *device_batteries;
|
||||||
extern Eina_List *device_ac_adapters;
|
extern Eina_List *device_ac_adapters;
|
||||||
extern double init_time;
|
extern double init_time;
|
||||||
|
|
||||||
static Ac_Adapter *ac = NULL;
|
static Ac_Adapter *ac = NULL;
|
||||||
static Battery *bat = NULL;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_battery_sysctl_start(void)
|
_battery_sysctl_start(void)
|
||||||
{
|
{
|
||||||
|
Battery *bat;
|
||||||
|
|
||||||
|
if (device_batteries) return 1;
|
||||||
|
|
||||||
# if defined(__OpenBSD__)
|
# if defined(__OpenBSD__)
|
||||||
int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0};
|
int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0};
|
||||||
int devn;
|
int devn;
|
||||||
|
@ -134,6 +137,8 @@ _battery_sysctl_start(void)
|
||||||
void
|
void
|
||||||
_battery_sysctl_stop(void)
|
_battery_sysctl_stop(void)
|
||||||
{
|
{
|
||||||
|
Battery *bat;
|
||||||
|
|
||||||
if (ac)
|
if (ac)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(ac->udi);
|
eina_stringshare_del(ac->udi);
|
||||||
|
@ -143,7 +148,7 @@ _battery_sysctl_stop(void)
|
||||||
E_FREE(ac);
|
E_FREE(ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bat)
|
EINA_LIST_FREE(device_batteries, bat)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(bat->udi);
|
eina_stringshare_del(bat->udi);
|
||||||
eina_stringshare_del(bat->technology);
|
eina_stringshare_del(bat->technology);
|
||||||
|
@ -160,12 +165,17 @@ _battery_sysctl_stop(void)
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_battery_sysctl_battery_update_poll(void *data EINA_UNUSED)
|
_battery_sysctl_battery_update_poll(void *data EINA_UNUSED)
|
||||||
{
|
{
|
||||||
_battery_sysctl_battery_update();
|
Battery *bat;
|
||||||
|
Eina_List *l;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(device_batteries, l, bat)
|
||||||
|
_battery_sysctl_battery_update(bat);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_battery_sysctl_battery_update()
|
_battery_sysctl_battery_update(Battery *bat)
|
||||||
{
|
{
|
||||||
double _time;
|
double _time;
|
||||||
# if defined(__OpenBSD__)
|
# if defined(__OpenBSD__)
|
||||||
|
|
Loading…
Reference in New Issue