elfe: Enable Remove app/widgets from desktops and from config
SVN revision: 57635
This commit is contained in:
parent
8a6486fe20
commit
c098372d87
|
@ -783,6 +783,12 @@ collections
|
|||
transition: "ACCELERATE" 0.3;
|
||||
after: "vib1";
|
||||
}
|
||||
program {
|
||||
name: "delete_click";
|
||||
signal: "mouse,clicked,1";
|
||||
source: "badge_delete";
|
||||
action: SIGNAL_EMIT "elfe,delete,clicked" "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,22 @@ struct _Elfe_Desktop_Item
|
|||
{
|
||||
Evas_Object *frame;
|
||||
Evas_Object *item;
|
||||
Evas_Object *icon;
|
||||
Efreet_Desktop *desktop;
|
||||
E_Gadcon_Client *gcc;
|
||||
E_Gadcon_Client_Class *cc;
|
||||
int row;
|
||||
int col;
|
||||
Efreet_Desktop *desktop;
|
||||
Eina_Bool edit_mode;
|
||||
|
||||
};
|
||||
|
||||
static void
|
||||
_gadget_del(E_Gadcon_Client *gcc)
|
||||
{
|
||||
e_object_del(E_OBJECT(gcc));
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_gadget_add(Elfe_Desktop_Item *dit, const char *name, E_Gadcon *gc)
|
||||
{
|
||||
|
@ -26,19 +36,26 @@ _gadget_add(Elfe_Desktop_Item *dit, const char *name, E_Gadcon *gc)
|
|||
|
||||
if (!gc) return NULL;
|
||||
|
||||
item = edje_object_add(evas_object_evas_get(dit->frame));
|
||||
edje_object_file_set(item, elfe_home_cfg->theme, "elfe/desktop/gadget/frame");
|
||||
|
||||
cc = elfe_utils_gadcon_client_class_from_name(name);
|
||||
if (!cc)
|
||||
{
|
||||
printf("Error unable to retrieve gadcon client class for %s\n", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gcc = cc->func.init(gc, cc->name, "test", cc->default_style);
|
||||
if (!gcc) return NULL;
|
||||
|
||||
e_object_del_func_set(E_OBJECT(gcc), E_OBJECT_CLEANUP_FUNC(_gadget_del));
|
||||
|
||||
item = edje_object_add(evas_object_evas_get(dit->frame));
|
||||
edje_object_file_set(item, elfe_home_cfg->theme, "elfe/desktop/gadget/frame");
|
||||
|
||||
gcc->cf = NULL;
|
||||
gcc->client_class = cc;
|
||||
edje_object_part_swallow(item, "elfe.swallow.content", gcc->o_base);
|
||||
dit->gcc = gcc;
|
||||
dit->cc = cc;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -59,6 +76,16 @@ _clicked_signal_cb(void *data, Evas_Object *obj, const char *emission, const cha
|
|||
_app_exec_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_delete_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Elfe_Desktop_Item *dit = data;
|
||||
|
||||
if (dit->edit_mode)
|
||||
evas_object_smart_callback_call(dit->frame,
|
||||
"item,delete", dit->frame);
|
||||
}
|
||||
|
||||
|
||||
static Evas_Object *
|
||||
_app_add(Elfe_Desktop_Item *dit, const char *name)
|
||||
|
@ -71,6 +98,7 @@ _app_add(Elfe_Desktop_Item *dit, const char *name)
|
|||
|
||||
icon = elfe_utils_fdo_icon_add(dit->frame, dit->desktop->icon, 96);
|
||||
edje_object_part_swallow(item, "elfe.swallow.content", icon);
|
||||
dit->icon = icon;
|
||||
|
||||
edje_object_part_text_set(item, "elfe.text.label", dit->desktop->name);
|
||||
edje_object_signal_callback_add(item, "mouse,clicked,1", "*", _clicked_signal_cb, dit);
|
||||
|
@ -79,7 +107,7 @@ _app_add(Elfe_Desktop_Item *dit, const char *name)
|
|||
}
|
||||
|
||||
void
|
||||
elfe_desktop_item_pos_get(Evas_Object *obj, int *col, int *row)
|
||||
elfe_desktop_item_pos_get(Evas_Object *obj, int *row, int *col)
|
||||
{
|
||||
Elfe_Desktop_Item *dit = evas_object_data_get(obj, "desktop_item");
|
||||
|
||||
|
@ -104,6 +132,26 @@ elfe_desktop_item_edit_mode_set(Evas_Object *obj, Eina_Bool mode)
|
|||
edje_object_signal_emit(dit->frame, "action,edit,on", "elfe");
|
||||
}
|
||||
|
||||
static void
|
||||
_obj_del_cb(void *data , Evas *e , Evas_Object *obj, void *event_info )
|
||||
{
|
||||
Elfe_Desktop_Item *dit = data;
|
||||
|
||||
/* FIXME delay object deletion and add edje effect before deleting */
|
||||
|
||||
if (dit->icon)
|
||||
evas_object_del(dit->icon);
|
||||
if (dit->gcc)
|
||||
e_object_del(E_OBJECT(dit->gcc));
|
||||
if (dit->item)
|
||||
evas_object_del(dit->item);
|
||||
if (dit->desktop)
|
||||
efreet_desktop_free(dit->desktop);
|
||||
free(dit);
|
||||
dit = NULL;
|
||||
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
elfe_desktop_item_add(Evas_Object *parent,
|
||||
int row, int col,
|
||||
|
@ -119,8 +167,8 @@ elfe_desktop_item_add(Evas_Object *parent,
|
|||
if (!dit)
|
||||
return NULL;
|
||||
|
||||
dit->col = col;
|
||||
dit->row = row;
|
||||
dit->col = col;
|
||||
|
||||
layout = edje_object_add(evas_object_evas_get(parent));
|
||||
edje_object_file_set(layout, elfe_home_cfg->theme, "elfe/desktop/frame");
|
||||
|
@ -144,16 +192,27 @@ elfe_desktop_item_add(Evas_Object *parent,
|
|||
break;
|
||||
case ELFE_DESKTOP_ITEM_GADGET:
|
||||
item = _gadget_add(dit, name, gc);
|
||||
if (!item)
|
||||
{
|
||||
printf("ERROR unable to create gadget %s\n", name);
|
||||
evas_object_del(layout);
|
||||
free(dit);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
edje_object_part_swallow(layout, "elfe.swallow.content", item);
|
||||
edje_object_signal_callback_add(layout, "elfe,delete,clicked", "*", _delete_signal_cb, dit);
|
||||
evas_object_show(item);
|
||||
|
||||
dit->item = item;
|
||||
|
||||
evas_object_event_callback_add(dit->frame, EVAS_CALLBACK_DEL,
|
||||
_obj_del_cb, dit);
|
||||
|
||||
evas_object_data_set(dit->frame, "desktop_item", dit);
|
||||
|
||||
return dit->frame;
|
||||
|
|
|
@ -19,7 +19,7 @@ struct _Elfe_Desktop_Page
|
|||
|
||||
static void
|
||||
_pos_to_geom(Elfe_Desktop_Page *page,
|
||||
int col, int row,
|
||||
int row, int col,
|
||||
Evas_Coord *x, Evas_Coord *y,
|
||||
Evas_Coord *w, Evas_Coord *h)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ _pos_to_geom(Elfe_Desktop_Page *page,
|
|||
|
||||
static void
|
||||
_xy_to_pos(Elfe_Desktop_Page *page, Evas_Coord x, Evas_Coord y,
|
||||
int *col, int *row)
|
||||
int *row, int *col)
|
||||
{
|
||||
Evas_Coord ow, oh;
|
||||
Evas_Coord w = 0, h = 0;
|
||||
|
@ -124,6 +124,21 @@ static void _gadcon_del(E_Gadcon *gc)
|
|||
/* FIXME delete gadcon */
|
||||
}
|
||||
|
||||
static void
|
||||
_item_delete_cb(void *data , Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *item = event_info;
|
||||
Elfe_Desktop_Page *page = data;
|
||||
int row, col;
|
||||
|
||||
elfe_desktop_item_pos_get(item, &row, &col);
|
||||
eina_matrixsparse_cell_idx_clear(page->items, row, col);
|
||||
evas_object_del(item);
|
||||
elfe_home_config_desktop_item_del(page->desktop,
|
||||
row, col);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_populate_page(Elfe_Desktop_Page *page)
|
||||
{
|
||||
|
@ -137,22 +152,26 @@ _populate_page(Elfe_Desktop_Page *page)
|
|||
{
|
||||
Evas_Coord x = 0, y = 0, w = 0, h = 0;
|
||||
|
||||
printf("Page %d populage item [%d %d]: %s\n", page->desktop, dic->col, dic->row, dic->name);
|
||||
printf("Page %d populage item [%d %d]: %s\n", page->desktop, dic->row, dic->col, dic->name);
|
||||
|
||||
/* This position is already in use, this is a conf issue! */
|
||||
/* FIXME: delete item from config ? */
|
||||
if (eina_matrixsparse_data_idx_get(page->items, dic->col, dic->row))
|
||||
if (eina_matrixsparse_data_idx_get(page->items, dic->row, dic->col))
|
||||
continue;
|
||||
|
||||
item = elfe_desktop_item_add(page->layout, dic->row, dic->col,
|
||||
dic->name, dic->type, page->gc);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
evas_object_smart_callback_add(item, "item,delete", _item_delete_cb, page);
|
||||
|
||||
e_layout_pack(page->layout, item);
|
||||
_pos_to_geom(page, dic->col, dic->row, &x, &y, &w, &h);
|
||||
_pos_to_geom(page, dic->row, dic->col, &x, &y, &w, &h);
|
||||
e_layout_child_resize(item, w, h);
|
||||
e_layout_child_move(item, x, y);
|
||||
evas_object_show(item);
|
||||
eina_matrixsparse_data_idx_set(page->items, dic->col, dic->row, item);
|
||||
eina_matrixsparse_data_idx_set(page->items, dic->row, dic->col, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,8 +194,8 @@ _page_resize_cb(void *data , Evas *e , Evas_Object *obj, void *event_info )
|
|||
EINA_ITERATOR_FOREACH(iter, cell)
|
||||
{
|
||||
item = eina_matrixsparse_cell_data_get(cell);
|
||||
elfe_desktop_item_pos_get(item, &col, &row);
|
||||
_pos_to_geom(page, col, row, &x, &y, &w, &h);
|
||||
elfe_desktop_item_pos_get(item, &row, &col);
|
||||
_pos_to_geom(page, row, col, &x, &y, &w, &h);
|
||||
e_layout_child_resize(item, w, h);
|
||||
e_layout_child_move(item, x, y);
|
||||
evas_object_show(item);
|
||||
|
@ -185,10 +204,10 @@ _page_resize_cb(void *data , Evas *e , Evas_Object *obj, void *event_info )
|
|||
}
|
||||
|
||||
Eina_Bool
|
||||
elfe_desktop_page_pos_is_free(Evas_Object *obj, int col, int row)
|
||||
elfe_desktop_page_pos_is_free(Evas_Object *obj, int row, int col)
|
||||
{
|
||||
Elfe_Desktop_Page *page = evas_object_data_get(obj, "desktop_page");
|
||||
if (eina_matrixsparse_data_idx_get(page->items, col, row))
|
||||
if (eina_matrixsparse_data_idx_get(page->items, row, col))
|
||||
return EINA_TRUE;
|
||||
else
|
||||
return EINA_FALSE;
|
||||
|
@ -203,26 +222,28 @@ elfe_desktop_page_item_gadget_add(Evas_Object *obj, const char *name,
|
|||
Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0;
|
||||
int row = 0, col = 0;
|
||||
|
||||
_xy_to_pos(page, x, y, &col, &row);
|
||||
_xy_to_pos(page, x, y, &row, &col);
|
||||
|
||||
/* This position is already used by another item! */
|
||||
if (eina_matrixsparse_data_idx_get(page->items, col, row)) return;
|
||||
if (eina_matrixsparse_data_idx_get(page->items, row, col)) return;
|
||||
|
||||
item = elfe_desktop_item_add(page->layout, col, row,
|
||||
item = elfe_desktop_item_add(page->layout, row, col,
|
||||
name,
|
||||
ELFE_DESKTOP_ITEM_GADGET, page->gc);
|
||||
e_layout_pack(page->layout, item);
|
||||
_pos_to_geom(page, col, row, &ox, &oy, &ow, &oh);
|
||||
_pos_to_geom(page, row, col, &ox, &oy, &ow, &oh);
|
||||
e_layout_child_resize(item, ow, oh);
|
||||
e_layout_child_move(item, ox, oy);
|
||||
evas_object_show(item);
|
||||
eina_matrixsparse_data_idx_set(page->items, col, row, item);
|
||||
evas_object_raise(item);
|
||||
eina_matrixsparse_data_idx_set(page->items, row, col, item);
|
||||
|
||||
elfe_home_config_desktop_item_add(page->desktop,
|
||||
ELFE_DESKTOP_ITEM_GADGET,
|
||||
col, row,
|
||||
row, col,
|
||||
0, 0, 0, 0,
|
||||
name);
|
||||
evas_object_smart_callback_add(item, "item,delete", _item_delete_cb, page);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -234,27 +255,29 @@ elfe_desktop_page_item_app_add(Evas_Object *obj, Efreet_Menu *menu,
|
|||
Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0;
|
||||
int row = 0, col = 0;
|
||||
|
||||
_xy_to_pos(page, x, y, &col, &row);
|
||||
_xy_to_pos(page, x, y, &row, &col);
|
||||
|
||||
/* This position is already used by another item! */
|
||||
if (eina_matrixsparse_data_idx_get(page->items, col, row)) return;
|
||||
if (eina_matrixsparse_data_idx_get(page->items, row, col)) return;
|
||||
|
||||
item = elfe_desktop_item_add(page->layout, col, row,
|
||||
item = elfe_desktop_item_add(page->layout, row, col,
|
||||
menu->desktop->orig_path,
|
||||
ELFE_DESKTOP_ITEM_APP, NULL);
|
||||
e_layout_pack(page->layout, item);
|
||||
_pos_to_geom(page, col, row, &ox, &oy, &ow, &oh);
|
||||
_pos_to_geom(page, row, col, &ox, &oy, &ow, &oh);
|
||||
e_layout_child_resize(item, ow, oh);
|
||||
e_layout_child_move(item, ox, oy);
|
||||
evas_object_show(item);
|
||||
evas_object_raise(item);
|
||||
|
||||
eina_matrixsparse_data_idx_set(page->items, col, row, item);
|
||||
eina_matrixsparse_data_idx_set(page->items, row, col, item);
|
||||
|
||||
elfe_home_config_desktop_item_add(page->desktop,
|
||||
ELFE_DESKTOP_ITEM_APP,
|
||||
col, row,
|
||||
row, col,
|
||||
0, 0, 0, 0,
|
||||
menu->desktop->orig_path);
|
||||
evas_object_smart_callback_add(item, "item,delete", _item_delete_cb, page);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -286,7 +309,7 @@ elfe_desktop_page_add(Evas_Object *parent, E_Zone *zone,
|
|||
if (!page)
|
||||
return NULL;
|
||||
|
||||
page->items = eina_matrixsparse_new(elfe_home_cfg->cols, elfe_home_cfg->rows,
|
||||
page->items = eina_matrixsparse_new(elfe_home_cfg->rows, elfe_home_cfg->cols,
|
||||
NULL, NULL);
|
||||
|
||||
page->layout = e_layout_add(evas_object_evas_get(parent));
|
||||
|
|
|
@ -165,7 +165,7 @@ _elfe_home_config_change_timeout(void *data __UNUSED__)
|
|||
|
||||
void elfe_home_config_desktop_item_add(int desktop,
|
||||
Elfe_Desktop_Item_Type type,
|
||||
int col, int row,
|
||||
int row, int col,
|
||||
Evas_Coord x, Evas_Coord y,
|
||||
Evas_Coord w, Evas_Coord h,
|
||||
const char *name)
|
||||
|
@ -190,3 +190,24 @@ void elfe_home_config_desktop_item_add(int desktop,
|
|||
|
||||
elfe_home_config_save();
|
||||
}
|
||||
|
||||
void elfe_home_config_desktop_item_del(int desktop,
|
||||
int row, int col)
|
||||
{
|
||||
Elfe_Desktop_Config *dc;
|
||||
Elfe_Desktop_Item_Config *dic;
|
||||
Eina_List *l;
|
||||
|
||||
printf("DELETE CONFIG ITEM %d %d\n", col, row);
|
||||
dc = eina_list_nth(elfe_home_cfg->desktops, desktop);
|
||||
EINA_LIST_FOREACH(dc->items, l, dic)
|
||||
{
|
||||
if ((dic->row == row) && (dic->col == col))
|
||||
{
|
||||
printf("Delete %d %d\n", row, col);
|
||||
dc->items = eina_list_remove(dc->items, dic);
|
||||
elfe_home_config_save();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ int elfe_home_config_save(void);
|
|||
void elfe_home_config_show(E_Container *con, const char *params);
|
||||
void elfe_home_config_desktop_item_add(int desktop,
|
||||
Elfe_Desktop_Item_Type type,
|
||||
int col, int row,
|
||||
int row, int col,
|
||||
Evas_Coord x, Evas_Coord y,
|
||||
Evas_Coord w, Evas_Coord h,
|
||||
const char *name);
|
||||
|
|
|
@ -17,7 +17,7 @@ _list_longpress(void *data, Evas_Object *obj, void *event_info)
|
|||
name = elm_list_item_data_get(it);
|
||||
|
||||
evas_object_smart_callback_call(data,
|
||||
"list,longpressed", name);
|
||||
"list,longpressed", (void*)name);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
|
|
Loading…
Reference in New Issue