desklock config now allows you to configure the image shown on each screen

also fixes ticket #753


SVN revision: 73339
This commit is contained in:
Mike Blumenkrantz 2012-07-05 12:33:33 +00:00
parent ec4b749f20
commit 575967808a
9 changed files with 169 additions and 72 deletions

View File

@ -39,6 +39,7 @@ static E_Config_DD *_e_config_bindings_wheel_edd = NULL;
static E_Config_DD *_e_config_bindings_acpi_edd = NULL;
static E_Config_DD *_e_config_path_append_edd = NULL;
static E_Config_DD *_e_config_desktop_bg_edd = NULL;
static E_Config_DD *_e_config_desklock_bg_edd = NULL;
static E_Config_DD *_e_config_desktop_name_edd = NULL;
static E_Config_DD *_e_config_remember_edd = NULL;
static E_Config_DD *_e_config_color_class_edd = NULL;
@ -244,6 +245,13 @@ e_config_init(void)
E_CONFIG_VAL(D, T, desk_show_mode, INT);
E_CONFIG_LIST(D, T, desk_list, _e_config_shelf_desk_edd);
_e_config_desklock_bg_edd = E_CONFIG_DD_NEW("E_Config_Desklock_Background", E_Config_Desklock_Background);
#undef T
#undef D
#define T E_Config_Desklock_Background
#define D _e_config_desklock_bg_edd
E_CONFIG_VAL(D, T, file, STR);
_e_config_desktop_bg_edd = E_CONFIG_DD_NEW("E_Config_Desktop_Background", E_Config_Desktop_Background);
#undef T
#undef D
@ -749,6 +757,7 @@ e_config_init(void)
E_CONFIG_VAL(D, T, font_hinting, INT); /**/
E_CONFIG_VAL(D, T, desklock_personal_passwd, STR);
E_CONFIG_VAL(D, T, desklock_background, STR);
E_CONFIG_LIST(D, T, desklock_backgrounds, _e_config_desklock_bg_edd); /**/
E_CONFIG_VAL(D, T, desklock_auth_method, INT);
E_CONFIG_VAL(D, T, desklock_login_box_zone, INT);
E_CONFIG_VAL(D, T, desklock_start_locked, INT);
@ -938,6 +947,7 @@ e_config_shutdown(void)
E_CONFIG_DD_FREE(_e_config_bindings_acpi_edd);
E_CONFIG_DD_FREE(_e_config_path_append_edd);
E_CONFIG_DD_FREE(_e_config_desktop_bg_edd);
E_CONFIG_DD_FREE(_e_config_desklock_bg_edd);
E_CONFIG_DD_FREE(_e_config_desktop_name_edd);
E_CONFIG_DD_FREE(_e_config_remember_edd);
E_CONFIG_DD_FREE(_e_config_gadcon_edd);
@ -1202,6 +1212,14 @@ e_config_load(void)
COPYVAL(multiscreen_flip);
IFCFGEND;
IFCFG(0x0151);
COPYPTR(desklock_backgrounds);
e_config->desklock_backgrounds = eina_list_append(e_config->desklock_backgrounds, tcfg->desklock_background);
if (e_config->desklock_backgrounds && (!e_config->desklock_backgrounds->data))
e_config->desklock_backgrounds = eina_list_free(e_config->desklock_backgrounds);
tcfg->desklock_background = NULL;
IFCFGEND;
e_config->config_version = E_CONFIG_FILE_VERSION;
_e_config_free(tcfg);
}

View File

