diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h
index 54ce1de..29b5a95 100644
--- a/src/bin/ephoto.h
+++ b/src/bin/ephoto.h
@@ -76,9 +76,9 @@ void ephoto_single_browser_path_pending_set(Evas_Object *obj,
void ephoto_single_browser_path_pending_unset(Evas_Object *obj);
void ephoto_single_browser_path_created(Evas_Object *obj, Ephoto_Entry *entry);
void ephoto_single_browser_image_data_update(Evas_Object *main,
- Evas_Object *image, unsigned int *image_data, int w, int h);
+ Evas_Object *image, unsigned int *image_data, Evas_Coord w, Evas_Coord h);
void ephoto_single_browser_image_data_done(Evas_Object *main,
- unsigned int *image_data, int w, int h);
+ unsigned int *image_data, Evas_Coord w, Evas_Coord h);
void ephoto_single_browser_cancel_editing(Evas_Object *main);
/* smart callbacks called: "back" - the user wants to go back to the previous
* screen. */
@@ -105,7 +105,7 @@ int e_thumb_init(void);
int e_thumb_shutdown(void);
Evas_Object *e_thumb_icon_add(Evas *evas);
void e_thumb_icon_file_set(Evas_Object *obj, const char *file, const char *key);
-void e_thumb_icon_size_set(Evas_Object *obj, int w, int h);
+void e_thumb_icon_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
void e_thumb_icon_begin(Evas_Object *obj);
void e_thumb_icon_end(Evas_Object *obj);
void e_thumb_icon_rethumb(Evas_Object *obj);
@@ -197,6 +197,7 @@ struct _Ephoto_Config
int window_height;
Eina_Bool fsel_hide;
Eina_Bool tool_hide;
+ double lpane_size;
const char *open;
Eina_Bool prompts;
Eina_Bool drop;
diff --git a/src/bin/ephoto_bcg.c b/src/bin/ephoto_bcg.c
index 3204cf5..a345f7b 100644
--- a/src/bin/ephoto_bcg.c
+++ b/src/bin/ephoto_bcg.c
@@ -14,7 +14,7 @@ struct _Ephoto_BCG
int contrast;
int brightness;
double gamma;
- int w, h;
+ Evas_Coord w, h;
unsigned int *original_im_data;
};
@@ -52,7 +52,7 @@ _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;
+ Evas_Coord x, y;
int a, r, g, b, bb, gg, rr;
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
@@ -103,8 +103,8 @@ _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, top, bottom;
- int a, r, g, b, bb, gg, rr;
+ Evas_Coord x, y;
+ int top, bottom, a, r, g, b, bb, gg, rr;
float factor;
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
@@ -158,7 +158,7 @@ _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;
+ Evas_Coord x, y;
int a, r, g, b, bb, gg, rr;
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
@@ -272,7 +272,7 @@ _bcg_apply(void *data, int type EINA_UNUSED,
{
Ephoto_BCG *ebcg = data;
unsigned int *image_data;
- int w, h;
+ Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(ebcg->image),
diff --git a/src/bin/ephoto_color.c b/src/bin/ephoto_color.c
index 282365f..cc5d384 100644
--- a/src/bin/ephoto_color.c
+++ b/src/bin/ephoto_color.c
@@ -14,7 +14,7 @@ struct _Ephoto_Color
int blue;
int green;
int red;
- int w, h;
+ Evas_Coord w, h;
unsigned int *original_im_data;
};
@@ -51,7 +51,7 @@ 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;
+ Evas_Coord x, y;
int a, r, g, b, rr;
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
@@ -100,7 +100,7 @@ _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;
+ Evas_Coord x, y;
int a, r, g, b, gg;
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
@@ -149,7 +149,7 @@ _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;
+ Evas_Coord x, y;
int a, r, g, b, bb;
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
@@ -257,7 +257,7 @@ _color_apply(void *data, int type EINA_UNUSED,
{
Ephoto_Color *eco = data;
unsigned int *image_data;
- int w, h;
+ Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(eco->image),
diff --git a/src/bin/ephoto_config.c b/src/bin/ephoto_config.c
index 1873e06..bba3c53 100644
--- a/src/bin/ephoto_config.c
+++ b/src/bin/ephoto_config.c
@@ -1,83 +1,12 @@
#include "ephoto.h"
-#define CONFIG_VERSION 14
+#define CONFIG_VERSION 15
static int _ephoto_config_load(Ephoto *ephoto);
static Eina_Bool _ephoto_on_config_save(void *data);
static Eet_Data_Descriptor *edd = NULL;
-Eina_Bool
-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)))
- {
- return EINA_FALSE;
- }
-
- if (!edd)
- edd = eet_data_descriptor_stream_new(&eddc);
-
-#undef T
-#undef D
-#define T Ephoto_Config
-#define D edd
-#define C_VAL(edd, type, member, dtype) \
- EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
-
- C_VAL(D, T, config_version, EET_T_INT);
- C_VAL(D, T, thumb_size, EET_T_INT);
- C_VAL(D, T, thumb_gen_size, EET_T_INT);
- C_VAL(D, T, directory, EET_T_STRING);
- C_VAL(D, T, slideshow_timeout, EET_T_DOUBLE);
- C_VAL(D, T, slideshow_transition, EET_T_STRING);
- C_VAL(D, T, window_width, EET_T_INT);
- C_VAL(D, T, window_height, EET_T_INT);
- 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:
- /* Start a new config */
- ephoto->config->config_version = CONFIG_VERSION;
- ephoto->config->slideshow_timeout = 4.0;
- ephoto->config->slideshow_transition = eina_stringshare_add("fade");
- ephoto->config->window_width = 900;
- 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;
- }
-
- ephoto_config_save(ephoto);
- return EINA_TRUE;
-}
-
-void
-ephoto_config_save(Ephoto *ephoto)
-{
- _ephoto_on_config_save(ephoto);
-}
-
-void
-ephoto_config_free(Ephoto *ephoto)
-{
- free(ephoto->config);
- ephoto->config = NULL;
-}
-
static void
_config_close_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -137,7 +66,7 @@ _open_hv_select(void *data, Evas_Object *obj, void *event_info)
}
static Evas_Object *
-_ephoto_config_general(Ephoto *ephoto, Evas_Object *parent)
+_config_general(Ephoto *ephoto, Evas_Object *parent)
{
Evas_Object *box, *table, *check, *hoversel, *entry;
@@ -232,7 +161,7 @@ _spinner_changed(void *data EINA_UNUSED, Evas_Object *obj,
}
static Evas_Object *
-_ephoto_config_slideshow(Ephoto *ephoto, Evas_Object *parent)
+_config_slideshow(Ephoto *ephoto, Evas_Object *parent)
{
Evas_Object *box, *table, *label, *spinner, *hoversel;
const Eina_List *l;
@@ -350,7 +279,7 @@ _link_anchor(void *data, Evas_Object *obj, void *event_info)
}
static Evas_Object *
-_ephoto_config_bindings(Evas_Object *parent)
+_config_bindings(Evas_Object *parent)
{
Evas_Object *box, *scroller, *entry;
Eina_Strbuf *sbuf = eina_strbuf_new();
@@ -424,7 +353,7 @@ _ephoto_config_bindings(Evas_Object *parent)
}
static Evas_Object *
-_ephoto_config_about(Evas_Object *parent)
+_config_about(Evas_Object *parent)
{
Evas_Object *box, *entry, *img, *lbl;
Eina_Strbuf *sbuf = eina_strbuf_new();
@@ -546,6 +475,71 @@ _segment_changed(void *data EINA_UNUSED, Evas_Object *o, void *event)
evas_object_show(page);
}
+static int
+_ephoto_config_load(Ephoto *ephoto)
+{
+ Eet_File *ef;
+ char buf[4096], buf2[4096];
+
+ snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME"));
+ ecore_file_mkpath(buf2);
+ snprintf(buf, sizeof(buf), "%s/ephoto.cfg", buf2);
+
+ ef = eet_open(buf, EET_FILE_MODE_READ);
+ if (!ef)
+ {
+ ephoto_config_free(ephoto);
+ ephoto->config = calloc(1, sizeof(Ephoto_Config));
+ return 0;
+ }
+
+ ephoto->config = eet_data_read(ef, edd, "config");
+ eet_close(ef);
+
+ if (!ephoto->config || ephoto->config->config_version > CONFIG_VERSION)
+ {
+ ephoto_config_free(ephoto);
+ ephoto->config = calloc(1, sizeof(Ephoto_Config));
+ return 0;
+ }
+
+ if (ephoto->config->config_version < CONFIG_VERSION)
+ {
+ ecore_file_unlink(buf);
+ ephoto_config_free(ephoto);
+ ephoto->config = calloc(1, sizeof(Ephoto_Config));
+ return 0;
+ }
+ return 1;
+}
+
+static Eina_Bool
+_ephoto_on_config_save(void *data)
+{
+ Ephoto *ephoto = data;
+ Eet_File *ef;
+ char buf[4096], buf2[4096];
+
+ snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME"));
+ snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
+
+ ef = eet_open(buf2, EET_FILE_MODE_WRITE);
+ if (!ef)
+ goto save_end;
+
+ eet_data_write(ef, edd, "config", ephoto->config, 1);
+ if (eet_close(ef))
+ goto save_end;
+
+ if (!ecore_file_mv(buf2, buf))
+ goto save_end;
+
+ save_end:
+ ecore_file_unlink(buf2);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
void
ephoto_config_main(Ephoto *ephoto)
{
@@ -563,13 +557,13 @@ ephoto_config_main(Ephoto *ephoto)
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
- gen = _ephoto_config_general(ephoto, table);
+ gen = _config_general(ephoto, table);
elm_table_pack(table, gen, 0, 2, 1, 1);
- slide = _ephoto_config_slideshow(ephoto, table);
+ slide = _config_slideshow(ephoto, table);
elm_table_pack(table, slide, 0, 2, 1, 1);
- kb = _ephoto_config_bindings(table);
+ kb = _config_bindings(table);
elm_table_pack(table, kb, 0, 2, 1, 1);
- about = _ephoto_config_about(table);
+ about = _config_about(table);
elm_table_pack(table, about, 0, 2, 1, 1);
segment = elm_segment_control_add(table);
@@ -661,67 +655,76 @@ ephoto_config_main(Ephoto *ephoto)
evas_object_show(popup);
}
-static int
-_ephoto_config_load(Ephoto *ephoto)
+void
+ephoto_config_save(Ephoto *ephoto)
{
- Eet_File *ef;
- char buf[4096], buf2[4096];
-
- snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME"));
- ecore_file_mkpath(buf2);
- snprintf(buf, sizeof(buf), "%s/ephoto.cfg", buf2);
-
- ef = eet_open(buf, EET_FILE_MODE_READ);
- if (!ef)
- {
- ephoto_config_free(ephoto);
- ephoto->config = calloc(1, sizeof(Ephoto_Config));
- return 0;
- }
-
- ephoto->config = eet_data_read(ef, edd, "config");
- eet_close(ef);
-
- if (!ephoto->config || ephoto->config->config_version > CONFIG_VERSION)
- {
- ephoto_config_free(ephoto);
- ephoto->config = calloc(1, sizeof(Ephoto_Config));
- return 0;
- }
-
- if (ephoto->config->config_version < CONFIG_VERSION)
- {
- ecore_file_unlink(buf);
- ephoto_config_free(ephoto);
- ephoto->config = calloc(1, sizeof(Ephoto_Config));
- return 0;
- }
- return 1;
+ _ephoto_on_config_save(ephoto);
}
-static Eina_Bool
-_ephoto_on_config_save(void *data)
+void
+ephoto_config_free(Ephoto *ephoto)
{
- Ephoto *ephoto = data;
- Eet_File *ef;
- char buf[4096], buf2[4096];
-
- snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME"));
- snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
-
- ef = eet_open(buf2, EET_FILE_MODE_WRITE);
- if (!ef)
- goto save_end;
-
- eet_data_write(ef, edd, "config", ephoto->config, 1);
- if (eet_close(ef))
- goto save_end;
-
- if (!ecore_file_mv(buf2, buf))
- goto save_end;
-
- save_end:
- ecore_file_unlink(buf2);
-
- return ECORE_CALLBACK_CANCEL;
+ free(ephoto->config);
+ ephoto->config = NULL;
}
+
+Eina_Bool
+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)))
+ {
+ return EINA_FALSE;
+ }
+
+ if (!edd)
+ edd = eet_data_descriptor_stream_new(&eddc);
+
+#undef T
+#undef D
+#define T Ephoto_Config
+#define D edd
+#define C_VAL(edd, type, member, dtype) \
+ EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
+
+ C_VAL(D, T, config_version, EET_T_INT);
+ C_VAL(D, T, thumb_size, EET_T_INT);
+ C_VAL(D, T, thumb_gen_size, EET_T_INT);
+ C_VAL(D, T, directory, EET_T_STRING);
+ C_VAL(D, T, slideshow_timeout, EET_T_DOUBLE);
+ C_VAL(D, T, slideshow_transition, EET_T_STRING);
+ C_VAL(D, T, window_width, EET_T_INT);
+ C_VAL(D, T, window_height, EET_T_INT);
+ C_VAL(D, T, fsel_hide, EET_T_INT);
+ C_VAL(D, T, tool_hide, EET_T_INT);
+ C_VAL(D, T, lpane_size, EET_T_DOUBLE);
+ 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:
+ /* Start a new config */
+ ephoto->config->config_version = CONFIG_VERSION;
+ ephoto->config->slideshow_timeout = 4.0;
+ ephoto->config->slideshow_transition = eina_stringshare_add("fade");
+ ephoto->config->window_width = 900;
+ ephoto->config->window_height = 600;
+ ephoto->config->fsel_hide = 0;
+ ephoto->config->tool_hide = 0;
+ ephoto->config->lpane_size = .15;
+ ephoto->config->open = eina_stringshare_add(getenv("HOME"));
+ ephoto->config->prompts = 1;
+ ephoto->config->drop = 0;
+ break;
+
+ default:
+ return EINA_TRUE;
+ }
+
+ ephoto_config_save(ephoto);
+ return EINA_TRUE;
+}
+
diff --git a/src/bin/ephoto_cropper.c b/src/bin/ephoto_cropper.c
index 61f0634..9f43f55 100644
--- a/src/bin/ephoto_cropper.c
+++ b/src/bin/ephoto_cropper.c
@@ -14,10 +14,10 @@ struct _Ephoto_Cropper
Evas_Object *cropw;
Evas_Object *croph;
Eina_List *handlers;
- int startx;
- int starty;
- int offsetx;
- int offsety;
+ Evas_Coord startx;
+ Evas_Coord starty;
+ Evas_Coord offsetx;
+ Evas_Coord offsety;
Eina_Bool resizing;
};
@@ -27,7 +27,7 @@ _calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
- int w, h, cw, ch, iw, ih, nw, nh;
+ Evas_Coord w, h, cw, ch, iw, ih, nw, nh;
double scalew, scaleh;
edje_object_part_geometry_get(elm_layout_edje_get(ec->layout),
@@ -60,7 +60,7 @@ _cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msgl, *msgr;
- int mw, cx, cw, nw, lx, lw, iw, left, right;
+ Evas_Coord mw, cx, cw, nw, lx, lw, iw, left, right;
double scalew;
mw = elm_slider_value_get(ec->cropw);
@@ -112,7 +112,7 @@ _cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msgt, *msgb;
- int mh, ch, cy, nh, lh, ly, ih, top, bottom;
+ Evas_Coord mh, ch, cy, nh, lh, ly, ih, top, bottom;
double scaleh;
mh = elm_slider_value_get(ec->croph);
@@ -180,8 +180,8 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED,
Ephoto_Cropper *ec = data;
Evas_Object *edje = elm_layout_edje_get(ec->layout);
- int x, y, w, h, cx, cy, cw, ch, iw, ih;
- int nx, ny, nw, nh, i, j, tmpx, tmpy, ind, index;
+ Evas_Coord x, y, w, h, cx, cy, cw, ch, iw, ih;
+ Evas_Coord nx, ny, nw, nh, i, j, tmpx, tmpy, ind, index;
double scalex, scaley, scalew, scaleh;
unsigned int *idata, *idata_new;
@@ -250,7 +250,7 @@ _cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
- int mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
+ Evas_Coord mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
@@ -305,7 +305,7 @@ _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;
+ Evas_Coord mx, my, cx, cy;
ec->resizing = 1;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
@@ -327,7 +327,7 @@ _cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
- int mx, cx, cy, cw, ch, nx, lx, lw;
+ Evas_Coord mx, cx, cy, cw, ch, nx, lx, lw;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, 0);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
@@ -371,7 +371,7 @@ _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;
+ Evas_Coord mx, my, cx, cy;
ec->resizing = 1;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
@@ -393,7 +393,7 @@ _cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
- int my, cx, cy, cw, ch, ny, ly, lh;
+ Evas_Coord my, cx, cy, cw, ch, ny, ly, lh;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), 0, &my);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
@@ -437,7 +437,7 @@ _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;
+ Evas_Coord mx, my, cx, cy;
ec->resizing = 1;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
@@ -462,7 +462,7 @@ _cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
if (!ec->resizing)
{
Edje_Message_Int_Set *msg;
- int mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
+ Evas_Coord mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper),
&mx, &my);
@@ -510,7 +510,7 @@ _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;
+ Evas_Coord mx, my, cx, cy;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
evas_object_geometry_get(ec->cropper, &cx, &cy, 0, 0);
@@ -532,12 +532,12 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
- int sx, sy, sw, sh, ix, iy, iw, ih, diffw, diffh;
+ Evas_Coord sx, sy, sw, sh, ix, iy, iw, ih, diffw, diffh;
evas_object_geometry_get(ec->layout, &sx, &sy, &sw, &sh);
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
- int nw, nh;
+ Evas_Coord nw, nh;
if (sw > sh)
{
@@ -545,7 +545,7 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
nh = ih * ((double) sw / (double) iw);
if (nh > sh)
{
- int onw, onh;
+ Evas_Coord onw, onh;
onw = nw;
onh = nh;
@@ -559,7 +559,7 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
nw = iw * ((double) sh / (double) ih);
if (nw > sw)
{
- int onw, onh;
+ Evas_Coord onw, onh;
onw = nw;
onh = nh;
@@ -631,7 +631,7 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
Evas_Object *image_parent, Evas_Object *image)
{
Ephoto_Cropper *ec;
- int w, h;
+ Evas_Coord w, h;
EINA_SAFETY_ON_NULL_GOTO(image, error);
diff --git a/src/bin/ephoto_filters.c b/src/bin/ephoto_filters.c
index b5416cf..5fa5512 100644
--- a/src/bin/ephoto_filters.c
+++ b/src/bin/ephoto_filters.c
@@ -34,7 +34,7 @@ ephoto_filter_blur(Evas_Object *main, Evas_Object *image)
{
unsigned int *im_data, *im_data_new, *p1, *p2;
int rad = 3;
- int x, y, w, h, mx, my, mw, mh, mt, xx, yy;
+ Evas_Coord x, y, w, h, mx, my, mw, mh, mt, xx, yy;
int a, r, g, b;
int *as, *rs, *gs, *bs;
@@ -128,7 +128,8 @@ void
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 a, r, g, b;
+ Evas_Coord x, y, w, h;
im_data =
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
@@ -183,7 +184,8 @@ void
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;
+ int gray, i, r, g, b, a;
+ Evas_Coord w, h;
im_data =
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
@@ -213,7 +215,8 @@ void
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;
+ int i, r, rr, g, gg, b, bb, a;
+ Evas_Coord w, h;
im_data =
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
@@ -247,7 +250,8 @@ void
ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image)
{
unsigned int *im_data, *im_data_new, *p1, *p2;
- int x, y, w, h, i, hist[256], cdf[256];
+ Evas_Coord x, y, w, h;
+ int i, hist[256], cdf[256];
int a, r, g, b, bb, gg, rr, norm, total;
float hh, s, v, nv, sum;
diff --git a/src/bin/ephoto_hsv.c b/src/bin/ephoto_hsv.c
index cfa7a02..577137d 100644
--- a/src/bin/ephoto_hsv.c
+++ b/src/bin/ephoto_hsv.c
@@ -14,7 +14,7 @@ struct _Ephoto_HSV
double hue;
double saturation;
double value;
- int w, h;
+ Evas_Coord w, h;
unsigned int *original_im_data;
};
@@ -51,7 +51,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;
+ Evas_Coord x, y;
int a, r, g, b, bb, gg, rr;
float hh, s, v;
@@ -107,7 +107,7 @@ _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;
+ Evas_Coord x, y;
int a, r, g, b, bb, gg, rr;
float hh, s, v;
@@ -163,7 +163,7 @@ _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;
+ Evas_Coord x, y;
int a, r, g, b, bb, gg, rr;
float hh, s, v;
@@ -279,7 +279,7 @@ _hsv_apply(void *data, int type EINA_UNUSED,
{
Ephoto_HSV *ehsv = data;
unsigned int *image_data;
- int w, h;
+ Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(ehsv->image),
diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c
index 6241281..60f711f 100644
--- a/src/bin/ephoto_main.c
+++ b/src/bin/ephoto_main.c
@@ -193,7 +193,7 @@ _resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto *ephoto = data;
- int w, h;
+ Evas_Coord w, h;
evas_object_geometry_get(ephoto->win, 0, 0, &w, &h);
if (w && h)
@@ -635,6 +635,9 @@ ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
ed->dirs_only = dirs_only;
ed->thumbs_only = thumbs_only;
+ if (!ecore_file_can_read(path))
+ return;
+
ephoto_title_set(ephoto, NULL);
eina_stringshare_replace(&ephoto->config->directory,
ecore_file_realpath(path));
diff --git a/src/bin/ephoto_red_eye.c b/src/bin/ephoto_red_eye.c
index b1215df..db171b9 100644
--- a/src/bin/ephoto_red_eye.c
+++ b/src/bin/ephoto_red_eye.c
@@ -10,7 +10,7 @@ struct _Ephoto_Reye
Evas_Object *rslider;
Eina_List *handlers;
int rad;
- int w, h;
+ Evas_Coord w, h;
unsigned int *original_im_data;
unsigned int *edited_im_data;
};
@@ -50,9 +50,9 @@ _reye_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
{
Ephoto_Reye *er = data;
unsigned int *im_data, *im_data_new, *p1, *p2;
- int x, y, imx, imy, imw, imh;
- int xpos, ypos, xadj, yadj;
- int a, r, g, b, nx, ny;
+ Evas_Coord x, y, imx, imy, imw, imh;
+ Evas_Coord xpos, ypos, xadj, yadj, nx, ny;
+ int a, r, g, b;
double scalex, scaley;
evas_pointer_canvas_xy_get(evas_object_evas_get(er->image), &xpos, &ypos);
@@ -151,7 +151,7 @@ _reye_apply(void *data, int type EINA_UNUSED,
{
Ephoto_Reye *er = data;
unsigned int *image_data;
- int w, h;
+ Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(er->image),
diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c
index 0e9bb92..ffed484 100644
--- a/src/bin/ephoto_single_browser.c
+++ b/src/bin/ephoto_single_browser.c
@@ -27,8 +27,8 @@ struct _Ephoto_Single_Browser
Eina_Bool editing:1;
Eina_Bool cropping:1;
unsigned int *edited_image_data;
- int ew;
- int eh;
+ Evas_Coord ew;
+ Evas_Coord eh;
};
struct _Ephoto_Viewer
@@ -43,27 +43,150 @@ struct _Ephoto_Viewer
Eina_Bool zoom_first:1;
};
-static void _zoom_set(Ephoto_Single_Browser *sb, double zoom);
-static void _zoom_in(Ephoto_Single_Browser *sb);
-static void _zoom_out(Ephoto_Single_Browser *sb);
-static void _key_down(void *data, Evas *e EINA_UNUSED,
- Evas_Object *obj EINA_UNUSED, void *event_info);
-static void _edit_menu(Ephoto_Single_Browser *sb);
-static void _back(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED);
+/*Common Callbacks*/
+static const char *_ephoto_get_edje_group(const char *path);
static char *_ephoto_get_file_size(const char *path);
-static void _update_bottom_bar(Ephoto_Single_Browser *sb);
+static void _ephoto_update_bottom_bar(Ephoto_Single_Browser *sb);
-static void
-_viewer_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
+/*Main Callbacks*/
+static void _ephoto_main_edit_menu(Ephoto_Single_Browser *sb);
+static void _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED,void *event_info EINA_UNUSED);
+static void _ephoto_main_focused(void *data, Evas *e EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED,void *event_info EINA_UNUSED);
+static void _ephoto_show_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_show_settings(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_main_back(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_main_del(void *data, Evas *e EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
+
+/*Common*/
+static const char *
+_ephoto_get_edje_group(const char *path)
{
- Ephoto_Viewer *v = data;
- if (v->monitor)
- ecore_file_monitor_del(v->monitor);
- free(v);
+ const char *group = NULL;
+ const char *ext = strrchr(path, '.');
+
+ if (ext)
+ {
+ ext++;
+ if ((strcasecmp(ext, "edj") == 0))
+ {
+ if (edje_file_group_exists(path, "e/desktop/background"))
+ group = "e/desktop/background";
+ else
+ {
+ Eina_List *g = edje_file_collection_list(path);
+
+ group = eina_list_data_get(g);
+ edje_file_collection_list_free(g);
+ }
+ }
+ }
+ return group;
}
+static void
+_ephoto_update_bottom_bar(Ephoto_Single_Browser *sb)
+{
+ Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
+ char image_info[PATH_MAX], *tmp;
+ Evas_Coord w, h;
+
+ if (sb->editing)
+ return;
+
+ evas_object_image_size_get(elm_image_object_get(v->image),
+ &w, &h);
+ tmp = _ephoto_get_file_size(sb->entry->path);
+ snprintf(image_info, PATH_MAX,
+ "%s: %s %s: %dx%d %s: %s",
+ _("Type"), efreet_mime_type_get(sb->entry->path),
+ _("Resolution"), w, h, _("File Size"), tmp);
+ free(tmp);
+
+ if (!evas_object_visible_get(sb->botbox))
+ {
+
+ evas_object_del(sb->botbox);
+
+ sb->botbox = elm_notify_add(sb->ephoto->win);
+ elm_notify_align_set(sb->botbox, 0.5, 1.0);
+ evas_object_size_hint_weight_set(sb->botbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(sb->botbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ sb->infolabel = elm_label_add(sb->botbox);
+ elm_label_line_wrap_set(sb->infolabel, ELM_WRAP_NONE);
+ evas_object_size_hint_weight_set(sb->infolabel, EVAS_HINT_EXPAND,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_align_set(sb->infolabel, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ elm_object_content_set(sb->botbox, sb->infolabel);
+ evas_object_show(sb->infolabel);
+ }
+
+ elm_object_text_set(sb->infolabel, image_info);
+ elm_notify_timeout_set(sb->botbox, 5);
+ evas_object_show(sb->botbox);
+}
+
+static char *
+_ephoto_get_file_size(const char *path)
+{
+ char isize[PATH_MAX];
+ Eina_File *f = eina_file_open(path, EINA_FALSE);
+ size_t size = eina_file_size_get(f);
+
+ eina_file_close(f);
+ double dsize = (double) size;
+
+ if (dsize < 1024.0)
+ snprintf(isize, sizeof(isize), "%'.0f%s", dsize, ngettext("B", "B",
+ dsize));
+ else
+ {
+ dsize /= 1024.0;
+ if (dsize < 1024)
+ snprintf(isize, sizeof(isize), "%'.0f%s", dsize,
+ ngettext("KB", "KB", dsize));
+ else
+ {
+ dsize /= 1024.0;
+ if (dsize < 1024)
+ snprintf(isize, sizeof(isize), "%'.1f%s", dsize,
+ ngettext("MB", "MB", dsize));
+ else
+ {
+ dsize /= 1024.0;
+ if (dsize < 1024)
+ snprintf(isize, sizeof(isize), "%'.1f%s", dsize,
+ ngettext("GB", "GB", dsize));
+ else
+ {
+ dsize /= 1024.0;
+ snprintf(isize, sizeof(isize), "%'.1f%s", dsize,
+ ngettext("TB", "TB", dsize));
+ }
+ }
+ }
+ }
+ return strdup(isize);
+}
+
+static void
+_menu_dismissed_cb(void *data, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Single_Browser *sb = data;
+
+ evas_object_del(obj);
+ elm_object_focus_set(sb->event, EINA_TRUE);
+}
+
+/*Image Viewer Callbacks*/
static Evas_Object *
_image_create_icon(void *data, Evas_Object *parent, Evas_Coord *xoff,
Evas_Coord *yoff)
@@ -152,34 +275,19 @@ _scroller_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
return;
if (ev->button == 3)
{
- _edit_menu(sb);
- _update_bottom_bar(sb);
+ _ephoto_main_edit_menu(sb);
+ _ephoto_update_bottom_bar(sb);
}
}
-static const char *
-_get_edje_group(const char *path)
+static void
+_viewer_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
{
- const char *group = NULL;
- const char *ext = strrchr(path, '.');
-
- if (ext)
- {
- ext++;
- if ((strcasecmp(ext, "edj") == 0))
- {
- if (edje_file_group_exists(path, "e/desktop/background"))
- group = "e/desktop/background";
- else
- {
- Eina_List *g = edje_file_collection_list(path);
-
- group = eina_list_data_get(g);
- edje_file_collection_list_free(g);
- }
- }
- }
- return group;
+ Ephoto_Viewer *v = data;
+ if (v->monitor)
+ ecore_file_monitor_del(v->monitor);
+ free(v);
}
static void
@@ -197,7 +305,7 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
{
Evas_Object *tmp;
Evas_Coord w, h;
- const char *group = _get_edje_group(sb->entry->path);
+ const char *group = _ephoto_get_edje_group(sb->entry->path);
tmp = evas_object_image_add(evas_object_evas_get(v->table));
evas_object_image_file_set(tmp, sb->entry->path, group);
@@ -215,70 +323,6 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
return;
}
-static Evas_Object *
-_viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
-{
- Ephoto_Viewer *v = calloc(1, sizeof(Ephoto_Viewer));
- int err;
-
- v->zoom_first = EINA_TRUE;
-
- Evas_Coord w, h;
- const char *group = _get_edje_group(path);
-
- v->scroller = elm_scroller_add(parent);
- evas_object_size_hint_weight_set(v->scroller, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(v->scroller,
- EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_data_set(v->scroller, "viewer", v);
- evas_object_event_callback_add(v->scroller, EVAS_CALLBACK_MOUSE_UP,
- _scroller_mouse_up_cb, sb);
- evas_object_event_callback_add(v->scroller, EVAS_CALLBACK_DEL, _viewer_del,
- v);
- evas_object_show(v->scroller);
-
- v->table = elm_table_add(v->scroller);
- evas_object_size_hint_weight_set(v->table, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(v->table, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_content_set(v->scroller, v->table);
- evas_object_show(v->table);
-
- v->image = elm_image_add(v->table);
- elm_image_preload_disabled_set(v->image, EINA_TRUE);
- elm_image_file_set(v->image, path, group);
- err = evas_object_image_load_error_get(elm_image_object_get(v->image));
- if (err != EVAS_LOAD_ERROR_NONE)
- goto error;
- evas_object_image_size_get(elm_image_object_get(v->image), &w, &h);
- elm_drop_target_add(v->image, ELM_SEL_FORMAT_IMAGE, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
- evas_object_size_hint_min_set(v->image, w, h);
- evas_object_size_hint_max_set(v->image, w, h);
- evas_object_event_callback_add(v->image, EVAS_CALLBACK_MOUSE_DOWN,
- _image_mouse_down_cb, sb);
- evas_object_event_callback_add(v->image, EVAS_CALLBACK_MOUSE_UP,
- _image_mouse_up_cb, sb);
- elm_table_pack(v->table, v->image, 0, 0, 1, 1);
- evas_object_show(v->image);
- if (elm_image_animated_available_get(v->image))
- {
- elm_image_animated_set(v->image, EINA_TRUE);
- elm_image_animated_play_set(v->image, EINA_TRUE);
- }
-
-
- v->monitor = ecore_file_monitor_add(path, _monitor_cb, sb);
- return v->scroller;
-
- error:
- evas_object_event_callback_del(v->scroller, EVAS_CALLBACK_DEL, _viewer_del);
- evas_object_data_del(v->scroller, "viewer");
- free(v);
- return NULL;
-}
-
static void
_viewer_zoom_apply(Ephoto_Viewer *v, double zoom)
{
@@ -384,55 +428,11 @@ _viewer_zoom_fit(Evas_Object *obj)
_viewer_zoom_fit_apply(v);
}
-static void
-_update_bottom_bar(Ephoto_Single_Browser *sb)
-{
- Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
- char image_info[PATH_MAX], *tmp;
- Evas_Coord w, h;
-
- if (sb->editing)
- return;
-
- evas_object_image_size_get(elm_image_object_get(v->image),
- &w, &h);
- tmp = _ephoto_get_file_size(sb->entry->path);
- snprintf(image_info, PATH_MAX,
- "%s: %s %s: %dx%d %s: %s",
- _("Type"), efreet_mime_type_get(sb->entry->path),
- _("Resolution"), w, h, _("File Size"), tmp);
- free(tmp);
-
- if (!evas_object_visible_get(sb->botbox))
- {
-
- evas_object_del(sb->botbox);
-
- sb->botbox = elm_notify_add(sb->ephoto->win);
- elm_notify_align_set(sb->botbox, 0.5, 1.0);
- evas_object_size_hint_weight_set(sb->botbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_fill_set(sb->botbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- sb->infolabel = elm_label_add(sb->botbox);
- elm_label_line_wrap_set(sb->infolabel, ELM_WRAP_NONE);
- evas_object_size_hint_weight_set(sb->infolabel, EVAS_HINT_EXPAND,
- EVAS_HINT_FILL);
- evas_object_size_hint_align_set(sb->infolabel, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- elm_object_content_set(sb->botbox, sb->infolabel);
- evas_object_show(sb->infolabel);
- }
-
- elm_object_text_set(sb->infolabel, image_info);
- elm_notify_timeout_set(sb->botbox, 5);
- evas_object_show(sb->botbox);
-}
-
static void
_orient_apply(Ephoto_Single_Browser *sb)
{
Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
- int w, h;
+ Evas_Coord w, h;
switch (sb->orient)
{
@@ -665,22 +665,6 @@ _flip_vert(Ephoto_Single_Browser *sb)
_orient_apply(sb);
}
-static void
-_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
- void *event_info)
-{
- Ephoto_Single_Browser *sb = data;
- Evas_Event_Mouse_Wheel *ev = event_info;
-
- if (!evas_key_modifier_is_set(ev->modifiers, "Control"))
- return;
-
- if (ev->z > 0)
- _zoom_out(sb);
- else
- _zoom_in(sb);
-}
-
static Ephoto_Entry *
_first_entry_find(Ephoto_Single_Browser *sb)
{
@@ -693,98 +677,6 @@ _last_entry_find(Ephoto_Single_Browser *sb)
return eina_list_last_data_get(sb->entries);
}
-static char *
-_ephoto_get_file_size(const char *path)
-{
- char isize[PATH_MAX];
- Eina_File *f = eina_file_open(path, EINA_FALSE);
- size_t size = eina_file_size_get(f);
-
- eina_file_close(f);
- double dsize = (double) size;
-
- if (dsize < 1024.0)
- snprintf(isize, sizeof(isize), "%'.0f%s", dsize, ngettext("B", "B",
- dsize));
- else
- {
- dsize /= 1024.0;
- if (dsize < 1024)
- snprintf(isize, sizeof(isize), "%'.0f%s", dsize,
- ngettext("KB", "KB", dsize));
- else
- {
- dsize /= 1024.0;
- if (dsize < 1024)
- snprintf(isize, sizeof(isize), "%'.1f%s", dsize,
- ngettext("MB", "MB", dsize));
- else
- {
- dsize /= 1024.0;
- if (dsize < 1024)
- snprintf(isize, sizeof(isize), "%'.1f%s", dsize,
- ngettext("GB", "GB", dsize));
- else
- {
- dsize /= 1024.0;
- snprintf(isize, sizeof(isize), "%'.1f%s", dsize,
- ngettext("TB", "TB", dsize));
- }
- }
- }
- }
- return strdup(isize);
-}
-
-static void
-_ephoto_single_browser_recalc(Ephoto_Single_Browser *sb)
-{
- if (sb->viewer)
- {
- evas_object_del(sb->viewer);
- sb->viewer = NULL;
- }
- if (sb->nolabel)
- {
- evas_object_del(sb->nolabel);
- sb->nolabel = NULL;
- }
- if (sb->entry)
- {
- const char *bname = ecore_file_file_get(sb->entry->path);
-
- sb->viewer = _viewer_add(sb->main, sb->entry->path, sb);
- if (sb->viewer)
- {
- elm_box_pack_start(sb->mhbox, sb->viewer);
- evas_object_show(sb->viewer);
- evas_object_event_callback_add(sb->viewer,
- EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel, sb);
- _update_bottom_bar(sb);
- ephoto_title_set(sb->ephoto, bname);
-
- if (!_ephoto_file_image_can_save(strrchr(bname, '.')+1))
- elm_object_item_disabled_set(sb->save, EINA_TRUE);
- else
- elm_object_item_disabled_set(sb->save, EINA_FALSE);
- }
- else
- {
- sb->nolabel = elm_label_add(sb->mhbox);
- elm_label_line_wrap_set(sb->nolabel, ELM_WRAP_WORD);
- elm_object_text_set(sb->nolabel,
- _("This image does not exist or is corrupted!"));
- evas_object_size_hint_weight_set(sb->nolabel, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(sb->nolabel, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- elm_box_pack_start(sb->mhbox, sb->nolabel);
- evas_object_show(sb->nolabel);
- ephoto_title_set(sb->ephoto, _("Bad Image"));
- }
- }
-}
-
static void
_zoom_set(Ephoto_Single_Browser *sb, double zoom)
{
@@ -867,6 +759,22 @@ _zoom_fit_cb(void *data, Evas_Object *obj EINA_UNUSED,
_zoom_fit(sb);
}
+static void
+_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ Ephoto_Single_Browser *sb = data;
+ Evas_Event_Mouse_Wheel *ev = event_info;
+
+ if (!evas_key_modifier_is_set(ev->modifiers, "Control"))
+ return;
+
+ if (ev->z > 0)
+ _zoom_out(sb);
+ else
+ _zoom_in(sb);
+}
+
static void
_next_entry(Ephoto_Single_Browser *sb)
{
@@ -1297,66 +1205,168 @@ _go_old_photo(void *data, Evas_Object *obj EINA_UNUSED,
}
}
+/*Image Viewer Function*/
+static Evas_Object *
+_viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
+{
+ Ephoto_Viewer *v = calloc(1, sizeof(Ephoto_Viewer));
+ int err;
+
+ v->zoom_first = EINA_TRUE;
+
+ Evas_Coord w, h;
+ const char *group = _ephoto_get_edje_group(path);
+
+ v->scroller = elm_scroller_add(parent);
+ evas_object_size_hint_weight_set(v->scroller, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(v->scroller,
+ EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_data_set(v->scroller, "viewer", v);
+ evas_object_event_callback_add(v->scroller, EVAS_CALLBACK_MOUSE_UP,
+ _scroller_mouse_up_cb, sb);
+ evas_object_event_callback_add(v->scroller, EVAS_CALLBACK_DEL, _viewer_del,
+ v);
+ evas_object_show(v->scroller);
+
+ v->table = elm_table_add(v->scroller);
+ evas_object_size_hint_weight_set(v->table, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(v->table, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_object_content_set(v->scroller, v->table);
+ evas_object_show(v->table);
+
+ v->image = elm_image_add(v->table);
+ elm_image_preload_disabled_set(v->image, EINA_TRUE);
+ elm_image_file_set(v->image, path, group);
+ err = evas_object_image_load_error_get(elm_image_object_get(v->image));
+ if (err != EVAS_LOAD_ERROR_NONE)
+ goto error;
+ evas_object_image_size_get(elm_image_object_get(v->image), &w, &h);
+ elm_drop_target_add(v->image, ELM_SEL_FORMAT_IMAGE, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
+ evas_object_size_hint_min_set(v->image, w, h);
+ evas_object_size_hint_max_set(v->image, w, h);
+ evas_object_event_callback_add(v->image, EVAS_CALLBACK_MOUSE_DOWN,
+ _image_mouse_down_cb, sb);
+ evas_object_event_callback_add(v->image, EVAS_CALLBACK_MOUSE_UP,
+ _image_mouse_up_cb, sb);
+ elm_table_pack(v->table, v->image, 0, 0, 1, 1);
+ evas_object_show(v->image);
+ if (elm_image_animated_available_get(v->image))
+ {
+ elm_image_animated_set(v->image, EINA_TRUE);
+ elm_image_animated_play_set(v->image, EINA_TRUE);
+ }
+
+
+ v->monitor = ecore_file_monitor_add(path, _monitor_cb, sb);
+ return v->scroller;
+
+ error:
+ evas_object_event_callback_del(v->scroller, EVAS_CALLBACK_DEL, _viewer_del);
+ evas_object_data_del(v->scroller, "viewer");
+ free(v);
+ return NULL;
+}
+
+/*Single Browser Populating Functions*/
static void
-_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
+_entry_free(void *data, const Ephoto_Entry *entry)
{
Ephoto_Single_Browser *sb = data;
+ if (entry == sb->entry)
+ {
+ if (eina_list_count(sb->entries) <= 1)
+ evas_object_smart_callback_call(sb->main, "back", NULL);
+ else
+ _next_entry(sb);
+ }
+}
+
+static Eina_Bool
+_ephoto_single_populate_end(void *data EINA_UNUSED, int type EINA_UNUSED,
+ void *event EINA_UNUSED)
+{
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_ephoto_single_entry_create(void *data, int type EINA_UNUSED,
+ void *event EINA_UNUSED)
+{
+ Ephoto_Single_Browser *sb = data;
+ Ephoto_Event_Entry_Create *ev = event;
+ Ephoto_Entry *e;
+
+ e = ev->entry;
+ if (sb->pending_path && !strcmp(e->path, sb->pending_path))
+ {
+ eina_stringshare_del(sb->pending_path);
+ sb->pending_path = NULL;
+ ephoto_single_browser_entry_set(sb->ephoto->single_browser, e);
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_ephoto_single_browser_recalc(Ephoto_Single_Browser *sb)
+{
+ if (sb->viewer)
+ {
+ evas_object_del(sb->viewer);
+ sb->viewer = NULL;
+ }
+ if (sb->nolabel)
+ {
+ evas_object_del(sb->nolabel);
+ sb->nolabel = NULL;
+ }
if (sb->entry)
{
- if (sb->event)
- {
- evas_object_del(sb->event);
- sb->event = NULL;
- }
- if (sb->botbox)
- evas_object_hide(sb->botbox);
- evas_object_smart_callback_call(sb->main, "slideshow", sb->entry);
+ const char *bname = ecore_file_file_get(sb->entry->path);
+
+ sb->viewer = _viewer_add(sb->main, sb->entry->path, sb);
+ if (sb->viewer)
+ {
+ elm_box_pack_start(sb->mhbox, sb->viewer);
+ evas_object_show(sb->viewer);
+ evas_object_event_callback_add(sb->viewer,
+ EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel, sb);
+ _ephoto_update_bottom_bar(sb);
+ ephoto_title_set(sb->ephoto, bname);
+
+ if (!_ephoto_file_image_can_save(strrchr(bname, '.')+1))
+ elm_object_item_disabled_set(sb->save, EINA_TRUE);
+ else
+ elm_object_item_disabled_set(sb->save, EINA_FALSE);
+ }
+ else
+ {
+ sb->nolabel = elm_label_add(sb->mhbox);
+ elm_label_line_wrap_set(sb->nolabel, ELM_WRAP_WORD);
+ elm_object_text_set(sb->nolabel,
+ _("This image does not exist or is corrupted!"));
+ evas_object_size_hint_weight_set(sb->nolabel, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(sb->nolabel, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ elm_box_pack_start(sb->mhbox, sb->nolabel);
+ evas_object_show(sb->nolabel);
+ ephoto_title_set(sb->ephoto, _("Bad Image"));
+ }
}
}
-static void
-_back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
-{
- Ephoto_Single_Browser *sb = data;
-
- if (sb->event)
- {
- evas_object_del(sb->event);
- sb->event = NULL;
- }
- if (sb->botbox)
- evas_object_hide(sb->botbox);
- evas_object_smart_callback_call(sb->main, "back", sb->entry);
-}
-
-static void
-_settings(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Single_Browser *sb = data;
-
- ephoto_config_main(sb->ephoto);
-}
-
-
-static void
-_menu_dismissed_cb(void *data, Evas_Object *obj,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Single_Browser *sb = data;
-
- evas_object_del(obj);
- elm_object_focus_set(sb->event, EINA_TRUE);
-}
-
+/*Ephoto Main Callbacks*/
static void
_add_edit_menu_items(Ephoto_Single_Browser *sb, Evas_Object *menu)
{
Evas_Object *menu_it, *menu_itt;
- elm_menu_item_add(menu, NULL, "go-previous", _("Back"), _back, sb);
+ elm_menu_item_add(menu, NULL, "go-previous", _("Back"), _ephoto_main_back, sb);
elm_menu_item_separator_add(menu, NULL);
menu_it =
@@ -1434,16 +1444,16 @@ _add_edit_menu_items(Ephoto_Single_Browser *sb, Evas_Object *menu)
_zoom_1_cb, sb);
elm_menu_item_separator_add(menu, NULL);
elm_menu_item_add(menu, NULL, "media-playback-start", _("Slideshow"),
- _slideshow, sb);
+ _ephoto_show_slideshow, sb);
elm_menu_item_add(menu, NULL, "preferences-system", _("Settings"),
- _settings, sb);
+ _ephoto_show_settings, sb);
}
static void
-_edit_menu(Ephoto_Single_Browser *sb)
+_ephoto_main_edit_menu(Ephoto_Single_Browser *sb)
{
Evas_Object *menu;
- int x, y;
+ Evas_Coord x, y;
evas_pointer_canvas_xy_get(evas_object_evas_get(sb->main), &x, &y);
menu = elm_menu_add(sb->main);
@@ -1457,7 +1467,7 @@ _edit_menu(Ephoto_Single_Browser *sb)
}
static void
-_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+_ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info)
{
Ephoto_Single_Browser *sb = data;
@@ -1531,7 +1541,7 @@ _key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_last_entry(sb);
else if (!strcmp(k, "F1"))
{
- _settings(sb, NULL, NULL);
+ _ephoto_show_settings(sb, NULL, NULL);
}
else if (!strcmp(k, "F5") && !sb->editing)
{
@@ -1555,21 +1565,66 @@ _key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
}
static void
-_entry_free(void *data, const Ephoto_Entry *entry)
+_ephoto_show_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
{
Ephoto_Single_Browser *sb = data;
- if (entry == sb->entry)
+ if (sb->entry)
{
- if (eina_list_count(sb->entries) <= 1)
- evas_object_smart_callback_call(sb->main, "back", NULL);
- else
- _next_entry(sb);
+ if (sb->event)
+ {
+ evas_object_del(sb->event);
+ sb->event = NULL;
+ }
+ if (sb->botbox)
+ evas_object_hide(sb->botbox);
+ evas_object_smart_callback_call(sb->main, "slideshow", sb->entry);
}
}
static void
-_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+_ephoto_show_settings(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Single_Browser *sb = data;
+
+ ephoto_config_main(sb->ephoto);
+}
+
+static void
+_ephoto_main_back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Ephoto_Single_Browser *sb = data;
+
+ if (sb->event)
+ {
+ evas_object_del(sb->event);
+ sb->event = NULL;
+ }
+ if (sb->botbox)
+ evas_object_hide(sb->botbox);
+ evas_object_smart_callback_call(sb->main, "back", sb->entry);
+}
+
+static void
+_ephoto_main_focused(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_data EINA_UNUSED)
+{
+ Ephoto_Single_Browser *sb = data;
+
+ if (sb->ephoto->state == EPHOTO_STATE_SINGLE)
+ {
+ if (sb->event)
+ {
+ elm_object_focus_set(sb->event, EINA_TRUE);
+ evas_object_raise(sb->event);
+ }
+ }
+}
+
+static void
+_ephoto_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
char tmp_path[PATH_MAX];
@@ -1595,118 +1650,7 @@ _main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
free(sb);
}
-static Eina_Bool
-_ephoto_single_populate_end(void *data EINA_UNUSED, int type EINA_UNUSED,
- void *event EINA_UNUSED)
-{
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_ephoto_single_entry_create(void *data, int type EINA_UNUSED,
- void *event EINA_UNUSED)
-{
- Ephoto_Single_Browser *sb = data;
- Ephoto_Event_Entry_Create *ev = event;
- Ephoto_Entry *e;
-
- e = ev->entry;
- if (sb->pending_path && !strcmp(e->path, sb->pending_path))
- {
- eina_stringshare_del(sb->pending_path);
- sb->pending_path = NULL;
- ephoto_single_browser_entry_set(sb->ephoto->single_browser, e);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void
-_main_focused(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
- void *event_data EINA_UNUSED)
-{
- Ephoto_Single_Browser *sb = data;
-
- if (sb->ephoto->state == EPHOTO_STATE_SINGLE)
- {
- if (sb->event)
- {
- elm_object_focus_set(sb->event, EINA_TRUE);
- evas_object_raise(sb->event);
- }
- }
-}
-
-Evas_Object *
-ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
-{
- Evas_Object *box = elm_box_add(parent);
- Ephoto_Single_Browser *sb;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
-
- sb = calloc(1, sizeof(Ephoto_Single_Browser));
- EINA_SAFETY_ON_NULL_GOTO(sb, error);
-
- sb->ephoto = ephoto;
- sb->editing = EINA_FALSE;
- sb->cropping = EINA_FALSE;
- sb->main = box;
-
- elm_box_horizontal_set(sb->main, EINA_FALSE);
- elm_object_tree_focus_allow_set(sb->main, EINA_FALSE);
- evas_object_event_callback_add(sb->main, EVAS_CALLBACK_DEL, _main_del, sb);
- evas_object_event_callback_add(sb->main, EVAS_CALLBACK_KEY_DOWN, _key_down,
- sb);
- evas_object_event_callback_add(sb->ephoto->win, EVAS_CALLBACK_FOCUS_IN,
- _main_focused, sb);
- evas_object_size_hint_weight_set(sb->main, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(sb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_data_set(sb->main, "single_browser", sb);
-
- sb->mhbox = elm_box_add(sb->main);
- elm_box_horizontal_set(sb->mhbox, EINA_TRUE);
- evas_object_size_hint_weight_set(sb->mhbox, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(sb->mhbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(sb->main, sb->mhbox);
- evas_object_show(sb->mhbox);
-
- sb->botbox = elm_notify_add(sb->ephoto->win);
- elm_notify_align_set(sb->botbox, 0.5, 1.0);
- elm_notify_timeout_set(sb->botbox, 5);
- evas_object_size_hint_weight_set(sb->botbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_fill_set(sb->botbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- sb->infolabel = elm_label_add(sb->botbox);
- elm_label_line_wrap_set(sb->infolabel, ELM_WRAP_NONE);
- evas_object_size_hint_weight_set(sb->infolabel, EVAS_HINT_EXPAND,
- EVAS_HINT_FILL);
- evas_object_size_hint_align_set(sb->infolabel, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- elm_object_content_set(sb->botbox, sb->infolabel);
- evas_object_show(sb->infolabel);
-
- sb->handlers =
- eina_list_append(sb->handlers,
- ecore_event_handler_add(EPHOTO_EVENT_POPULATE_END,
- _ephoto_single_populate_end, sb));
-
- sb->handlers =
- eina_list_append(sb->handlers,
- ecore_event_handler_add(EPHOTO_EVENT_ENTRY_CREATE,
- _ephoto_single_entry_create, sb));
-
- sb->orient = EPHOTO_ORIENT_0;
-
- return sb->main;
-
- error:
- evas_object_del(sb->main);
- return NULL;
-}
-
+/*Ephoto Single Browser Public Functions*/
void
ephoto_single_browser_entries_set(Evas_Object *obj, Eina_List *entries)
{
@@ -1748,7 +1692,7 @@ ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
evas_object_color_set(sb->event, 0, 0, 0, 0);
evas_object_repeat_events_set(sb->event, EINA_TRUE);
evas_object_show(sb->event);
- evas_object_event_callback_add(sb->event, EVAS_CALLBACK_KEY_DOWN, _key_down,
+ evas_object_event_callback_add(sb->event, EVAS_CALLBACK_KEY_DOWN, _ephoto_main_key_down,
sb);
evas_object_raise(sb->event);
elm_object_focus_set(sb->event, EINA_TRUE);
@@ -1803,7 +1747,7 @@ ephoto_single_browser_path_created(Evas_Object *obj, Ephoto_Entry *entry)
void
ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image,
- unsigned int *image_data, int w, int h)
+ unsigned int *image_data, Evas_Coord w, Evas_Coord h)
{
Ephoto_Single_Browser *sb = evas_object_data_get(main, "single_browser");
@@ -1817,7 +1761,7 @@ ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image,
void
ephoto_single_browser_image_data_done(Evas_Object *main,
- unsigned int *image_data, int w, int h)
+ unsigned int *image_data, Evas_Coord w, Evas_Coord h)
{
Ephoto_Single_Browser *sb = evas_object_data_get(main, "single_browser");
@@ -1832,7 +1776,7 @@ ephoto_single_browser_image_data_done(Evas_Object *main,
evas_object_image_data_update_add(elm_image_object_get(v->image), 0, 0, w,
h);
- _update_bottom_bar(sb);
+ _ephoto_update_bottom_bar(sb);
sb->edited_image_data = image_data;
sb->ew = w;
sb->eh = h;
@@ -1865,3 +1809,74 @@ ephoto_single_browser_cancel_editing(Evas_Object *main)
_zoom_fit(sb);
}
}
+
+Evas_Object *
+ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
+{
+ Evas_Object *box = elm_box_add(parent);
+ Ephoto_Single_Browser *sb;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
+
+ sb = calloc(1, sizeof(Ephoto_Single_Browser));
+ EINA_SAFETY_ON_NULL_GOTO(sb, error);
+
+ sb->ephoto = ephoto;
+ sb->editing = EINA_FALSE;
+ sb->cropping = EINA_FALSE;
+ sb->main = box;
+
+ elm_box_horizontal_set(sb->main, EINA_FALSE);
+ elm_object_tree_focus_allow_set(sb->main, EINA_FALSE);
+ evas_object_event_callback_add(sb->main, EVAS_CALLBACK_DEL, _ephoto_main_del, sb);
+ evas_object_event_callback_add(sb->main, EVAS_CALLBACK_KEY_DOWN, _ephoto_main_key_down,
+ sb);
+ evas_object_event_callback_add(sb->ephoto->win, EVAS_CALLBACK_FOCUS_IN,
+ _ephoto_main_focused, sb);
+ evas_object_size_hint_weight_set(sb->main, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(sb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_data_set(sb->main, "single_browser", sb);
+
+ sb->mhbox = elm_box_add(sb->main);
+ elm_box_horizontal_set(sb->mhbox, EINA_TRUE);
+ evas_object_size_hint_weight_set(sb->mhbox, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(sb->mhbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(sb->main, sb->mhbox);
+ evas_object_show(sb->mhbox);
+
+ sb->botbox = elm_notify_add(sb->ephoto->win);
+ elm_notify_align_set(sb->botbox, 0.5, 1.0);
+ elm_notify_timeout_set(sb->botbox, 5);
+ evas_object_size_hint_weight_set(sb->botbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(sb->botbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ sb->infolabel = elm_label_add(sb->botbox);
+ elm_label_line_wrap_set(sb->infolabel, ELM_WRAP_NONE);
+ evas_object_size_hint_weight_set(sb->infolabel, EVAS_HINT_EXPAND,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_align_set(sb->infolabel, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ elm_object_content_set(sb->botbox, sb->infolabel);
+ evas_object_show(sb->infolabel);
+
+ sb->handlers =
+ eina_list_append(sb->handlers,
+ ecore_event_handler_add(EPHOTO_EVENT_POPULATE_END,
+ _ephoto_single_populate_end, sb));
+
+ sb->handlers =
+ eina_list_append(sb->handlers,
+ ecore_event_handler_add(EPHOTO_EVENT_ENTRY_CREATE,
+ _ephoto_single_entry_create, sb));
+
+ sb->orient = EPHOTO_ORIENT_0;
+
+ return sb->main;
+
+ error:
+ evas_object_del(sb->main);
+ return NULL;
+}
+
diff --git a/src/bin/ephoto_thumb.c b/src/bin/ephoto_thumb.c
index 3421eb9..07d2873 100644
--- a/src/bin/ephoto_thumb.c
+++ b/src/bin/ephoto_thumb.c
@@ -110,7 +110,7 @@ e_thumb_icon_file_set(Evas_Object *obj, const char *file, const char *key)
}
void
-e_thumb_icon_size_set(Evas_Object *obj, int w, int h)
+e_thumb_icon_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
{
E_Thumb *eth;
diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c
index b22efd9..1315979 100644
--- a/src/bin/ephoto_thumb_browser.c
+++ b/src/bin/ephoto_thumb_browser.c
@@ -21,6 +21,7 @@ struct _Ephoto_Thumb_Browser
{
Ephoto *ephoto;
Evas_Object *main;
+ Evas_Object *panes;
Evas_Object *table;
Evas_Object *gridbox;
Evas_Object *grid;
@@ -63,1114 +64,78 @@ struct _Ephoto_Thumb_Browser
Eina_Bool main_deleted:1;
};
+/*Item Classes*/
static Elm_Gengrid_Item_Class _ephoto_thumb_file_class;
static Elm_Genlist_Item_Class _ephoto_dir_class;
+/*Main Callbacks*/
+static void _ephoto_show_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_show_settings(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
+static void _ephoto_panes_unpress(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_panes_double_clicked(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_main_del(void *data, Evas *e EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
+
+/*File Pane Functions*/
static void _ephoto_dir_hide_folders(void *data, Evas_Object *obj,
void *event_info);
static void _ephoto_dir_show_folders(void *data, Evas_Object *obj,
void *event_info);
-static Elm_Object_Item *_dnd_item_get(Evas_Object *obj, Evas_Coord x,
- Evas_Coord y, int *xposret, int *yposret);
-static Eina_Bool _dnd_item_data_get(Evas_Object *obj, Elm_Object_Item *it,
- Elm_Drag_User_Info *info);
-static void _grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
- Evas_Object *obj EINA_UNUSED, void *event_info);
+
+/*Thumb Pane Functions*/
+static void _ephoto_thumb_update_info_label(Ephoto_Thumb_Browser *tb);
static void _ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info);
-static void _zoom_set(Ephoto_Thumb_Browser *tb, int zoom);
-static void _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
- Ecore_File_Event event, const char *path);
+static void _ephoto_thumb_zoom_set(Ephoto_Thumb_Browser *tb, int zoom);
+static void _ephoto_thumb_search_go(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_thumb_search_cancel(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+static void _ephoto_thumb_search_start(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED);
+/*Common Callbacks*/
static void
-_update_info_label(Ephoto_Thumb_Browser *tb)
-{
- char buf[PATH_MAX];
- char isize[PATH_MAX];
- char image_info[PATH_MAX];
- double totsize;
-
-
- if (!tb->totimages)
- {
- elm_object_text_set(tb->nolabel,
- _("No images matched your search"));
- snprintf(buf, PATH_MAX, "%s: 0 %s %s: 0%s",
- _("Total"), ngettext("image", "images", 0), _("Size"),
- ngettext("B", "B", 0));
- elm_object_text_set(tb->infolabel, buf);
- }
- else
- {
- elm_object_text_set(tb->nolabel, " ");
- totsize = tb->totsize;
- if (totsize < 1024.0)
- snprintf(isize, sizeof(isize), "%'.0f%s", totsize, ngettext("B",
- "B", totsize));
- else
- {
- totsize /= 1024.0;
- if (totsize < 1024)
- snprintf(isize, sizeof(isize), "%'.0f%s", totsize,
- ngettext("KB", "KB", totsize));
- else
- {
- totsize /= 1024.0;
- if (totsize < 1024)
- snprintf(isize, sizeof(isize), "%'.1f%s", totsize,
- ngettext("MB", "MB", totsize));
- else
- {
- totsize /= 1024.0;
- if (totsize < 1024)
- snprintf(isize, sizeof(isize), "%'.1f%s", totsize,
- ngettext("GB", "GB", totsize));
- else
- {
- totsize /= 1024.0;
- snprintf(isize, sizeof(isize), "%'.1f%s",
- totsize, ngettext("TB", "TB", totsize));
- }
- }
- }
- }
- snprintf(image_info, PATH_MAX, "%s: %d %s %s: %s",
- _("Total"), tb->totimages, ngettext("image", "images",
- tb->totimages), _("Size"), isize);
- elm_object_text_set(tb->infolabel, image_info);
- }
-}
-
-static void
-_todo_items_free(Ephoto_Thumb_Browser *tb)
-{
- eina_list_free(tb->todo_items);
- tb->todo_items = NULL;
-}
-
-static void
-_on_list_expand_req(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *it = event_info;
-
- ecore_job_del(tb->change_dir_job);
- tb->change_dir_job = NULL;
- ecore_timer_del(tb->click_timer);
- tb->click_timer = NULL;
- elm_genlist_item_expanded_set(it, EINA_TRUE);
-}
-
-static void
-_on_list_contract_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
- void *event_info)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *it = event_info;
-
- ecore_job_del(tb->change_dir_job);
- tb->change_dir_job = NULL;
- ecore_timer_del(tb->click_timer);
- tb->click_timer = NULL;
- elm_genlist_item_expanded_set(it, EINA_FALSE);
-}
-
-static void
-_on_list_expanded(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *it = event_info;
- Ephoto_Entry *entry;
- const char *path;
-
- entry = elm_object_item_data_get(it);
- path = entry->path;
- tb->dirs_only = 0;
- if (!strcmp(path, tb->ephoto->config->directory))
- tb->dirs_only = 1;
- else
- tb->dirs_only = 0;
- tb->thumbs_only = 0;
- ephoto_directory_set(tb->ephoto, path, it, tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
-}
-
-static void
-_on_list_contracted(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *it = event_info;
- Ephoto_Entry *entry;
- const char *path;
-
- entry = elm_object_item_data_get(it);
- path = entry->path;
- elm_genlist_item_subitems_clear(it);
- if (!strcmp(path, tb->ephoto->config->directory))
- return;
- tb->thumbs_only = 1;
- tb->dirs_only = 0;
- ephoto_directory_set(tb->ephoto, path, NULL,
- tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto,
- tb->ephoto->config->directory);
-}
-
-static void
-_dir_job(void *data)
-{
- Elm_Object_Item *it = data;
- Ephoto_Thumb_Browser *tb = evas_object_data_get(it, "thumb_browser");
- Ephoto_Entry *entry;
- const char *path;
-
- entry = elm_object_item_data_get(it);
- path = entry->path;
- tb->change_dir_job = NULL;
- tb->thumbs_only = 1;
- tb->dirs_only = 0;
- ephoto_directory_set(tb->ephoto, path, NULL,
- tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
-}
-
-static void
-_wait_job(void *data)
-{
- Elm_Object_Item *it = data;
- Ephoto_Thumb_Browser *tb = evas_object_data_get(it, "thumb_browser");
-
- if (tb->change_dir_job)
- ecore_job_del(tb->change_dir_job);
- tb->change_dir_job = ecore_job_add(_dir_job, it);
-}
-
-static void
-_on_list_selected(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *it = event_info;
-
- evas_object_data_set(it, "thumb_browser", tb);
- if (!tb->dragging)
- {
- tb->dir_current = it;
-
- ecore_job_add(_wait_job, it);
- }
-}
-
-static char *
-_ephoto_dir_item_text_get(void *data, Evas_Object *obj EINA_UNUSED,
- const char *part EINA_UNUSED)
-{
- Ephoto_Entry *e = data;
-
- return strdup(e->label);
-}
-
-static char *
-_ephoto_thumb_item_text_get(void *data, Evas_Object *obj EINA_UNUSED,
- const char *part EINA_UNUSED)
-{
- Ephoto_Entry *e = data;
-
- return strdup(e->label);
-}
-
-static Evas_Object *
-_ephoto_dir_item_icon_get(void *data EINA_UNUSED, Evas_Object *obj,
- const char *part)
-{
- if (!strcmp(part, "elm.swallow.end"))
- return NULL;
- Evas_Object *ic = elm_icon_add(obj);
-
- elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
- elm_icon_standard_set(ic, "folder");
- return ic;
-}
-
-static Evas_Object *
-_ephoto_thumb_file_icon_get(void *data, Evas_Object *obj,
- const char *part)
-{
- Ephoto_Entry *e = data;
- Evas_Object *thumb = NULL;
-
- if (strcmp(part, "elm.swallow.icon"))
- return NULL;
-
- if (e)
- {
- thumb = ephoto_thumb_add(e->ephoto, obj, e->path);
- evas_object_show(thumb);
- }
- return thumb;
-}
-
-static void
-_ephoto_dir_item_del(void *data, Evas_Object *obj EINA_UNUSED)
-{
- Ephoto_Entry *e = data;
-
- if (!e->no_delete)
- ephoto_entry_free(e->ephoto, e);
-}
-
-static void
-_ephoto_thumb_item_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
-{
- /* The entry is already freed when changing directories. */
-}
-
-static int
-_entry_cmp(const void *pa, const void *pb)
-{
- const Ephoto_Entry *a, *b;
-
- a = elm_object_item_data_get(pa);
- b = elm_object_item_data_get(pb);
-
- return strcasecmp(a->basename, b->basename);
-}
-
-static int
-_entry_cmp_grid_alpha_asc(const void *pa, const void *pb)
-{
- const Ephoto_Entry *a, *b;
-
- a = elm_object_item_data_get(pa);
- b = elm_object_item_data_get(pb);
-
- return strcasecmp(a->basename, b->basename);
-}
-
-static int
-_entry_cmp_grid_alpha_desc(const void *pa, const void *pb)
-{
- const Ephoto_Entry *a, *b;
- int i;
-
- a = elm_object_item_data_get(pa);
- b = elm_object_item_data_get(pb);
- i = strcasecmp(a->basename, b->basename);
- if (i < 0)
- i = 1;
- else if (i > 0)
- i = -1;
-
- return i;
-}
-
-static int
-_entry_cmp_grid_mod_asc(const void *pa, const void *pb)
-{
- const Ephoto_Entry *a, *b;
- long long moda, modb;
-
- a = elm_object_item_data_get(pa);
- b = elm_object_item_data_get(pb);
-
- moda = ecore_file_mod_time(a->path);
- modb = ecore_file_mod_time(b->path);
-
- if (moda < modb)
- return -1;
- else if (moda > modb)
- return 1;
- else
- return strcasecmp(a->basename, b->basename);
-}
-
-static int
-_entry_cmp_grid_mod_desc(const void *pa, const void *pb)
-{
- const Ephoto_Entry *a, *b;
- long long moda, modb;
-
- a = elm_object_item_data_get(pa);
- b = elm_object_item_data_get(pb);
-
- moda = ecore_file_mod_time(a->path);
- modb = ecore_file_mod_time(b->path);
-
- if (moda < modb)
- return 1;
- else if (moda > modb)
- return -1;
- else
- {
- int i;
-
- i = strcasecmp(a->basename, b->basename);
- if (i < 0)
- i = 1;
- else if (i > 0)
- i = -1;
- return i;
- }
-}
-
-static void
-_sort_alpha_asc(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_data EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Evas_Object *ic;
-
- tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
- tb->thumbs_only = 1;
- tb->dirs_only = 0;
- ic = elm_icon_add(tb->hover);
- elm_icon_standard_set(ic, "view-sort-ascending");
- elm_object_part_content_set(tb->hover, "icon", ic);
- evas_object_show(ic);
- ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
- NULL, tb->dirs_only, tb->thumbs_only);
-}
-
-static void
-_sort_alpha_desc(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_data EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Evas_Object *ic;
-
- tb->sort = EPHOTO_SORT_ALPHABETICAL_DESCENDING;
- tb->thumbs_only = 1;
- tb->dirs_only = 0;
- ic = elm_icon_add(tb->hover);
- elm_icon_standard_set(ic, "view-sort-descending");
- elm_object_part_content_set(tb->hover, "icon", ic);
- evas_object_show(ic);
- ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
- NULL, tb->dirs_only, tb->thumbs_only);
-}
-
-static void
-_sort_mod_asc(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_data EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Evas_Object *ic;
-
- tb->sort = EPHOTO_SORT_MODTIME_ASCENDING;
- tb->thumbs_only = 1;
- tb->dirs_only = 0;
- ic = elm_icon_add(tb->hover);
- elm_icon_standard_set(ic, "view-sort-ascending");
- elm_object_part_content_set(tb->hover, "icon", ic);
- evas_object_show(ic);
- ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
- NULL, tb->dirs_only, tb->thumbs_only);
-}
-
-static void
-_sort_mod_desc(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_data EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Evas_Object *ic;
-
- tb->sort = EPHOTO_SORT_MODTIME_DESCENDING;
- tb->thumbs_only = 1;
- tb->dirs_only = 0;
- ic = elm_icon_add(tb->hover);
- elm_icon_standard_set(ic, "view-sort-descending");
- elm_object_part_content_set(tb->hover, "icon", ic);
- evas_object_show(ic);
- ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
- NULL, tb->dirs_only, tb->thumbs_only);
-}
-
-static Eina_Bool
-_check_for_subdirs(Ephoto_Entry *entry)
-{
- Eina_Iterator *ls = eina_file_direct_ls(entry->path);
- Eina_File_Direct_Info *info;
-
- if (!ls)
- return EINA_FALSE;
- EINA_ITERATOR_FOREACH(ls, info)
- {
- if (info->type == EINA_FILE_DIR)
- {
- eina_iterator_free(ls);
- return EINA_TRUE;
- }
- }
- eina_iterator_free(ls);
- return EINA_FALSE;
-}
-
-static void
-_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
- Ecore_File_Event event, const char *path)
-{
- Elm_Object_Item *item;
- Ephoto_Entry *entry = data;
- Ephoto_Entry *e;
- char file[PATH_MAX], dir[PATH_MAX];
- const Elm_Genlist_Item_Class *ic;
- char buf[PATH_MAX];
-
- if (!entry)
- return;
-
- snprintf(file, PATH_MAX, "%s", path);
- snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
-
- if (strcmp(entry->path, dir))
- return;
- if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
- {
- if (!ecore_file_is_dir(path))
- return;
- if (ephoto_entry_exists(entry->ephoto, path))
- return;
-
- if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_TREE &&
- elm_genlist_item_expanded_get(entry->item) == EINA_TRUE)
- {
- ic = &_ephoto_dir_class;
- snprintf(buf, PATH_MAX, "%s", path);
- e = ephoto_entry_new(entry->ephoto, path, basename(buf),
- EINA_FILE_DIR);
- e->genlist = entry->genlist;
- e->parent = entry->item;
- e->item =
- elm_genlist_item_sorted_insert(entry->genlist, ic, e,
- e->parent, ELM_GENLIST_ITEM_NONE, _entry_cmp, NULL, NULL);
- if (e->item)
- e->monitor = ecore_file_monitor_add(e->path, _monitor_cb, e);
- }
- if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_NONE)
- {
- Elm_Object_Item *parent;
-
- ic = &_ephoto_dir_class;
- parent =
- elm_genlist_item_insert_before(entry->genlist, ic, entry,
- entry->parent, entry->item, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- entry->no_delete = EINA_TRUE;
- if (entry->monitor)
- ecore_file_monitor_del(entry->monitor);
- elm_object_item_del(entry->item);
- entry->item = parent;
- entry->no_delete = EINA_FALSE;
- entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry);
- }
- return;
- }
- else if (event == ECORE_FILE_EVENT_DELETED_DIRECTORY)
- {
- item = elm_genlist_first_item_get(entry->genlist);
- while (item)
- {
- e = elm_object_item_data_get(item);
- if (!strcmp(e->path, path))
- {
- elm_object_item_del(e->item);
- //if (!strcmp(e->path, e->ephoto->config->directory))
- break;
- }
- item = elm_genlist_item_next_get(item);
- }
- if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_TREE &&
- _check_for_subdirs(entry) == EINA_FALSE)
- {
- Elm_Object_Item *parent;
-
- ic = &_ephoto_dir_class;
- parent =
- elm_genlist_item_insert_before(entry->genlist, ic, entry,
- entry->parent, entry->item, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- entry->no_delete = EINA_TRUE;
- elm_object_item_del(entry->item);
- entry->item = parent;
- entry->no_delete = EINA_FALSE;
- }
- if (!ecore_file_exists(entry->ephoto->config->directory))
- {
- ephoto_directory_set(entry->ephoto, entry->path, entry->parent, 0, 1);
- ephoto_title_set(entry->ephoto, entry->path);
- }
- return;
- }
- else if (event == ECORE_FILE_EVENT_MODIFIED)
- {
- if (!ecore_file_is_dir(path))
- return;
- if ((elm_genlist_item_expanded_get(entry->item) == EINA_TRUE))
- {
- item = elm_genlist_first_item_get(entry->genlist);
- while (item)
- {
- e = elm_object_item_data_get(item);
- if (!strcmp(e->path, path))
- {
- elm_genlist_item_update(e->item);
- break;
- }
- item = elm_genlist_item_next_get(item);
- }
- }
- return;
- }
-}
-
-static Eina_Bool
-_todo_items_process(void *data)
-{
- Ephoto_Thumb_Browser *tb = data;
- Ephoto_Entry *entry;
- int i = 0;
-
- if ((!tb->ls) && (tb->animator.processed == tb->animator.count))
- {
- if (tb->animator.count == 0)
- return EINA_TRUE;
- tb->animator.todo_items = NULL;
- tb->processing = 0;
- return EINA_FALSE;
- }
- if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH))
- return EINA_TRUE;
-
- tb->animator.todo_items = NULL;
- tb->processing = 1;
- EINA_LIST_FREE(tb->todo_items, entry)
- {
- i++;
- if (i > TODO_ITEM_MIN_BATCH)
- return EINA_TRUE;
- if (entry->is_dir && !entry->item)
- {
- const Elm_Genlist_Item_Class *ic;
-
- ic = &_ephoto_dir_class;
- if (_check_for_subdirs(entry))
- entry->item =
- elm_genlist_item_sorted_insert(tb->fsel, ic, entry,
- entry->parent, ELM_GENLIST_ITEM_TREE, _entry_cmp, NULL, NULL);
- else
- entry->item =
- elm_genlist_item_sorted_insert(tb->fsel, ic, entry,
- entry->parent, ELM_GENLIST_ITEM_NONE, _entry_cmp, NULL, NULL);
- if (!entry->item)
- {
- ephoto_entry_free(tb->ephoto, entry);
- }
- else
- {
- entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry);
- entry->genlist = tb->fsel;
- }
- }
- else if (!entry->is_dir && !entry->item)
- {
- const Elm_Gengrid_Item_Class *ic;
-
- ic = &_ephoto_thumb_file_class;
- if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_alpha_asc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_alpha_desc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_mod_asc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_mod_desc, NULL, NULL);
- if (entry->item)
- {
- elm_object_item_data_set(entry->item, entry);
- }
- else
- {
- ephoto_entry_free(tb->ephoto, entry);
- }
- }
- tb->animator.processed++;
- }
- return EINA_TRUE;
-}
-
-static void
-_ephoto_dir_go_home(void *data, Evas_Object *obj EINA_UNUSED,
+_menu_dismissed_cb(void *data, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
- elm_genlist_clear(tb->fsel);
- tb->thumbs_only = 0;
- tb->dirs_only = 0;
- ephoto_directory_set(tb->ephoto, getenv("HOME"), NULL,
- tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
- ephoto_thumb_browser_top_dir_set(tb->ephoto, tb->ephoto->config->directory);
-}
-
-static void
-_ephoto_dir_go_up(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- if (strcmp(tb->ephoto->config->directory, "/"))
- {
- char path[PATH_MAX];
-
- snprintf(path, PATH_MAX, "%s", tb->ephoto->config->directory);
- elm_genlist_clear(tb->fsel);
- tb->thumbs_only = 0;
- tb->dirs_only = 0;
- ephoto_directory_set(tb->ephoto, ecore_file_dir_get(path), NULL,
- tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
- ephoto_thumb_browser_top_dir_set(tb->ephoto,
- tb->ephoto->config->directory);
- }
-}
-
-static void
-_ephoto_dir_go_trash(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- char path[PATH_MAX];
-
- snprintf(path, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
- if (!ecore_file_exists(path))
- ecore_file_mkpath(path);
- elm_genlist_clear(tb->fsel);
- tb->thumbs_only = 0;
- tb->dirs_only = 0;
- ephoto_directory_set(tb->ephoto, path, NULL,
- tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto, _("Trash"));
- ephoto_thumb_browser_top_dir_set(tb->ephoto, tb->ephoto->config->directory);
-}
-
-static void
-_ephoto_direntry_go(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- const char *dir;
- Ephoto_Thumb_Browser *tb = data;
-
- dir = elm_object_text_get(tb->direntry);
- if (ecore_file_is_dir(dir))
- {
- elm_genlist_clear(tb->fsel);
- tb->thumbs_only = 0;
- tb->dirs_only = 0;
- ephoto_directory_set(tb->ephoto, dir, NULL,
- tb->dirs_only, tb->thumbs_only);
- ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
- ephoto_thumb_browser_top_dir_set(tb->ephoto,
- tb->ephoto->config->directory);
- }
-}
-
-static void
-_ephoto_search_go(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Evas_Object *search = data;
- Ephoto_Thumb_Browser *tb = evas_object_data_get(search, "thumb_browser");
- if (tb->processing)
- return;
- Elm_Object_Item *next = NULL;
- Elm_Object_Item *found = NULL;
- Elm_Object_Item *o = NULL;
- Eina_List *sel = eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
- Eina_List *l, *results = NULL;
- const char *search_text = elm_object_text_get(search);
- char pattern[PATH_MAX];
-
- if (tb->original_grid)
- {
- elm_gengrid_clear(tb->grid);
- elm_box_unpack(tb->gridbox, tb->grid);
- evas_object_del(tb->grid);
- tb->grid = tb->original_grid;
- elm_box_pack_end(tb->gridbox, tb->grid);
- evas_object_show(tb->grid);
- next = elm_gengrid_first_item_get(tb->grid);
- }
- snprintf(pattern, PATH_MAX, "*%s*", search_text);
- EINA_LIST_FOREACH(sel, l, o)
- {
- elm_gengrid_item_selected_set(o, EINA_FALSE);
- }
- eina_list_free(sel);
- found = elm_gengrid_search_by_text_item_get(tb->grid, next, NULL, pattern,
- ELM_GLOB_MATCH_NOCASE);
- while (found)
- {
- results = eina_list_append(results, found);
- if (found == elm_gengrid_last_item_get(tb->grid))
- break;
- next = elm_gengrid_item_next_get(found);
- found = elm_gengrid_search_by_text_item_get(tb->grid, next, NULL,
- pattern, ELM_GLOB_MATCH_NOCASE);
- }
- tb->original_grid = tb->grid;
- elm_box_unpack(tb->gridbox, tb->original_grid);
- evas_object_hide(tb->original_grid);
-
- tb->grid = elm_gengrid_add(tb->gridbox);
- evas_object_size_hint_weight_set(tb->grid, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_gengrid_align_set(tb->grid, 0.5, 0.0);
- elm_gengrid_multi_select_set(tb->grid, EINA_TRUE);
- elm_gengrid_multi_select_mode_set(tb->grid,
- ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT);
- elm_scroller_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE);
- evas_object_smart_callback_add(tb->grid, "activated",
- _ephoto_thumb_activated, tb);
- evas_object_event_callback_add(tb->grid, EVAS_CALLBACK_MOUSE_UP,
- _grid_mouse_up_cb, tb);
- elm_drag_item_container_add(tb->grid, ANIM_TIME, DRAG_TIMEOUT,
- _dnd_item_get, _dnd_item_data_get);
- evas_object_data_set(tb->grid, "thumb_browser", tb);
- _zoom_set(tb, tb->ephoto->config->thumb_size);
- elm_box_pack_end(tb->gridbox, tb->grid);
- evas_object_show(tb->grid);
-
- if (!tb->ephoto->config->fsel_hide)
- elm_table_pack(tb->table, tb->gridbox, 1, 0, 4, 1);
- else
- elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
- if (tb->searchentries)
- eina_list_free(tb->searchentries);
- tb->searchentries = NULL;
- if (results)
- {
- tb->totimages = 0;
- tb->totsize = 0;
- EINA_LIST_FOREACH(results, l, o)
- {
- const Elm_Gengrid_Item_Class *ic = NULL;
- Ephoto_Entry *entry = NULL, *e = NULL;
-
- ic = &_ephoto_thumb_file_class;
- entry = elm_object_item_data_get(o);
- e = ephoto_entry_new(tb->ephoto, entry->path, entry->label,
- EINA_FILE_REG);
- if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING)
- e->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, e,
- _entry_cmp_grid_alpha_asc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING)
- e->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, e,
- _entry_cmp_grid_alpha_desc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING)
- e->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, e,
- _entry_cmp_grid_mod_asc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING)
- e->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, e,
- _entry_cmp_grid_mod_desc, NULL, NULL);
- if (e->item)
- {
- Eina_File *f;
- elm_object_item_data_set(e->item, e);
- tb->totimages++;
- f = eina_file_open(e->path, EINA_FALSE);
- tb->totsize += (double) eina_file_size_get(f);
- eina_file_close(f);
- tb->searchentries = eina_list_append(tb->searchentries, e);
- }
- else
- {
- ephoto_entry_free(tb->ephoto, e);
- }
- }
- tb->entries = tb->searchentries;
- _update_info_label(tb);
- eina_list_free(results);
- }
- else
- {
- tb->totimages = 0;
- tb->totsize = 0;
- _update_info_label(tb);
- tb->searchentries = NULL;
- tb->entries = NULL;
- }
-}
-
-static void
-_ephoto_search_cancel(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Evas_Object *search = data;
- if (!search)
- return;
- Evas_Object *hbox = evas_object_data_get(search, "parent");
- Ephoto_Thumb_Browser *tb = evas_object_data_get(search, "thumb_browser");
-
- tb->entries = tb->ephoto->entries;
- if (tb->ephoto->searchentries)
- eina_list_free(tb->ephoto->searchentries);
- if (tb->searchentries)
- eina_list_free(tb->searchentries);
- tb->ephoto->searchentries = NULL;
- tb->searchentries = NULL;
- if (tb->original_grid)
- {
- elm_gengrid_clear(tb->grid);
- elm_box_unpack(tb->gridbox, tb->grid);
- evas_object_del(tb->grid);
- tb->grid = tb->original_grid;
- elm_box_pack_end(tb->gridbox, tb->grid);
- evas_object_show(tb->grid);
- tb->original_grid = NULL;
- tb->totimages = tb->totimages_old;
- tb->totsize = tb->totsize_old;
- }
- if (!tb->ephoto->entries)
- {
- tb->totimages = 0;
- tb->totsize = 0;
- }
+ evas_object_del(obj);
elm_object_focus_set(tb->main, EINA_TRUE);
- evas_object_del(tb->search);
- tb->search = NULL;
- elm_box_unpack(tb->gridbox, hbox);
- evas_object_del(hbox);
- tb->searching = 0;
- _update_info_label(tb);
- tb->totimages_old = 0;
- tb->totsize_old = 0;
}
static void
-_ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info)
+_menu_empty_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
- Eina_List *selected, *s;
+ Eina_List *paths = NULL;
Elm_Object_Item *item;
- Elm_Object_Item *it = event_info;
- Ephoto_Entry *e = elm_object_item_data_get(it);
-
- elm_gengrid_item_selected_set(it, EINA_TRUE);
- selected =
- eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
- if (eina_list_count(selected) <= 1 && tb->searchentries)
+ Ephoto_Entry *file;
+ item = elm_gengrid_first_item_get(tb->grid);
+ while (item)
{
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
+ file = elm_object_item_data_get(item);
+ paths = eina_list_append(paths, strdup(file->path));
+ item = elm_gengrid_item_next_get(item);
}
- else if (eina_list_count(selected) > 1)
+ item = elm_genlist_first_item_get(tb->fsel);
+ while (item)
{
- EINA_LIST_FOREACH(selected, s, item)
- {
- elm_gengrid_item_selected_set(item, EINA_TRUE);
- tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
- elm_object_item_data_get(item));
- }
+ file = elm_object_item_data_get(item);
+ paths = eina_list_append(paths, strdup(file->path));
+ item = elm_genlist_item_next_get(item);
}
- else
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- if (tb->ephoto->searchentries)
- eina_list_free(tb->ephoto->searchentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = NULL;
- }
- evas_object_smart_callback_call(tb->main, "view", e);
- if (selected)
- eina_list_free(selected);
-}
-
-static void
-_zoom_set(Ephoto_Thumb_Browser *tb, int zoom)
-{
- double scale = elm_config_scale_get();
-
- if (zoom > ZOOM_MAX)
- zoom = ZOOM_MAX;
- else if (zoom < ZOOM_MIN)
- zoom = ZOOM_MIN;
- ephoto_thumb_size_set(tb->ephoto, zoom);
- elm_gengrid_item_size_set(tb->grid, zoom * scale, zoom * scale);
-}
-
-static void
-_zoom_in(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
-
- _zoom_set(tb, zoom);
-}
-
-static void
-_zoom_out(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
-
- _zoom_set(tb, zoom);
-}
-
-static void
-_search(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Evas_Object *hbox, *search;
-
- if (tb->processing)
+ if (eina_list_count(paths) <= 0)
return;
- if (!tb->searching)
- tb->searching = 1;
- else
- {
- _ephoto_search_cancel(tb->search, NULL, NULL);
- return;
- }
- hbox = elm_box_add(tb->gridbox);
- elm_box_horizontal_set(hbox, EINA_TRUE);
- evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_start(tb->gridbox, hbox);
- evas_object_show(hbox);
-
- search = elm_entry_add(hbox);
- elm_entry_single_line_set(search, EINA_TRUE);
- elm_entry_scrollable_set(search, EINA_TRUE);
- elm_object_part_text_set(search, "guide", _("Search"));
- elm_scroller_policy_set(search, ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_OFF);
- evas_object_size_hint_weight_set(search, EVAS_HINT_EXPAND,
- EVAS_HINT_FILL);
- evas_object_size_hint_align_set(search, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- evas_object_data_set(search, "thumb_browser", tb);
- evas_object_data_set(search, "parent", hbox);
- evas_object_smart_callback_add(search, "activated",
- _ephoto_search_go, search);
- elm_box_pack_end(hbox, search);
- evas_object_show(search);
-
- tb->search = search;
- tb->totimages_old = tb->totimages;
- tb->totsize_old = tb->totsize;
-
- elm_object_focus_set(search, EINA_TRUE);
-}
-
-static void
-_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Eina_List *selected, *s;
- Elm_Object_Item *item;
- Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
- Ephoto_Entry *entry;
-
- if (it)
- entry = elm_object_item_data_get(it);
- else
- entry = eina_list_nth(tb->entries, 0);
- if (!entry)
- return;
- selected =
- eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
- if (eina_list_count(selected) <= 1 && tb->searchentries)
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
- }
- else if (eina_list_count(selected) > 1)
- {
- EINA_LIST_FOREACH(selected, s, item)
- {
- tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
- elm_object_item_data_get(item));
- }
- }
- else
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- if (tb->ephoto->searchentries)
- eina_list_free(tb->ephoto->searchentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = NULL;
- }
- evas_object_smart_callback_call(tb->main, "slideshow", entry);
- if (selected)
- eina_list_free(selected);
-}
-
-static void
-_settings(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- ephoto_config_main(tb->ephoto);
-}
-
-static void
-_ephoto_dir_show_folders(void *data, Evas_Object *obj,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- evas_object_show(tb->leftbox);
- elm_table_pack(tb->table, tb->leftbox, 0, 0, 1, 1);
- elm_table_unpack(tb->table, tb->nolabel);
- elm_table_pack(tb->table, tb->nolabel, 1, 0, 4, 1);
- elm_table_unpack(tb->table, tb->gridbox);
- elm_table_pack(tb->table, tb->gridbox, 1, 0, 4, 1);
- tb->ephoto->config->fsel_hide = 0;
- evas_object_smart_callback_del(obj, "changed", _ephoto_dir_show_folders);
- evas_object_smart_callback_add(obj, "changed", _ephoto_dir_hide_folders, tb);
-}
-
-static void
-_ephoto_dir_hide_folders(void *data, Evas_Object *obj,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- evas_object_hide(tb->leftbox);
- elm_table_unpack(tb->table, tb->leftbox);
- elm_table_unpack(tb->table, tb->nolabel);
- elm_table_pack(tb->table, tb->nolabel, 0, 0, 5, 1);
- elm_table_unpack(tb->table, tb->gridbox);
- elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
- elm_object_focus_set(tb->main, EINA_TRUE);
- tb->ephoto->config->fsel_hide = 1;
- evas_object_smart_callback_del(obj, "changed", _ephoto_dir_hide_folders);
- evas_object_smart_callback_add(obj, "changed", _ephoto_dir_show_folders, tb);
+ ephoto_file_empty_trash(tb->ephoto, paths);
}
static char *
@@ -1456,6 +421,278 @@ _dnd_item_data_get(Evas_Object *obj, Elm_Object_Item *it,
return EINA_FALSE;
}
+/*File Pane Callbacks*/
+static void
+_on_list_expand_req(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *it = event_info;
+
+ ecore_job_del(tb->change_dir_job);
+ tb->change_dir_job = NULL;
+ ecore_timer_del(tb->click_timer);
+ tb->click_timer = NULL;
+ elm_genlist_item_expanded_set(it, EINA_TRUE);
+}
+
+static void
+_on_list_contract_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *it = event_info;
+
+ ecore_job_del(tb->change_dir_job);
+ tb->change_dir_job = NULL;
+ ecore_timer_del(tb->click_timer);
+ tb->click_timer = NULL;
+ elm_genlist_item_expanded_set(it, EINA_FALSE);
+}
+
+static void
+_on_list_expanded(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *it = event_info;
+ Ephoto_Entry *entry;
+ const char *path;
+
+ entry = elm_object_item_data_get(it);
+ path = entry->path;
+ tb->dirs_only = 0;
+ if (!strcmp(path, tb->ephoto->config->directory))
+ tb->dirs_only = 1;
+ else
+ tb->dirs_only = 0;
+ tb->thumbs_only = 0;
+ ephoto_directory_set(tb->ephoto, path, it, tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
+}
+
+static void
+_on_list_contracted(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *it = event_info;
+ Ephoto_Entry *entry;
+ const char *path;
+
+ entry = elm_object_item_data_get(it);
+ path = entry->path;
+ elm_genlist_item_subitems_clear(it);
+ if (!strcmp(path, tb->ephoto->config->directory))
+ return;
+ tb->thumbs_only = 1;
+ tb->dirs_only = 0;
+ ephoto_directory_set(tb->ephoto, path, NULL,
+ tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto,
+ tb->ephoto->config->directory);
+}
+
+static void
+_dir_job(void *data)
+{
+ Elm_Object_Item *it = data;
+ Ephoto_Thumb_Browser *tb = evas_object_data_get(it, "thumb_browser");
+ Ephoto_Entry *entry;
+ const char *path;
+
+ entry = elm_object_item_data_get(it);
+ path = entry->path;
+ tb->change_dir_job = NULL;
+ tb->thumbs_only = 1;
+ tb->dirs_only = 0;
+ ephoto_directory_set(tb->ephoto, path, NULL,
+ tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
+}
+
+static void
+_wait_job(void *data)
+{
+ Elm_Object_Item *it = data;
+ Ephoto_Thumb_Browser *tb = evas_object_data_get(it, "thumb_browser");
+
+ if (tb->change_dir_job)
+ ecore_job_del(tb->change_dir_job);
+ tb->change_dir_job = ecore_job_add(_dir_job, it);
+}
+
+static void
+_on_list_selected(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *it = event_info;
+
+ evas_object_data_set(it, "thumb_browser", tb);
+ if (!tb->dragging)
+ {
+ tb->dir_current = it;
+
+ ecore_job_add(_wait_job, it);
+ }
+}
+
+static char *
+_dir_item_text_get(void *data, Evas_Object *obj EINA_UNUSED,
+ const char *part EINA_UNUSED)
+{
+ Ephoto_Entry *e = data;
+
+ return strdup(e->label);
+}
+
+static Evas_Object *
+_dir_item_icon_get(void *data EINA_UNUSED, Evas_Object *obj,
+ const char *part)
+{
+ if (!strcmp(part, "elm.swallow.end"))
+ return NULL;
+ Evas_Object *ic = elm_icon_add(obj);
+
+ elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
+ elm_icon_standard_set(ic, "folder");
+ return ic;
+}
+
+static void
+_dir_item_del(void *data, Evas_Object *obj EINA_UNUSED)
+{
+ Ephoto_Entry *e = data;
+
+ if (!e->no_delete)
+ ephoto_entry_free(e->ephoto, e);
+}
+
+static Eina_Bool
+_check_for_subdirs(Ephoto_Entry *entry)
+{
+ Eina_Iterator *ls = eina_file_direct_ls(entry->path);
+ Eina_File_Direct_Info *info;
+
+ if (!ls)
+ return EINA_FALSE;
+ EINA_ITERATOR_FOREACH(ls, info)
+ {
+ if (info->type == EINA_FILE_DIR)
+ {
+ eina_iterator_free(ls);
+ return EINA_TRUE;
+ }
+ }
+ eina_iterator_free(ls);
+ return EINA_FALSE;
+}
+
+static void
+_dir_go_home(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ elm_genlist_clear(tb->fsel);
+ tb->thumbs_only = 0;
+ tb->dirs_only = 0;
+ ephoto_directory_set(tb->ephoto, getenv("HOME"), NULL,
+ tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
+ ephoto_thumb_browser_top_dir_set(tb->ephoto, tb->ephoto->config->directory);
+}
+
+static void
+_dir_go_up(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ if (strcmp(tb->ephoto->config->directory, "/"))
+ {
+ char path[PATH_MAX];
+ Elm_Object_Item *it, *next;
+ Ephoto_Entry *e;
+
+ snprintf(path, PATH_MAX, "%s", tb->ephoto->config->directory);
+ it = elm_genlist_first_item_get(tb->fsel);
+ while (it)
+ {
+ e = elm_object_item_data_get(it);
+ if (!strcmp(e->path, path))
+ {
+ if (e->parent)
+ {
+ elm_genlist_item_expanded_set(e->parent, EINA_FALSE);
+ return;
+ }
+ }
+ next = elm_genlist_item_next_get(it);
+ it = next;
+ }
+ elm_genlist_clear(tb->fsel);
+ tb->thumbs_only = 0;
+ tb->dirs_only = 0;
+ ephoto_directory_set(tb->ephoto, ecore_file_dir_get(path), NULL,
+ tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
+ ephoto_thumb_browser_top_dir_set(tb->ephoto,
+ tb->ephoto->config->directory);
+ }
+}
+
+static void
+_dir_go_trash(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ char path[PATH_MAX];
+
+ snprintf(path, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
+ if (!ecore_file_exists(path))
+ ecore_file_mkpath(path);
+ elm_genlist_clear(tb->fsel);
+ tb->thumbs_only = 0;
+ tb->dirs_only = 0;
+ ephoto_directory_set(tb->ephoto, path, NULL,
+ tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto, _("Trash"));
+ ephoto_thumb_browser_top_dir_set(tb->ephoto, tb->ephoto->config->directory);
+}
+
+static void
+_dir_go_entry(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ const char *dir;
+ Ephoto_Thumb_Browser *tb = data;
+
+ dir = elm_object_text_get(tb->direntry);
+ if (ecore_file_is_dir(dir))
+ {
+ elm_genlist_clear(tb->fsel);
+ tb->thumbs_only = 0;
+ tb->dirs_only = 0;
+ ephoto_directory_set(tb->ephoto, dir, NULL,
+ tb->dirs_only, tb->thumbs_only);
+ ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
+ ephoto_thumb_browser_top_dir_set(tb->ephoto,
+ tb->ephoto->config->directory);
+ }
+}
+
+static Eina_Bool
+_click_timer_cb(void *data)
+{
+ Elm_Object_Item *item = data;
+ Ephoto_Thumb_Browser *tb = evas_object_data_get(item, "thumb_browser");
+
+ _on_list_selected(tb, NULL, item);
+ tb->click_timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
static void
_fsel_menu_new_dir_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@@ -1477,6 +714,524 @@ _fsel_menu_new_dir_cb(void *data, Evas_Object *obj EINA_UNUSED,
ephoto_file_new_dir(tb->ephoto, path);
}
+static void
+_fsel_menu_paste_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *item = elm_genlist_selected_item_get(tb->fsel);
+ Ephoto_Entry *entry;
+ const char *path;
+
+ if (item)
+ {
+ entry = elm_object_item_data_get(item);
+ path = entry->path;
+ }
+ else
+ path = tb->ephoto->config->directory;
+
+ if (eina_list_count(tb->cut_items) > 0)
+ {
+ ephoto_file_paste(tb->ephoto, eina_list_clone(tb->cut_items), EINA_FALSE, path);
+ eina_list_free(tb->cut_items);
+ tb->cut_items = NULL;
+ }
+ else if (eina_list_count(tb->copy_items) > 0)
+ {
+ ephoto_file_paste(tb->ephoto, eina_list_clone(tb->copy_items), EINA_TRUE, path);
+ eina_list_free(tb->copy_items);
+ tb->copy_items = NULL;
+ }
+}
+
+static void
+_fsel_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *item = elm_genlist_selected_item_get(tb->fsel);
+ Ephoto_Entry *entry;
+ const char *path;
+
+ if (!item)
+ return;
+ entry = elm_object_item_data_get(item);
+ path = entry->path;
+ if (!path)
+ return;
+ ephoto_file_rename(tb->ephoto, path);
+}
+
+static void
+_fsel_menu_delete_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Elm_Object_Item *item = elm_genlist_selected_item_get(tb->fsel);
+ Ephoto_Entry *entry;
+ Eina_List *files = NULL;
+ const char *path;
+
+ if (!item)
+ return;
+ entry = elm_object_item_data_get(item);
+ path = entry->path;
+ if (!path)
+ return;
+ files = eina_list_append(files, path);
+ ephoto_file_delete(tb->ephoto, files, EINA_FILE_DIR);
+}
+
+static void
+_fsel_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Evas_Object *menu;
+ Elm_Object_Item *item, *menu_it;
+ Evas_Event_Mouse_Up *info = event_info;
+ char trash[PATH_MAX];
+ Evas_Coord x, y;
+
+ evas_pointer_canvas_xy_get(evas_object_evas_get(tb->fsel), &x, &y);
+ item = elm_genlist_at_xy_item_get(tb->fsel, x, y, 0);
+
+ if (info->button == 1 && item)
+ {
+ if (info->flags == EVAS_BUTTON_DOUBLE_CLICK)
+ {
+ if (elm_genlist_item_type_get(item) == ELM_GENLIST_ITEM_TREE)
+ {
+ if (tb->click_timer)
+ {
+ ecore_timer_del(tb->click_timer);
+ tb->click_timer = NULL;
+ elm_genlist_item_expanded_set(item,
+ !elm_genlist_item_expanded_get(item));
+ }
+ }
+ }
+ else
+ {
+ evas_object_data_set(item, "thumb_browser", tb);
+ if (elm_genlist_item_type_get(item) == ELM_GENLIST_ITEM_TREE)
+ tb->click_timer = ecore_timer_add(.3, _click_timer_cb, item);
+ else
+ _on_list_selected(tb, NULL, item);
+ }
+ }
+ else if (!item)
+ {
+ Elm_Object_Item *it;
+
+ it = elm_genlist_selected_item_get(tb->fsel);
+ if (it)
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+ ephoto_directory_set(tb->ephoto, tb->ephoto->top_directory, NULL, 0, 1);
+ }
+
+ if (info->button != 3)
+ return;
+
+ snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
+
+ if (item)
+ elm_genlist_item_selected_set(item, EINA_TRUE);
+ menu = elm_menu_add(tb->ephoto->win);
+ elm_menu_move(menu, x, y);
+ menu_it = elm_menu_item_add(menu, NULL, "document-properties", _("Edit"),
+ NULL, NULL);
+ elm_menu_item_separator_add(menu, NULL);
+ if (strcmp(tb->ephoto->config->directory, trash))
+ {
+ elm_menu_item_add(menu, menu_it, "folder-new", _("New Folder"),
+ _fsel_menu_new_dir_cb, tb);
+ }
+ if (item)
+ {
+ evas_object_data_set(item, "thumb_browser", tb);
+ elm_menu_item_add(menu, menu_it, "edit", _("Rename"),
+ _fsel_menu_rename_cb, item);
+ }
+ if (tb->cut_items || tb->copy_items)
+ {
+ elm_menu_item_add(menu, menu_it, "edit-paste", _("Paste"),
+ _fsel_menu_paste_cb, tb);
+ }
+ if (!strcmp(tb->ephoto->config->directory, trash) &&
+ elm_gengrid_first_item_get(tb->grid))
+ {
+ elm_menu_item_add(menu, menu_it, "edit-delete", _("Empty Trash"),
+ _menu_empty_cb, tb);
+ }
+ else if (!strcmp(tb->ephoto->config->directory, trash) &&
+ elm_genlist_first_item_get(tb->fsel))
+ {
+ elm_menu_item_add(menu, menu_it, "edit-delete", _("Empty Trash"),
+ _menu_empty_cb, tb);
+ }
+ if (strcmp(tb->ephoto->config->directory, trash) && item)
+ {
+ elm_menu_item_add(menu, menu_it, "edit-delete", _("Delete"),
+ _fsel_menu_delete_cb, tb);
+ }
+ if (strcmp(tb->ephoto->config->directory, trash) &&
+ elm_gengrid_first_item_get(tb->grid))
+ {
+ elm_menu_item_add(menu, NULL, "media-playback-start", _("Slideshow"),
+ _ephoto_show_slideshow, tb);
+ }
+ elm_menu_item_add(menu, NULL, "preferences-system", _("Settings"),
+ _ephoto_show_settings, tb);
+ evas_object_smart_callback_add(menu, "dismissed", _menu_dismissed_cb,
+ tb);
+ evas_object_show(menu);
+}
+
+/*File Pane Functions*/
+static void
+_ephoto_dir_show_folders(void *data, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ // evas_object_show(tb->leftbox);
+ elm_panes_content_left_min_size_set(tb->panes, 100);
+ elm_panes_content_left_size_set(tb->panes, tb->ephoto->config->lpane_size);
+ tb->ephoto->config->fsel_hide = 0;
+ evas_object_smart_callback_del(obj, "changed", _ephoto_dir_show_folders);
+ evas_object_smart_callback_add(obj, "changed", _ephoto_dir_hide_folders, tb);
+}
+
+static void
+_ephoto_dir_hide_folders(void *data, Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ //evas_object_hide(tb->leftbox);
+ elm_panes_content_left_min_size_set(tb->panes, 0);
+ elm_panes_content_left_size_set(tb->panes, 0.0);
+ tb->ephoto->config->fsel_hide = 1;
+ evas_object_smart_callback_del(obj, "changed", _ephoto_dir_hide_folders);
+ evas_object_smart_callback_add(obj, "changed", _ephoto_dir_show_folders, tb);
+}
+
+void
+_ephoto_file_pane_add(Ephoto_Thumb_Browser *tb)
+{
+ Evas_Object *hbox, *but, *ic;
+
+ tb->leftbox = elm_box_add(tb->panes);
+ elm_box_horizontal_set(tb->leftbox, EINA_FALSE);
+ elm_box_homogeneous_set(tb->leftbox, EINA_FALSE);
+ evas_object_size_hint_weight_set(tb->leftbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(tb->leftbox,
+ EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ hbox = elm_box_add(tb->leftbox);
+ elm_box_horizontal_set(hbox, EINA_TRUE);
+ elm_box_homogeneous_set(hbox, EINA_TRUE);
+ evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(tb->leftbox, hbox);
+ evas_object_show(hbox);
+
+ ic = elm_icon_add(hbox);
+ elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
+ elm_icon_standard_set(ic, "go-up");
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ but = elm_button_add(hbox);
+ elm_object_part_content_set(but, "icon", ic);
+ elm_object_text_set(but, _("Up"));
+ evas_object_size_hint_weight_set(but, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(but, "clicked", _dir_go_up, tb);
+ elm_box_pack_end(hbox, but);
+ evas_object_show(but);
+
+ ic = elm_icon_add(hbox);
+ elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
+ elm_icon_standard_set(ic, "go-home");
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ but = elm_button_add(hbox);
+ elm_object_part_content_set(but, "icon", ic);
+ elm_object_text_set(but, _("Home"));
+ evas_object_size_hint_weight_set(but, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(but, "clicked", _dir_go_home, tb);
+ elm_box_pack_end(hbox, but);
+ evas_object_show(but);
+
+ ic = elm_icon_add(hbox);
+ elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
+ elm_icon_standard_set(ic, "user-trash");
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ but = elm_button_add(hbox);
+ elm_object_part_content_set(but, "icon", ic);
+ elm_object_text_set(but, _("Trash"));
+ evas_object_size_hint_weight_set(but, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(but, "clicked", _dir_go_trash, tb);
+ elm_box_pack_end(hbox, but);
+ evas_object_show(but);
+
+ tb->direntry = elm_entry_add(tb->main);
+ elm_entry_single_line_set(tb->direntry, EINA_TRUE);
+ elm_entry_scrollable_set(tb->direntry, EINA_TRUE);
+ elm_scroller_policy_set(tb->direntry, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
+ evas_object_size_hint_weight_set(tb->direntry, EVAS_HINT_EXPAND,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_align_set(tb->direntry, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_smart_callback_add(tb->direntry, "activated",
+ _dir_go_entry, tb);
+ elm_box_pack_end(tb->leftbox, tb->direntry);
+ evas_object_show(tb->direntry);
+
+ tb->fsel = elm_genlist_add(tb->leftbox);
+ elm_genlist_homogeneous_set(tb->fsel, EINA_TRUE);
+ elm_genlist_select_mode_set(tb->fsel, ELM_OBJECT_SELECT_MODE_ALWAYS);
+ evas_object_size_hint_weight_set(tb->fsel, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(tb->fsel, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(tb->fsel, "expand,request",
+ _on_list_expand_req, tb);
+ evas_object_smart_callback_add(tb->fsel, "contract,request",
+ _on_list_contract_req, tb);
+ evas_object_smart_callback_add(tb->fsel, "expanded", _on_list_expanded, tb);
+ evas_object_smart_callback_add(tb->fsel, "contracted", _on_list_contracted,
+ tb);
+ evas_object_event_callback_add(tb->fsel, EVAS_CALLBACK_MOUSE_UP,
+ _fsel_mouse_up_cb, tb);
+ evas_object_data_set(tb->fsel, "thumb_browser", tb);
+ elm_box_pack_end(tb->leftbox, tb->fsel);
+ evas_object_show(tb->fsel);
+
+ elm_drop_item_container_add(tb->fsel, ELM_SEL_FORMAT_TARGETS,
+ _drop_item_getcb, _drop_enter, tb, _drop_leave, tb, _drop_pos, tb,
+ _drop_dropcb, NULL);
+
+ evas_object_raise(hbox);
+ evas_object_raise(tb->direntry);
+}
+
+/*Thumb Pane Callbacks*/
+static char *
+_thumb_item_text_get(void *data, Evas_Object *obj EINA_UNUSED,
+ const char *part EINA_UNUSED)
+{
+ Ephoto_Entry *e = data;
+
+ return strdup(e->label);
+}
+
+static Evas_Object *
+_thumb_file_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ Ephoto_Entry *e = data;
+ Evas_Object *thumb = NULL;
+
+ if (strcmp(part, "elm.swallow.icon"))
+ return NULL;
+
+ if (e)
+ {
+ thumb = ephoto_thumb_add(e->ephoto, obj, e->path);
+ evas_object_show(thumb);
+ }
+ return thumb;
+}
+
+static void
+_thumb_item_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
+{
+ /* The entry is already freed when changing directories. */
+}
+
+static int
+_entry_cmp(const void *pa, const void *pb)
+{
+ const Ephoto_Entry *a, *b;
+
+ a = elm_object_item_data_get(pa);
+ b = elm_object_item_data_get(pb);
+
+ return strcasecmp(a->basename, b->basename);
+}
+
+static int
+_entry_cmp_grid_alpha_asc(const void *pa, const void *pb)
+{
+ const Ephoto_Entry *a, *b;
+
+ a = elm_object_item_data_get(pa);
+ b = elm_object_item_data_get(pb);
+
+ return strcasecmp(a->basename, b->basename);
+}
+
+static int
+_entry_cmp_grid_alpha_desc(const void *pa, const void *pb)
+{
+ const Ephoto_Entry *a, *b;
+ int i;
+
+ a = elm_object_item_data_get(pa);
+ b = elm_object_item_data_get(pb);
+ i = strcasecmp(a->basename, b->basename);
+ if (i < 0)
+ i = 1;
+ else if (i > 0)
+ i = -1;
+
+ return i;
+}
+
+static int
+_entry_cmp_grid_mod_asc(const void *pa, const void *pb)
+{
+ const Ephoto_Entry *a, *b;
+ long long moda, modb;
+
+ a = elm_object_item_data_get(pa);
+ b = elm_object_item_data_get(pb);
+
+ moda = ecore_file_mod_time(a->path);
+ modb = ecore_file_mod_time(b->path);
+
+ if (moda < modb)
+ return -1;
+ else if (moda > modb)
+ return 1;
+ else
+ return strcasecmp(a->basename, b->basename);
+}
+
+static int
+_entry_cmp_grid_mod_desc(const void *pa, const void *pb)
+{
+ const Ephoto_Entry *a, *b;
+ long long moda, modb;
+
+ a = elm_object_item_data_get(pa);
+ b = elm_object_item_data_get(pb);
+
+ moda = ecore_file_mod_time(a->path);
+ modb = ecore_file_mod_time(b->path);
+
+ if (moda < modb)
+ return 1;
+ else if (moda > modb)
+ return -1;
+ else
+ {
+ int i;
+
+ i = strcasecmp(a->basename, b->basename);
+ if (i < 0)
+ i = 1;
+ else if (i > 0)
+ i = -1;
+ return i;
+ }
+}
+
+static void
+_sort_alpha_asc(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_data EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Evas_Object *ic;
+
+ tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
+ tb->thumbs_only = 1;
+ tb->dirs_only = 0;
+ ic = elm_icon_add(tb->hover);
+ elm_icon_standard_set(ic, "view-sort-ascending");
+ elm_object_part_content_set(tb->hover, "icon", ic);
+ evas_object_show(ic);
+ ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
+ NULL, tb->dirs_only, tb->thumbs_only);
+}
+
+static void
+_sort_alpha_desc(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_data EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Evas_Object *ic;
+
+ tb->sort = EPHOTO_SORT_ALPHABETICAL_DESCENDING;
+ tb->thumbs_only = 1;
+ tb->dirs_only = 0;
+ ic = elm_icon_add(tb->hover);
+ elm_icon_standard_set(ic, "view-sort-descending");
+ elm_object_part_content_set(tb->hover, "icon", ic);
+ evas_object_show(ic);
+ ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
+ NULL, tb->dirs_only, tb->thumbs_only);
+}
+
+static void
+_sort_mod_asc(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_data EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Evas_Object *ic;
+
+ tb->sort = EPHOTO_SORT_MODTIME_ASCENDING;
+ tb->thumbs_only = 1;
+ tb->dirs_only = 0;
+ ic = elm_icon_add(tb->hover);
+ elm_icon_standard_set(ic, "view-sort-ascending");
+ elm_object_part_content_set(tb->hover, "icon", ic);
+ evas_object_show(ic);
+ ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
+ NULL, tb->dirs_only, tb->thumbs_only);
+}
+
+static void
+_sort_mod_desc(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_data EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Evas_Object *ic;
+
+ tb->sort = EPHOTO_SORT_MODTIME_DESCENDING;
+ tb->thumbs_only = 1;
+ tb->dirs_only = 0;
+ ic = elm_icon_add(tb->hover);
+ elm_icon_standard_set(ic, "view-sort-descending");
+ elm_object_part_content_set(tb->hover, "icon", ic);
+ evas_object_show(ic);
+ ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
+ NULL, tb->dirs_only, tb->thumbs_only);
+}
+
+static void
+_zoom_in(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
+
+ _ephoto_thumb_zoom_set(tb, zoom);
+}
+
+static void
+_zoom_out(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
+
+ _ephoto_thumb_zoom_set(tb, zoom);
+}
+
static void
_grid_menu_select_all_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@@ -1571,37 +1326,6 @@ _grid_menu_copy_cb(void *data, Evas_Object *obj EINA_UNUSED,
eina_list_free(selection);
}
-static void
-_fsel_menu_paste_cb(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *item = elm_genlist_selected_item_get(tb->fsel);
- Ephoto_Entry *entry;
- const char *path;
-
- if (item)
- {
- entry = elm_object_item_data_get(item);
- path = entry->path;
- }
- else
- path = tb->ephoto->config->directory;
-
- if (eina_list_count(tb->cut_items) > 0)
- {
- ephoto_file_paste(tb->ephoto, eina_list_clone(tb->cut_items), EINA_FALSE, path);
- eina_list_free(tb->cut_items);
- tb->cut_items = NULL;
- }
- else if (eina_list_count(tb->copy_items) > 0)
- {
- ephoto_file_paste(tb->ephoto, eina_list_clone(tb->copy_items), EINA_TRUE, path);
- eina_list_free(tb->copy_items);
- tb->copy_items = NULL;
- }
-}
-
static void
_grid_menu_paste_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@@ -1624,24 +1348,6 @@ _grid_menu_paste_cb(void *data, Evas_Object *obj EINA_UNUSED,
}
}
-static void
-_fsel_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *item = elm_genlist_selected_item_get(tb->fsel);
- Ephoto_Entry *entry;
- const char *path;
-
- if (!item)
- return;
- entry = elm_object_item_data_get(item);
- path = entry->path;
- if (!path)
- return;
- ephoto_file_rename(tb->ephoto, path);
-}
-
static void
_grid_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@@ -1655,26 +1361,6 @@ _grid_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_data_del(item, "thumb_browser");
}
-static void
-_fsel_menu_delete_cb(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Elm_Object_Item *item = elm_genlist_selected_item_get(tb->fsel);
- Ephoto_Entry *entry;
- Eina_List *files = NULL;
- const char *path;
-
- if (!item)
- return;
- entry = elm_object_item_data_get(item);
- path = entry->path;
- if (!path)
- return;
- files = eina_list_append(files, path);
- ephoto_file_delete(tb->ephoto, files, EINA_FILE_DIR);
-}
-
static void
_grid_menu_delete_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@@ -1699,161 +1385,6 @@ _grid_menu_delete_cb(void *data, Evas_Object *obj EINA_UNUSED,
eina_list_free(selection);
}
-static void
-_grid_menu_empty_cb(void *data, Evas_Object *obj EINA_UNUSED,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
- Eina_List *paths = NULL;
- Elm_Object_Item *item;
- Ephoto_Entry *file;
- item = elm_gengrid_first_item_get(tb->grid);
- while (item)
- {
- file = elm_object_item_data_get(item);
- paths = eina_list_append(paths, strdup(file->path));
- item = elm_gengrid_item_next_get(item);
- }
- item = elm_genlist_first_item_get(tb->fsel);
- while (item)
- {
- file = elm_object_item_data_get(item);
- paths = eina_list_append(paths, strdup(file->path));
- item = elm_genlist_item_next_get(item);
- }
- if (eina_list_count(paths) <= 0)
- return;
- ephoto_file_empty_trash(tb->ephoto, paths);
-}
-
-static void
-_menu_dismissed_cb(void *data, Evas_Object *obj,
- void *event_info EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- evas_object_del(obj);
- elm_object_focus_set(tb->main, EINA_TRUE);
-}
-
-static Eina_Bool
-_click_timer_cb(void *data)
-{
- Elm_Object_Item *item = data;
- Ephoto_Thumb_Browser *tb = evas_object_data_get(item, "thumb_browser");
-
- _on_list_selected(tb, NULL, item);
- tb->click_timer = NULL;
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void
-_fsel_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
- Evas_Object *obj EINA_UNUSED, void *event_info)
-{
- Ephoto_Thumb_Browser *tb = data;
- Evas_Object *menu;
- Elm_Object_Item *item, *menu_it;
- Evas_Event_Mouse_Up *info = event_info;
- char trash[PATH_MAX];
- int x, y;
-
- evas_pointer_canvas_xy_get(evas_object_evas_get(tb->fsel), &x, &y);
- item = elm_genlist_at_xy_item_get(tb->fsel, x, y, 0);
-
- if (info->button == 1 && item)
- {
- if (info->flags == EVAS_BUTTON_DOUBLE_CLICK)
- {
- if (elm_genlist_item_type_get(item) == ELM_GENLIST_ITEM_TREE)
- {
- if (tb->click_timer)
- {
- ecore_timer_del(tb->click_timer);
- tb->click_timer = NULL;
- elm_genlist_item_expanded_set(item,
- !elm_genlist_item_expanded_get(item));
- }
- }
- }
- else
- {
- evas_object_data_set(item, "thumb_browser", tb);
- if (elm_genlist_item_type_get(item) == ELM_GENLIST_ITEM_TREE)
- tb->click_timer = ecore_timer_add(.3, _click_timer_cb, item);
- else
- _on_list_selected(tb, NULL, item);
- }
- }
- else if (!item)
- {
- Elm_Object_Item *it;
-
- it = elm_genlist_selected_item_get(tb->fsel);
- if (it)
- elm_genlist_item_selected_set(it, EINA_FALSE);
- ephoto_directory_set(tb->ephoto, tb->ephoto->top_directory, NULL, 0, 1);
- }
-
- if (info->button != 3)
- return;
-
- snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
-
- if (item)
- elm_genlist_item_selected_set(item, EINA_TRUE);
- menu = elm_menu_add(tb->ephoto->win);
- elm_menu_move(menu, x, y);
- menu_it = elm_menu_item_add(menu, NULL, "document-properties", _("Edit"),
- NULL, NULL);
- elm_menu_item_separator_add(menu, NULL);
- if (strcmp(tb->ephoto->config->directory, trash))
- {
- elm_menu_item_add(menu, menu_it, "folder-new", _("New Folder"),
- _fsel_menu_new_dir_cb, tb);
- }
- if (item)
- {
- evas_object_data_set(item, "thumb_browser", tb);
- elm_menu_item_add(menu, menu_it, "edit", _("Rename"),
- _fsel_menu_rename_cb, item);
- }
- if (tb->cut_items || tb->copy_items)
- {
- elm_menu_item_add(menu, menu_it, "edit-paste", _("Paste"),
- _fsel_menu_paste_cb, tb);
- }
- if (!strcmp(tb->ephoto->config->directory, trash) &&
- elm_gengrid_first_item_get(tb->grid))
- {
- elm_menu_item_add(menu, menu_it, "edit-delete", _("Empty Trash"),
- _grid_menu_empty_cb, tb);
- }
- else if (!strcmp(tb->ephoto->config->directory, trash) &&
- elm_genlist_first_item_get(tb->fsel))
- {
- elm_menu_item_add(menu, menu_it, "edit-delete", _("Empty Trash"),
- _grid_menu_empty_cb, tb);
- }
- if (strcmp(tb->ephoto->config->directory, trash) && item)
- {
- elm_menu_item_add(menu, menu_it, "edit-delete", _("Delete"),
- _fsel_menu_delete_cb, tb);
- }
- if (strcmp(tb->ephoto->config->directory, trash) &&
- elm_gengrid_first_item_get(tb->grid))
- {
- elm_menu_item_add(menu, NULL, "media-playback-start", _("Slideshow"),
- _slideshow, tb);
- }
- elm_menu_item_add(menu, NULL, "preferences-system", _("Settings"),
- _settings, tb);
- evas_object_smart_callback_add(menu, "dismissed", _menu_dismissed_cb,
- tb);
- evas_object_show(menu);
-}
-
static void
_grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED, void *event_info)
@@ -1955,7 +1486,7 @@ _grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
NULL, NULL);
elm_menu_item_separator_add(menu, NULL);
elm_menu_item_add(menu, menu_it, "system-search", _("Search"),
- _search, tb);
+ _ephoto_thumb_search_start, tb);
elm_menu_item_separator_add(menu, menu_it);
elm_menu_item_add(menu, menu_it, "edit-select-all", _("Select All"),
_grid_menu_select_all_cb, tb);
@@ -1989,7 +1520,7 @@ _grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
elm_gengrid_first_item_get(tb->grid))
{
elm_menu_item_add(menu, menu_it, "edit-delete", _("Empty Trash"),
- _grid_menu_empty_cb, tb);
+ _menu_empty_cb, tb);
}
else
{
@@ -1998,11 +1529,11 @@ _grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
elm_menu_item_add(menu, menu_it, "edit-delete", _("Delete"),
_grid_menu_delete_cb, tb);
elm_menu_item_add(menu, NULL, "media-playback-start",
- _("Slideshow"), _slideshow, tb);
+ _("Slideshow"), _ephoto_show_slideshow, tb);
}
}
elm_menu_item_add(menu, NULL, "preferences-system", _("Settings"),
- _settings, tb);
+ _ephoto_show_settings, tb);
evas_object_smart_callback_add(menu, "dismissed", _menu_dismissed_cb,
tb);
evas_object_show(menu);
@@ -2026,690 +1557,352 @@ _grid_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
}
static void
-_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+_ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info)
{
Ephoto_Thumb_Browser *tb = data;
- Evas_Event_Key_Down *ev = event_info;
- Eina_Bool ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
- Eina_Bool shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
- Eina_List *selected =
+ Eina_List *selected, *s;
+ Elm_Object_Item *item;
+ Elm_Object_Item *it = event_info;
+ Ephoto_Entry *e = elm_object_item_data_get(it);
+
+ elm_gengrid_item_selected_set(it, EINA_TRUE);
+ selected =
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
- const char *k = ev->keyname;
-
- if (ctrl)
+ if (eina_list_count(selected) <= 1 && tb->searchentries)
{
- if (shift)
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
+ }
+ else if (eina_list_count(selected) > 1)
+ {
+ EINA_LIST_FOREACH(selected, s, item)
{
- if (!strcasecmp(k, "f"))
- {
- if (evas_object_visible_get(tb->leftbox))
- _ephoto_dir_hide_folders(tb, NULL, NULL);
- else
- _ephoto_dir_show_folders(tb, NULL, NULL);
- }
- }
- else if ((!strcasecmp(k, "plus")) || (!strcasecmp(k, "equal")))
- {
- int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
-
- _zoom_set(tb, zoom);
- }
- else if ((!strcasecmp(k, "minus")) || (!strcasecmp(k, "underscore")))
- {
- int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
-
- _zoom_set(tb, zoom);
- }
- else if (!strcasecmp(k, "Tab"))
- {
- Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
- Ephoto_Entry *entry;
- Eina_List *s;
- Elm_Object_Item *item;
-
- if (it)
- entry = elm_object_item_data_get(it);
- else
- entry = eina_list_nth(tb->entries, 0);
- if (eina_list_count(selected) <= 1 && tb->searchentries)
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries =
- eina_list_clone(tb->searchentries);
- }
- else if (eina_list_count(selected) > 1)
- {
- EINA_LIST_FOREACH(selected, s, item)
- {
- tb->ephoto->selentries =
- eina_list_append(tb->ephoto->selentries,
- elm_object_item_data_get(item));
- }
- }
- else
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- if (tb->ephoto->searchentries)
- eina_list_free(tb->ephoto->searchentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = NULL;
- }
- if (entry)
- {
- evas_object_smart_callback_call(tb->main, "view", entry);
- }
- }
- else if (!strcasecmp(k, "c"))
- {
- _grid_menu_copy_cb(tb, NULL, NULL);
- }
- else if (!strcasecmp(k, "x"))
- {
- _grid_menu_cut_cb(tb, NULL, NULL);
- }
- else if (!strcasecmp(k, "v"))
- {
- _grid_menu_paste_cb(tb, NULL, NULL);
- }
- else if (!strcasecmp(k, "a"))
- {
- _grid_menu_select_all_cb(tb, NULL, NULL);
- }
- else if (!strcasecmp(k, "f") && !tb->processing)
- {
- if (tb->searching)
- _ephoto_search_cancel(tb->search, NULL, NULL);
- else
- _search(tb, NULL, NULL);
- }
- else if (!strcasecmp(k, "Delete"))
- {
- char path[PATH_MAX];
- char *trash;
-
- snprintf(path, PATH_MAX, "%s/.config/ephoto/trash",
- getenv("HOME"));
- trash = strdup(path);
- if ((strlen(trash)) == (strlen(tb->ephoto->config->directory)))
- {
- if (!strcmp(trash, tb->ephoto->config->directory))
- {
- _grid_menu_empty_cb(tb, NULL, NULL);
- free(trash);
- return;
- }
- }
- else
- _grid_menu_delete_cb(tb, NULL, NULL);
- free(trash);
+ elm_gengrid_item_selected_set(item, EINA_TRUE);
+ tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
+ elm_object_item_data_get(item));
}
}
- else if (!strcasecmp(k, "F1"))
+ else
{
- _settings(tb, NULL, NULL);
- }
- else if (!strcasecmp(k, "F2"))
- {
- Elm_Object_Item *it = NULL;
-
- it = eina_list_data_get(
- eina_list_last(selected));
- if (it)
- {
- evas_object_data_set(it, "thumb_browser", tb);
- _grid_menu_rename_cb(it, NULL, NULL);
- }
- }
- else if (!strcasecmp(k, "F5"))
- {
- Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
- Ephoto_Entry *entry;
- Eina_List *s;
- Elm_Object_Item *item;
-
- if (it)
- entry = elm_object_item_data_get(it);
- else
- entry = eina_list_nth(tb->entries, 0);
- if (eina_list_count(selected) <= 1 && tb->searchentries)
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
- }
- else if (eina_list_count(selected) > 1)
- {
- EINA_LIST_FOREACH(selected, s, item)
- {
- tb->ephoto->selentries =
- eina_list_append(tb->ephoto->selentries,
- elm_object_item_data_get(item));
- }
- }
- else
- {
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- if (tb->ephoto->searchentries)
- eina_list_free(tb->ephoto->searchentries);
- tb->ephoto->selentries = NULL;
- tb->ephoto->searchentries = NULL;
- }
- if (entry)
- evas_object_smart_callback_call(tb->main, "slideshow", entry);
- }
- else if (!strcasecmp(k, "F11"))
- {
- Evas_Object *win = tb->ephoto->win;
-
- elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
- }
- else if (!strcasecmp(k, "Escape"))
- {
- if (tb->searching)
- _ephoto_search_cancel(tb->search, NULL, NULL);
- else
- _grid_menu_clear_cb(tb, NULL, NULL);
- }
- else if (ev->compose && (((ev->compose[0] != '\\')
- && (ev->compose[0] >= ' ')) || ev->compose[1]))
- {
- if (elm_object_focus_get(tb->direntry))
- return;
- if (!tb->searching)
- {
- _search(tb, NULL, NULL);
- elm_entry_entry_append(tb->search, ev->compose);
- elm_entry_cursor_end_set(tb->search);
- }
- else if (!elm_object_focus_get(tb->search))
- {
- elm_object_focus_set(tb->search, EINA_TRUE);
- elm_entry_entry_append(tb->search, ev->compose);
- elm_entry_cursor_end_set(tb->search);
- }
- _ephoto_search_go(tb->search, NULL, NULL);
- }
- else if (tb->searching && ((!strcasecmp(k, "Backspace")) ||
- !strcasecmp(k, "Delete")))
- {
- _ephoto_search_go(tb->search, NULL, NULL);
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ if (tb->ephoto->searchentries)
+ eina_list_free(tb->ephoto->searchentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = NULL;
}
+ evas_object_smart_callback_call(tb->main, "view", e);
if (selected)
eina_list_free(selected);
}
+/*Thumb Pane Functions*/
static void
-_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+_ephoto_thumb_update_info_label(Ephoto_Thumb_Browser *tb)
+{
+ char buf[PATH_MAX];
+ char isize[PATH_MAX];
+ char image_info[PATH_MAX];
+ double totsize;
+
+
+ if (!tb->totimages)
+ {
+ elm_object_text_set(tb->nolabel,
+ _("No images matched your search"));
+ snprintf(buf, PATH_MAX, "%s: 0 %s %s: 0%s",
+ _("Total"), ngettext("image", "images", 0), _("Size"),
+ ngettext("B", "B", 0));
+ elm_object_text_set(tb->infolabel, buf);
+ }
+ else
+ {
+ elm_object_text_set(tb->nolabel, " ");
+ totsize = tb->totsize;
+ if (totsize < 1024.0)
+ snprintf(isize, sizeof(isize), "%'.0f%s", totsize, ngettext("B",
+ "B", totsize));
+ else
+ {
+ totsize /= 1024.0;
+ if (totsize < 1024)
+ snprintf(isize, sizeof(isize), "%'.0f%s", totsize,
+ ngettext("KB", "KB", totsize));
+ else
+ {
+ totsize /= 1024.0;
+ if (totsize < 1024)
+ snprintf(isize, sizeof(isize), "%'.1f%s", totsize,
+ ngettext("MB", "MB", totsize));
+ else
+ {
+ totsize /= 1024.0;
+ if (totsize < 1024)
+ snprintf(isize, sizeof(isize), "%'.1f%s", totsize,
+ ngettext("GB", "GB", totsize));
+ else
+ {
+ totsize /= 1024.0;
+ snprintf(isize, sizeof(isize), "%'.1f%s",
+ totsize, ngettext("TB", "TB", totsize));
+ }
+ }
+ }
+ }
+ snprintf(image_info, PATH_MAX, "%s: %d %s %s: %s",
+ _("Total"), tb->totimages, ngettext("image", "images",
+ tb->totimages), _("Size"), isize);
+ elm_object_text_set(tb->infolabel, image_info);
+ }
+}
+
+static void
+_ephoto_thumb_zoom_set(Ephoto_Thumb_Browser *tb, int zoom)
+{
+ double scale = elm_config_scale_get();
+
+ if (zoom > ZOOM_MAX)
+ zoom = ZOOM_MAX;
+ else if (zoom < ZOOM_MIN)
+ zoom = ZOOM_MIN;
+ ephoto_thumb_size_set(tb->ephoto, zoom);
+ elm_gengrid_item_size_set(tb->grid, zoom * scale, zoom * scale);
+}
+
+static void
+_ephoto_thumb_search_go(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
- Ephoto_Thumb_Browser *tb = data;
- Ecore_Event_Handler *handler;
+ Evas_Object *search = data;
+ Ephoto_Thumb_Browser *tb = evas_object_data_get(search, "thumb_browser");
+ if (tb->processing)
+ return;
+ Elm_Object_Item *next = NULL;
+ Elm_Object_Item *found = NULL;
+ Elm_Object_Item *o = NULL;
+ Eina_List *sel = eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
+ Eina_List *l, *results = NULL;
+ const char *search_text = elm_object_text_get(search);
+ char pattern[PATH_MAX];
- _todo_items_free(tb);
- EINA_LIST_FREE(tb->handlers, handler) ecore_event_handler_del(handler);
- if (tb->animator.todo_items)
+ if (tb->original_grid)
{
- ecore_animator_del(tb->animator.todo_items);
- tb->animator.todo_items = NULL;
+ elm_gengrid_clear(tb->grid);
+ elm_box_unpack(tb->gridbox, tb->grid);
+ evas_object_del(tb->grid);
+ tb->grid = tb->original_grid;
+ elm_box_pack_end(tb->gridbox, tb->grid);
+ evas_object_show(tb->grid);
+ next = elm_gengrid_first_item_get(tb->grid);
}
- if (tb->ls)
+ snprintf(pattern, PATH_MAX, "*%s*", search_text);
+ EINA_LIST_FOREACH(sel, l, o)
{
- tb->main_deleted = EINA_TRUE;
- eio_file_cancel(tb->ls);
- return;
+ elm_gengrid_item_selected_set(o, EINA_FALSE);
}
- if (tb->cut_items)
- eina_list_free(tb->cut_items);
- else if (tb->copy_items)
- eina_list_free(tb->copy_items);
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
+ eina_list_free(sel);
+ found = elm_gengrid_search_by_text_item_get(tb->grid, next, NULL, pattern,
+ ELM_GLOB_MATCH_NOCASE);
+ while (found)
+ {
+ results = eina_list_append(results, found);
+ if (found == elm_gengrid_last_item_get(tb->grid))
+ break;
+ next = elm_gengrid_item_next_get(found);
+ found = elm_gengrid_search_by_text_item_get(tb->grid, next, NULL,
+ pattern, ELM_GLOB_MATCH_NOCASE);
+ }
+ tb->original_grid = tb->grid;
+ elm_box_unpack(tb->gridbox, tb->original_grid);
+ evas_object_hide(tb->original_grid);
+
+ tb->grid = elm_gengrid_add(tb->gridbox);
+ evas_object_size_hint_weight_set(tb->grid, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_gengrid_align_set(tb->grid, 0.5, 0.0);
+ elm_gengrid_multi_select_set(tb->grid, EINA_TRUE);
+ elm_gengrid_multi_select_mode_set(tb->grid,
+ ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT);
+ elm_scroller_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE);
+ evas_object_smart_callback_add(tb->grid, "activated",
+ _ephoto_thumb_activated, tb);
+ evas_object_event_callback_add(tb->grid, EVAS_CALLBACK_MOUSE_UP,
+ _grid_mouse_up_cb, tb);
+ elm_drag_item_container_add(tb->grid, ANIM_TIME, DRAG_TIMEOUT,
+ _dnd_item_get, _dnd_item_data_get);
+ evas_object_data_set(tb->grid, "thumb_browser", tb);
+ _ephoto_thumb_zoom_set(tb, tb->ephoto->config->thumb_size);
+ elm_box_pack_end(tb->gridbox, tb->grid);
+ evas_object_show(tb->grid);
+
+ elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
+ if (tb->searchentries)
+ eina_list_free(tb->searchentries);
+ tb->searchentries = NULL;
+ if (results)
+ {
+ tb->totimages = 0;
+ tb->totsize = 0;
+ EINA_LIST_FOREACH(results, l, o)
+ {
+ const Elm_Gengrid_Item_Class *ic = NULL;
+ Ephoto_Entry *entry = NULL, *e = NULL;
+
+ ic = &_ephoto_thumb_file_class;
+ entry = elm_object_item_data_get(o);
+ e = ephoto_entry_new(tb->ephoto, entry->path, entry->label,
+ EINA_FILE_REG);
+ if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING)
+ e->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, e,
+ _entry_cmp_grid_alpha_asc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING)
+ e->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, e,
+ _entry_cmp_grid_alpha_desc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING)
+ e->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, e,
+ _entry_cmp_grid_mod_asc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING)
+ e->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, e,
+ _entry_cmp_grid_mod_desc, NULL, NULL);
+ if (e->item)
+ {
+ Eina_File *f;
+ elm_object_item_data_set(e->item, e);
+ tb->totimages++;
+ f = eina_file_open(e->path, EINA_FALSE);
+ tb->totsize += (double) eina_file_size_get(f);
+ eina_file_close(f);
+ tb->searchentries = eina_list_append(tb->searchentries, e);
+ }
+ else
+ {
+ ephoto_entry_free(tb->ephoto, e);
+ }
+ }
+ tb->entries = tb->searchentries;
+ _ephoto_thumb_update_info_label(tb);
+ eina_list_free(results);
+ }
+ else
+ {
+ tb->totimages = 0;
+ tb->totsize = 0;
+ _ephoto_thumb_update_info_label(tb);
+ tb->searchentries = NULL;
+ tb->entries = NULL;
+ }
+}
+
+static void
+_ephoto_thumb_search_cancel(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Evas_Object *search = data;
+ if (!search)
+ return;
+ Evas_Object *hbox = evas_object_data_get(search, "parent");
+ Ephoto_Thumb_Browser *tb = evas_object_data_get(search, "thumb_browser");
+
+ tb->entries = tb->ephoto->entries;
if (tb->ephoto->searchentries)
eina_list_free(tb->ephoto->searchentries);
if (tb->searchentries)
eina_list_free(tb->searchentries);
- if (tb->monitor)
- ecore_file_monitor_del(tb->monitor);
- free(tb);
-}
-
-static Eina_Bool
-_ephoto_thumb_populate_start(void *data, int type EINA_UNUSED,
- void *event EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- evas_object_smart_callback_call(tb->main, "changed,directory", NULL);
-
- tb->animator.processed = 0;
- tb->animator.count = 0;
- if (tb->ephoto->selentries)
- eina_list_free(tb->ephoto->selentries);
- if (tb->searching)
- _ephoto_search_cancel(tb->search, NULL, NULL);
- _todo_items_free(tb);
- if (!tb->dirs_only)
+ tb->ephoto->searchentries = NULL;
+ tb->searchentries = NULL;
+ if (tb->original_grid)
{
- elm_gengrid_clear(tb->grid);
- tb->totimages = 0;
- tb->totsize = 0;
- }
- elm_object_text_set(tb->direntry, tb->ephoto->config->directory);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_ephoto_thumb_populate_end(void *data, int type EINA_UNUSED,
- void *event EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- tb->ls = NULL;
- if (tb->main_deleted)
- {
- free(tb);
- return ECORE_CALLBACK_PASS_ON;
+ elm_gengrid_clear(tb->grid);
+ elm_box_unpack(tb->gridbox, tb->grid);
+ evas_object_del(tb->grid);
+ tb->grid = tb->original_grid;
+ elm_box_pack_end(tb->gridbox, tb->grid);
+ evas_object_show(tb->grid);
+ tb->original_grid = NULL;
+ tb->totimages = tb->totimages_old;
+ tb->totsize = tb->totsize_old;
}
if (!tb->ephoto->entries)
{
tb->totimages = 0;
tb->totsize = 0;
}
- _update_info_label(tb);
- tb->dirs_only = 0;
- tb->thumbs_only = 0;
- tb->entries = tb->ephoto->entries;
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_ephoto_thumb_populate_error(void *data, int type EINA_UNUSED,
- void *event EINA_UNUSED)
-{
- Ephoto_Thumb_Browser *tb = data;
-
- tb->dirs_only = 0;
- tb->thumbs_only = 0;
-
- return ECORE_CALLBACK_PASS_ON;
+ elm_object_focus_set(tb->main, EINA_TRUE);
+ evas_object_del(tb->search);
+ tb->search = NULL;
+ elm_box_unpack(tb->gridbox, hbox);
+ evas_object_del(hbox);
+ tb->searching = 0;
+ _ephoto_thumb_update_info_label(tb);
+ tb->totimages_old = 0;
+ tb->totsize_old = 0;
}
static void
-_top_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
- Ecore_File_Event event, const char *path)
-{
- Elm_Object_Item *item;
- Ephoto_Thumb_Browser *tb = data;
- Ephoto_Entry *e;
- const Elm_Genlist_Item_Class *ic;
- char buf[PATH_MAX], file[PATH_MAX], dir[PATH_MAX];
-
- if (!tb)
- return;
- snprintf(file, PATH_MAX, "%s", path);
- snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
-
- if (strcmp(tb->ephoto->top_directory, dir))
- return;
- if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
- {
- if (!ecore_file_is_dir(path))
- return;
- if (ephoto_entry_exists(tb->ephoto, path))
- return;
- snprintf(buf, PATH_MAX, "%s", path);
- e = ephoto_entry_new(tb->ephoto, path, basename(buf),
- EINA_FILE_DIR);
- e->genlist = tb->fsel;
- ic = &_ephoto_dir_class;
- e->item =
- elm_genlist_item_append(tb->fsel, ic, e,
- NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- if (e->item)
- e->monitor = ecore_file_monitor_add(e->path, _monitor_cb, e);
- return;
- }
- else if (event == ECORE_FILE_EVENT_DELETED_DIRECTORY)
- {
- item = elm_genlist_first_item_get(tb->fsel);
- while (item)
- {
- e = elm_object_item_data_get(item);
- if (!strcmp(e->path, path))
- {
- if (!strcmp(path, tb->ephoto->config->directory))
- _ephoto_dir_go_up(tb, NULL, NULL);
- else
- elm_object_item_del(e->item);
- break;
- }
- item = elm_genlist_item_next_get(item);
- }
- return;
- }
- else if (event == ECORE_FILE_EVENT_MODIFIED)
- {
- if (!ecore_file_is_dir(path))
- return;
- item = elm_genlist_first_item_get(tb->fsel);
- while (item)
- {
- e = elm_object_item_data_get(item);
- if (!strcmp(e->path, path))
- {
- elm_genlist_item_update(e->item);
- break;
- }
- item = elm_genlist_item_next_get(item);
- }
- return;
- }
-}
-
-static Eina_Bool
-_ephoto_thumb_entry_create(void *data, int type EINA_UNUSED, void *event)
+_ephoto_thumb_search_start(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
- Ephoto_Event_Entry_Create *ev = event;
- Ephoto_Entry *e;
+ Evas_Object *hbox, *search;
- e = ev->entry;
- if (!e->is_dir)
- {
- Eina_File *f;
-
- tb->totimages += 1;
- f = eina_file_open(e->path, EINA_FALSE);
- e->size = eina_file_size_get(f);
- tb->totsize += (double) e->size;
- eina_file_close(f);
- tb->todo_items = eina_list_append(tb->todo_items, e);
- tb->animator.count++;
- }
- else if (e->is_dir)
- {
- tb->todo_items = eina_list_append(tb->todo_items, e);
- tb->animator.count++;
- }
- if (!tb->animator.todo_items)
- tb->animator.todo_items = ecore_animator_add(_todo_items_process, tb);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-void
-ephoto_thumb_browser_insert(Ephoto *ephoto, Ephoto_Entry *entry)
-{
- Ephoto_Thumb_Browser *tb =
- evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
-
- if (!entry->is_dir && !entry->item)
- {
- Eina_File *f;
- const Elm_Gengrid_Item_Class *ic;
-
- tb->totimages += 1;
- f = eina_file_open(entry->path, EINA_FALSE);
- entry->size = eina_file_size_get(f);
- tb->totsize += (double) entry->size;
- eina_file_close(f);
-
- ic = &_ephoto_thumb_file_class;
- if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_alpha_asc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_alpha_desc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_mod_asc, NULL, NULL);
- else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING)
- entry->item =
- elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
- _entry_cmp_grid_mod_desc, NULL, NULL);
- if (entry->item)
- {
- elm_object_item_data_set(entry->item, entry);
- }
- else
- {
- ephoto_entry_free(tb->ephoto, entry);
- }
- _update_info_label(tb);
- }
-}
-
-void
-ephoto_thumb_browser_remove(Ephoto *ephoto, Ephoto_Entry *entry)
-{
- Ephoto_Thumb_Browser *tb =
- evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
-
- if (!entry->is_dir)
- {
- tb->totimages -= 1;
- tb->totsize -= entry->size;
-
- if (eina_list_count(tb->ephoto->entries) == 1)
- {
- tb->totimages = 0;
- tb->totsize = 0;
- }
- _update_info_label(tb);
- elm_object_item_del(entry->item);
- }
-}
-
-void
-ephoto_thumb_browser_update(Ephoto *ephoto, Ephoto_Entry *entry)
-{
- Ephoto_Thumb_Browser *tb =
- evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
-
- if (!entry->is_dir)
- {
- Eina_File *f;
-
- tb->totsize -= entry->size;
-
- f = eina_file_open(entry->path, EINA_FALSE);
- entry->size = eina_file_size_get(f);
- tb->totsize += (double) entry->size;
- eina_file_close(f);
-
- elm_gengrid_item_update(entry->item);
- tb->totsize += entry->size;
- _update_info_label(tb);
- }
-}
-
-void
-ephoto_thumb_browser_top_dir_set(Ephoto *ephoto, const char *dir)
-{
- Ephoto_Thumb_Browser *tb =
- evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
-
- if (tb->monitor)
- ecore_file_monitor_del(tb->monitor);
- if (ephoto->top_directory)
- eina_stringshare_replace(&ephoto->top_directory, dir);
+ if (tb->processing)
+ return;
+ if (!tb->searching)
+ tb->searching = 1;
else
- ephoto->top_directory = eina_stringshare_add(dir);
- tb->monitor = ecore_file_monitor_add(dir, _top_monitor_cb, tb);
-}
-
-void
-ephoto_thumb_browser_fsel_clear(Ephoto *ephoto)
-{
- Ephoto_Thumb_Browser *tb =
- evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
-
- if (tb)
- elm_genlist_clear(tb->fsel);
-}
-
-Evas_Object *
-ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
-{
- Evas_Object *box = elm_box_add(parent);
- Evas_Object *hbox, *but, *ic;
- Ephoto_Thumb_Browser *tb;
- int ret;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
-
- tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
- EINA_SAFETY_ON_NULL_GOTO(tb, error);
-
- _ephoto_thumb_file_class.item_style = "thumb";
- _ephoto_thumb_file_class.func.text_get = _ephoto_thumb_item_text_get;
- _ephoto_thumb_file_class.func.content_get = _ephoto_thumb_file_icon_get;
- _ephoto_thumb_file_class.func.state_get = NULL;
- _ephoto_thumb_file_class.func.del = _ephoto_thumb_item_del;
-
- _ephoto_dir_class.item_style = "tree_effect";
- _ephoto_dir_class.func.text_get = _ephoto_dir_item_text_get;
- _ephoto_dir_class.func.content_get = _ephoto_dir_item_icon_get;
- _ephoto_dir_class.func.state_get = NULL;
- _ephoto_dir_class.func.del = _ephoto_dir_item_del;
-
- tb->ephoto = ephoto;
- tb->thumbs_only = 0;
- tb->dirs_only = 0;
- tb->dragging = 0;
- tb->searching = 0;
- tb->cut_items = NULL;
- tb->copy_items = NULL;
- tb->dir_current = NULL;
- tb->change_dir_job = NULL;
- tb->last_sel = NULL;
- tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
- tb->main = box;
-
- elm_box_horizontal_set(tb->main, EINA_FALSE);
- evas_object_size_hint_weight_set(tb->main, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_event_callback_add(tb->main, EVAS_CALLBACK_DEL, _main_del, tb);
- evas_object_event_callback_add(tb->main, EVAS_CALLBACK_KEY_DOWN, _key_down,
- tb);
- evas_object_data_set(tb->main, "thumb_browser", tb);
-
- tb->table = elm_table_add(tb->main);
- evas_object_size_hint_weight_set(tb->table, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tb->table, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(tb->main, tb->table);
- evas_object_show(tb->table);
-
- tb->leftbox = elm_box_add(tb->table);
- evas_object_size_hint_weight_set(tb->leftbox, 0.2, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tb->leftbox,
- EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- hbox = elm_box_add(tb->leftbox);
+ {
+ _ephoto_thumb_search_cancel(tb->search, NULL, NULL);
+ return;
+ }
+ hbox = elm_box_add(tb->gridbox);
elm_box_horizontal_set(hbox, EINA_TRUE);
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(tb->leftbox, hbox);
+ elm_box_pack_start(tb->gridbox, hbox);
evas_object_show(hbox);
- ic = elm_icon_add(hbox);
- elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
- elm_icon_standard_set(ic, "go-up");
- evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
- but = elm_button_add(hbox);
- elm_object_part_content_set(but, "icon", ic);
- elm_object_text_set(but, _("Up"));
- evas_object_size_hint_weight_set(but, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(but, "clicked", _ephoto_dir_go_up, tb);
- elm_box_pack_end(hbox, but);
- evas_object_show(but);
-
- ic = elm_icon_add(hbox);
- elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
- elm_icon_standard_set(ic, "go-home");
- evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
- but = elm_button_add(hbox);
- elm_object_part_content_set(but, "icon", ic);
- elm_object_text_set(but, _("Home"));
- evas_object_size_hint_weight_set(but, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(but, "clicked", _ephoto_dir_go_home, tb);
- elm_box_pack_end(hbox, but);
- evas_object_show(but);
-
- ic = elm_icon_add(hbox);
- elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
- elm_icon_standard_set(ic, "user-trash");
- evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
- but = elm_button_add(hbox);
- elm_object_part_content_set(but, "icon", ic);
- elm_object_text_set(but, _("Trash"));
- evas_object_size_hint_weight_set(but, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(but, "clicked", _ephoto_dir_go_trash, tb);
- elm_box_pack_end(hbox, but);
- evas_object_show(but);
-
- tb->direntry = elm_entry_add(tb->main);
- elm_entry_single_line_set(tb->direntry, EINA_TRUE);
- elm_entry_scrollable_set(tb->direntry, EINA_TRUE);
- elm_scroller_policy_set(tb->direntry, ELM_SCROLLER_POLICY_OFF,
+ search = elm_entry_add(hbox);
+ elm_entry_single_line_set(search, EINA_TRUE);
+ elm_entry_scrollable_set(search, EINA_TRUE);
+ elm_object_part_text_set(search, "guide", _("Search"));
+ elm_scroller_policy_set(search, ELM_SCROLLER_POLICY_OFF,
ELM_SCROLLER_POLICY_OFF);
- evas_object_size_hint_weight_set(tb->direntry, EVAS_HINT_EXPAND,
+ evas_object_size_hint_weight_set(search, EVAS_HINT_EXPAND,
EVAS_HINT_FILL);
- evas_object_size_hint_align_set(tb->direntry, EVAS_HINT_FILL,
+ evas_object_size_hint_align_set(search, EVAS_HINT_FILL,
EVAS_HINT_FILL);
- evas_object_smart_callback_add(tb->direntry, "activated",
- _ephoto_direntry_go, tb);
- elm_box_pack_end(tb->leftbox, tb->direntry);
- evas_object_show(tb->direntry);
+ evas_object_data_set(search, "thumb_browser", tb);
+ evas_object_data_set(search, "parent", hbox);
+ evas_object_smart_callback_add(search, "activated",
+ _ephoto_thumb_search_go, search);
+ elm_box_pack_end(hbox, search);
+ evas_object_show(search);
- tb->fsel = elm_genlist_add(tb->leftbox);
- elm_genlist_homogeneous_set(tb->fsel, EINA_TRUE);
- elm_genlist_select_mode_set(tb->fsel, ELM_OBJECT_SELECT_MODE_ALWAYS);
- evas_object_size_hint_weight_set(tb->fsel, EVAS_HINT_EXPAND,
+ tb->search = search;
+ tb->totimages_old = tb->totimages;
+ tb->totsize_old = tb->totsize;
+
+ elm_object_focus_set(search, EINA_TRUE);
+}
+
+void _ephoto_thumb_pane_add(Ephoto_Thumb_Browser *tb)
+{
+ Evas_Object *hbox, *but, *ic;
+ int ret;
+
+ tb->table = elm_table_add(tb->panes);
+ evas_object_size_hint_weight_set(tb->table, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tb->fsel, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(tb->fsel, "expand,request",
- _on_list_expand_req, tb);
- evas_object_smart_callback_add(tb->fsel, "contract,request",
- _on_list_contract_req, tb);
- evas_object_smart_callback_add(tb->fsel, "expanded", _on_list_expanded, tb);
- evas_object_smart_callback_add(tb->fsel, "contracted", _on_list_contracted,
- tb);
- evas_object_event_callback_add(tb->fsel, EVAS_CALLBACK_MOUSE_UP,
- _fsel_mouse_up_cb, tb);
- evas_object_data_set(tb->fsel, "thumb_browser", tb);
- elm_box_pack_end(tb->leftbox, tb->fsel);
- evas_object_show(tb->fsel);
- elm_drop_item_container_add(tb->fsel, ELM_SEL_FORMAT_TARGETS,
- _drop_item_getcb, _drop_enter, tb, _drop_leave, tb, _drop_pos, tb,
- _drop_dropcb, NULL);
-
- if (!tb->ephoto->config->fsel_hide)
- {
- elm_table_pack(tb->table, tb->leftbox, 0, 0, 1, 1);
- evas_object_show(tb->leftbox);
- }
- else
- {
- evas_object_hide(tb->leftbox);
- }
+ evas_object_size_hint_align_set(tb->table, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(tb->table);
tb->nolabel = elm_label_add(tb->table);
elm_label_line_wrap_set(tb->nolabel, ELM_WRAP_WORD);
@@ -2721,10 +1914,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
EVAS_HINT_FILL);
evas_object_size_hint_aspect_set(tb->nolabel, EVAS_ASPECT_CONTROL_VERTICAL,
1, 1);
- if (!tb->ephoto->config->fsel_hide)
- elm_table_pack(tb->table, tb->nolabel, 1, 0, 4, 1);
- else
- elm_table_pack(tb->table, tb->nolabel, 0, 0, 5, 1);
+ elm_table_pack(tb->table, tb->nolabel, 0, 0, 5, 1);
evas_object_show(tb->nolabel);
tb->gridbox = elm_box_add(tb->table);
@@ -2755,12 +1945,9 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
evas_object_data_set(tb->grid, "thumb_browser", tb);
elm_box_pack_end(tb->gridbox, tb->grid);
evas_object_show(tb->grid);
- if (!tb->ephoto->config->fsel_hide)
- elm_table_pack(tb->table, tb->gridbox, 1, 0, 4, 1);
- else
- elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
+ elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
- _zoom_set(tb, tb->ephoto->config->thumb_size);
+ _ephoto_thumb_zoom_set(tb, tb->ephoto->config->thumb_size);
hbox = elm_box_add(tb->main);
elm_box_horizontal_set(hbox, EINA_TRUE);
@@ -2850,6 +2037,909 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
evas_object_show(ic);
elm_box_pack_end(hbox, tb->hover);
evas_object_show(tb->hover);
+}
+
+/*Ephoto Populating Functions*/
+static void
+_todo_items_free(Ephoto_Thumb_Browser *tb)
+{
+ eina_list_free(tb->todo_items);
+ tb->todo_items = NULL;
+}
+
+static void
+_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
+ Ecore_File_Event event, const char *path)
+{
+ Elm_Object_Item *item;
+ Ephoto_Entry *entry = data;
+ Ephoto_Entry *e;
+ char file[PATH_MAX], dir[PATH_MAX];
+ const Elm_Genlist_Item_Class *ic;
+ char buf[PATH_MAX];
+
+ if (!entry)
+ return;
+
+ snprintf(file, PATH_MAX, "%s", path);
+ snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
+
+ if (strcmp(entry->path, dir))
+ return;
+ if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
+ {
+ if (!ecore_file_is_dir(path))
+ return;
+ if (ephoto_entry_exists(entry->ephoto, path))
+ return;
+
+ if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_TREE &&
+ elm_genlist_item_expanded_get(entry->item) == EINA_TRUE)
+ {
+ ic = &_ephoto_dir_class;
+ snprintf(buf, PATH_MAX, "%s", path);
+ e = ephoto_entry_new(entry->ephoto, path, basename(buf),
+ EINA_FILE_DIR);
+ e->genlist = entry->genlist;
+ e->parent = entry->item;
+ e->item =
+ elm_genlist_item_sorted_insert(entry->genlist, ic, e,
+ e->parent, ELM_GENLIST_ITEM_NONE, _entry_cmp, NULL, NULL);
+ if (e->item)
+ e->monitor = ecore_file_monitor_add(e->path, _monitor_cb, e);
+ }
+ if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_NONE)
+ {
+ Elm_Object_Item *parent;
+
+ ic = &_ephoto_dir_class;
+ parent =
+ elm_genlist_item_insert_before(entry->genlist, ic, entry,
+ entry->parent, entry->item, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+ entry->no_delete = EINA_TRUE;
+ if (entry->monitor)
+ ecore_file_monitor_del(entry->monitor);
+ elm_object_item_del(entry->item);
+ entry->item = parent;
+ entry->no_delete = EINA_FALSE;
+ entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry);
+ }
+ return;
+ }
+ else if (event == ECORE_FILE_EVENT_DELETED_DIRECTORY)
+ {
+ item = elm_genlist_first_item_get(entry->genlist);
+ while (item)
+ {
+ e = elm_object_item_data_get(item);
+ if (!strcmp(e->path, path))
+ {
+ elm_object_item_del(e->item);
+ //if (!strcmp(e->path, e->ephoto->config->directory))
+ break;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+ if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_TREE &&
+ _check_for_subdirs(entry) == EINA_FALSE)
+ {
+ Elm_Object_Item *parent;
+
+ ic = &_ephoto_dir_class;
+ parent =
+ elm_genlist_item_insert_before(entry->genlist, ic, entry,
+ entry->parent, entry->item, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ entry->no_delete = EINA_TRUE;
+ elm_object_item_del(entry->item);
+ entry->item = parent;
+ entry->no_delete = EINA_FALSE;
+ }
+ if (!ecore_file_exists(entry->ephoto->config->directory))
+ {
+ ephoto_directory_set(entry->ephoto, entry->path, entry->parent, 0, 1);
+ ephoto_title_set(entry->ephoto, entry->path);
+ }
+ return;
+ }
+ else if (event == ECORE_FILE_EVENT_MODIFIED)
+ {
+ if (!ecore_file_is_dir(path))
+ return;
+ if ((elm_genlist_item_expanded_get(entry->item) == EINA_TRUE))
+ {
+ item = elm_genlist_first_item_get(entry->genlist);
+ while (item)
+ {
+ e = elm_object_item_data_get(item);
+ if (!strcmp(e->path, path))
+ {
+ elm_genlist_item_update(e->item);
+ break;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+ }
+ return;
+ }
+}
+
+static void
+_top_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
+ Ecore_File_Event event, const char *path)
+{
+ Elm_Object_Item *item;
+ Ephoto_Thumb_Browser *tb = data;
+ Ephoto_Entry *e;
+ const Elm_Genlist_Item_Class *ic;
+ char buf[PATH_MAX], file[PATH_MAX], dir[PATH_MAX];
+
+ if (!tb)
+ return;
+ snprintf(file, PATH_MAX, "%s", path);
+ snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
+
+ if (strcmp(tb->ephoto->top_directory, dir))
+ return;
+ if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
+ {
+ if (!ecore_file_is_dir(path))
+ return;
+ if (ephoto_entry_exists(tb->ephoto, path))
+ return;
+ snprintf(buf, PATH_MAX, "%s", path);
+ e = ephoto_entry_new(tb->ephoto, path, basename(buf),
+ EINA_FILE_DIR);
+ e->genlist = tb->fsel;
+ ic = &_ephoto_dir_class;
+ e->item =
+ elm_genlist_item_append(tb->fsel, ic, e,
+ NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ if (e->item)
+ e->monitor = ecore_file_monitor_add(e->path, _monitor_cb, e);
+ return;
+ }
+ else if (event == ECORE_FILE_EVENT_DELETED_DIRECTORY)
+ {
+ item = elm_genlist_first_item_get(tb->fsel);
+ while (item)
+ {
+ e = elm_object_item_data_get(item);
+ if (!strcmp(e->path, path))
+ {
+ if (!strcmp(path, tb->ephoto->config->directory))
+ _dir_go_up(tb, NULL, NULL);
+ else
+ elm_object_item_del(e->item);
+ break;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+ return;
+ }
+ else if (event == ECORE_FILE_EVENT_MODIFIED)
+ {
+ if (!ecore_file_is_dir(path))
+ return;
+ item = elm_genlist_first_item_get(tb->fsel);
+ while (item)
+ {
+ e = elm_object_item_data_get(item);
+ if (!strcmp(e->path, path))
+ {
+ elm_genlist_item_update(e->item);
+ break;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+ return;
+ }
+}
+
+static Eina_Bool
+_todo_items_process(void *data)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Ephoto_Entry *entry;
+ int i = 0;
+
+ if ((!tb->ls) && (tb->animator.processed == tb->animator.count))
+ {
+ if (tb->animator.count == 0)
+ return EINA_TRUE;
+ tb->animator.todo_items = NULL;
+ tb->processing = 0;
+ return EINA_FALSE;
+ }
+ if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH))
+ return EINA_TRUE;
+
+ tb->animator.todo_items = NULL;
+ tb->processing = 1;
+ EINA_LIST_FREE(tb->todo_items, entry)
+ {
+ i++;
+ if (i > TODO_ITEM_MIN_BATCH)
+ return EINA_TRUE;
+ if (entry->is_dir && !entry->item)
+ {
+ const Elm_Genlist_Item_Class *ic;
+
+ ic = &_ephoto_dir_class;
+ if (_check_for_subdirs(entry))
+ entry->item =
+ elm_genlist_item_sorted_insert(tb->fsel, ic, entry,
+ entry->parent, ELM_GENLIST_ITEM_TREE, _entry_cmp, NULL, NULL);
+ else
+ entry->item =
+ elm_genlist_item_sorted_insert(tb->fsel, ic, entry,
+ entry->parent, ELM_GENLIST_ITEM_NONE, _entry_cmp, NULL, NULL);
+ if (!entry->item)
+ {
+ ephoto_entry_free(tb->ephoto, entry);
+ }
+ else
+ {
+ entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry);
+ entry->genlist = tb->fsel;
+ }
+ }
+ else if (!entry->is_dir && !entry->item)
+ {
+ const Elm_Gengrid_Item_Class *ic;
+
+ ic = &_ephoto_thumb_file_class;
+ if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_alpha_asc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_alpha_desc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_mod_asc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_mod_desc, NULL, NULL);
+ if (entry->item)
+ {
+ elm_object_item_data_set(entry->item, entry);
+ }
+ else
+ {
+ ephoto_entry_free(tb->ephoto, entry);
+ }
+ }
+ tb->animator.processed++;
+ }
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_ephoto_thumb_populate_start(void *data, int type EINA_UNUSED,
+ void *event EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ evas_object_smart_callback_call(tb->main, "changed,directory", NULL);
+
+ tb->animator.processed = 0;
+ tb->animator.count = 0;
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ if (tb->searching)
+ _ephoto_thumb_search_cancel(tb->search, NULL, NULL);
+ _todo_items_free(tb);
+ if (!tb->dirs_only)
+ {
+ elm_gengrid_clear(tb->grid);
+ tb->totimages = 0;
+ tb->totsize = 0;
+ }
+ elm_object_text_set(tb->direntry, tb->ephoto->config->directory);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_ephoto_thumb_populate_end(void *data, int type EINA_UNUSED,
+ void *event EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ tb->ls = NULL;
+ if (tb->main_deleted)
+ {
+ free(tb);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+ if (!tb->ephoto->entries)
+ {
+ tb->totimages = 0;
+ tb->totsize = 0;
+ }
+ _ephoto_thumb_update_info_label(tb);
+ tb->dirs_only = 0;
+ tb->thumbs_only = 0;
+ tb->entries = tb->ephoto->entries;
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_ephoto_thumb_populate_error(void *data, int type EINA_UNUSED,
+ void *event EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ tb->dirs_only = 0;
+ tb->thumbs_only = 0;
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_ephoto_thumb_entry_create(void *data, int type EINA_UNUSED, void *event)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Ephoto_Event_Entry_Create *ev = event;
+ Ephoto_Entry *e;
+
+ e = ev->entry;
+ if (!e->is_dir)
+ {
+ Eina_File *f;
+
+ tb->totimages += 1;
+ f = eina_file_open(e->path, EINA_FALSE);
+ e->size = eina_file_size_get(f);
+ tb->totsize += (double) e->size;
+ eina_file_close(f);
+ tb->todo_items = eina_list_append(tb->todo_items, e);
+ tb->animator.count++;
+ }
+ else if (e->is_dir)
+ {
+ tb->todo_items = eina_list_append(tb->todo_items, e);
+ tb->animator.count++;
+ }
+ if (!tb->animator.todo_items)
+ tb->animator.todo_items = ecore_animator_add(_todo_items_process, tb);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+/*Ephoto Thumb Browser Main Callbacks*/
+static void
+_ephoto_show_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Eina_List *selected, *s;
+ Elm_Object_Item *item;
+ Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
+ Ephoto_Entry *entry;
+
+ if (it)
+ entry = elm_object_item_data_get(it);
+ else
+ entry = eina_list_nth(tb->entries, 0);
+ if (!entry)
+ return;
+ selected =
+ eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
+ if (eina_list_count(selected) <= 1 && tb->searchentries)
+ {
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
+ }
+ else if (eina_list_count(selected) > 1)
+ {
+ EINA_LIST_FOREACH(selected, s, item)
+ {
+ tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
+ elm_object_item_data_get(item));
+ }
+ }
+ else
+ {
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ if (tb->ephoto->searchentries)
+ eina_list_free(tb->ephoto->searchentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = NULL;
+ }
+ evas_object_smart_callback_call(tb->main, "slideshow", entry);
+ if (selected)
+ eina_list_free(selected);
+}
+
+static void
+_ephoto_show_settings(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ ephoto_config_main(tb->ephoto);
+}
+
+static void
+_ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Evas_Event_Key_Down *ev = event_info;
+ Eina_Bool ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
+ Eina_Bool shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
+ Eina_List *selected =
+ eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
+ const char *k = ev->keyname;
+
+ if (ctrl)
+ {
+ if (shift)
+ {
+ if (!strcasecmp(k, "f"))
+ {
+ if (evas_object_visible_get(tb->leftbox))
+ _ephoto_dir_hide_folders(tb, NULL, NULL);
+ else
+ _ephoto_dir_show_folders(tb, NULL, NULL);
+ }
+ }
+ else if ((!strcasecmp(k, "plus")) || (!strcasecmp(k, "equal")))
+ {
+ int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
+
+ _ephoto_thumb_zoom_set(tb, zoom);
+ }
+ else if ((!strcasecmp(k, "minus")) || (!strcasecmp(k, "underscore")))
+ {
+ int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
+
+ _ephoto_thumb_zoom_set(tb, zoom);
+ }
+ else if (!strcasecmp(k, "Tab"))
+ {
+ Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
+ Ephoto_Entry *entry;
+ Eina_List *s;
+ Elm_Object_Item *item;
+
+ if (it)
+ entry = elm_object_item_data_get(it);
+ else
+ entry = eina_list_nth(tb->entries, 0);
+ if (eina_list_count(selected) <= 1 && tb->searchentries)
+ {
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries =
+ eina_list_clone(tb->searchentries);
+ }
+ else if (eina_list_count(selected) > 1)
+ {
+ EINA_LIST_FOREACH(selected, s, item)
+ {
+ tb->ephoto->selentries =
+ eina_list_append(tb->ephoto->selentries,
+ elm_object_item_data_get(item));
+ }
+ }
+ else
+ {
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ if (tb->ephoto->searchentries)
+ eina_list_free(tb->ephoto->searchentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = NULL;
+ }
+ if (entry)
+ {
+ evas_object_smart_callback_call(tb->main, "view", entry);
+ }
+ }
+ else if (!strcasecmp(k, "c"))
+ {
+ _grid_menu_copy_cb(tb, NULL, NULL);
+ }
+ else if (!strcasecmp(k, "x"))
+ {
+ _grid_menu_cut_cb(tb, NULL, NULL);
+ }
+ else if (!strcasecmp(k, "v"))
+ {
+ _grid_menu_paste_cb(tb, NULL, NULL);
+ }
+ else if (!strcasecmp(k, "a"))
+ {
+ _grid_menu_select_all_cb(tb, NULL, NULL);
+ }
+ else if (!strcasecmp(k, "f") && !tb->processing)
+ {
+ if (tb->searching)
+ _ephoto_thumb_search_cancel(tb->search, NULL, NULL);
+ else
+ _ephoto_thumb_search_start(tb, NULL, NULL);
+ }
+ else if (!strcasecmp(k, "Delete"))
+ {
+ char path[PATH_MAX];
+ char *trash;
+
+ snprintf(path, PATH_MAX, "%s/.config/ephoto/trash",
+ getenv("HOME"));
+ trash = strdup(path);
+ if ((strlen(trash)) == (strlen(tb->ephoto->config->directory)))
+ {
+ if (!strcmp(trash, tb->ephoto->config->directory))
+ {
+ _menu_empty_cb(tb, NULL, NULL);
+ free(trash);
+ return;
+ }
+ }
+ else
+ _grid_menu_delete_cb(tb, NULL, NULL);
+ free(trash);
+ }
+ }
+ else if (!strcasecmp(k, "F1"))
+ {
+ _ephoto_show_settings(tb, NULL, NULL);
+ }
+ else if (!strcasecmp(k, "F2"))
+ {
+ Elm_Object_Item *it = NULL;
+
+ it = eina_list_data_get(
+ eina_list_last(selected));
+ if (it)
+ {
+ evas_object_data_set(it, "thumb_browser", tb);
+ _grid_menu_rename_cb(it, NULL, NULL);
+ }
+ }
+ else if (!strcasecmp(k, "F5"))
+ {
+ Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
+ Ephoto_Entry *entry;
+ Eina_List *s;
+ Elm_Object_Item *item;
+
+ if (it)
+ entry = elm_object_item_data_get(it);
+ else
+ entry = eina_list_nth(tb->entries, 0);
+ if (eina_list_count(selected) <= 1 && tb->searchentries)
+ {
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
+ }
+ else if (eina_list_count(selected) > 1)
+ {
+ EINA_LIST_FOREACH(selected, s, item)
+ {
+ tb->ephoto->selentries =
+ eina_list_append(tb->ephoto->selentries,
+ elm_object_item_data_get(item));
+ }
+ }
+ else
+ {
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ if (tb->ephoto->searchentries)
+ eina_list_free(tb->ephoto->searchentries);
+ tb->ephoto->selentries = NULL;
+ tb->ephoto->searchentries = NULL;
+ }
+ if (entry)
+ evas_object_smart_callback_call(tb->main, "slideshow", entry);
+ }
+ else if (!strcasecmp(k, "F11"))
+ {
+ Evas_Object *win = tb->ephoto->win;
+
+ elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
+ }
+ else if (!strcasecmp(k, "Escape"))
+ {
+ if (tb->searching)
+ _ephoto_thumb_search_cancel(tb->search, NULL, NULL);
+ else
+ _grid_menu_clear_cb(tb, NULL, NULL);
+ }
+ else if (ev->compose && (((ev->compose[0] != '\\')
+ && (ev->compose[0] >= ' ')) || ev->compose[1]))
+ {
+ if (elm_object_focus_get(tb->direntry))
+ return;
+ if (!tb->searching)
+ {
+ _ephoto_thumb_search_start(tb, NULL, NULL);
+ elm_entry_entry_append(tb->search, ev->compose);
+ elm_entry_cursor_end_set(tb->search);
+ }
+ else if (!elm_object_focus_get(tb->search))
+ {
+ elm_object_focus_set(tb->search, EINA_TRUE);
+ elm_entry_entry_append(tb->search, ev->compose);
+ elm_entry_cursor_end_set(tb->search);
+ }
+ _ephoto_thumb_search_go(tb->search, NULL, NULL);
+ }
+ else if (tb->searching && ((!strcasecmp(k, "Backspace")) ||
+ !strcasecmp(k, "Delete")))
+ {
+ _ephoto_thumb_search_go(tb->search, NULL, NULL);
+ }
+ if (selected)
+ eina_list_free(selected);
+}
+
+static void _ephoto_panes_unpress(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+
+ if (!tb->ephoto->config->fsel_hide)
+ tb->ephoto->config->lpane_size = elm_panes_content_left_size_get(tb->panes);
+}
+
+static void _ephoto_panes_double_clicked(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ double tmp_size = 0.0;
+
+ tmp_size = elm_panes_content_left_size_get(tb->panes);
+
+ if (tmp_size > 0)
+ {
+ _ephoto_dir_hide_folders(tb, NULL, NULL);
+ }
+ else
+ {
+ _ephoto_dir_show_folders(tb, NULL, NULL);
+ }
+}
+
+static void
+_ephoto_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Ecore_Event_Handler *handler;
+
+ _todo_items_free(tb);
+ EINA_LIST_FREE(tb->handlers, handler) ecore_event_handler_del(handler);
+ if (tb->animator.todo_items)
+ {
+ ecore_animator_del(tb->animator.todo_items);
+ tb->animator.todo_items = NULL;
+ }
+ if (tb->ls)
+ {
+ tb->main_deleted = EINA_TRUE;
+ eio_file_cancel(tb->ls);
+ return;
+ }
+ if (tb->cut_items)
+ eina_list_free(tb->cut_items);
+ else if (tb->copy_items)
+ eina_list_free(tb->copy_items);
+ if (tb->ephoto->selentries)
+ eina_list_free(tb->ephoto->selentries);
+ if (tb->ephoto->searchentries)
+ eina_list_free(tb->ephoto->searchentries);
+ if (tb->searchentries)
+ eina_list_free(tb->searchentries);
+ if (tb->monitor)
+ ecore_file_monitor_del(tb->monitor);
+ free(tb);
+}
+
+
+/*Ephoto Thumb Browser Public Functions*/
+void
+ephoto_thumb_browser_insert(Ephoto *ephoto, Ephoto_Entry *entry)
+{
+ Ephoto_Thumb_Browser *tb =
+ evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
+
+ if (!entry->is_dir && !entry->item)
+ {
+ Eina_File *f;
+ const Elm_Gengrid_Item_Class *ic;
+
+ tb->totimages += 1;
+ f = eina_file_open(entry->path, EINA_FALSE);
+ entry->size = eina_file_size_get(f);
+ tb->totsize += (double) entry->size;
+ eina_file_close(f);
+
+ ic = &_ephoto_thumb_file_class;
+ if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_alpha_asc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_alpha_desc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_mod_asc, NULL, NULL);
+ else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING)
+ entry->item =
+ elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
+ _entry_cmp_grid_mod_desc, NULL, NULL);
+ if (entry->item)
+ {
+ elm_object_item_data_set(entry->item, entry);
+ }
+ else
+ {
+ ephoto_entry_free(tb->ephoto, entry);
+ }
+ _ephoto_thumb_update_info_label(tb);
+ }
+}
+
+void
+ephoto_thumb_browser_remove(Ephoto *ephoto, Ephoto_Entry *entry)
+{
+ Ephoto_Thumb_Browser *tb =
+ evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
+
+ if (!entry->is_dir)
+ {
+ tb->totimages -= 1;
+ tb->totsize -= entry->size;
+
+ if (eina_list_count(tb->ephoto->entries) == 1)
+ {
+ tb->totimages = 0;
+ tb->totsize = 0;
+ }
+ _ephoto_thumb_update_info_label(tb);
+ elm_object_item_del(entry->item);
+ }
+}
+
+void
+ephoto_thumb_browser_update(Ephoto *ephoto, Ephoto_Entry *entry)
+{
+ Ephoto_Thumb_Browser *tb =
+ evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
+
+ if (!entry->is_dir)
+ {
+ Eina_File *f;
+
+ tb->totsize -= entry->size;
+
+ f = eina_file_open(entry->path, EINA_FALSE);
+ entry->size = eina_file_size_get(f);
+ tb->totsize += (double) entry->size;
+ eina_file_close(f);
+
+ elm_gengrid_item_update(entry->item);
+ tb->totsize += entry->size;
+ _ephoto_thumb_update_info_label(tb);
+ }
+}
+
+void
+ephoto_thumb_browser_top_dir_set(Ephoto *ephoto, const char *dir)
+{
+ Ephoto_Thumb_Browser *tb =
+ evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
+
+ if (tb->monitor)
+ ecore_file_monitor_del(tb->monitor);
+ if (ephoto->top_directory)
+ eina_stringshare_replace(&ephoto->top_directory, dir);
+ else
+ ephoto->top_directory = eina_stringshare_add(dir);
+ tb->monitor = ecore_file_monitor_add(dir, _top_monitor_cb, tb);
+}
+
+void
+ephoto_thumb_browser_fsel_clear(Ephoto *ephoto)
+{
+ Ephoto_Thumb_Browser *tb =
+ evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
+
+ if (tb)
+ elm_genlist_clear(tb->fsel);
+}
+
+Evas_Object *
+ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
+{
+ Evas_Object *box = elm_box_add(parent);
+ Ephoto_Thumb_Browser *tb;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
+
+ tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
+ EINA_SAFETY_ON_NULL_GOTO(tb, error);
+
+ _ephoto_thumb_file_class.item_style = "thumb";
+ _ephoto_thumb_file_class.func.text_get = _thumb_item_text_get;
+ _ephoto_thumb_file_class.func.content_get = _thumb_file_icon_get;
+ _ephoto_thumb_file_class.func.state_get = NULL;
+ _ephoto_thumb_file_class.func.del = _thumb_item_del;
+
+ _ephoto_dir_class.item_style = "tree_effect";
+ _ephoto_dir_class.func.text_get = _dir_item_text_get;
+ _ephoto_dir_class.func.content_get = _dir_item_icon_get;
+ _ephoto_dir_class.func.state_get = NULL;
+ _ephoto_dir_class.func.del = _dir_item_del;
+
+ tb->ephoto = ephoto;
+ tb->thumbs_only = 0;
+ tb->dirs_only = 0;
+ tb->dragging = 0;
+ tb->searching = 0;
+ tb->cut_items = NULL;
+ tb->copy_items = NULL;
+ tb->dir_current = NULL;
+ tb->change_dir_job = NULL;
+ tb->last_sel = NULL;
+ tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
+ tb->main = box;
+
+ elm_box_horizontal_set(tb->main, EINA_FALSE);
+ evas_object_size_hint_weight_set(tb->main, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(tb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_event_callback_add(tb->main, EVAS_CALLBACK_DEL,
+ _ephoto_main_del, tb);
+ evas_object_event_callback_add(tb->main, EVAS_CALLBACK_KEY_DOWN,
+ _ephoto_main_key_down, tb);
+ evas_object_data_set(tb->main, "thumb_browser", tb);
+
+ tb->panes = elm_panes_add(tb->main);
+ evas_object_size_hint_weight_set(tb->panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(tb->panes, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_panes_content_left_min_size_set(tb->panes, 100);
+ elm_panes_content_left_size_set(tb->panes, tb->ephoto->config->lpane_size);
+ evas_object_smart_callback_add(tb->panes, "clicked,double",
+ _ephoto_panes_double_clicked, tb);
+ evas_object_smart_callback_add(tb->panes, "unpress",
+ _ephoto_panes_unpress, tb);
+ elm_box_pack_end(tb->main, tb->panes);
+ evas_object_show(tb->panes);
+
+ _ephoto_file_pane_add(tb);
+ elm_object_part_content_set(tb->panes, "left", tb->leftbox);
+ if (!tb->ephoto->config->fsel_hide)
+ {
+ evas_object_show(tb->leftbox);
+ }
+ else
+ {
+ evas_object_hide(tb->leftbox);
+ elm_panes_content_left_min_size_set(tb->panes, 0);
+ elm_panes_content_left_size_set(tb->panes, 0.0);
+ }
+
+ _ephoto_thumb_pane_add(tb);
+ elm_object_part_content_set(tb->panes, "right", tb->table);
tb->handlers =
eina_list_append(tb->handlers,