fix sys battery reader to support lowercase bats too...

some other bugs and fixes


SVN revision: 33849
This commit is contained in:
Carsten Haitzler 2008-02-26 09:47:51 +00:00
parent 2227cdbd91
commit 497281afaa
5 changed files with 61 additions and 33 deletions

View File

@ -618,10 +618,12 @@ _e_drag_win_show(E_Drop_Handler *h)
switch (h->obj->type) switch (h->obj->type)
{ {
case E_GADCON_TYPE: case E_GADCON_TYPE:
e_shelf_toggle(e_gadcon_shelf_get((E_Gadcon *)(h->obj)), 1); /* FIXME: this is wrong - it ASSUMES the holder is a shelf */
// e_shelf_toggle(e_gadcon_shelf_get((E_Gadcon *)(h->obj)), 1);
break; break;
case E_GADCON_CLIENT_TYPE: case E_GADCON_CLIENT_TYPE:
e_shelf_toggle(e_gadcon_shelf_get(((E_Gadcon_Client *)(h->obj))->gadcon), 1); /* FIXME: this is wrong - it ASSUMES the holder is a shelf */
// e_shelf_toggle(e_gadcon_shelf_get(((E_Gadcon_Client *)(h->obj))->gadcon), 1);
break; break;
/* FIXME: add more types as needed */ /* FIXME: add more types as needed */
default: default:

View File

@ -30,10 +30,12 @@ struct _E_Smart_Data
} history[20]; } history[20];
double anim_start; double anim_start;
Ecore_Animator *momentum_animator; Ecore_Animator *momentum_animator;
Evas_Coord locked_x, locked_y;
unsigned char now : 1; unsigned char now : 1;
unsigned char dragged : 1; unsigned char dragged : 1;
unsigned char dir_x : 1; unsigned char dir_x : 1;
unsigned char dir_y : 1; unsigned char dir_y : 1;
unsigned char locked : 1;
} down; } down;
struct { struct {
@ -63,6 +65,7 @@ static void _e_smart_pan_changed_hook(void *data, Evas_Object *obj, void *event_
static void _e_smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info); static void _e_smart_pan_pan_changed_hook(void *data, Evas_Object *obj, void *event_info);
static void _e_smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static int _e_smart_momentum_animator(void *data);
static void _e_smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_smart_event_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_smart_event_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
@ -435,6 +438,7 @@ _e_smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
} }
if (ev->button == 1) if (ev->button == 1)
{ {
printf("down @ %3.3f\n", ecore_time_get());
sd->down.now = 1; sd->down.now = 1;
sd->down.dragged = 0; sd->down.dragged = 0;
sd->down.dir_x = 0; sd->down.dir_x = 0;
@ -444,6 +448,7 @@ _e_smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
e_scrollframe_child_pos_get(sd->smart_obj, &x, &y); e_scrollframe_child_pos_get(sd->smart_obj, &x, &y);
sd->down.sx = x; sd->down.sx = x;
sd->down.sy = y; sd->down.sy = y;
sd->down.locked = 0;
memset(&(sd->down.history[0]), 0, sizeof(sd->down.history[0]) * 20); memset(&(sd->down.history[0]), 0, sizeof(sd->down.history[0]) * 20);
sd->down.history[0].timestamp = ecore_time_get(); sd->down.history[0].timestamp = ecore_time_get();
sd->down.history[0].x = ev->canvas.x; sd->down.history[0].x = ev->canvas.x;
@ -453,7 +458,7 @@ _e_smart_event_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
} }
static int static int
_e_cb_momentum_animator(void *data) _e_smart_momentum_animator(void *data)
{ {
E_Smart_Data *sd; E_Smart_Data *sd;
double t, dt, p; double t, dt, p;
@ -494,7 +499,7 @@ _e_smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
if (ev->button == 1) if (ev->button == 1)
{ {
printf("up @ %3.3f\n", ecore_time_get());
x = ev->canvas.x - sd->down.x; x = ev->canvas.x - sd->down.x;
y = ev->canvas.y - sd->down.y; y = ev->canvas.y - sd->down.y;
if (sd->down.dragged) if (sd->down.dragged)
@ -529,7 +534,7 @@ _e_smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
(vel > e_config->thumbscroll_momentum_threshhold)) (vel > e_config->thumbscroll_momentum_threshhold))
{ {
if (!sd->down.momentum_animator) if (!sd->down.momentum_animator)
sd->down.momentum_animator = ecore_animator_add(_e_cb_momentum_animator, sd); sd->down.momentum_animator = ecore_animator_add(_e_smart_momentum_animator, sd);
sd->down.dx = ((double)dx / at); sd->down.dx = ((double)dx / at);
sd->down.dy = ((double)dy / at); sd->down.dy = ((double)dy / at);
sd->down.anim_start = t; sd->down.anim_start = t;
@ -565,7 +570,9 @@ _e_smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_inf
sd->down.history[0].y = ev->cur.canvas.y; sd->down.history[0].y = ev->cur.canvas.y;
x = ev->cur.canvas.x - sd->down.x; x = ev->cur.canvas.x - sd->down.x;
if (x < 0) x = -x;
y = ev->cur.canvas.y - sd->down.y; y = ev->cur.canvas.y - sd->down.y;
if (y < 0) y = -y;
if ((sd->one_dir_at_a_time) && if ((sd->one_dir_at_a_time) &&
(!sd->down.dir_x) && (!sd->down.dir_y)) (!sd->down.dir_x) && (!sd->down.dir_y))
{ {
@ -598,8 +605,15 @@ _e_smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_inf
y = sd->down.sy - (ev->cur.canvas.y - sd->down.y); y = sd->down.sy - (ev->cur.canvas.y - sd->down.y);
if ((sd->down.dir_x) || (sd->down.dir_y)) if ((sd->down.dir_x) || (sd->down.dir_y))
{ {
if (sd->down.dir_x) y = sd->down.sy; if (!sd->down.locked)
else x = sd->down.sx; {
printf("lock dir to x%iy%i\n", sd->down.dir_x, sd->down.dir_y);
sd->down.locked_x = x;
sd->down.locked_y = y;
sd->down.locked = 1;
}
if (sd->down.dir_x) y = sd->down.locked_y;
else x = sd->down.locked_x;
} }
e_scrollframe_child_pos_set(sd->smart_obj, x, y); e_scrollframe_child_pos_set(sd->smart_obj, x, y);
} }

View File

@ -196,7 +196,7 @@ _e_smart_reconfigure(E_Smart_Data *sd)
evas_object_clip_set(sd->o2, evas_object_clip_get(sd->smart_obj)); evas_object_clip_set(sd->o2, evas_object_clip_get(sd->smart_obj));
evas_object_show(sd->o2); evas_object_show(sd->o2);
} }
if (a < 128) if (at < 128)
{ {
if (it1->func) it1->func(it1->data); if (it1->func) it1->func(it1->data);
} }
@ -256,7 +256,19 @@ static void
_e_smart_del(Evas_Object *obj) _e_smart_del(Evas_Object *obj)
{ {
INTERNAL_ENTRY; INTERNAL_ENTRY;
while (sd->items)
{
E_Smart_Item *it;
it = sd->items->data;
sd->items = evas_list_remove_list(sd->items, sd->items);
if (it->label) evas_stringshare_del(it->label);
if (it->icon) evas_stringshare_del(it->icon);
free(it);
}
evas_object_del(sd->event_obj); evas_object_del(sd->event_obj);
if (sd->o1) evas_object_del(sd->o1);
if (sd->o2) evas_object_del(sd->o2);
free(sd); free(sd);
} }

View File

@ -183,7 +183,7 @@ _e_smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_inf
d1 = ev->cur.canvas.x - sd->down_x; d1 = ev->cur.canvas.x - sd->down_x;
d2 = ev->cur.canvas.y - sd->down_y; d2 = ev->cur.canvas.y - sd->down_y;
d = (d1 * d1) + (d2 * d2); d = (d1 * d1) + (d2 * d2);
if (d > (16 * 16)) if (d > (64 * 64))
{ {
edje_object_signal_emit(sd->edje_obj, "e,state,slide,hint,off", "e"); edje_object_signal_emit(sd->edje_obj, "e,state,slide,hint,off", "e");
sd->down_cancel = 1; sd->down_cancel = 1;

View File

@ -251,10 +251,10 @@ _battery_cb_check(void *data)
#else #else
if (battery_config->battery_check_mode == 0) if (battery_config->battery_check_mode == 0)
{ {
if (ecore_file_is_dir("/proc/acpi")) /* <= 2.6.24 */ if (ecore_file_is_dir("/sys/class/power_supply")) /* >= 2.6.24 */
battery_config->battery_check_mode = CHECK_ACPI;
else if (ecore_file_is_dir("/sys/class/power_supply")) /* >= 2.6.24 */
battery_config->battery_check_mode = CHECK_SYS_ACPI; battery_config->battery_check_mode = CHECK_SYS_ACPI;
else if (ecore_file_is_dir("/proc/acpi")) /* <= 2.6.24 */
battery_config->battery_check_mode = CHECK_ACPI;
else if (ecore_file_exists("/proc/apm")) else if (ecore_file_exists("/proc/apm"))
battery_config->battery_check_mode = CHECK_APM; battery_config->battery_check_mode = CHECK_APM;
else if (ecore_file_is_dir("/proc/pmu")) else if (ecore_file_is_dir("/proc/pmu"))
@ -418,7 +418,7 @@ _battery_linux_sys_acpi_check(void)
int rate = 1; int rate = 1;
int level = 0; int level = 0;
if (name && strncmp("BAT",name,3)) continue; if (name && strncasecmp("BAT", name, 3)) continue;
/* present */ /* present */
snprintf(buf, sizeof(buf), "/sys/class/power_supply/%s/present", name); snprintf(buf, sizeof(buf), "/sys/class/power_supply/%s/present", name);