forked from enlightenment/enlightenment
Changing e_conf_wallpaper_import dialog.
It has been split into two other dialogs, one for wallpaper file selection and another one for import settings. Also the "Set As Background" efm action just calls the latter because the file was already selected. SVN revision: 39831
This commit is contained in:
parent
3805af7fcc
commit
b7234a0020
|
@ -171,21 +171,22 @@ e_int_config_wallpaper_handler_set(Evas_Object *obj, const char *path, void *dat
|
|||
|
||||
if (!path) return;
|
||||
e_fm2_path_get(obj, &dev, &fpath);
|
||||
if (dev)
|
||||
{
|
||||
if (e_config->wallpaper_import_last_dev)
|
||||
{
|
||||
eina_stringshare_del(e_config->wallpaper_import_last_dev);
|
||||
e_config->wallpaper_import_last_dev = NULL;
|
||||
}
|
||||
if (dev)
|
||||
e_config->wallpaper_import_last_dev = eina_stringshare_add(dev);
|
||||
if (e_config->wallpaper_import_last_path) {
|
||||
eina_stringshare_del(e_config->wallpaper_import_last_path);
|
||||
e_config->wallpaper_import_last_path = NULL;
|
||||
}
|
||||
if (fpath)
|
||||
{
|
||||
if (e_config->wallpaper_import_last_path)
|
||||
eina_stringshare_del(e_config->wallpaper_import_last_path);
|
||||
e_config->wallpaper_import_last_path = eina_stringshare_add(fpath);
|
||||
}
|
||||
e_config_save_queue();
|
||||
|
||||
e_int_config_wallpaper_import(NULL);
|
||||
e_int_config_wallpaper_import(NULL, path);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
|
@ -365,7 +366,7 @@ _cb_import(void *data1, void *data2)
|
|||
if (cfdata->win_import)
|
||||
e_win_raise(cfdata->win_import);
|
||||
else
|
||||
cfdata->win_import = e_int_config_wallpaper_import(cfdata->cfd);
|
||||
cfdata->win_import = e_int_config_wallpaper_fsel(cfdata->cfd);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -471,7 +472,7 @@ static void
|
|||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (cfdata->win_import)
|
||||
e_int_config_wallpaper_del(cfdata->win_import);
|
||||
e_int_config_wallpaper_import_del(cfdata->win_import);
|
||||
if (cfdata->dia_gradient)
|
||||
e_int_config_wallpaper_gradient_del(cfdata->dia_gradient);
|
||||
#ifdef HAVE_EXCHANGE
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#define IMPORT_SCALE_ASPECT_IN 3
|
||||
#define IMPORT_SCALE_ASPECT_OUT 4
|
||||
|
||||
typedef struct _Import Import;
|
||||
typedef struct _FSel FSel;
|
||||
|
||||
struct _Import
|
||||
struct _FSel
|
||||
{
|
||||
E_Config_Dialog *parent;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
@ -26,6 +26,23 @@ struct _Import
|
|||
Evas_Object *ok_obj;
|
||||
Evas_Object *close_obj;
|
||||
|
||||
E_Win *win;
|
||||
};
|
||||
|
||||
typedef struct _Import Import;
|
||||
|
||||
struct _Import
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
Evas_Object *bg_obj;
|
||||
Evas_Object *box_obj;
|
||||
Evas_Object *event_obj;
|
||||
Evas_Object *content_obj;
|
||||
|
||||
Evas_Object *ok_obj;
|
||||
Evas_Object *close_obj;
|
||||
|
||||
Evas_Object *fill_stretch_obj;
|
||||
Evas_Object *fill_center_obj;
|
||||
Evas_Object *fill_tile_obj;
|
||||
|
@ -38,6 +55,8 @@ struct _Import
|
|||
|
||||
E_Win *win;
|
||||
|
||||
FSel *fsel;
|
||||
|
||||
Ecore_Exe *exe;
|
||||
Ecore_Event_Handler *exe_handler;
|
||||
char *tmpf;
|
||||
|
@ -53,37 +72,39 @@ struct _E_Config_Dialog_Data
|
|||
};
|
||||
|
||||
static void _import_opt_disabled_set(Import *import, int disabled);
|
||||
static void _import_cb_sel_selected(void *data, Evas_Object *obj);
|
||||
static void _import_cb_sel_change(void *data, Evas_Object *obj);
|
||||
static void _import_path_save(Import *import);
|
||||
static void _fsel_path_save(FSel *fsel);
|
||||
static void _import_edj_gen(Import *import);
|
||||
static int _import_cb_edje_cc_exit(void *data, int type, void *event);
|
||||
static void _import_cb_delete(E_Win *win);
|
||||
static void _import_cb_resize(E_Win *win);
|
||||
static void _import_cb_close(void *data, void *data2);
|
||||
static void _import_cb_ok(void *data, void *data2);
|
||||
static void _fsel_cb_delete(E_Win *win);
|
||||
static void _fsel_cb_resize(E_Win *win);
|
||||
static void _fsel_cb_close(void *data, void *data2);
|
||||
static void _fsel_cb_ok(void *data, void *data2);
|
||||
static void _import_cb_wid_on_focus(void *data, Evas_Object *obj);
|
||||
static void _import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event);
|
||||
static void _fsel_cb_wid_on_focus(void *data, Evas_Object *obj);
|
||||
static void _fsel_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event);
|
||||
|
||||
EAPI E_Win *
|
||||
e_int_config_wallpaper_import(E_Config_Dialog *parent)
|
||||
e_int_config_wallpaper_import(void *data, const char *path)
|
||||
{
|
||||
Evas *evas;
|
||||
E_Win *win;
|
||||
Import *import;
|
||||
Evas_Object *o, *of, *ofm, *ord, *ot;
|
||||
Evas_Object *o, *of, *ord, *ot;
|
||||
E_Radio_Group *rg;
|
||||
Evas_Coord w, h;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_Modifier_Mask mask;
|
||||
const char *fdev, *fpath;
|
||||
|
||||
if (!path) return NULL;
|
||||
|
||||
import = E_NEW(Import, 1);
|
||||
if (!import) return NULL;
|
||||
|
||||
if (parent)
|
||||
win = e_win_new(parent->con);
|
||||
else
|
||||
win = e_win_new(e_container_current_get(e_manager_current_get()));
|
||||
|
||||
if (!win)
|
||||
|
@ -92,18 +113,19 @@ e_int_config_wallpaper_import(E_Config_Dialog *parent)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
import->fsel = data;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfdata->method = IMPORT_STRETCH;
|
||||
cfdata->external = 0;
|
||||
cfdata->quality = 90;
|
||||
cfdata->file = strdup(path);
|
||||
import->cfdata = cfdata;
|
||||
import->win = win;
|
||||
|
||||
evas = e_win_evas_get(win);
|
||||
|
||||
if (parent) import->parent = parent;
|
||||
|
||||
e_win_title_set(win, _("Select a Picture..."));
|
||||
e_win_title_set(win, _("Wallpaper settings..."));
|
||||
e_win_delete_callback_set(win, _import_cb_delete);
|
||||
e_win_resize_callback_set(win, _import_cb_resize);
|
||||
e_win_dialog_set(win, 1);
|
||||
|
@ -137,20 +159,6 @@ e_int_config_wallpaper_import(E_Config_Dialog *parent)
|
|||
o = e_widget_list_add(evas, 0, 0);
|
||||
import->content_obj = o;
|
||||
|
||||
fdev = e_config->wallpaper_import_last_dev;
|
||||
fpath = e_config->wallpaper_import_last_path;
|
||||
if ((!fdev) && (!fpath))
|
||||
{
|
||||
fdev = "~/";
|
||||
fpath = "/";
|
||||
}
|
||||
ofm = e_widget_fsel_add(evas, fdev, fpath, NULL, NULL,
|
||||
_import_cb_sel_selected, import,
|
||||
_import_cb_sel_change, import, 1);
|
||||
e_widget_fsel_window_object_set(ofm, E_OBJECT(win));
|
||||
import->fsel_obj = ofm;
|
||||
e_widget_list_object_append(o, ofm, 1, 1, 0.5);
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Fill and Stretch Options"), 1);
|
||||
|
@ -229,17 +237,131 @@ e_int_config_wallpaper_import(E_Config_Dialog *parent)
|
|||
|
||||
win->data = import;
|
||||
|
||||
_import_opt_disabled_set(import, 1);
|
||||
return win;
|
||||
}
|
||||
|
||||
EAPI E_Win *
|
||||
e_int_config_wallpaper_fsel(E_Config_Dialog *parent)
|
||||
{
|
||||
Evas *evas;
|
||||
E_Win *win;
|
||||
FSel *fsel;
|
||||
Evas_Object *o, *ofm;
|
||||
Evas_Coord w, h;
|
||||
Evas_Modifier_Mask mask;
|
||||
const char *fdev, *fpath;
|
||||
|
||||
fsel = E_NEW(FSel, 1);
|
||||
if (!fsel) return NULL;
|
||||
|
||||
if (parent)
|
||||
win = e_win_new(parent->con);
|
||||
else
|
||||
win = e_win_new(e_container_current_get(e_manager_current_get()));
|
||||
|
||||
if (!win)
|
||||
{
|
||||
E_FREE(fsel);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fsel->win = win;
|
||||
|
||||
evas = e_win_evas_get(win);
|
||||
|
||||
if (parent) fsel->parent = parent;
|
||||
|
||||
e_win_title_set(win, _("Select a Picture..."));
|
||||
e_win_delete_callback_set(win, _fsel_cb_delete);
|
||||
e_win_resize_callback_set(win, _fsel_cb_resize);
|
||||
e_win_dialog_set(win, 1);
|
||||
e_win_name_class_set(win, "E", "_wallpaper_fsel_dialog");
|
||||
|
||||
o = edje_object_add(evas);
|
||||
fsel->bg_obj = o;
|
||||
e_theme_edje_object_set(o, "base/theme/dialog", "e/widgets/dialog/main");
|
||||
evas_object_move(o, 0, 0);
|
||||
evas_object_show(o);
|
||||
|
||||
o = e_widget_list_add(evas, 1, 1);
|
||||
e_widget_on_focus_hook_set(o, _import_cb_wid_on_focus, fsel);
|
||||
fsel->box_obj = o;
|
||||
edje_object_part_swallow(fsel->bg_obj, "e.swallow.buttons", o);
|
||||
|
||||
o = evas_object_rectangle_add(evas);
|
||||
fsel->event_obj = o;
|
||||
mask = 0;
|
||||
evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
||||
mask = evas_key_modifier_mask_get(evas, "Shift");
|
||||
evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
||||
mask = 0;
|
||||
evas_object_key_grab(o, "Return", mask, ~mask, 0);
|
||||
mask = 0;
|
||||
evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0);
|
||||
mask = 0;
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN,
|
||||
_fsel_cb_key_down, fsel);
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
fsel->content_obj = o;
|
||||
|
||||
fdev = e_config->wallpaper_import_last_dev;
|
||||
fpath = e_config->wallpaper_import_last_path;
|
||||
if ((!fdev) && (!fpath))
|
||||
{
|
||||
fdev = "~/";
|
||||
fpath = "/";
|
||||
}
|
||||
ofm = e_widget_fsel_add(evas, fdev, fpath, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, 1);
|
||||
e_widget_fsel_window_object_set(ofm, E_OBJECT(win));
|
||||
fsel->fsel_obj = ofm;
|
||||
e_widget_list_object_append(o, ofm, 1, 1, 0.5);
|
||||
|
||||
e_widget_min_size_get(o, &w, &h);
|
||||
edje_extern_object_min_size_set(o, w, h);
|
||||
edje_object_part_swallow(fsel->bg_obj, "e.swallow.content", o);
|
||||
evas_object_show(o);
|
||||
|
||||
|
||||
fsel->ok_obj = e_widget_button_add(evas, _("OK"), NULL,
|
||||
_fsel_cb_ok, win, NULL);
|
||||
e_widget_list_object_append(fsel->box_obj, fsel->ok_obj, 1, 0, 0.5);
|
||||
|
||||
fsel->close_obj = e_widget_button_add(evas, _("Cancel"), NULL,
|
||||
_fsel_cb_close, win, NULL);
|
||||
e_widget_list_object_append(fsel->box_obj, fsel->close_obj, 1, 0, 0.5);
|
||||
|
||||
e_win_centered_set(win, 1);
|
||||
|
||||
o = fsel->box_obj;
|
||||
e_widget_min_size_get(o, &w, &h);
|
||||
edje_extern_object_min_size_set(o, w, h);
|
||||
edje_object_part_swallow(fsel->bg_obj, "e.swallow.buttons", o);
|
||||
|
||||
|
||||
edje_object_size_min_calc(fsel->bg_obj, &w, &h);
|
||||
evas_object_resize(fsel->bg_obj, w, h);
|
||||
e_win_resize(win, w, h);
|
||||
e_win_size_min_set(win, w, h);
|
||||
e_win_size_max_set(win, 99999, 99999);
|
||||
e_win_show(win);
|
||||
e_win_border_icon_set(win, "enlightenment/background");
|
||||
|
||||
if (!e_widget_focus_get(fsel->bg_obj))
|
||||
e_widget_focus_set(fsel->box_obj, 1);
|
||||
|
||||
win->data = fsel;
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_int_config_wallpaper_del(E_Win *win)
|
||||
e_int_config_wallpaper_import_del(E_Win *win)
|
||||
{
|
||||
Import *import;
|
||||
|
||||
import = win->data;
|
||||
_import_path_save(import);
|
||||
if (import->exe_handler) ecore_event_handler_del(import->exe_handler);
|
||||
import->exe_handler = NULL;
|
||||
if (import->tmpf) unlink(import->tmpf);
|
||||
|
@ -247,59 +369,30 @@ e_int_config_wallpaper_del(E_Win *win)
|
|||
E_FREE(import->fdest);
|
||||
import->exe = NULL;
|
||||
e_object_del(E_OBJECT(import->win));
|
||||
if (import->parent)
|
||||
e_int_config_wallpaper_import_done(import->parent);
|
||||
E_FREE(import->cfdata->file);
|
||||
E_FREE(import->cfdata);
|
||||
if (import) free(import);
|
||||
}
|
||||
|
||||
static void
|
||||
_import_opt_disabled_set(Import *import, int disabled)
|
||||
EAPI void
|
||||
e_int_config_wallpaper_fsel_del(E_Win *win)
|
||||
{
|
||||
e_widget_disabled_set(import->fill_stretch_obj, disabled);
|
||||
e_widget_disabled_set(import->fill_center_obj, disabled);
|
||||
e_widget_disabled_set(import->fill_tile_obj, disabled);
|
||||
e_widget_disabled_set(import->fill_within_obj, disabled);
|
||||
e_widget_disabled_set(import->fill_fill_obj, disabled);
|
||||
e_widget_disabled_set(import->external_obj, disabled);
|
||||
e_widget_disabled_set(import->quality_obj, disabled);
|
||||
e_widget_disabled_set(import->frame_fill_obj, disabled);
|
||||
e_widget_disabled_set(import->frame_quality_obj, disabled);
|
||||
FSel *fsel;
|
||||
|
||||
fsel = win->data;
|
||||
_fsel_path_save(fsel);
|
||||
e_object_del(E_OBJECT(fsel->win));
|
||||
if (fsel->parent)
|
||||
e_int_config_wallpaper_import_done(fsel->parent);
|
||||
if (fsel) free(fsel);
|
||||
}
|
||||
|
||||
static void
|
||||
_import_cb_sel_selected(void *data, Evas_Object *obj)
|
||||
{
|
||||
Import *import;
|
||||
|
||||
import = data;
|
||||
_import_cb_ok(import->win, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_import_cb_sel_change(void *data, Evas_Object *obj)
|
||||
{
|
||||
Import *import;
|
||||
const char *path, *p = NULL;
|
||||
|
||||
import = data;
|
||||
path = e_widget_fsel_selection_path_get(import->fsel_obj);
|
||||
E_FREE(import->cfdata->file);
|
||||
if (path) import->cfdata->file = strdup(path);
|
||||
if (path) p = strrchr(path, '.');
|
||||
if ((!p) || (!strcasecmp(p, ".edj")))
|
||||
_import_opt_disabled_set(import, 1);
|
||||
else
|
||||
_import_opt_disabled_set(import, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_import_path_save(Import *import)
|
||||
_fsel_path_save(FSel *fsel)
|
||||
{
|
||||
const char *fdev = NULL, *fpath = NULL;
|
||||
|
||||
e_widget_fsel_path_get(import->fsel_obj, &fdev, &fpath);
|
||||
e_widget_fsel_path_get(fsel->fsel_obj, &fdev, &fpath);
|
||||
if ((fdev) || (fpath))
|
||||
{
|
||||
if (e_config->wallpaper_import_last_dev)
|
||||
|
@ -493,7 +586,10 @@ static int
|
|||
_import_cb_edje_cc_exit(void *data, int type, void *event)
|
||||
{
|
||||
Import *import;
|
||||
FSel *fsel;
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
char *fdest;
|
||||
int r = 1;
|
||||
|
||||
ev = event;
|
||||
import = data;
|
||||
|
@ -504,19 +600,37 @@ _import_cb_edje_cc_exit(void *data, int type, void *event)
|
|||
e_util_dialog_show(_("Picture Import Error"),
|
||||
_("Enlightenment was unable to import the picture<br>"
|
||||
"due to conversion errors."));
|
||||
r = 0;
|
||||
}
|
||||
|
||||
if (import->parent)
|
||||
e_int_config_wallpaper_update(import->parent, import->fdest);
|
||||
fsel = import->fsel;
|
||||
fdest = strdup(import->fdest);
|
||||
e_int_config_wallpaper_import_del(import->win);
|
||||
if (fsel)
|
||||
{
|
||||
if (r && fsel->parent)
|
||||
{
|
||||
e_int_config_wallpaper_update(fsel->parent, fdest);
|
||||
}
|
||||
e_int_config_wallpaper_fsel_del(fsel->win);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r)
|
||||
{
|
||||
e_bg_default_set(fdest);
|
||||
e_bg_update();
|
||||
}
|
||||
}
|
||||
E_FREE(fdest);
|
||||
|
||||
e_int_config_wallpaper_del(import->win);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_import_cb_delete(E_Win *win)
|
||||
{
|
||||
e_int_config_wallpaper_del(win);
|
||||
e_int_config_wallpaper_import_del(win);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -534,30 +648,33 @@ _import_cb_close(void *data, void *data2)
|
|||
E_Win *win;
|
||||
|
||||
win = data;
|
||||
e_int_config_wallpaper_del(win);
|
||||
e_int_config_wallpaper_import_del(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_import_cb_ok(void *data, void *data2)
|
||||
{
|
||||
Import *import;
|
||||
FSel *fsel;
|
||||
E_Win *win;
|
||||
const char *path;
|
||||
const char *file;
|
||||
const char *homedir;
|
||||
char buf[4096];
|
||||
int is_bg, is_theme;
|
||||
int r;
|
||||
|
||||
r = 0;
|
||||
win = data;
|
||||
if (!(import = win->data)) return;
|
||||
path = e_widget_fsel_selection_path_get(import->fsel_obj);
|
||||
E_FREE(import->cfdata->file);
|
||||
if (path) import->cfdata->file = strdup(path);
|
||||
if (import->cfdata->file)
|
||||
{
|
||||
file = ecore_file_file_get(import->cfdata->file);
|
||||
if (!e_util_glob_case_match(file, "*.edj"))
|
||||
{
|
||||
_import_edj_gen(import);
|
||||
e_win_hide(win);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
homedir = e_user_homedir_get();
|
||||
|
@ -574,37 +691,126 @@ _import_cb_ok(void *data, void *data2)
|
|||
{
|
||||
if (!ecore_file_cp(import->cfdata->file, buf))
|
||||
{
|
||||
e_int_config_wallpaper_del(win);
|
||||
e_util_dialog_show(_("Wallpaper Import Error"),
|
||||
_("Enlightenment was unable to "
|
||||
"import the wallpaper<br>due to a "
|
||||
"copy error."));
|
||||
return;
|
||||
}
|
||||
else
|
||||
r = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (import->parent)
|
||||
e_int_config_wallpaper_update(import->parent, buf);
|
||||
e_int_config_wallpaper_del(win);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
e_int_config_wallpaper_del(win);
|
||||
e_util_dialog_show(_("Wallpaper Import Error"),
|
||||
_("Enlightenment was unable to "
|
||||
"import the wallpaper.<br><br>"
|
||||
"Are you sure this is a valid "
|
||||
"wallpaper?"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e_win_hide(win);
|
||||
return;
|
||||
fsel = import->fsel;
|
||||
e_int_config_wallpaper_import_del(win);
|
||||
if (fsel)
|
||||
{
|
||||
if (r && fsel->parent)
|
||||
e_int_config_wallpaper_update(fsel->parent, buf);
|
||||
e_int_config_wallpaper_fsel_del(fsel->win);
|
||||
}
|
||||
e_int_config_wallpaper_del(win);
|
||||
else
|
||||
{
|
||||
if (r)
|
||||
{
|
||||
e_bg_default_set(buf);
|
||||
e_bg_update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_fsel_cb_delete(E_Win *win)
|
||||
{
|
||||
e_int_config_wallpaper_fsel_del(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_fsel_cb_resize(E_Win *win)
|
||||
{
|
||||
Import *import;
|
||||
|
||||
if (!(import = win->data)) return;
|
||||
evas_object_resize(import->bg_obj, win->w, win->h);
|
||||
}
|
||||
|
||||
static void
|
||||
_fsel_cb_close(void *data, void *data2)
|
||||
{
|
||||
E_Win *win;
|
||||
|
||||
win = data;
|
||||
e_int_config_wallpaper_fsel_del(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_fsel_cb_ok(void *data, void *data2)
|
||||
{
|
||||
FSel *fsel;
|
||||
E_Win *win;
|
||||
const char *path;
|
||||
const char *p;
|
||||
|
||||
win = data;
|
||||
if (!(fsel = win->data)) return;
|
||||
path = e_widget_fsel_selection_path_get(fsel->fsel_obj);
|
||||
|
||||
if (path) p = strrchr(path, '.');
|
||||
if ((!p) || (!strcasecmp(p, ".edj")))
|
||||
{
|
||||
int r;
|
||||
int is_bg, is_theme;
|
||||
const char *homedir, *file;
|
||||
char buf[4096];
|
||||
|
||||
r = 0;
|
||||
file = ecore_file_file_get(path);
|
||||
homedir = e_user_homedir_get();
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s",
|
||||
homedir, file);
|
||||
|
||||
is_bg = edje_file_group_exists(path,
|
||||
"e/desktop/background");
|
||||
is_theme =
|
||||
edje_file_group_exists(path,
|
||||
"e/widgets/border/default/border");
|
||||
|
||||
if ((is_bg) && (!is_theme))
|
||||
{
|
||||
if (!ecore_file_cp(path, buf))
|
||||
{
|
||||
e_util_dialog_show(_("Wallpaper Import Error"),
|
||||
_("Enlightenment was unable to "
|
||||
"import the wallpaper<br>due to a "
|
||||
"copy error."));
|
||||
}
|
||||
else
|
||||
r = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
e_util_dialog_show(_("Wallpaper Import Error"),
|
||||
_("Enlightenment was unable to "
|
||||
"import the wallpaper.<br><br>"
|
||||
"Are you sure this is a valid "
|
||||
"wallpaper?"));
|
||||
}
|
||||
|
||||
if (r && fsel->parent)
|
||||
e_int_config_wallpaper_update(fsel->parent, buf);
|
||||
e_int_config_wallpaper_fsel_del(fsel->win);
|
||||
}
|
||||
else
|
||||
e_int_config_wallpaper_import(fsel, path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -619,6 +825,18 @@ _import_cb_wid_on_focus(void *data, Evas_Object *obj)
|
|||
e_widget_focused_object_clear(import->content_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_fsel_cb_wid_on_focus(void *data, Evas_Object *obj)
|
||||
{
|
||||
FSel *fsel;
|
||||
|
||||
fsel = data;
|
||||
if (obj == fsel->content_obj)
|
||||
e_widget_focused_object_clear(fsel->box_obj);
|
||||
else if (fsel->content_obj)
|
||||
e_widget_focused_object_clear(fsel->content_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
|
||||
{
|
||||
|
@ -677,3 +895,62 @@ _import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
|
|||
if (o) e_widget_activate(o);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_fsel_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
|
||||
{
|
||||
Evas_Event_Key_Down *ev;
|
||||
FSel *fsel;
|
||||
|
||||
ev = event;
|
||||
fsel = data;
|
||||
if (!strcmp(ev->keyname, "Tab"))
|
||||
{
|
||||
if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(fsel->win)), "Shift"))
|
||||
{
|
||||
if (e_widget_focus_get(fsel->box_obj))
|
||||
{
|
||||
if (!e_widget_focus_jump(fsel->box_obj, 0))
|
||||
{
|
||||
e_widget_focus_set(fsel->content_obj, 0);
|
||||
if (!e_widget_focus_get(fsel->content_obj))
|
||||
e_widget_focus_set(fsel->box_obj, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!e_widget_focus_jump(fsel->content_obj, 0))
|
||||
e_widget_focus_set(fsel->box_obj, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e_widget_focus_get(fsel->box_obj))
|
||||
{
|
||||
if (!e_widget_focus_jump(fsel->box_obj, 1))
|
||||
{
|
||||
e_widget_focus_set(fsel->content_obj, 1);
|
||||
if (!e_widget_focus_get(fsel->content_obj))
|
||||
e_widget_focus_set(fsel->box_obj, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!e_widget_focus_jump(fsel->content_obj, 1))
|
||||
e_widget_focus_set(fsel->box_obj, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (((!strcmp(ev->keyname, "Return")) ||
|
||||
(!strcmp(ev->keyname, "KP_Enter")) ||
|
||||
(!strcmp(ev->keyname, "space"))))
|
||||
{
|
||||
Evas_Object *o = NULL;
|
||||
|
||||
if ((fsel->content_obj) && (e_widget_focus_get(fsel->content_obj)))
|
||||
o = e_widget_focused_object_get(fsel->content_obj);
|
||||
else
|
||||
o = e_widget_focused_object_get(fsel->box_obj);
|
||||
if (o) e_widget_activate(o);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#ifndef E_INT_CONFIG_WALLPAPER_IMPORT_H
|
||||
#define E_INT_CONFIG_WALLPAPER_IMPORT_H
|
||||
|
||||
EAPI E_Win *e_int_config_wallpaper_import(E_Config_Dialog *parent);
|
||||
EAPI E_Win *e_int_config_wallpaper_fsel(E_Config_Dialog *parent);
|
||||
EAPI E_Win *e_int_config_wallpaper_import(void *data, const char *path);
|
||||
EAPI void e_int_config_wallpaper_del(E_Win *win);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue