2012-08-09 13:15:30 -07:00
|
|
|
#include "entrance_client.h"
|
|
|
|
#include "Ecore_X.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct Entrance_Gui_ Entrance_Gui;
|
|
|
|
typedef struct Entrance_Screen_ Entrance_Screen;
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
static Eina_Bool _entrance_gui_cb_window_property(void *data, int type, void *event_info);
|
|
|
|
static void _entrance_gui_user_sel_cb(void *data, Evas_Object *obj, void *event_info);
|
|
|
|
static char *_entrance_gui_user_text_get(void *data, Evas_Object *obj, const char *part);
|
|
|
|
static Evas_Object *_entrance_gui_user_content_get(void *data, Evas_Object *obj, const char *part);
|
|
|
|
static Eina_Bool _entrance_gui_user_state_get(void *data, Evas_Object *obj, const char *part);
|
|
|
|
static void _entrance_gui_user_del(void *data, Evas_Object *obj);
|
|
|
|
static void _entrance_gui_actions_populate();
|
|
|
|
static void _entrance_gui_conf_clicked_cb(void *data, Evas_Object *obj, void *event_info);
|
|
|
|
static void _entrance_gui_update(void);
|
2013-10-29 11:26:56 -07:00
|
|
|
static void _entrance_gui_auth_cb(void *data, const char *user, Eina_Bool granted);
|
2014-01-08 15:09:31 -08:00
|
|
|
static void _entrance_gui_user_bg_cb(void *data, Evas_Object *obj, const char *sig, const char *src);
|
2014-03-06 05:09:37 -08:00
|
|
|
static Eina_List* _entrance_gui_theme_icons_cache_fill(Evas_Object *obj, const char *themename);
|
|
|
|
static Eina_List* _entrance_gui_theme_background_cache_fill(Evas_Object *obj, const char *themename);
|
2013-09-03 11:08:37 -07:00
|
|
|
|
|
|
|
static Entrance_Gui *_gui;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ENTRANCE_CONF_NONE = 0,
|
|
|
|
ENTRANCE_CONF_STATE = (1 << 0),
|
|
|
|
ENTRANCE_CONF_WALLPAPER = (1 << 1),
|
|
|
|
ENTRANCE_CONF_VKBD = (1 << 2)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-09 13:15:30 -07:00
|
|
|
struct Entrance_Gui_
|
|
|
|
{
|
2013-09-03 11:08:37 -07:00
|
|
|
Evas_Object *win;
|
2012-08-09 13:15:30 -07:00
|
|
|
Eina_List *screens;
|
|
|
|
Eina_List *xsessions;
|
|
|
|
Eina_List *users;
|
|
|
|
Eina_List *actions;
|
2014-03-06 05:09:37 -08:00
|
|
|
Eina_List *background_pool;
|
|
|
|
Eina_List *icon_pool;
|
|
|
|
Eina_List *theme_background_pool;
|
|
|
|
Eina_List *theme_icon_pool;
|
2012-08-09 13:15:30 -07:00
|
|
|
Entrance_Xsession *selected_session;
|
2014-03-06 16:49:32 -08:00
|
|
|
Ecore_Event_Handler *handler;
|
2012-08-09 13:15:30 -07:00
|
|
|
const char *theme;
|
2013-09-03 11:08:37 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
const char *group;
|
|
|
|
} bg;
|
|
|
|
unsigned char changed;
|
|
|
|
Eina_Bool conf_enabled : 1;
|
|
|
|
Eina_Bool vkbd_enabled : 1;
|
2014-03-06 16:49:32 -08:00
|
|
|
|
2012-08-09 13:15:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Entrance_Screen_
|
|
|
|
{
|
|
|
|
Evas_Object *edj;
|
2013-09-03 11:08:37 -07:00
|
|
|
Evas_Object *background;
|
|
|
|
Evas_Object *transition;
|
|
|
|
Evas_Object *login;
|
|
|
|
Eina_Bool focused:1;
|
2012-08-09 13:15:30 -07:00
|
|
|
Eina_Bool managed:1;
|
|
|
|
};
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
int
|
|
|
|
entrance_gui_init(const char *theme)
|
|
|
|
{
|
2012-09-03 15:56:53 -07:00
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
Ecore_X_Window xw;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
int i, j;
|
|
|
|
int x, y, w, h;
|
|
|
|
int ww = 0, hh = 0;
|
2012-09-03 15:56:53 -07:00
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
PT("Gui init: ");
|
|
|
|
fprintf(stderr, "%s\n", theme);
|
|
|
|
_gui = calloc(1, sizeof(Entrance_Gui));
|
|
|
|
if (!_gui)
|
|
|
|
{
|
|
|
|
PT("Not Enough memory\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
_gui->theme = eina_stringshare_add(theme);
|
2012-09-03 15:56:53 -07:00
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
#ifdef XNEST_DEBUG
|
|
|
|
char *tmp = getenv("DISPLAY");
|
|
|
|
if (tmp && *tmp)
|
|
|
|
{
|
|
|
|
PT("client Using display name");
|
|
|
|
fprintf(stderr, " %s\n", tmp);
|
|
|
|
}
|
|
|
|
#endif
|
2012-08-09 13:15:30 -07:00
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
i = ecore_x_xinerama_screen_count_get();
|
|
|
|
if (i < 1) i = 1;
|
|
|
|
_gui->win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
|
|
|
|
elm_win_fullscreen_set(_gui->win, EINA_TRUE);
|
|
|
|
elm_win_title_set(_gui->win, PACKAGE);
|
|
|
|
for(j = 0; j < i; ++j)
|
|
|
|
{
|
|
|
|
Evas_Object *o, *ol;
|
|
|
|
screen = calloc(1, sizeof(Entrance_Screen));
|
|
|
|
if (!screen) return 1;
|
2012-08-09 13:15:30 -07:00
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
/* layout */
|
|
|
|
o = entrance_gui_theme_get(_gui->win, "entrance/wallpaper/default");
|
|
|
|
screen->transition = o;
|
2014-01-08 13:27:54 -08:00
|
|
|
elm_object_signal_callback_add(o, "entrance,wallpaper,end", "",
|
|
|
|
_entrance_gui_user_bg_cb, screen);
|
2013-09-03 11:08:37 -07:00
|
|
|
ol = entrance_gui_theme_get(_gui->win, "entrance");
|
|
|
|
screen->edj = ol;
|
|
|
|
if (!ol)
|
|
|
|
{
|
|
|
|
PT("Tut Tut Tut no theme");
|
|
|
|
fprintf(stderr, "%s\n", "entrance");
|
|
|
|
return j;
|
|
|
|
}
|
2013-09-03 17:10:38 -07:00
|
|
|
elm_object_part_content_set(o, "entrance.screen", ol);
|
|
|
|
o = entrance_login_add(ol, _entrance_gui_auth_cb, screen);
|
2013-09-03 11:08:37 -07:00
|
|
|
entrance_login_open_session_set(o, EINA_TRUE);
|
|
|
|
screen->login = o;
|
|
|
|
elm_object_part_content_set(ol, "entrance.login", o);
|
|
|
|
evas_object_smart_callback_add(
|
|
|
|
ENTRANCE_GUI_GET(ol, "entrance.conf"),
|
|
|
|
"clicked",
|
|
|
|
_entrance_gui_conf_clicked_cb,
|
|
|
|
screen->transition);
|
|
|
|
evas_object_show(screen->transition);
|
|
|
|
evas_object_show(screen->edj);
|
|
|
|
evas_object_show(screen->login);
|
|
|
|
|
|
|
|
_gui->screens = eina_list_append(_gui->screens, screen);
|
|
|
|
ecore_x_xinerama_screen_geometry_get(j, &x, &y, &w, &h);
|
|
|
|
evas_object_move(screen->transition, x, y);
|
|
|
|
evas_object_resize(screen->transition, w, h);
|
|
|
|
if ((x + w) > ww) ww = x + w;
|
|
|
|
if ((y + h) > hh) hh = y + h;
|
|
|
|
}
|
2014-03-06 05:09:37 -08:00
|
|
|
_gui->theme_icon_pool =
|
|
|
|
_entrance_gui_theme_icons_cache_fill(_gui->win, _gui->theme);
|
|
|
|
_gui->theme_background_pool =
|
|
|
|
_entrance_gui_theme_background_cache_fill(_gui->win, _gui->theme);
|
2013-09-03 11:08:37 -07:00
|
|
|
_entrance_gui_update();
|
|
|
|
xw = elm_win_xwindow_get(_gui->win);
|
|
|
|
ecore_x_window_move(xw, 0, 0);
|
2014-03-06 16:49:32 -08:00
|
|
|
ecore_x_event_mask_set(ecore_x_window_root_get(xw),
|
|
|
|
ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
|
|
|
|
_gui->handler =
|
|
|
|
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY,
|
|
|
|
_entrance_gui_cb_window_property, NULL);
|
2013-09-03 11:08:37 -07:00
|
|
|
evas_object_resize(_gui->win, ww, hh);
|
|
|
|
evas_object_show(_gui->win);
|
|
|
|
{
|
|
|
|
/* tricky situation. we are not normally running with a wm and thus
|
|
|
|
* have to set focus to our window so things work right */
|
|
|
|
screen = _gui->screens->data;
|
|
|
|
ecore_evas_focus_set
|
|
|
|
(ecore_evas_ecore_evas_get(evas_object_evas_get(_gui->win)), 1);
|
|
|
|
/* need to hide and show the cursor */
|
|
|
|
ecore_x_window_cursor_show(elm_win_xwindow_get(_gui->win),
|
|
|
|
EINA_FALSE);
|
|
|
|
ecore_x_window_cursor_show(elm_win_xwindow_get(_gui->win),
|
|
|
|
EINA_TRUE);
|
|
|
|
}
|
|
|
|
return j;
|
|
|
|
}
|
2012-08-09 13:15:30 -07:00
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
void
|
2014-01-08 15:04:44 -08:00
|
|
|
entrance_gui_shutdown(void)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2013-09-03 11:08:37 -07:00
|
|
|
Entrance_Screen *screen;
|
|
|
|
Entrance_Xsession *xsession;
|
2014-03-06 05:09:37 -08:00
|
|
|
Entrance_Image *img;
|
2013-09-03 11:08:37 -07:00
|
|
|
PT("Gui shutdown\n");
|
|
|
|
evas_object_del(_gui->win);
|
|
|
|
EINA_LIST_FREE(_gui->screens, screen)
|
|
|
|
{
|
|
|
|
free(screen);
|
|
|
|
}
|
|
|
|
eina_stringshare_del(_gui->theme);
|
|
|
|
EINA_LIST_FREE(_gui->xsessions, xsession)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(xsession->name);
|
|
|
|
eina_stringshare_del(xsession->command);
|
|
|
|
eina_stringshare_del(xsession->icon);
|
|
|
|
}
|
2014-03-06 16:49:32 -08:00
|
|
|
ecore_event_handler_del(_gui->handler);
|
2014-03-06 05:09:37 -08:00
|
|
|
EINA_LIST_FREE(_gui->background_pool, img)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(img->path);
|
|
|
|
eina_stringshare_del(img->group);
|
|
|
|
free(img);
|
|
|
|
}
|
|
|
|
EINA_LIST_FREE(_gui->icon_pool, img)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(img->path);
|
|
|
|
eina_stringshare_del(img->group);
|
|
|
|
free(img);
|
|
|
|
}
|
|
|
|
EINA_LIST_FREE(_gui->theme_icon_pool, img)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(img->path);
|
|
|
|
eina_stringshare_del(img->group);
|
|
|
|
free(img);
|
|
|
|
}
|
2014-03-06 08:28:04 -08:00
|
|
|
EINA_LIST_FREE(_gui->theme_background_pool, img)
|
2014-03-06 05:09:37 -08:00
|
|
|
{
|
|
|
|
eina_stringshare_del(img->path);
|
|
|
|
eina_stringshare_del(img->group);
|
|
|
|
free(img);
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
if (_gui) free(_gui);
|
|
|
|
}
|
|
|
|
|
2014-03-06 05:09:37 -08:00
|
|
|
static Eina_List*
|
|
|
|
_entrance_gui_string_to_entrance_image(Eina_List *src, char *stdfile, char *mask)
|
|
|
|
{
|
|
|
|
//If srdfile is NULL we will set the src string to file, if not we will set the stdfile. And the src as group.
|
|
|
|
Eina_List *result = NULL;
|
|
|
|
char *src_str, path[PATH_MAX];
|
|
|
|
Entrance_Image *img;
|
|
|
|
EINA_LIST_FREE(src, src_str)
|
|
|
|
{
|
|
|
|
img = calloc(1, sizeof(Entrance_Image));
|
|
|
|
if (stdfile)
|
|
|
|
{
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
snprintf(path, PATH_MAX, mask, src_str);
|
|
|
|
img->group = eina_stringshare_add(path);
|
|
|
|
eina_stringshare_del(src_str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
img->group = src_str;
|
|
|
|
img->path = eina_stringshare_add(stdfile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
img->path = src_str;
|
|
|
|
result = eina_list_append(result,img);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_List*
|
|
|
|
entrance_gui_theme_icons(void)
|
|
|
|
{
|
|
|
|
return _gui->theme_icon_pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_List*
|
|
|
|
entrance_gui_theme_backgrounds(void)
|
|
|
|
{
|
|
|
|
return _gui->theme_background_pool;
|
|
|
|
}
|
|
|
|
static Eina_List*
|
|
|
|
_entrance_gui_theme_icons_cache_fill(Evas_Object *obj, const char *themename)
|
|
|
|
{
|
|
|
|
Evas_Object *edje, *o;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
Eina_List *icons = NULL;
|
|
|
|
|
|
|
|
edje = elm_layout_add(obj);
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
PACKAGE_DATA_DIR"/themes/%s.edj", themename);
|
|
|
|
if (!elm_layout_file_set(edje, buf, "entrance/user"))
|
|
|
|
return NULL; //Can we get to this point ??
|
|
|
|
o = elm_layout_edje_get(edje);
|
|
|
|
if (!o) return NULL;
|
|
|
|
icons = entrance_gui_stringlist_get(edje_object_data_get(o, "items"));
|
|
|
|
evas_object_del(edje);
|
|
|
|
return _entrance_gui_string_to_entrance_image(icons, buf, "entrance/user/%s");
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List*
|
|
|
|
_entrance_gui_theme_background_cache_fill(Evas_Object *obj, const char *themename)
|
|
|
|
{
|
|
|
|
Evas_Object *edje, *o;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
Eina_List *icons = NULL;
|
|
|
|
|
|
|
|
edje = elm_layout_add(obj);
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
PACKAGE_DATA_DIR"/themes/%s.edj", themename);
|
|
|
|
if (!elm_layout_file_set(edje, buf, "entrance/background"))
|
|
|
|
return NULL;
|
|
|
|
o = elm_layout_edje_get(edje);
|
|
|
|
if (!o) return NULL;
|
|
|
|
icons = entrance_gui_stringlist_get(edje_object_data_get(o, "items"));
|
|
|
|
if (!icons) return NULL;
|
|
|
|
evas_object_del(edje);
|
|
|
|
return _entrance_gui_string_to_entrance_image(icons, buf, "entrance/background/%s");
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
Evas_Object *
|
|
|
|
entrance_gui_theme_get (Evas_Object *win, const char *group)
|
|
|
|
{
|
|
|
|
Evas_Object *edje;
|
2012-08-09 13:15:30 -07:00
|
|
|
|
|
|
|
edje = elm_layout_add(win);
|
2013-09-03 11:08:37 -07:00
|
|
|
if (_gui->theme)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
2013-09-03 11:08:37 -07:00
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
PACKAGE_DATA_DIR"/themes/%s.edj", _gui->theme);
|
2012-08-09 13:15:30 -07:00
|
|
|
if (!elm_layout_file_set(edje, buf, group))
|
|
|
|
{
|
2013-09-03 11:08:37 -07:00
|
|
|
PT("Can't load %s theme fallback to default\n", _gui->theme);
|
2012-09-11 12:52:26 -07:00
|
|
|
elm_layout_file_set(edje, PACKAGE_DATA_DIR"/themes/default.edj",
|
|
|
|
group);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_layout_file_set(edje, PACKAGE_DATA_DIR"/themes/default.edj", group);
|
|
|
|
return edje;
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
Eina_List *
|
|
|
|
entrance_gui_stringlist_get(const char *str)
|
|
|
|
{
|
|
|
|
Eina_List *list = NULL;
|
|
|
|
const char *s, *b;
|
|
|
|
if (!str) return NULL;
|
|
|
|
for (b = s = str; 1; s++)
|
|
|
|
{
|
|
|
|
if ((*s == ' ') || (!*s))
|
|
|
|
{
|
|
|
|
char *t = malloc(s - b + 1);
|
|
|
|
if (t)
|
|
|
|
{
|
|
|
|
strncpy(t, b, s - b);
|
|
|
|
t[s - b] = 0;
|
|
|
|
list = eina_list_append(list, eina_stringshare_add(t));
|
|
|
|
free(t);
|
|
|
|
}
|
|
|
|
b = s + 1;
|
|
|
|
}
|
|
|
|
if (!*s) break;
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
entrance_gui_stringlist_free(Eina_List *list)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
EINA_LIST_FREE(list, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
entrance_gui_actions_set(Eina_List *actions)
|
|
|
|
{
|
|
|
|
if (!actions) return;
|
|
|
|
PT("Actions set\n");
|
|
|
|
_gui->actions = actions;
|
|
|
|
_entrance_gui_actions_populate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
entrance_gui_auth_max_tries(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Evas_Object *o;
|
|
|
|
Eina_List *l;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
|
|
|
{
|
|
|
|
o = ENTRANCE_GUI_GET(screen->edj, "entrance.login");
|
|
|
|
elm_entry_entry_set(o, "");
|
|
|
|
elm_object_disabled_set(o, EINA_TRUE);
|
|
|
|
o = ENTRANCE_GUI_GET(screen->edj, "entrance.password");
|
|
|
|
elm_entry_entry_set(o, "");
|
|
|
|
elm_object_disabled_set(o, EINA_TRUE);
|
|
|
|
}
|
|
|
|
ecore_timer_add(5.0, _entrance_gui_auth_enable, NULL);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
entrance_gui_users_set(Eina_List *users)
|
|
|
|
{
|
|
|
|
Evas_Object *ol;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
Eina_List *l;
|
|
|
|
Entrance_Fill *ef;
|
2014-03-06 08:38:05 -08:00
|
|
|
const char *style;
|
2013-09-03 11:08:37 -07:00
|
|
|
|
2014-02-12 09:54:34 -08:00
|
|
|
screen = eina_list_data_get(_gui->screens);
|
2014-03-06 08:38:05 -08:00
|
|
|
|
|
|
|
style = edje_object_data_get(elm_layout_edje_get(screen->edj), "item_style_users");
|
|
|
|
|
|
|
|
if (!style)
|
|
|
|
style = "default"; //theme has not settet a style
|
|
|
|
|
2014-02-12 09:54:34 -08:00
|
|
|
PT("Add users list, using item style: %s\n", style);
|
|
|
|
ef = entrance_fill_new(style,
|
2013-09-03 11:08:37 -07:00
|
|
|
_entrance_gui_user_text_get,
|
|
|
|
_entrance_gui_user_content_get,
|
|
|
|
_entrance_gui_user_state_get,
|
|
|
|
_entrance_gui_user_del);
|
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
|
|
|
{
|
|
|
|
ol = ENTRANCE_GUI_GET(screen->edj, "entrance.users");
|
|
|
|
if (!ol) continue;
|
2013-10-29 11:26:56 -07:00
|
|
|
entrance_fill(ol, ef, users, NULL,
|
|
|
|
_entrance_gui_user_sel_cb, screen->login);
|
2013-09-03 17:10:38 -07:00
|
|
|
elm_object_signal_emit(screen->edj,
|
2013-09-03 11:08:37 -07:00
|
|
|
"entrance,users,enabled", "");
|
|
|
|
}
|
|
|
|
_gui->users = users;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Eina_List *
|
|
|
|
entrance_gui_users_get(void)
|
|
|
|
{
|
|
|
|
return _gui->users;
|
|
|
|
}
|
|
|
|
|
2014-03-06 05:09:37 -08:00
|
|
|
const Entrance_Login*
|
|
|
|
entrance_gui_user_get(const char* name)
|
|
|
|
{
|
|
|
|
Entrance_Login *el;
|
|
|
|
Eina_List *l;
|
|
|
|
EINA_LIST_FOREACH(_gui->users, l, el)
|
|
|
|
{
|
|
|
|
if(!strcmp(name, el->login))
|
|
|
|
{
|
|
|
|
return el;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
void
|
|
|
|
entrance_gui_xsessions_set(Eina_List *xsessions)
|
|
|
|
{
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
|
|
|
{
|
|
|
|
entrance_login_xsessions_populate(screen->login, xsessions);
|
|
|
|
}
|
|
|
|
_gui->xsessions = xsessions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Eina_List *
|
|
|
|
entrance_gui_xsessions_get(void)
|
|
|
|
{
|
|
|
|
return _gui->xsessions;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
entrance_gui_conf_set(const Entrance_Conf_Gui_Event *conf)
|
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
_gui->background_pool = conf->background_pool;
|
|
|
|
_gui->icon_pool = conf->icon_pool;
|
2013-09-03 11:08:37 -07:00
|
|
|
if ((conf->bg.path) && (*conf->bg.path)
|
|
|
|
&& (_gui->bg.path != conf->bg.path))
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&_gui->bg.path, conf->bg.path);
|
|
|
|
_gui->changed &= ENTRANCE_CONF_WALLPAPER;
|
|
|
|
}
|
|
|
|
if ((conf->bg.group) && (*conf->bg.group)
|
|
|
|
&& (_gui->bg.group != conf->bg.group))
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&_gui->bg.group, conf->bg.group);
|
|
|
|
_gui->changed &= ENTRANCE_CONF_WALLPAPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_gui->vkbd_enabled != conf->vkbd_enabled)
|
|
|
|
{
|
|
|
|
_gui->vkbd_enabled = conf->vkbd_enabled;
|
|
|
|
_gui->changed &= ENTRANCE_CONF_VKBD;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gui->changed = ~(ENTRANCE_CONF_NONE);
|
|
|
|
_entrance_gui_update();
|
|
|
|
}
|
|
|
|
|
2013-10-29 11:26:56 -07:00
|
|
|
void
|
|
|
|
entrance_gui_theme_name_set(const char *theme)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
const char *
|
|
|
|
entrance_gui_theme_name_get(void)
|
|
|
|
{
|
|
|
|
return _gui->theme;
|
|
|
|
}
|
|
|
|
|
2014-03-06 05:09:37 -08:00
|
|
|
Eina_List*
|
|
|
|
entrance_gui_background_pool_get(void)
|
|
|
|
{
|
|
|
|
return _gui->background_pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_List*
|
|
|
|
entrance_gui_icon_pool_get(void)
|
|
|
|
{
|
|
|
|
return _gui->icon_pool;
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
const char *
|
|
|
|
entrance_gui_theme_path_get(void)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
PACKAGE_DATA_DIR"/themes/%s.edj", _gui->theme);
|
|
|
|
return eina_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
entrance_gui_background_get(const char **path, const char **group)
|
|
|
|
{
|
|
|
|
if (path)
|
|
|
|
*path = _gui->bg.path;
|
|
|
|
if (group)
|
|
|
|
*group = _gui->bg.group;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
entrance_gui_vkbd_enabled_get(void)
|
|
|
|
{
|
|
|
|
return _gui->vkbd_enabled;
|
|
|
|
}
|
2012-08-09 13:15:30 -07:00
|
|
|
|
2014-01-08 13:27:54 -08:00
|
|
|
void
|
|
|
|
entrance_gui_user_bg_set(const char *path, const char *group)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
|
|
|
{
|
|
|
|
if (path && group)
|
|
|
|
{
|
|
|
|
o = elm_layout_add(screen->background);
|
|
|
|
elm_layout_file_set(o, path, group);
|
|
|
|
elm_object_part_content_set(screen->transition,
|
|
|
|
"entrance.wallpaper.user.start", o);
|
|
|
|
evas_object_show(o);
|
|
|
|
elm_object_signal_emit(screen->transition,
|
|
|
|
"entrance,wallpaper,user", "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_object_signal_emit(screen->transition,
|
|
|
|
"entrance,wallpaper,default", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
static void
|
|
|
|
_entrance_gui_update(void)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
|
|
|
{
|
2013-09-03 11:08:37 -07:00
|
|
|
Evas_Object *bg = NULL;
|
|
|
|
if (_gui->changed & ENTRANCE_CONF_WALLPAPER)
|
|
|
|
{
|
|
|
|
PT("Set background %s - %s\n", _gui->bg.path, _gui->bg.group);
|
|
|
|
if (_gui->bg.path)
|
|
|
|
{
|
|
|
|
if (_gui->bg.group)
|
|
|
|
{
|
|
|
|
bg = elm_layout_add(screen->transition);
|
|
|
|
elm_layout_file_set(bg, _gui->bg.path, _gui->bg.group);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bg = elm_layout_add(screen->transition);
|
|
|
|
elm_layout_file_set(bg, _gui->bg.path,
|
|
|
|
"entrance/background/default");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bg)
|
|
|
|
{
|
2013-10-29 11:26:56 -07:00
|
|
|
const char *path;
|
|
|
|
const char *group;
|
2013-09-03 11:08:37 -07:00
|
|
|
if (_gui->bg.group)
|
|
|
|
bg = entrance_gui_theme_get(screen->transition,
|
|
|
|
_gui->bg.group);
|
|
|
|
else
|
|
|
|
bg = entrance_gui_theme_get(screen->transition,
|
|
|
|
"entrance/background/default");
|
2013-10-29 11:26:56 -07:00
|
|
|
edje_object_file_get(elm_layout_edje_get(bg), &path, &group);
|
|
|
|
eina_stringshare_replace(&_gui->bg.path, path);
|
|
|
|
eina_stringshare_replace(&_gui->bg.group, group);
|
2013-09-03 11:08:37 -07:00
|
|
|
}
|
|
|
|
elm_object_part_content_set(screen->transition,
|
|
|
|
"entrance.wallpaper.default", bg);
|
|
|
|
evas_object_del(screen->background);
|
|
|
|
screen->background = bg;
|
|
|
|
}
|
|
|
|
if (_gui->conf_enabled)
|
|
|
|
{
|
|
|
|
elm_object_signal_emit(screen->edj,
|
|
|
|
"entrance,custom_config.enabled", "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_object_signal_emit(screen->edj,
|
|
|
|
"entrance,custom_config.disabled", "");
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
2013-09-03 11:08:37 -07:00
|
|
|
_gui->changed = 0;
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
static void
|
|
|
|
_entrance_gui_conf_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2013-09-03 11:08:37 -07:00
|
|
|
entrance_conf_begin(data, _gui->win);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
2012-09-03 15:56:53 -07:00
|
|
|
///////////////////////////////////////////////////
|
2012-08-09 13:15:30 -07:00
|
|
|
///////////////// USER ////////////////////////////
|
2012-09-03 15:56:53 -07:00
|
|
|
///////////////////////////////////////////////////
|
2012-08-09 13:15:30 -07:00
|
|
|
|
|
|
|
|
2014-03-06 05:09:37 -08:00
|
|
|
static Evas_Object*
|
|
|
|
_entrance_gui_user_icon_random_get(Evas_Object *obj, const char *username)
|
2013-09-03 11:08:37 -07:00
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
unsigned int rnd = 0;
|
|
|
|
Evas_Object *o = NULL;
|
|
|
|
Entrance_Image *img;
|
|
|
|
const Entrance_Login *el;
|
|
|
|
Eina_List *user_icons, *sys_icons, *theme_icons;
|
|
|
|
|
|
|
|
el = entrance_gui_user_get(username);
|
|
|
|
user_icons = el->icon_pool;
|
|
|
|
sys_icons = entrance_gui_icon_pool_get();
|
|
|
|
theme_icons = entrance_gui_theme_icons();
|
|
|
|
|
2014-03-06 08:28:04 -08:00
|
|
|
srand(time(NULL));
|
2014-03-06 05:09:37 -08:00
|
|
|
rnd = (((eina_list_count(user_icons) + eina_list_count(sys_icons) + eina_list_count(theme_icons))
|
|
|
|
* (double)rand()) / (RAND_MAX + 1.0));
|
|
|
|
if (rnd < eina_list_count(user_icons))
|
|
|
|
{
|
|
|
|
o = elm_icon_add(obj);
|
|
|
|
img = eina_list_nth(user_icons, rnd);
|
|
|
|
elm_image_file_set(o, img->path, NULL);
|
2013-09-03 11:08:37 -07:00
|
|
|
|
2014-03-06 05:09:37 -08:00
|
|
|
}
|
|
|
|
else if((rnd >= eina_list_count(user_icons)) && (rnd < (eina_list_count(user_icons)
|
|
|
|
+eina_list_count(sys_icons))))
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
o = elm_icon_add(obj);
|
|
|
|
img = eina_list_nth(sys_icons, (rnd - eina_list_count(user_icons)));
|
|
|
|
elm_image_file_set(o, img->path, NULL);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
2014-03-06 05:09:37 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
img = eina_list_nth(theme_icons, (rnd - (eina_list_count(user_icons)
|
|
|
|
+ eina_list_count(sys_icons))));
|
|
|
|
o = elm_icon_add(obj);
|
|
|
|
elm_image_file_set(o, img->path, img->group);
|
2013-09-03 11:08:37 -07:00
|
|
|
|
2014-03-06 05:09:37 -08:00
|
|
|
}
|
|
|
|
return o;
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-10-29 11:26:56 -07:00
|
|
|
_entrance_gui_user_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2013-10-29 11:26:56 -07:00
|
|
|
Entrance_Login *eu;
|
2013-09-03 11:08:37 -07:00
|
|
|
eu = elm_object_item_data_get(event_info);
|
|
|
|
entrance_login_login_set(data, eu->login);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
|
2014-01-08 13:27:54 -08:00
|
|
|
|
2012-08-09 13:15:30 -07:00
|
|
|
static char *
|
2014-02-12 09:54:34 -08:00
|
|
|
_entrance_gui_user_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2013-10-29 11:26:56 -07:00
|
|
|
Entrance_Login *eu;
|
2012-08-09 13:15:30 -07:00
|
|
|
eu = data;
|
2014-02-12 09:54:34 -08:00
|
|
|
if ((part) && (!strcmp(part, "elm.text.sub")))
|
|
|
|
if (eu->lsess)
|
|
|
|
return strdup(eu->lsess);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return strdup(eu->login);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2013-10-29 11:26:56 -07:00
|
|
|
_entrance_gui_user_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
Evas_Object *ic = NULL, *o;
|
2013-10-29 11:26:56 -07:00
|
|
|
Entrance_Login *eu;
|
2012-08-09 13:15:30 -07:00
|
|
|
eu = data;
|
|
|
|
if (eu && !strcmp(part, "elm.swallow.icon"))
|
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
ic = entrance_gui_theme_get(obj, "entrance/user");
|
|
|
|
if ((!eu->image.path) && (!eu->image.group))
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
o = _entrance_gui_user_icon_random_get(obj, eu->login);
|
|
|
|
}
|
|
|
|
else if(eu->image.path && (!eu->image.group))
|
|
|
|
{
|
|
|
|
o = elm_icon_add(obj);
|
|
|
|
elm_image_file_set(o, eu->image.path, NULL);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-06 05:09:37 -08:00
|
|
|
o = entrance_gui_theme_get(obj, eu->image.group);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
2014-03-06 05:09:37 -08:00
|
|
|
//TODO if this fails we maybe should wipe those fields in the config and use a random one
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_show(o);
|
|
|
|
elm_object_part_content_set(ic ,"entrance.icon", o);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
return ic;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-10-29 11:26:56 -07:00
|
|
|
_entrance_gui_user_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-10-29 11:26:56 -07:00
|
|
|
_entrance_gui_user_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-03 15:56:53 -07:00
|
|
|
///////////////////////////////////////////////////
|
|
|
|
///////////////// ACTION //////////////////////////
|
|
|
|
///////////////////////////////////////////////////
|
2012-08-09 13:15:30 -07:00
|
|
|
|
2012-09-03 15:56:53 -07:00
|
|
|
static char *
|
2013-10-29 11:26:56 -07:00
|
|
|
_entrance_gui_action_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2012-09-03 15:56:53 -07:00
|
|
|
Entrance_Action *ea;
|
|
|
|
ea = data;
|
2014-02-09 08:35:57 -08:00
|
|
|
if ((part) && (!strcmp(part, "icon")))
|
|
|
|
return NULL;
|
2012-09-03 15:56:53 -07:00
|
|
|
return strdup(ea->label);
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
static void
|
2014-02-08 23:55:24 -08:00
|
|
|
_entrance_gui_action_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
2013-09-03 11:08:37 -07:00
|
|
|
{
|
|
|
|
Entrance_Action *ea;
|
2014-02-08 23:55:24 -08:00
|
|
|
ea = elm_object_item_data_get(event_info);
|
2013-09-03 11:08:37 -07:00
|
|
|
if (ea) entrance_connect_action_send(ea->id);
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:15:30 -07:00
|
|
|
static void
|
2012-09-03 15:56:53 -07:00
|
|
|
_entrance_gui_actions_populate()
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2012-09-03 15:56:53 -07:00
|
|
|
Evas_Object *o;
|
2012-09-11 12:52:26 -07:00
|
|
|
Eina_List *l;
|
2012-09-03 15:56:53 -07:00
|
|
|
Entrance_Screen *screen;
|
2014-03-06 08:38:05 -08:00
|
|
|
const char *style;
|
|
|
|
|
|
|
|
screen = eina_list_data_get(_gui->screens);
|
|
|
|
|
|
|
|
style = edje_object_data_get(elm_layout_edje_get(screen->edj), "item_style_actions");
|
|
|
|
|
|
|
|
if (!style)
|
|
|
|
style = "default"; //theme has not settet a style
|
2012-08-09 13:15:30 -07:00
|
|
|
|
2012-09-11 12:52:26 -07:00
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
2012-08-09 13:15:30 -07:00
|
|
|
{
|
2012-09-03 15:56:53 -07:00
|
|
|
Entrance_Fill *ef;
|
2014-03-06 08:38:05 -08:00
|
|
|
ef = entrance_fill_new(style, _entrance_gui_action_text_get,
|
2012-09-03 15:56:53 -07:00
|
|
|
NULL, NULL, NULL);
|
2013-09-03 11:08:37 -07:00
|
|
|
o = ENTRANCE_GUI_GET(screen->edj, "entrance.actions");
|
2013-10-29 11:26:56 -07:00
|
|
|
entrance_fill(o, ef, _gui->actions, NULL,
|
2013-09-03 11:08:37 -07:00
|
|
|
_entrance_gui_action_clicked_cb, screen);
|
2012-09-03 15:56:53 -07:00
|
|
|
edje_object_signal_emit(elm_layout_edje_get(screen->edj),
|
2013-09-03 11:08:37 -07:00
|
|
|
"entrance,action,enabled", "");
|
2012-08-09 13:15:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2013-09-03 17:10:38 -07:00
|
|
|
static void
|
2014-01-08 15:09:31 -08:00
|
|
|
_entrance_gui_auth_cb(void *data EINA_UNUSED, const char *user EINA_UNUSED, Eina_Bool granted)
|
2013-09-03 17:10:38 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_gui->screens, l, screen)
|
|
|
|
{
|
|
|
|
if (granted)
|
|
|
|
{
|
|
|
|
elm_object_signal_emit(screen->edj,
|
|
|
|
"entrance,auth,valid", "");
|
2014-02-09 16:49:39 -08:00
|
|
|
|
2013-09-03 17:10:38 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elm_object_signal_emit(screen->edj,
|
|
|
|
"entrance,auth,error", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
if (granted)
|
|
|
|
_gui_login_timeout = ecore_timer_add(10.0,
|
|
|
|
_entrance_gui_login_timeout,
|
|
|
|
data);
|
|
|
|
*/
|
|
|
|
}
|
2013-09-03 11:08:37 -07:00
|
|
|
|
2014-01-08 13:27:54 -08:00
|
|
|
static void
|
2014-01-08 15:09:31 -08:00
|
|
|
_entrance_gui_user_bg_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
|
2014-01-08 13:27:54 -08:00
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Entrance_Screen *screen;
|
|
|
|
screen = data;
|
|
|
|
o = elm_object_part_content_get(screen->transition,
|
|
|
|
"entrance.wallpaper.user");
|
|
|
|
evas_object_del(o);
|
|
|
|
o = elm_object_part_content_get(screen->transition,
|
|
|
|
"entrance.wallpaper.user.start");
|
|
|
|
if (o)
|
|
|
|
elm_object_part_content_set(screen->transition,
|
|
|
|
"entrance.wallpaper.user", o);
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:08:37 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_entrance_gui_cb_window_property(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
|
|
|
|
{
|
|
|
|
Ecore_X_Event_Window_Property *ev;
|
|
|
|
|
|
|
|
ev = event_info;
|
|
|
|
if (ev->atom == ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK)
|
|
|
|
{
|
|
|
|
PT("screen managed\n");
|
|
|
|
elm_exit();
|
|
|
|
}
|
2014-02-06 14:23:28 -08:00
|
|
|
|
2014-02-09 16:49:39 -08:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
|