@ -12,6 +12,7 @@ typedef struct _E_Config_Binding_Signal E_Config_Binding_Signal;
typedef struct _E_Config_Binding_Wheel E_Config_Binding_Wheel;
typedef struct _E_Config_Binding_Acpi E_Config_Binding_Acpi;
typedef struct _E_Config_Desktop_Background E_Config_Desktop_Background;
typedef struct _E_Config_Desklock_Background E_Config_Desklock_Background;
typedef struct _E_Config_Desktop_Name E_Config_Desktop_Name;
typedef struct _E_Config_Gadcon E_Config_Gadcon;
typedef struct _E_Config_Gadcon_Client E_Config_Gadcon_Client;
@ -36,7 +37,7 @@ typedef struct _E_Event_Config_Icon_Theme E_Event_Config_Icon_Theme;
/* increment this whenever a new set of config values are added but the users
* config doesn't need to be wiped - simply new values need to be put in
*/
#define E_CONFIG_FILE_GENERATION 0x0150
#define E_CONFIG_FILE_GENERATION 0x0151
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
struct _E_Config
@ -176,7 +177,8 @@ struct _E_Config
int font_hinting; // GUI
const char *desklock_personal_passwd; // GUI
const char *desklock_background; // GUI
const char *desklock_background; // OLD DON'T USE
Eina_List *desklock_backgrounds; // GUI
int desklock_auth_method; // GUI
int desklock_login_box_zone; // GUI
int desklock_start_locked; // GUI
@ -380,6 +382,11 @@ struct _E_Config
} xkb;
};
struct _E_Config_Desklock_Background
{
const char *file;
};
struct _E_Config_Env_Var
{
const char *var;

View File

@ -152,7 +152,7 @@ e_desklock_show_autolocked(void)
EAPI int
e_desklock_show(void)
{
Eina_List *managers, *l, *l2, *l3;
Eina_List *managers, *l, *l2, *l3, *l4;
E_Manager *man;
E_Desklock_Popup_Data *edp;
Evas_Coord mw, mh;
@ -264,8 +264,14 @@ works:
{
E_Zone *zone;
l4 = e_config->desklock_backgrounds;
EINA_LIST_FOREACH(con->zones, l3, zone)
{
E_Config_Desklock_Background *cbg;
const char *bg;
cbg = l4 ? l4->data : NULL;
bg = cbg ? cbg->file : NULL;
edp = E_NEW(E_Desklock_Popup_Data, 1);
if (edp)
{
@ -279,14 +285,14 @@ works:
evas_event_freeze(edp->popup_wnd->evas);
edp->bg_object = edje_object_add(edp->popup_wnd->evas);
if ((!e_config->desklock_background) ||
(!strcmp(e_config->desklock_background, "theme_desklock_background")))
if ((!bg) ||
(!strcmp(bg, "theme_desklock_background")))
{
e_theme_edje_object_set(edp->bg_object,
"base/theme/desklock",
"e/desklock/background");
}
else if (!strcmp(e_config->desklock_background, "theme_background"))
else if (!strcmp(bg, "theme_background"))
{
e_theme_edje_object_set(edp->bg_object,
"base/theme/backgrounds",
@ -296,10 +302,10 @@ works:
{
const char *f;
if (!strcmp(e_config->desklock_background, "user_background"))
if (!strcmp(bg, "user_background"))
f = _user_wallpaper_get();
else
f = e_config->desklock_background;
f = bg;
if (e_util_edje_collection_exists(f, "e/desklock/background"))
{
@ -361,6 +367,7 @@ works:
edd->elock_wnd_list = eina_list_append(edd->elock_wnd_list, edp);
}
l4 = l4->next;
zone_counter++;
}
}

View File

@ -149,6 +149,15 @@ _e_wid_preview_thumb_gen(void *data, Evas_Object *obj __UNUSED__, void *event_in
evas_object_smart_callback_call(wd->obj, "preview_update", NULL);
}
EAPI void
e_widget_preview_file_get(Evas_Object *obj, const char **file, const char **group)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
edje_object_file_get(wd->o_thumb, file, group);
}
EAPI int
e_widget_preview_edje_set(Evas_Object *obj, const char *file, const char *group)
{

View File

@ -6,6 +6,7 @@
EAPI Evas_Object *e_widget_preview_add(Evas *evas, int minw, int minh);
EAPI Evas *e_widget_preview_evas_get(Evas_Object *obj);
EAPI void e_widget_preview_extern_object_set(Evas_Object *obj, Evas_Object *eobj);
EAPI void e_widget_preview_file_get(Evas_Object *obj, const char **file, const char **group);
EAPI int e_widget_preview_file_set(Evas_Object *obj, const char *file, const char *key);
EAPI int e_widget_preview_thumb_set(Evas_Object *obj, const char *file, const char *key, int w, int h);
EAPI int e_widget_preview_edje_set(Evas_Object *obj, const char *file, const char *group);

View File

@ -21,7 +21,6 @@ struct _E_Config_Dialog_Data
/* Common vars */
int use_xscreensaver;
int fmdir;
int zone_count;
/* Locking */
@ -40,7 +39,7 @@ struct _E_Config_Dialog_Data
/* Adv props */
int bg_method;
const char *bg;
Eina_List *bgs;
int custom_lock;
int ask_presentation;
double ask_presentation_timeout;
@ -51,7 +50,8 @@ struct _E_Config_Dialog_Data
Evas_Object *post_screensaver_slider;
Evas_Object *auto_lock_slider;
Evas_Object *ask_presentation_slider;
Evas_Object *o_bg;
Evas_Object *o_table;
Eina_List *bgs;
} gui;
};
@ -79,44 +79,48 @@ e_int_config_desklock(E_Container *con, const char *params __UNUSED__)
}
void
e_int_config_desklock_fsel_done(E_Config_Dialog *cfd, const char *bg_file)
e_int_config_desklock_fsel_done(E_Config_Dialog *cfd, Evas_Object *bg, const char *bg_file)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l;
const char *cbg;
if (!(cfdata = cfd->cfdata)) return;
cfdata->bg_fsel = NULL;
if (bg_file)
{
eina_stringshare_replace(&cfdata->bg, bg_file);
e_widget_preview_edje_set(cfdata->gui.o_bg, cfdata->bg,
"e/desktop/background");
}
if (!bg_file) return;
e_widget_preview_file_get(bg, &cbg, NULL);
l = eina_list_data_find_list(cfdata->bgs, cbg);
if (l->data)
eina_stringshare_replace((const char**)&l->data, bg_file);
else
eina_list_data_set(l, eina_stringshare_add(bg_file));
e_widget_preview_edje_set(bg, bg_file, "e/desktop/background");
}
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
cfdata->fmdir = 0;
if (e_config->desklock_background)
{
cfdata->bg = eina_stringshare_ref(e_config->desklock_background);
if (!strstr(cfdata->bg, e_user_homedir_get()))
cfdata->fmdir = 1;
}
else
cfdata->bg = eina_stringshare_add("theme_desklock_background");
Eina_List *l;
E_Config_Desklock_Background *bg;
int x;
if (!strcmp(cfdata->bg, "theme_desklock_background"))
cfdata->zone_count = _zone_count_get();
EINA_LIST_FOREACH(e_config->desklock_backgrounds, l, bg)
cfdata->bgs = eina_list_append(cfdata->bgs, eina_stringshare_ref(bg->file));
if (!cfdata->bgs)
for (x = 0; x < cfdata->zone_count; x++)
cfdata->bgs = eina_list_append(cfdata->bgs, eina_stringshare_add("theme_desklock_background"));
if (!e_util_strcmp(cfdata->bgs->data, "theme_desklock_background"))
cfdata->bg_method = 0;
else if (!strcmp(cfdata->bg, "theme_background"))
else if (!e_util_strcmp(cfdata->bgs->data, "theme_background"))
cfdata->bg_method = 1;
else if (!strcmp(cfdata->bg, "user_background"))
else if (!e_util_strcmp(cfdata->bgs->data, "user_background"))
cfdata->bg_method = 2;
else
cfdata->bg_method = 3;
cfdata->use_xscreensaver = ecore_x_screensaver_event_available_get();
cfdata->zone_count = _zone_count_get();
cfdata->custom_lock = e_config->desklock_use_custom_desklock;
if (e_config->desklock_custom_desklock_cmd)
@ -158,10 +162,12 @@ _create_data(E_Config_Dialog *cfd)
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
const char *bg;
if (cfdata->bg_fsel)
e_object_del(E_OBJECT(cfdata->bg_fsel));
E_FREE(cfdata->custom_lock_cmd);
if (cfdata->bg) eina_stringshare_del(cfdata->bg);
EINA_LIST_FREE(cfdata->bgs, bg)
eina_stringshare_del(bg);
E_FREE(cfdata);
}
@ -190,9 +196,13 @@ _basic_screensaver_lock_cb_changed(void *data, Evas_Object *o __UNUSED__)
static Evas_Object *
_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *otb, *ol, *ow, *of;
Evas_Object *otb, *ol, *ow, *of, *ot;
Eina_List *l, *ll, *lll;
E_Zone *zone;
E_Radio_Group *rg;
int screen_count;
E_Manager *man;
E_Container *con;
int screen_count, x = 0;
screen_count = ecore_x_xinerama_screen_count_get();
@ -302,12 +312,21 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
e_widget_table_object_append(of, ow, 1, 1, 1, 1, 1, 0, 1, 0);
e_widget_list_object_append(ol, of, 1, 1, 0.5);
ow = e_widget_preview_add(evas, 100, 140);
cfdata->gui.o_bg = ow;
e_widget_disabled_set(cfdata->gui.o_bg, (cfdata->bg_method < 3));
evas_object_event_callback_add(ow, EVAS_CALLBACK_MOUSE_DOWN,
_cb_bg_mouse_down, cfdata);
e_widget_list_object_append(ol, ow, 1, 1, 0.5);
cfdata->gui.o_table = ot = e_widget_table_add(evas, 1);
EINA_LIST_FOREACH(e_manager_list(), l, man)
EINA_LIST_FOREACH(man->containers, ll, con)
EINA_LIST_FOREACH(con->zones, lll, zone)
{
ow = e_widget_preview_add(evas, 100, 140);
cfdata->gui.bgs = eina_list_append(cfdata->gui.bgs, ow);
evas_object_data_set(ow, "zone", zone);
e_widget_disabled_set(ow, (cfdata->bg_method < 3));
evas_object_event_callback_add(ow, EVAS_CALLBACK_MOUSE_DOWN, _cb_bg_mouse_down, cfdata);
e_widget_table_object_append(cfdata->gui.o_table, ow, x++, 0, 1, 1, 1, 1, 1, 1);
}
_cb_method_change(cfdata, NULL, NULL);
e_widget_list_object_append(ol, cfdata->gui.o_table, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Wallpaper"), ol,
1, 0, 1, 0, 0.5, 0.0);
@ -322,6 +341,10 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
static int
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
const char *bg;
E_Config_Desklock_Background *cbg;
e_config->desklock_start_locked = cfdata->start_locked;
e_config->desklock_on_suspend = cfdata->lock_on_suspend;
e_config->desklock_autolock_idle = cfdata->auto_lock;
@ -332,12 +355,21 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
e_config->desklock_ask_presentation_timeout =
cfdata->ask_presentation_timeout;
if (cfdata->bg)
if (cfdata->bgs)
{
if (e_config->desklock_background)
e_filereg_deregister(e_config->desklock_background);
eina_stringshare_replace(&e_config->desklock_background, cfdata->bg);
e_filereg_register(e_config->desklock_background);
EINA_LIST_FREE(e_config->desklock_backgrounds, cbg)
{
e_filereg_deregister(cbg->file);
eina_stringshare_del(cbg->file);
free(cbg);
}
EINA_LIST_FOREACH(cfdata->bgs, l, bg)
{
cbg = E_NEW(E_Config_Desklock_Background, 1);
cbg->file = eina_stringshare_ref(bg);
e_config->desklock_backgrounds = eina_list_append(e_config->desklock_backgrounds, cbg);
e_filereg_register(bg);
}
}
if (cfdata->login_zone < 0)
@ -357,6 +389,8 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
static int
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l, *ll;
E_Config_Desklock_Background *cbg;
if (e_config->desklock_start_locked != cfdata->start_locked)
return 1;
@ -376,8 +410,13 @@ _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfda
if (e_config->desklock_autolock_idle_timeout != cfdata->idle_time * 60)
return 1;
if (e_config->desklock_background != cfdata->bg)
return 1;
ll = cfdata->bgs;
EINA_LIST_FOREACH(e_config->desklock_backgrounds, l, cbg)
{
if (!ll) return 1;
if (cbg->file != ll->data) return 1;
ll = ll->next;
}
if (cfdata->login_zone < 0)
{
@ -409,56 +448,72 @@ static void
_cb_method_change(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
Eina_List *l;
Evas_Object *bg;
const char *theme = NULL;
int x;
if (!(cfdata = data)) return;
e_widget_disabled_set(cfdata->gui.o_bg, (cfdata->bg_method < 3));
EINA_LIST_FOREACH(cfdata->gui.bgs, l, bg)
e_widget_disabled_set(bg, (cfdata->bg_method < 3));
switch (cfdata->bg_method)
{
case 0:
eina_stringshare_replace(&cfdata->bg, "theme_desklock_background");
EINA_LIST_FREE(cfdata->bgs, theme)
eina_stringshare_del(theme);
for (x = 0; x < cfdata->zone_count; x++)
cfdata->bgs = eina_list_append(cfdata->bgs, eina_stringshare_add("theme_desklock_background"));
theme = e_theme_edje_file_get("base/theme/desklock",
"e/desklock/background");
if (theme)
e_widget_preview_edje_set(cfdata->gui.o_bg, theme,
"e/desklock/background");
EINA_LIST_FOREACH(cfdata->gui.bgs, l, bg)
e_widget_preview_edje_set(bg, theme, "e/desklock/background");
break;
case 1:
eina_stringshare_replace(&cfdata->bg, "theme_background");
theme = e_theme_edje_file_get("base/theme/backgrounds",
"e/desktop/background");
if (theme)
e_widget_preview_edje_set(cfdata->gui.o_bg, theme,
"e/desktop/background");
EINA_LIST_FOREACH(cfdata->gui.bgs, l, bg)
e_widget_preview_edje_set(bg, theme, "e/desklock/background");
break;
case 2:
eina_stringshare_replace(&cfdata->bg, "user_background");
if (e_config->desktop_default_background)
theme = e_config->desktop_default_background;
{
theme = e_config->desktop_default_background;
if (theme)
EINA_LIST_FOREACH(cfdata->gui.bgs, l, bg)
e_widget_preview_edje_set(bg, theme, "e/desklock/background");
}
else
{
const E_Config_Desktop_Background *cbg;
const Eina_List *l;
Eina_List *ll;
ll = cfdata->gui.bgs;
EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cbg)
{
if (!ll) break;
if (cbg->file)
{
theme = cbg->file;
break;
}
e_widget_preview_edje_set(ll->data, cbg->file, "e/desktop/background");
ll = ll->next;
}
}
if (theme)
e_widget_preview_edje_set(cfdata->gui.o_bg, theme,
"e/desktop/background");
break;
default:
e_widget_preview_edje_set(cfdata->gui.o_bg, cfdata->bg,
"e/desktop/background");
{
Eina_List *ll;
ll = cfdata->gui.bgs;
EINA_LIST_FOREACH(cfdata->bgs, l, theme)
{
if (!ll) break;
e_widget_preview_edje_set(ll->data, theme, "e/desktop/background");
ll = ll->next;
}
}
break;
}
}
@ -500,7 +555,7 @@ _cb_bg_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *eve
if (cfdata->bg_fsel)
e_win_raise(cfdata->bg_fsel->dia->win);
else
cfdata->bg_fsel = e_int_config_desklock_fsel(cfdata->cfd);
cfdata->bg_fsel = e_int_config_desklock_fsel(cfdata->cfd, obj);
}
static void

