entrance: pools are now sent seperated from the config

This commit is contained in:
Marcel Hollerbach 2014-05-14 09:51:20 +02:00
parent de2f271f03
commit a69be80762
11 changed files with 181 additions and 83 deletions

View File

@ -313,8 +313,6 @@ _entrance_conf_main_apply(void)
conf.bg.path = _entrance_int_conf_main->bg.path;
conf.bg.group = _entrance_int_conf_main->bg.group;
conf.background_pool = NULL;
conf.icon_pool = NULL;
conf.vkbd_enabled = _entrance_int_conf_main->vkbd_enabled;
if (_entrance_int_conf_main->scale != elm_config_scale_get())

View File

@ -345,7 +345,7 @@ _entrance_conf_user_build_cb(Evas_Object *t, Entrance_Login *eu)
IMG_LIST_FORK(entrance_gui_background_pool_get(), l);
IMG_LIST_FORK(entrance_gui_background_pool_get(), l);
IMG_LIST_FORK(entrance_gui_theme_backgrounds(), l);
IMG_LIST_FORK(eu->background_pool, l);
IMG_LIST_FORK(entrance_gui_user_background_pool_get(eu->login), l);
entrance_fill(gl, entrance_conf_background_fill_get(),
l, _entrance_conf_user_bg_fill_cb,
_entrance_conf_user_bg_sel, o);
@ -383,7 +383,7 @@ _entrance_conf_user_build_cb(Evas_Object *t, Entrance_Login *eu)
l = eina_list_append(NULL, img);
IMG_LIST_FORK(entrance_gui_icon_pool_get(), l);
IMG_LIST_FORK(entrance_gui_theme_icons(), l);
IMG_LIST_FORK(eu->icon_pool, l);
IMG_LIST_FORK(entrance_gui_user_icon_pool_get(eu->login), l);
entrance_fill(gl, entrance_conf_background_fill_get(),
l, _entrance_conf_user_icon_fill_cb,
_entrance_conf_user_icon_sel, o);

View File

@ -97,6 +97,11 @@ _entrance_connect_read_cb(const void *data, size_t size EINA_UNUSED, void *user_
PT("Gui conf received\n");
entrance_gui_conf_set(&(eev->event.conf_gui));
}
else if (eev->type == ENTRANCE_EVENT_POOLS)
{
PT("Pools received\n");
entrance_gui_pools_set(&(eev->event.pools));
}
else
{
PT("UNKNOW signal ");
@ -146,8 +151,6 @@ entrance_connect_conf_gui_send(Entrance_Conf_Gui_Event *ev)
PT("Send gui config\n");
eev.event.conf_gui.bg.path = ev->bg.path;
eev.event.conf_gui.bg.group = ev->bg.group;
eev.event.conf_gui.background_pool = NULL;
eev.event.conf_gui.icon_pool = NULL;
eev.type = ENTRANCE_EVENT_CONF_GUI;
entrance_event_send(&eev);
@ -165,8 +168,6 @@ entrance_connect_conf_user_send(Entrance_Login *el)
eev.event.conf_user.bg.path = el->bg.path;
eev.event.conf_user.bg.group = el->bg.group;
eev.event.conf_user.remember_session = el->remember_session;
eev.event.conf_user.icon_pool = NULL;
eev.event.conf_user.background_pool = NULL;
eev.type = ENTRANCE_EVENT_CONF_USER;
entrance_event_send(&eev);
}

View File

