2010-07-01 11:49:22 -07:00
|
|
|
#include "ephoto.h"
|
2016-05-26 15:44:43 -07:00
|
|
|
#include <elm_interface_scrollable.h>
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
#define ZOOM_MAX 512
|
|
|
|
#define ZOOM_MIN 128
|
|
|
|
#define ZOOM_STEP 32
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
#define FILESEP "file://"
|
|
|
|
#define FILESEP_LEN sizeof(FILESEP) - 1
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
#define TODO_ITEM_MIN_BATCH 5
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
#define DRAG_TIMEOUT 0.3
|
|
|
|
#define ANIM_TIME 0.2
|
2015-01-16 11:39:02 -08:00
|
|
|
|
|
|
|
static Eina_Bool _5s_cancel = EINA_FALSE;
|
|
|
|
static Ecore_Timer *_5s_timeout = NULL;
|
|
|
|
|
2010-09-13 09:40:33 -07:00
|
|
|
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2010-10-09 12:13:35 -07:00
|
|
|
struct _Ephoto_Thumb_Browser
|
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto *ephoto;
|
2011-06-28 15:26:16 -07:00
|
|
|
Evas_Object *main;
|
2014-11-18 11:37:49 -08:00
|
|
|
Evas_Object *table;
|
2015-12-15 14:42:38 -08:00
|
|
|
Evas_Object *gridbox;
|
2010-10-09 12:13:35 -07:00
|
|
|
Evas_Object *grid;
|
2016-01-01 15:04:25 -08:00
|
|
|
Evas_Object *original_grid;
|
2014-11-25 12:15:27 -08:00
|
|
|
Evas_Object *nolabel;
|
2015-12-15 14:42:38 -08:00
|
|
|
Evas_Object *search;
|
2016-05-26 15:44:43 -07:00
|
|
|
Evas_Object *menu;
|
2016-08-15 10:36:50 -07:00
|
|
|
Evas_Object *hover;
|
|
|
|
Elm_Object_Item *similarity;
|
2015-12-14 12:27:11 -08:00
|
|
|
Elm_Object_Item *last_sel;
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Sort sort;
|
2011-02-24 14:26:47 -08:00
|
|
|
Eio_File *ls;
|
2016-05-26 15:44:43 -07:00
|
|
|
Eina_Bool dirs_only;
|
|
|
|
Eina_Bool thumbs_only;
|
2015-11-24 14:21:21 -08:00
|
|
|
Eina_List *cut_items;
|
|
|
|
Eina_List *copy_items;
|
2011-02-24 14:26:47 -08:00
|
|
|
Eina_List *handlers;
|
2015-11-24 14:21:21 -08:00
|
|
|
Eina_List *todo_items;
|
2016-01-01 15:04:25 -08:00
|
|
|
Eina_List *entries;
|
|
|
|
Eina_List *searchentries;
|
2016-02-24 08:03:44 -08:00
|
|
|
double totsize;
|
|
|
|
double totsize_old;
|
2015-01-24 13:19:25 -08:00
|
|
|
int totimages;
|
2016-02-24 08:03:44 -08:00
|
|
|
int totimages_old;
|
2016-01-13 13:48:11 -08:00
|
|
|
Eina_Bool dragging;
|
|
|
|
Eina_Bool searching;
|
|
|
|
Eina_Bool processing;
|
2015-11-24 14:21:21 -08:00
|
|
|
struct
|
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ecore_Animator *todo_items;
|
2015-11-24 14:21:21 -08:00
|
|
|
int count;
|
|
|
|
int processed;
|
2011-02-21 17:55:08 -08:00
|
|
|
} animator;
|
2015-11-24 14:21:21 -08:00
|
|
|
Eina_Bool main_deleted:1;
|
2010-10-09 12:13:35 -07:00
|
|
|
};
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
/*Item Classes*/
|
2015-01-24 13:19:25 -08:00
|
|
|
static Elm_Gengrid_Item_Class _ephoto_thumb_file_class;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
/*Main Callbacks*/
|
|
|
|
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_main_del(void *data, Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
|
|
|
|
|
|
|
|
/*Thumb Pane Functions*/
|
2016-01-01 15:04:25 -08:00
|
|
|
static void _ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info);
|
2016-04-08 09:49:40 -07:00
|
|
|
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);
|
2016-09-01 14:21:37 -07:00
|
|
|
static char * _drag_data_extract(char **drag_data);
|
2016-04-08 09:49:40 -07:00
|
|
|
|
|
|
|
/*Common Callbacks*/
|
2016-06-01 12:57:39 -07:00
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_menu_dismissed_cb(void *data, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
2016-02-24 08:03:44 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2016-02-24 08:03:44 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_del(obj);
|
|
|
|
elm_object_focus_set(tb->main, EINA_TRUE);
|
2016-06-01 12:57:39 -07:00
|
|
|
}
|
2016-02-24 08:03:44 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
|
|
|
_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)
|
2016-02-24 08:03:44 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
file = elm_object_item_data_get(item);
|
|
|
|
paths = eina_list_append(paths, strdup(file->path));
|
|
|
|
item = elm_gengrid_item_next_get(item);
|
2016-02-24 08:03:44 -08:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
if (eina_list_count(paths) <= 0)
|
|
|
|
return;
|
|
|
|
ephoto_file_empty_trash(tb->ephoto, paths);
|
2016-02-24 08:03:44 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_5s_timeout_gone(void *data)
|
2015-12-01 15:02:19 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_drag_cancel(data);
|
|
|
|
_5s_timeout = NULL;
|
2015-12-01 15:02:19 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2015-12-01 15:02:19 -08:00
|
|
|
}
|
|
|
|
|
2016-09-01 14:21:37 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_drop_dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Object_Item *it EINA_UNUSED,
|
|
|
|
Elm_Selection_Data *ev, int xposret EINA_UNUSED, int yposret EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eina_List *files = NULL;
|
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
|
|
|
|
const char *path = tb->ephoto->config->directory;
|
|
|
|
char *dir;
|
|
|
|
|
|
|
|
if (!ev->data)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (ev->len <= 0)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!path)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
char *dd = strdup(ev->data);
|
|
|
|
|
|
|
|
if (!dd)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
char *s = _drag_data_extract(&dd);
|
|
|
|
|
|
|
|
while (s)
|
|
|
|
{
|
|
|
|
dir = ecore_file_dir_get(s);
|
|
|
|
if (!strcmp(path, dir))
|
|
|
|
{
|
|
|
|
free(dir);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (evas_object_image_extension_can_load_get(basename(s)))
|
|
|
|
files = eina_list_append(files, s);
|
|
|
|
free(dir);
|
|
|
|
s = _drag_data_extract(&dd);
|
|
|
|
}
|
|
|
|
free(dd);
|
|
|
|
|
|
|
|
if (eina_list_count(files) <= 0)
|
|
|
|
return EINA_TRUE;
|
|
|
|
if (tb->ephoto->config->move_drop)
|
|
|
|
ephoto_file_move(tb->ephoto, files, path);
|
|
|
|
else
|
|
|
|
ephoto_file_copy(tb->ephoto, files, path);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Elm_Object_Item *
|
|
|
|
_drop_item_getcb(Evas_Object *obj EINA_UNUSED, Evas_Coord x EINA_UNUSED,
|
|
|
|
Evas_Coord y EINA_UNUSED,int *xposret EINA_UNUSED, int *yposret EINA_UNUSED)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drop_enter(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drop_leave(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_drop_pos(void *data EINA_UNUSED, Evas_Object *cont EINA_UNUSED,
|
|
|
|
Elm_Object_Item *it EINA_UNUSED, Evas_Coord x EINA_UNUSED,
|
|
|
|
Evas_Coord y EINA_UNUSED, int xposret EINA_UNUSED,
|
|
|
|
int yposret EINA_UNUSED, Elm_Xdnd_Action action EINA_UNUSED)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_drag_data_extract(char **drag_data)
|
|
|
|
{
|
|
|
|
char *uri = NULL;
|
|
|
|
|
|
|
|
if (!drag_data)
|
|
|
|
return uri;
|
|
|
|
|
|
|
|
char *p = *drag_data;
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
return uri;
|
|
|
|
char *s = strstr(p, FILESEP);
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
p += FILESEP_LEN;
|
|
|
|
s = strchr(p, '\n');
|
|
|
|
uri = p;
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
if (s - p > 0)
|
|
|
|
{
|
|
|
|
char *s1 = s - 1;
|
|
|
|
|
|
|
|
if (s1[0] == '\r')
|
|
|
|
s1[0] = '\0';
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *s2 = s + 1;
|
|
|
|
|
|
|
|
if (s2[0] == '\r')
|
|
|
|
{
|
|
|
|
s[0] = '\0';
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s[0] = '\0';
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
p = NULL;
|
|
|
|
*drag_data = s;
|
|
|
|
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
2015-12-01 15:02:19 -08:00
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_dnd_drag_start(void *data EINA_UNUSED, Evas_Object *obj)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
|
2015-12-01 15:02:19 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (_5s_cancel)
|
|
|
|
_5s_timeout = ecore_timer_add(5.0, _5s_timeout_gone, obj);
|
|
|
|
elm_object_cursor_set(tb->main, ELM_CURSOR_HAND2);
|
2016-05-26 15:44:43 -07:00
|
|
|
|
|
|
|
ephoto_show_folders(tb->ephoto, EINA_FALSE);
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->dragging = 1;
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
|
|
|
_dnd_drag_done(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
Eina_Bool doaccept EINA_UNUSED)
|
2015-01-24 13:19:25 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
|
2016-01-19 11:58:28 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (_5s_cancel)
|
|
|
|
{
|
|
|
|
ecore_timer_del(_5s_timeout);
|
|
|
|
_5s_timeout = NULL;
|
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(data))
|
|
|
|
eina_list_free(data);
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_object_cursor_unset(tb->main);
|
|
|
|
tb->dragging = 0;
|
|
|
|
return;
|
2015-01-24 13:19:25 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static const char *
|
|
|
|
_dnd_drag_data_build(Eina_List **items)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
const char *drag_data = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (*items)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
Ephoto_Entry *e;
|
|
|
|
unsigned int len = 0;
|
2010-10-09 18:13:53 -07:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
EINA_LIST_FOREACH(*items, l, it)
|
|
|
|
{
|
|
|
|
e = elm_object_item_data_get(it);
|
|
|
|
if (e->path)
|
|
|
|
len += strlen(e->path);
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
drag_data =
|
|
|
|
malloc(len + eina_list_count(*items) * (FILESEP_LEN + 1) + 1);
|
|
|
|
strcpy((char *) drag_data, "");
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(*items, l, it)
|
2016-05-26 15:44:43 -07:00
|
|
|
{
|
|
|
|
e = elm_object_item_data_get(it);
|
|
|
|
if (e->path)
|
|
|
|
{
|
|
|
|
strcat((char *) drag_data, FILESEP);
|
|
|
|
strcat((char *) drag_data, e->path);
|
|
|
|
strcat((char *) drag_data, "\n");
|
|
|
|
}
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
return drag_data;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_dnd_create_icon(void *data, Evas_Object *win, Evas_Coord *xoff,
|
|
|
|
Evas_Coord *yoff)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
Evas_Object *icon = NULL;
|
|
|
|
Evas_Object *o = elm_object_item_part_content_get(data, "elm.swallow.icon");
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
int xm, ym, w = 30, h = 30;
|
|
|
|
const char *f;
|
|
|
|
const char *g;
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_image_file_get(o, &f, &g);
|
|
|
|
evas_pointer_canvas_xy_get(evas_object_evas_get(o), &xm, &ym);
|
|
|
|
if (xoff)
|
|
|
|
*xoff = xm - (w / 2);
|
|
|
|
if (yoff)
|
|
|
|
*yoff = ym - (h / 2);
|
|
|
|
icon = elm_icon_add(win);
|
|
|
|
elm_image_file_set(icon, f, g);
|
|
|
|
evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
if (xoff && yoff)
|
|
|
|
evas_object_move(icon, *xoff, *yoff);
|
|
|
|
evas_object_resize(icon, w, h);
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
return icon;
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static const char *
|
|
|
|
_dnd_get_drag_data(Evas_Object *obj, Elm_Object_Item *it, Eina_List **items)
|
2015-12-15 14:42:38 -08:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
const char *drag_data = NULL;
|
2016-04-08 09:49:40 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
*items = eina_list_clone(elm_gengrid_selected_items_get(obj));
|
|
|
|
if (it)
|
|
|
|
{
|
|
|
|
if (!elm_gengrid_item_selected_get(it))
|
|
|
|
*items = eina_list_append(*items, it);
|
|
|
|
}
|
|
|
|
drag_data = _dnd_drag_data_build(items);
|
2015-12-15 14:42:38 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
return drag_data;
|
|
|
|
}
|
2015-12-15 14:42:38 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static Elm_Object_Item *
|
|
|
|
_dnd_item_get(Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *xposret,
|
|
|
|
int *yposret)
|
|
|
|
{
|
|
|
|
Elm_Object_Item *item;
|
2015-12-15 14:42:38 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
item = elm_gengrid_at_xy_item_get(obj, x, y, xposret, yposret);
|
|
|
|
return item;
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_dnd_item_data_get(Evas_Object *obj, Elm_Object_Item *it,
|
|
|
|
Elm_Drag_User_Info *info)
|
|
|
|
{
|
|
|
|
info->format = ELM_SEL_FORMAT_TARGETS;
|
|
|
|
info->createicon = _dnd_create_icon;
|
|
|
|
info->createdata = it;
|
|
|
|
info->dragstart = _dnd_drag_start;
|
|
|
|
info->icons = NULL;
|
|
|
|
info->dragdone = _dnd_drag_done;
|
|
|
|
info->data = _dnd_get_drag_data(obj, it, (Eina_List **) & info->donecbdata);
|
|
|
|
info->acceptdata = info->donecbdata;
|
|
|
|
if (info->data)
|
|
|
|
return EINA_TRUE;
|
|
|
|
else
|
|
|
|
return EINA_FALSE;
|
2015-12-15 14:42:38 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
/*Thumb Pane Callbacks*/
|
|
|
|
static char *
|
|
|
|
_thumb_item_text_get(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *part EINA_UNUSED)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Entry *e = data;
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2016-09-25 08:57:14 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
|
|
|
|
if (!e->label)
|
|
|
|
return NULL;
|
2016-04-08 09:49:40 -07:00
|
|
|
return strdup(e->label);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2016-08-15 06:44:29 -07:00
|
|
|
_thumb_file_icon_get(void *data, Evas_Object *obj,
|
2016-04-08 09:49:40 -07:00
|
|
|
const char *part)
|
|
|
|
{
|
|
|
|
Ephoto_Entry *e = data;
|
2016-08-15 06:44:29 -07:00
|
|
|
Evas_Object *thumb = NULL;
|
2016-04-08 09:49:40 -07:00
|
|
|
|
|
|
|
if (strcmp(part, "elm.swallow.icon"))
|
|
|
|
return NULL;
|
|
|
|
|
2016-08-15 06:44:29 -07:00
|
|
|
if (e)
|
|
|
|
{
|
2016-08-15 10:36:50 -07:00
|
|
|
thumb = ephoto_thumb_add(e->ephoto, obj, e);
|
2016-08-15 06:44:29 -07:00
|
|
|
evas_object_show(thumb);
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
return thumb;
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
|
|
|
|
2014-11-19 14:50:56 -08:00
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_thumb_item_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
|
2014-11-19 14:50:56 -08:00
|
|
|
{
|
2016-08-15 10:36:50 -07:00
|
|
|
/*The entry is already freed when changing directories*/
|
2014-11-19 14:50:56 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static int
|
|
|
|
_entry_cmp_grid_alpha_asc(const void *pa, const void *pb)
|
2015-01-25 09:11:03 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
const Ephoto_Entry *a, *b;
|
2015-01-25 09:11:03 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
a = elm_object_item_data_get(pa);
|
|
|
|
b = elm_object_item_data_get(pb);
|
|
|
|
|
|
|
|
return strcasecmp(a->basename, b->basename);
|
2015-01-25 09:11:03 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static int
|
|
|
|
_entry_cmp_grid_alpha_desc(const void *pa, const void *pb)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
const Ephoto_Entry *a, *b;
|
|
|
|
int i;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
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;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
return i;
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static int
|
|
|
|
_entry_cmp_grid_mod_asc(const void *pa, const void *pb)
|
|
|
|
{
|
|
|
|
const Ephoto_Entry *a, *b;
|
|
|
|
long long moda, modb;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
a = elm_object_item_data_get(pa);
|
|
|
|
b = elm_object_item_data_get(pb);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
moda = ecore_file_mod_time(a->path);
|
|
|
|
modb = ecore_file_mod_time(b->path);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (moda < modb)
|
|
|
|
return -1;
|
|
|
|
else if (moda > modb)
|
|
|
|
return 1;
|
2015-11-24 14:21:21 -08:00
|
|
|
else
|
2016-04-08 09:49:40 -07:00
|
|
|
return strcasecmp(a->basename, b->basename);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static int
|
|
|
|
_entry_cmp_grid_mod_desc(const void *pa, const void *pb)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
const Ephoto_Entry *a, *b;
|
|
|
|
long long moda, modb;
|
2015-12-01 15:02:19 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
a = elm_object_item_data_get(pa);
|
|
|
|
b = elm_object_item_data_get(pb);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
moda = ecore_file_mod_time(a->path);
|
|
|
|
modb = ecore_file_mod_time(b->path);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (moda < modb)
|
|
|
|
return 1;
|
|
|
|
else if (moda > modb)
|
|
|
|
return -1;
|
|
|
|
else
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
int i;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
i = strcasecmp(a->basename, b->basename);
|
|
|
|
if (i < 0)
|
|
|
|
i = 1;
|
|
|
|
else if (i > 0)
|
|
|
|
i = -1;
|
|
|
|
return i;
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2016-08-15 10:36:50 -07:00
|
|
|
static int
|
|
|
|
_entry_cmp_grid_similarity(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);
|
|
|
|
|
|
|
|
if (!a->sort_id || !b->sort_id)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return strcmp(a->sort_id, b->sort_id);
|
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
2016-05-26 15:44:43 -07:00
|
|
|
_sort_alpha_asc(void *data, Evas_Object *obj,
|
2016-04-08 09:49:40 -07:00
|
|
|
void *event_data EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Object *ic;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
|
2016-08-15 15:21:04 -07:00
|
|
|
tb->ephoto->sort = tb->sort;
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->thumbs_only = 1;
|
|
|
|
tb->dirs_only = 0;
|
2016-05-26 15:44:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_icon_standard_set(ic, "view-sort-ascending");
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_part_content_set(obj, "icon", ic);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_show(ic);
|
|
|
|
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
|
|
|
|
NULL, tb->dirs_only, tb->thumbs_only);
|
2016-08-18 09:16:11 -07:00
|
|
|
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_sort_alpha_desc(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_data EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2016-04-08 09:49:40 -07:00
|
|
|
Evas_Object *ic;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->sort = EPHOTO_SORT_ALPHABETICAL_DESCENDING;
|
2016-08-15 15:21:04 -07:00
|
|
|
tb->ephoto->sort = tb->sort;
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->thumbs_only = 1;
|
|
|
|
tb->dirs_only = 0;
|
2016-05-26 15:44:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_icon_standard_set(ic, "view-sort-descending");
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_part_content_set(obj, "icon", ic);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_show(ic);
|
|
|
|
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
|
|
|
|
NULL, tb->dirs_only, tb->thumbs_only);
|
2016-08-18 09:16:11 -07:00
|
|
|
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_sort_mod_asc(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_data EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2016-04-08 09:49:40 -07:00
|
|
|
Evas_Object *ic;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->sort = EPHOTO_SORT_MODTIME_ASCENDING;
|
2016-08-15 15:21:04 -07:00
|
|
|
tb->ephoto->sort = tb->sort;
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->thumbs_only = 1;
|
|
|
|
tb->dirs_only = 0;
|
2016-05-26 15:44:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_icon_standard_set(ic, "view-sort-ascending");
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_part_content_set(obj, "icon", ic);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_show(ic);
|
|
|
|
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
|
|
|
|
NULL, tb->dirs_only, tb->thumbs_only);
|
2016-08-18 09:16:11 -07:00
|
|
|
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_sort_mod_desc(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_data EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Object *ic;
|
|
|
|
|
|
|
|
tb->sort = EPHOTO_SORT_MODTIME_DESCENDING;
|
2016-08-15 15:21:04 -07:00
|
|
|
tb->ephoto->sort = tb->sort;
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->thumbs_only = 1;
|
|
|
|
tb->dirs_only = 0;
|
2016-05-26 15:44:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_icon_standard_set(ic, "view-sort-descending");
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_part_content_set(obj, "icon", ic);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_show(ic);
|
|
|
|
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
|
|
|
|
NULL, tb->dirs_only, tb->thumbs_only);
|
2016-08-18 09:16:11 -07:00
|
|
|
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2016-08-15 10:36:50 -07:00
|
|
|
static void
|
|
|
|
_sort_similarity(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2016-08-15 20:30:58 -07:00
|
|
|
Evas_Object *ic;
|
2016-08-15 10:36:50 -07:00
|
|
|
|
|
|
|
tb->sort = EPHOTO_SORT_SIMILARITY;
|
2016-08-15 20:30:58 -07:00
|
|
|
tb->ephoto->sort = EPHOTO_SORT_SIMILARITY;
|
2016-08-15 10:36:50 -07:00
|
|
|
tb->thumbs_only = 1;
|
|
|
|
tb->dirs_only = 0;
|
2016-08-15 15:21:04 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-08-15 10:36:50 -07:00
|
|
|
elm_icon_standard_set(ic, "view-sort-ascending");
|
|
|
|
elm_object_part_content_set(obj, "icon", ic);
|
|
|
|
evas_object_show(ic);
|
2016-08-15 20:30:58 -07:00
|
|
|
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
|
|
|
|
NULL, tb->dirs_only, tb->thumbs_only);
|
2016-08-18 09:16:11 -07:00
|
|
|
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
|
2016-08-15 10:36:50 -07:00
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
|
|
|
_zoom_in(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_zoom_set(tb, zoom);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_zoom_out(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_zoom_set(tb, zoom);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static void
|
|
|
|
_view_single(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
Eina_List *selected, *s;
|
|
|
|
Elm_Object_Item *item;
|
|
|
|
|
|
|
|
if (it)
|
|
|
|
entry = elm_object_item_data_get(it);
|
|
|
|
else
|
|
|
|
entry = eina_list_nth(tb->entries, 0);
|
|
|
|
selected =
|
|
|
|
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
|
|
|
|
if (eina_list_count(selected) <= 1 && tb->searchentries)
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-05-26 15:44:43 -07:00
|
|
|
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
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-05-26 15:44:43 -07:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->searchentries))
|
2016-05-26 15:44:43 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_grid_menu_select_all_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Elm_Object_Item *item;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
item = elm_gengrid_first_item_get(tb->grid);
|
|
|
|
while (item)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_gengrid_item_selected_set(item, EINA_TRUE);
|
|
|
|
item = elm_gengrid_item_next_get(item);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
|
|
|
_grid_menu_clear_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Elm_Object_Item *item;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
item = elm_gengrid_first_item_get(tb->grid);
|
|
|
|
while (item)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
elm_gengrid_item_selected_set(item, EINA_FALSE);
|
|
|
|
item = elm_gengrid_item_next_get(item);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
|
|
|
_grid_menu_cut_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Eina_List *selection =
|
|
|
|
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
|
|
|
|
Eina_List *f;
|
|
|
|
Elm_Object_Item *item;
|
|
|
|
Ephoto_Entry *file;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (eina_list_count(selection) <= 0)
|
|
|
|
return;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (tb->cut_items)
|
|
|
|
{
|
|
|
|
eina_list_free(tb->cut_items);
|
|
|
|
tb->cut_items = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
if (tb->copy_items)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->copy_items);
|
|
|
|
tb->copy_items = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
EINA_LIST_FOREACH(selection, f, item)
|
|
|
|
{
|
|
|
|
file = elm_object_item_data_get(item);
|
|
|
|
tb->cut_items = eina_list_append(tb->cut_items, strdup(file->path));
|
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(selection))
|
|
|
|
eina_list_free(selection);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_grid_menu_copy_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Eina_List *selection =
|
|
|
|
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
|
|
|
|
Eina_List *f;
|
|
|
|
Elm_Object_Item *item;
|
|
|
|
Ephoto_Entry *file;
|
|
|
|
|
|
|
|
if (eina_list_count(selection) <= 0)
|
|
|
|
return;
|
|
|
|
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->cut_items))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
eina_list_free(tb->cut_items);
|
|
|
|
tb->cut_items = NULL;
|
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->copy_items))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
eina_list_free(tb->copy_items);
|
|
|
|
tb->copy_items = NULL;
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(selection, f, item)
|
|
|
|
{
|
|
|
|
file = elm_object_item_data_get(item);
|
|
|
|
tb->copy_items = eina_list_append(tb->copy_items, strdup(file->path));
|
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(selection))
|
|
|
|
eina_list_free(selection);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_grid_menu_paste_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->cut_items))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-03-25 13:45:18 -07:00
|
|
|
ephoto_file_paste(tb->ephoto, eina_list_clone(tb->cut_items), EINA_FALSE,
|
|
|
|
tb->ephoto->config->directory);
|
|
|
|
eina_list_free(tb->cut_items);
|
|
|
|
tb->cut_items = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
else if (eina_list_count(tb->copy_items))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-03-25 13:45:18 -07:00
|
|
|
ephoto_file_paste(tb->ephoto, eina_list_clone(tb->copy_items), EINA_TRUE,
|
|
|
|
tb->ephoto->config->directory);
|
|
|
|
eina_list_free(tb->copy_items);
|
|
|
|
tb->copy_items = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_grid_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Elm_Object_Item *item = data;
|
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(item, "thumb_browser");
|
|
|
|
Ephoto_Entry *file;
|
|
|
|
|
|
|
|
file = elm_object_item_data_get(item);
|
2016-03-25 13:45:18 -07:00
|
|
|
ephoto_file_rename(tb->ephoto, file->path);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_data_del(item, "thumb_browser");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_grid_menu_delete_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Eina_List *paths = NULL, *f;
|
|
|
|
Eina_List *selection =
|
|
|
|
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
|
|
|
|
Elm_Object_Item *item;
|
|
|
|
Ephoto_Entry *file;
|
|
|
|
|
|
|
|
if (eina_list_count(selection) <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(selection, f, item)
|
|
|
|
{
|
|
|
|
file = elm_object_item_data_get(item);
|
|
|
|
if (ecore_file_exists(file->path))
|
|
|
|
paths = eina_list_append(paths, strdup(file->path));
|
|
|
|
}
|
2016-03-25 13:45:18 -07:00
|
|
|
ephoto_file_delete(tb->ephoto, paths, EINA_FILE_REG);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(selection))
|
|
|
|
eina_list_free(selection);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
|
2016-01-20 07:56:10 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED, void *event_info)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2016-05-26 15:44:43 -07:00
|
|
|
Evas_Object *menu;
|
2016-04-08 09:49:40 -07:00
|
|
|
Elm_Object_Item *item;
|
2015-11-24 14:21:21 -08:00
|
|
|
Evas_Event_Mouse_Up *info = event_info;
|
2016-04-08 09:49:40 -07:00
|
|
|
Eina_Bool ctrl = evas_key_modifier_is_set(info->modifiers, "Control");
|
|
|
|
Eina_Bool shift = evas_key_modifier_is_set(info->modifiers, "Shift");
|
2016-05-26 15:44:43 -07:00
|
|
|
Eina_Bool clear_selection = EINA_FALSE;
|
2015-11-24 14:21:21 -08:00
|
|
|
char trash[PATH_MAX];
|
2016-04-08 09:49:40 -07:00
|
|
|
const Eina_List *selected = elm_gengrid_selected_items_get(tb->grid);
|
2015-11-24 14:21:21 -08:00
|
|
|
int x, y;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_pointer_canvas_xy_get(evas_object_evas_get(tb->grid), &x, &y);
|
|
|
|
item = elm_gengrid_at_xy_item_get(tb->grid, x, y, 0, 0);
|
2015-12-01 15:02:19 -08:00
|
|
|
|
2015-12-01 21:03:50 -08:00
|
|
|
if (info->button == 1 && item)
|
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
if (ctrl)
|
2015-12-01 21:03:50 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->last_sel = item;
|
2015-12-01 21:03:50 -08:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
else if (shift)
|
2015-12-14 13:21:23 -08:00
|
|
|
{
|
|
|
|
if (tb->last_sel)
|
|
|
|
{
|
|
|
|
int one, two, i;
|
|
|
|
Elm_Object_Item *it, *cur = tb->last_sel;
|
|
|
|
one = elm_gengrid_item_index_get(tb->last_sel);
|
|
|
|
two = elm_gengrid_item_index_get(item);
|
|
|
|
if (two < one)
|
|
|
|
{
|
|
|
|
for (i = one; i > (two+1); i--)
|
|
|
|
{
|
|
|
|
it = elm_gengrid_item_prev_get(cur);
|
|
|
|
elm_gengrid_item_selected_set(it, EINA_TRUE);
|
|
|
|
cur = it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (two > one)
|
|
|
|
{
|
|
|
|
for (i = one; i < (two-1); i++)
|
|
|
|
{
|
|
|
|
it = elm_gengrid_item_next_get(cur);
|
|
|
|
elm_gengrid_item_selected_set(it, EINA_TRUE);
|
|
|
|
cur = it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tb->last_sel = item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tb->last_sel = item;
|
|
|
|
}
|
2015-12-14 12:27:11 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
clear_selection = EINA_TRUE;
|
2015-12-14 13:21:23 -08:00
|
|
|
tb->last_sel = item;
|
2015-12-14 12:27:11 -08:00
|
|
|
}
|
|
|
|
}
|
2015-12-15 10:44:54 -08:00
|
|
|
if (info->button == 1 && !item)
|
2016-05-26 15:44:43 -07:00
|
|
|
clear_selection = EINA_TRUE;
|
|
|
|
|
|
|
|
else if (info->button == 3 && item)
|
|
|
|
{
|
|
|
|
if (!elm_gengrid_item_selected_get(item))
|
|
|
|
clear_selection = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (clear_selection)
|
2015-12-15 10:44:54 -08:00
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
Eina_List *sel = eina_list_clone(selected);
|
2015-12-15 10:44:54 -08:00
|
|
|
Elm_Object_Item *it;
|
|
|
|
if (eina_list_count(sel) > 0)
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
EINA_LIST_FREE(sel, it)
|
2015-12-15 10:44:54 -08:00
|
|
|
{
|
|
|
|
elm_gengrid_item_selected_set(it, EINA_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
if (info->button != 3)
|
|
|
|
return;
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
if (!elm_gengrid_first_item_get(tb->grid) && !tb->cut_items)
|
|
|
|
{
|
|
|
|
if (!tb->copy_items)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
|
|
|
|
|
|
|
if (item)
|
2016-05-26 15:44:43 -07:00
|
|
|
{
|
|
|
|
elm_gengrid_item_selected_set(item, EINA_TRUE);
|
|
|
|
tb->last_sel = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
selected = elm_gengrid_selected_items_get(tb->grid);
|
|
|
|
|
2016-03-30 11:17:31 -07:00
|
|
|
menu = elm_menu_add(tb->ephoto->win);
|
2016-03-25 13:45:18 -07:00
|
|
|
elm_menu_move(menu, x, y);
|
2016-05-26 15:44:43 -07:00
|
|
|
|
2016-03-30 11:17:31 -07:00
|
|
|
if (elm_gengrid_first_item_get(tb->grid))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_menu_item_add(menu, NULL, "system-search", _("Search"),
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_search_start, tb);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_menu_item_add(menu, NULL, "edit-select-all", _("Select All"),
|
2016-03-30 11:17:31 -07:00
|
|
|
_grid_menu_select_all_cb, tb);
|
2016-05-26 15:44:43 -07:00
|
|
|
if (eina_list_count(selected) || item)
|
|
|
|
elm_menu_item_add(menu, NULL, "edit-clear", _("Select None"),
|
|
|
|
_grid_menu_clear_cb, tb);
|
2016-04-08 09:49:40 -07:00
|
|
|
if (item)
|
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_menu_item_add(menu, NULL, "edit", _("Rename"),
|
|
|
|
_grid_menu_rename_cb, item);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_data_set(item, "thumb_browser", tb);
|
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
if (eina_list_count(selected))
|
|
|
|
{
|
|
|
|
elm_menu_item_add(menu, NULL, "edit-cut", _("Cut"),
|
|
|
|
_grid_menu_cut_cb, tb);
|
|
|
|
elm_menu_item_add(menu, NULL, "edit-copy", _("Copy"),
|
|
|
|
_grid_menu_copy_cb, tb);
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
if (tb->cut_items || tb->copy_items)
|
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_menu_item_add(menu, NULL, "edit-paste", _("Paste"),
|
|
|
|
_grid_menu_paste_cb, tb);
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
if (elm_gengrid_first_item_get(tb->grid))
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
if (!strcmp(tb->ephoto->config->directory, trash))
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_menu_item_add(menu, NULL, "edit-delete", _("Empty Trash"),
|
|
|
|
_menu_empty_cb, tb);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elm_menu_item_add(menu, NULL, "edit-delete", _("Delete"),
|
2016-04-08 09:49:40 -07:00
|
|
|
_grid_menu_delete_cb, tb);
|
|
|
|
}
|
|
|
|
}
|
2016-06-01 12:57:39 -07:00
|
|
|
evas_object_smart_callback_add(menu, "dismissed", _menu_dismissed_cb,
|
|
|
|
tb);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_show(menu);
|
|
|
|
}
|
|
|
|
static void
|
|
|
|
_grid_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Event_Mouse_Wheel *ev = event_info;
|
|
|
|
Eina_Bool ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
|
|
|
|
if (ctrl)
|
|
|
|
{
|
|
|
|
if (ev->z > 0)
|
|
|
|
_zoom_out(tb, NULL, NULL);
|
|
|
|
else
|
|
|
|
_zoom_in(tb, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static void
|
|
|
|
_grid_changed(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Coord w, h, gw, gh;
|
|
|
|
Edje_Message_Int_Set *msg;
|
|
|
|
|
|
|
|
if (tb->ephoto->state != EPHOTO_STATE_THUMB)
|
|
|
|
return;
|
|
|
|
|
|
|
|
elm_scroller_region_get(tb->grid, 0, 0, &w, &h);
|
|
|
|
evas_object_geometry_get(tb->grid, 0, 0, &gw, &gh);
|
|
|
|
gw -= w;
|
|
|
|
gh -= h;
|
|
|
|
msg = alloca(sizeof(Edje_Message_Int_Set) + (2 * sizeof(int)));
|
|
|
|
msg->count = 2;
|
|
|
|
msg->val[0] = gw;
|
|
|
|
msg->val[1] = gh;
|
|
|
|
edje_object_message_send(elm_layout_edje_get(tb->ephoto->layout),
|
|
|
|
EDJE_MESSAGE_INT_SET, 1, msg);
|
|
|
|
}
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
static void
|
|
|
|
_ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
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));
|
|
|
|
if (eina_list_count(selected) <= 1 && tb->searchentries)
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
elm_gengrid_item_selected_set(item, EINA_TRUE);
|
|
|
|
tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
|
|
|
|
elm_object_item_data_get(item));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->searchentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->searchentries);
|
|
|
|
tb->ephoto->selentries = NULL;
|
|
|
|
tb->ephoto->searchentries = NULL;
|
|
|
|
}
|
|
|
|
evas_object_smart_callback_call(tb->main, "view", e);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(selected))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(selected);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Thumb Pane Functions*/
|
2016-05-26 15:44:43 -07:00
|
|
|
void
|
|
|
|
ephoto_thumb_browser_update_info_label(Ephoto *ephoto)
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
char isize[PATH_MAX];
|
|
|
|
char image_info[PATH_MAX];
|
|
|
|
double totsize;
|
2016-05-26 15:44:43 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(ephoto->thumb_browser,
|
|
|
|
"thumb_browser");
|
2016-04-08 09:49:40 -07:00
|
|
|
|
|
|
|
if (!tb->totimages)
|
|
|
|
{
|
2016-05-31 09:48:40 -07:00
|
|
|
if (tb->searching)
|
|
|
|
elm_object_text_set(tb->nolabel,
|
|
|
|
_("No images matched your search"));
|
|
|
|
else
|
|
|
|
elm_object_text_set(tb->nolabel,
|
|
|
|
_("There are no images in this directory"));
|
2016-04-08 09:49:40 -07:00
|
|
|
snprintf(buf, PATH_MAX, "<b>%s:</b> 0 %s <b>%s:</b> 0%s",
|
|
|
|
_("Total"), ngettext("image", "images", 0), _("Size"),
|
|
|
|
ngettext("B", "B", 0));
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_text_set(tb->ephoto->infolabel, buf);
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-02 14:45:57 -07:00
|
|
|
if (tb->nolabel)
|
|
|
|
elm_object_text_set(tb->nolabel, " ");
|
2016-04-08 09:49:40 -07:00
|
|
|
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, "<b>%s:</b> %d %s <b>%s:</b> %s",
|
|
|
|
_("Total"), tb->totimages, ngettext("image", "images",
|
|
|
|
tb->totimages), _("Size"), isize);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_text_set(tb->ephoto->infolabel, image_info);
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2016-10-10 11:43:40 -07:00
|
|
|
elm_gengrid_clear(tb->grid);
|
2016-04-08 09:49:40 -07:00
|
|
|
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);
|
2016-08-15 15:21:04 -07:00
|
|
|
EINA_LIST_FREE(sel, o)
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
|
|
|
elm_gengrid_item_selected_set(o, EINA_FALSE);
|
|
|
|
}
|
|
|
|
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);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->searchentries))
|
|
|
|
eina_list_free(tb->searchentries);
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->searchentries = NULL;
|
|
|
|
if (results)
|
|
|
|
{
|
|
|
|
tb->totimages = 0;
|
|
|
|
tb->totsize = 0;
|
|
|
|
EINA_LIST_FOREACH(results, l, o)
|
|
|
|
{
|
2016-08-15 06:44:29 -07:00
|
|
|
const Elm_Gengrid_Item_Class *ic = NULL;
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Entry *entry = NULL, *e = NULL;
|
|
|
|
|
2016-08-15 06:44:29 -07:00
|
|
|
ic = &_ephoto_thumb_file_class;
|
2016-04-08 09:49:40 -07:00
|
|
|
entry = elm_object_item_data_get(o);
|
|
|
|
e = ephoto_entry_new(tb->ephoto, entry->path, entry->label,
|
|
|
|
EINA_FILE_REG);
|
2016-08-15 06:44:29 -07:00
|
|
|
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);
|
2016-08-15 20:30:58 -07:00
|
|
|
else if (tb->sort == EPHOTO_SORT_SIMILARITY)
|
|
|
|
e->item =
|
|
|
|
elm_gengrid_item_sorted_insert(tb->grid, ic, e,
|
|
|
|
_entry_cmp_grid_similarity, NULL, NULL);
|
|
|
|
if (e->item)
|
2016-08-15 06:44:29 -07:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
tb->entries = tb->searchentries;
|
2016-08-15 06:44:29 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(results))
|
|
|
|
eina_list_free(results);
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tb->totimages = 0;
|
|
|
|
tb->totsize = 0;
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
2016-04-08 09:49:40 -07:00
|
|
|
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;
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->searchentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->searchentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->searchentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->searchentries);
|
|
|
|
tb->ephoto->searchentries = NULL;
|
|
|
|
tb->searchentries = NULL;
|
|
|
|
if (tb->original_grid)
|
|
|
|
{
|
2016-10-10 11:43:40 -07:00
|
|
|
elm_gengrid_clear(tb->grid);
|
2016-04-08 09:49:40 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
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;
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->totimages_old = 0;
|
|
|
|
tb->totsize_old = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ephoto_thumb_search_start(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Object *hbox, *search;
|
|
|
|
|
|
|
|
if (tb->processing)
|
|
|
|
return;
|
|
|
|
if (!tb->searching)
|
|
|
|
tb->searching = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_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_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_thumb_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);
|
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static void
|
|
|
|
_ephoto_thumb_view_add(Ephoto_Thumb_Browser *tb)
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
tb->table = elm_table_add(tb->main);
|
2016-04-08 09:49:40 -07:00
|
|
|
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);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_box_pack_end(tb->main, tb->table);
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_show(tb->table);
|
|
|
|
|
|
|
|
tb->nolabel = elm_label_add(tb->table);
|
|
|
|
elm_label_line_wrap_set(tb->nolabel, ELM_WRAP_WORD);
|
|
|
|
elm_object_text_set(tb->nolabel,
|
|
|
|
_("There are no images in this directory"));
|
|
|
|
evas_object_size_hint_weight_set(tb->nolabel, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(tb->nolabel, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_aspect_set(tb->nolabel, EVAS_ASPECT_CONTROL_VERTICAL,
|
|
|
|
1, 1);
|
|
|
|
elm_table_pack(tb->table, tb->nolabel, 0, 0, 5, 1);
|
|
|
|
evas_object_show(tb->nolabel);
|
|
|
|
|
|
|
|
tb->gridbox = elm_box_add(tb->table);
|
|
|
|
elm_box_horizontal_set(tb->gridbox, EINA_FALSE);
|
|
|
|
evas_object_size_hint_weight_set(tb->gridbox, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(tb->gridbox, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
evas_object_show(tb->gridbox);
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
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);
|
|
|
|
evas_object_event_callback_add(tb->grid, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_grid_mouse_wheel, tb);
|
|
|
|
elm_drag_item_container_add(tb->grid, ANIM_TIME, DRAG_TIMEOUT,
|
|
|
|
_dnd_item_get, _dnd_item_data_get);
|
2016-09-01 14:21:37 -07:00
|
|
|
elm_drop_item_container_add(tb->grid, ELM_SEL_FORMAT_TARGETS,
|
|
|
|
_drop_item_getcb, _drop_enter, tb, _drop_leave, tb, _drop_pos, tb,
|
|
|
|
_drop_dropcb, NULL);
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_data_set(tb->grid, "thumb_browser", tb);
|
|
|
|
elm_box_pack_end(tb->gridbox, tb->grid);
|
|
|
|
evas_object_smart_callback_add(tb->grid, "changed", _grid_changed, tb);
|
|
|
|
evas_object_show(tb->grid);
|
|
|
|
elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
|
|
|
|
|
|
|
|
_ephoto_thumb_zoom_set(tb, tb->ephoto->config->thumb_size);
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Ephoto Populating Functions*/
|
|
|
|
static void
|
|
|
|
_todo_items_free(Ephoto_Thumb_Browser *tb)
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->todo_items))
|
|
|
|
eina_list_free(tb->todo_items);
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->todo_items = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
else if (!entry->is_dir && !entry->item)
|
|
|
|
{
|
2016-08-15 06:44:29 -07:00
|
|
|
const Elm_Gengrid_Item_Class *ic;
|
|
|
|
|
2016-08-29 12:33:20 -07:00
|
|
|
entry->gengrid = tb->grid;
|
|
|
|
|
2016-08-15 06:44:29 -07:00
|
|
|
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);
|
2016-08-15 20:30:58 -07:00
|
|
|
else if (tb->sort == EPHOTO_SORT_SIMILARITY)
|
|
|
|
entry->thumb =
|
|
|
|
ephoto_thumb_add(entry->ephoto, tb->grid, entry);
|
2016-08-29 12:33:20 -07:00
|
|
|
|
2016-08-15 06:44:29 -07:00
|
|
|
if (entry->item)
|
|
|
|
{
|
|
|
|
elm_object_item_data_set(entry->item, entry);
|
2016-08-29 12:33:20 -07:00
|
|
|
|
2016-08-15 06:44:29 -07:00
|
|
|
}
|
2016-08-15 20:30:58 -07:00
|
|
|
else if (tb->sort != EPHOTO_SORT_SIMILARITY)
|
2016-08-15 06:44:29 -07:00
|
|
|
{
|
|
|
|
ephoto_entry_free(tb->ephoto, entry);
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
}
|
|
|
|
tb->animator.processed++;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_populate_start(void *data, int type EINA_UNUSED,
|
|
|
|
void *event EINA_UNUSED)
|
|
|
|
{
|
2016-10-10 11:43:40 -07:00
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
2016-04-08 09:49:40 -07:00
|
|
|
|
2016-08-09 07:26:41 -07:00
|
|
|
if (tb->dirs_only)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->animator.processed = 0;
|
|
|
|
tb->animator.count = 0;
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
|
|
|
if (tb->searching)
|
|
|
|
_ephoto_thumb_search_cancel(tb->search, NULL, NULL);
|
|
|
|
_todo_items_free(tb);
|
2016-10-10 11:43:40 -07:00
|
|
|
elm_gengrid_clear(tb->grid);
|
2016-05-26 15:44:43 -07:00
|
|
|
tb->totimages = 0;
|
|
|
|
tb->totsize = 0;
|
2016-04-08 09:49:40 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_populate_end(void *data, int type EINA_UNUSED,
|
|
|
|
void *event EINA_UNUSED)
|
|
|
|
{
|
2016-10-10 11:43:40 -07:00
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
2016-04-08 09:49:40 -07:00
|
|
|
|
2016-08-09 07:26:41 -07:00
|
|
|
if (tb->dirs_only)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->ls = NULL;
|
|
|
|
if (tb->main_deleted)
|
|
|
|
{
|
|
|
|
free(tb);
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
if (!tb->ephoto->entries)
|
|
|
|
{
|
|
|
|
tb->totimages = 0;
|
|
|
|
tb->totsize = 0;
|
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
if (tb->ephoto->state == EPHOTO_STATE_THUMB)
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(tb->main, "changed,directory", NULL);
|
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
|
|
|
}
|
|
|
|
tb->entries = tb->ephoto->entries;
|
2016-09-20 13:24:49 -07:00
|
|
|
ephoto_single_browser_entries_set(tb->ephoto->single_browser,
|
|
|
|
tb->ephoto->entries);
|
2016-08-07 20:54:08 -07:00
|
|
|
if (eina_list_count(tb->entries) < 1 && tb->ephoto->config->folders)
|
2016-05-31 09:48:40 -07:00
|
|
|
{
|
|
|
|
ephoto_show_folders(tb->ephoto, EINA_FALSE);
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->dirs_only = 0;
|
|
|
|
tb->thumbs_only = 0;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_populate_error(void *data, int type EINA_UNUSED,
|
|
|
|
void *event EINA_UNUSED)
|
|
|
|
{
|
2016-10-10 11:43:40 -07:00
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
2016-04-08 09:49:40 -07:00
|
|
|
|
2016-08-09 07:26:41 -07:00
|
|
|
if (tb->dirs_only)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->thumbs_only = 0;
|
2016-05-26 15:44:43 -07:00
|
|
|
tb->dirs_only = 0;
|
2016-04-08 09:49:40 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_entry_create(void *data, int type EINA_UNUSED, void *event)
|
|
|
|
{
|
2016-10-10 11:43:40 -07:00
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
2016-04-08 09:49:40 -07:00
|
|
|
Ephoto_Event_Entry_Create *ev = event;
|
|
|
|
Ephoto_Entry *e;
|
|
|
|
|
2016-08-09 07:26:41 -07:00
|
|
|
if (tb->dirs_only)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
e = ev->entry;
|
2016-08-05 19:26:21 -07:00
|
|
|
if (!e->is_dir && !ecore_file_is_dir(ecore_file_realpath(e->path)))
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
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*/
|
2016-05-26 15:44:43 -07:00
|
|
|
void
|
|
|
|
ephoto_thumb_browser_slideshow(Evas_Object *obj)
|
2016-04-08 09:49:40 -07:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
|
2016-04-08 09:49:40 -07:00
|
|
|
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)
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
|
|
|
tb->ephoto->selentries = NULL;
|
|
|
|
tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
|
2016-03-30 11:17:31 -07:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
else if (eina_list_count(selected) > 1)
|
2016-03-30 11:17:31 -07:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
EINA_LIST_FOREACH(selected, s, item)
|
2016-03-30 11:17:31 -07:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
|
|
|
|
elm_object_item_data_get(item));
|
2016-03-30 11:17:31 -07:00
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-03-30 11:17:31 -07:00
|
|
|
else
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->searchentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->searchentries);
|
|
|
|
tb->ephoto->selentries = NULL;
|
|
|
|
tb->ephoto->searchentries = NULL;
|
2016-03-25 13:45:18 -07:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(selected))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(selected);
|
2016-03-25 13:45:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_show_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2016-03-25 13:45:18 -07:00
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
ephoto_config_main(tb->ephoto);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
2015-11-24 14:21:21 -08:00
|
|
|
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");
|
2015-12-01 21:03:50 -08:00
|
|
|
Eina_Bool shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
2016-01-20 07:56:10 -08:00
|
|
|
Eina_List *selected =
|
|
|
|
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
|
2015-11-24 14:21:21 -08:00
|
|
|
const char *k = ev->keyname;
|
2016-01-20 07:56:10 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
if (ctrl)
|
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
if ((!strcasecmp(k, "plus")) || (!strcasecmp(k, "equal")))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_zoom_set(tb, zoom);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if ((!strcasecmp(k, "minus")) || (!strcasecmp(k, "underscore")))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
|
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_zoom_set(tb, zoom);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "Tab"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
_view_single(tb, NULL, NULL);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "c"))
|
2015-01-24 13:19:25 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
_grid_menu_copy_cb(tb, NULL, NULL);
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "x"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
_grid_menu_cut_cb(tb, NULL, NULL);
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "v"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
_grid_menu_paste_cb(tb, NULL, NULL);
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "a"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
_grid_menu_select_all_cb(tb, NULL, NULL);
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "f") && !tb->processing)
|
2015-12-15 14:42:38 -08:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
if (shift)
|
|
|
|
ephoto_show_folders(tb->ephoto, EINA_TRUE);
|
2016-01-01 15:04:25 -08:00
|
|
|
else
|
2016-05-26 15:44:43 -07:00
|
|
|
{
|
|
|
|
if (tb->searching)
|
|
|
|
_ephoto_thumb_search_cancel(tb->search, NULL, NULL);
|
|
|
|
else
|
|
|
|
_ephoto_thumb_search_start(tb, NULL, NULL);
|
|
|
|
}
|
2015-12-15 14:42:38 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "Delete"))
|
2015-12-15 14:42:38 -08:00
|
|
|
{
|
|
|
|
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))
|
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
_menu_empty_cb(tb, NULL, NULL);
|
2015-12-15 14:42:38 -08:00
|
|
|
free(trash);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_grid_menu_delete_cb(tb, NULL, NULL);
|
|
|
|
free(trash);
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "F1"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_show_settings(tb, NULL, NULL);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "F2"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
Elm_Object_Item *it = NULL;
|
|
|
|
|
|
|
|
it = eina_list_data_get(
|
2016-01-01 15:04:25 -08:00
|
|
|
eina_list_last(selected));
|
2015-11-24 14:21:21 -08:00
|
|
|
if (it)
|
|
|
|
{
|
|
|
|
evas_object_data_set(it, "thumb_browser", tb);
|
|
|
|
_grid_menu_rename_cb(it, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "F5"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2015-12-01 15:02:19 -08:00
|
|
|
Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Entry *entry;
|
2016-01-01 15:04:25 -08:00
|
|
|
Eina_List *s;
|
|
|
|
Elm_Object_Item *item;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
|
|
|
if (it)
|
|
|
|
entry = elm_object_item_data_get(it);
|
|
|
|
else
|
2016-01-01 15:04:25 -08:00
|
|
|
entry = eina_list_nth(tb->entries, 0);
|
|
|
|
if (eina_list_count(selected) <= 1 && tb->searchentries)
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-01-01 15:04:25 -08:00
|
|
|
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)
|
|
|
|
{
|
2016-01-20 07:56:10 -08:00
|
|
|
tb->ephoto->selentries =
|
|
|
|
eina_list_append(tb->ephoto->selentries,
|
2016-01-01 15:04:25 -08:00
|
|
|
elm_object_item_data_get(item));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-01-01 15:04:25 -08:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->searchentries))
|
2016-01-01 15:04:25 -08:00
|
|
|
eina_list_free(tb->ephoto->searchentries);
|
|
|
|
tb->ephoto->selentries = NULL;
|
|
|
|
tb->ephoto->searchentries = NULL;
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
if (entry)
|
|
|
|
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "F11"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
Evas_Object *win = tb->ephoto->win;
|
|
|
|
|
|
|
|
elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
|
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (!strcasecmp(k, "Escape"))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-01 13:29:46 -07:00
|
|
|
if (tb->searching)
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_search_cancel(tb->search, NULL, NULL);
|
2016-04-01 13:29:46 -07:00
|
|
|
else
|
|
|
|
_grid_menu_clear_cb(tb, NULL, NULL);
|
|
|
|
}
|
|
|
|
else if (ev->compose && (((ev->compose[0] != '\\')
|
|
|
|
&& (ev->compose[0] >= ' ')) || ev->compose[1]))
|
|
|
|
{
|
|
|
|
if (!tb->searching)
|
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_search_start(tb, NULL, NULL);
|
2016-04-01 13:29:46 -07:00
|
|
|
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);
|
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_search_go(tb->search, NULL, NULL);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-01 17:09:44 -07:00
|
|
|
else if (tb->searching && ((!strcasecmp(k, "Backspace")) ||
|
|
|
|
!strcasecmp(k, "Delete")))
|
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_search_go(tb->search, NULL, NULL);
|
2016-04-01 17:09:44 -07:00
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(selected))
|
2016-01-01 15:04:25 -08:00
|
|
|
eina_list_free(selected);
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static void
|
|
|
|
_hover_dismissed_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
2015-11-24 14:21:21 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
tb->ephoto->hover_blocking = EINA_FALSE;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static void
|
|
|
|
_hover_expand_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
2016-04-08 09:49:40 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
tb->ephoto->hover_blocking = EINA_TRUE;
|
2010-10-10 18:10:27 -07:00
|
|
|
}
|
2011-02-14 13:16:13 -08:00
|
|
|
|
2016-02-29 09:15:52 -08:00
|
|
|
static void
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2011-02-14 13:16:13 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2016-04-08 09:49:40 -07:00
|
|
|
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;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2016-04-08 09:49:40 -07:00
|
|
|
if (tb->ls)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
2016-04-08 09:49:40 -07:00
|
|
|
tb->main_deleted = EINA_TRUE;
|
|
|
|
eio_file_cancel(tb->ls);
|
|
|
|
return;
|
2015-01-24 13:19:25 -08:00
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->cut_items))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->cut_items);
|
2016-08-15 15:21:04 -07:00
|
|
|
else if (eina_list_count(tb->copy_items))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->copy_items);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->selentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->selentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->ephoto->searchentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->ephoto->searchentries);
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->searchentries))
|
2016-04-08 09:49:40 -07:00
|
|
|
eina_list_free(tb->searchentries);
|
|
|
|
free(tb);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
2016-08-14 16:33:49 -07:00
|
|
|
|
2016-08-15 06:44:29 -07:00
|
|
|
/*Ephoto Thumb Browser Public Functions*/
|
2016-08-09 07:26:41 -07:00
|
|
|
void
|
|
|
|
ephoto_thumb_browser_dirs_only_set(Ephoto *ephoto, Eina_Bool dirs_only)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
|
|
|
|
|
|
|
tb->dirs_only = dirs_only;
|
|
|
|
}
|
|
|
|
|
2016-08-03 14:05:48 -07:00
|
|
|
void
|
|
|
|
ephoto_thumb_browser_clear(Ephoto *ephoto)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
|
|
|
|
|
|
|
elm_gengrid_clear(tb->grid);
|
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
void
|
|
|
|
ephoto_thumb_browser_paste(Ephoto *ephoto, Elm_Object_Item *item)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
if (item)
|
|
|
|
{
|
|
|
|
entry = elm_object_item_data_get(item);
|
|
|
|
path = entry->path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
path = tb->ephoto->config->directory;
|
|
|
|
|
2016-08-15 15:21:04 -07:00
|
|
|
if (eina_list_count(tb->cut_items))
|
2016-05-26 15:44:43 -07:00
|
|
|
{
|
|
|
|
ephoto_file_paste(tb->ephoto, eina_list_clone(tb->cut_items), EINA_FALSE, path);
|
|
|
|
eina_list_free(tb->cut_items);
|
|
|
|
tb->cut_items = NULL;
|
|
|
|
}
|
2016-08-15 15:21:04 -07:00
|
|
|
else if (eina_list_count(tb->copy_items))
|
2016-05-26 15:44:43 -07:00
|
|
|
{
|
|
|
|
ephoto_file_paste(tb->ephoto, eina_list_clone(tb->copy_items), EINA_TRUE, path);
|
|
|
|
eina_list_free(tb->copy_items);
|
|
|
|
tb->copy_items = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-19 11:58:28 -08:00
|
|
|
void
|
|
|
|
ephoto_thumb_browser_insert(Ephoto *ephoto, Ephoto_Entry *entry)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb =
|
|
|
|
evas_object_data_get(ephoto->thumb_browser, "thumb_browser");
|
2016-01-20 07:56:10 -08:00
|
|
|
|
2016-03-15 14:45:20 -07:00
|
|
|
if (!entry->is_dir && !entry->item)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2016-08-29 12:33:20 -07:00
|
|
|
entry->gengrid = tb->grid;
|
|
|
|
|
2016-01-19 11:58:28 -08:00
|
|
|
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);
|
2016-08-15 20:30:58 -07:00
|
|
|
else if (tb->sort == EPHOTO_SORT_SIMILARITY)
|
|
|
|
entry->item =
|
|
|
|
elm_gengrid_item_sorted_insert(tb->grid, ic, entry,
|
|
|
|
_entry_cmp_grid_similarity, NULL, NULL);
|
2016-01-19 11:58:28 -08:00
|
|
|
if (entry->item)
|
|
|
|
{
|
|
|
|
elm_object_item_data_set(entry->item, entry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ephoto_entry_free(tb->ephoto, entry);
|
2016-01-20 07:56:10 -08:00
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2016-01-20 07:56:10 -08:00
|
|
|
|
2016-01-19 11:58:28 -08:00
|
|
|
if (eina_list_count(tb->ephoto->entries) == 1)
|
|
|
|
{
|
2016-02-24 08:03:44 -08:00
|
|
|
tb->totimages = 0;
|
|
|
|
tb->totsize = 0;
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
2016-01-19 11:58:28 -08:00
|
|
|
elm_object_item_del(entry->item);
|
2016-08-02 14:45:57 -07:00
|
|
|
ephoto_entry_free(tb->ephoto, entry);
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-24 14:47:39 -08:00
|
|
|
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;
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(tb->ephoto);
|
2016-02-24 14:47:39 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-19 11:58:28 -08:00
|
|
|
void
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_show_controls(Ephoto *ephoto)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(ephoto->thumb_browser,
|
|
|
|
"thumb_browser");
|
|
|
|
Evas_Object *but, *ic, *hover;
|
|
|
|
int ret;
|
2016-01-19 11:58:28 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
ic = elm_icon_add(ephoto->controls_left);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
2016-05-31 08:11:05 -07:00
|
|
|
ret = elm_icon_standard_set(ic, "view-list-details");
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2016-05-29 08:33:06 -07:00
|
|
|
if (!ret)
|
|
|
|
ret = elm_image_file_set(ic, PACKAGE_DATA_DIR "/images/single.png", NULL);
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
but = elm_button_add(ephoto->controls_left);
|
|
|
|
if (!ret)
|
|
|
|
elm_object_text_set(but, _("View Images"));
|
2016-05-29 08:33:06 -07:00
|
|
|
elm_object_part_content_set(but, "icon", ic);
|
|
|
|
elm_object_tooltip_text_set(but, _("View Images"));
|
|
|
|
elm_object_tooltip_orient_set(but, ELM_TOOLTIP_ORIENT_TOP);
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _view_single, tb);
|
|
|
|
elm_box_pack_end(ephoto->controls_left, but);
|
|
|
|
evas_object_show(but);
|
2016-01-19 11:58:28 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
ic = elm_icon_add(ephoto->controls_left);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
|
|
|
ret = elm_icon_standard_set(ic, "zoom-in");
|
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2016-05-29 08:33:06 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
but = elm_button_add(ephoto->controls_left);
|
|
|
|
if (!ret)
|
|
|
|
elm_object_text_set(but, _("Zoom In"));
|
2016-05-29 08:33:06 -07:00
|
|
|
elm_object_part_content_set(but, "icon", ic);
|
|
|
|
elm_object_tooltip_text_set(but, _("Zoom In"));
|
|
|
|
elm_object_tooltip_orient_set(but, ELM_TOOLTIP_ORIENT_TOP);
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _zoom_in, tb);
|
|
|
|
elm_box_pack_end(ephoto->controls_left, but);
|
|
|
|
evas_object_show(but);
|
|
|
|
|
|
|
|
ic = elm_icon_add(ephoto->controls_left);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
|
|
|
elm_icon_standard_set(ic, "zoom-out");
|
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2016-05-29 08:33:06 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
but = elm_button_add(ephoto->controls_left);
|
|
|
|
if (!ret)
|
|
|
|
elm_object_text_set(but, _("Zoom Out"));
|
2016-05-29 08:33:06 -07:00
|
|
|
elm_object_part_content_set(but, "icon", ic);
|
|
|
|
elm_object_tooltip_text_set(but, _("Zoom Out"));
|
|
|
|
elm_object_tooltip_orient_set(but, ELM_TOOLTIP_ORIENT_TOP);
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _zoom_out, tb);
|
|
|
|
elm_box_pack_end(ephoto->controls_left, but);
|
|
|
|
evas_object_show(but);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
hover = elm_hoversel_add(ephoto->controls_right);
|
|
|
|
elm_hoversel_hover_parent_set(hover, ephoto->win);
|
|
|
|
elm_hoversel_item_add(hover, _("Alphabetical Ascending"),
|
|
|
|
"view-sort-ascending", ELM_ICON_STANDARD, _sort_alpha_asc, tb);
|
|
|
|
elm_hoversel_item_add(hover, _("Alphabetical Descending"),
|
|
|
|
"view-sort-descending", ELM_ICON_STANDARD, _sort_alpha_desc, tb);
|
|
|
|
elm_hoversel_item_add(hover, _("Modification Time Ascending"),
|
|
|
|
"view-sort-ascending", ELM_ICON_STANDARD, _sort_mod_asc, tb);
|
|
|
|
elm_hoversel_item_add(hover, _("Modification Time Descending"),
|
|
|
|
"view-sort-descending", ELM_ICON_STANDARD, _sort_mod_desc, tb);
|
2016-08-15 10:36:50 -07:00
|
|
|
tb->similarity = elm_hoversel_item_add(hover, _("Image Simalarity"),
|
|
|
|
"view-sort-ascending", ELM_ICON_STANDARD, _sort_similarity, tb);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_text_set(hover, _("Sort"));
|
|
|
|
ic = elm_icon_add(hover);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
|
|
|
elm_icon_standard_set(ic, "view-sort-ascending");
|
|
|
|
elm_object_part_content_set(hover, "icon", ic);
|
|
|
|
evas_object_show(ic);
|
|
|
|
elm_object_tooltip_text_set(hover, _("Sort"));
|
|
|
|
elm_object_tooltip_orient_set(hover, ELM_TOOLTIP_ORIENT_TOP);
|
|
|
|
evas_object_smart_callback_add(hover, "expanded", _hover_expand_cb, tb);
|
|
|
|
evas_object_smart_callback_add(hover, "dismissed", _hover_dismissed_cb, tb);
|
|
|
|
elm_box_pack_end(ephoto->controls_right, hover);
|
|
|
|
evas_object_show(hover);
|
2016-08-15 10:36:50 -07:00
|
|
|
tb->hover = hover;
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
Evas_Object *
|
|
|
|
ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|
|
|
{
|
2014-11-18 11:37:49 -08:00
|
|
|
Evas_Object *box = elm_box_add(parent);
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb;
|
|
|
|
|
2014-11-18 11:37:49 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
|
|
|
|
EINA_SAFETY_ON_NULL_GOTO(tb, error);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2012-02-22 08:16:24 -08:00
|
|
|
_ephoto_thumb_file_class.item_style = "thumb";
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_file_class.func.text_get = _thumb_item_text_get;
|
|
|
|
_ephoto_thumb_file_class.func.content_get = _thumb_file_icon_get;
|
2012-02-22 08:16:24 -08:00
|
|
|
_ephoto_thumb_file_class.func.state_get = NULL;
|
2016-04-08 09:49:40 -07:00
|
|
|
_ephoto_thumb_file_class.func.del = _thumb_item_del;
|
2012-02-22 08:16:24 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
tb->ephoto = ephoto;
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->dragging = 0;
|
2015-12-15 14:42:38 -08:00
|
|
|
tb->searching = 0;
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->cut_items = NULL;
|
|
|
|
tb->copy_items = NULL;
|
2015-12-14 12:27:11 -08:00
|
|
|
tb->last_sel = NULL;
|
2016-08-15 15:21:04 -07:00
|
|
|
tb->entries = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
|
2014-11-18 11:37:49 -08:00
|
|
|
tb->main = box;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2015-12-01 15:02:19 -08:00
|
|
|
elm_box_horizontal_set(tb->main, EINA_FALSE);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_size_hint_weight_set(tb->main, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
2014-11-18 11:37:49 -08:00
|
|
|
evas_object_size_hint_align_set(tb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2016-04-08 09:49:40 -07:00
|
|
|
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);
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_data_set(tb->main, "thumb_browser", tb);
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
_ephoto_thumb_view_add(tb);
|
|
|
|
elm_box_pack_end(tb->main, tb->table);
|
2016-03-03 17:20:50 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->handlers =
|
|
|
|
eina_list_append(tb->handlers,
|
|
|
|
ecore_event_handler_add(EPHOTO_EVENT_POPULATE_START,
|
2016-10-10 11:43:40 -07:00
|
|
|
_ephoto_thumb_populate_start, ephoto));
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->handlers =
|
|
|
|
eina_list_append(tb->handlers,
|
|
|
|
ecore_event_handler_add(EPHOTO_EVENT_POPULATE_END,
|
2016-10-10 11:43:40 -07:00
|
|
|
_ephoto_thumb_populate_end, ephoto));
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->handlers =
|
|
|
|
eina_list_append(tb->handlers,
|
|
|
|
ecore_event_handler_add(EPHOTO_EVENT_POPULATE_ERROR,
|
2016-10-10 11:43:40 -07:00
|
|
|
_ephoto_thumb_populate_error, ephoto));
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
tb->handlers =
|
|
|
|
eina_list_append(tb->handlers,
|
|
|
|
ecore_event_handler_add(EPHOTO_EVENT_ENTRY_CREATE,
|
2016-10-10 11:43:40 -07:00
|
|
|
_ephoto_thumb_entry_create, ephoto));
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
return tb->main;
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
error:
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_del(tb->main);
|
2011-02-24 14:26:47 -08:00
|
|
|
return NULL;
|
2011-02-14 13:16:13 -08:00
|
|
|
}
|
2016-01-19 11:58:28 -08:00
|
|
|
|