From 1df4d95c892601634a36dfc3c83177421ef1a14c Mon Sep 17 00:00:00 2001 From: Michael Bouchaud Date: Wed, 8 Jan 2014 22:27:10 +0100 Subject: [PATCH] entrance: fill config panel --- src/bin/entrance_conf.c | 169 ++++++++++++++++++++++++++++++++-------- 1 file changed, 135 insertions(+), 34 deletions(-) diff --git a/src/bin/entrance_conf.c b/src/bin/entrance_conf.c index 15386ce..72f0e83 100644 --- a/src/bin/entrance_conf.c +++ b/src/bin/entrance_conf.c @@ -54,13 +54,15 @@ static Evas_Object *_entrance_conf_bg_content_get(void *data, Evas_Object *obj, static Eina_Bool _entrance_conf_bg_state_get(void *data, Evas_Object *obj, const char *part); static void _entrance_conf_bg_sel(void *data, Evas_Object *obj, void *event_info); static Eina_Bool _entrance_conf_bg_fill_cb(void *data, Elm_Object_Item *it); +static Eina_Bool _entrance_conf_user_bg_fill_cb(void *data, Elm_Object_Item *it); static void _entrance_conf_user_bg_sel(void *data, Evas_Object *obj, void *event_info); static void _entrance_conf_changed(); static void _entrance_conf_apply(); static Evas_Object *_entrance_conf_user_build(Evas_Object *obj); -static void _entrance_conf_user_build_cb(Evas_Object *t, const char *user); +static void _entrance_conf_user_build_cb(Evas_Object *t, Entrance_Login *eu); static Entrance_Fill *_entrance_background_fill = NULL; +static Entrance_Fill *_entrance_session_fill = NULL; static Entrance_Int_Conf *_entrance_int_conf = NULL; static char * @@ -159,6 +161,50 @@ _entrance_conf_user_bg_sel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, _entrance_conf_changed(); } +static Eina_Bool +_entrance_conf_user_bg_fill_cb(void *data, Elm_Object_Item *it) +{ + Entrance_Conf_Background *cbg; + const char *bg_path, *bg_group; + cbg = data; + + bg_path = _entrance_int_conf->user.orig->bg.path; + bg_group = _entrance_int_conf->user.orig->bg.group; + if ((cbg->path) + && (cbg->group) + && (bg_path) + && (bg_group) + && (!strcmp(cbg->path, bg_path)) + && (!strcmp(cbg->group, bg_group))) + { + elm_genlist_item_selected_set(it, EINA_TRUE); + return EINA_TRUE; + } + return EINA_FALSE; +} +static char * +_entrance_conf_session_text_get(void *data, Evas_Object *obj, const char *part) +{ + return NULL; +} + +static Evas_Object * +_entrance_conf_session_content_get(void *data, Evas_Object *obj, const char *part) +{ + return NULL; +} + +static Eina_Bool +_entrance_conf_session_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) +{ + return EINA_FALSE; +} + +static void +_entrance_conf_session_del(void *data, Evas_Object *obj EINA_UNUSED) +{ +} + /* vkbd */ static void _entrance_conf_vkbd_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event EINA_UNUSED) @@ -282,6 +328,7 @@ _entrance_conf_apply() { elm_config_scale_set(_entrance_int_conf->scale); elm_config_all_flush(); + elm_config_save(); } if (_entrance_int_conf->theme != entrance_gui_theme_name_get()) { @@ -289,6 +336,37 @@ _entrance_conf_apply() } entrance_gui_conf_set(&conf); entrance_connect_conf_send(&conf); + + if (_entrance_int_conf->user.orig) + { + Entrance_Login *eu; + eu = _entrance_int_conf->user.orig; + if (eu->bg.path != _entrance_int_conf->user.bg.path) + eina_stringshare_replace(&eu->bg.path, + _entrance_int_conf->user.bg.path); + if (eu->bg.group != _entrance_int_conf->user.bg.group) + eina_stringshare_replace(&eu->bg.group, + _entrance_int_conf->user.bg.group); + if (eu->image.path != _entrance_int_conf->user.image.path) + eina_stringshare_replace(&eu->image.path, + _entrance_int_conf->user.image.path); + if (eu->image.group != _entrance_int_conf->user.image.group) + eina_stringshare_replace(&eu->image.group, + _entrance_int_conf->user.image.group); + if (eu->remember_session != _entrance_int_conf->user.remember_session) + eu->remember_session = _entrance_int_conf->user.remember_session; + if (eu->lsess != _entrance_int_conf->user.lsess) + eina_stringshare_replace(&eu->lsess, _entrance_int_conf->user.lsess); + /* + printf("%s | %s\n%s | %s\n%s | %s\n%s | %s\n%d | %d\n%s | %s\n", + eu->bg.path, _entrance_int_conf->user.bg.path, + eu->bg.group, _entrance_int_conf->user.bg.group, + eu->image.path, _entrance_int_conf->user.image.path, + eu->image.group, _entrance_int_conf->user.image.group, + eu->remember_session, _entrance_int_conf->user.remember_session, + eu->lsess, _entrance_int_conf->user.lsess); + */ + } } /* Build it */ @@ -377,7 +455,7 @@ _entrance_conf_build(Evas_Object *obj) evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_table_pack(t, o, 0, j, 1, 1); evas_object_show(o); - o = elm_button_add(t); + o = elm_hoversel_add(t); elm_object_text_set(o, _entrance_int_conf->elm_profile); evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0); evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -419,11 +497,40 @@ static void _entrance_conf_user_auth(void *data, const char *user, Eina_Bool granted) { Evas_Object *t; + const Eina_List *users, *l; + Entrance_Login *eu; + if (granted) { t = elm_object_part_content_get(data, "entrance.conf"); - _entrance_conf_user_build_cb(t, user); - elm_object_signal_emit(data, "entrance,conf_user,enabled", ""); + users = entrance_gui_users_get(); + EINA_LIST_FOREACH(users, l, eu) + { + if (!strcmp(eu->login, user)) + { + _entrance_int_conf->user.orig = eu; + _entrance_int_conf->user.bg.path = eu->bg.path; + _entrance_int_conf->user.bg.group = eu->bg.group; + _entrance_int_conf->user.image.path = eu->image.path; + _entrance_int_conf->user.image.group = eu->image.group; + _entrance_int_conf->user.lsess = eu->lsess; + _entrance_int_conf->user.remember_session + = eu->remember_session; + printf("init %s %s | %s %s | %s | %d\n", + _entrance_int_conf->user.bg.path, + _entrance_int_conf->user.bg.group, + _entrance_int_conf->user.image.path, + _entrance_int_conf->user.image.group, + _entrance_int_conf->user.lsess, + _entrance_int_conf->user.remember_session); + break; + } + } + if (eu) + { + _entrance_conf_user_build_cb(t, eu); + elm_object_signal_emit(data, "entrance,conf_user,enabled", ""); + } } } @@ -449,12 +556,10 @@ _entrance_conf_user_build(Evas_Object *obj) } static void -_entrance_conf_user_build_cb(Evas_Object *t, const char *user) +_entrance_conf_user_build_cb(Evas_Object *t, Entrance_Login *eu) { - Evas_Object *o, *bx, *hbx; - Entrance_Login *eu; + Evas_Object *o, *gl, *bx, *hbx; Eina_List *l; - const Eina_List *users, *ll; int j = 0; /* Background */ @@ -471,16 +576,12 @@ _entrance_conf_user_build_cb(Evas_Object *t, const char *user) ++j; evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL); - o = elm_genlist_add(hbx); - elm_scroller_bounce_set(o, EINA_FALSE, EINA_TRUE); - evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); - l = _entrance_conf_backgrounds_get(o, user); - entrance_fill(o, _entrance_background_fill, - l, NULL, _entrance_conf_user_bg_sel, o); - eina_list_free(l); - elm_box_pack_end(hbx, o); - evas_object_show(o); + gl = elm_genlist_add(hbx); + elm_scroller_bounce_set(gl, EINA_FALSE, EINA_TRUE); + evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(hbx, gl); + evas_object_show(gl); bx = elm_box_add(hbx); elm_box_pack_end(hbx, bx); evas_object_show(bx); @@ -496,6 +597,11 @@ _entrance_conf_user_build_cb(Evas_Object *t, const char *user) elm_box_pack_end(bx, o); evas_object_show(o); evas_object_show(hbx); + l = _entrance_conf_backgrounds_get(o, eu->login); + entrance_fill(gl, _entrance_background_fill, + l, _entrance_conf_user_bg_fill_cb, + _entrance_conf_user_bg_sel, o); + eina_list_free(l); /* Icon */ @@ -529,23 +635,9 @@ _entrance_conf_user_build_cb(Evas_Object *t, const char *user) ++j; evas_object_show(t); - - users = entrance_gui_users_get(); - EINA_LIST_FOREACH(users, ll, eu) - { - if (!strcmp(eu->login, user)) - { - _entrance_int_conf->user.orig = eu; - _entrance_int_conf->user.bg.path = eu->bg.path; - _entrance_int_conf->user.bg.group = eu->bg.group; - _entrance_int_conf->user.image.path = eu->image.path; - _entrance_int_conf->user.image.group = eu->image.group; - break; - } - - } } + static void _entrance_conf_control_changed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event) { @@ -572,10 +664,11 @@ _entrance_conf_changed(void) || (_entrance_int_conf->elm_profile != elm_config_profile_get()) || (_entrance_int_conf->vkbd_enabled != entrance_gui_vkbd_enabled_get())) || ((_entrance_int_conf->user.orig) && + ((_entrance_int_conf->user.orig->bg.path != _entrance_int_conf->user.bg.path) || (_entrance_int_conf->user.orig->bg.group != _entrance_int_conf->user.bg.group) || (_entrance_int_conf->user.orig->image.path != _entrance_int_conf->user.image.path) - || (_entrance_int_conf->user.orig->image.path != _entrance_int_conf->user.image.group) + || (_entrance_int_conf->user.orig->image.group != _entrance_int_conf->user.image.group) || (_entrance_int_conf->user.orig->remember_session != _entrance_int_conf->user.remember_session) || (_entrance_int_conf->user.orig->lsess != _entrance_int_conf->user.lsess)))) @@ -601,6 +694,13 @@ _entrance_conf_init(void) _entrance_conf_bg_content_get, _entrance_conf_bg_state_get, _entrance_conf_bg_del); + _entrance_session_fill = + entrance_fill_new("default", + _entrance_conf_session_text_get, + _entrance_conf_session_content_get, + _entrance_conf_session_state_get, + _entrance_conf_session_del); + _entrance_int_conf = calloc(1, sizeof(Entrance_Int_Conf)); _entrance_int_conf->theme = entrance_gui_theme_name_get(); entrance_gui_background_get(&(_entrance_int_conf->bg.path), @@ -615,6 +715,7 @@ _entrance_conf_shutdown(void) { PT("conf shutdown\n"); entrance_fill_del(_entrance_background_fill); + entrance_fill_del(_entrance_session_fill); free(_entrance_int_conf); }