Places: support site other than desktop
Now on shelf and toolbars show just an hard-disk icon, clicking the icon will upen a popup (like clock or connman modules) containing the usual volumes list. SVN revision: 84514
This commit is contained in:
parent
678fa102cc
commit
189f937f08
|
@ -49,12 +49,14 @@ collections
|
||||||
box {
|
box {
|
||||||
layout: "vertical";
|
layout: "vertical";
|
||||||
align: 0.5 0.0;
|
align: 0.5 0.0;
|
||||||
|
min: 1 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
description { state: "horiz" 0.0;
|
description { state: "horiz" 0.0;
|
||||||
box {
|
box {
|
||||||
layout: "orizontal";
|
layout: "orizontal";
|
||||||
align: 0.5 0.5;
|
align: 0.5 0.5;
|
||||||
|
min: 1 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,7 @@ collections
|
||||||
/** GADGET HEADER *********************************/
|
/** GADGET HEADER *********************************/
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
group { name: "modules/places/header";
|
group { name: "modules/places/header";
|
||||||
min: 120 35;
|
min: 200 35;
|
||||||
max: 384 35;
|
max: 384 35;
|
||||||
parts {
|
parts {
|
||||||
part { name: "bg";
|
part { name: "bg";
|
||||||
|
@ -284,7 +286,7 @@ collections
|
||||||
/** GADGET VOLUME *********************************/
|
/** GADGET VOLUME *********************************/
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
group { name: "modules/places/volume";
|
group { name: "modules/places/volume";
|
||||||
min: 150 50;
|
min: 200 50;
|
||||||
max: 384 50;
|
max: 384 50;
|
||||||
script { /* this set the gauge value */
|
script { /* this set the gauge value */
|
||||||
public message(Msg_Type:type, id, ...) {
|
public message(Msg_Type:type, id, ...) {
|
||||||
|
|
162
src/e_mod_main.c
162
src/e_mod_main.c
|
@ -18,6 +18,7 @@ static void _places_conf_new(void);
|
||||||
static void _places_conf_free(void);
|
static void _places_conf_free(void);
|
||||||
static Eina_Bool _places_conf_timer(void *data);
|
static Eina_Bool _places_conf_timer(void *data);
|
||||||
static Config_Item *_places_conf_item_get(const char *id);
|
static Config_Item *_places_conf_item_get(const char *id);
|
||||||
|
static void _places_icon_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||||
static void _places_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
static void _places_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||||
static void _places_cb_menu_post(void *data, E_Menu *menu);
|
static void _places_cb_menu_post(void *data, E_Menu *menu);
|
||||||
static void _places_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi);
|
static void _places_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi);
|
||||||
|
@ -34,8 +35,8 @@ static const E_Gadcon_Client_Class _gc_class =
|
||||||
{
|
{
|
||||||
GADCON_CLIENT_CLASS_VERSION, "Places",
|
GADCON_CLIENT_CLASS_VERSION, "Places",
|
||||||
{_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon,
|
{_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon,
|
||||||
_gc_id_new, _gc_id_del, e_gadcon_site_is_not_toolbar},
|
_gc_id_new, _gc_id_del, NULL},
|
||||||
E_GADCON_CLIENT_STYLE_INSET
|
E_GADCON_CLIENT_STYLE_PLAIN
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Places"};
|
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Places"};
|
||||||
|
@ -193,7 +194,7 @@ places_menu_augmentation(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gadcon Functions */
|
/* Gadcon IFace */
|
||||||
static E_Gadcon_Client *
|
static E_Gadcon_Client *
|
||||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
{
|
{
|
||||||
|
@ -202,7 +203,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
inst = E_NEW(Instance, 1);
|
inst = E_NEW(Instance, 1);
|
||||||
inst->conf_item = _places_conf_item_get(id);
|
inst->conf_item = _places_conf_item_get(id);
|
||||||
|
|
||||||
if (1) // site is desktop
|
if (e_gadcon_site_is_desktop(gc->location->site))
|
||||||
{
|
{
|
||||||
inst->o_main = places_main_obj_create(gc->evas);
|
inst->o_main = places_main_obj_create(gc->evas);
|
||||||
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
|
@ -212,7 +213,11 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO site is shelf or toolbar
|
inst->o_icon = e_icon_add(gc->evas);
|
||||||
|
e_util_icon_theme_set(inst->o_icon, "drive-harddisk");
|
||||||
|
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_icon);
|
||||||
|
evas_object_event_callback_add(inst->o_icon, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
|
_places_icon_cb_mouse_down, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
inst->gcc->data = inst;
|
inst->gcc->data = inst;
|
||||||
|
@ -250,47 +255,44 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
static void
|
static void
|
||||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = gcc->data;
|
||||||
Volume *v;
|
Evas_Coord min_w, min_h;
|
||||||
Eina_List *l;
|
|
||||||
int count = 1;
|
if (e_gadcon_site_is_desktop(gcc->gadcon->location->site))
|
||||||
|
{
|
||||||
|
switch (orient)
|
||||||
|
{
|
||||||
|
case E_GADCON_ORIENT_HORIZ:
|
||||||
|
case E_GADCON_ORIENT_TOP:
|
||||||
|
case E_GADCON_ORIENT_BOTTOM:
|
||||||
|
case E_GADCON_ORIENT_CORNER_TL:
|
||||||
|
case E_GADCON_ORIENT_CORNER_TR:
|
||||||
|
case E_GADCON_ORIENT_CORNER_BL:
|
||||||
|
case E_GADCON_ORIENT_CORNER_BR:
|
||||||
|
inst->horiz = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
case E_GADCON_ORIENT_FLOAT:
|
||||||
|
case E_GADCON_ORIENT_VERT:
|
||||||
|
case E_GADCON_ORIENT_LEFT:
|
||||||
|
case E_GADCON_ORIENT_RIGHT:
|
||||||
|
case E_GADCON_ORIENT_CORNER_LT:
|
||||||
|
case E_GADCON_ORIENT_CORNER_RT:
|
||||||
|
case E_GADCON_ORIENT_CORNER_LB:
|
||||||
|
case E_GADCON_ORIENT_CORNER_RB:
|
||||||
|
default:
|
||||||
|
inst->horiz = EINA_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
EINA_LIST_FOREACH(places_volume_list_get(), l, v)
|
places_fill_box(inst->o_main, inst->horiz);
|
||||||
if (v->valid) count++;
|
evas_object_size_hint_min_get(inst->o_main, &min_w, &min_h);
|
||||||
|
e_gadcon_client_min_size_set(gcc, min_w, min_h);
|
||||||
inst = gcc->data;
|
}
|
||||||
switch (orient)
|
else
|
||||||
{
|
{
|
||||||
case E_GADCON_ORIENT_HORIZ:
|
e_gadcon_client_min_size_set(gcc, 16, 16);
|
||||||
case E_GADCON_ORIENT_TOP:
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||||
case E_GADCON_ORIENT_BOTTOM:
|
}
|
||||||
case E_GADCON_ORIENT_CORNER_TL:
|
|
||||||
case E_GADCON_ORIENT_CORNER_TR:
|
|
||||||
case E_GADCON_ORIENT_CORNER_BL:
|
|
||||||
case E_GADCON_ORIENT_CORNER_BR:
|
|
||||||
// TODO get sizes from the theme
|
|
||||||
e_gadcon_client_aspect_set(gcc, 200 * count, 60);
|
|
||||||
e_gadcon_client_min_size_set(gcc, 200 * count, 60);
|
|
||||||
inst->horiz = EINA_TRUE;
|
|
||||||
break;
|
|
||||||
case E_GADCON_ORIENT_FLOAT:
|
|
||||||
case E_GADCON_ORIENT_VERT:
|
|
||||||
case E_GADCON_ORIENT_LEFT:
|
|
||||||
case E_GADCON_ORIENT_RIGHT:
|
|
||||||
case E_GADCON_ORIENT_CORNER_LT:
|
|
||||||
case E_GADCON_ORIENT_CORNER_RT:
|
|
||||||
case E_GADCON_ORIENT_CORNER_LB:
|
|
||||||
case E_GADCON_ORIENT_CORNER_RB:
|
|
||||||
// TODO get sizes from the theme
|
|
||||||
e_gadcon_client_aspect_set(gcc, 200, 50 * count);
|
|
||||||
e_gadcon_client_min_size_set(gcc, 200, 50 * count);
|
|
||||||
inst->horiz = EINA_FALSE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
places_fill_box(inst->o_main, inst->horiz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
@ -410,7 +412,77 @@ _places_conf_item_get(const char *id)
|
||||||
return ci;
|
return ci;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* popup */
|
||||||
static void
|
static void
|
||||||
|
_places_popup_del(Instance *inst)
|
||||||
|
{
|
||||||
|
if (inst->popup)
|
||||||
|
e_object_del(E_OBJECT(inst->popup));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_places_popup_del_cb(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Instance *inst;
|
||||||
|
|
||||||
|
inst = e_object_data_get(E_OBJECT(obj));
|
||||||
|
if (!inst) return;
|
||||||
|
|
||||||
|
places_empty_box(inst->o_main);
|
||||||
|
evas_object_del(inst->o_main);
|
||||||
|
inst->o_main = NULL;
|
||||||
|
inst->popup = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_places_popup_new(Instance *inst)
|
||||||
|
{
|
||||||
|
E_Gadcon_Popup *popup;
|
||||||
|
|
||||||
|
// do not create twice
|
||||||
|
if (inst->popup)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// create the popup
|
||||||
|
popup = e_gadcon_popup_new(inst->gcc);
|
||||||
|
if (0) // TODO make popup_autoclose an option (and close when volume selected?)
|
||||||
|
e_popup_autoclose(popup->win, NULL, NULL);
|
||||||
|
e_object_data_set(E_OBJECT(popup), inst);
|
||||||
|
E_OBJECT_DEL_SET(popup, _places_popup_del_cb);
|
||||||
|
inst->popup = popup;
|
||||||
|
|
||||||
|
// build and fill the main edje object
|
||||||
|
inst->o_main = places_main_obj_create(popup->win->evas);
|
||||||
|
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
|
_places_cb_mouse_down, inst);
|
||||||
|
places_fill_box(inst->o_main, EINA_FALSE);
|
||||||
|
|
||||||
|
// show the popup
|
||||||
|
e_gadcon_popup_content_set(popup, inst->o_main);
|
||||||
|
e_gadcon_popup_show(popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void // mouse down on the icon (for shelf and toolbars)
|
||||||
|
_places_icon_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||||
|
{
|
||||||
|
Instance *inst = data;
|
||||||
|
Evas_Event_Mouse_Down *ev = event;
|
||||||
|
|
||||||
|
if (!inst)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ev->button == 1)
|
||||||
|
{
|
||||||
|
if (!inst->o_main)
|
||||||
|
_places_popup_new(inst);
|
||||||
|
else
|
||||||
|
_places_popup_del(inst);
|
||||||
|
}
|
||||||
|
else if (ev->button == 3)
|
||||||
|
_places_cb_mouse_down(inst, evas, obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void // mouse down on the main edje object (the list of volumes)
|
||||||
_places_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
|
_places_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||||
{
|
{
|
||||||
Instance *inst = NULL;
|
Instance *inst = NULL;
|
||||||
|
|
|
@ -55,6 +55,8 @@ struct _Instance
|
||||||
{
|
{
|
||||||
E_Gadcon_Client *gcc;
|
E_Gadcon_Client *gcc;
|
||||||
Evas_Object *o_main;
|
Evas_Object *o_main;
|
||||||
|
Evas_Object *o_icon;
|
||||||
|
E_Gadcon_Popup *popup;
|
||||||
Eina_Bool horiz;
|
Eina_Bool horiz;
|
||||||
E_Menu *menu;
|
E_Menu *menu;
|
||||||
Config_Item *conf_item;
|
Config_Item *conf_item;
|
||||||
|
|
|
@ -241,6 +241,8 @@ places_fill_box(Evas_Object *main, Eina_Bool horiz)
|
||||||
char *f1, *f2, *f3;
|
char *f1, *f2, *f3;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
|
if (!main) return;
|
||||||
|
|
||||||
places_empty_box(main);
|
places_empty_box(main);
|
||||||
|
|
||||||
/*if (places_conf->show_home)
|
/*if (places_conf->show_home)
|
||||||
|
@ -278,7 +280,7 @@ places_fill_box(Evas_Object *main, Eina_Bool horiz)
|
||||||
edje_object_size_max_get(o, &max_w, &max_h);
|
edje_object_size_max_get(o, &max_w, &max_h);
|
||||||
evas_object_size_hint_min_set(o, min_w, min_h);
|
evas_object_size_hint_min_set(o, min_w, min_h);
|
||||||
evas_object_size_hint_max_set(o, max_w, max_h);
|
evas_object_size_hint_max_set(o, max_w, max_h);
|
||||||
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
// evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
|
||||||
edje_object_part_box_append(main, "box", o);
|
edje_object_part_box_append(main, "box", o);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
||||||
|
@ -386,10 +388,16 @@ places_fill_box(Evas_Object *main, Eina_Bool horiz)
|
||||||
edje_object_size_max_get(o, &max_w, &max_h);
|
edje_object_size_max_get(o, &max_w, &max_h);
|
||||||
evas_object_size_hint_min_set(o, min_w, min_h);
|
evas_object_size_hint_min_set(o, min_w, min_h);
|
||||||
evas_object_size_hint_max_set(o, max_w, max_h);
|
evas_object_size_hint_max_set(o, max_w, max_h);
|
||||||
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
// evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
|
||||||
|
// evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
edje_object_part_box_append(main, "box", o);
|
edje_object_part_box_append(main, "box", o);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edje_object_calc_force(main);
|
||||||
|
edje_object_size_min_restricted_calc(main, &min_w, &min_h, 99, 1);
|
||||||
|
// printf("PLACES: SIZE: %d %d\n", min_w, min_h);
|
||||||
|
evas_object_size_hint_min_set(main, min_w, min_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue