forked from enlightenment/enlightenment
remove all traces of old and unused bg import dialog. whoever put a separate import dialog into e_utils.c, and the person who committed r44556 with the id "barbieri" on 2009-12-18 shall indeed remain nameless, decided to leave the other one hanging around. as a result, the one that he copied from the original sat around without being modified, and now ended up being removed instead of being properly integrated
SVN revision: 75052
This commit is contained in:
parent
516ff07701
commit
f6af7bd8d2
255
src/bin/e_bg.c
255
src/bin/e_bg.c
|
@ -4,26 +4,12 @@
|
|||
static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _e_bg_event_bg_update_free(void *data, void *event);
|
||||
|
||||
static void _e_bg_image_import_dialog_done(void *data, const char *path, Eina_Bool ok, Eina_Bool external, int quality, E_Image_Import_Mode mode);
|
||||
static void _e_bg_image_import_done(void *data, Eina_Bool ok, const char *image_path, const char *edje_path);
|
||||
static void _e_bg_handler_image_imported(void *data, const char *image_path);
|
||||
static void _e_bg_handler_image_imported(const char *image_path, void *data);
|
||||
|
||||
/* local subsystem globals */
|
||||
EAPI int E_EVENT_BG_UPDATE = 0;
|
||||
static E_Fm2_Mime_Handler *bg_hdl = NULL;
|
||||
|
||||
struct _E_Bg_Image_Import_Handle
|
||||
{
|
||||
struct
|
||||
{
|
||||
void (*func)(void *data, const char *edje_file);
|
||||
void *data;
|
||||
} cb;
|
||||
E_Dialog *dia;
|
||||
E_Util_Image_Import_Handle *importer;
|
||||
Eina_Bool canceled : 1;
|
||||
};
|
||||
|
||||
/* externally accessible functions */
|
||||
EINTERN int
|
||||
e_bg_init(void)
|
||||
|
@ -451,105 +437,6 @@ e_bg_update(void)
|
|||
}
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
_e_bg_file_edje_check(const char *path)
|
||||
{
|
||||
const char *ext;
|
||||
const size_t extlen = sizeof(".edj") - 1;
|
||||
size_t len;
|
||||
|
||||
if (!path) return EINA_FALSE;
|
||||
|
||||
len = strlen(path);
|
||||
if (len <= extlen) return EINA_FALSE;
|
||||
ext = path + len - extlen;
|
||||
return memcmp(ext, ".edj", extlen) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through process of importing an image as E background.
|
||||
*
|
||||
* This will go through process of importing an image as E
|
||||
* background. It will ask fill/tile mode of the image, as well as
|
||||
* quality to use.
|
||||
*
|
||||
* User can cancel operation at any time, and in this case callback is
|
||||
* called with @c NULL as second parameter.
|
||||
*
|
||||
* The operation can be canceled by application/module as well using
|
||||
* e_bg_image_import_cancel(). Even in this case the callback is called so user
|
||||
* can free possibly allocated data.
|
||||
*
|
||||
* @param image_file source file to use, must be supported by Evas.
|
||||
* @param cb callback to call when import process is done. The first
|
||||
* argument is the given data, while the second is the path to
|
||||
* the imported background file (edje) that can be used with
|
||||
* e_bg_add() or e_bg_default_set(). Note that if @a edje_file
|
||||
* is @c NULL, then the import process was canceled!
|
||||
* This function is @b always called and after it returns
|
||||
* E_Bg_Image_Import_Handle is deleted.
|
||||
* @param data pointer to data to be given to callback.
|
||||
*
|
||||
* @return handle to the import process. It will die automatically
|
||||
* when user cancels the process or when code automatically
|
||||
* calls e_bg_image_import_cancel(). Before dying, callback
|
||||
* will always be called.
|
||||
*/
|
||||
EAPI E_Bg_Image_Import_Handle *
|
||||
e_bg_image_import(const char *image_file, void (*cb)(void *data, const char *edje_file), const void *data)
|
||||
{
|
||||
E_Bg_Image_Import_Handle *handle;
|
||||
|
||||
if (!image_file) return NULL;
|
||||
if (!cb) return NULL;
|
||||
|
||||
handle = E_NEW(E_Bg_Image_Import_Handle, 1);
|
||||
if (!handle) return NULL;
|
||||
handle->cb.func = cb;
|
||||
handle->cb.data = (void *)data;
|
||||
|
||||
handle->dia = e_util_image_import_settings_new
|
||||
(image_file, _e_bg_image_import_dialog_done, handle);
|
||||
if (!handle->dia)
|
||||
{
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
e_dialog_show(handle->dia);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels previously started import process.
|
||||
*
|
||||
* Note that his handle will be deleted when process import, so don't
|
||||
* call it after your callback is called!
|
||||
*/
|
||||
EAPI void
|
||||
e_bg_image_import_cancel(E_Bg_Image_Import_Handle *handle)
|
||||
{
|
||||
if (!handle) return;
|
||||
|
||||
handle->canceled = EINA_TRUE;
|
||||
|
||||
if (handle->cb.func)
|
||||
{
|
||||
handle->cb.func(handle->cb.data, NULL);
|
||||
handle->cb.func = NULL;
|
||||
}
|
||||
if (handle->dia)
|
||||
{
|
||||
e_object_del(E_OBJECT(handle->dia));
|
||||
handle->dia = NULL;
|
||||
}
|
||||
else if (handle->importer)
|
||||
{
|
||||
e_util_image_import_cancel(handle->importer);
|
||||
handle->importer = NULL;
|
||||
}
|
||||
E_FREE(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set background to image, as required in e_fm2_mime_handler_new()
|
||||
|
@ -557,55 +444,57 @@ e_bg_image_import_cancel(E_Bg_Image_Import_Handle *handle)
|
|||
EAPI void
|
||||
e_bg_handler_set(Evas_Object *obj __UNUSED__, const char *path, void *data __UNUSED__)
|
||||
{
|
||||
E_Container *con;
|
||||
char buf[PATH_MAX];
|
||||
int copy = 1;
|
||||
E_Zone *zone;
|
||||
E_Desk *desk;
|
||||
|
||||
if (!path) return;
|
||||
|
||||
if (_e_bg_file_edje_check(path))
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
if (!eina_str_has_extension(path, "edj"))
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
int copy = 1;
|
||||
e_import_config_dialog_show(con, path, (Ecore_End_Cb)_e_bg_handler_image_imported, NULL);
|
||||
return;
|
||||
}
|
||||
zone = e_zone_current_get(con);
|
||||
desk = e_desk_current_get(zone);
|
||||
|
||||
E_Container *con = e_container_current_get(e_manager_current_get());
|
||||
E_Zone *zone = e_zone_current_get(con);
|
||||
E_Desk *desk = e_desk_current_get(zone);
|
||||
|
||||
/* if not in system dir or user dir, copy to user dir */
|
||||
e_prefix_data_concat_static(buf, "data/backgrounds");
|
||||
/* if not in system dir or user dir, copy to user dir */
|
||||
e_prefix_data_concat_static(buf, "data/backgrounds");
|
||||
if (!strncmp(buf, path, strlen(buf)))
|
||||
copy = 0;
|
||||
if (copy)
|
||||
{
|
||||
e_user_dir_concat_static(buf, "backgrounds");
|
||||
if (!strncmp(buf, path, strlen(buf)))
|
||||
copy = 0;
|
||||
if (copy)
|
||||
}
|
||||
if (copy)
|
||||
{
|
||||
const char *file;
|
||||
char *name;
|
||||
|
||||
file = ecore_file_file_get(path);
|
||||
name = ecore_file_strip_ext(file);
|
||||
|
||||
e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s-%f.edj", name, ecore_time_unix_get());
|
||||
free(name);
|
||||
|
||||
if (!ecore_file_exists(buf))
|
||||
{
|
||||
e_user_dir_concat_static(buf, "backgrounds");
|
||||
if (!strncmp(buf, path, strlen(buf)))
|
||||
copy = 0;
|
||||
}
|
||||
if (copy)
|
||||
{
|
||||
const char *file;
|
||||
char *name;
|
||||
|
||||
file = ecore_file_file_get(path);
|
||||
name = ecore_file_strip_ext(file);
|
||||
|
||||
e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s-%f.edj", name, ecore_time_unix_get());
|
||||
free(name);
|
||||
|
||||
if (!ecore_file_exists(buf))
|
||||
{
|
||||
ecore_file_cp(path, buf);
|
||||
e_bg_add(con->num, zone->num, desk->x, desk->y, buf);
|
||||
}
|
||||
else
|
||||
e_bg_add(con->num, zone->num, desk->x, desk->y, path);
|
||||
ecore_file_cp(path, buf);
|
||||
e_bg_add(con->num, zone->num, desk->x, desk->y, buf);
|
||||
}
|
||||
else
|
||||
e_bg_add(con->num, zone->num, desk->x, desk->y, path);
|
||||
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
return;
|
||||
}
|
||||
else
|
||||
e_bg_add(con->num, zone->num, desk->x, desk->y, path);
|
||||
|
||||
e_bg_image_import(path, _e_bg_handler_image_imported, NULL);
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -625,7 +514,7 @@ e_bg_handler_test(Evas_Object *obj __UNUSED__, const char *path, void *data __UN
|
|||
{
|
||||
if (!path) return 0;
|
||||
|
||||
if (_e_bg_file_edje_check(path))
|
||||
if (eina_str_has_extension(path, "edj"))
|
||||
{
|
||||
if (edje_file_group_exists(path, "e/desktop/background")) return 1;
|
||||
return 0;
|
||||
|
@ -665,72 +554,12 @@ _e_bg_event_bg_update_free(void *data __UNUSED__, void *event)
|
|||
}
|
||||
|
||||
static void
|
||||
_e_bg_image_import_dialog_done(void *data, const char *path, Eina_Bool ok, Eina_Bool external, int quality, E_Image_Import_Mode mode)
|
||||
{
|
||||
E_Bg_Image_Import_Handle *handle = data;
|
||||
const char *file;
|
||||
char *name;
|
||||
char buf[PATH_MAX];
|
||||
size_t used, off;
|
||||
unsigned num;
|
||||
|
||||
if (!ok) goto aborted;
|
||||
|
||||
file = ecore_file_file_get(path);
|
||||
if (!file) goto aborted;
|
||||
name = ecore_file_strip_ext(file);
|
||||
if (!name) goto aborted;
|
||||
|
||||
used = e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s.edj", name);
|
||||
free(name);
|
||||
if (used >= sizeof(buf)) goto aborted;
|
||||
|
||||
off = used - (sizeof(".edj") - 1);
|
||||
|
||||
for (num = 0; ecore_file_exists(buf); num++)
|
||||
snprintf(buf + off, sizeof(buf) - off, "-%u.edj", num);
|
||||
|
||||
handle->importer = e_util_image_import
|
||||
(path, buf, "e/desktop/background", external, quality, mode,
|
||||
_e_bg_image_import_done, handle);
|
||||
if (!handle->importer) goto aborted;
|
||||
|
||||
return;
|
||||
|
||||
aborted:
|
||||
if (handle->cb.func)
|
||||
{
|
||||
handle->cb.func(handle->cb.data, NULL);
|
||||
handle->cb.func = NULL;
|
||||
}
|
||||
if (!handle->canceled) E_FREE(handle);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_bg_image_import_done(void *data, Eina_Bool ok, const char *image_path __UNUSED__, const char *edje_path)
|
||||
{
|
||||
E_Bg_Image_Import_Handle *handle = data;
|
||||
|
||||
if (!ok) edje_path = NULL;
|
||||
|
||||
if (handle->cb.func)
|
||||
{
|
||||
handle->cb.func(handle->cb.data, edje_path);
|
||||
handle->cb.func = NULL;
|
||||
}
|
||||
|
||||
if (!handle->canceled) E_FREE(handle);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_bg_handler_image_imported(void *data __UNUSED__, const char *image_path)
|
||||
_e_bg_handler_image_imported(const char *image_path, void *data __UNUSED__)
|
||||
{
|
||||
E_Container *con = e_container_current_get(e_manager_current_get());
|
||||
E_Zone *zone = e_zone_current_get(con);
|
||||
E_Desk *desk = e_desk_current_get(zone);
|
||||
|
||||
if (!image_path) return;
|
||||
|
||||
e_bg_add(con->num, zone->num, desk->x, desk->y, image_path);
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
|
|
|
@ -10,7 +10,6 @@ EAPI E_Path *path_backgrounds = NULL;
|
|||
EAPI E_Path *path_messages = NULL;
|
||||
|
||||
typedef struct _E_Util_Fake_Mouse_Up_Info E_Util_Fake_Mouse_Up_Info;
|
||||
typedef struct _E_Util_Image_Import_Settings E_Util_Image_Import_Settings;
|
||||
|
||||
struct _E_Util_Fake_Mouse_Up_Info
|
||||
{
|
||||
|
@ -18,45 +17,10 @@ struct _E_Util_Fake_Mouse_Up_Info
|
|||
int button;
|
||||
};
|
||||
|
||||
struct _E_Util_Image_Import_Settings
|
||||
{
|
||||
E_Dialog *dia;
|
||||
struct
|
||||
{
|
||||
void (*func)(void *data, const char *path, Eina_Bool ok, Eina_Bool external, int quality, E_Image_Import_Mode mode);
|
||||
void *data;
|
||||
} cb;
|
||||
const char *path;
|
||||
int quality;
|
||||
int external;
|
||||
int mode;
|
||||
Eina_Bool ok;
|
||||
};
|
||||
|
||||
struct _E_Util_Image_Import_Handle
|
||||
{
|
||||
Ecore_Exe *exe;
|
||||
Ecore_Event_Handler *handler;
|
||||
struct
|
||||
{
|
||||
void (*func)(void *data, Eina_Bool ok, const char *image_path, const char *edje_path);
|
||||
void *data;
|
||||
} cb;
|
||||
struct
|
||||
{
|
||||
const char *image, *edje, *temp;
|
||||
} path;
|
||||
};
|
||||
|
||||
/* local subsystem functions */
|
||||
static Eina_Bool _e_util_cb_delayed_del(void *data);
|
||||
static Eina_Bool _e_util_wakeup_cb(void *data);
|
||||
|
||||
static void _e_util_image_import_settings_do(void *data, E_Dialog *dia);
|
||||
static void _e_util_image_import_settings_del(void *obj);
|
||||
|
||||
static Eina_Bool _e_util_image_import_exit(void *data, int type __UNUSED__, void *event);
|
||||
static void _e_util_image_import_handle_free(E_Util_Image_Import_Handle *handle);
|
||||
static Evas_Object *_e_util_icon_add(const char *path, Evas *evas, int size);
|
||||
|
||||
static void _e_util_cb_delayed_cancel(void *data, void *obj);
|
||||
|
@ -1203,290 +1167,6 @@ e_util_win_auto_resize_fill(E_Win *win)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new dialog to query image import settings, report results.
|
||||
*
|
||||
* @param path may be used to display live preview (not used so far).
|
||||
* @param cb function to call before exit. Last parameter is mode of
|
||||
* image filling.
|
||||
* @param data extra data to give to @a cb as first argument.
|
||||
*
|
||||
* @return newly allocated window on success, @c NULL on failure. If
|
||||
* @c NULL is returned, then callback is never called!
|
||||
*/
|
||||
EAPI E_Dialog *
|
||||
e_util_image_import_settings_new(const char *path, void (*cb)(void *data, const char *path, Eina_Bool ok, Eina_Bool external, int quality, E_Image_Import_Mode mode), const void *data)
|
||||
{
|
||||
Evas *evas;
|
||||
E_Util_Image_Import_Settings *ctxt;
|
||||
Evas_Object *vlist, *frame, *radio, *check, *slider;
|
||||
E_Radio_Group *rg;
|
||||
Evas_Coord w, h;
|
||||
|
||||
if (!path) return NULL;
|
||||
if (!cb) return NULL;
|
||||
|
||||
ctxt = E_NEW(E_Util_Image_Import_Settings, 1);
|
||||
if (!ctxt) return NULL;
|
||||
|
||||
ctxt->dia = e_dialog_new(NULL, "E", "_image_import_settings");
|
||||
if (!ctxt->dia)
|
||||
{
|
||||
E_FREE(ctxt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctxt->dia->data = ctxt;
|
||||
|
||||
e_object_del_attach_func_set
|
||||
(E_OBJECT(ctxt->dia), _e_util_image_import_settings_del);
|
||||
e_dialog_title_set(ctxt->dia, _("Image Import Settings"));
|
||||
e_dialog_border_icon_set(ctxt->dia, "dialog-ask");
|
||||
|
||||
e_dialog_button_add
|
||||
(ctxt->dia, _("Import"), NULL, _e_util_image_import_settings_do, ctxt);
|
||||
e_dialog_button_add
|
||||
(ctxt->dia, _("Cancel"), NULL, NULL, ctxt);
|
||||
e_dialog_button_focus_num(ctxt->dia, 0);
|
||||
|
||||
ctxt->cb.func = cb;
|
||||
ctxt->cb.data = (void *)data;
|
||||
ctxt->path = eina_stringshare_add(path);
|
||||
ctxt->quality = 90;
|
||||
ctxt->ok = EINA_FALSE;
|
||||
ctxt->external = EINA_FALSE;
|
||||
ctxt->mode = E_IMAGE_IMPORT_STRETCH;
|
||||
|
||||
evas = e_win_evas_get(ctxt->dia->win);
|
||||
|
||||
vlist = e_widget_list_add(evas, 0, 0);
|
||||
|
||||
frame = e_widget_frametable_add(evas, _("Fill and Stretch Options"), 1);
|
||||
rg = e_widget_radio_group_new(&ctxt->mode);
|
||||
|
||||
#define RD(lbl, icon, val, col, row) \
|
||||
radio = e_widget_radio_icon_add \
|
||||
(evas, lbl, "enlightenment/wallpaper_"icon, 24, 24, val, rg); \
|
||||
e_widget_frametable_object_append(frame, radio, col, row, 1, 1, 1, 1, 0, 0)
|
||||
|
||||
RD(_("Stretch"), "stretch", E_IMAGE_IMPORT_STRETCH, 0, 0);
|
||||
RD(_("Center"), "center", E_IMAGE_IMPORT_CENTER, 1, 0);
|
||||
RD(_("Tile"), "tile", E_IMAGE_IMPORT_TILE, 2, 0);
|
||||
RD(_("Within"), "scale_aspect_in", E_IMAGE_IMPORT_SCALE_ASPECT_IN, 3, 0);
|
||||
RD(_("Fill"), "scale_aspect_out", E_IMAGE_IMPORT_SCALE_ASPECT_OUT, 4, 0);
|
||||
#undef RD
|
||||
|
||||
e_widget_list_object_append(vlist, frame, 1, 1, 0.5);
|
||||
|
||||
frame = e_widget_frametable_add(evas, _("File Quality"), 0);
|
||||
|
||||
check = e_widget_check_add(evas, _("Use original file"), &ctxt->external);
|
||||
e_widget_frametable_object_append(frame, check, 0, 0, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
slider = e_widget_slider_add
|
||||
(evas, 1, 0, _("%3.0f%%"), 0.0, 100.0, 1.0, 0, NULL, &ctxt->quality, 150);
|
||||
e_widget_frametable_object_append(frame, slider, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
e_widget_list_object_append(vlist, frame, 1, 1, 0.5);
|
||||
|
||||
e_widget_size_min_get(vlist, &w, &h);
|
||||
w += 50;
|
||||
e_dialog_content_set(ctxt->dia, vlist, w, h);
|
||||
|
||||
e_win_centered_set(ctxt->dia->win, 1);
|
||||
|
||||
return ctxt->dia;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request given image to be imported as an edje file.
|
||||
*
|
||||
* This is useful to convert images to icons and background.
|
||||
*
|
||||
* @param image_path path to source image to use.
|
||||
* @param edje_path path to destination edje to generate.
|
||||
* @param external if @c EINA_TRUE, then it will not embed image into edje,
|
||||
* but reference the original @a image_path.
|
||||
* @param quality quality value from 0-100.
|
||||
* @param mode how to resize image with edje.
|
||||
* @param cb function to callback when process finishes.
|
||||
* @param data extra context to give to callback.
|
||||
*
|
||||
* @return handle so one can cancel the operation. This handle will be
|
||||
* invalid after @a cb is called!
|
||||
*/
|
||||
EAPI E_Util_Image_Import_Handle *
|
||||
e_util_image_import(const char *image_path, const char *edje_path, const char *edje_group, Eina_Bool external, int quality, E_Image_Import_Mode mode, void (*cb)(void *data, Eina_Bool ok, const char *image_path, const char *edje_path), const void *data)
|
||||
{
|
||||
static const char *tmpdir = NULL;
|
||||
E_Util_Image_Import_Handle *handle;
|
||||
Ecore_Evas *ee;
|
||||
Evas_Object *img;
|
||||
int fd, w, h;
|
||||
const char *escaped_file;
|
||||
char cmd[PATH_MAX * 2], tmpn[PATH_MAX];
|
||||
FILE *f;
|
||||
|
||||
if (!image_path) return NULL;
|
||||
if (!edje_path) return NULL;
|
||||
if (!edje_group) return NULL;
|
||||
if (!cb) return NULL;
|
||||
ee = ecore_evas_buffer_new(1, 1);
|
||||
img = evas_object_image_add(ecore_evas_get(ee));
|
||||
evas_object_image_file_set(img, image_path, NULL);
|
||||
if (evas_object_image_load_error_get(img) != EVAS_LOAD_ERROR_NONE)
|
||||
{
|
||||
ecore_evas_free(ee);
|
||||
ERR("Error loading image '%s'", image_path);
|
||||
return NULL;
|
||||
}
|
||||
evas_object_image_size_get(img, &w, &h);
|
||||
ecore_evas_free(ee);
|
||||
|
||||
if (!tmpdir)
|
||||
{
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) tmpdir = "/tmp";
|
||||
}
|
||||
snprintf(tmpn, sizeof(tmpn), "%s/e_util_image_import-XXXXXX", tmpdir);
|
||||
fd = mkstemp(tmpn);
|
||||
if (fd < 0)
|
||||
{
|
||||
ERR("Error Creating tmp file: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f = fdopen(fd, "wb");
|
||||
if (!f)
|
||||
{
|
||||
ERR("Cannot open %s for writing", tmpn);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
escaped_file = e_util_filename_escape(image_path); // watch out ret buffer!
|
||||
|
||||
fprintf(f, "images.image: \"%s\" ", escaped_file);
|
||||
if (external)
|
||||
fputs("USER", f);
|
||||
else if (quality >= 100)
|
||||
fputs("COMP", f);
|
||||
else
|
||||
fprintf(f, "LOSSY %d", (quality > 1) ? quality : 90);
|
||||
|
||||
fprintf(f,
|
||||
";\n"
|
||||
"collections {\n"
|
||||
" group {\n"
|
||||
" name: \"%s\";\n"
|
||||
" data.item: \"style\" \"%d\";\n"
|
||||
" max: %d %d;\n"
|
||||
" parts {\n",
|
||||
edje_group, mode, w, h);
|
||||
|
||||
if ((mode == E_IMAGE_IMPORT_CENTER) ||
|
||||
(mode == E_IMAGE_IMPORT_SCALE_ASPECT_IN))
|
||||
{
|
||||
fputs(" part {\n"
|
||||
" type: RECT;\n"
|
||||
" name: \"col\";\n"
|
||||
" mouse_events: 0;\n"
|
||||
" description {\n"
|
||||
" state: \"default\" 0.0;\n"
|
||||
" color: 255 255 255 255;\n"
|
||||
" }\n"
|
||||
" }\n",
|
||||
f);
|
||||
}
|
||||
|
||||
fprintf(f,
|
||||
" part {\n"
|
||||
" type: IMAGE;\n"
|
||||
" name: \"image\";\n"
|
||||
" mouse_events: 0;\n"
|
||||
" description {\n"
|
||||
" state: \"default\" 0.0;\n"
|
||||
" image {\n"
|
||||
" normal: \"%s\";\n"
|
||||
" scale_hint: STATIC;\n"
|
||||
" }\n",
|
||||
escaped_file);
|
||||
|
||||
if (mode == E_IMAGE_IMPORT_TILE)
|
||||
{
|
||||
fprintf(f,
|
||||
" fill {\n"
|
||||
" size {\n"
|
||||
" relative: 0.0 0.0;\n"
|
||||
" offset: %d %d;\n"
|
||||
" }\n"
|
||||
" }\n",
|
||||
w, h);
|
||||
}
|
||||
else if (mode == E_IMAGE_IMPORT_CENTER)
|
||||
{
|
||||
fprintf(f,
|
||||
" min: %d %d;\n"
|
||||
" max: %d %d;\n",
|
||||
w, h, w, h);
|
||||
}
|
||||
else if ((mode == E_IMAGE_IMPORT_SCALE_ASPECT_IN) ||
|
||||
(mode == E_IMAGE_IMPORT_SCALE_ASPECT_OUT))
|
||||
{
|
||||
const char *locale = e_intl_language_get();
|
||||
double aspect = (double)w / (double)h;
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
fprintf(f,
|
||||
" aspect: %1.9f %1.9f;\n"
|
||||
" aspect_preference: %s;\n",
|
||||
aspect, aspect,
|
||||
(mode == E_IMAGE_IMPORT_SCALE_ASPECT_IN) ? "BOTH" : "NONE");
|
||||
setlocale(LC_NUMERIC, locale);
|
||||
}
|
||||
|
||||
fputs(" }\n" // description
|
||||
" }\n" // part
|
||||
" }\n" // parts
|
||||
" }\n" // group
|
||||
"}\n", // collections
|
||||
f);
|
||||
|
||||
fclose(f); // fd gets closed here
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "edje_cc %s %s",
|
||||
tmpn, e_util_filename_escape(edje_path));
|
||||
|
||||
handle = E_NEW(E_Util_Image_Import_Handle, 1);
|
||||
if (!handle)
|
||||
{
|
||||
unlink(tmpn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle->cb.func = cb;
|
||||
handle->cb.data = (void *)data;
|
||||
handle->path.image = eina_stringshare_add(image_path);
|
||||
handle->path.edje = eina_stringshare_add(edje_path);
|
||||
handle->path.temp = eina_stringshare_add(tmpn);
|
||||
handle->handler = ecore_event_handler_add
|
||||
(ECORE_EXE_EVENT_DEL, _e_util_image_import_exit, handle);
|
||||
handle->exe = ecore_exe_run(cmd, NULL);
|
||||
if (!handle->exe)
|
||||
{
|
||||
_e_util_image_import_handle_free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_util_image_import_cancel(E_Util_Image_Import_Handle *handle)
|
||||
{
|
||||
if (!handle) return;
|
||||
ecore_exe_kill(handle->exe);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_util_container_desk_count_get(E_Container *con)
|
||||
{
|
||||
|
@ -1562,58 +1242,6 @@ _e_util_wakeup_cb(void *data __UNUSED__)
|
|||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_util_image_import_settings_do(void *data, E_Dialog *dia)
|
||||
{
|
||||
E_Util_Image_Import_Settings *ctxt = data;
|
||||
|
||||
ctxt->ok = EINA_TRUE;
|
||||
e_util_defer_object_del(E_OBJECT(dia));
|
||||
}
|
||||
|
||||
static void
|
||||
_e_util_image_import_settings_del(void *obj)
|
||||
{
|
||||
E_Dialog *dia = obj;
|
||||
E_Util_Image_Import_Settings *ctxt = dia->data;
|
||||
|
||||
ctxt->cb.func(ctxt->cb.data, ctxt->path,
|
||||
ctxt->ok, ctxt->external, ctxt->quality, ctxt->mode);
|
||||
|
||||
eina_stringshare_del(ctxt->path);
|
||||
E_FREE(ctxt);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_util_image_import_exit(void *data, int type __UNUSED__, void *event)
|
||||
{
|
||||
E_Util_Image_Import_Handle *handle = data;
|
||||
Ecore_Exe_Event_Del *ev = event;
|
||||
Eina_Bool ok;
|
||||
|
||||
if (ev->exe != handle->exe) return ECORE_CALLBACK_PASS_ON;
|
||||
|
||||
ok = (ev->exit_code == 0);
|
||||
|
||||
if (!ok) unlink(handle->path.edje);
|
||||
handle->cb.func(handle->cb.data, ok, handle->path.image, handle->path.edje);
|
||||
|
||||
_e_util_image_import_handle_free(handle);
|
||||
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_util_image_import_handle_free(E_Util_Image_Import_Handle *handle)
|
||||
{
|
||||
unlink(handle->path.temp);
|
||||
eina_stringshare_del(handle->path.image);
|
||||
eina_stringshare_del(handle->path.edje);
|
||||
eina_stringshare_del(handle->path.temp);
|
||||
if (handle->handler) ecore_event_handler_del(handle->handler);
|
||||
E_FREE(handle);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_util_conf_timer_old(void *data)
|
||||
{
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Util_Image_Import_Handle E_Util_Image_Import_Handle;
|
||||
|
||||
typedef enum _E_Image_Import_Mode E_Image_Import_Mode;
|
||||
enum _E_Image_Import_Mode
|
||||
{
|
||||
E_IMAGE_IMPORT_STRETCH = 0,
|
||||
E_IMAGE_IMPORT_TILE = 1,
|
||||
E_IMAGE_IMPORT_CENTER = 2,
|
||||
E_IMAGE_IMPORT_SCALE_ASPECT_IN = 3,
|
||||
E_IMAGE_IMPORT_SCALE_ASPECT_OUT = 4
|
||||
};
|
||||
|
||||
#else
|
||||
#ifndef E_UTILS_H
|
||||
#define E_UTILS_H
|
||||
|
||||
#define E_UTIL_IMAGE_IMPORT_SETTINGS 0xE0b0104f
|
||||
|
||||
#define e_util_dialog_show(title, args...) \
|
||||
{ \
|
||||
char __tmpbuf[PATH_MAX]; \
|
||||
|
@ -73,10 +59,6 @@ EAPI void e_util_win_auto_resize_fill(E_Win *win);
|
|||
dialog warning if loaded version is older or newer than current */
|
||||
EAPI Eina_Bool e_util_module_config_check(const char *module_name, int loaded, int current);
|
||||
|
||||
EAPI E_Dialog *e_util_image_import_settings_new(const char *path, void (*cb)(void *data, const char *path, Eina_Bool ok, Eina_Bool external, int quality, E_Image_Import_Mode mode), const void *data);
|
||||
EAPI E_Util_Image_Import_Handle *e_util_image_import(const char *image_path, const char *edje_path, const char *edje_group, Eina_Bool external, int quality, E_Image_Import_Mode mode, void (*cb)(void *data, Eina_Bool ok, const char *image_path, const char *edje_path), const void *data);
|
||||
EAPI void e_util_image_import_cancel(E_Util_Image_Import_Handle *handle);
|
||||
|
||||
EAPI int e_util_container_desk_count_get(E_Container *con);
|
||||
|
||||
EAPI Eina_Bool e_util_fullscreen_curreny_any(void);
|
||||
|
|
Loading…
Reference in New Issue