You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1489 lines
44 KiB

#include "e.h"
#define DEFAULT_LAYER E_LAYER_CLIENT_ABOVE
#define E_BRYCE_TYPE 0xE31338
static unsigned int bryce_version = 2;
typedef struct Bryce
{
E_Object *e_obj_inherit;
Eina_Stringshare *name;
Evas_Object *bryce;
Evas_Object *events;
Evas_Object *layout;
Evas_Object *site;
Evas_Object *scroller;
Evas_Object *autohide_event;
Eina_List *zone_obstacles;
Eina_List *spacers;
Evas_Object *parent; //comp_object is not an elm widget
Eina_Stringshare *style;
int size;
int x, y;
int last_w, last_h;
int autohide_size;
E_Layer layer;
unsigned int zone;
E_Gadget_Site_Orient orient;
E_Gadget_Site_Anchor anchor;
Ecore_Job *calc_job;
Ecore_Timer *save_timer;
Ecore_Timer *autohide_timer;
unsigned int autohide_blocked;
Eina_List *popups;
void *event_info;
unsigned int last_timestamp;
E_Menu *menu;
/* config: do not bitfield! */
Eina_Bool autosize;
Eina_Bool autohide;
unsigned int version;
Eina_Bool hidden E_BITFIELD;
Eina_Bool animating E_BITFIELD;
Eina_Bool mouse_in E_BITFIELD;
Eina_Bool noshadow E_BITFIELD;
Eina_Bool size_changed E_BITFIELD;
Eina_Bool editing E_BITFIELD;
} Bryce;
typedef struct Bryces
{
Eina_List *bryces;
} Bryces;
static E_Config_DD *edd_bryces;
static E_Config_DD *edd_bryce;
static Bryces *bryces;
static E_Action *resize_act;
static Eina_List *handlers;
static void _bryce_menu(Bryce *b, Evas_Object *g);
#define BRYCE_GET(obj) \
Bryce *b; \
b = evas_object_data_get((obj), "__bryce"); \
if (!b) abort()
static void
_bryce_obstacle_del(void *obs)
{
Bryce *b = e_object_data_get(obs);
b->zone_obstacles = eina_list_remove(b->zone_obstacles, obs);
}
static void
_bryce_autohide_end(void *data, E_Efx_Map_Data *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
{
Bryce *b = data;
b->animating = 0;
}
static void
_bryce_autohide_coords(Bryce *b, int *x, int *y)
{
int ox, oy, ow, oh;
E_Gadget_Site_Anchor an;
if (b->parent == e_comp->elm)
{
E_Zone *zone;
zone = e_comp_zone_number_get(b->zone);
ox = zone->x, oy = zone->y, ow = zone->w, oh = zone->h;
}
else
evas_object_geometry_get(b->parent, &ox, &oy, &ow, &oh);
an = e_gadget_site_anchor_get(b->site);
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
{
*x = b->x;
if (an & E_GADGET_SITE_ANCHOR_TOP)
*y = oy - lround(e_scale * b->size) + lround(e_scale * b->autohide_size);
if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
*y = oy + oh - lround(e_scale * b->autohide_size);
}
else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
{
*y = b->y;
if (an & E_GADGET_SITE_ANCHOR_LEFT)
*x = ox - lround(e_scale * b->size) + lround(e_scale * b->autohide_size);
if (an & E_GADGET_SITE_ANCHOR_RIGHT)
*x = ox + ow - lround(e_scale * b->autohide_size);
}
}
static void
_bryce_position(Bryce *b, int w, int h, int *nx, int *ny)
{
int ox, oy, ow, oh;
int x, y;
E_Gadget_Site_Anchor an;
if (b->parent == e_comp->elm)
{
E_Zone *zone;
zone = e_comp_zone_number_get(b->zone);
ox = zone->x, oy = zone->y, ow = zone->w, oh = zone->h;
if (starting)
{
E_Zone *zone2;
zone2 = e_comp_object_util_zone_get(b->bryce);
if (zone != zone2)
evas_object_move(b->bryce, ox, oy);
}
}
else
evas_object_geometry_get(b->parent, &ox, &oy, &ow, &oh);
x = ox + (ow - w) / 2;
x = E_CLAMP(x, ox, ox + ow / 2);
y = oy + (oh - h) / 2;
y = E_CLAMP(y, oy, oy + oh / 2);
an = e_gadget_site_anchor_get(b->site);
if (an & E_GADGET_SITE_ANCHOR_LEFT)
x = ox;
if (an & E_GADGET_SITE_ANCHOR_TOP)
y = oy;
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
{
if (an & E_GADGET_SITE_ANCHOR_RIGHT)
x = ox + ow - w;
if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
y = oy + oh - lround(e_scale * b->size);
if (!b->autosize)
x = ox;
}
else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
{
if (an & E_GADGET_SITE_ANCHOR_RIGHT)
x = ox + ow - lround(e_scale * b->size);
if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
y = oy + oh - h;
if (!b->autosize)
y = oy;
}
b->x = x, b->y = y;
if (b->animating)
{
if (b->hidden)
{
_bryce_autohide_coords(b, &x, &y);
e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), 0.5, _bryce_autohide_end, b);
}
else
e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), 0.5, _bryce_autohide_end, b);
}
else if (b->hidden)
_bryce_autohide_coords(b, &x, &y);
if (nx && ny)
*nx = x, *ny = y;
else
evas_object_move(b->bryce, x, y);
}
static void
_bryce_autosize(Bryce *b)
{
int lw, lh, sw, sh, maxw, maxh, x, y, w, h;
E_FREE_FUNC(b->calc_job, ecore_job_del);
if (!b->autosize)
{
if (b->parent == e_comp->elm)
{
w = e_comp_zone_number_get(b->zone)->w;
if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_zone_useful_geometry_get(e_comp_zone_number_get(b->zone), NULL, NULL, NULL, &h);
else
h = e_comp_zone_number_get(b->zone)->h;
}
else
evas_object_geometry_get(b->parent, NULL, NULL, &w, &h);
if (b->size_changed)
elm_object_content_unset(b->scroller);
_bryce_position(b, w, h, &x, &y);
evas_object_move(b->bryce, x, y);
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
e_efx_resize(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), w, lround(b->size * e_scale), 0.1, NULL, NULL);
else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_efx_resize(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), lround(b->size * e_scale), h, 0.1, NULL, NULL);
evas_object_smart_need_recalculate_set(b->site, 1);
evas_object_size_hint_min_set(b->site, -1, -1);
if (b->size_changed)
elm_object_content_set(b->scroller, b->site);
b->size_changed = 0;
return;
}
if (b->parent == e_comp->elm) //screen-based bryce
{
E_Zone *zone;
zone = e_comp_zone_number_get(b->zone);
if (zone)
{
maxw = zone->w;
if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
e_zone_useful_geometry_get(e_comp_zone_number_get(b->zone), NULL, NULL, NULL, &maxh);
else
maxh = zone->h;
}
else return;
}
else
evas_object_geometry_get(b->parent, NULL, NULL, &maxw, &maxh);
do
{
if (b->size_changed)
{
evas_object_geometry_get(b->bryce, NULL, NULL, &w, &h);
elm_object_content_unset(b->scroller);
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
{
if (!h) h = 1;
evas_object_resize(b->bryce, w * lround(b->size * e_scale) / h, lround(b->size * e_scale));
evas_object_resize(b->site, w * lround(b->size * e_scale) / h, lround(b->size * e_scale));
}
else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
{
if (!w) w = 1;
evas_object_resize(b->bryce, lround(b->size * e_scale), h * lround(b->size * e_scale) / w);
evas_object_resize(b->site, lround(b->size * e_scale), h * lround(b->size * e_scale) / w);
}
evas_object_smart_need_recalculate_set(b->site, 1);
evas_object_size_hint_min_set(b->site, -1, -1);
evas_object_smart_calculate(b->site);
elm_object_content_set(b->scroller, b->site);
}
evas_object_size_hint_min_get(b->site, &sw, &sh);
if ((!sw) && (!sh)) b->size_changed = 1;
}
while ((!sw) && (!sh));
edje_object_size_min_calc(elm_layout_edje_get(b->layout), &lw, &lh);
_bryce_position(b, lw + sw, lh + sh, &x, &y);
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
w = MIN(MAX(lw + sw, lround(b->size * e_scale)), maxw), h = lround(b->size * e_scale);
else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
w = lround(b->size * e_scale), h = MIN(MAX(lh + sh, lround(b->size * e_scale)), maxh);
evas_object_move(b->bryce, x, y);
e_efx_resize(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), w, h, 0.1, NULL, NULL);
b->size_changed = 0;
}
static Eina_Bool
_bryce_autohide_timeout(Bryce *b)
{
int x = 0, y = 0;
b->autohide_timer = NULL;
b->hidden = b->animating = 1;
_bryce_autohide_coords(b, &x, &y);
e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), 0.5, _bryce_autohide_end, b);
return EINA_FALSE;
}
static void
_bryce_autohide_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Bryce *b = data;
int x, y, w, h;
evas_object_geometry_get(obj, &x, &y, &w, &h);
evas_object_geometry_set(b->autohide_event, x, y, w, h);
}
static void
_bryce_autohide_show(Bryce *b)
{
E_FREE_FUNC(b->autohide_timer, ecore_timer_del);
if (b->animating && (!b->hidden)) return;
e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(b->x, b->y), 0.5, _bryce_autohide_end, b);
b->animating = 1;
b->hidden = 0;
}
static void
_bryce_autohide_hide(Bryce *b)
{
if (b->autohide_blocked) return;
if (b->autohide_timer)
ecore_timer_loop_reset(b->autohide_timer);
else
b->autohide_timer = ecore_timer_loop_add(1.0, (Ecore_Task_Cb)_bryce_autohide_timeout, b);
}
static void
_bryce_autohide_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Bryce *b = data;
_bryce_autohide_hide(b);
b->mouse_in = 0;
}
static void
_bryce_autohide_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Bryce *b = data;
b->mouse_in = 1;
_bryce_autohide_show(b);
}
static void
_bryce_autohide_setup(Bryce *b)
{
int x, y, w, h;
if (!b->autohide) return;
b->autohide_event = evas_object_rectangle_add(evas_object_evas_get(b->bryce));
evas_object_geometry_get(b->bryce, &x, &y, &w, &h);
evas_object_geometry_set(b->autohide_event, x, y, w, h);
evas_object_color_set(b->autohide_event, 0, 0, 0, 0);
evas_object_repeat_events_set(b->autohide_event, 1);
evas_object_layer_set(b->autohide_event, b->layer + 1);
evas_object_show(b->autohide_event);
evas_object_event_callback_add(b->autohide_event, EVAS_CALLBACK_MOUSE_IN, _bryce_autohide_mouse_in, b);
evas_object_event_callback_add(b->autohide_event, EVAS_CALLBACK_MOUSE_OUT, _bryce_autohide_mouse_out, b);
evas_object_event_callback_add(b->bryce, EVAS_CALLBACK_MOVE, _bryce_autohide_moveresize, b);
evas_object_event_callback_add(b->bryce, EVAS_CALLBACK_RESIZE, _bryce_autohide_moveresize, b);
ecore_evas_pointer_xy_get(e_comp->ee, &x, &y);
if (!E_INSIDE(x, y, b->x, b->y, w, h))
_bryce_autohide_hide(b);
}
static void
_bryce_style(Evas_Object *site, Eina_Stringshare *name, Evas_Object *g)
{
Evas_Object *ly, *prev;
char buf[1024];
BRYCE_GET(site);
ly = elm_layout_add(b->site);
snprintf(buf, sizeof(buf), "e/bryce/%s/%s", b->style ?: "default", name ?: "plain");
if (!e_theme_edje_object_set(ly, NULL, buf))
{
evas_object_del(ly);
return;
}
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
elm_layout_signal_emit(ly, "e,state,orient,horizontal", "e");
else
elm_layout_signal_emit(ly, "e,state,orient,vertical", "e");
edje_object_message_signal_process(elm_layout_edje_get(ly));
prev = e_gadget_util_layout_style_init(g, ly);
elm_object_part_content_set(ly, "e.swallow.content", g);
evas_object_smart_callback_call(g, "gadget_reparent", ly);
evas_object_del(prev);
}
static void
_bryce_site_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Bryce *b = data;
int w, h;
evas_object_size_hint_min_get(obj, &w, &h);
if ((w < 0) || (h < 0)) return;
if (b->autosize && (!b->calc_job))
b->calc_job = ecore_job_add((Ecore_Cb)_bryce_autosize, b);
}
static E_Comp_Object_Type
_bryce_shadow_type(const Bryce *b)
{
if ((b->layer == E_LAYER_DESKTOP_TOP) || b->noshadow)
return E_COMP_OBJECT_TYPE_NONE;
return E_COMP_OBJECT_TYPE_POPUP;
}
static void
_bryce_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Bryce *b = data;
E_Layer layer;
layer = evas_object_layer_get(obj);
if (layer > DEFAULT_LAYER) return;
b->layer = layer;
if ((!b->noshadow) && (layer != b->layer))
e_comp_object_util_type_set(b->bryce, _bryce_shadow_type(b));
}
static Eina_Bool
_bryce_moveresize_save(void *data)
{
Bryce *b = data;
int w, h;
int size;
b->save_timer = NULL;
evas_object_geometry_get(b->bryce, NULL, NULL, &w, &h);
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
size = h;
else
size = w;
size = lround(size / e_scale);
if (b->size == size) return EINA_FALSE;
e_config_save_queue();
b->size = size;
return EINA_FALSE;
}
static void
_bryce_zone_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Bryce *b = data;
e_object_del(E_OBJECT(b->e_obj_inherit));
}
static void
_bryce_zone_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Bryce *b = data;
if (!b->calc_job)
b->calc_job = ecore_job_add((Ecore_Cb)_bryce_autosize, b);
}
static void
_bryce_zone_setup(Bryce *b)
{
Evas_Object *zone_clip;
zone_clip = evas_object_clip_get(b->bryce);
if (zone_clip)
{
evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_DEL, _bryce_zone_del, b);
evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize, b);
evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize, b);
}
zone_clip = e_comp_zone_number_get(b->zone)->bg_clip_object;
evas_object_clip_set(b->bryce, zone_clip);
evas_object_event_callback_add(zone_clip, EVAS_CALLBACK_DEL, _bryce_zone_del, b);
evas_object_event_callback_add(zone_clip, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize, b);
evas_object_event_callback_add(zone_clip, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize, b);
}
static void
_bryce_rename(Bryce *b, int num)
{
char buf[1024], buf2[1024], *name, *p;
name = strdup(b->name);
if (b->version >= 2)
{
p = strrchr(name, '_');
p[0] = 0;
}
snprintf(buf, sizeof(buf), "__bryce%s", name);
snprintf(buf2, sizeof(buf2), "__bryce%s_%d", name, num);
e_gadget_site_rename(buf, buf2);
if (b->version >= 2)
{
snprintf(buf, sizeof(buf), "%s_%u", name, num);
eina_stringshare_replace(&b->name, buf);
}
free(name);
}
static void
_bryce_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Bryce *b = data;
int x, y, w, h;
E_Zone *zone;
int size;
evas_object_geometry_get(obj, &x, &y, &w, &h);
evas_object_geometry_set(b->events, x, y, w, h);
if (b->autohide)
{
E_FREE_LIST(b->zone_obstacles, e_object_del);
return;
}
if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
size = h;
else
size = w;
if (((b->orient == E_GADGET_SITE_ORIENT_VERTICAL) && (w != b->last_w)) ||
((b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL) && (h != b->last_h)))
{
evas_object_smart_need_recalculate_set(b->site, 1);
evas_object_size_hint_min_set(b->site, -1, -1);
}
b->last_w = w, b->last_h = h;
if (size && (b->size != size))
{
if (b->save_timer)
ecore_timer_loop_reset(b->save_timer);
else
b->save_timer = ecore_timer_loop_add(0.5, _bryce_moveresize_save, b);
}
if (starting) return;
zone = e_comp_object_util_zone_get(obj);
if (zone)
{
Eina_Bool vertical = b->orient == E_GADGET_SITE_ORIENT_VERTICAL;
if (b->zone_obstacles)
{
Eina_List *l;
E_Zone_Obstacle *obs;
EINA_LIST_FOREACH(b->zone_obstacles, l, obs)
e_zone_obstacle_modify(obs, &(Eina_Rectangle){b->x, b->y, w, h}, vertical);
}
else
{
void *obs;
obs = e_zone_obstacle_add(e_comp_object_util_zone_get(obj), NULL,
&(Eina_Rectangle){b->x, b->y, w, h}, vertical);
e_object_data_set(obs, b);
E_OBJECT_DEL_SET(obs, _bryce_obstacle_del);
b->zone_obstacles = eina_list_append(b->zone_obstacles, obs);
}
}
else
{
/* determine "closest" zone:
* calculate size of rect between bryce and zone
* smallest rect = closest zone
*/
Eina_List *l;
E_Zone *lz;
size = 0;
E_FREE_LIST(b->zone_obstacles, e_object_del);
EINA_LIST_FOREACH(e_comp->zones, l, lz)
{
int cw, ch;
if (x < lz->x)
cw = lz->x + lz->w - x;
else
cw = x + w - lz->x;
if (y < lz->y)
ch = lz->y + lz->h - y;
else
ch = y + h - lz->y;
if (size >= cw * ch) continue;
size = cw * ch;
zone = lz;
}
}
if (!zone) return;
if (b->zone == zone->num) return;
e_config_save_queue();
_bryce_rename(b, zone->num);
b->zone = zone->num;
_bryce_zone_setup(b);
_bryce_autosize(b);
}
static void
_bryce_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Bryce *b = data;
Evas_Event_Mouse_Wheel *ev = event_info;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
if (e_bindings_wheel_evas_event_handle(E_BINDING_CONTEXT_ANY, b->e_obj_inherit, ev))
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
static void
_bryce_popup_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Bryce *b = data;
b->autohide_blocked--;
b->popups = eina_list_remove(b->popups, obj);
if (!b->autohide) return;
if (!b->mouse_in)
_bryce_autohide_hide(b);
}
static void
_bryce_popup(Bryce *b, Evas_Object *popup)
{
evas_object_event_callback_add(popup, EVAS_CALLBACK_HIDE, _bryce_popup_hide, b);
b->autohide_blocked++;
b->popups = eina_list_append(b->popups, popup);
if (b->autohide)
_bryce_autohide_show(b);
}
static void
_bryce_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Bryce *b = data;
Evas_Object *p;
Evas_Object *zone_clip;
void *obs;
if (b->menu)
{
e_menu_deactivate(b->menu);
e_object_del(E_OBJECT(b->menu));
b->menu = NULL;
}
EINA_LIST_FREE(b->zone_obstacles, obs)
{
E_OBJECT_DEL_SET(obs, NULL);
e_object_del(obs);
}
evas_object_del(b->autohide_event);
E_FREE_FUNC(b->events, evas_object_del);
E_FREE_FUNC(b->calc_job, ecore_job_del);
E_FREE_FUNC(b->autohide_timer, ecore_timer_del);
ecore_timer_del(b->save_timer);
EINA_LIST_FREE(b->popups, p)
evas_object_event_callback_del(p, EVAS_CALLBACK_HIDE, _bryce_popup_hide);
zone_clip = evas_object_clip_get(b->bryce);
if (zone_clip)
{
evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_DEL, _bryce_zone_del, b);
evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize, b);
evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize, b);
}
E_FREE(b->e_obj_inherit);
b->bryce = NULL;
b->site = NULL;
}
static void
_bryce_object_free(E_Object *eobj)
{
Bryce *b = e_object_data_get(eobj);
evas_object_hide(b->bryce);
evas_object_del(b->bryce);
}
static void
_bryce_style_menu(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Bryce *b = data;
char buf[1024];
snprintf(buf, sizeof(buf), "e/bryce/%s", b->style ?: "default");
e_object_data_set(event_info, e_theme_collection_items_find(NULL, buf));
}
static void
_bryce_gadgets_menu_close(void *data, Evas_Object *obj)
{
Bryce *b = data;
b->autohide_blocked--;
b->editing = 0;
evas_object_layer_set(b->bryce, b->layer);
evas_object_hide(obj);
evas_object_del(obj);
if (b->autohide && (!b->mouse_in))
_bryce_autohide_hide(b);
}
static void
_bryce_gadgets_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Bryce *b = data;
Evas_Object *comp_object;
b->autohide_blocked++;
b->editing = 1;
comp_object = e_gadget_site_edit(b->site);
evas_object_layer_set(b->bryce, E_LAYER_POPUP);
e_comp_object_util_autoclose(comp_object, _bryce_gadgets_menu_close, e_comp_object_util_autoclose_on_escape, b);
}
static void
_bryce_autosize_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Bryce *b = data;
e_bryce_autosize_set(b->bryce, !b->autosize);
}
static void
_bryce_autohide_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Bryce *b = data;
e_bryce_autohide_set(b->bryce, !b->autohide);
}
static void
_bryce_remove_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Bryce *b = data;
bryces->bryces = eina_list_remove(bryces->bryces, data);
e_gadget_site_del(b->site);
eina_stringshare_del(b->name);
eina_stringshare_del(b->style);
evas_object_hide(b->bryce);
evas_object_del(b->bryce);
e_config_save_queue();
}
static void
_bryce_wizard_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Bryce *b = data;
Evas_Object *editor;
editor = e_bryce_edit(b->bryce);
_bryce_popup(b, editor);
}
static void
_bryce_gadget_settings_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Evas_Object *g = data;
e_gadget_configure(g);
}
static void
_bryce_gadget_remove_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
{
Evas_Object *g = data;
e_gadget_del(g);
e_config_save_queue();
}
static void
_bryce_menu_post_cb(void *data, E_Menu *m)
{
Bryce *b = data;
if (b->menu != m) return;
b->menu = NULL;
}
static void
_bryce_menu_populate(Bryce *b, E_Menu *m, Evas_Object *g)
{
E_Menu_Item *mi;
const char *s = NULL;
if (g) s = e_gadget_type_get(g);
if (s) e_menu_title_set(m, e_gadget_type_get(g));
else e_menu_title_set(m, _("Gadget Bar"));
if (g)
{
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Settings"));
e_util_menu_item_theme_icon_set(mi, "preferences-system");
e_menu_item_callback_set(mi, _bryce_gadget_settings_menu, g);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Delete"));
e_util_menu_item_theme_icon_set(mi, "list-remove");
e_menu_item_callback_set(mi, _bryce_gadget_remove_menu, g);
e_gadget_menu_populate(g, m);
mi = e_menu_item_new(m);
e_menu_item_separator_set(mi, 1);
}
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Autosize"));
e_menu_item_check_set(mi, 1);
e_menu_item_toggle_set(mi, b->autosize);
e_menu_item_callback_set(mi, _bryce_autosize_menu, b);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Autohide"));
e_menu_item_check_set(mi, 1);
e_menu_item_toggle_set(mi, b->autohide);
e_menu_item_callback_set(mi, _bryce_autohide_menu, b);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Bar Settings"));
e_menu_item_callback_set(mi, _bryce_wizard_menu, b);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Add Gadget"));
e_menu_item_callback_set(mi, _bryce_gadgets_menu, b);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Delete Bar"));
e_util_menu_item_theme_icon_set(mi, "list-remove");
e_menu_item_callback_set(mi, _bryce_remove_menu, b);
if (b->menu)
{
e_menu_deactivate(b->menu);
e_object_del(E_OBJECT(b->menu));
}
b->menu = m;
e_menu_post_deactivate_callback_set(m, _bryce_menu_post_cb, b);
}
static void
_bryce_owner_menu(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{