forked from enlightenment/enlightenment
We need id's for gadgets which are independent of shelves, so if we move
a gadget from one shelf to another it will keep the same config. Since the id is mainly for the module to find the appropriate config for a gadget, the module is now responsible for creating id's for gadgets config. One problem is that we no longer can trust the id of a gadget, so we need to store a reference between a gadget and its config after startup. No big deal. SVN revision: 31727
This commit is contained in:
parent
b285623bc0
commit
ac35054634
|
@ -1357,10 +1357,10 @@ e_config_init(void)
|
|||
cf_gc->name = evas_stringshare_add(_name); \
|
||||
cf_gc->id = evas_stringshare_add(_id); \
|
||||
e_config->gadcons = evas_list_append(e_config->gadcons, cf_gc)
|
||||
#define CFG_GADCON_CLIENT(_name, _id, _res, _size, _pos, _style, _autoscr, _resizable) \
|
||||
#define CFG_GADCON_CLIENT(_name, _res, _size, _pos, _style, _autoscr, _resizable) \
|
||||
cf_gcc = E_NEW(E_Config_Gadcon_Client, 1); \
|
||||
cf_gcc->name = evas_stringshare_add(_name); \
|
||||
cf_gcc->id = evas_stringshare_add(_id); \
|
||||
cf_gcc->id = NULL; \
|
||||
cf_gcc->geom.res = _res; \
|
||||
cf_gcc->geom.size = _size; \
|
||||
cf_gcc->geom.pos = _pos; \
|
||||
|
@ -1374,39 +1374,39 @@ e_config_init(void)
|
|||
|
||||
/* the default shelf on the default head/zone */
|
||||
CFG_GADCON("shelf", "0");
|
||||
CFG_GADCON_CLIENT("start", "0.start.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("start", 800, 32,
|
||||
0, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("pager", "0.pager.0", 800, 120,
|
||||
CFG_GADCON_CLIENT("pager", 800, 120,
|
||||
32, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("ibox", "0.ibox.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("ibox", 800, 32,
|
||||
32 + 120, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("ibar", "0.ibar.0", 800, 200,
|
||||
CFG_GADCON_CLIENT("ibar", 800, 200,
|
||||
(800 / 2) - (100 / 2), NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("temperature", "0.temperature.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("temperature", 800, 32,
|
||||
800 - 128, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("cpufreq", "0.cpufreq.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("cpufreq", 800, 32,
|
||||
800 - 96, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("battery", "0.battery.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("battery", 800, 32,
|
||||
800 - 64, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("clock", "0.clock.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("clock", 800, 32,
|
||||
800 - 32, NULL, 0, 0);
|
||||
/* additional shelves for up to 3 more heads by default */
|
||||
CFG_GADCON("shelf", "1");
|
||||
CFG_GADCON_CLIENT("pager", "1.pager.0", 800, 120,
|
||||
CFG_GADCON_CLIENT("pager", 800, 120,
|
||||
0, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("ibox", "1.ibox.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("ibox", 800, 32,
|
||||
800 - 32, NULL, 0, 0);
|
||||
|
||||
CFG_GADCON("shelf", "2");
|
||||
CFG_GADCON_CLIENT("pager", "2.pager.0", 800, 120,
|
||||
CFG_GADCON_CLIENT("pager", 800, 120,
|
||||
0, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("ibox", "2.ibox.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("ibox", 800, 32,
|
||||
800 - 32, NULL, 0, 0);
|
||||
|
||||
CFG_GADCON("shelf", "3");
|
||||
CFG_GADCON_CLIENT("pager", "3.pager.0", 800, 120,
|
||||
CFG_GADCON_CLIENT("pager", 800, 120,
|
||||
0, NULL, 0, 0);
|
||||
CFG_GADCON_CLIENT("ibox", "3.ibox.0", 800, 32,
|
||||
CFG_GADCON_CLIENT("ibox", 800, 32,
|
||||
800 - 32, NULL, 0, 0);
|
||||
}
|
||||
IFCFGEND;
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
|
||||
/*
|
||||
* TODO: gadcon client ordering on drop
|
||||
*/
|
||||
|
||||
static void _e_gadcon_free(E_Gadcon *gc);
|
||||
static void _e_gadcon_client_free(E_Gadcon_Client *gcc);
|
||||
|
||||
|
@ -56,6 +60,8 @@ static void e_gadcon_layout_pack_aspect_set(Evas_Object *obj, int w, int h);
|
|||
static void e_gadcon_layout_pack_aspect_pad_set(Evas_Object *obj, int w, int h);
|
||||
static void e_gadcon_layout_unpack(Evas_Object *obj);
|
||||
|
||||
static int _e_gadcon_client_class_version_check(E_Gadcon_Client_Class *cc);
|
||||
|
||||
/********************/
|
||||
#define E_LAYOUT_ITEM_DRAG_RESIST_LEVEL 10
|
||||
|
||||
|
@ -164,6 +170,11 @@ static Evas_Hash *providers = NULL;
|
|||
static Evas_List *providers_list = NULL;
|
||||
static Evas_List *gadcons = NULL;
|
||||
|
||||
/* This is the gadcon client which is currently dragged */
|
||||
static E_Gadcon_Client *drag_gcc = NULL;
|
||||
/* This is the gadcon client created on entering a new shelf */
|
||||
static E_Gadcon_Client *new_gcc = NULL;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
e_gadcon_init(void)
|
||||
|
@ -177,33 +188,6 @@ e_gadcon_shutdown(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
EAPI E_Config_Gadcon *
|
||||
e_gadcon_config_get(const char *name, const char *id)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Config_Gadcon *cf_gc = NULL;
|
||||
|
||||
if (!name) return NULL;
|
||||
|
||||
for (l = e_config->gadcons; l; l = l->next)
|
||||
{
|
||||
cf_gc = l->data;
|
||||
if ((!strcmp(cf_gc->name, name)) &&
|
||||
(!strcmp(cf_gc->id, id)))
|
||||
{
|
||||
return cf_gc;
|
||||
}
|
||||
}
|
||||
|
||||
cf_gc = E_NEW(E_Config_Gadcon, 1);
|
||||
if (!cf_gc) return NULL;
|
||||
cf_gc->name = evas_stringshare_add(name);
|
||||
cf_gc->id = evas_stringshare_add(id);
|
||||
e_config->gadcons = evas_list_append(e_config->gadcons, cf_gc);
|
||||
e_config_save_queue();
|
||||
return cf_gc;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_gadcon_provider_register(const E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
|
@ -253,15 +237,16 @@ e_gadcon_provider_list(void)
|
|||
}
|
||||
|
||||
EAPI E_Gadcon *
|
||||
e_gadcon_swallowed_new(const char *name, char *id, Evas_Object *obj, char *swallow_name)
|
||||
e_gadcon_swallowed_new(const char *name, const char *id, Evas_Object *obj, char *swallow_name)
|
||||
{
|
||||
E_Gadcon *gc;
|
||||
Evas_List *l;
|
||||
Evas_Coord x, y, w, h;
|
||||
const char *drop_types[] = { "enlightenment/gadcon_client" };
|
||||
|
||||
gc = E_OBJECT_ALLOC(E_Gadcon, E_GADCON_TYPE, _e_gadcon_free);
|
||||
if (!gc) return NULL;
|
||||
|
||||
|
||||
gc->name = evas_stringshare_add(name);
|
||||
gc->id = evas_stringshare_add(id);
|
||||
gc->layout_policy = E_GADCON_LAYOUT_POLICY_PANEL;
|
||||
|
@ -290,6 +275,27 @@ e_gadcon_swallowed_new(const char *name, char *id, Evas_Object *obj, char *swall
|
|||
edje_object_part_swallow(gc->edje.o_parent, gc->edje.swallow_name,
|
||||
gc->o_container);
|
||||
gadcons = evas_list_append(gadcons, gc);
|
||||
|
||||
for (l = e_config->gadcons; l; l = l->next)
|
||||
{
|
||||
E_Config_Gadcon *cf_gc;
|
||||
|
||||
cf_gc = l->data;
|
||||
if ((!strcmp(cf_gc->name, gc->name)) &&
|
||||
(!strcmp(cf_gc->id, gc->id)))
|
||||
{
|
||||
gc->cf = cf_gc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!gc->cf)
|
||||
{
|
||||
gc->cf = E_NEW(E_Config_Gadcon, 1);
|
||||
gc->cf->name = evas_stringshare_add(gc->name);
|
||||
gc->cf->id = evas_stringshare_add(gc->id);
|
||||
e_config->gadcons = evas_list_append(e_config->gadcons, gc->cf);
|
||||
e_config_save_queue();
|
||||
}
|
||||
return gc;
|
||||
}
|
||||
|
||||
|
@ -348,16 +354,13 @@ EAPI void
|
|||
e_gadcon_populate(E_Gadcon *gc)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Config_Gadcon *cf_gc;
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
|
||||
E_OBJECT_CHECK(gc);
|
||||
E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
|
||||
e_gadcon_layout_freeze(gc->o_container);
|
||||
cf_gc = e_gadcon_config_get(gc->name, gc->id);
|
||||
if (!cf_gc) return;
|
||||
for (l = cf_gc->clients; l; l = l->next)
|
||||
for (l = gc->cf->clients; l; l = l->next)
|
||||
{
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
E_Gadcon_Client_Class *cc;
|
||||
|
||||
cf_gcc = l->data;
|
||||
|
@ -367,6 +370,9 @@ e_gadcon_populate(E_Gadcon *gc)
|
|||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
|
||||
if ((!cf_gcc->id) && (_e_gadcon_client_class_version_check(cc)))
|
||||
cf_gcc->id = evas_stringshare_add(cc->func.id_new());
|
||||
|
||||
if (!cf_gcc->style)
|
||||
{
|
||||
gcc = cc->func.init(gc, cf_gcc->name, cf_gcc->id,
|
||||
|
@ -378,6 +384,7 @@ e_gadcon_populate(E_Gadcon *gc)
|
|||
|
||||
if (gcc)
|
||||
{
|
||||
gcc->cf = cf_gcc;
|
||||
gcc->client_class = cc;
|
||||
gcc->config.pos = cf_gcc->geom.pos;
|
||||
gcc->config.size = cf_gcc->geom.size;
|
||||
|
@ -427,16 +434,14 @@ EAPI void
|
|||
e_gadcon_populate_class(E_Gadcon *gc, const E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Config_Gadcon *cf_gc;
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
|
||||
E_OBJECT_CHECK(gc);
|
||||
E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
|
||||
e_gadcon_layout_freeze(gc->o_container);
|
||||
cf_gc = e_gadcon_config_get(gc->name, gc->id);
|
||||
if (!cf_gc) return;
|
||||
for (l = cf_gc->clients; l; l = l->next)
|
||||
for (l = gc->cf->clients; l; l = l->next)
|
||||
{
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
|
||||
cf_gcc = l->data;
|
||||
if ((cf_gcc->name) && (cc->name) &&
|
||||
(!strcmp(cf_gcc->name, cc->name)))
|
||||
|
@ -447,6 +452,7 @@ e_gadcon_populate_class(E_Gadcon *gc, const E_Gadcon_Client_Class *cc)
|
|||
cf_gcc->style);
|
||||
if (gcc)
|
||||
{
|
||||
gcc->cf = cf_gcc;
|
||||
gcc->client_class = cc;
|
||||
gcc->config.pos = cf_gcc->geom.pos;
|
||||
gcc->config.size = cf_gcc->geom.size;
|
||||
|
@ -668,93 +674,42 @@ e_gadcon_shelf_get(E_Gadcon *gc)
|
|||
EAPI E_Config_Gadcon_Client *
|
||||
e_gadcon_client_config_new(E_Gadcon *gc, const char *name)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Config_Gadcon *cf_gc;
|
||||
E_Gadcon_Client_Class *cc;
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
int id = 0;
|
||||
char buf[256];
|
||||
int ok;
|
||||
|
||||
E_OBJECT_CHECK_RETURN(gc, NULL);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
|
||||
if (!name) return NULL;
|
||||
|
||||
cf_gc = e_gadcon_config_get(gc->name, gc->id);
|
||||
if (!cf_gc) return NULL;
|
||||
do
|
||||
{
|
||||
ok = 1;
|
||||
snprintf(buf, sizeof(buf), "%s.%s.%i", cf_gc->id, name, id);
|
||||
for (l = cf_gc->clients; l; l = l->next)
|
||||
{
|
||||
cf_gcc = l->data;
|
||||
if (!strcmp(buf, cf_gcc->id))
|
||||
{
|
||||
ok = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
id++;
|
||||
}
|
||||
while (!ok);
|
||||
cc = evas_hash_find(providers, name);
|
||||
if (!cc) return NULL;
|
||||
if (!_e_gadcon_client_class_version_check(cc)) return NULL;
|
||||
|
||||
cf_gcc = E_NEW(E_Config_Gadcon_Client, 1);
|
||||
if (!cf_gcc) return NULL;
|
||||
cf_gcc->name = evas_stringshare_add(name);
|
||||
cf_gcc->id = evas_stringshare_add(buf);
|
||||
cf_gcc->id = evas_stringshare_add(cc->func.id_new());
|
||||
cf_gcc->geom.res = 800;
|
||||
cf_gcc->geom.size = 80;
|
||||
cf_gcc->geom.pos = cf_gcc->geom.res - cf_gcc->geom.size;
|
||||
cf_gcc->style = NULL;
|
||||
cf_gcc->autoscroll = 0;
|
||||
cf_gcc->resizable = 0;
|
||||
cf_gc->clients = evas_list_append(cf_gc->clients, cf_gcc);
|
||||
gc->cf->clients = evas_list_append(gc->cf->clients, cf_gcc);
|
||||
e_config_save_queue();
|
||||
return cf_gcc;
|
||||
}
|
||||
|
||||
EAPI E_Config_Gadcon_Client *
|
||||
e_gadcon_client_config_get(E_Gadcon *gc, const char *id)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Config_Gadcon *cf_gc = NULL;
|
||||
E_Config_Gadcon_Client *cf_gcc = NULL;
|
||||
|
||||
E_OBJECT_CHECK_RETURN(gc, NULL);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
|
||||
|
||||
cf_gc = e_gadcon_config_get(gc->name, gc->id);
|
||||
if (!cf_gc) return NULL;
|
||||
for (l = cf_gc->clients; l; l = l->next)
|
||||
{
|
||||
cf_gcc = l->data;
|
||||
if (!strcmp(cf_gcc->id, id))
|
||||
{
|
||||
return cf_gcc;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_gadcon_client_config_del(E_Gadcon *gc, const char *id)
|
||||
e_gadcon_client_config_del(E_Config_Gadcon *cf_gc, E_Config_Gadcon_Client *cf_gcc)
|
||||
{
|
||||
E_Config_Gadcon *cf_gc;
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
if (!cf_gcc) return;
|
||||
|
||||
cf_gc = e_gadcon_config_get(gc->name, gc->id);
|
||||
if (cf_gc)
|
||||
{
|
||||
cf_gcc = e_gadcon_client_config_get(gc, id);
|
||||
if (cf_gcc)
|
||||
{
|
||||
if (cf_gcc->name) evas_stringshare_del(cf_gcc->name);
|
||||
if (cf_gcc->id) evas_stringshare_del(cf_gcc->id);
|
||||
if (cf_gcc->style) evas_stringshare_del(cf_gcc->style);
|
||||
cf_gc->clients = evas_list_remove(cf_gc->clients, cf_gcc);
|
||||
free(cf_gcc);
|
||||
}
|
||||
}
|
||||
if (cf_gcc->name) evas_stringshare_del(cf_gcc->name);
|
||||
if (cf_gcc->id) evas_stringshare_del(cf_gcc->id);
|
||||
if (cf_gcc->style) evas_stringshare_del(cf_gcc->style);
|
||||
if (cf_gc) cf_gc->clients = evas_list_remove(cf_gc->clients, cf_gcc);
|
||||
free(cf_gcc);
|
||||
}
|
||||
|
||||
EAPI E_Gadcon_Client *
|
||||
|
@ -767,10 +722,11 @@ e_gadcon_client_new(E_Gadcon *gc, const char *name, const char *id, const char *
|
|||
gcc = E_OBJECT_ALLOC(E_Gadcon_Client, E_GADCON_CLIENT_TYPE, _e_gadcon_client_free);
|
||||
if (!gcc) return NULL;
|
||||
gcc->name = evas_stringshare_add(name);
|
||||
gcc->id = evas_stringshare_add(id);
|
||||
gcc->gadcon = gc;
|
||||
gcc->o_base = base_obj;
|
||||
gc->clients = evas_list_append(gc->clients, gcc);
|
||||
/* This must only be unique during runtime */
|
||||
gcc->id = E_GADCON_CLIENT(evas_list_last(gc->clients))->id + 1;
|
||||
if ((gc->frame_request.func) && (style))
|
||||
{
|
||||
gcc->o_frame = gc->frame_request.func(gc->frame_request.data, gcc, style);
|
||||
|
@ -1227,22 +1183,11 @@ _e_gadcon_client_cb_menu_remove(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
{
|
||||
E_Gadcon *gc;
|
||||
E_Gadcon_Client *gcc;
|
||||
E_Config_Gadcon *cf_gc;
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
|
||||
gcc = data;
|
||||
gc = gcc->gadcon;
|
||||
|
||||
cf_gc = e_gadcon_config_get(gcc->gadcon->name, gcc->gadcon->id);
|
||||
if (!cf_gc) return;
|
||||
cf_gcc = e_gadcon_client_config_get(gcc->gadcon, gcc->id);
|
||||
if (!cf_gcc) return;
|
||||
|
||||
if (cf_gcc->name) evas_stringshare_del(cf_gcc->name);
|
||||
if (cf_gcc->id) evas_stringshare_del(cf_gcc->id);
|
||||
if (cf_gcc->style) evas_stringshare_del(cf_gcc->style);
|
||||
free(cf_gcc);
|
||||
cf_gc->clients = evas_list_remove(cf_gc->clients, cf_gcc);
|
||||
e_gadcon_client_config_del(gc->cf, gcc->cf);
|
||||
e_gadcon_unpopulate(gc);
|
||||
e_gadcon_populate(gc);
|
||||
e_config_save_queue();
|
||||
|
@ -1378,22 +1323,6 @@ e_gadcon_client_util_menu_attach(E_Gadcon_Client *gcc)
|
|||
evas_object_event_callback_add(gcc->o_base, EVAS_CALLBACK_MOUSE_DOWN, _e_gadcon_client_cb_mouse_down, gcc);
|
||||
}
|
||||
|
||||
EAPI E_Gadcon_Client *
|
||||
e_gadcon_client_find(E_Gadcon *gc, const char *id)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = gc->clients; l; l = l->next)
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
|
||||
gcc = l->data;
|
||||
if ((gcc->id) && (!strcmp(id, gcc->id)))
|
||||
return gcc;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_gadcon_free(E_Gadcon *gc)
|
||||
|
@ -1424,7 +1353,6 @@ _e_gadcon_client_free(E_Gadcon_Client *gcc)
|
|||
if (gcc->o_box) evas_object_del(gcc->o_box);
|
||||
if (gcc->o_frame) evas_object_del(gcc->o_frame);
|
||||
evas_stringshare_del(gcc->name);
|
||||
evas_stringshare_del(gcc->id);
|
||||
if (gcc->scroll_timer) ecore_timer_del(gcc->scroll_timer);
|
||||
if (gcc->scroll_animator) ecore_animator_del(gcc->scroll_animator);
|
||||
if (gcc->style) evas_stringshare_del(gcc->style);
|
||||
|
@ -1565,25 +1493,17 @@ _e_gadcon_cb_client_frame_moveresize(void *data, Evas *e, Evas_Object *obj, void
|
|||
static void
|
||||
_e_gadcon_client_save(E_Gadcon_Client *gcc)
|
||||
{
|
||||
E_Config_Gadcon *cf_gc;
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
|
||||
cf_gc = e_gadcon_config_get(gcc->gadcon->name, gcc->gadcon->id);
|
||||
if (!cf_gc) return;
|
||||
cf_gcc = e_gadcon_client_config_get(gcc->gadcon, gcc->id);
|
||||
if (!cf_gcc) return;
|
||||
|
||||
cf_gcc->geom.pos = gcc->config.pos;
|
||||
cf_gcc->geom.size = gcc->config.size;
|
||||
cf_gcc->geom.res = gcc->config.res;
|
||||
cf_gcc->state_info.seq = gcc->state_info.seq;
|
||||
cf_gcc->state_info.flags = gcc->state_info.flags;
|
||||
cf_gcc->autoscroll = gcc->autoscroll;
|
||||
if (cf_gcc->style) evas_stringshare_del(cf_gcc->style);
|
||||
cf_gcc->style = NULL;
|
||||
gcc->cf->geom.pos = gcc->config.pos;
|
||||
gcc->cf->geom.size = gcc->config.size;
|
||||
gcc->cf->geom.res = gcc->config.res;
|
||||
gcc->cf->state_info.seq = gcc->state_info.seq;
|
||||
gcc->cf->state_info.flags = gcc->state_info.flags;
|
||||
gcc->cf->autoscroll = gcc->autoscroll;
|
||||
if (gcc->cf->style) evas_stringshare_del(gcc->cf->style);
|
||||
gcc->cf->style = NULL;
|
||||
if (gcc->style)
|
||||
cf_gcc->style = evas_stringshare_add(gcc->style);
|
||||
cf_gcc->resizable = gcc->resizable;
|
||||
gcc->cf->style = evas_stringshare_add(gcc->style);
|
||||
gcc->cf->resizable = gcc->resizable;
|
||||
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
@ -1596,17 +1516,16 @@ _e_gadcon_client_drag_begin(E_Gadcon_Client *gcc, int x, int y)
|
|||
Evas_Coord w, h;
|
||||
const char *drag_types[] = { "enlightenment/gadcon_client" };
|
||||
|
||||
drag_gcc = gcc;
|
||||
|
||||
e_object_ref(E_OBJECT(gcc));
|
||||
/* Delete the config, it will be recreated on drop */
|
||||
e_gadcon_client_config_del(gcc->gadcon, gcc->id);
|
||||
/* Remove this config from the current gadcon */
|
||||
gcc->gadcon->cf->clients = evas_list_remove(gcc->gadcon->cf->clients, gcc->cf);
|
||||
gcc->state_info.state = E_LAYOUT_ITEM_STATE_NONE;
|
||||
gcc->state_info.resist = 0;
|
||||
|
||||
if (!e_drop_inside(gcc->gadcon->drop_handler, x, y))
|
||||
e_gadcon_client_hide(gcc);
|
||||
/* Set id on gcc to something we can recognize later */
|
||||
evas_stringshare_del(gcc->id);
|
||||
gcc->id = evas_stringshare_add("drag");
|
||||
|
||||
drag = e_drag_new(gcc->gadcon->zone->container, gcc->drag.x, gcc->drag.y,
|
||||
drag_types, 1, gcc, -1, NULL, _e_gadcon_cb_drag_finished);
|
||||
|
@ -2116,12 +2035,22 @@ _e_gadcon_cb_drag_finished(E_Drag *drag, int dropped)
|
|||
E_Gadcon_Client *gcc;
|
||||
|
||||
gcc = drag->data;
|
||||
if (!strcmp(gcc->id, "drag"))
|
||||
if (!dropped)
|
||||
{
|
||||
/* This gadcon client was not dropped on the starting gadcon, delete it */
|
||||
/* free client config */
|
||||
e_gadcon_client_config_del(NULL, gcc->cf);
|
||||
/* delete the gadcon client */
|
||||
/* TODO: Clean up module config too? */
|
||||
e_object_del(E_OBJECT(gcc));
|
||||
}
|
||||
else if (new_gcc)
|
||||
{
|
||||
/* dropped on new gadcon, delete this one as it is no longer in use */
|
||||
e_object_del(E_OBJECT(gcc));
|
||||
}
|
||||
e_object_unref(E_OBJECT(gcc));
|
||||
new_gcc = NULL;
|
||||
drag_gcc = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2134,9 +2063,9 @@ _e_gadcon_cb_dnd_enter(void *data, const char *type, void *event)
|
|||
ev = event;
|
||||
gc = data;
|
||||
e_gadcon_layout_freeze(gc->o_container);
|
||||
gcc = drag_gcc;
|
||||
|
||||
gcc = e_gadcon_client_find(gc, "drag");
|
||||
if (gcc)
|
||||
if (gcc->gadcon == gc)
|
||||
{
|
||||
/* We have re-entered the gadcon we left, revive gadcon client */
|
||||
Evas_Coord dx, dy;
|
||||
|
@ -2162,7 +2091,6 @@ _e_gadcon_cb_dnd_enter(void *data, const char *type, void *event)
|
|||
else if (ev->data)
|
||||
{
|
||||
/* Create a new gadcon to show where the gadcon will end up */
|
||||
E_Gadcon_Client *gcc2;
|
||||
E_Gadcon_Client_Class *cc;
|
||||
|
||||
gcc = ev->data;
|
||||
|
@ -2171,31 +2099,32 @@ _e_gadcon_cb_dnd_enter(void *data, const char *type, void *event)
|
|||
{
|
||||
if (!gcc->style)
|
||||
{
|
||||
gcc2 = cc->func.init(gc, gcc->name, "new",
|
||||
new_gcc = cc->func.init(gc, gcc->name, gcc->cf->id,
|
||||
cc->default_style);
|
||||
}
|
||||
else
|
||||
gcc2 = cc->func.init(gc, gcc->name, "new",
|
||||
new_gcc = cc->func.init(gc, gcc->name, gcc->cf->id,
|
||||
gcc->style);
|
||||
|
||||
if (gcc2)
|
||||
if (new_gcc)
|
||||
{
|
||||
gcc2->client_class = cc;
|
||||
gcc2->config.pos = gcc->config.pos;
|
||||
gcc2->config.size = gcc->config.size;
|
||||
gcc2->config.res = gcc->config.res;
|
||||
gcc2->state_info.seq = gcc->state_info.seq;
|
||||
gcc2->state_info.flags = gcc->state_info.flags;
|
||||
if (gcc2->o_frame)
|
||||
e_gadcon_layout_pack_options_set(gcc2->o_frame, gcc2);
|
||||
new_gcc->cf = gcc->cf;
|
||||
new_gcc->client_class = cc;
|
||||
new_gcc->config.pos = gcc->config.pos;
|
||||
new_gcc->config.size = gcc->config.size;
|
||||
new_gcc->config.res = gcc->config.res;
|
||||
new_gcc->state_info.seq = gcc->state_info.seq;
|
||||
new_gcc->state_info.flags = gcc->state_info.flags;
|
||||
if (new_gcc->o_frame)
|
||||
e_gadcon_layout_pack_options_set(new_gcc->o_frame, new_gcc);
|
||||
else
|
||||
e_gadcon_layout_pack_options_set(gcc2->o_base, gcc2);
|
||||
e_gadcon_layout_pack_options_set(new_gcc->o_base, new_gcc);
|
||||
|
||||
e_gadcon_client_autoscroll_set(gcc2, gcc->autoscroll);
|
||||
e_gadcon_client_resizable_set(gcc2, gcc->resizable);
|
||||
if (gcc2->client_class->func.orient)
|
||||
gcc2->client_class->func.orient(gcc2);
|
||||
gcc2->state_info.resist = 1;
|
||||
e_gadcon_client_autoscroll_set(new_gcc, gcc->autoscroll);
|
||||
e_gadcon_client_resizable_set(new_gcc, gcc->resizable);
|
||||
if (new_gcc->client_class->func.orient)
|
||||
new_gcc->client_class->func.orient(new_gcc);
|
||||
new_gcc->state_info.resist = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2211,13 +2140,15 @@ _e_gadcon_cb_dnd_move(void *data, const char *type, void *event)
|
|||
{
|
||||
E_Event_Dnd_Move *ev;
|
||||
E_Gadcon *gc;
|
||||
E_Gadcon_Client *gcc;
|
||||
E_Gadcon_Client *gcc = NULL;
|
||||
|
||||
ev = event;
|
||||
gc = data;
|
||||
|
||||
gcc = e_gadcon_client_find(gc, "drag");
|
||||
if (!gcc) gcc = e_gadcon_client_find(gc, "new");
|
||||
/* If we move in the same gadcon as the client originates */
|
||||
if (drag_gcc->gadcon == gc) gcc = drag_gcc;
|
||||
/* If we move in the newly entered gadcon */
|
||||
else if (new_gcc->gadcon == gc) gcc = new_gcc;
|
||||
if (gcc)
|
||||
{
|
||||
Evas_Coord dx, dy;
|
||||
|
@ -2230,7 +2161,6 @@ _e_gadcon_cb_dnd_move(void *data, const char *type, void *event)
|
|||
}
|
||||
e_gadcon_layout_freeze(gc->o_container);
|
||||
|
||||
/* We have re-entered the gadcon we left, revive gadcon client */
|
||||
if (e_gadcon_layout_orientation_get(gc->o_container))
|
||||
gcc->config.pos = ev->x - gcc->config.size / 2;
|
||||
else
|
||||
|
@ -2254,18 +2184,19 @@ _e_gadcon_cb_dnd_leave(void *data, const char *type, void *event)
|
|||
{
|
||||
E_Event_Dnd_Leave *ev;
|
||||
E_Gadcon *gc;
|
||||
E_Gadcon_Client *gcc;
|
||||
|
||||
ev = event;
|
||||
gc = data;
|
||||
|
||||
/* If we exit the starting container hide the gadcon visual */
|
||||
gcc = e_gadcon_client_find(gc, "drag");
|
||||
if (gcc) e_gadcon_client_hide(gcc);
|
||||
if (drag_gcc->gadcon == gc) e_gadcon_client_hide(drag_gcc);
|
||||
|
||||
/* Delete temporary object */
|
||||
gcc = e_gadcon_client_find(gc, "new");
|
||||
if (gcc) e_object_del(E_OBJECT(gcc));
|
||||
if (new_gcc)
|
||||
{
|
||||
e_object_del(E_OBJECT(new_gcc));
|
||||
new_gcc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2273,20 +2204,14 @@ _e_gadcon_cb_drop(void *data, const char *type, void *event)
|
|||
{
|
||||
E_Event_Dnd_Drop *ev;
|
||||
E_Gadcon *gc;
|
||||
E_Gadcon_Client *gcc;
|
||||
|
||||
E_Config_Gadcon_Client *cf_gcc;
|
||||
E_Gadcon_Client *gcc = NULL;
|
||||
|
||||
ev = event;
|
||||
gc = data;
|
||||
gcc = e_gadcon_client_find(gc, "drag");
|
||||
if (!gcc) gcc = e_gadcon_client_find(gc, "new");
|
||||
if (!gcc) return;
|
||||
if (drag_gcc->gadcon == gc) gcc = drag_gcc;
|
||||
else if ((new_gcc) && (new_gcc->gadcon == gc)) gcc = new_gcc;
|
||||
|
||||
/* Create config for new gadcon client */
|
||||
cf_gcc = e_gadcon_client_config_new(gc, gcc->name);
|
||||
evas_stringshare_del(gcc->id);
|
||||
gcc->id = evas_stringshare_add(cf_gcc->id);
|
||||
gc->cf->clients = evas_list_append(gc->cf->clients, gcc->cf);
|
||||
|
||||
if (gc->editing) e_gadcon_client_edit_begin(gcc);
|
||||
e_config_save_queue();
|
||||
|
@ -4859,3 +4784,13 @@ _e_gadcon_layout_smart_restore_gadcons_position_before_move(E_Smart_Data *sd, E_
|
|||
lc->state = E_LAYOUT_ITEM_CONTAINER_STATE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_e_gadcon_client_class_version_check(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
if (cc->version == GADCON_CLIENT_CLASS_VERSION) return 1;
|
||||
e_util_dialog_show("Old module version",
|
||||
"Module %s is version %d, it must be<br>"
|
||||
"version %d to work with e17", cc->name, cc->version, GADCON_CLIENT_CLASS_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
#define E_GADCON_CLIENT(x) ((E_Gadcon_Client *)(x))
|
||||
|
||||
/* different layout policies - only 1 supported for now */
|
||||
typedef enum _E_Gadcon_Layout_Policy
|
||||
{
|
||||
|
@ -84,9 +86,11 @@ struct _E_Gadcon
|
|||
E_Shelf *shelf;
|
||||
|
||||
E_Drop_Handler *drop_handler;
|
||||
|
||||
E_Config_Gadcon *cf;
|
||||
};
|
||||
|
||||
#define GADCON_CLIENT_CLASS_VERSION 1
|
||||
#define GADCON_CLIENT_CLASS_VERSION 2
|
||||
struct _E_Gadcon_Client_Class
|
||||
{
|
||||
int version;
|
||||
|
@ -99,6 +103,11 @@ struct _E_Gadcon_Client_Class
|
|||
char *(*label) (void);
|
||||
Evas_Object *(*icon) (Evas *evas);
|
||||
/* All members below are part of version 2 */
|
||||
/* Create new id, so that the gadcon client can refer to a config set inside the module */
|
||||
const char *(*id_new) (void);
|
||||
/* Del an id when a gadcon client is removed from the system */
|
||||
void (*id_del) (const char *id);
|
||||
/* All members below are part of version 3 */
|
||||
} func;
|
||||
char *default_style;
|
||||
};
|
||||
|
@ -108,7 +117,7 @@ struct _E_Gadcon_Client
|
|||
E_Object e_obj_inherit;
|
||||
E_Gadcon *gadcon;
|
||||
const char *name;
|
||||
const char *id;
|
||||
int id;
|
||||
Evas_Object *o_base;
|
||||
Evas_Object *o_box;
|
||||
Evas_Object *o_frame;
|
||||
|
@ -153,15 +162,16 @@ struct _E_Gadcon_Client
|
|||
} drag;
|
||||
|
||||
unsigned char hidden : 1;
|
||||
|
||||
E_Config_Gadcon_Client *cf;
|
||||
};
|
||||
|
||||
EAPI int e_gadcon_init(void);
|
||||
EAPI int e_gadcon_shutdown(void);
|
||||
EAPI E_Config_Gadcon *e_gadcon_config_get(const char *name, const char *id);
|
||||
EAPI void e_gadcon_provider_register(const E_Gadcon_Client_Class *cc);
|
||||
EAPI void e_gadcon_provider_unregister(const E_Gadcon_Client_Class *cc);
|
||||
EAPI Evas_List *e_gadcon_provider_list(void);
|
||||
EAPI E_Gadcon *e_gadcon_swallowed_new(const char *name, char *id, Evas_Object *obj, char *swallow_name);
|
||||
EAPI E_Gadcon *e_gadcon_swallowed_new(const char *name, const char *id, Evas_Object *obj, char *swallow_name);
|
||||
EAPI void e_gadcon_swallowed_min_size_set(E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
|
||||
EAPI void e_gadcon_min_size_request_callback_set(E_Gadcon *gc, void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data);
|
||||
EAPI void e_gadcon_size_request_callback_set(E_Gadcon *gc, void (*func) (void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data);
|
||||
|
@ -186,8 +196,7 @@ EAPI void e_gadcon_shelf_set(E_Gadcon *gc, E_Shelf *shelf);
|
|||
EAPI E_Shelf *e_gadcon_shelf_get(E_Gadcon *gc);
|
||||
|
||||
EAPI E_Config_Gadcon_Client *e_gadcon_client_config_new(E_Gadcon *gc, const char *name);
|
||||
EAPI E_Config_Gadcon_Client *e_gadcon_client_config_get(E_Gadcon *gc, const char *id);
|
||||
EAPI void e_gadcon_client_config_del(E_Gadcon *gc, const char *id);
|
||||
EAPI void e_gadcon_client_config_del(E_Config_Gadcon *cf_gc, E_Config_Gadcon_Client *cf_gcc);
|
||||
EAPI E_Gadcon_Client *e_gadcon_client_new(E_Gadcon *gc, const char *name, const char *id, const char *style, Evas_Object *base_obj);
|
||||
EAPI void e_gadcon_client_edit_begin(E_Gadcon_Client *gcc);
|
||||
EAPI void e_gadcon_client_edit_end(E_Gadcon_Client *gcc);
|
||||
|
@ -205,7 +214,5 @@ EAPI int e_gadcon_client_geometry_get(E_Gadcon_Client *gcc, int *x, int *y
|
|||
EAPI void e_gadcon_client_util_menu_items_append(E_Gadcon_Client *gcc, E_Menu *menu, int flags);
|
||||
EAPI void e_gadcon_client_util_menu_attach(E_Gadcon_Client *gcc);
|
||||
|
||||
EAPI E_Gadcon_Client *e_gadcon_client_find(E_Gadcon *gc, const char *id);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -11,12 +11,13 @@ static void _load_available_gadgets(void *data);
|
|||
static void _load_selected_gadgets(void *data);
|
||||
static int _cb_mod_update(void *data, int type, void *event);
|
||||
|
||||
/* Actual config data we will be playing with whil the dialog is active */
|
||||
/* Actual config data we will be playing with while the dialog is active */
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
E_Gadcon *gc;
|
||||
char *name_add;
|
||||
char *id_remove;
|
||||
Evas_Hash *ids;
|
||||
Evas_Object *o_add, *o_remove, *o_instances, *o_avail;
|
||||
|
||||
E_Config_Gadcon *cf_gc;
|
||||
|
@ -51,9 +52,19 @@ e_int_gadcon_config(E_Gadcon *gc)
|
|||
static void
|
||||
_fill_data(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
cfdata->name_add = NULL;
|
||||
cfdata->id_remove = NULL;
|
||||
cfdata->cf_gc = e_gadcon_config_get(cfdata->gc->name, cfdata->gc->id);
|
||||
cfdata->cf_gc = cfdata->gc->cf;
|
||||
|
||||
for (l = cfdata->cf_gc->clients; l; l = l->next)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%p", l->data);
|
||||
cfdata->ids = evas_hash_add(cfdata->ids, buf, l->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void *
|
||||
|
@ -71,6 +82,7 @@ static void
|
|||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
cfdata->gc->config_dialog = NULL;
|
||||
evas_hash_free(cfdata->ids);
|
||||
if (cfdata->name_add) free(cfdata->name_add);
|
||||
if (cfdata->id_remove) free(cfdata->id_remove);
|
||||
if (cfdata->hdl) ecore_event_handler_del(cfdata->hdl);
|
||||
|
@ -103,7 +115,7 @@ _cb_add_instance(void *data, void *data2)
|
|||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
e_gadcon_client_config_new(cfdata->gc, cfdata->name_add);
|
||||
if (!e_gadcon_client_config_new(cfdata->gc, cfdata->name_add)) return;
|
||||
|
||||
e_gadcon_unpopulate(cfdata->gc);
|
||||
e_gadcon_populate(cfdata->gc);
|
||||
|
@ -123,7 +135,7 @@ _cb_remove_instance(void *data, void *data2)
|
|||
cfdata = data;
|
||||
i = e_widget_ilist_selected_get(cfdata->o_instances);
|
||||
|
||||
e_gadcon_client_config_del(cfdata->gc, cfdata->id_remove);
|
||||
e_gadcon_client_config_del(cfdata->cf_gc, evas_hash_find(cfdata->ids, cfdata->id_remove));
|
||||
|
||||
_load_selected_gadgets(cfdata);
|
||||
|
||||
|
@ -259,11 +271,14 @@ _load_selected_gadgets(void *data)
|
|||
if ((cc->name) && (cf_gcc->name) &&
|
||||
(!strcmp(cc->name, cf_gcc->name)))
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%p", cf_gcc);
|
||||
if (cc->func.label) label = cc->func.label();
|
||||
if (!label) label = cc->name;
|
||||
if (cc->func.icon) icon = cc->func.icon(evas);
|
||||
e_widget_ilist_append(oi, icon, label, _cb_select_client_instance,
|
||||
cfdata, cf_gcc->id);
|
||||
cfdata, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,13 +31,14 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"battery",
|
||||
{
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL
|
||||
},
|
||||
E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
@ -148,6 +149,13 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
return _gadcon_class.name;
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
@ -12,13 +12,14 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"clock",
|
||||
{
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL
|
||||
},
|
||||
E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
@ -102,6 +103,13 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
return _gadcon_class.name;
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
@ -17,13 +17,14 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"cpufreq",
|
||||
{
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL
|
||||
},
|
||||
E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
@ -141,6 +142,13 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
return _gadcon_class.name;
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ struct _Config
|
|||
/* saved * loaded config values */
|
||||
double poll_time;
|
||||
int restore_governor;
|
||||
const char *governor;
|
||||
const char *governor;
|
||||
/* just config state */
|
||||
E_Module *module;
|
||||
Evas_List *instances;
|
||||
|
|
|
@ -153,7 +153,7 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
if (cfdata->dir) ci->dir = evas_stringshare_add(cfdata->dir);
|
||||
ci->show_label = cfdata->show_label;
|
||||
ci->eap_label = cfdata->eap_label;
|
||||
_ibar_config_update();
|
||||
_ibar_config_update(ci);
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,15 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
static void _gc_id_del(const char *id);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"ibar",
|
||||
{
|
||||
_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_CLIENT_STYLE_INSET
|
||||
};
|
||||
|
@ -44,7 +46,7 @@ struct _Instance
|
|||
Evas_Object *o_ibar;
|
||||
IBar *ibar;
|
||||
E_Drop_Handler *drop_handler;
|
||||
const char *dir;
|
||||
Config_Item *ci;
|
||||
};
|
||||
|
||||
struct _IBar
|
||||
|
@ -58,8 +60,6 @@ struct _IBar
|
|||
int drop_before;
|
||||
E_Order *apps;
|
||||
Evas_List *icons;
|
||||
int show_label;
|
||||
int eap_label;
|
||||
Evas_Coord dnd_x, dnd_y;
|
||||
};
|
||||
|
||||
|
@ -80,7 +80,7 @@ struct _IBar_Icon
|
|||
} drag;
|
||||
};
|
||||
|
||||
static IBar *_ibar_new(Evas *evas, const char *dir);
|
||||
static IBar *_ibar_new(Evas *evas, Instance *inst);
|
||||
static void _ibar_free(IBar *b);
|
||||
static void _ibar_cb_empty_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _ibar_empty_handle(IBar *b);
|
||||
|
@ -137,13 +137,9 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst = E_NEW(Instance, 1);
|
||||
|
||||
ci = _ibar_config_item_get(id);
|
||||
inst->ci = ci;
|
||||
if (!ci->dir) ci->dir = evas_stringshare_add("default");
|
||||
inst->dir = evas_stringshare_add(ci->dir);
|
||||
b = _ibar_new(gc->evas, ci->dir);
|
||||
b->show_label = ci->show_label;
|
||||
b->eap_label = ci->eap_label;
|
||||
b->inst = inst;
|
||||
inst->ibar = b;
|
||||
b = _ibar_new(gc->evas, inst);
|
||||
o = b->o_box;
|
||||
gcc = e_gadcon_client_new(gc, name, id, style, o);
|
||||
gcc->data = inst;
|
||||
|
@ -171,7 +167,6 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
|||
Instance *inst;
|
||||
|
||||
inst = gcc->data;
|
||||
evas_stringshare_del(inst->dir);
|
||||
ibar_config->instances = evas_list_remove(ibar_config->instances, inst);
|
||||
e_drop_handler_del(inst->drop_handler);
|
||||
_ibar_free(inst->ibar);
|
||||
|
@ -231,6 +226,29 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = _ibar_config_item_get(NULL);
|
||||
return ci->id;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_id_del(const char *id)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = _ibar_config_item_get(id);
|
||||
if (ci)
|
||||
{
|
||||
if (ci->id) evas_stringshare_del(ci->id);
|
||||
ibar_config->items = evas_list_remove(ibar_config->items, ci);
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -238,25 +256,27 @@ _gc_icon(Evas *evas)
|
|||
/**/
|
||||
|
||||
static IBar *
|
||||
_ibar_new(Evas *evas, const char *dir)
|
||||
_ibar_new(Evas *evas, Instance *inst)
|
||||
{
|
||||
IBar *b;
|
||||
char buf[4096];
|
||||
|
||||
b = E_NEW(IBar, 1);
|
||||
inst->ibar = b;
|
||||
b->inst = inst;
|
||||
b->o_box = e_box_add(evas);
|
||||
e_box_homogenous_set(b->o_box, 1);
|
||||
e_box_orientation_set(b->o_box, 1);
|
||||
e_box_align_set(b->o_box, 0.5, 0.5);
|
||||
if (dir[0] != '/')
|
||||
if (inst->ci->dir[0] != '/')
|
||||
{
|
||||
const char *homedir;
|
||||
|
||||
homedir = e_user_homedir_get();
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, dir);
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->ci->dir);
|
||||
}
|
||||
else
|
||||
snprintf(buf, sizeof(buf), dir);
|
||||
snprintf(buf, sizeof(buf), inst->ci->dir);
|
||||
b->apps = e_order_new(buf);
|
||||
e_order_update_callback_set(b->apps, _ibar_cb_app_change, b);
|
||||
_ibar_fill(b);
|
||||
|
@ -431,23 +451,49 @@ _ibar_config_item_get(const char *id)
|
|||
{
|
||||
Evas_List *l;
|
||||
Config_Item *ci;
|
||||
|
||||
for (l = ibar_config->items; l; l = l->next)
|
||||
|
||||
if (!id)
|
||||
{
|
||||
ci = l->data;
|
||||
if ((ci->id) && (ci->dir) && (!strcmp(ci->id, id)))
|
||||
return ci;
|
||||
char buf[128];
|
||||
int num = 0;
|
||||
|
||||
/* Create id */
|
||||
if (ibar_config->items)
|
||||
{
|
||||
char *p;
|
||||
ci = evas_list_last(ibar_config->items)->data;
|
||||
p = strrchr(ci->id, '.');
|
||||
if (p) num = atoi(p + 1) + 1;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s.%d", _gadcon_class.name, num);
|
||||
|
||||
/* Create new config */
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(buf);
|
||||
ci->show_label = 1;
|
||||
ci->eap_label = 0;
|
||||
ibar_config->items = evas_list_append(ibar_config->items, ci);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Find old config, or reuse supplied id */
|
||||
for (l = ibar_config->items; l; l = l->next)
|
||||
{
|
||||
ci = l->data;
|
||||
if ((ci->id) && (ci->dir) && (!strcmp(ci->id, id)))
|
||||
return ci;
|
||||
}
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(id);
|
||||
ci->show_label = 1;
|
||||
ci->eap_label = 0;
|
||||
ibar_config->items = evas_list_append(ibar_config->items, ci);
|
||||
}
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(id);
|
||||
ci->show_label = 1;
|
||||
ci->eap_label = 0;
|
||||
ibar_config->items = evas_list_append(ibar_config->items, ci);
|
||||
return ci;
|
||||
}
|
||||
|
||||
void
|
||||
_ibar_config_update(void)
|
||||
_ibar_config_update(Config_Item *ci)
|
||||
{
|
||||
Evas_List *l;
|
||||
Evas_List *i;
|
||||
|
@ -455,35 +501,27 @@ _ibar_config_update(void)
|
|||
for (l = ibar_config->instances; l; l = l->next)
|
||||
{
|
||||
Instance *inst;
|
||||
Config_Item *ci;
|
||||
|
||||
char buf[4096];
|
||||
|
||||
inst = l->data;
|
||||
ci = _ibar_config_item_get(inst->gcc->id);
|
||||
if ((inst->dir) && (ci->dir) && (strcmp(ci->dir, inst->dir)))
|
||||
{
|
||||
char buf[4096];
|
||||
if (inst->ci != ci) continue;
|
||||
|
||||
evas_stringshare_del(inst->dir);
|
||||
inst->dir = evas_stringshare_add(ci->dir);
|
||||
_ibar_empty(inst->ibar);
|
||||
if (inst->ibar->apps)
|
||||
e_object_del(E_OBJECT(inst->ibar->apps));
|
||||
if (inst->dir[0] != '/')
|
||||
{
|
||||
const char *homedir;
|
||||
|
||||
homedir = e_user_homedir_get();
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->dir);
|
||||
}
|
||||
else
|
||||
snprintf(buf, sizeof(buf), inst->dir);
|
||||
inst->ibar->apps = e_order_new(buf);
|
||||
_ibar_fill(inst->ibar);
|
||||
_ibar_resize_handle(inst->ibar);
|
||||
_gc_orient(inst->gcc);
|
||||
_ibar_empty(inst->ibar);
|
||||
if (inst->ibar->apps)
|
||||
e_object_del(E_OBJECT(inst->ibar->apps));
|
||||
if (inst->ci->dir[0] != '/')
|
||||
{
|
||||
const char *homedir;
|
||||
|
||||
homedir = e_user_homedir_get();
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->ci->dir);
|
||||
}
|
||||
inst->ibar->show_label = ci->show_label;
|
||||
inst->ibar->eap_label = ci->eap_label;
|
||||
else
|
||||
snprintf(buf, sizeof(buf), inst->ci->dir);
|
||||
inst->ibar->apps = e_order_new(buf);
|
||||
_ibar_fill(inst->ibar);
|
||||
_ibar_resize_handle(inst->ibar);
|
||||
_gc_orient(inst->gcc);
|
||||
|
||||
for (i = inst->ibar->icons; i; i = i->next)
|
||||
{
|
||||
|
@ -589,7 +627,7 @@ _ibar_icon_fill(IBar_Icon *ic)
|
|||
evas_object_pass_events_set(ic->o_icon2, 1);
|
||||
evas_object_show(ic->o_icon2);
|
||||
|
||||
switch (ic->ibar->eap_label)
|
||||
switch (ic->ibar->inst->ci->eap_label)
|
||||
{
|
||||
case 0: /* Eap Name */
|
||||
edje_object_part_text_set(ic->o_holder, "e.text.label", ic->app->name);
|
||||
|
@ -679,11 +717,9 @@ static void
|
|||
_ibar_cb_menu_configuration(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
IBar *b;
|
||||
Config_Item *ci;
|
||||
|
||||
|
||||
b = data;
|
||||
ci = _ibar_config_item_get(b->inst->gcc->id);
|
||||
_config_ibar_module(ci);
|
||||
_config_ibar_module(b->inst->ci);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -714,7 +750,7 @@ _ibar_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
ev = event_info;
|
||||
ic = data;
|
||||
_ibar_icon_signal_emit(ic, "e,state,focused", "e");
|
||||
if (ic->ibar->show_label)
|
||||
if (ic->ibar->inst->ci->show_label)
|
||||
_ibar_icon_signal_emit(ic, "e,action,show,label", "e");
|
||||
}
|
||||
|
||||
|
@ -727,7 +763,7 @@ _ibar_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
ev = event_info;
|
||||
ic = data;
|
||||
_ibar_icon_signal_emit(ic, "e,state,unfocused", "e");
|
||||
if (ic->ibar->show_label)
|
||||
if (ic->ibar->inst->ci->show_label)
|
||||
_ibar_icon_signal_emit(ic, "e,action,hide,label", "e");
|
||||
}
|
||||
|
||||
|
@ -1222,19 +1258,6 @@ e_modapi_shutdown(E_Module *m)
|
|||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for (l = ibar_config->instances; l; l = l->next)
|
||||
{
|
||||
Instance *inst;
|
||||
Config_Item *ci;
|
||||
|
||||
inst = l->data;
|
||||
ci = _ibar_config_item_get(inst->gcc->id);
|
||||
if (ci->dir) evas_stringshare_del(ci->dir);
|
||||
/* FIXME: path should be recorded from setup */
|
||||
ci->dir = evas_stringshare_add(inst->dir);
|
||||
}
|
||||
e_config_domain_save("module.ibar", conf_edd, ibar_config);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ EAPI int e_modapi_save (E_Module *m);
|
|||
EAPI int e_modapi_info (E_Module *m);
|
||||
EAPI int e_modapi_about (E_Module *m);
|
||||
|
||||
void _ibar_config_update(void);
|
||||
void _ibar_config_update(Config_Item *ci);
|
||||
void _config_ibar_module(Config_Item *ci);
|
||||
extern Config *ibar_config;
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
ci->show_zone = cfdata->zone_policy;
|
||||
ci->show_desk = cfdata->desk_policy;
|
||||
|
||||
_ibox_config_update();
|
||||
_ibox_config_update(ci);
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -12,13 +12,15 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
static void _gc_id_del(const char *id);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"ibox",
|
||||
{
|
||||
_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_CLIENT_STYLE_INSET
|
||||
};
|
||||
|
@ -40,6 +42,7 @@ struct _Instance
|
|||
Evas_Object *o_ibox;
|
||||
IBox *ibox;
|
||||
E_Drop_Handler *drop_handler;
|
||||
Config_Item *ci;
|
||||
};
|
||||
|
||||
struct _IBox
|
||||
|
@ -52,10 +55,6 @@ struct _IBox
|
|||
IBox_Icon *ic_drop_before;
|
||||
int drop_before;
|
||||
Evas_List *icons;
|
||||
int show_label;
|
||||
int show_zone;
|
||||
int show_desk;
|
||||
int icon_label;
|
||||
E_Zone *zone;
|
||||
Evas_Coord dnd_x, dnd_y;
|
||||
};
|
||||
|
@ -140,16 +139,12 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst = E_NEW(Instance, 1);
|
||||
|
||||
ci = _ibox_config_item_get(id);
|
||||
inst->ci = ci;
|
||||
|
||||
b = _ibox_new(gc->evas, gc->zone);
|
||||
b->show_label = ci->show_label;
|
||||
b->show_zone = ci->show_zone;
|
||||
b->show_desk = ci->show_desk;
|
||||
b->icon_label = ci->icon_label;
|
||||
_ibox_fill(b);
|
||||
|
||||
b->inst = inst;
|
||||
inst->ibox = b;
|
||||
_ibox_fill(b);
|
||||
o = b->o_box;
|
||||
gcc = e_gadcon_client_new(gc, name, id, style, o);
|
||||
gcc->data = inst;
|
||||
|
@ -236,6 +231,29 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = _ibox_config_item_get(NULL);
|
||||
return ci->id;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_id_del(const char *id)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = _ibox_config_item_get(id);
|
||||
if (ci)
|
||||
{
|
||||
if (ci->id) evas_stringshare_del(ci->id);
|
||||
ibox_config->items = evas_list_remove(ibox_config->items, ci);
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -352,17 +370,17 @@ _ibox_fill(IBox *b)
|
|||
while ((bd = e_container_border_list_next(bl)))
|
||||
{
|
||||
ok = 0;
|
||||
if ((b->show_zone == 0) && (bd->iconic))
|
||||
if ((b->inst->ci->show_zone == 0) && (bd->iconic))
|
||||
{
|
||||
ok = 1;
|
||||
}
|
||||
else if((b->show_zone == 1) && (bd->iconic))
|
||||
else if((b->inst->ci->show_zone == 1) && (bd->iconic))
|
||||
{
|
||||
if ((b->show_desk == 0) && (bd->zone == b->zone))
|
||||
if ((b->inst->ci->show_desk == 0) && (bd->zone == b->zone))
|
||||
{
|
||||
ok = 1;
|
||||
}
|
||||
else if((b->show_desk == 1) && (bd->zone == b->zone) &&
|
||||
else if((b->inst->ci->show_desk == 1) && (bd->zone == b->zone) &&
|
||||
(bd->desk == e_desk_current_get(b->zone)))
|
||||
{
|
||||
ok = 1;
|
||||
|
@ -538,7 +556,7 @@ _ibox_icon_fill_label(IBox_Icon *ic)
|
|||
{
|
||||
char *label = NULL;
|
||||
|
||||
switch (ic->ibox->icon_label)
|
||||
switch (ic->ibox->inst->ci->icon_label)
|
||||
{
|
||||
case 0:
|
||||
label = ic->border->client.netwm.name;
|
||||
|
@ -594,18 +612,12 @@ _ibox_zone_find(E_Zone *zone)
|
|||
for (l = ibox_config->instances; l; l = l->next)
|
||||
{
|
||||
Instance *inst;
|
||||
Config_Item *ci;
|
||||
|
||||
inst = l->data;
|
||||
ci = _ibox_config_item_get(inst->gcc->id);
|
||||
if (!ci) continue;
|
||||
|
||||
if (ci->show_zone == 0)
|
||||
if (inst->ci->show_zone == 0)
|
||||
ibox = evas_list_append(ibox, inst->ibox);
|
||||
else if ((inst->ci->show_zone == 1) && (inst->ibox->zone == zone))
|
||||
ibox = evas_list_append(ibox, inst->ibox);
|
||||
else if (ci->show_zone == 1)
|
||||
{
|
||||
if (inst->ibox->zone == zone) ibox = evas_list_append(ibox, inst->ibox);
|
||||
}
|
||||
}
|
||||
return ibox;
|
||||
}
|
||||
|
@ -637,7 +649,7 @@ _ibox_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
ev = event_info;
|
||||
ic = data;
|
||||
_ibox_icon_signal_emit(ic, "e,state,focused", "e");
|
||||
if (ic->ibox->show_label)
|
||||
if (ic->ibox->inst->ci->show_label)
|
||||
{
|
||||
_ibox_icon_fill_label(ic);
|
||||
_ibox_icon_signal_emit(ic, "e,action,show,label", "e");
|
||||
|
@ -653,7 +665,7 @@ _ibox_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
ev = event_info;
|
||||
ic = data;
|
||||
_ibox_icon_signal_emit(ic, "e,state,unfocused", "e");
|
||||
if (ic->ibox->show_label)
|
||||
if (ic->ibox->inst->ci->show_label)
|
||||
_ibox_icon_signal_emit(ic, "e,action,hide,label", "e");
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1034,7 @@ _ibox_cb_event_border_add(void *data, int type, void *event)
|
|||
{
|
||||
b = l->data;
|
||||
if (_ibox_icon_find(b, ev->border)) continue;
|
||||
if ((b->show_desk) && (ev->border->desk != desk)) continue;
|
||||
if ((b->inst->ci->show_desk) && (ev->border->desk != desk)) continue;
|
||||
ic = _ibox_icon_new(b, ev->border);
|
||||
if (!ic) continue;
|
||||
b->icons = evas_list_append(b->icons, ic);
|
||||
|
@ -1084,7 +1096,7 @@ _ibox_cb_event_border_iconify(void *data, int type, void *event)
|
|||
{
|
||||
b = l->data;
|
||||
if (_ibox_icon_find(b, ev->border)) continue;
|
||||
if ((b->show_desk) && (ev->border->desk != desk)) continue;
|
||||
if ((b->inst->ci->show_desk) && (ev->border->desk != desk)) continue;
|
||||
ic = _ibox_icon_new(b, ev->border);
|
||||
if (!ic) continue;
|
||||
b->icons = evas_list_append(b->icons, ic);
|
||||
|
@ -1212,7 +1224,7 @@ _ibox_cb_event_desk_show(void *data, int type, void *event)
|
|||
for (l = ibox; l; l = l->next)
|
||||
{
|
||||
b = l->data;
|
||||
if (b->show_desk)
|
||||
if (b->inst->ci->show_desk)
|
||||
{
|
||||
_ibox_empty(b);
|
||||
_ibox_fill(b);
|
||||
|
@ -1232,39 +1244,61 @@ _ibox_config_item_get(const char *id)
|
|||
{
|
||||
Evas_List *l;
|
||||
Config_Item *ci;
|
||||
|
||||
for (l = ibox_config->items; l; l = l->next)
|
||||
if (!id)
|
||||
{
|
||||
ci = l->data;
|
||||
if ((ci->id) && (!strcmp(ci->id, id)))
|
||||
return ci;
|
||||
char buf[128];
|
||||
int num = 0;
|
||||
|
||||
/* Create id */
|
||||
if (ibox_config->items)
|
||||
{
|
||||
char *p;
|
||||
ci = evas_list_last(ibox_config->items)->data;
|
||||
p = strrchr(ci->id, '.');
|
||||
if (p) num = atoi(p + 1) + 1;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s.%d", _gadcon_class.name, num);
|
||||
|
||||
/* Create new config */
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(buf);
|
||||
ci->show_label = 0;
|
||||
ci->show_zone = 1;
|
||||
ci->show_desk = 0;
|
||||
ci->icon_label = 0;
|
||||
ibox_config->items = evas_list_append(ibox_config->items, ci);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Find old config, or reuse supplied id */
|
||||
for (l = ibox_config->items; l; l = l->next)
|
||||
{
|
||||
ci = l->data;
|
||||
if ((ci->id) && (!strcmp(ci->id, id)))
|
||||
return ci;
|
||||
}
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(id);
|
||||
ci->show_label = 0;
|
||||
ci->show_zone = 1;
|
||||
ci->show_desk = 0;
|
||||
ci->icon_label = 0;
|
||||
ibox_config->items = evas_list_append(ibox_config->items, ci);
|
||||
}
|
||||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(id);
|
||||
ci->show_label = 0;
|
||||
ci->show_zone = 1;
|
||||
ci->show_desk = 0;
|
||||
ci->icon_label = 0;
|
||||
ibox_config->items = evas_list_append(ibox_config->items, ci);
|
||||
return ci;
|
||||
}
|
||||
|
||||
void
|
||||
_ibox_config_update(void)
|
||||
_ibox_config_update(Config_Item *ci)
|
||||
{
|
||||
Evas_List *l;
|
||||
for (l = ibox_config->instances; l; l = l->next)
|
||||
{
|
||||
Instance *inst;
|
||||
Config_Item *ci;
|
||||
|
||||
inst = l->data;
|
||||
ci = _ibox_config_item_get(inst->gcc->id);
|
||||
inst->ibox->show_label = ci->show_label;
|
||||
inst->ibox->show_zone = ci->show_zone;
|
||||
inst->ibox->show_desk = ci->show_desk;
|
||||
inst->ibox->icon_label = ci->icon_label;
|
||||
|
||||
if (inst->ci != ci) continue;
|
||||
|
||||
_ibox_empty(inst->ibox);
|
||||
_ibox_fill(inst->ibox);
|
||||
_ibox_resize_handle(inst->ibox);
|
||||
|
@ -1281,13 +1315,12 @@ _ibox_cb_menu_configuration(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
Evas_List *l;
|
||||
|
||||
b = data;
|
||||
ci = _ibox_config_item_get(b->inst->gcc->id);
|
||||
for (l = ibox_config->config_dialog; l; l = l->next)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
|
||||
cfd = l->data;
|
||||
if (cfd->data == ci)
|
||||
if (cfd->data == b->inst->ci)
|
||||
{
|
||||
ok = 0;
|
||||
break;
|
||||
|
|
|
@ -34,7 +34,7 @@ EAPI int e_modapi_shutdown (E_Module *m);
|
|||
EAPI int e_modapi_save (E_Module *m);
|
||||
EAPI int e_modapi_about (E_Module *m);
|
||||
|
||||
void _ibox_config_update(void);
|
||||
void _ibox_config_update(Config_Item *ci);
|
||||
void _config_ibox_module(Config_Item *ci);
|
||||
extern Config *ibox_config;
|
||||
|
||||
|
|
|
@ -12,13 +12,14 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"pager",
|
||||
{
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL
|
||||
},
|
||||
E_GADCON_CLIENT_STYLE_INSET
|
||||
};
|
||||
|
@ -250,6 +251,13 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
return _gadcon_class.name;
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ struct _Config
|
|||
unsigned int drag_resist;
|
||||
unsigned int scale;
|
||||
unsigned char resize;
|
||||
Evas_List *items; /* FIXME: save/load this */
|
||||
/* just config state */
|
||||
E_Module *module;
|
||||
E_Config_Dialog *config_dialog;
|
||||
|
@ -43,12 +42,6 @@ struct _Config
|
|||
unsigned int flip_desk;
|
||||
};
|
||||
|
||||
struct _Config_Item
|
||||
{
|
||||
char *id;
|
||||
int zone_num;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init (E_Module *m);
|
||||
|
|
|
@ -12,13 +12,14 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"start",
|
||||
{
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
|
||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL
|
||||
},
|
||||
E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
@ -114,6 +115,13 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
return _gadcon_class.name;
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
@ -17,13 +17,15 @@ static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|||
static void _gc_orient(E_Gadcon_Client *gcc);
|
||||
static char *_gc_label(void);
|
||||
static Evas_Object *_gc_icon(Evas *evas);
|
||||
static const char *_gc_id_new(void);
|
||||
static void _gc_id_del(const char *id);
|
||||
/* and actually define the gadcon class that this module provides (just 1) */
|
||||
static const E_Gadcon_Client_Class _gadcon_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION,
|
||||
"temperature",
|
||||
{
|
||||
_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_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
@ -42,6 +44,7 @@ static void _temperature_face_level_set(Config_Face *inst, double level);
|
|||
static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
|
||||
static Evas_Bool _temperature_face_shutdown(Evas_Hash *hash, const char *key, void *hdata, void *fdata);
|
||||
static Evas_Bool _temperature_face_id_max(Evas_Hash *hash, const char *key, void *hdata, void *fdata);
|
||||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
static E_Config_DD *conf_face_edd = NULL;
|
||||
|
@ -59,7 +62,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
if (!inst)
|
||||
{
|
||||
inst = E_NEW(Config_Face, 1);
|
||||
temperature_config->faces = evas_hash_add(temperature_config->faces, id, inst);
|
||||
inst->id = evas_stringshare_add(id);
|
||||
inst->poll_time = 10.0;
|
||||
inst->low = 30;
|
||||
inst->high = 80;
|
||||
|
@ -67,7 +70,9 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst->sensor_name = NULL;
|
||||
inst->sensor_path = NULL;
|
||||
inst->units = CELCIUS;
|
||||
temperature_config->faces = evas_hash_direct_add(temperature_config->faces, inst->id, inst);
|
||||
}
|
||||
if (!inst->id) evas_stringshare_add(id);
|
||||
E_CONFIG_LIMIT(inst->poll_time, 0.5, 1000.0);
|
||||
E_CONFIG_LIMIT(inst->low, 0, 100);
|
||||
E_CONFIG_LIMIT(inst->high, 0, 220);
|
||||
|
@ -139,6 +144,45 @@ _gc_icon(Evas *evas)
|
|||
edje_object_file_set(o, buf, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(void)
|
||||
{
|
||||
Config_Face *inst;
|
||||
char id[128];
|
||||
int num = 0;
|
||||
|
||||
evas_hash_foreach(temperature_config->faces, _temperature_face_id_max, &num);
|
||||
snprintf(id, sizeof(id), "%s.%d", _gadcon_class.name, num + 1);
|
||||
|
||||
inst = E_NEW(Config_Face, 1);
|
||||
inst->id = evas_stringshare_add(id);
|
||||
inst->poll_time = 10.0;
|
||||
inst->low = 30;
|
||||
inst->high = 80;
|
||||
inst->sensor_type = SENSOR_TYPE_NONE;
|
||||
inst->sensor_name = NULL;
|
||||
inst->sensor_path = NULL;
|
||||
inst->units = CELCIUS;
|
||||
temperature_config->faces = evas_hash_direct_add(temperature_config->faces, inst->id, inst);
|
||||
return inst->id;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_id_del(const char *id)
|
||||
{
|
||||
Config_Face *inst;
|
||||
|
||||
inst = evas_hash_find(temperature_config->faces, id);
|
||||
if (inst)
|
||||
{
|
||||
temperature_config->faces = evas_hash_del(temperature_config->faces, id, inst);
|
||||
if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
|
||||
if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
|
||||
free(inst);
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -525,10 +569,25 @@ _temperature_face_shutdown(Evas_Hash *hash, const char *key, void *hdata, void *
|
|||
|
||||
if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
|
||||
if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
|
||||
if (inst->id) evas_stringshare_del(inst->id);
|
||||
free(inst);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Bool
|
||||
_temperature_face_id_max(Evas_Hash *hash, const char *key, void *hdata, void *fdata)
|
||||
{
|
||||
const char *p;
|
||||
int *max;
|
||||
int num = -1;
|
||||
|
||||
max = (int *)fdata;
|
||||
p = strrchr(key, '.');
|
||||
if (p) num = atoi(p + 1);
|
||||
if (num > *max) *max = num;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
temperature_face_update_config(Config_Face *inst)
|
||||
{
|
||||
|
@ -595,6 +654,7 @@ temperature_get_i2c_files()
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/**/
|
||||
/* module setup */
|
||||
|
@ -612,6 +672,7 @@ e_modapi_init(E_Module *m)
|
|||
#undef D
|
||||
#define T Config_Face
|
||||
#define D conf_face_edd
|
||||
E_CONFIG_VAL(D, T, id, STR);
|
||||
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
||||
E_CONFIG_VAL(D, T, low, INT);
|
||||
E_CONFIG_VAL(D, T, high, INT);
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef enum _Sensor_Type
|
|||
|
||||
struct _Config_Face
|
||||
{
|
||||
const char *id;
|
||||
/* saved * loaded config values */
|
||||
double poll_time;
|
||||
int low, high;
|
||||
|
|
Loading…
Reference in New Issue