Ephoto: Add file operations, context menus, sorting, and more.
This commit is contained in:
parent
0b62428e24
commit
cf25f7c561
|
@ -6,6 +6,9 @@ ephoto_CPPFLAGS = \
|
|||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wshadow \
|
||||
@EFL_CFLAGS@
|
||||
ephoto_LDADD = @EFL_LIBS@
|
||||
if HAVE_PO
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
static void _ephoto_display_usage(void);
|
||||
|
||||
/* Global log domain pointer */
|
||||
int __log_domain = -1;
|
||||
|
||||
EAPI int
|
||||
elm_main(int argc, char **argv)
|
||||
{
|
||||
|
@ -23,20 +20,11 @@ elm_main(int argc, char **argv)
|
|||
textdomain(PACKAGE);
|
||||
#endif
|
||||
|
||||
__log_domain = eina_log_domain_register("ephoto", EINA_COLOR_ORANGE);
|
||||
if (!__log_domain)
|
||||
{
|
||||
EINA_LOG_ERR("Could not register log domain: Ephoto");
|
||||
r = 1;
|
||||
goto end_log_domain;
|
||||
}
|
||||
|
||||
if (!efreet_mime_init())
|
||||
ERR("Could not init efreet_mime!");
|
||||
printf("Could not initialize Efreet_Mime!\n");
|
||||
|
||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||
|
||||
DBG("Logging initialized");
|
||||
if (argc > 2)
|
||||
{
|
||||
printf("Too Many Arguments!\n");
|
||||
|
@ -47,6 +35,7 @@ elm_main(int argc, char **argv)
|
|||
else if (argc < 2)
|
||||
{
|
||||
Evas_Object *win = ephoto_window_add(NULL);
|
||||
|
||||
if (!win)
|
||||
{
|
||||
r = 1;
|
||||
|
@ -62,6 +51,7 @@ elm_main(int argc, char **argv)
|
|||
else
|
||||
{
|
||||
char *real = ecore_file_realpath(argv[1]);
|
||||
|
||||
if (!real)
|
||||
{
|
||||
printf("invalid file or directory: '%s'\n", argv[1]);
|
||||
|
@ -69,6 +59,7 @@ elm_main(int argc, char **argv)
|
|||
goto end;
|
||||
}
|
||||
Evas_Object *win = ephoto_window_add(real);
|
||||
|
||||
free(real);
|
||||
if (!win)
|
||||
{
|
||||
|
@ -80,9 +71,7 @@ elm_main(int argc, char **argv)
|
|||
elm_run();
|
||||
|
||||
end:
|
||||
eina_log_domain_unregister(__log_domain);
|
||||
efreet_mime_shutdown();
|
||||
end_log_domain:
|
||||
eio_shutdown();
|
||||
|
||||
return r;
|
||||
|
@ -92,8 +81,7 @@ elm_main(int argc, char **argv)
|
|||
static void
|
||||
_ephoto_display_usage(void)
|
||||
{
|
||||
printf("Ephoto Usage: \n"
|
||||
"ephoto --help : This page\n"
|
||||
printf("Ephoto Usage: \n" "ephoto --help : This page\n"
|
||||
"ephoto filename : Specifies a file to open\n"
|
||||
"ephoto dirname : Specifies a directory to open\n");
|
||||
}
|
||||
|
|
115
src/bin/ephoto.h
115
src/bin/ephoto.h
|
@ -11,6 +11,7 @@
|
|||
# include <Ecore_File.h>
|
||||
# include <Efreet_Mime.h>
|
||||
# include <Elementary.h>
|
||||
# include <Elementary_Cursor.h>
|
||||
# include <Eina.h>
|
||||
# include <Edje.h>
|
||||
# include <Evas.h>
|
||||
|
@ -27,8 +28,11 @@
|
|||
# include <locale.h>
|
||||
# endif
|
||||
|
||||
#ifdef HAVE_GETTEXT
|
||||
#include "gettext.h"
|
||||
#if HAVE_GETTEXT && ENABLE_NLS
|
||||
#define _(string) gettext (string)
|
||||
#else
|
||||
#define _(string) (string)
|
||||
#define ngettext(String1, String2, Var) Var == 1 ? String1 : String2
|
||||
#endif
|
||||
|
||||
typedef struct _Ephoto_Config Ephoto_Config;
|
||||
|
@ -38,13 +42,16 @@ typedef struct _Ephoto_Event_Entry_Create Ephoto_Event_Entry_Create;
|
|||
|
||||
typedef enum _Ephoto_State Ephoto_State;
|
||||
typedef enum _Ephoto_Orient Ephoto_Orient;
|
||||
typedef enum _Ephoto_Sort Ephoto_Sort;
|
||||
|
||||
Evas_Object *ephoto_window_add(const char *path);
|
||||
void ephoto_title_set(Ephoto *ephoto, const char *title);
|
||||
void ephoto_thumb_size_set(Ephoto *ephoto, int size);
|
||||
Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path);
|
||||
Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent,
|
||||
const char *path);
|
||||
void ephoto_thumb_path_set(Evas_Object *obj, const char *path);
|
||||
void ephoto_directory_set(Ephoto *ephoto, const char *path);
|
||||
void ephoto_directory_set(Ephoto *ephoto, const char *path,
|
||||
Elm_Widget_Item *expanded, Eina_Bool dirs_only);
|
||||
|
||||
Eina_Bool ephoto_config_init(Ephoto *em);
|
||||
void ephoto_config_save(Ephoto *em);
|
||||
|
@ -55,28 +62,35 @@ void ephoto_config_about(Ephoto *em);
|
|||
|
||||
Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path);
|
||||
void ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w, int h);
|
||||
void ephoto_single_browser_cancel_editing(Evas_Object *main, Evas_Object *image);
|
||||
/* smart callbacks called:
|
||||
* "back" - the user wants to go back to the previous screen.
|
||||
*/
|
||||
void ephoto_single_browser_path_pending_set(Evas_Object *obj,
|
||||
const char *path);
|
||||
void ephoto_single_browser_image_data_update(Evas_Object *main,
|
||||
Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w,
|
||||
int h);
|
||||
void ephoto_single_browser_cancel_editing(Evas_Object *main,
|
||||
Evas_Object *image);
|
||||
/* smart callbacks called: "back" - the user wants to go back to the previous
|
||||
* screen. */
|
||||
Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
/* smart callbacks called:
|
||||
* "back" - the user wants to go back to the previous screen.
|
||||
*/
|
||||
|
||||
/* smart callbacks called: "back" - the user wants to go back to the previous
|
||||
* screen. */
|
||||
|
||||
Evas_Object *ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_thumb_browser_fsel_clear(Ephoto *ephoto);
|
||||
|
||||
/* smart callbacks called:
|
||||
* "selected" - an item in the thumb browser is selected. The selected Ephoto_Entry is passed as event_info argument.
|
||||
*/
|
||||
/* smart callbacks called: "selected" - an item in the thumb browser is
|
||||
* selected. The selected Ephoto_Entry is passed as event_info argument. */
|
||||
|
||||
void ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_parent, Evas_Object *image);
|
||||
void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image);
|
||||
void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image);
|
||||
void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image);
|
||||
void ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image_parent, Evas_Object *image);
|
||||
void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image);
|
||||
void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image);
|
||||
void ephoto_color_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image);
|
||||
void ephoto_filter_blur(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image);
|
||||
|
@ -90,7 +104,7 @@ enum _Ephoto_State
|
|||
EPHOTO_STATE_SLIDESHOW
|
||||
};
|
||||
|
||||
enum _Ephoto_Orient /* matches with exif orientation tag */
|
||||
enum _Ephoto_Orient
|
||||
{
|
||||
EPHOTO_ORIENT_0 = 1,
|
||||
EPHOTO_ORIENT_FLIP_HORIZ = 2,
|
||||
|
@ -102,13 +116,14 @@ enum _Ephoto_Orient /* matches with exif orientation tag */
|
|||
EPHOTO_ORIENT_270 = 8
|
||||
};
|
||||
|
||||
/* TODO: split into window & global config, allow multi window
|
||||
*
|
||||
* This also requires single instance, as 2 instances changing the
|
||||
* same configuration will lead to problems.
|
||||
*
|
||||
* Single instance is better done as DBus, using FDO standard methods.
|
||||
*/
|
||||
enum _Ephoto_Sort
|
||||
{
|
||||
EPHOTO_SORT_ALPHABETICAL_ASCENDING,
|
||||
EPHOTO_SORT_ALPHABETICAL_DESCENDING,
|
||||
EPHOTO_SORT_MODTIME_ASCENDING,
|
||||
EPHOTO_SORT_MODTIME_DESCENDING
|
||||
};
|
||||
|
||||
struct _Ephoto_Config
|
||||
{
|
||||
int config_version;
|
||||
|
@ -122,11 +137,15 @@ struct _Ephoto_Config
|
|||
int fsel_hide;
|
||||
int tool_hide;
|
||||
const char *open;
|
||||
int prompts;
|
||||
int drop;
|
||||
Evas_Object *slide_time;
|
||||
Evas_Object *slide_trans;
|
||||
Evas_Object *hide_toolbar;
|
||||
Evas_Object *open_dir;
|
||||
Evas_Object *open_dir_custom;
|
||||
Evas_Object *show_prompts;
|
||||
Evas_Object *move_drop;
|
||||
};
|
||||
|
||||
struct _Ephoto
|
||||
|
@ -144,14 +163,16 @@ struct _Ephoto
|
|||
|
||||
Eina_List *entries;
|
||||
Eina_List *direntries;
|
||||
Eina_List *thumbs; /* live thumbs that need to be regenerated on changes */
|
||||
Eina_List *thumbs;
|
||||
|
||||
int thumb_gen_size; /* pending value for thumb_regen */
|
||||
int thumb_gen_size;
|
||||
Evas_Coord bottom_bar_size;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
Ecore_Timer *thumb_regen;
|
||||
} timer;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
Ecore_Job *change_dir;
|
||||
} job;
|
||||
|
||||
|
@ -166,10 +187,11 @@ struct _Ephoto
|
|||
struct _Ephoto_Entry
|
||||
{
|
||||
const char *path;
|
||||
const char *basename; /* pointer inside path */
|
||||
const char *basename;
|
||||
const char *label;
|
||||
Ephoto *ephoto;
|
||||
Elm_Object_Item *item;
|
||||
Elm_Object_Item *parent;
|
||||
Eina_List *free_listeners;
|
||||
Eina_Bool is_dir;
|
||||
};
|
||||
|
@ -179,47 +201,44 @@ struct _Ephoto_Event_Entry_Create
|
|||
Ephoto_Entry *entry;
|
||||
};
|
||||
|
||||
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label, Eina_File_Type type);
|
||||
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path,
|
||||
const char *label, Eina_File_Type type);
|
||||
void ephoto_entry_free(Ephoto_Entry *entry);
|
||||
void ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entry_free_listener_add(Ephoto_Entry *entry,
|
||||
void (*cb) (void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entry_free_listener_del(Ephoto_Entry *entry,
|
||||
void (*cb) (void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entries_free(Ephoto *ephoto);
|
||||
int ephoto_entries_cmp(const void *pa, const void *pb);
|
||||
|
||||
extern int __log_domain;
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
|
||||
#define INF(...) EINA_LOG_DOM_INFO(__log_domain, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(__log_domain, __VA_ARGS__)
|
||||
|
||||
static inline Eina_Bool
|
||||
_ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
||||
{
|
||||
const char *type, *bname;
|
||||
int i = 0;
|
||||
|
||||
const char *filters[] =
|
||||
{
|
||||
const char *filters[] = {
|
||||
"png", "jpeg", "jpg", "eet", "xpm", "tiff", "gif", "svg", "webp", "pmaps",
|
||||
"bmp", "tga", "wbmp", "ico", "psd", "jp2k", "generic"
|
||||
};
|
||||
|
||||
bname = info->path + info->name_start;
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
if (bname[0] == '.')
|
||||
return EINA_FALSE;
|
||||
if ((info->type != EINA_FILE_REG) && (info->type != EINA_FILE_UNKNOWN))
|
||||
return EINA_FALSE;
|
||||
|
||||
type = strrchr(bname, '.');
|
||||
if(!type) return EINA_FALSE;
|
||||
if (!type)
|
||||
return EINA_FALSE;
|
||||
int count = sizeof(filters) / sizeof(filters[0]);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (!strcasecmp(type + 1, filters[i]))
|
||||
return evas_object_image_extension_can_load_get(bname);
|
||||
}
|
||||
return EINA_FALSE;
|
||||
/* seems that this does not play nice with threads */
|
||||
//if (!(type = efreet_mime_type_get(info->path))) return EINA_FALSE;
|
||||
//return strncmp(type, "image/", sizeof("image/") - 1) == 0;
|
||||
}
|
||||
|
||||
extern int EPHOTO_EVENT_ENTRY_CREATE;
|
||||
|
|
|
@ -32,7 +32,7 @@ static int
|
|||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -41,23 +41,25 @@ static int
|
|||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_bcg_adjust_brightness(Ephoto_BCG *ebcg, int brightness, unsigned int *image_data)
|
||||
_ephoto_bcg_adjust_brightness(Ephoto_BCG *ebcg, int brightness,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
else
|
||||
memcpy(im_data, ebcg->original_im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, ebcg->original_im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->brightness = brightness;
|
||||
im_data_new = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
@ -89,16 +91,18 @@ _ephoto_bcg_adjust_brightness(Ephoto_BCG *ebcg, int brightness, unsigned int *im
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE, im_data_new, ebcg->w, ebcg->h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
|
||||
im_data_new, ebcg->w, ebcg->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast, unsigned int *image_data)
|
||||
_ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h, top, bottom;
|
||||
int x, y, top, bottom;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float factor;
|
||||
|
||||
|
@ -106,7 +110,8 @@ _ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast, unsigned int *image_
|
|||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
else
|
||||
memcpy(im_data, ebcg->original_im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, ebcg->original_im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->contrast = contrast;
|
||||
top = ((255 + (contrast)) * 259);
|
||||
|
@ -141,23 +146,26 @@ _ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast, unsigned int *image_
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE, im_data_new, ebcg->w, ebcg->h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
|
||||
im_data_new, ebcg->w, ebcg->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_bcg_adjust_gamma(Ephoto_BCG *ebcg, double gamma, unsigned int *image_data)
|
||||
_ephoto_bcg_adjust_gamma(Ephoto_BCG *ebcg, double gamma,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
else
|
||||
memcpy(im_data, ebcg->original_im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, ebcg->original_im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->gamma = 1 / gamma;
|
||||
im_data_new = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
@ -189,53 +197,60 @@ _ephoto_bcg_adjust_gamma(Ephoto_BCG *ebcg, double gamma, unsigned int *image_dat
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE, im_data_new, ebcg->w, ebcg->h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
|
||||
im_data_new, ebcg->w, ebcg->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
static void
|
||||
_brightness_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_brightness_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
int brightness;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
brightness = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_bcg_adjust_brightness(ebcg, brightness, NULL);
|
||||
image_data_two = _ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data);
|
||||
image_data_three = _ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data);
|
||||
_ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_contrast_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_contrast_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
int contrast;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
contrast = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_bcg_adjust_contrast(ebcg, contrast, NULL);
|
||||
image_data_two = _ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
image_data_three = _ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
_ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_gamma_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_gamma_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
double gamma;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
gamma = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_bcg_adjust_gamma(ebcg, gamma, NULL);
|
||||
image_data_two = _ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
image_data_three = _ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
_ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_bcg_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_bcg_reset(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
|
||||
|
@ -249,20 +264,25 @@ _bcg_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSE
|
|||
}
|
||||
|
||||
static void
|
||||
_bcg_apply(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_bcg_apply(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
unsigned int *image_data;
|
||||
int w, h;
|
||||
|
||||
image_data = evas_object_image_data_get(elm_image_object_get(ebcg->image), EINA_FALSE);
|
||||
image_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ebcg->image),
|
||||
EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ebcg->image), &w, &h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_TRUE, image_data, w, h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_TRUE,
|
||||
image_data, w, h);
|
||||
evas_object_del(ebcg->frame);
|
||||
}
|
||||
|
||||
static void
|
||||
_bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
|
||||
|
@ -278,16 +298,19 @@ _bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
}
|
||||
|
||||
static void
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
|
||||
free(ebcg->original_im_data);
|
||||
free(ebcg);
|
||||
}
|
||||
|
||||
void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
void
|
||||
ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *win, *box, *slider, *ic, *button;
|
||||
Evas_Object *box, *slider, *ic, *button;
|
||||
Ephoto_BCG *ebcg;
|
||||
unsigned int *im_data;
|
||||
|
||||
|
@ -302,10 +325,14 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
ebcg->main = main;
|
||||
ebcg->parent = parent;
|
||||
ebcg->image = image;
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(ebcg->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ebcg->image), &ebcg->w, &ebcg->h);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ebcg->image),
|
||||
EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ebcg->image), &ebcg->w,
|
||||
&ebcg->h);
|
||||
ebcg->original_im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(ebcg->original_im_data, im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(ebcg->original_im_data, im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->frame = elm_frame_add(parent);
|
||||
elm_object_text_set(ebcg->frame, _("Brightness/Contrast/Gamma"));
|
||||
|
@ -313,7 +340,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
evas_object_size_hint_align_set(ebcg->frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(parent, ebcg->frame);
|
||||
evas_object_data_set(ebcg->frame, "ebcg", ebcg);
|
||||
evas_object_event_callback_add(ebcg->frame, EVAS_CALLBACK_DEL, _frame_del, ebcg);
|
||||
evas_object_event_callback_add(ebcg->frame, EVAS_CALLBACK_DEL, _frame_del,
|
||||
ebcg);
|
||||
evas_object_show(ebcg->frame);
|
||||
|
||||
box = elm_box_add(ebcg->frame);
|
||||
|
@ -331,7 +359,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
elm_slider_unit_format_set(slider, "%1.0f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _brightness_slider_changed, ebcg);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_brightness_slider_changed, ebcg);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ebcg->bslider = slider;
|
||||
|
@ -344,7 +373,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
elm_slider_unit_format_set(slider, "%1.0f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _contrast_slider_changed, ebcg);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_contrast_slider_changed, ebcg);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ebcg->cslider = slider;
|
||||
|
@ -357,7 +387,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
elm_slider_unit_format_set(slider, "%1.2f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _gamma_slider_changed, ebcg);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_gamma_slider_changed, ebcg);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ebcg->gslider = slider;
|
||||
|
|
|
@ -32,7 +32,7 @@ static int
|
|||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static int
|
|||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -50,14 +50,15 @@ unsigned int *
|
|||
_ephoto_color_adjust_red(Ephoto_Color *eco, int red, unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, rr;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
else
|
||||
memcpy(im_data, eco->original_im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, eco->original_im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->red = red;
|
||||
im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
@ -87,23 +88,26 @@ _ephoto_color_adjust_red(Ephoto_Color *eco, int red, unsigned int *image_data)
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE, im_data_new, eco->w, eco->h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
|
||||
im_data_new, eco->w, eco->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_color_adjust_green(Ephoto_Color *eco, int green, unsigned int *image_data)
|
||||
_ephoto_color_adjust_green(Ephoto_Color *eco, int green,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, gg;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
else
|
||||
memcpy(im_data, eco->original_im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, eco->original_im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->green = green;
|
||||
im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
@ -133,23 +137,26 @@ _ephoto_color_adjust_green(Ephoto_Color *eco, int green, unsigned int *image_dat
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE, im_data_new, eco->w, eco->h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
|
||||
im_data_new, eco->w, eco->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_color_adjust_blue(Ephoto_Color *eco, int blue, unsigned int *image_data)
|
||||
_ephoto_color_adjust_blue(Ephoto_Color *eco, int blue,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
else
|
||||
memcpy(im_data, eco->original_im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, eco->original_im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->blue = blue;
|
||||
im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
@ -179,7 +186,8 @@ _ephoto_color_adjust_blue(Ephoto_Color *eco, int blue, unsigned int *image_data)
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE, im_data_new, eco->w, eco->h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
|
||||
im_data_new, eco->w, eco->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
@ -189,43 +197,45 @@ _red_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|||
{
|
||||
Ephoto_Color *eco = data;
|
||||
int red;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
red = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_color_adjust_red(eco, red, NULL);
|
||||
image_data_two = _ephoto_color_adjust_green(eco, eco->green, image_data);
|
||||
image_data_three = _ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
_ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_green_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_green_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
int green;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
green = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_color_adjust_green(eco, green, NULL);
|
||||
image_data_two = _ephoto_color_adjust_red(eco, eco->red, image_data);
|
||||
image_data_three = _ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
_ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_blue_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_blue_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
int blue;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
blue = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_color_adjust_blue(eco, blue, NULL);
|
||||
image_data_two = _ephoto_color_adjust_red(eco, eco->red, image_data);
|
||||
image_data_three = _ephoto_color_adjust_green(eco, eco->green, image_data_two);
|
||||
_ephoto_color_adjust_green(eco, eco->green, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_color_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_color_reset(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
|
||||
|
@ -239,20 +249,24 @@ _color_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNU
|
|||
}
|
||||
|
||||
static void
|
||||
_color_apply(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_color_apply(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
unsigned int *image_data;
|
||||
int w, h;
|
||||
|
||||
image_data = evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
image_data =
|
||||
evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(eco->image), &w, &h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE, image_data, w, h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE,
|
||||
image_data, w, h);
|
||||
evas_object_del(eco->frame);
|
||||
}
|
||||
|
||||
static void
|
||||
_color_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_color_cancel(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
|
||||
|
@ -268,16 +282,19 @@ _color_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
}
|
||||
|
||||
static void
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
|
||||
free(eco->original_im_data);
|
||||
free(eco);
|
||||
}
|
||||
|
||||
void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
void
|
||||
ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *win, *box, *slider, *ic, *button;
|
||||
Evas_Object *box, *slider, *ic, *button;
|
||||
Ephoto_Color *eco;
|
||||
unsigned int *im_data;
|
||||
|
||||
|
@ -292,10 +309,13 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
eco->main = main;
|
||||
eco->parent = parent;
|
||||
eco->image = image;
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(eco->image), &eco->w, &eco->h);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(eco->image), &eco->w,
|
||||
&eco->h);
|
||||
eco->original_im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(eco->original_im_data, im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(eco->original_im_data, im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->frame = elm_frame_add(parent);
|
||||
elm_object_text_set(eco->frame, _("Adjust Color Levels"));
|
||||
|
@ -303,7 +323,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
evas_object_size_hint_align_set(eco->frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(parent, eco->frame);
|
||||
evas_object_data_set(eco->frame, "eco", eco);
|
||||
evas_object_event_callback_add(eco->frame, EVAS_CALLBACK_DEL, _frame_del, eco);
|
||||
evas_object_event_callback_add(eco->frame, EVAS_CALLBACK_DEL, _frame_del,
|
||||
eco);
|
||||
evas_object_show(eco->frame);
|
||||
|
||||
box = elm_box_add(eco->frame);
|
||||
|
@ -321,7 +342,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
elm_slider_unit_format_set(slider, "%1.0f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _red_slider_changed, eco);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _red_slider_changed,
|
||||
eco);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
eco->rslider = slider;
|
||||
|
@ -334,7 +356,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
elm_slider_unit_format_set(slider, "%1.0f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _green_slider_changed, eco);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_green_slider_changed, eco);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
eco->gslider = slider;
|
||||
|
@ -347,7 +370,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
elm_slider_unit_format_set(slider, "%1.0f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _blue_slider_changed, eco);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _blue_slider_changed,
|
||||
eco);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
eco->bslider = slider;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
#define CONFIG_VERSION 11
|
||||
#define CONFIG_VERSION 13
|
||||
|
||||
static int _ephoto_config_load(Ephoto *ephoto);
|
||||
static Eina_Bool _ephoto_on_config_save(void *data);
|
||||
|
@ -13,14 +13,13 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
Eet_Data_Descriptor_Class eddc;
|
||||
|
||||
if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof(eddc),
|
||||
"Ephoto_Config",
|
||||
sizeof(Ephoto_Config)))
|
||||
"Ephoto_Config", sizeof(Ephoto_Config)))
|
||||
{
|
||||
ERR("Unable to create the config data descriptor!");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!edd) edd = eet_data_descriptor_stream_new(&eddc);
|
||||
if (!edd)
|
||||
edd = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
#undef T
|
||||
#undef D
|
||||
|
@ -40,6 +39,8 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
C_VAL(D, T, fsel_hide, EET_T_INT);
|
||||
C_VAL(D, T, tool_hide, EET_T_INT);
|
||||
C_VAL(D, T, open, EET_T_STRING);
|
||||
C_VAL(D, T, prompts, EET_T_INT);
|
||||
C_VAL(D, T, drop, EET_T_INT);
|
||||
switch (_ephoto_config_load(ephoto))
|
||||
{
|
||||
case 0:
|
||||
|
@ -51,7 +52,11 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
ephoto->config->window_height = 600;
|
||||
ephoto->config->fsel_hide = 0;
|
||||
ephoto->config->tool_hide = 0;
|
||||
ephoto->config->open = eina_stringshare_add(getenv("HOME"));
|
||||
ephoto->config->prompts = 1;
|
||||
ephoto->config->drop = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -82,7 +87,8 @@ _close(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
}
|
||||
|
||||
static void
|
||||
_save_general(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_save_general(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto *ephoto = evas_object_data_get(popup, "ephoto");
|
||||
|
@ -100,12 +106,13 @@ _save_general(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
|
||||
if (ecore_file_is_dir(path) || !strcmp(path, "Last"))
|
||||
eina_stringshare_replace(&ephoto->config->open, path);
|
||||
ephoto->config->tool_hide = elm_check_state_get(ephoto->config->hide_toolbar);
|
||||
|
||||
ephoto->config->tool_hide =
|
||||
elm_check_state_get(ephoto->config->hide_toolbar);
|
||||
ephoto->config->prompts = elm_check_state_get(ephoto->config->show_prompts);
|
||||
ephoto->config->drop = elm_check_state_get(ephoto->config->move_drop);
|
||||
evas_object_del(popup);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_open_hv_select(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
|
@ -122,7 +129,7 @@ _open_hv_select(void *data, Evas_Object *obj, void *event_info)
|
|||
void
|
||||
ephoto_config_general(Ephoto *ephoto)
|
||||
{
|
||||
Evas_Object *popup, *box, *table, *check, *label, *hoversel, *entry, *ic, *button;
|
||||
Evas_Object *popup, *box, *table, *check, *hoversel, *entry, *ic, *button;
|
||||
|
||||
popup = elm_popup_add(ephoto->win);
|
||||
elm_popup_scrollable_set(popup, EINA_TRUE);
|
||||
|
@ -148,17 +155,38 @@ ephoto_config_general(Ephoto *ephoto)
|
|||
evas_object_show(check);
|
||||
ephoto->config->hide_toolbar = check;
|
||||
|
||||
check = elm_check_add(table);
|
||||
elm_object_text_set(check, _("Prompt Before Changing The Filesystem"));
|
||||
evas_object_size_hint_align_set(check, 0.0, EVAS_HINT_FILL);
|
||||
elm_check_state_set(check, ephoto->config->prompts);
|
||||
elm_table_pack(table, check, 0, 2, 1, 1);
|
||||
evas_object_show(check);
|
||||
ephoto->config->show_prompts = check;
|
||||
|
||||
check = elm_check_add(table);
|
||||
elm_object_text_set(check, _("Move Files When Dropped"));
|
||||
evas_object_size_hint_align_set(check, 0.0, EVAS_HINT_FILL);
|
||||
elm_check_state_set(check, ephoto->config->drop);
|
||||
elm_table_pack(table, check, 0, 3, 1, 1);
|
||||
evas_object_show(check);
|
||||
ephoto->config->move_drop = check;
|
||||
|
||||
hoversel = elm_hoversel_add(table);
|
||||
elm_hoversel_hover_parent_set(hoversel, ephoto->win);
|
||||
elm_hoversel_item_add(hoversel, _("Root Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Home Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Last Open Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Custom Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Root Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Home Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Last Open Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Custom Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_object_text_set(hoversel, _("Directory To Open Ephoto In"));
|
||||
evas_object_data_set(hoversel, "ephoto", ephoto);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(hoversel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, hoversel, 0, 2, 1, 1);
|
||||
elm_table_pack(table, hoversel, 0, 4, 1, 1);
|
||||
evas_object_show(hoversel);
|
||||
ephoto->config->open_dir = hoversel;
|
||||
|
||||
|
@ -167,10 +195,11 @@ ephoto_config_general(Ephoto *ephoto)
|
|||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
elm_object_text_set(entry, _("Custom Directory"));
|
||||
elm_object_disabled_set(entry, EINA_TRUE);
|
||||
elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
|
||||
elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF,
|
||||
ELM_SCROLLER_POLICY_OFF);
|
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, entry, 0, 3, 1, 1);
|
||||
elm_table_pack(table, entry, 0, 5, 1, 1);
|
||||
evas_object_show(entry);
|
||||
ephoto->config->open_dir_custom = entry;
|
||||
|
||||
|
@ -212,10 +241,11 @@ _save(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
Ephoto *ephoto = evas_object_data_get(popup, "ephoto");
|
||||
|
||||
if (elm_spinner_value_get(ephoto->config->slide_time) > 0)
|
||||
ephoto->config->slideshow_timeout = elm_spinner_value_get(ephoto->config->slide_time);
|
||||
ephoto->config->slideshow_timeout =
|
||||
elm_spinner_value_get(ephoto->config->slide_time);
|
||||
if (elm_object_text_get(ephoto->config->slide_trans))
|
||||
eina_stringshare_replace(&ephoto->config->slideshow_transition, elm_object_text_get(ephoto->config->slide_trans));
|
||||
|
||||
eina_stringshare_replace(&ephoto->config->slideshow_transition,
|
||||
elm_object_text_get(ephoto->config->slide_trans));
|
||||
evas_object_del(popup);
|
||||
}
|
||||
|
||||
|
@ -226,7 +256,8 @@ _hv_select(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
static void
|
||||
_spinner_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_spinner_changed(void *data EINA_UNUSED, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
double val;
|
||||
char buf[PATH_MAX];
|
||||
|
@ -262,7 +293,7 @@ ephoto_config_slideshow(Ephoto *ephoto)
|
|||
|
||||
label = elm_label_add(table);
|
||||
memset(buf, 0, PATH_MAX);
|
||||
snprintf(buf, PATH_MAX, "<b>%s:</b>", _("Show Each Slide For"));
|
||||
snprintf(buf, PATH_MAX, "%s:", _("Show Each Slide For"));
|
||||
elm_object_text_set(label, buf);
|
||||
evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, label, 0, 1, 1, 1);
|
||||
|
@ -283,7 +314,7 @@ ephoto_config_slideshow(Ephoto *ephoto)
|
|||
|
||||
label = elm_label_add(table);
|
||||
memset(buf, 0, PATH_MAX);
|
||||
snprintf(buf, PATH_MAX, "<b>%s:</b>", _("Slide Transition"));
|
||||
snprintf(buf, PATH_MAX, "%s:", _("Slide Transition"));
|
||||
elm_object_text_set(label, buf);
|
||||
evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, label, 0, 2, 1, 1);
|
||||
|
@ -291,11 +322,13 @@ ephoto_config_slideshow(Ephoto *ephoto)
|
|||
|
||||
hoversel = elm_hoversel_add(table);
|
||||
elm_hoversel_hover_parent_set(hoversel, ephoto->win);
|
||||
EINA_LIST_FOREACH(elm_slideshow_transitions_get(ephoto->slideshow), l, transition)
|
||||
elm_hoversel_item_add(hoversel, transition, NULL, 0, _hv_select, transition);
|
||||
EINA_LIST_FOREACH(elm_slideshow_transitions_get(ephoto->slideshow), l,
|
||||
transition) elm_hoversel_item_add(hoversel, transition, NULL, 0,
|
||||
_hv_select, transition);
|
||||
elm_hoversel_item_add(hoversel, "None", NULL, 0, _hv_select, NULL);
|
||||
elm_object_text_set(hoversel, ephoto->config->slideshow_transition);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(hoversel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, hoversel, 1, 2, 1, 1);
|
||||
evas_object_show(hoversel);
|
||||
|
@ -358,13 +391,13 @@ ephoto_config_about(Ephoto *ephoto)
|
|||
"For more information, please visit the Ephoto project page on the Enlightenment wiki:<br/>"
|
||||
"https://phab.enlightenment.org/w/projects/ephoto<br/>"
|
||||
"Ephoto's source can be found through Enlightenment's git:<br/>"
|
||||
"http://git.enlightenment.org/apps/ephoto.git<br/>"
|
||||
"<br/>"
|
||||
"http://git.enlightenment.org/apps/ephoto.git<br/>" "<br/>"
|
||||
"<b>Authors:</b><br/>"));
|
||||
f = fopen(PACKAGE_DATA_DIR "/AUTHORS", "r");
|
||||
if (f)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
int len;
|
||||
|
@ -384,13 +417,15 @@ ephoto_config_about(Ephoto *ephoto)
|
|||
do
|
||||
{
|
||||
p = strchr(buf, '<');
|
||||
if (p) *p = 0;
|
||||
if (p)
|
||||
*p = 0;
|
||||
}
|
||||
while (p);
|
||||
do
|
||||
{
|
||||
p = strchr(buf, '>');
|
||||
if (p) *p = 0;
|
||||
if (p)
|
||||
*p = 0;
|
||||
}
|
||||
while (p);
|
||||
eina_strbuf_append_printf(sbuf, "%s<br>", buf);
|
||||
|
@ -471,14 +506,15 @@ _ephoto_on_config_save(void *data)
|
|||
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
|
||||
|
||||
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
|
||||
if (!ef) goto save_end;
|
||||
if (!ef)
|
||||
goto save_end;
|
||||
|
||||
eet_data_write(ef, edd, "config", ephoto->config, 1);
|
||||
if (eet_close(ef)) goto save_end;
|
||||
if (eet_close(ef))
|
||||
goto save_end;
|
||||
|
||||
if (!ecore_file_mv(buf2, buf)) goto save_end;
|
||||
|
||||
INF("Config saved");
|
||||
if (!ecore_file_mv(buf2, buf))
|
||||
goto save_end;
|
||||
|
||||
save_end:
|
||||
ecore_file_unlink(buf2);
|
||||
|
|
|
@ -21,11 +21,11 @@ struct _Ephoto_Cropper
|
|||
};
|
||||
|
||||
static void
|
||||
_calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
char buf[PATH_MAX];
|
||||
int w, h, cw, ch, iw, ih, nw, nh;
|
||||
double scalew, scaleh;
|
||||
|
||||
|
@ -48,11 +48,13 @@ _calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED, const char *em
|
|||
msg->val[0] = 11;
|
||||
msg->val[1] = nw;
|
||||
msg->val[2] = nh;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msgl, *msgr;
|
||||
|
@ -88,22 +90,25 @@ _cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf
|
|||
msgl->val[0] = 8;
|
||||
msgl->val[1] = left;
|
||||
msgl->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgl);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgl);
|
||||
|
||||
msgr = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msgr->count = 3;
|
||||
msgr->val[0] = 4;
|
||||
msgr->val[1] = right;
|
||||
msgr->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgr);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgr);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msgt, *msgb;
|
||||
int mh, ch, cy, nh, lh, ly, ih, left, top, bottom;
|
||||
int mh, ch, cy, nh, lh, ly, ih, top, bottom;
|
||||
double scaleh;
|
||||
|
||||
mh = elm_slider_value_get(ec->croph);
|
||||
|
@ -134,18 +139,21 @@ _cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
msgt->val[0] = 2;
|
||||
msgt->val[1] = 0;
|
||||
msgt->val[2] = top;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgt);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgt);
|
||||
|
||||
msgb = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msgb->count = 3;
|
||||
msgb->val[0] = 6;
|
||||
msgb->val[1] = 0;
|
||||
msgb->val[2] = bottom;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgb);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgb);
|
||||
}
|
||||
|
||||
static void
|
||||
_reset_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_reset_crop(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -155,26 +163,29 @@ _reset_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
msg->val[0] = 10;
|
||||
msg->val[1] = 0;
|
||||
msg->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_apply_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_apply_crop(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Evas_Object *edje = elm_layout_edje_get(ec->layout);
|
||||
|
||||
const char *path, *key, *type;;
|
||||
int x, y, w, h, cx, cy, cw, ch, iw, ih;
|
||||
int nx, ny, nw, nh, i, j, tmpx, tmpy, ind, index;
|
||||
double scalex, scaley, scalew, scaleh;
|
||||
unsigned int *idata, *idata_new;
|
||||
|
||||
evas_object_geometry_get(ec->layout, &x, &y, &w, &h);
|
||||
edje_object_part_geometry_get(edje, "ephoto.swallow.cropper", &cx, &cy, &cw, &ch);
|
||||
edje_object_part_geometry_get(edje, "ephoto.swallow.cropper", &cx, &cy, &cw,
|
||||
&ch);
|
||||
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
|
||||
|
||||
idata = evas_object_image_data_get(elm_image_object_get(ec->image), EINA_FALSE);
|
||||
idata =
|
||||
evas_object_image_data_get(elm_image_object_get(ec->image), EINA_FALSE);
|
||||
|
||||
scalex = (double) cx / (double) w;
|
||||
scaley = (double) cy / (double) h;
|
||||
|
@ -203,7 +214,8 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
elm_table_unpack(ec->image_parent, ec->box);
|
||||
elm_layout_content_unset(ec->layout, "ephoto.swallow.image");
|
||||
elm_table_pack(ec->image_parent, ec->image, 0, 0, 1, 1);
|
||||
ephoto_single_browser_image_data_update(ec->main, ec->image, EINA_TRUE, idata_new, nw, nh);
|
||||
ephoto_single_browser_image_data_update(ec->main, ec->image, EINA_TRUE,
|
||||
idata_new, nw, nh);
|
||||
evas_object_del(ec->frame);
|
||||
evas_object_del(ec->cropper);
|
||||
evas_object_del(ec->layout);
|
||||
|
@ -211,7 +223,8 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
}
|
||||
|
||||
static void
|
||||
_cancel_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cancel_crop(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
|
@ -226,7 +239,8 @@ _cancel_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNU
|
|||
}
|
||||
|
||||
static void
|
||||
_cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -263,21 +277,26 @@ _cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *e
|
|||
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_both_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_both_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source, _cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source, _cropper_both_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source,
|
||||
_cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_both_mouse_up, ec);
|
||||
ec->resizing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_resize_both(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_resize_both(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -290,12 +309,15 @@ _cropper_resize_both(void *data, Evas_Object *obj EINA_UNUSED, const char *emiss
|
|||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source, _cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source, _cropper_both_mouse_up, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source,
|
||||
_cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_both_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -321,21 +343,26 @@ _cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *
|
|||
msg->val[0] = 8;
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_horiz_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_horiz_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source, _cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source, _cropper_horiz_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source,
|
||||
_cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_horiz_mouse_up, ec);
|
||||
ec->resizing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_resize_horiz(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_resize_horiz(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -348,12 +375,15 @@ _cropper_resize_horiz(void *data, Evas_Object *obj EINA_UNUSED, const char *emis
|
|||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source, _cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source, _cropper_horiz_mouse_up, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source,
|
||||
_cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_horiz_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -379,21 +409,26 @@ _cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *e
|
|||
msg->val[0] = 6;
|
||||
msg->val[1] = 0;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_vert_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_vert_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source, _cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source, _cropper_vert_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source,
|
||||
_cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_vert_mouse_up, ec);
|
||||
ec->resizing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_resize_vert(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_resize_vert(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -406,15 +441,18 @@ _cropper_resize_vert(void *data, Evas_Object *obj EINA_UNUSED, const char *emiss
|
|||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source, _cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source, _cropper_vert_mouse_up, ec);
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source,
|
||||
_cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_vert_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
if (!ec->resizing)
|
||||
{
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -443,21 +481,26 @@ _cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emissi
|
|||
msg->val[0] = 0;
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", "dragger", _cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", "dragger", _cropper_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", "dragger",
|
||||
_cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", "dragger",
|
||||
_cropper_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -469,12 +512,15 @@ _cropper_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EIN
|
|||
ec->offsetx = mx - cx;
|
||||
ec->offsety = my - cy;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", "dragger", _cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", "dragger", _cropper_mouse_up, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", "dragger",
|
||||
_cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", "dragger",
|
||||
_cropper_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -485,6 +531,7 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
|
||||
|
||||
int nw, nh;
|
||||
|
||||
if (sw > sh)
|
||||
{
|
||||
nw = sw;
|
||||
|
@ -492,6 +539,7 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
if (nh > sh)
|
||||
{
|
||||
int onw, onh;
|
||||
|
||||
onw = nw;
|
||||
onh = nh;
|
||||
nh = sh;
|
||||
|
@ -505,6 +553,7 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
if (nw > sw)
|
||||
{
|
||||
int onw, onh;
|
||||
|
||||
onw = nw;
|
||||
onh = nh;
|
||||
nw = sw;
|
||||
|
@ -526,18 +575,22 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
msg->val[0] = 9;
|
||||
msg->val[1] = 0;
|
||||
msg->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cropper_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
free(ec);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_parent, Evas_Object *image)
|
||||
ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image_parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *vbox, *ic, *button;
|
||||
Ephoto_Cropper *ec;
|
||||
|
@ -559,40 +612,57 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
ec->box = elm_box_add(image_parent);
|
||||
elm_box_homogeneous_set(ec->box, EINA_TRUE);
|
||||
elm_box_horizontal_set(ec->box, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(ec->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(ec->box, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ec->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(image_parent, ec->box, 0, 0, 1, 1);
|
||||
evas_object_show(ec->box);
|
||||
|
||||
ec->layout = elm_layout_add(ec->box);
|
||||
elm_layout_file_set(ec->layout, PACKAGE_DATA_DIR "/themes/crop.edj", "ephoto,image,cropper,base");
|
||||
evas_object_size_hint_weight_set(ec->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_layout_file_set(ec->layout, PACKAGE_DATA_DIR "/themes/crop.edj",
|
||||
"ephoto,image,cropper,base");
|
||||
evas_object_size_hint_weight_set(ec->layout, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ec->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(ec->box, ec->layout);
|
||||
evas_object_show(ec->layout);
|
||||
|
||||
evas_object_size_hint_weight_set(ec->image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(ec->image, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ec->image, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_layout_content_set(ec->layout, "ephoto.swallow.image", ec->image);
|
||||
evas_object_show(ec->image);
|
||||
|
||||
ec->cropper = edje_object_add(evas_object_evas_get(ec->layout));
|
||||
edje_object_file_set(ec->cropper, PACKAGE_DATA_DIR "/themes/crop.edj", "ephoto,image,cropper");
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(ec->layout), "cropper,changed", "ephoto.swallow.cropper", _calculate_cropper_size, ec);
|
||||
edje_object_file_set(ec->cropper, PACKAGE_DATA_DIR "/themes/crop.edj",
|
||||
"ephoto,image,cropper");
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(ec->layout),
|
||||
"cropper,changed", "ephoto.swallow.cropper", _calculate_cropper_size,
|
||||
ec);
|
||||
elm_layout_content_set(ec->layout, "ephoto.swallow.cropper", ec->cropper);
|
||||
evas_object_show(ec->cropper);
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "dragger", _cropper_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle1", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle2", _cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle3", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle4", _cropper_resize_horiz, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle5", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle6", _cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle7", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle8", _cropper_resize_horiz, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "dragger",
|
||||
_cropper_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle1",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle2",
|
||||
_cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle3",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle4",
|
||||
_cropper_resize_horiz, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle5",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle6",
|
||||
_cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle7",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle8",
|
||||
_cropper_resize_horiz, ec);
|
||||
|
||||
evas_object_event_callback_add(ec->layout, EVAS_CALLBACK_RESIZE, _image_resize, ec);
|
||||
evas_object_event_callback_add(ec->layout, EVAS_CALLBACK_RESIZE,
|
||||
_image_resize, ec);
|
||||
evas_object_event_callback_add(ec->box, EVAS_CALLBACK_DEL, _cropper_del, ec);
|
||||
|
||||
ec->frame = elm_frame_add(parent);
|
||||
|
@ -615,10 +685,12 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
elm_slider_step_set(ec->cropw, 1);
|
||||
elm_slider_unit_format_set(ec->cropw, "%1.0f");
|
||||
elm_object_text_set(ec->cropw, _("Width"));
|
||||
evas_object_size_hint_weight_set(ec->cropw, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(ec->cropw, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(ec->cropw, EVAS_HINT_FILL, 0.5);
|
||||
elm_box_pack_end(vbox, ec->cropw);
|
||||
evas_object_smart_callback_add(ec->cropw, "slider,drag,stop", _cropper_changed_width, ec);
|
||||
evas_object_smart_callback_add(ec->cropw, "slider,drag,stop",
|
||||
_cropper_changed_width, ec);
|
||||
evas_object_show(ec->cropw);
|
||||
|
||||
ec->croph = elm_slider_add(vbox);
|
||||
|
@ -626,10 +698,12 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
elm_slider_step_set(ec->croph, 1);
|
||||
elm_slider_unit_format_set(ec->croph, "%1.0f");
|
||||
elm_object_text_set(ec->croph, _("Height"));
|
||||
evas_object_size_hint_weight_set(ec->croph, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(ec->croph, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(ec->croph, EVAS_HINT_FILL, 0.5);
|
||||
elm_box_pack_end(vbox, ec->croph);
|
||||
evas_object_smart_callback_add(ec->croph, "slider,drag,stop", _cropper_changed_height, ec);
|
||||
evas_object_smart_callback_add(ec->croph, "slider,drag,stop",
|
||||
_cropper_changed_height, ec);
|
||||
evas_object_show(ec->croph);
|
||||
|
||||
ic = elm_icon_add(vbox);
|
||||
|
|
|
@ -15,7 +15,7 @@ static int
|
|||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ static int
|
|||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ ephoto_filter_blur(Evas_Object *main, Evas_Object *image)
|
|||
int a, r, g, b;
|
||||
int *as, *rs, *gs, *bs;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
|
@ -119,7 +120,8 @@ ephoto_filter_blur(Evas_Object *main, Evas_Object *image)
|
|||
free(gs);
|
||||
free(bs);
|
||||
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -127,17 +129,13 @@ ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image)
|
|||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int a, r, g, b, x, y, w, h;
|
||||
int mul, mul2, tot;
|
||||
int rad = 3;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
|
||||
mul = (rad * 4) + 1;
|
||||
mul2 = rad;
|
||||
tot = mul - (mul2 * 4);
|
||||
for (y = 1; y < (h - 1); y++)
|
||||
{
|
||||
p1 = im_data + 1 + (y * w);
|
||||
|
@ -177,7 +175,8 @@ ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image)
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -186,7 +185,8 @@ ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image)
|
|||
unsigned int *im_data, *im_data_new;
|
||||
int gray, i, r, g, b, a, w, h;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
|
@ -205,7 +205,8 @@ ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image)
|
|||
gray = (gray * a) / 255;
|
||||
im_data_new[i] = (a << 24) | (gray << 16) | (gray << 8) | gray;
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -214,7 +215,8 @@ ephoto_filter_old_photo(Evas_Object *main, Evas_Object *image)
|
|||
unsigned int *im_data, *im_data_new;
|
||||
int i, r, rr, g, gg, b, bb, a, w, h;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
for (i = 0; i < (w * h); i++)
|
||||
|
@ -237,7 +239,8 @@ ephoto_filter_old_photo(Evas_Object *main, Evas_Object *image)
|
|||
rr = _demul_color_alpha(rr, a);
|
||||
im_data_new[i] = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -248,7 +251,8 @@ ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image)
|
|||
int a, r, g, b, bb, gg, rr, norm, total;
|
||||
float hh, s, v, nv, sum;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
total = w * h;
|
||||
|
@ -306,6 +310,6 @@ ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image)
|
|||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ static int
|
|||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static int
|
|||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ unsigned int *
|
|||
_ephoto_hsv_adjust_hue(Ephoto_HSV *ehsv, double hue, unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float hh, s, v;
|
||||
|
||||
|
@ -58,7 +58,8 @@ _ephoto_hsv_adjust_hue(Ephoto_HSV *ehsv, double hue, unsigned int *image_data)
|
|||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
else
|
||||
memcpy(im_data, ehsv->original_im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, ehsv->original_im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
|
@ -94,16 +95,18 @@ _ephoto_hsv_adjust_hue(Ephoto_HSV *ehsv, double hue, unsigned int *image_data)
|
|||
}
|
||||
}
|
||||
ehsv->hue = hue;
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE, im_data_new, ehsv->w, ehsv->h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
|
||||
im_data_new, ehsv->w, ehsv->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double saturation, unsigned int *image_data)
|
||||
_ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double saturation,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float hh, s, v;
|
||||
|
||||
|
@ -111,7 +114,8 @@ _ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double saturation, unsigned int
|
|||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
else
|
||||
memcpy(im_data, ehsv->original_im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, ehsv->original_im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
|
@ -147,16 +151,18 @@ _ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double saturation, unsigned int
|
|||
}
|
||||
}
|
||||
ehsv->saturation = saturation;
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE, im_data_new, ehsv->w, ehsv->h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
|
||||
im_data_new, ehsv->w, ehsv->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value, unsigned int *image_data)
|
||||
_ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float hh, s, v;
|
||||
|
||||
|
@ -164,7 +170,8 @@ _ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value, unsigned int *image_dat
|
|||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
else
|
||||
memcpy(im_data, ehsv->original_im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, ehsv->original_im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
|
@ -200,7 +207,8 @@ _ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value, unsigned int *image_dat
|
|||
}
|
||||
}
|
||||
ehsv->value = value;
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE, im_data_new, ehsv->w, ehsv->h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
|
||||
im_data_new, ehsv->w, ehsv->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
@ -210,43 +218,46 @@ _hue_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
double hue;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
hue = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_hsv_adjust_hue(ehsv, hue, NULL);
|
||||
image_data_two = _ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data);
|
||||
image_data_three = _ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data);
|
||||
_ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_saturation_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_saturation_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
double saturation;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
saturation = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_hsv_adjust_saturation(ehsv, saturation, NULL);
|
||||
image_data_two = _ephoto_hsv_adjust_hue(ehsv, ehsv->hue, image_data);
|
||||
image_data_three = _ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
_ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_value_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_value_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
double value;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
value = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_hsv_adjust_value(ehsv, value, NULL);
|
||||
image_data_two = _ephoto_hsv_adjust_hue(ehsv, ehsv->hue, image_data);
|
||||
image_data_three = _ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data_two);
|
||||
_ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_hsv_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_hsv_reset(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
|
||||
|
@ -260,20 +271,25 @@ _hsv_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSE
|
|||
}
|
||||
|
||||
static void
|
||||
_hsv_apply(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_hsv_apply(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
unsigned int *image_data;
|
||||
int w, h;
|
||||
|
||||
image_data = evas_object_image_data_get(elm_image_object_get(ehsv->image), EINA_FALSE);
|
||||
image_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ehsv->image),
|
||||
EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ehsv->image), &w, &h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_TRUE, image_data, w, h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_TRUE,
|
||||
image_data, w, h);
|
||||
evas_object_del(ehsv->frame);
|
||||
}
|
||||
|
||||
static void
|
||||
_hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
|
||||
|
@ -289,16 +305,19 @@ _hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
}
|
||||
|
||||
static void
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
|
||||
free(ehsv->original_im_data);
|
||||
free(ehsv);
|
||||
}
|
||||
|
||||
void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
void
|
||||
ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *win, *box, *slider, *ic, *button;
|
||||
Evas_Object *box, *slider, *ic, *button;
|
||||
Ephoto_HSV *ehsv;
|
||||
unsigned int *im_data;
|
||||
|
||||
|
@ -313,10 +332,14 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
ehsv->main = main;
|
||||
ehsv->parent = parent;
|
||||
ehsv->image = image;
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(ehsv->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ehsv->image), &ehsv->w, &ehsv->h);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ehsv->image),
|
||||
EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ehsv->image), &ehsv->w,
|
||||
&ehsv->h);
|
||||
ehsv->original_im_data = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(ehsv->original_im_data, im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(ehsv->original_im_data, im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
ehsv->frame = elm_frame_add(parent);
|
||||
elm_object_text_set(ehsv->frame, _("Hue/Saturation/Value"));
|
||||
|
@ -324,7 +347,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
evas_object_size_hint_align_set(ehsv->frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(parent, ehsv->frame);
|
||||
evas_object_data_set(ehsv->frame, "ehsv", ehsv);
|
||||
evas_object_event_callback_add(ehsv->frame, EVAS_CALLBACK_DEL, _frame_del, ehsv);
|
||||
evas_object_event_callback_add(ehsv->frame, EVAS_CALLBACK_DEL, _frame_del,
|
||||
ehsv);
|
||||
evas_object_show(ehsv->frame);
|
||||
|
||||
box = elm_box_add(ehsv->frame);
|
||||
|
@ -342,7 +366,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
elm_slider_unit_format_set(slider, "%1.0f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _hue_slider_changed, ehsv);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _hue_slider_changed,
|
||||
ehsv);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ehsv->hslider = slider;
|
||||
|
@ -355,7 +380,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
elm_slider_unit_format_set(slider, "%1.2f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _saturation_slider_changed, ehsv);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_saturation_slider_changed, ehsv);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ehsv->sslider = slider;
|
||||
|
@ -368,7 +394,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
elm_slider_unit_format_set(slider, "%1.2f");
|
||||
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _value_slider_changed, ehsv);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_value_slider_changed, ehsv);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ehsv->vslider = slider;
|
||||
|
|
|
@ -12,6 +12,14 @@ struct _Ephoto_Entry_Free_Listener
|
|||
const void *data;
|
||||
};
|
||||
|
||||
typedef struct _Ephoto_Dir_Data Ephoto_Dir_Data;
|
||||
struct _Ephoto_Dir_Data
|
||||
{
|
||||
Ephoto *ephoto;
|
||||
Elm_Widget_Item *expanded;
|
||||
Eina_Bool dirs_only;
|
||||
};
|
||||
|
||||
static void
|
||||
_ephoto_state_set(Ephoto *ephoto, Ephoto_State state)
|
||||
{
|
||||
|
@ -22,8 +30,6 @@ _ephoto_state_set(Ephoto *ephoto, Ephoto_State state)
|
|||
static void
|
||||
_ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||
{
|
||||
DBG("entry '%s'", entry ? entry->path : "");
|
||||
|
||||
ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
|
||||
ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
|
||||
elm_naviframe_item_promote(ephoto->tb);
|
||||
|
@ -38,7 +44,6 @@ _ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|||
static void
|
||||
_ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||
{
|
||||
DBG("entry '%s'", entry->path);
|
||||
ephoto_single_browser_entry_set(ephoto->single_browser, entry);
|
||||
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->single_browser);
|
||||
elm_object_focus_set(ephoto->single_browser, EINA_TRUE);
|
||||
|
@ -48,7 +53,6 @@ _ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|||
static void
|
||||
_ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||
{
|
||||
DBG("entry '%s'", entry->path);
|
||||
ephoto_slideshow_entry_set(ephoto->slideshow, entry);
|
||||
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->slideshow);
|
||||
elm_object_focus_set(ephoto->slideshow, EINA_TRUE);
|
||||
|
@ -56,74 +60,92 @@ _ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|||
}
|
||||
|
||||
static void
|
||||
_ephoto_single_browser_back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_single_browser_back(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_slideshow_back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_slideshow_back(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
switch (ephoto->prev_state)
|
||||
{
|
||||
case EPHOTO_STATE_SINGLE:
|
||||
_ephoto_single_browser_show(ephoto, entry);
|
||||
break;
|
||||
|
||||
case EPHOTO_STATE_THUMB:
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("unhandled previous state %d", ephoto->prev_state);
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_thumb_browser_view(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_thumb_browser_view(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_single_browser_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_thumb_browser_changed_directory(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_ephoto_thumb_browser_changed_directory(void *data,
|
||||
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
|
||||
ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
|
||||
ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_thumb_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_thumb_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_slideshow_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_single_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_single_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_slideshow_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
if (ephoto->timer.thumb_regen) ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
|
||||
if (ephoto->timer.thumb_regen)
|
||||
ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
ephoto_config_save(ephoto);
|
||||
free(ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
int w, h;
|
||||
|
@ -141,6 +163,7 @@ ephoto_window_add(const char *path)
|
|||
{
|
||||
Ephoto *ephoto = calloc(1, sizeof(Ephoto));
|
||||
char buf[PATH_MAX];
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ephoto, NULL);
|
||||
|
||||
EPHOTO_EVENT_ENTRY_CREATE = ecore_event_type_new();
|
||||
|
@ -155,11 +178,10 @@ ephoto_window_add(const char *path)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
evas_object_event_callback_add
|
||||
(ephoto->win, EVAS_CALLBACK_FREE, _win_free, ephoto);
|
||||
evas_object_event_callback_add
|
||||
(ephoto->win, EVAS_CALLBACK_RESIZE, _resize_cb, ephoto);
|
||||
|
||||
evas_object_event_callback_add(ephoto->win, EVAS_CALLBACK_FREE, _win_free,
|
||||
ephoto);
|
||||
evas_object_event_callback_add(ephoto->win, EVAS_CALLBACK_RESIZE, _resize_cb,
|
||||
ephoto);
|
||||
elm_win_autodel_set(ephoto->win, EINA_TRUE);
|
||||
|
||||
if (!ephoto_config_init(ephoto))
|
||||
|
@ -175,59 +197,57 @@ ephoto_window_add(const char *path)
|
|||
|
||||
ephoto->pager = elm_naviframe_add(ephoto->win);
|
||||
elm_naviframe_prev_btn_auto_pushed_set(ephoto->pager, EINA_FALSE);
|
||||
evas_object_size_hint_weight_set
|
||||
(ephoto->pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set
|
||||
(ephoto->pager, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(ephoto->pager, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set(ephoto->pager, EVAS_HINT_FILL,
|
||||
EVAS_HINT_FILL);
|
||||
elm_win_resize_object_add(ephoto->win, ephoto->pager);
|
||||
evas_object_show(ephoto->pager);
|
||||
|
||||
ephoto->thumb_browser = ephoto_thumb_browser_add(ephoto, ephoto->pager);
|
||||
if (!ephoto->thumb_browser)
|
||||
{
|
||||
ERR("could not add thumb browser");
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
ephoto->tb = elm_naviframe_item_push(ephoto->pager, NULL, NULL, NULL, ephoto->thumb_browser, "overlap");
|
||||
ephoto->tb =
|
||||
elm_naviframe_item_push(ephoto->pager, NULL, NULL, NULL,
|
||||
ephoto->thumb_browser, "overlap");
|
||||
elm_naviframe_item_title_enabled_set(ephoto->tb, EINA_FALSE, EINA_FALSE);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->thumb_browser, "view", _ephoto_thumb_browser_view, ephoto);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->thumb_browser, "changed,directory",
|
||||
evas_object_smart_callback_add(ephoto->thumb_browser, "view",
|
||||
_ephoto_thumb_browser_view, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->thumb_browser, "changed,directory",
|
||||
_ephoto_thumb_browser_changed_directory, ephoto);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->thumb_browser, "slideshow",
|
||||
evas_object_smart_callback_add(ephoto->thumb_browser, "slideshow",
|
||||
_ephoto_thumb_browser_slideshow, ephoto);
|
||||
|
||||
ephoto->single_browser = ephoto_single_browser_add(ephoto, ephoto->pager);
|
||||
if (!ephoto->single_browser)
|
||||
{
|
||||
ERR("could not add single browser");
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
ephoto->sb = elm_naviframe_item_insert_after(ephoto->pager, ephoto->tb,
|
||||
NULL, NULL, NULL, ephoto->single_browser, "overlap");
|
||||
ephoto->sb =
|
||||
elm_naviframe_item_insert_after(ephoto->pager, ephoto->tb, NULL, NULL,
|
||||
NULL, ephoto->single_browser, "overlap");
|
||||
elm_naviframe_item_title_enabled_set(ephoto->sb, EINA_FALSE, EINA_FALSE);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->single_browser, "back", _ephoto_single_browser_back, ephoto);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->single_browser, "slideshow",
|
||||
evas_object_smart_callback_add(ephoto->single_browser, "back",
|
||||
_ephoto_single_browser_back, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->single_browser, "slideshow",
|
||||
_ephoto_single_browser_slideshow, ephoto);
|
||||
|
||||
ephoto->slideshow = ephoto_slideshow_add(ephoto, ephoto->pager);
|
||||
if (!ephoto->slideshow)
|
||||
{
|
||||
ERR("could not add single browser");
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
ephoto->sl = elm_naviframe_item_insert_after(ephoto->pager, ephoto->sb,
|
||||
NULL, NULL, NULL, ephoto->slideshow, "overlap");
|
||||
ephoto->sl =
|
||||
elm_naviframe_item_insert_after(ephoto->pager, ephoto->sb, NULL, NULL,
|
||||
NULL, ephoto->slideshow, "overlap");
|
||||
elm_naviframe_item_title_enabled_set(ephoto->sl, EINA_FALSE, EINA_FALSE);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->slideshow, "back", _ephoto_slideshow_back, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->slideshow, "back",
|
||||
_ephoto_slideshow_back, ephoto);
|
||||
|
||||
if ((!path) || (!ecore_file_exists(path)))
|
||||
{
|
||||
|
@ -237,7 +257,8 @@ ephoto_window_add(const char *path)
|
|||
path = ephoto->config->directory;
|
||||
else
|
||||
path = ephoto->config->open;
|
||||
if ((path) && (!ecore_file_exists(path))) path = NULL;
|
||||
if ((path) && (!ecore_file_exists(path)))
|
||||
path = NULL;
|
||||
}
|
||||
else if (!ephoto->config->open || path)
|
||||
{
|
||||
|
@ -250,13 +271,14 @@ ephoto_window_add(const char *path)
|
|||
|
||||
if (ecore_file_is_dir(path))
|
||||
{
|
||||
ephoto_directory_set(ephoto, path);
|
||||
ephoto_directory_set(ephoto, path, NULL, EINA_FALSE);
|
||||
_ephoto_thumb_browser_show(ephoto, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *dir = ecore_file_dir_get(path);
|
||||
ephoto_directory_set(ephoto, dir);
|
||||
|
||||
ephoto_directory_set(ephoto, dir, NULL, EINA_FALSE);
|
||||
free(dir);
|
||||
ephoto_single_browser_path_pending_set(ephoto->single_browser, path);
|
||||
|
||||
|
@ -265,7 +287,8 @@ ephoto_window_add(const char *path)
|
|||
ephoto->state = EPHOTO_STATE_SINGLE;
|
||||
}
|
||||
|
||||
evas_object_resize(ephoto->win, ephoto->config->window_width, ephoto->config->window_height);
|
||||
evas_object_resize(ephoto->win, ephoto->config->window_width,
|
||||
ephoto->config->window_height);
|
||||
evas_object_show(ephoto->win);
|
||||
|
||||
return ephoto->win;
|
||||
|
@ -289,51 +312,64 @@ int
|
|||
ephoto_entries_cmp(const void *pa, const void *pb)
|
||||
{
|
||||
const Ephoto_Entry *a = pa, *b = pb;
|
||||
|
||||
return strcoll(a->basename, b->basename);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info)
|
||||
_ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED,
|
||||
const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
Ephoto_Entry *e;
|
||||
Ephoto_Event_Entry_Create *ev;
|
||||
|
||||
e = ephoto_entry_new(ephoto, info->path, info->path + info->name_start, info->type);
|
||||
e = ephoto_entry_new(ed->ephoto, info->path, info->path + info->name_start,
|
||||
info->type);
|
||||
|
||||
if (e->is_dir)
|
||||
{
|
||||
if (!ephoto->direntries)
|
||||
ephoto->direntries = eina_list_append(ephoto->direntries, e);
|
||||
if (!ed->ephoto->direntries)
|
||||
ed->ephoto->direntries = eina_list_append(ed->ephoto->direntries, e);
|
||||
else
|
||||
{
|
||||
int near_cmp;
|
||||
Eina_List *near_node = eina_list_search_sorted_near_list
|
||||
(ephoto->direntries, ephoto_entries_cmp, e, &near_cmp);
|
||||
Eina_List *near_node =
|
||||
eina_list_search_sorted_near_list(ed->ephoto->direntries,
|
||||
ephoto_entries_cmp, e, &near_cmp);
|
||||
|
||||
if (near_cmp < 0)
|
||||
ephoto->direntries = eina_list_append_relative_list
|
||||
(ephoto->direntries, e, near_node);
|
||||
ed->ephoto->direntries =
|
||||
eina_list_append_relative_list(ed->ephoto->direntries, e,
|
||||
near_node);
|
||||
else
|
||||
ephoto->direntries = eina_list_prepend_relative_list
|
||||
(ephoto->direntries, e, near_node);
|
||||
ed->ephoto->direntries =
|
||||
eina_list_prepend_relative_list(ed->ephoto->direntries, e,
|
||||
near_node);
|
||||
}
|
||||
e->parent = ed->expanded;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ephoto->entries)
|
||||
ephoto->entries = eina_list_append(ephoto->entries, e);
|
||||
if (!ed->ephoto->entries)
|
||||
ed->ephoto->entries = eina_list_append(ed->ephoto->entries, e);
|
||||
else
|
||||
{
|
||||
int near_cmp;
|
||||
Eina_List *near_node = eina_list_search_sorted_near_list
|
||||
(ephoto->entries, ephoto_entries_cmp, e, &near_cmp);
|
||||
Eina_List *near_node =
|
||||
eina_list_search_sorted_near_list(ed->ephoto->entries,
|
||||
ephoto_entries_cmp, e, &near_cmp);
|
||||
|
||||
if (near_cmp < 0)
|
||||
ephoto->entries = eina_list_append_relative_list
|
||||
(ephoto->entries, e, near_node);
|
||||
ed->ephoto->entries =
|
||||
eina_list_append_relative_list(ed->ephoto->entries, e,
|
||||
near_node);
|
||||
else
|
||||
ephoto->entries = eina_list_prepend_relative_list
|
||||
(ephoto->entries, e, near_node);
|
||||
ed->ephoto->entries =
|
||||
eina_list_prepend_relative_list(ed->ephoto->entries, e,
|
||||
near_node);
|
||||
}
|
||||
e->parent = NULL;
|
||||
}
|
||||
ev = calloc(1, sizeof(Ephoto_Event_Entry_Create));
|
||||
ev->entry = e;
|
||||
|
@ -342,48 +378,54 @@ _ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED, const Eina_File
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ephoto_populate_filter(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info)
|
||||
_ephoto_populate_filter(void *data, Eio_File *handler EINA_UNUSED,
|
||||
const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
const char *bname = info->path + info->name_start;
|
||||
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
if (info->type == EINA_FILE_DIR) return EINA_TRUE;
|
||||
|
||||
if (bname[0] == '.')
|
||||
return EINA_FALSE;
|
||||
if (info->type == EINA_FILE_DIR)
|
||||
return EINA_TRUE;
|
||||
if (!ed->dirs_only)
|
||||
return _ephoto_eina_file_direct_info_image_useful(info);
|
||||
else
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_end(void *data, Eio_File *handler EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
ephoto->ls = NULL;
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
|
||||
ed->ephoto->ls = NULL;
|
||||
|
||||
ecore_event_add(EPHOTO_EVENT_POPULATE_END, NULL, NULL, NULL);
|
||||
free(ed);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_error(void *data, Eio_File *handler, int error)
|
||||
_ephoto_populate_error(void *data, Eio_File *handler, int error EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
if (error) ERR("could not populate: %s", strerror(error));
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
|
||||
ecore_event_add(EPHOTO_EVENT_POPULATE_ERROR, NULL, NULL, NULL);
|
||||
_ephoto_populate_end(ephoto, handler);
|
||||
_ephoto_populate_end(ed->ephoto, handler);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_entries(Ephoto *ephoto)
|
||||
_ephoto_populate_entries(Ephoto_Dir_Data *ed)
|
||||
{
|
||||
DBG("populate from '%s'", ephoto->config->directory);
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
ephoto_entries_free(ephoto);
|
||||
|
||||
ephoto->ls = eio_file_stat_ls(ephoto->config->directory,
|
||||
_ephoto_populate_filter,
|
||||
_ephoto_populate_main,
|
||||
_ephoto_populate_end,
|
||||
_ephoto_populate_error,
|
||||
ephoto);
|
||||
if (!ed->dirs_only)
|
||||
ephoto_entries_free(ed->ephoto);
|
||||
else
|
||||
EINA_LIST_FREE(ed->ephoto->direntries, entry) ephoto_entry_free(entry);
|
||||
ed->ephoto->ls =
|
||||
eio_file_stat_ls(ed->ephoto->config->directory, _ephoto_populate_filter,
|
||||
_ephoto_populate_main, _ephoto_populate_end, _ephoto_populate_error, ed);
|
||||
|
||||
ecore_event_add(EPHOTO_EVENT_POPULATE_START, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -391,20 +433,29 @@ _ephoto_populate_entries(Ephoto *ephoto)
|
|||
static void
|
||||
_ephoto_change_dir(void *data)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
ephoto->job.change_dir = NULL;
|
||||
_ephoto_populate_entries(ephoto);
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
|
||||
ed->ephoto->job.change_dir = NULL;
|
||||
_ephoto_populate_entries(ed);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_directory_set(Ephoto *ephoto, const char *path)
|
||||
ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
|
||||
Eina_Bool dirs_only)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(ephoto);
|
||||
Ephoto_Dir_Data *ed;
|
||||
|
||||
ed = malloc(sizeof(Ephoto_Dir_Data));
|
||||
ed->ephoto = ephoto;
|
||||
ed->expanded = expanded;
|
||||
ed->dirs_only = dirs_only;
|
||||
|
||||
ephoto_title_set(ephoto, NULL);
|
||||
eina_stringshare_replace(&ephoto->config->directory, path);
|
||||
if (ephoto->job.change_dir) ecore_job_del(ephoto->job.change_dir);
|
||||
ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ephoto);
|
||||
|
||||
if (ed->ephoto->job.change_dir)
|
||||
ecore_job_del(ed->ephoto->job.change_dir);
|
||||
ed->ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ed);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -414,16 +465,15 @@ _thumb_gen_size_changed_timer_cb(void *data)
|
|||
const Eina_List *l;
|
||||
Evas_Object *o;
|
||||
|
||||
if (ephoto->config->thumb_gen_size == ephoto->thumb_gen_size) goto end;
|
||||
|
||||
INF("thumbnail generation size changed from %d to %d",
|
||||
ephoto->config->thumb_gen_size, ephoto->thumb_gen_size);
|
||||
if (ephoto->config->thumb_gen_size == ephoto->thumb_gen_size)
|
||||
goto end;
|
||||
|
||||
ephoto->config->thumb_gen_size = ephoto->thumb_gen_size;
|
||||
|
||||
EINA_LIST_FOREACH(ephoto->thumbs, l, o)
|
||||
{
|
||||
Ethumb_Thumb_Format format;
|
||||
|
||||
format = (long) evas_object_data_get(o, "ephoto_format");
|
||||
if (format)
|
||||
{
|
||||
|
@ -436,11 +486,11 @@ _thumb_gen_size_changed_timer_cb(void *data)
|
|||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_LARGE);
|
||||
}
|
||||
else
|
||||
elm_thumb_size_set(o, ephoto->thumb_gen_size, ephoto->thumb_gen_size);
|
||||
elm_thumb_size_set(o, ephoto->thumb_gen_size,
|
||||
ephoto->thumb_gen_size);
|
||||
elm_thumb_reload(o);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
ephoto->timer.thumb_regen = NULL;
|
||||
return EINA_FALSE;
|
||||
|
@ -451,43 +501,40 @@ ephoto_thumb_size_set(Ephoto *ephoto, int size)
|
|||
{
|
||||
if (ephoto->config->thumb_size != size)
|
||||
{
|
||||
INF("thumbnail display size changed from %d to %d",
|
||||
ephoto->config->thumb_size, size);
|
||||
ephoto->config->thumb_size = size;
|
||||
}
|
||||
|
||||
if (size <= 128) ephoto->thumb_gen_size = 128;
|
||||
else if (size <= 256) ephoto->thumb_gen_size = 256;
|
||||
else ephoto->thumb_gen_size = 512;
|
||||
if (size <= 128)
|
||||
ephoto->thumb_gen_size = 128;
|
||||
else if (size <= 256)
|
||||
ephoto->thumb_gen_size = 256;
|
||||
else
|
||||
ephoto->thumb_gen_size = 512;
|
||||
|
||||
if (ephoto->timer.thumb_regen) ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
ephoto->timer.thumb_regen = ecore_timer_add
|
||||
(0.1, _thumb_gen_size_changed_timer_cb, ephoto);
|
||||
if (ephoto->timer.thumb_regen)
|
||||
ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
ephoto->timer.thumb_regen =
|
||||
ecore_timer_add(0.1, _thumb_gen_size_changed_timer_cb, ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
ephoto->thumbs = eina_list_remove(ephoto->thumbs, obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_load_error(void *data , Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *path = data;
|
||||
ERR("Error loading thumbnail: %s\n", path);
|
||||
ephoto->thumbs = eina_list_remove(ephoto->thumbs, obj);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
|
||||
{
|
||||
Evas_Object *o;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
||||
|
||||
if (path)
|
||||
{
|
||||
const char *ext = strrchr(path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
|
@ -498,16 +545,17 @@ ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
|
|||
}
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
ephoto_thumb_path_set(o, path);
|
||||
}
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
if (!o) return NULL;
|
||||
if (!o)
|
||||
return NULL;
|
||||
|
||||
if (path) ephoto_thumb_path_set(o, path);
|
||||
elm_object_style_set(o, "noframe");
|
||||
ephoto->thumbs = eina_list_append(ephoto->thumbs, o);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, ephoto);
|
||||
evas_object_smart_callback_add(o, "generate,error", _load_error, path);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -517,12 +565,12 @@ ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
|||
Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO;
|
||||
const char *group = NULL;
|
||||
const char *ext = strrchr(path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "jpg") == 0) ||
|
||||
(strcasecmp(ext, "jpeg") == 0))
|
||||
format = ETHUMB_THUMB_JPEG; /* faster! */
|
||||
if ((strcasecmp(ext, "jpg") == 0) || (strcasecmp(ext, "jpeg") == 0))
|
||||
format = ETHUMB_THUMB_JPEG;
|
||||
else if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
if (edje_file_group_exists(path, "e/desktop/background"))
|
||||
|
@ -530,6 +578,7 @@ ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
|||
else
|
||||
{
|
||||
Eina_List *g = edje_file_collection_list(path);
|
||||
|
||||
group = eina_list_data_get(g);
|
||||
edje_file_collection_list_free(g);
|
||||
}
|
||||
|
@ -547,12 +596,12 @@ ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
|||
}
|
||||
|
||||
Ephoto_Entry *
|
||||
ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label, Eina_File_Type type)
|
||||
ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label,
|
||||
Eina_File_Type type)
|
||||
{
|
||||
Ephoto_Entry *entry;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||
|
||||
entry = calloc(1, sizeof(Ephoto_Entry));
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(entry, NULL);
|
||||
entry->ephoto = ephoto;
|
||||
entry->path = eina_stringshare_add(path);
|
||||
entry->basename = ecore_file_file_get(entry->path);
|
||||
|
@ -574,38 +623,36 @@ ephoto_entry_free(Ephoto_Entry *entry)
|
|||
fl->cb((void *) fl->data, entry);
|
||||
free(fl);
|
||||
}
|
||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
||||
eina_stringshare_del(entry->path);
|
||||
eina_stringshare_del(entry->label);
|
||||
free(entry);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data)
|
||||
ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb) (void *data,
|
||||
const Ephoto_Entry *entry), const void *data)
|
||||
{
|
||||
Ephoto_Entry_Free_Listener *fl;
|
||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cb);
|
||||
|
||||
fl = malloc(sizeof(Ephoto_Entry_Free_Listener));
|
||||
EINA_SAFETY_ON_NULL_RETURN(fl);
|
||||
fl->cb = cb;
|
||||
fl->data = data;
|
||||
entry->free_listeners = eina_list_append(entry->free_listeners, fl);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data)
|
||||
ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb) (void *data,
|
||||
const Ephoto_Entry *entry), const void *data)
|
||||
{
|
||||
Eina_List *l;
|
||||
Ephoto_Entry_Free_Listener *fl;
|
||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cb);
|
||||
|
||||
EINA_LIST_FOREACH(entry->free_listeners, l, fl)
|
||||
{
|
||||
if ((fl->cb == cb) && (fl->data == data))
|
||||
{
|
||||
entry->free_listeners = eina_list_remove_list
|
||||
(entry->free_listeners, l);
|
||||
entry->free_listeners =
|
||||
eina_list_remove_list(entry->free_listeners, l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -615,6 +662,7 @@ void
|
|||
ephoto_entries_free(Ephoto *ephoto)
|
||||
{
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
EINA_LIST_FREE(ephoto->entries, entry) ephoto_entry_free(entry);
|
||||
EINA_LIST_FREE(ephoto->direntries, entry) ephoto_entry_free(entry);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,6 +8,7 @@ struct _Ephoto_Slideshow
|
|||
Evas_Object *slideshow;
|
||||
Evas_Object *notify;
|
||||
Evas_Object *bar;
|
||||
Evas_Object *event;
|
||||
Elm_Widget_Item *pause;
|
||||
Elm_Widget_Item *pause_after;
|
||||
Elm_Widget_Item *fullscreen;
|
||||
|
@ -17,44 +18,23 @@ struct _Ephoto_Slideshow
|
|||
};
|
||||
|
||||
static void
|
||||
_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
const char *k = ev->keyname;
|
||||
|
||||
if (!strcmp(k, "Escape"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
Elm_Object_Item *slideshow_item;
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
slideshow_item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (slideshow_item) entry = elm_object_item_data_get(slideshow_item);
|
||||
else entry = ss->entry;
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
evas_object_hide(ss->notify);
|
||||
ss->playing = 0;
|
||||
evas_object_freeze_events_set(ss->slideshow, EINA_TRUE);
|
||||
}
|
||||
else if (!strcmp(k, "F11"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Elm_Object_Item *slideshow_item;
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
slideshow_item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (slideshow_item) entry = elm_object_item_data_get(slideshow_item);
|
||||
else entry = ss->entry;
|
||||
if (slideshow_item)
|
||||
entry = elm_object_item_data_get(slideshow_item);
|
||||
else
|
||||
entry = ss->entry;
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_del(ss->event);
|
||||
ss->event = NULL;
|
||||
}
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
evas_object_hide(ss->notify);
|
||||
|
@ -66,20 +46,24 @@ static void
|
|||
_entry_free(void *data, const Ephoto_Entry *entry EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
ss->entry = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_slideshow_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_slideshow_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
if (ss->entry)
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
free(ss);
|
||||
}
|
||||
|
||||
static void
|
||||
_notify_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_notify_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_show(data);
|
||||
}
|
||||
|
@ -92,8 +76,15 @@ _back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
Ephoto_Entry *entry;
|
||||
|
||||
slideshow_item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (slideshow_item) entry = elm_object_item_data_get(slideshow_item);
|
||||
else entry = ss->entry;
|
||||
if (slideshow_item)
|
||||
entry = elm_object_item_data_get(slideshow_item);
|
||||
else
|
||||
entry = ss->entry;
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_del(ss->event);
|
||||
ss->event = NULL;
|
||||
}
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
evas_object_hide(ss->notify);
|
||||
|
@ -114,7 +105,7 @@ _next(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
}
|
||||
|
||||
static void
|
||||
_pause(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_pause(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
|
@ -123,21 +114,25 @@ _pause(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EI
|
|||
if (ss->playing)
|
||||
{
|
||||
elm_slideshow_timeout_set(ss->slideshow, 0.0);
|
||||
ss->pause = elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
ss->pause =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-start", _("Play"), _pause, ss);
|
||||
ss->playing = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_slideshow_timeout_set(ss->slideshow, ss->ephoto->config->slideshow_timeout);
|
||||
ss->pause = elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
elm_slideshow_timeout_set(ss->slideshow,
|
||||
ss->ephoto->config->slideshow_timeout);
|
||||
ss->pause =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-pause", _("Pause"), _pause, ss);
|
||||
ss->playing = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_previous(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_previous(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_slideshow_previous(data);
|
||||
}
|
||||
|
@ -151,7 +146,8 @@ _last(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
}
|
||||
|
||||
static void
|
||||
_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_fullscreen(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
|
@ -159,39 +155,200 @@ _fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
|
||||
if (elm_win_fullscreen_get(ss->ephoto->win))
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-restore", _("Normal"), _fullscreen, ss);
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_settings(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_general_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
ephoto_config_general(ss->ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_slideshow_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
ephoto_config_slideshow(ss->ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_about_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
ephoto_config_about(ss->ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_close_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
evas_object_del(popup);
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_freeze_events_set(ss->event, EINA_FALSE);
|
||||
elm_object_focus_set(ss->event, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Object *popup, *list, *button, *ic;
|
||||
|
||||
if (ss->event)
|
||||
evas_object_freeze_events_set(ss->event, EINA_TRUE);
|
||||
|
||||
popup = elm_popup_add(ss->ephoto->win);
|
||||
elm_popup_scrollable_set(popup, EINA_TRUE);
|
||||
elm_object_part_text_set(popup, "title,text", _("Settings Panel"));
|
||||
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
|
||||
|
||||
list = elm_list_add(popup);
|
||||
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_list_mode_set(list, ELM_LIST_EXPAND);
|
||||
|
||||
ic = elm_icon_add(list);
|
||||
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
elm_icon_standard_set(ic, "preferences-system");
|
||||
evas_object_show(ic);
|
||||
elm_list_item_append(list, _("General Settings"), ic, NULL,
|
||||
_general_settings, popup);
|
||||
|
||||
ic = elm_icon_add(list);
|
||||
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
elm_icon_standard_set(ic, "media-playback-start");
|
||||
evas_object_show(ic);
|
||||
elm_list_item_append(list, _("Slideshow Settings"), ic, NULL,
|
||||
_slideshow_settings, popup);
|
||||
ic = elm_icon_add(list);
|
||||
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
elm_icon_standard_set(ic, "help-about");
|
||||
evas_object_show(ic);
|
||||
elm_list_item_append(list, _("About Ephoto"), ic, NULL, _about_settings,
|
||||
popup);
|
||||
|
||||
ic = elm_icon_add(popup);
|
||||
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
elm_icon_standard_set(ic, "window-close");
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, _("Close"));
|
||||
elm_object_part_content_set(button, "icon", ic);
|
||||
evas_object_smart_callback_add(button, "clicked", _close_settings, popup);
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_show(button);
|
||||
|
||||
elm_list_go(list);
|
||||
evas_object_show(list);
|
||||
|
||||
evas_object_data_set(popup, "slideshow", ss);
|
||||
elm_object_content_set(popup, list);
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_notify_timeout_set(data, 0.0);
|
||||
evas_object_show(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_notify_timeout_set(data, 3.0);
|
||||
}
|
||||
|
||||
static void
|
||||
_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
const char *k = ev->keyname;
|
||||
|
||||
if (!strcmp(k, "Escape") || !strcmp(k, "F5"))
|
||||
{
|
||||
_back(ss, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "F1"))
|
||||
{
|
||||
_settings(ss, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "F11"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
|
||||
elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
|
||||
}
|
||||
else if (!strcmp(k, "space"))
|
||||
{
|
||||
_pause(ss, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "Home"))
|
||||
{
|
||||
_first(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "End"))
|
||||
{
|
||||
_last(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "Left"))
|
||||
{
|
||||
_previous(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "Right"))
|
||||
{
|
||||
_next(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_main_focused(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_data EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
if (ss->ephoto->state == EPHOTO_STATE_SLIDESHOW)
|
||||
{
|
||||
if (ss->event)
|
||||
elm_object_focus_set(ss->event, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
||||
{
|
||||
|
@ -205,26 +362,30 @@ ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
ss->ephoto = ephoto;
|
||||
ss->slideshow = slideshow;
|
||||
ss->playing = 0;
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_DEL, _slideshow_del, ss);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_KEY_DOWN, _key_down, ss);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, ss);
|
||||
evas_object_data_set(slideshow, "slideshow", ss);
|
||||
ss->event = NULL;
|
||||
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_DEL, _slideshow_del,
|
||||
ss);
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_mouse_down, ss);
|
||||
evas_object_event_callback_add(ss->ephoto->win, EVAS_CALLBACK_FOCUS_IN,
|
||||
_main_focused, ss);
|
||||
evas_object_data_set(slideshow, "slideshow", ss);
|
||||
elm_object_tree_focus_allow_set(slideshow, EINA_FALSE);
|
||||
elm_slideshow_loop_set(slideshow, EINA_TRUE);
|
||||
elm_slideshow_layout_set(slideshow, "fullscreen");
|
||||
evas_object_size_hint_weight_set
|
||||
(slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(slideshow, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(slideshow, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
ss->notify = elm_notify_add(ephoto->win);
|
||||
elm_notify_align_set(ss->notify, 0.5, 1.0);
|
||||
evas_object_size_hint_weight_set(ss->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(ss->notify, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
elm_notify_timeout_set(ss->notify, 3.0);
|
||||
elm_win_resize_object_add(ephoto->win, ss->notify);
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE, _notify_show, ss->notify);
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
|
||||
_notify_show, ss->notify);
|
||||
elm_object_tree_focus_allow_set(ss->notify, EINA_FALSE);
|
||||
|
||||
ss->bar = elm_toolbar_add(ss->notify);
|
||||
elm_toolbar_horizontal_set(ss->bar, EINA_TRUE);
|
||||
|
@ -235,17 +396,30 @@ ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
evas_object_size_hint_weight_set(ss->bar, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(ss->bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_content_set(ss->notify, ss->bar);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_IN, _mouse_in, ss->notify);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_OUT, _mouse_out, ss->notify);
|
||||
elm_object_tree_focus_allow_set(ss->bar, EINA_FALSE);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
|
||||
ss->notify);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
|
||||
ss->notify);
|
||||
|
||||
elm_toolbar_item_append(ss->bar, "window-close", _("Back"), _back, ss);
|
||||
elm_toolbar_item_append(ss->bar, "go-first", _("First"), _first, ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-previous", _("Previous"), _previous, ss->slideshow);
|
||||
ss->pause = elm_toolbar_item_append(ss->bar, "media-playback-start", _("Play"), _pause, ss);
|
||||
ss->pause_after = elm_toolbar_item_append(ss->bar, "go-next", _("Next"), _next, ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-first", _("First"), _first,
|
||||
ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-previous", _("Previous"), _previous,
|
||||
ss->slideshow);
|
||||
ss->pause =
|
||||
elm_toolbar_item_append(ss->bar, "media-playback-start", _("Play"),
|
||||
_pause, ss);
|
||||
ss->pause_after =
|
||||
elm_toolbar_item_append(ss->bar, "go-next", _("Next"), _next,
|
||||
ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-last", _("Last"), _last, ss->slideshow);
|
||||
ss->fullscreen = elm_toolbar_item_append(ss->bar, "view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
ss->fullscreen_after = elm_toolbar_item_append(ss->bar, "preferences-system", _("Settings"), _settings, ss);
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_append(ss->bar, "view-fullscreen", _("Fullscreen"),
|
||||
_fullscreen, ss);
|
||||
ss->fullscreen_after =
|
||||
elm_toolbar_item_append(ss->bar, "preferences-system", _("Settings"),
|
||||
_settings, ss);
|
||||
|
||||
evas_object_show(ss->bar);
|
||||
|
||||
|
@ -258,9 +432,12 @@ ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void _image_shown(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
||||
static void
|
||||
_image_shown(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_data EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Entry *entry = data;
|
||||
|
||||
ephoto_title_set(entry->ephoto, entry->basename);
|
||||
}
|
||||
|
||||
|
@ -271,6 +448,7 @@ _slideshow_item_get(void *data, Evas_Object *obj)
|
|||
|
||||
const char *group = NULL;
|
||||
const char *ext = strrchr(entry->path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
|
@ -281,20 +459,24 @@ _slideshow_item_get(void *data, Evas_Object *obj)
|
|||
else
|
||||
{
|
||||
Eina_List *g = edje_file_collection_list(entry->path);
|
||||
|
||||
group = eina_list_data_get(g);
|
||||
edje_file_collection_list_free(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
Evas_Object *image = elm_image_add(obj);
|
||||
|
||||
elm_image_file_set(image, entry->path, group);
|
||||
elm_object_style_set(image, "shadow");
|
||||
evas_object_event_callback_add(image, EVAS_CALLBACK_SHOW, _image_shown, entry);
|
||||
evas_object_event_callback_add(image, EVAS_CALLBACK_SHOW, _image_shown,
|
||||
entry);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static const Elm_Slideshow_Item_Class _item_cls = {{_slideshow_item_get, NULL}};
|
||||
static const Elm_Slideshow_Item_Class _item_cls =
|
||||
{ {_slideshow_item_get, NULL} };
|
||||
|
||||
void
|
||||
ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
||||
|
@ -302,7 +484,6 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
|||
Ephoto_Slideshow *ss = evas_object_data_get(obj, "slideshow");
|
||||
Ephoto_Entry *itr;
|
||||
const Eina_List *l;
|
||||
EINA_SAFETY_ON_NULL_RETURN(ss);
|
||||
|
||||
if (ss->entry)
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
|
@ -313,17 +494,21 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
|||
ephoto_entry_free_listener_add(entry, _entry_free, ss);
|
||||
|
||||
elm_slideshow_loop_set(ss->slideshow, EINA_TRUE);
|
||||
elm_slideshow_transition_set(ss->slideshow, ss->ephoto->config->slideshow_transition);
|
||||
elm_slideshow_timeout_set(ss->slideshow, ss->ephoto->config->slideshow_timeout);
|
||||
elm_slideshow_transition_set(ss->slideshow,
|
||||
ss->ephoto->config->slideshow_transition);
|
||||
elm_slideshow_timeout_set(ss->slideshow,
|
||||
ss->ephoto->config->slideshow_timeout);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
if (!entry) return;
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
evas_object_freeze_events_set(ss->slideshow, EINA_FALSE);
|
||||
|
||||
if (ss->pause)
|
||||
{
|
||||
elm_object_item_del(ss->pause);
|
||||
ss->pause = elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
ss->pause =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-pause", _("Pause"), _pause, ss);
|
||||
ss->playing = 1;
|
||||
}
|
||||
|
@ -332,12 +517,14 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
|||
elm_object_item_del(ss->fullscreen);
|
||||
if (elm_win_fullscreen_get(ss->ephoto->win))
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-restore", _("Normal"), _fullscreen, ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +532,23 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
|||
EINA_LIST_FOREACH(ss->ephoto->entries, l, itr)
|
||||
{
|
||||
Elm_Object_Item *slideshow_item;
|
||||
|
||||
slideshow_item = elm_slideshow_item_add(ss->slideshow, &_item_cls, itr);
|
||||
if (itr == entry) elm_slideshow_item_show(slideshow_item);
|
||||
if (itr == entry)
|
||||
elm_slideshow_item_show(slideshow_item);
|
||||
}
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_del(ss->event);
|
||||
ss->event = NULL;
|
||||
}
|
||||
ss->event = evas_object_rectangle_add(ss->ephoto->win);
|
||||
evas_object_smart_member_add(ss->event, ss->ephoto->win);
|
||||
evas_object_color_set(ss->event, 0, 0, 0, 0);
|
||||
evas_object_repeat_events_set(ss->event, EINA_TRUE);
|
||||
evas_object_show(ss->event);
|
||||
evas_object_event_callback_add(ss->event, EVAS_CALLBACK_KEY_DOWN, _key_down,
|
||||
ss);
|
||||
evas_object_raise(ss->event);
|
||||
elm_object_focus_set(ss->event, EINA_TRUE);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue