2007-07-04 08:09:25 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2006-08-07 13:25:34 -07:00
|
|
|
#include "e.h"
|
2007-07-04 08:09:25 -07:00
|
|
|
#include "e_mod_main.h"
|
2006-08-07 13:25:34 -07:00
|
|
|
|
|
|
|
#define IMPORT_STRETCH 0
|
|
|
|
#define IMPORT_TILE 1
|
|
|
|
#define IMPORT_CENTER 2
|
|
|
|
#define IMPORT_SCALE_ASPECT_IN 3
|
|
|
|
#define IMPORT_SCALE_ASPECT_OUT 4
|
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
typedef struct _FSel FSel;
|
2006-08-07 13:25:34 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
struct _FSel
|
2006-08-07 13:25:34 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog *parent;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
Evas_Object *bg_obj;
|
|
|
|
Evas_Object *box_obj;
|
|
|
|
Evas_Object *event_obj;
|
|
|
|
Evas_Object *content_obj;
|
|
|
|
Evas_Object *fsel_obj;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
Evas_Object *ok_obj;
|
|
|
|
Evas_Object *close_obj;
|
2006-08-12 05:49:52 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
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;
|
|
|
|
|
2006-08-12 05:49:52 -07:00
|
|
|
Evas_Object *fill_stretch_obj;
|
|
|
|
Evas_Object *fill_center_obj;
|
|
|
|
Evas_Object *fill_tile_obj;
|
|
|
|
Evas_Object *fill_within_obj;
|
|
|
|
Evas_Object *fill_fill_obj;
|
2006-11-17 07:04:52 -08:00
|
|
|
Evas_Object *external_obj;
|
2006-08-12 05:49:52 -07:00
|
|
|
Evas_Object *quality_obj;
|
|
|
|
Evas_Object *frame_fill_obj;
|
|
|
|
Evas_Object *frame_quality_obj;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
E_Win *win;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
FSel *fsel;
|
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
Ecore_Exe *exe;
|
|
|
|
Ecore_Event_Handler *exe_handler;
|
|
|
|
char *tmpf;
|
|
|
|
char *fdest;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _E_Config_Dialog_Data
|
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
int method;
|
2006-11-17 07:04:52 -08:00
|
|
|
int external;
|
2006-08-12 19:40:11 -07:00
|
|
|
int quality;
|
2006-08-07 13:25:34 -07:00
|
|
|
};
|
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
static void _fsel_path_save(FSel *fsel);
|
2006-08-07 13:25:34 -07:00
|
|
|
static void _import_edj_gen(Import *import);
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool _import_cb_edje_cc_exit(void *data, int type, void *event);
|
2006-08-07 13:25:34 -07:00
|
|
|
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);
|
2009-04-01 20:46:22 -07:00
|
|
|
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);
|
2006-08-07 13:25:34 -07:00
|
|
|
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);
|
2009-04-01 20:46:22 -07:00
|
|
|
static void _fsel_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event);
|
2006-08-07 13:25:34 -07:00
|
|
|
|
2009-12-17 13:41:31 -08:00
|
|
|
E_Win *
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_import(void *data, const char *path)
|
2006-08-07 13:25:34 -07:00
|
|
|
{
|
|
|
|
Evas *evas;
|
|
|
|
E_Win *win;
|
|
|
|
Import *import;
|
2009-04-01 20:46:22 -07:00
|
|
|
Evas_Object *o, *of, *ord, *ot;
|
2006-08-07 13:25:34 -07:00
|
|
|
E_Radio_Group *rg;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
E_Config_Dialog_Data *cfdata;
|
|
|
|
Evas_Modifier_Mask mask;
|
2010-01-10 10:27:51 -08:00
|
|
|
Eina_Bool kg;
|
2009-04-01 20:46:22 -07:00
|
|
|
|
|
|
|
if (!path) return NULL;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
import = E_NEW(Import, 1);
|
|
|
|
if (!import) return NULL;
|
2007-10-24 01:37:48 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
win = e_win_new(e_container_current_get(e_manager_current_get()));
|
2007-10-24 01:37:48 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
if (!win)
|
|
|
|
{
|
2008-05-12 13:40:00 -07:00
|
|
|
E_FREE(import);
|
2009-04-01 20:46:22 -07:00
|
|
|
return NULL;
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
import->fsel = data;
|
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
2006-08-08 13:41:46 -07:00
|
|
|
cfdata->method = IMPORT_STRETCH;
|
2006-11-17 07:04:52 -08:00
|
|
|
cfdata->external = 0;
|
2006-08-12 19:40:11 -07:00
|
|
|
cfdata->quality = 90;
|
2009-04-01 20:46:22 -07:00
|
|
|
cfdata->file = strdup(path);
|
2006-08-07 13:25:34 -07:00
|
|
|
import->cfdata = cfdata;
|
|
|
|
import->win = win;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
evas = e_win_evas_get(win);
|
2007-10-24 01:37:48 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
e_win_title_set(win, _("Wallpaper settings..."));
|
2006-08-07 13:25:34 -07:00
|
|
|
e_win_delete_callback_set(win, _import_cb_delete);
|
|
|
|
e_win_resize_callback_set(win, _import_cb_resize);
|
|
|
|
e_win_dialog_set(win, 1);
|
2006-08-14 04:08:40 -07:00
|
|
|
e_win_name_class_set(win, "E", "_wallpaper_import_dialog");
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
o = edje_object_add(evas);
|
|
|
|
import->bg_obj = o;
|
2006-08-22 20:30:41 -07:00
|
|
|
e_theme_edje_object_set(o, "base/theme/dialog", "e/widgets/dialog/main");
|
2006-08-07 13:25:34 -07:00
|
|
|
evas_object_move(o, 0, 0);
|
|
|
|
evas_object_show(o);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
o = e_widget_list_add(evas, 1, 1);
|
|
|
|
e_widget_on_focus_hook_set(o, _import_cb_wid_on_focus, import);
|
|
|
|
import->box_obj = o;
|
2006-08-22 20:30:41 -07:00
|
|
|
edje_object_part_swallow(import->bg_obj, "e.swallow.buttons", o);
|
2006-08-07 13:25:34 -07:00
|
|
|
|
2006-08-15 23:10:30 -07:00
|
|
|
o = evas_object_rectangle_add(evas);
|
2006-08-07 13:25:34 -07:00
|
|
|
import->event_obj = o;
|
|
|
|
mask = 0;
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
|
2006-08-07 13:25:34 -07:00
|
|
|
mask = evas_key_modifier_mask_get(evas, "Shift");
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
|
2006-08-07 13:25:34 -07:00
|
|
|
mask = 0;
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "Return", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Return\" key events to object %p.\n", o);
|
2006-08-07 13:25:34 -07:00
|
|
|
mask = 0;
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"KP_Enter\" key events to object %p.\n", o);
|
2009-04-01 20:46:22 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN,
|
2008-05-12 13:40:00 -07:00
|
|
|
_import_cb_key_down, import);
|
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
o = e_widget_list_add(evas, 0, 0);
|
2006-08-07 13:25:34 -07:00
|
|
|
import->content_obj = o;
|
|
|
|
|
2006-08-08 13:41:46 -07:00
|
|
|
ot = e_widget_table_add(evas, 0);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-08 13:41:46 -07:00
|
|
|
of = e_widget_frametable_add(evas, _("Fill and Stretch Options"), 1);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->frame_fill_obj = of;
|
2006-08-07 13:25:34 -07:00
|
|
|
rg = e_widget_radio_group_new(&cfdata->method);
|
2009-04-01 20:46:22 -07:00
|
|
|
ord = e_widget_radio_icon_add(evas, _("Stretch"),
|
|
|
|
"enlightenment/wallpaper_stretch",
|
2007-10-27 17:58:17 -07:00
|
|
|
24, 24, IMPORT_STRETCH, rg);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->fill_stretch_obj = ord;
|
2006-08-07 13:25:34 -07:00
|
|
|
e_widget_frametable_object_append(of, ord, 0, 0, 1, 1, 1, 0, 1, 0);
|
2009-04-01 20:46:22 -07:00
|
|
|
ord = e_widget_radio_icon_add(evas, _("Center"),
|
|
|
|
"enlightenment/wallpaper_center",
|
2007-10-27 17:58:17 -07:00
|
|
|
24, 24, IMPORT_CENTER, rg);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->fill_center_obj = ord;
|
2006-08-08 13:41:46 -07:00
|
|
|
e_widget_frametable_object_append(of, ord, 1, 0, 1, 1, 1, 0, 1, 0);
|
2009-04-01 20:46:22 -07:00
|
|
|
ord = e_widget_radio_icon_add(evas, _("Tile"),
|
|
|
|
"enlightenment/wallpaper_tile",
|
2007-10-27 17:58:17 -07:00
|
|
|
24, 24, IMPORT_TILE, rg);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->fill_tile_obj = ord;
|
2006-08-08 13:41:46 -07:00
|
|
|
e_widget_frametable_object_append(of, ord, 2, 0, 1, 1, 1, 0, 1, 0);
|
2009-04-01 20:46:22 -07:00
|
|
|
ord = e_widget_radio_icon_add(evas, _("Within"),
|
|
|
|
"enlightenment/wallpaper_scale_aspect_in",
|
2007-10-27 17:58:17 -07:00
|
|
|
24, 24, IMPORT_SCALE_ASPECT_IN, rg);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->fill_within_obj = ord;
|
2006-08-08 13:41:46 -07:00
|
|
|
e_widget_frametable_object_append(of, ord, 3, 0, 1, 1, 1, 0, 1, 0);
|
2009-04-01 20:46:22 -07:00
|
|
|
ord = e_widget_radio_icon_add(evas, _("Fill"),
|
|
|
|
"enlightenment/wallpaper_scale_aspect_out",
|
2007-10-27 17:58:17 -07:00
|
|
|
24, 24, IMPORT_SCALE_ASPECT_OUT, rg);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->fill_fill_obj = ord;
|
2006-08-08 13:41:46 -07:00
|
|
|
e_widget_frametable_object_append(of, ord, 4, 0, 1, 1, 1, 0, 1, 0);
|
|
|
|
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 0);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-08 13:41:46 -07:00
|
|
|
of = e_widget_frametable_add(evas, _("File Quality"), 0);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->frame_quality_obj = of;
|
2006-11-17 07:04:52 -08:00
|
|
|
ord = e_widget_check_add(evas, _("Use original file"), &(cfdata->external));
|
|
|
|
import->external_obj = ord;
|
|
|
|
e_widget_frametable_object_append(of, ord, 0, 0, 1, 1, 1, 0, 1, 0);
|
2009-04-01 20:46:22 -07:00
|
|
|
ord = e_widget_slider_add(evas, 1, 0, _("%3.0f%%"), 0.0, 100.0, 1.0, 0,
|
2007-10-27 17:58:17 -07:00
|
|
|
NULL, &(cfdata->quality), 150);
|
2006-08-12 05:49:52 -07:00
|
|
|
import->quality_obj = ord;
|
2006-11-17 07:04:52 -08:00
|
|
|
e_widget_frametable_object_append(of, ord, 0, 1, 1, 1, 1, 0, 1, 0);
|
2006-08-08 13:41:46 -07:00
|
|
|
e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 1, 1, 0);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-08 13:41:46 -07:00
|
|
|
e_widget_list_object_append(o, ot, 0, 0, 0.5);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(o, &w, &h);
|
2006-08-07 13:25:34 -07:00
|
|
|
edje_extern_object_min_size_set(o, w, h);
|
2006-08-22 20:30:41 -07:00
|
|
|
edje_object_part_swallow(import->bg_obj, "e.swallow.content", o);
|
2006-08-07 13:25:34 -07:00
|
|
|
evas_object_show(o);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
import->ok_obj = e_widget_button_add(evas, _("OK"), NULL,
|
2007-10-27 17:58:17 -07:00
|
|
|
_import_cb_ok, win, cfdata);
|
2006-08-07 13:25:34 -07:00
|
|
|
e_widget_list_object_append(import->box_obj, import->ok_obj, 1, 0, 0.5);
|
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
import->close_obj = e_widget_button_add(evas, _("Cancel"), NULL,
|
2007-10-27 17:58:17 -07:00
|
|
|
_import_cb_close, win, NULL);
|
2006-08-07 13:25:34 -07:00
|
|
|
e_widget_list_object_append(import->box_obj, import->close_obj, 1, 0, 0.5);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
e_win_centered_set(win, 1);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
o = import->box_obj;
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(o, &w, &h);
|
2006-08-07 13:25:34 -07:00
|
|
|
edje_extern_object_min_size_set(o, w, h);
|
2006-08-22 20:30:41 -07:00
|
|
|
edje_object_part_swallow(import->bg_obj, "e.swallow.buttons", o);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
edje_object_size_min_calc(import->bg_obj, &w, &h);
|
2006-08-26 02:06:47 -07:00
|
|
|
evas_object_resize(import->bg_obj, w, h);
|
|
|
|
e_win_resize(win, w, h);
|
2006-08-07 13:25:34 -07:00
|
|
|
e_win_size_min_set(win, w, h);
|
|
|
|
e_win_size_max_set(win, 99999, 99999);
|
|
|
|
e_win_show(win);
|
2009-03-08 16:09:48 -07:00
|
|
|
e_win_border_icon_set(win, "folder-image");
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
if (!e_widget_focus_get(import->bg_obj))
|
|
|
|
e_widget_focus_set(import->box_obj, 1);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
win->data = import;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:41:31 -08:00
|
|
|
E_Win *
|
2009-04-01 20:46:22 -07:00
|
|
|
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;
|
2010-01-10 10:27:51 -08:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
Eina_Bool kg;
|
2009-04-01 20:46:22 -07:00
|
|
|
|
|
|
|
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;
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
|
2009-04-01 20:46:22 -07:00
|
|
|
mask = evas_key_modifier_mask_get(evas, "Shift");
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "Tab", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Tab\" key events to object %p.\n", o);
|
2009-04-01 20:46:22 -07:00
|
|
|
mask = 0;
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "Return", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"Return\" key events to object %p.\n", o);
|
2009-04-01 20:46:22 -07:00
|
|
|
mask = 0;
|
2010-01-10 10:27:51 -08:00
|
|
|
kg = evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0);
|
|
|
|
if (!kg)
|
|
|
|
fprintf(stderr,"ERROR: unable to redirect \"KP_Enter\" key events to object %p.\n", o);
|
2009-04-01 20:46:22 -07:00
|
|
|
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;
|
2009-09-07 21:15:25 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s%s",fdev,e_config->wallpaper_import_last_path);
|
2009-10-09 14:49:03 -07:00
|
|
|
|
2009-09-07 21:15:25 -07:00
|
|
|
if(!ecore_file_exists(ecore_file_realpath(buf)))
|
2009-10-09 14:49:03 -07:00
|
|
|
fpath = "/";
|
2009-09-07 21:15:25 -07:00
|
|
|
else
|
2009-10-09 14:49:03 -07:00
|
|
|
fpath = e_config->wallpaper_import_last_path;
|
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
if ((!fdev) && (!fpath))
|
|
|
|
{
|
|
|
|
fdev = "~/";
|
|
|
|
fpath = "/";
|
|
|
|
}
|
2009-10-09 14:49:03 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
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);
|
|
|
|
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(o, &w, &h);
|
2009-04-01 20:46:22 -07:00
|
|
|
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;
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(o, &w, &h);
|
2009-04-01 20:46:22 -07:00
|
|
|
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;
|
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:41:31 -08:00
|
|
|
void
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_import_del(E_Win *win)
|
2006-08-07 13:25:34 -07:00
|
|
|
{
|
|
|
|
Import *import;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2010-07-18 10:02:12 -07:00
|
|
|
if (!(import = win->data)) return;
|
2006-08-07 13:25:34 -07:00
|
|
|
if (import->exe_handler) ecore_event_handler_del(import->exe_handler);
|
|
|
|
import->exe_handler = NULL;
|
|
|
|
if (import->tmpf) unlink(import->tmpf);
|
|
|
|
E_FREE(import->tmpf);
|
|
|
|
E_FREE(import->fdest);
|
|
|
|
import->exe = NULL;
|
2010-07-18 10:02:12 -07:00
|
|
|
if (import->win) e_object_del(E_OBJECT(import->win));
|
2006-08-15 23:10:30 -07:00
|
|
|
E_FREE(import->cfdata->file);
|
|
|
|
E_FREE(import->cfdata);
|
2006-08-07 13:25:34 -07:00
|
|
|
if (import) free(import);
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:41:31 -08:00
|
|
|
void
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_fsel_del(E_Win *win)
|
2006-08-07 13:25:34 -07:00
|
|
|
{
|
2009-04-01 20:46:22 -07:00
|
|
|
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);
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
|
|
|
|
2006-08-14 04:08:40 -07:00
|
|
|
static void
|
2009-04-01 20:46:22 -07:00
|
|
|
_fsel_path_save(FSel *fsel)
|
2006-08-14 04:08:40 -07:00
|
|
|
{
|
|
|
|
const char *fdev = NULL, *fpath = NULL;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
e_widget_fsel_path_get(fsel->fsel_obj, &fdev, &fpath);
|
2006-08-14 04:08:40 -07:00
|
|
|
if ((fdev) || (fpath))
|
|
|
|
{
|
2007-10-27 17:58:17 -07:00
|
|
|
if (e_config->wallpaper_import_last_dev)
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(e_config->wallpaper_import_last_dev);
|
2007-10-27 17:58:17 -07:00
|
|
|
if (fdev)
|
2008-10-15 08:12:56 -07:00
|
|
|
e_config->wallpaper_import_last_dev = eina_stringshare_add(fdev);
|
2006-08-14 04:08:40 -07:00
|
|
|
else e_config->wallpaper_import_last_dev = NULL;
|
2007-10-27 17:58:17 -07:00
|
|
|
if (e_config->wallpaper_import_last_path)
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(e_config->wallpaper_import_last_path);
|
2007-10-27 17:58:17 -07:00
|
|
|
if (fpath)
|
2008-10-15 08:12:56 -07:00
|
|
|
e_config->wallpaper_import_last_path = eina_stringshare_add(fpath);
|
2006-08-14 04:08:40 -07:00
|
|
|
else e_config->wallpaper_import_last_path = NULL;
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
static void
|
|
|
|
_import_edj_gen(Import *import)
|
|
|
|
{
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Object *img;
|
2006-08-12 05:49:52 -07:00
|
|
|
int fd, num = 1;
|
2006-08-07 13:25:34 -07:00
|
|
|
int w = 0, h = 0;
|
2009-04-13 07:56:38 -07:00
|
|
|
const char *file, *locale;
|
2006-08-08 13:41:46 -07:00
|
|
|
char buf[4096], cmd[4096], tmpn[4096], ipart[4096], enc[128];
|
2006-09-22 12:55:11 -07:00
|
|
|
char *imgdir = NULL, *fstrip;
|
2006-08-12 20:17:34 -07:00
|
|
|
int cr = 255, cg = 255, cb = 255, ca = 255;
|
2006-08-07 13:25:34 -07:00
|
|
|
FILE *f;
|
2009-04-13 07:56:38 -07:00
|
|
|
size_t len, off;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
evas = e_win_evas_get(import->win);
|
2007-07-25 10:01:04 -07:00
|
|
|
file = ecore_file_file_get(import->cfdata->file);
|
2006-08-07 13:25:34 -07:00
|
|
|
fstrip = ecore_file_strip_ext(file);
|
2006-09-22 12:55:11 -07:00
|
|
|
if (!fstrip) return;
|
2009-04-13 07:56:38 -07:00
|
|
|
len = e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s.edj", fstrip);
|
|
|
|
if (len >= sizeof(buf)) return;
|
2009-04-18 16:13:33 -07:00
|
|
|
off = len - (sizeof(".edj") - 1);
|
2010-05-24 19:45:00 -07:00
|
|
|
for (num = 1; ecore_file_exists(buf) && num < 100; num++)
|
2006-08-12 05:49:52 -07:00
|
|
|
{
|
2009-04-13 07:56:38 -07:00
|
|
|
snprintf(buf + off, sizeof(buf) - off, "-%d.edj", num);
|
2006-08-12 05:49:52 -07:00
|
|
|
}
|
2006-08-07 13:25:34 -07:00
|
|
|
free(fstrip);
|
2010-05-24 19:45:00 -07:00
|
|
|
|
|
|
|
if (num == 100)
|
|
|
|
{
|
|
|
|
printf("Couldn't come up with another filename for %s\n", buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
strcpy(tmpn, "/tmp/e_bgdlg_new.edc-tmp-XXXXXX");
|
|
|
|
fd = mkstemp(tmpn);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
printf("Error Creating tmp file: %s\n", strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
close(fd);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
f = fopen(tmpn, "w");
|
|
|
|
if (!f)
|
|
|
|
{
|
2006-08-14 04:08:40 -07:00
|
|
|
printf("Cannot open %s for writing\n", tmpn);
|
2006-08-07 13:25:34 -07:00
|
|
|
return;
|
|
|
|
}
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2007-07-25 10:01:04 -07:00
|
|
|
imgdir = ecore_file_dir_get(import->cfdata->file);
|
2006-08-07 13:25:34 -07:00
|
|
|
if (!imgdir) ipart[0] = '\0';
|
|
|
|
else
|
|
|
|
{
|
2006-08-20 15:51:12 -07:00
|
|
|
snprintf(ipart, sizeof(ipart), "-id %s", e_util_filename_escape(imgdir));
|
2006-08-07 13:25:34 -07:00
|
|
|
free(imgdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
img = evas_object_image_add(evas);
|
|
|
|
evas_object_image_file_set(img, import->cfdata->file, NULL);
|
|
|
|
evas_object_image_size_get(img, &w, &h);
|
2009-04-03 17:37:57 -07:00
|
|
|
evas_object_del(img);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-11-17 07:04:52 -08:00
|
|
|
if (import->cfdata->external)
|
|
|
|
{
|
|
|
|
fstrip = strdup(e_util_filename_escape(import->cfdata->file));
|
|
|
|
snprintf(enc, sizeof(enc), "USER");
|
|
|
|
}
|
2006-08-08 13:41:46 -07:00
|
|
|
else
|
2006-11-17 07:04:52 -08:00
|
|
|
{
|
|
|
|
fstrip = strdup(e_util_filename_escape(file));
|
|
|
|
if (import->cfdata->quality == 100)
|
|
|
|
snprintf(enc, sizeof(enc), "COMP");
|
|
|
|
else
|
|
|
|
snprintf(enc, sizeof(enc), "LOSSY %i", import->cfdata->quality);
|
|
|
|
}
|
2006-08-07 13:25:34 -07:00
|
|
|
switch (import->cfdata->method)
|
|
|
|
{
|
2006-08-08 13:41:46 -07:00
|
|
|
case IMPORT_STRETCH:
|
|
|
|
fprintf(f,
|
|
|
|
"images { image: \"%s\" %s; }\n"
|
|
|
|
"collections {\n"
|
2006-08-22 20:30:41 -07:00
|
|
|
"group { name: \"e/desktop/background\";\n"
|
2007-10-27 17:58:17 -07:00
|
|
|
"data { item: \"style\" \"0\"; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"max: %i %i;\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
"parts {\n"
|
|
|
|
"part { name: \"bg\"; mouse_events: 0;\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"description { state: \"default\" 0.0;\n"
|
2009-05-07 06:27:11 -07:00
|
|
|
"image { normal: \"%s\"; scale_hint: STATIC; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"} } } } }\n"
|
|
|
|
, fstrip, enc, w, h, fstrip);
|
2006-08-07 13:25:34 -07:00
|
|
|
break;
|
|
|
|
case IMPORT_TILE:
|
2006-08-08 13:41:46 -07:00
|
|
|
fprintf(f,
|
|
|
|
"images { image: \"%s\" %s; }\n"
|
|
|
|
"collections {\n"
|
2006-08-22 20:30:41 -07:00
|
|
|
"group { name: \"e/desktop/background\";\n"
|
2007-10-27 17:58:17 -07:00
|
|
|
"data { item: \"style\" \"1\"; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"max: %i %i;\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
"parts {\n"
|
|
|
|
"part { name: \"bg\"; mouse_events: 0;\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"description { state: \"default\" 0.0;\n"
|
|
|
|
"image { normal: \"%s\"; }\n"
|
|
|
|
"fill { size {\n"
|
|
|
|
"relative: 0.0 0.0;\n"
|
|
|
|
"offset: %i %i;\n"
|
|
|
|
"} } } } } } }\n"
|
|
|
|
, fstrip, enc, w, h, fstrip, w, h);
|
2006-08-07 13:25:34 -07:00
|
|
|
break;
|
2006-08-08 13:41:46 -07:00
|
|
|
case IMPORT_CENTER:
|
|
|
|
fprintf(f,
|
|
|
|
"images { image: \"%s\" %s; }\n"
|
|
|
|
"collections {\n"
|
2006-08-22 20:30:41 -07:00
|
|
|
"group { name: \"e/desktop/background\";\n"
|
2007-10-27 17:58:17 -07:00
|
|
|
"data { item: \"style\" \"2\"; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"max: %i %i;\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
"parts {\n"
|
|
|
|
"part { name: \"col\"; type: RECT; mouse_events: 0;\n"
|
|
|
|
"description { state: \"default\" 0.0;\n"
|
|
|
|
"color: %i %i %i %i;\n"
|
|
|
|
"} }\n"
|
|
|
|
"part { name: \"bg\"; mouse_events: 0;\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"description { state: \"default\" 0.0;\n"
|
2006-08-13 03:00:49 -07:00
|
|
|
"min: %i %i; max: %i %i;\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"image { normal: \"%s\"; }\n"
|
|
|
|
"} } } } }\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
, fstrip, enc, w, h, cr, cg, cb, ca, w, h, w, h, fstrip);
|
2006-08-08 13:41:46 -07:00
|
|
|
break;
|
|
|
|
case IMPORT_SCALE_ASPECT_IN:
|
2009-04-03 17:37:57 -07:00
|
|
|
locale = e_intl_language_get();
|
|
|
|
setlocale(LC_NUMERIC, "C");
|
2006-08-08 13:41:46 -07:00
|
|
|
fprintf(f,
|
|
|
|
"images { image: \"%s\" %s; }\n"
|
|
|
|
"collections {\n"
|
2006-08-22 20:30:41 -07:00
|
|
|
"group { name: \"e/desktop/background\";\n"
|
2007-10-27 17:58:17 -07:00
|
|
|
"data { item: \"style\" \"3\"; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"max: %i %i;\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
"parts {\n"
|
|
|
|
"part { name: \"col\"; type: RECT; mouse_events: 0;\n"
|
|
|
|
"description { state: \"default\" 0.0;\n"
|
|
|
|
"color: %i %i %i %i;\n"
|
|
|
|
"} }\n"
|
|
|
|
"part { name: \"bg\"; mouse_events: 0;\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"description { state: \"default\" 0.0;\n"
|
|
|
|
"aspect: %1.9f %1.9f; aspect_preference: BOTH;\n"
|
2009-05-07 06:27:11 -07:00
|
|
|
"image { normal: \"%s\"; scale_hint: STATIC; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"} } } } }\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
, fstrip, enc, w, h, cr, cg, cb, ca, (double)w / (double)h, (double)w / (double)h, fstrip);
|
2009-04-03 17:37:57 -07:00
|
|
|
setlocale(LC_NUMERIC, locale);
|
2006-08-08 13:41:46 -07:00
|
|
|
break;
|
|
|
|
case IMPORT_SCALE_ASPECT_OUT:
|
2009-04-03 17:37:57 -07:00
|
|
|
locale = e_intl_language_get();
|
|
|
|
setlocale(LC_NUMERIC, "C");
|
2006-08-08 13:41:46 -07:00
|
|
|
fprintf(f,
|
|
|
|
"images { image: \"%s\" %s; }\n"
|
|
|
|
"collections {\n"
|
2006-08-22 20:30:41 -07:00
|
|
|
"group { name: \"e/desktop/background\";\n"
|
2007-10-27 17:58:17 -07:00
|
|
|
"data { item: \"style\" \"4\"; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"max: %i %i;\n"
|
2006-08-12 20:17:34 -07:00
|
|
|
"parts {\n"
|
|
|
|
"part { name: \"bg\"; mouse_events: 0;\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"description { state: \"default\" 0.0;\n"
|
|
|
|
"aspect: %1.9f %1.9f; aspect_preference: NONE;\n"
|
2009-05-07 06:27:11 -07:00
|
|
|
"image { normal: \"%s\"; scale_hint: STATIC; }\n"
|
2006-08-08 13:41:46 -07:00
|
|
|
"} } } } }\n"
|
|
|
|
, fstrip, enc, w, h, (double)w / (double)h, (double)w / (double)h, fstrip);
|
2009-04-03 17:37:57 -07:00
|
|
|
setlocale(LC_NUMERIC, locale);
|
2006-08-08 13:41:46 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* won't happen */
|
2006-08-07 13:25:34 -07:00
|
|
|
break;
|
|
|
|
}
|
2006-08-08 13:41:46 -07:00
|
|
|
free(fstrip);
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s",
|
|
|
|
ipart, tmpn, e_util_filename_escape(buf));
|
|
|
|
|
|
|
|
import->tmpf = strdup(tmpn);
|
|
|
|
import->fdest = strdup(buf);
|
2007-10-27 17:58:17 -07:00
|
|
|
import->exe_handler =
|
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
|
|
|
_import_cb_edje_cc_exit, import);
|
2006-08-07 13:25:34 -07:00
|
|
|
import->exe = ecore_exe_run(cmd, NULL);
|
|
|
|
}
|
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_import_cb_edje_cc_exit(void *data, __UNUSED__ int type, void *event)
|
2006-08-07 13:25:34 -07:00
|
|
|
{
|
|
|
|
Import *import;
|
2009-04-01 20:46:22 -07:00
|
|
|
FSel *fsel;
|
2006-08-07 13:25:34 -07:00
|
|
|
Ecore_Exe_Event_Del *ev;
|
2009-04-01 20:46:22 -07:00
|
|
|
char *fdest;
|
|
|
|
int r = 1;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
ev = event;
|
|
|
|
import = data;
|
2010-06-24 09:19:12 -07:00
|
|
|
if (ev->exe != import->exe) return ECORE_CALLBACK_PASS_ON;
|
2006-08-12 05:49:52 -07:00
|
|
|
|
|
|
|
if (ev->exit_code != 0)
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Picture Import Error"),
|
|
|
|
_("Enlightenment was unable to import the picture<br>"
|
|
|
|
"due to conversion errors."));
|
2009-04-01 20:46:22 -07:00
|
|
|
r = 0;
|
2006-08-12 05:49:52 -07:00
|
|
|
}
|
2007-10-24 01:37:48 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
fsel = import->fsel;
|
|
|
|
fdest = strdup(import->fdest);
|
|
|
|
e_int_config_wallpaper_import_del(import->win);
|
|
|
|
if (fsel)
|
|
|
|
{
|
2009-10-09 14:49:03 -07:00
|
|
|
if ((r) && (fsel->parent))
|
|
|
|
e_int_config_wallpaper_update(fsel->parent, fdest);
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_fsel_del(fsel->win);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
e_bg_default_set(fdest);
|
|
|
|
e_bg_update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
E_FREE(fdest);
|
2006-08-07 13:25:34 -07:00
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_import_cb_delete(E_Win *win)
|
|
|
|
{
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_import_del(win);
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_import_cb_resize(E_Win *win)
|
|
|
|
{
|
|
|
|
Import *import;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
|
|
|
if (!(import = win->data)) return;
|
2006-08-07 13:25:34 -07:00
|
|
|
evas_object_resize(import->bg_obj, win->w, win->h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_import_cb_close(void *data, void *data2)
|
|
|
|
{
|
|
|
|
E_Win *win;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
win = data;
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_import_del(win);
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_import_cb_ok(void *data, void *data2)
|
|
|
|
{
|
|
|
|
Import *import;
|
2009-04-01 20:46:22 -07:00
|
|
|
FSel *fsel;
|
2006-08-07 13:25:34 -07:00
|
|
|
E_Win *win;
|
2006-09-01 21:43:55 -07:00
|
|
|
const char *file;
|
2006-09-22 12:55:11 -07:00
|
|
|
char buf[4096];
|
2006-09-01 21:43:55 -07:00
|
|
|
int is_bg, is_theme;
|
2009-04-01 20:46:22 -07:00
|
|
|
int r;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
r = 0;
|
2006-08-07 13:25:34 -07:00
|
|
|
win = data;
|
2008-05-12 13:40:00 -07:00
|
|
|
if (!(import = win->data)) return;
|
2006-08-07 13:25:34 -07:00
|
|
|
if (import->cfdata->file)
|
|
|
|
{
|
2007-07-25 10:01:04 -07:00
|
|
|
file = ecore_file_file_get(import->cfdata->file);
|
2006-09-01 21:43:55 -07:00
|
|
|
if (!e_util_glob_case_match(file, "*.edj"))
|
2009-04-01 20:46:22 -07:00
|
|
|
{
|
|
|
|
_import_edj_gen(import);
|
|
|
|
e_win_hide(win);
|
|
|
|
return;
|
|
|
|
}
|
2006-09-01 21:43:55 -07:00
|
|
|
else
|
|
|
|
{
|
2009-04-13 07:56:38 -07:00
|
|
|
e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s", file);
|
2006-09-22 12:55:11 -07:00
|
|
|
|
2006-09-01 22:15:01 -07:00
|
|
|
is_bg = edje_file_group_exists(import->cfdata->file,
|
|
|
|
"e/desktop/background");
|
2006-09-01 21:43:55 -07:00
|
|
|
is_theme =
|
2006-09-01 22:15:01 -07:00
|
|
|
edje_file_group_exists(import->cfdata->file,
|
|
|
|
"e/widgets/border/default/border");
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-09-01 21:43:55 -07:00
|
|
|
if ((is_bg) && (!is_theme))
|
|
|
|
{
|
|
|
|
if (!ecore_file_cp(import->cfdata->file, buf))
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Wallpaper Import Error"),
|
|
|
|
_("Enlightenment was unable to "
|
|
|
|
"import the wallpaper<br>due to a "
|
2006-11-19 00:58:05 -08:00
|
|
|
"copy error."));
|
2006-09-01 21:43:55 -07:00
|
|
|
}
|
|
|
|
else
|
2009-04-01 20:46:22 -07:00
|
|
|
r = 1;
|
2006-09-01 21:43:55 -07:00
|
|
|
}
|
|
|
|
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?"));
|
|
|
|
}
|
|
|
|
}
|
2009-04-01 20:46:22 -07:00
|
|
|
}
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2009-04-01 20:46:22 -07:00
|
|
|
fsel = import->fsel;
|
|
|
|
e_int_config_wallpaper_import_del(win);
|
|
|
|
if (fsel)
|
|
|
|
{
|
2009-10-09 14:49:03 -07:00
|
|
|
if ((r) && (fsel->parent))
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_update(fsel->parent, buf);
|
|
|
|
e_int_config_wallpaper_fsel_del(fsel->win);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
e_bg_default_set(buf);
|
|
|
|
e_bg_update();
|
|
|
|
}
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
2009-04-01 20:46:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_fsel_cb_delete(E_Win *win)
|
|
|
|
{
|
|
|
|
e_int_config_wallpaper_fsel_del(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_fsel_cb_resize(E_Win *win)
|
|
|
|
{
|
2009-07-26 20:45:18 -07:00
|
|
|
FSel *fsel;
|
2009-04-01 20:46:22 -07:00
|
|
|
|
2009-07-26 20:45:18 -07:00
|
|
|
if (!(fsel = win->data)) return;
|
|
|
|
evas_object_resize(fsel->bg_obj, win->w, win->h);
|
2009-04-01 20:46:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2010-01-15 11:36:00 -08:00
|
|
|
if (!path) return;
|
2009-04-01 20:46:22 -07:00
|
|
|
|
2010-01-15 11:36:00 -08:00
|
|
|
p = strrchr(path, '.');
|
2009-04-01 20:46:22 -07:00
|
|
|
if ((!p) || (!strcasecmp(p, ".edj")))
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
int is_bg, is_theme;
|
2009-04-13 07:56:38 -07:00
|
|
|
const char *file;
|
2009-04-01 20:46:22 -07:00
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
r = 0;
|
|
|
|
file = ecore_file_file_get(path);
|
2009-04-13 07:56:38 -07:00
|
|
|
e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s", file);
|
2009-04-01 20:46:22 -07:00
|
|
|
|
2009-10-09 14:49:03 -07:00
|
|
|
is_bg = edje_file_group_exists(path, "e/desktop/background");
|
2009-04-01 20:46:22 -07:00
|
|
|
is_theme =
|
2009-10-09 14:49:03 -07:00
|
|
|
edje_file_group_exists(path, "e/widgets/border/default/border");
|
2009-04-01 20:46:22 -07:00
|
|
|
|
|
|
|
if ((is_bg) && (!is_theme))
|
|
|
|
{
|
|
|
|
if (!ecore_file_cp(path, buf))
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Wallpaper Import Error"),
|
2009-10-09 14:49:03 -07:00
|
|
|
_("Enlightenment was unable to "
|
|
|
|
"import the wallpaper<br>due to a "
|
|
|
|
"copy error."));
|
2009-04-01 20:46:22 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
r = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Wallpaper Import Error"),
|
2009-10-09 14:49:03 -07:00
|
|
|
_("Enlightenment was unable to "
|
|
|
|
"import the wallpaper.<br><br>"
|
|
|
|
"Are you sure this is a valid "
|
|
|
|
"wallpaper?"));
|
2009-04-01 20:46:22 -07:00
|
|
|
}
|
|
|
|
|
2009-10-09 14:49:03 -07:00
|
|
|
if ((r) && (fsel->parent))
|
2009-04-01 20:46:22 -07:00
|
|
|
e_int_config_wallpaper_update(fsel->parent, buf);
|
|
|
|
e_int_config_wallpaper_fsel_del(fsel->win);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_int_config_wallpaper_import(fsel, path);
|
2006-08-07 13:25:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_import_cb_wid_on_focus(void *data, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Import *import;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
import = data;
|
|
|
|
if (obj == import->content_obj)
|
|
|
|
e_widget_focused_object_clear(import->box_obj);
|
|
|
|
else if (import->content_obj)
|
|
|
|
e_widget_focused_object_clear(import->content_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_import_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
|
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev;
|
|
|
|
Import *import;
|
|
|
|
|
|
|
|
ev = event;
|
|
|
|
import = data;
|
|
|
|
if (!strcmp(ev->keyname, "Tab"))
|
|
|
|
{
|
|
|
|
if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(import->win)), "Shift"))
|
|
|
|
{
|
|
|
|
if (e_widget_focus_get(import->box_obj))
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(import->box_obj, 0))
|
|
|
|
{
|
|
|
|
e_widget_focus_set(import->content_obj, 0);
|
|
|
|
if (!e_widget_focus_get(import->content_obj))
|
|
|
|
e_widget_focus_set(import->box_obj, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(import->content_obj, 0))
|
|
|
|
e_widget_focus_set(import->box_obj, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e_widget_focus_get(import->box_obj))
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(import->box_obj, 1))
|
|
|
|
{
|
|
|
|
e_widget_focus_set(import->content_obj, 1);
|
|
|
|
if (!e_widget_focus_get(import->content_obj))
|
|
|
|
e_widget_focus_set(import->box_obj, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(import->content_obj, 1))
|
|
|
|
e_widget_focus_set(import->box_obj, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (((!strcmp(ev->keyname, "Return")) ||
|
|
|
|
(!strcmp(ev->keyname, "KP_Enter")) ||
|
|
|
|
(!strcmp(ev->keyname, "space"))))
|
|
|
|
{
|
|
|
|
Evas_Object *o = NULL;
|
2008-05-12 13:40:00 -07:00
|
|
|
|
2006-08-07 13:25:34 -07:00
|
|
|
if ((import->content_obj) && (e_widget_focus_get(import->content_obj)))
|
|
|
|
o = e_widget_focused_object_get(import->content_obj);
|
|
|
|
else
|
|
|
|
o = e_widget_focused_object_get(import->box_obj);
|
|
|
|
if (o) e_widget_activate(o);
|
|
|
|
}
|
|
|
|
}
|
2009-04-01 20:46:22 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|