@ -38,6 +38,7 @@ struct Entrance_Gui_
Eina_List *actions;
Eina_List *background_pool;
Eina_List *icon_pool;
Eina_List *user_pools;
Eina_List *theme_background_pool;
Eina_List *theme_icon_pool;
Entrance_Xsession *selected_session;
@ -458,30 +459,6 @@ entrance_gui_xsessions_get(void)
void
entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf)
{
Entrance_Image *img;
if (conf->background_pool)
{
EINA_LIST_FREE(_gui->background_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
_gui->background_pool = conf->background_pool;
}
if (conf->icon_pool)
{
EINA_LIST_FREE(_gui->icon_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
_gui->icon_pool = conf->icon_pool;
}
if (_gui->bg.path != conf->bg.path)
{
if ((conf->bg.path) && (*conf->bg.path))
@ -514,6 +491,62 @@ entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf)
_gui->changed = ~(ENTRANCE_CONF_NONE);
_entrance_gui_update();
}
static Entrance_User_Pool*
_entrance_gui_user_pool_get(const char *name)
{
Eina_List *node;
Entrance_User_Pool *pool;
EINA_LIST_FOREACH(_gui->user_pools, node, pool)
{
if (!strcmp(pool->name, name))
{
return pool;
}
}
return NULL;
}
Eina_List*
entrance_gui_user_icon_pool_get(const char *name)
{
return _entrance_gui_user_pool_get(name)->icon_pool;
}
Eina_List*
entrance_gui_user_background_pool_get(const char *name)
{
return _entrance_gui_user_pool_get(name)->background_pool;
}
void
entrance_gui_pools_set(const Entrance_Pools *pool)
{
Entrance_Image *img;
EINA_LIST_FREE(_gui->background_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
_gui->background_pool = pool->background_pool;
EINA_LIST_FREE(_gui->icon_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
_gui->icon_pool = pool->icon_pool;
EINA_LIST_FREE(_gui->user_pools, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
_gui->user_pools = pool->user_pools;
}
void
entrance_gui_theme_name_set(const char *theme)
@ -691,19 +724,16 @@ _entrance_gui_user_icon_random_get(Evas_Object *obj, const char *username)
unsigned int rnd = 0;
Evas_Object *o = NULL;
Entrance_Image *img;
const Entrance_Login *el;
Eina_List *user_icons = NULL, *sys_icons = NULL, *theme_icons = NULL;
el = entrance_gui_user_get(username);
if (el)
user_icons = el->icon_pool;
user_icons = entrance_gui_user_icon_pool_get(username);
sys_icons = entrance_gui_icon_pool_get();
theme_icons = entrance_gui_theme_icons();
srand(time(NULL));
rnd = (((eina_list_count(user_icons) + eina_list_count(sys_icons) + eina_list_count(theme_icons))
* (double)rand()) / (RAND_MAX + 1.0));
if ((el) && (rnd < eina_list_count(user_icons)))
if ((rnd < eina_list_count(user_icons)))
{
o = elm_icon_add(obj);
img = eina_list_nth(user_icons, rnd);

View File

@ -30,6 +30,10 @@ const char *entrance_gui_theme_path_get(void);
void entrance_gui_user_bg_set(const char *path, const char *group);
Eina_List* entrance_gui_background_pool_get(void);
Eina_List* entrance_gui_icon_pool_get(void);
void entrance_gui_pools_set(const Entrance_Pools *pool);
Eina_List* entrance_gui_user_icon_pool_get(const char *name);
Eina_List* entrance_gui_user_background_pool_get(const char *name);
/*
char *entrance_gui_user_get();
char *entrance_gui_password_get();

View File

@ -245,8 +245,6 @@ _entrance_user_init(void)
}
}
eina_stringshare_del(user);
eu->icon_pool = entrance_image_user_icons(eu->login);
eu->background_pool = entrance_image_user_backgrounds(eu->login);
_lusers = eina_list_append(_lusers, eu);
}
}
@ -255,7 +253,6 @@ static void
_entrance_user_shutdown(void)
{
Entrance_Login *eu;
char *buf;
EINA_LIST_FREE(_lusers, eu)
{
if (!_entrance_history_match(eu->login))
@ -266,14 +263,6 @@ _entrance_user_shutdown(void)
eina_stringshare_del(eu->image.group);
eina_stringshare_del(eu->bg.path);
eina_stringshare_del(eu->bg.group);
EINA_LIST_FREE(eu->background_pool, buf)
{
eina_stringshare_del(buf);
}
EINA_LIST_FREE(eu->icon_pool, buf)
{
eina_stringshare_del(buf);
}
free(eu);
}
}

View File

@ -106,3 +106,46 @@ entrance_image_user_backgrounds(const char *username)
snprintf(path, sizeof(path),"%s/.config/entrance/images/backgrounds/", homedir);
return _entrance_image_get(_entrance_image_readdir(path), NULL, NULL);
}
Eina_List*
entrance_image_user_pool_get(Eina_List *users)
{
Eina_List *node, *result = NULL;
Entrance_Login *eu;
Entrance_User_Pool *pool;
EINA_LIST_FOREACH(users, node, eu)
{
pool = calloc(1, sizeof(Entrance_User_Pool));
pool->name = eina_stringshare_add(eu->login);
pool->icon_pool = entrance_image_user_icons(pool->name);
pool->background_pool = entrance_image_user_backgrounds(pool->name);
result = eina_list_append(result, pool);
}
return result;
}
void
entrance_image_user_pool_free(Eina_List *user_pool)
{
Entrance_User_Pool *pool;
Entrance_Image *img;
EINA_LIST_FREE(user_pool, pool)
{
eina_stringshare_del(pool->name);
EINA_LIST_FREE(pool->icon_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
EINA_LIST_FREE(pool->background_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
free(pool);
}
}

View File

@ -5,6 +5,7 @@ Eina_List* entrance_image_system_icons();
Eina_List* entrance_image_system_backgrounds();
Eina_List* entrance_image_user_icons(const char *username);
Eina_List* entrance_image_user_backgrounds(const char *username);
Eina_List* entrance_image_user_pool_get(Eina_List *users);
void entrance_image_user_pool_free(Eina_List *user_pool);
#endif /* ENTRANCE_H_ */

View File

@ -14,7 +14,6 @@ static Eina_Bool
_entrance_server_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
Entrance_Event eev;
Entrance_Image *img;
PT("server client connected\n");
PT("Sending users\n");
@ -40,22 +39,15 @@ _entrance_server_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event E
eev.event.conf_gui.enabled = EINA_TRUE;
eev.event.conf_gui.bg.path = entrance_config->bg.path;
eev.event.conf_gui.bg.group = entrance_config->bg.group;
eev.event.conf_gui.background_pool = entrance_image_system_backgrounds();
eev.event.conf_gui.icon_pool = entrance_image_system_icons();
entrance_event_send(&eev);
EINA_LIST_FREE(eev.event.conf_gui.background_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
EINA_LIST_FREE(eev.event.conf_gui.icon_pool, img)
{
eina_stringshare_del(img->path);
eina_stringshare_del(img->group);
free(img);
}
}
PT("Sending pools\n");
eev.type = ENTRANCE_EVENT_POOLS;
eev.event.pools.icon_pool = entrance_image_system_icons();
eev.event.pools.background_pool = entrance_image_system_backgrounds();
eev.event.pools.user_pools = entrance_image_user_pool_get(entrance_history_get());
entrance_event_send(&eev);
entrance_image_user_pool_free(eev.event.pools.user_pools);
return ECORE_CALLBACK_RENEW;
}

View File

@ -12,6 +12,7 @@
#define ENTRANCE_EVENT_ACTION_NAME "EntranceEventAction"
#define ENTRANCE_EVENT_CONF_GUI_NAME "EntranceEventConfGui"
#define ENTRANCE_EVENT_CONF_USER_NAME "EntranceEventConfUser"
#define ENTRANCE_EVENT_POOLS_NAME "EntranceEventPools"
static Eina_Bool _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow);
static const char *_entrance_event_type_get(const void *data, Eina_Bool *unknow);
@ -61,6 +62,8 @@ _entrance_event_type_set(const char *type, void *data, Eina_Bool unknow)
*ev = ENTRANCE_EVENT_ACTION;
else if (!strcmp(type, ENTRANCE_EVENT_CONF_GUI_NAME))
*ev = ENTRANCE_EVENT_CONF_GUI;
else if (!strcmp(type, ENTRANCE_EVENT_POOLS_NAME))
*ev = ENTRANCE_EVENT_POOLS;
else
{
printf("error on type set %s\n", type);
@ -92,6 +95,8 @@ _entrance_event_type_get(const void *data, Eina_Bool *unknow)
return ENTRANCE_EVENT_ACTION_NAME;
else if (*ev == ENTRANCE_EVENT_CONF_GUI)
return ENTRANCE_EVENT_CONF_GUI_NAME;
else if (*ev == ENTRANCE_EVENT_POOLS)
return ENTRANCE_EVENT_POOLS_NAME;
else
{
printf("error on type get %d\n", *ev);
@ -155,12 +160,11 @@ _entrance_event_maxtries_dd(void)
static Eet_Data_Descriptor *
_entrance_event_conf_gui_dd(void)
{
Eet_Data_Descriptor *edd, *eddi;
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc,
Entrance_Conf_Gui_Event);
edd = eet_data_descriptor_stream_new(&eddc);
eddi = _entrance_event_image_dd();
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "enabled",
enabled, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "bg.path",
@ -169,10 +173,6 @@ _entrance_event_conf_gui_dd(void)
bg.group, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_Conf_Gui_Event, "vkbd_enabled",
vkbd_enabled, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Conf_Gui_Event, "icon_pool",
icon_pool, eddi);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Conf_Gui_Event, "background_pool",
background_pool, eddi);
return edd;
}
@ -223,9 +223,8 @@ _entrance_event_users_dd(void)
static Eet_Data_Descriptor *
_entrance_event_conf_user_dd(Eina_Bool stream)
{
Eet_Data_Descriptor *edd, *eddi;
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
eddi = _entrance_event_image_dd();
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Login);
edd = eet_data_descriptor_stream_new(&eddc);
#define EET_LOGIN_ADD(NAME, TYPE) \
@ -238,14 +237,6 @@ _entrance_event_conf_user_dd(Eina_Bool stream)
EET_LOGIN_ADD(lsess, EET_T_STRING);
EET_LOGIN_ADD(remember_session, EET_T_INT);
// TODO screenshot
if (stream)
{
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Login, "icon_pool",
icon_pool, eddi);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Login, "background_pool",
background_pool, eddi);
}
#undef EET_LOGIN_ADD
return edd;
}
@ -279,6 +270,41 @@ _entrance_event_action_dd(void)
action, EET_T_UCHAR);
return edd;
}
static Eet_Data_Descriptor *
_entrance_event_user_pool_dd(void)
{
Eet_Data_Descriptor *edd, *eddi;
Eet_Data_Descriptor_Class eddc;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_User_Pool);
edd = eet_data_descriptor_stream_new(&eddc);
eddi = _entrance_event_image_dd();
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Entrance_User_Pool, "name",
name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_User_Pool, "icon_pool",
icon_pool, eddi);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_User_Pool, "background_pool",
background_pool, eddi);
return edd;
}
static Eet_Data_Descriptor *
_entrance_event_pools_dd(void)
{
Eet_Data_Descriptor *edd, *eddi, *eddup;
Eet_Data_Descriptor_Class eddc;
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entrance_Pools);
edd = eet_data_descriptor_stream_new(&eddc);
eddi = _entrance_event_image_dd();
eddup = _entrance_event_user_pool_dd();
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Pools, "icon_pool",
icon_pool, eddi);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Pools, "background_pool",
background_pool, eddi);
EET_DATA_DESCRIPTOR_ADD_LIST(edd, Entrance_Pools, "user_pools",
user_pools, eddup);
return edd;
}
static Eet_Data_Descriptor *
_entrance_event_new(void)
@ -313,6 +339,8 @@ _entrance_event_new(void)
_entrance_event_action_dd());
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_CONF_GUI_NAME,
_entrance_event_conf_gui_dd());
EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, ENTRANCE_EVENT_POOLS_NAME,
_entrance_event_pools_dd());
EET_DATA_DESCRIPTOR_ADD_UNION(edd, Entrance_Event, "event",
event, type, unified);

View File

@ -13,6 +13,7 @@ typedef enum Entrance_Event_Type_
ENTRANCE_EVENT_ACTION,
ENTRANCE_EVENT_MAXTRIES,
ENTRANCE_EVENT_CONF_GUI,
ENTRANCE_EVENT_POOLS
} Entrance_Event_Type;
typedef struct Entrance_Xsession_
@ -77,8 +78,6 @@ typedef struct Entrance_Conf_Gui_Event_
const char *path;
} bg;
Eina_Bool vkbd_enabled;
Eina_List *background_pool;
Eina_List *icon_pool;
} Entrance_Conf_Gui_Event;
@ -95,9 +94,21 @@ typedef struct Entrance_Login_
Entrance_Image bg;
Entrance_Image image;
Eina_Bool remember_session;
} Entrance_Login;
typedef struct Entrance_User_Pool_
{
const char *name;
Eina_List *icon_pool;
Eina_List *background_pool;
} Entrance_Login;
} Entrance_User_Pool;
typedef struct Entrance_Pools_
{
Eina_List *icon_pool;
Eina_List *background_pool;
Eina_List *user_pools;
} Entrance_Pools;
typedef struct Entrance_Event_
{
@ -113,6 +124,7 @@ typedef struct Entrance_Event_
Entrance_Actions_Event actions;
Entrance_Action_Event action;
Entrance_Conf_Gui_Event conf_gui;
Entrance_Pools pools;
} event;
} Entrance_Event;