View File

@ -4,7 +4,7 @@
#define E_INT_CONFIG_DESKLOCK_H
E_Config_Dialog *e_int_config_desklock(E_Container *con, const char *params __UNUSED__);
void e_int_config_desklock_fsel_done(E_Config_Dialog *cfd, const char *bg_file);
void e_int_config_desklock_fsel_done(E_Config_Dialog *cfd, Evas_Object *bg, const char *bg_file);
#endif
#endif

View File

@ -20,7 +20,7 @@ static void _cb_radio_changed(void *data, Evas_Object *obj, void *event)
static void _cb_dir_up(void *data1, void *data2);
E_Config_Dialog *
e_int_config_desklock_fsel(E_Config_Dialog *parent)
e_int_config_desklock_fsel(E_Config_Dialog *parent, Evas_Object *bg)
{
E_Container *con;
E_Config_Dialog *cfd;
@ -41,7 +41,7 @@ e_int_config_desklock_fsel(E_Config_Dialog *parent)
cfd = e_config_dialog_new(con, _("Select a Background..."),
"E", "_desklock_fsel_dialog",
"enlightenment/background", 0, v, parent);
e_object_data_set(E_OBJECT(cfd), bg);
return cfd;
}
@ -64,7 +64,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
if (cfdata->bg) bg_file = strdup(cfdata->bg);
E_FREE(cfdata->bg);
E_FREE(cfdata);
e_int_config_desklock_fsel_done(cfd->data, bg_file);
e_int_config_desklock_fsel_done(cfd->data, e_object_data_get(E_OBJECT(cfd)), bg_file);
}
static Evas_Object *

View File

@ -3,7 +3,7 @@
# ifndef E_INT_CONFIG_DESKLOCK_FSEL_H
# define E_INT_CONFIG_DESKLOCK_FSEL_H
E_Config_Dialog *e_int_config_desklock_fsel(E_Config_Dialog *parent);
E_Config_Dialog *e_int_config_desklock_fsel(E_Config_Dialog *parent, Evas_Object *bg);
void e_int_config_desklock_fsel_del(E_Config_Dialog *cfd);
# endif