ephoto/src/bin/ephoto_thumb_browser.c

3420 lines
100 KiB
C
Raw Normal View History

#include "ephoto.h"
#define ZOOM_MAX 512
#define ZOOM_MIN 128
#define ZOOM_STEP 32
#define TODO_ITEM_MIN_BATCH 16
#define FILESEP "file://"
#define FILESEP_LEN sizeof(FILESEP) - 1
#define DRAG_TIMEOUT 0.3
#define ANIM_TIME 0.2
static Eina_Bool _5s_cancel = EINA_FALSE;
static Ecore_Timer *_5s_timeout = NULL;
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
struct _Ephoto_Thumb_Browser
{
Ephoto *ephoto;
Evas_Object *main;
Evas_Object *table;
Evas_Object *grid;
Evas_Object *nolabel;
Evas_Object *infolabel;
Evas_Object *bar;
Evas_Object *vbar;
Evas_Object *fsel;
Evas_Object *min;
Evas_Object *max;
Evas_Object *leftbox;
Evas_Object *bleftbox;
Evas_Object *direntry;
Evas_Object *dir_loading;
Evas_Object *hoversel;
Elm_Object_Item *dir_current;
Ephoto_Sort sort;
Eio_File *ls;
Eina_List *cut_items;
Eina_List *copy_items;
Eina_List *handlers;
Eina_List *idler_pos;
Eina_List *todo_items;
Ecore_Idler *idler;
int thumbs_only;
int dirs_only;
int totimages;
int file_errors;
int dragging;
double totsize;
struct
{
Ecore_Animator *todo_items;
int count;
int processed;
} animator;
Eina_Bool main_deleted:1;
};
static Elm_Gengrid_Item_Class _ephoto_thumb_file_class;
static Elm_Genlist_Item_Class _ephoto_dir_class;
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 EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info)
{
Elm_Widget_Item *it = event_info;
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)
{
Elm_Widget_Item *it = event_info;
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_Widget_Item *it = event_info;
const char *path = elm_object_item_data_get(it);
if (strlen(path) == strlen(tb->ephoto->config->directory))
{
if (!strcmp(path, tb->ephoto->config->directory))
tb->dirs_only = 1;
}
ephoto_directory_set(tb->ephoto, path, it, tb->dirs_only);
ephoto_title_set(tb->ephoto, path);
}
static void
_on_list_contracted(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Ephoto_Thumb_Browser *tb = data;
Elm_Widget_Item *it = event_info;
const char *path = elm_object_item_data_get(it);
elm_genlist_item_subitems_clear(it);
if (strlen(path) == strlen(tb->ephoto->config->directory))
{
if (!strcmp(path, tb->ephoto->config->directory))
tb->dirs_only = 1;
}
tb->thumbs_only = 1;
ephoto_directory_set(tb->ephoto, path, NULL, tb->dirs_only);
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
}
static void
_on_list_selected(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Ephoto_Thumb_Browser *tb = data;
Elm_Widget_Item *it = event_info;
if (!tb->dragging)
tb->dir_current = it;
}
static char *
_ephoto_dir_item_text_get(void *data, Evas_Object *obj EINA_UNUSED,
const char *part EINA_UNUSED)
{
return strdup(basename(data));
}
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);
2015-08-10 08:42:02 -07:00
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);
return thumb;
}
static void
_ephoto_dir_item_del(void *data, Evas_Object *obj EINA_UNUSED)
{
eina_stringshare_del(data);
}
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 Elm_Widget_Item *ia = pa;
const Elm_Widget_Item *ib = pb;
const char *a, *b;
a = elm_object_item_data_get(ia);
b = elm_object_item_data_get(ib);
return strcasecmp(a, b);
}
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;
tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
tb->thumbs_only = 1;
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
NULL, EINA_FALSE);
elm_object_text_set(tb->hoversel, _("Alphabetical Ascending"));
}
static void
_sort_alpha_desc(void *data, Evas_Object *obj EINA_UNUSED,
void *event_data EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
tb->sort = EPHOTO_SORT_ALPHABETICAL_DESCENDING;
tb->thumbs_only = 1;
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
NULL, EINA_FALSE);
elm_object_text_set(tb->hoversel, _("Alphabetical Descending"));
}
static void
_sort_mod_asc(void *data, Evas_Object *obj EINA_UNUSED,
void *event_data EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
tb->sort = EPHOTO_SORT_MODTIME_ASCENDING;
tb->thumbs_only = 1;
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
NULL, EINA_FALSE);
elm_object_text_set(tb->hoversel, _("Modification Time Ascending"));
}
static void
_sort_mod_desc(void *data, Evas_Object *obj EINA_UNUSED,
void *event_data EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
tb->sort = EPHOTO_SORT_MODTIME_DESCENDING;
tb->thumbs_only = 1;
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory,
NULL, EINA_FALSE);
elm_object_text_set(tb->hoversel, _("Modification Time Descending"));
}
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;
if (tb->dir_loading)
{
evas_object_del(tb->dir_loading);
evas_object_freeze_events_set(tb->main, EINA_FALSE);
elm_object_focus_set(tb->main, EINA_TRUE);
}
tb->animator.todo_items = NULL;
return EINA_FALSE;
}
if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH))
return EINA_TRUE;
tb->animator.todo_items = NULL;
EINA_LIST_FREE(tb->todo_items, entry)
{
i++;
if (i > TODO_ITEM_MIN_BATCH)
return EINA_TRUE;
if (entry->is_dir)
{
const Elm_Genlist_Item_Class *ic;
const char *path;
ic = &_ephoto_dir_class;
path = eina_stringshare_add(entry->path);
entry->item =
elm_genlist_item_sorted_insert(tb->fsel, ic, path,
entry->parent, ELM_GENLIST_ITEM_TREE, _entry_cmp, NULL, NULL);
if (!entry->item)
{
ephoto_entry_free(entry);
}
}
else
{
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(entry);
}
}
tb->animator.processed++;
}
return EINA_TRUE;
}
static void
_ephoto_dir_double_clicked(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Widget_Item *it = event_info;
elm_genlist_item_expanded_set(it, !elm_genlist_item_expanded_get(it));
}
static void
_ephoto_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;
ephoto_directory_set(tb->ephoto, getenv("HOME"), NULL, tb->dirs_only);
ephoto_title_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;
ephoto_directory_set(tb->ephoto, dirname(path), NULL, tb->dirs_only);
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
}
}
2015-08-10 14:05:35 -07:00
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;
ephoto_directory_set(tb->ephoto, path, NULL, tb->dirs_only);
ephoto_title_set(tb->ephoto, _("Trash"));
}
static void
_ephoto_direntry_go(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
2015-08-10 14:05:35 -07:00
{
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);
ephoto_directory_set(tb->ephoto, dir, NULL, tb->dirs_only);
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
2015-08-10 14:05:35 -07:00
}
}
static void
_ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info)
{
Ephoto_Thumb_Browser *tb = data;
Elm_Widget_Item *it = event_info;
Ephoto_Entry *e = elm_object_item_data_get(it);
evas_object_smart_callback_call(tb->main, "view", e);
}
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);
if (zoom >= ZOOM_MAX)
elm_object_disabled_set(tb->max, EINA_TRUE);
if (zoom > ZOOM_MIN)
elm_object_disabled_set(tb->min, EINA_FALSE);
if (zoom <= ZOOM_MIN)
elm_object_disabled_set(tb->min, EINA_TRUE);
if (zoom < ZOOM_MAX)
elm_object_disabled_set(tb->max, EINA_FALSE);
}
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
_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
Elm_Widget_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->ephoto->entries, 0);
if (!entry)
return;
evas_object_smart_callback_call(tb->main, "slideshow", entry);
}
static void
_general_settings(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *popup = data;
Ephoto_Thumb_Browser *tb = evas_object_data_get(popup, "thumb_browser");
ephoto_config_general(tb->ephoto);
}
2015-10-30 12:42:13 -07:00
static void
_slideshow_settings(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
2015-10-30 12:42:13 -07:00
{
Evas_Object *popup = data;
Ephoto_Thumb_Browser *tb = evas_object_data_get(popup, "thumb_browser");
ephoto_config_slideshow(tb->ephoto);
}
static void
_about_settings(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
2015-10-30 12:42:13 -07:00
{
Evas_Object *popup = data;
Ephoto_Thumb_Browser *tb = evas_object_data_get(popup, "thumb_browser");
ephoto_config_about(tb->ephoto);
}
static void
_close_settings(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
2015-10-30 12:42:13 -07:00
{
Evas_Object *popup = data;
Ephoto_Thumb_Browser *tb = evas_object_data_get(popup, "thumb_browser");
2015-10-30 12:42:13 -07:00
evas_object_del(popup);
evas_object_freeze_events_set(tb->main, EINA_FALSE);
elm_object_focus_set(tb->main, EINA_TRUE);
2015-10-30 12:42:13 -07:00
}
static void
_settings(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
2015-10-30 12:42:13 -07:00
Evas_Object *popup, *list, *button, *ic;
evas_object_freeze_events_set(tb->main, EINA_TRUE);
2015-10-30 12:42:13 -07:00
popup = elm_popup_add(tb->ephoto->win);
elm_popup_scrollable_set(popup, EINA_TRUE);
elm_object_part_text_set(popup, "title,text", _("Settings Panel"));
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
2015-10-30 12:42:13 -07:00
list = elm_list_add(popup);
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_list_mode_set(list, ELM_LIST_EXPAND);
ic = elm_icon_add(list);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "preferences-system");
evas_object_show(ic);
elm_list_item_append(list, _("General Settings"), ic, NULL,
_general_settings, popup);
2015-10-30 12:42:13 -07:00
ic = elm_icon_add(list);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "media-playback-start");
evas_object_show(ic);
elm_list_item_append(list, _("Slideshow Settings"), ic, NULL,
_slideshow_settings, popup);
2015-10-30 12:42:13 -07:00
ic = elm_icon_add(list);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "help-about");
evas_object_show(ic);
elm_list_item_append(list, _("About Ephoto"), ic, NULL, _about_settings,
popup);
2015-10-30 12:42:13 -07:00
ic = elm_icon_add(popup);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(popup);
elm_object_text_set(button, _("Close"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _close_settings, popup);
elm_object_part_content_set(popup, "button1", button);
evas_object_show(button);
elm_list_go(list);
evas_object_show(list);
evas_object_data_set(popup, "thumb_browser", tb);
elm_object_content_set(popup, list);
evas_object_show(popup);
}
static void
_ephoto_dir_show_folders(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
elm_box_unpack(tb->main, tb->bleftbox);
evas_object_del(tb->bleftbox);
tb->bleftbox = NULL;
tb->vbar = NULL;
evas_object_show(tb->leftbox);
elm_box_pack_start(tb->main, tb->leftbox);
tb->ephoto->config->fsel_hide = 0;
}
static void
_ephoto_dir_hide_folders(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Thumb_Browser *tb = data;
Elm_Widget_Item *icon;
2015-10-30 12:42:13 -07:00
Evas_Object *max, *min, *but, *ic;
evas_object_hide(tb->leftbox);
elm_box_unpack(tb->main, tb->leftbox);
tb->bleftbox = elm_box_add(tb->main);
evas_object_size_hint_weight_set(tb->bleftbox, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(tb->bleftbox, EVAS_HINT_FILL,
EVAS_HINT_FILL);
elm_box_pack_start(tb->main, tb->bleftbox);
evas_object_show(tb->bleftbox);
tb->vbar = elm_toolbar_add(tb->main);
elm_toolbar_horizontal_set(tb->vbar, EINA_FALSE);
elm_toolbar_homogeneous_set(tb->vbar, EINA_TRUE);
elm_toolbar_shrink_mode_set(tb->vbar, ELM_TOOLBAR_SHRINK_NONE);
elm_toolbar_select_mode_set(tb->vbar, ELM_OBJECT_SELECT_MODE_NONE);
elm_toolbar_icon_order_lookup_set(tb->vbar, ELM_ICON_LOOKUP_FDO_THEME);
elm_toolbar_align_set(tb->vbar, 0.0);
elm_object_tree_focus_allow_set(tb->vbar, EINA_FALSE);
evas_object_size_hint_weight_set(tb->vbar, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(tb->vbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
icon =
elm_toolbar_item_append(tb->vbar, "zoom-in", _("Zoom In"), _zoom_in, tb);
max = elm_object_item_widget_get(icon);
icon =
elm_toolbar_item_append(tb->vbar, "zoom-out", _("Zoom Out"), _zoom_out,
tb);
min = elm_object_item_widget_get(icon);
evas_object_data_set(max, "min", min);
evas_object_data_set(min, "max", max);
elm_toolbar_item_append(tb->vbar, "media-playback-start", _("Slideshow"),
_slideshow, tb);
elm_toolbar_item_append(tb->vbar, "preferences-system", _("Settings"),
_settings, tb);
elm_box_pack_end(tb->bleftbox, tb->vbar);
evas_object_show(tb->vbar);
ic = elm_icon_add(tb->bleftbox);
2015-08-10 08:42:02 -07:00
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
elm_icon_standard_set(ic, "go-next");
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
but = elm_button_add(tb->bleftbox);
elm_object_part_content_set(but, "icon", ic);
elm_object_tooltip_text_set(but, _("Show the file selector"));
evas_object_size_hint_weight_set(but, 0.0, 0.0);
evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(but, "clicked", _ephoto_dir_show_folders, tb);
elm_box_pack_end(tb->bleftbox, but);
evas_object_show(but);
tb->ephoto->config->fsel_hide = 1;
}
static void
_complete_ok(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *popup = data;
Ephoto_Thumb_Browser *tb = evas_object_data_get(popup, "thumb_browser");
evas_object_del(popup);
evas_object_freeze_events_set(tb->main, EINA_FALSE);
elm_object_focus_set(tb->main, EINA_TRUE);
}
static void
_complete(Ephoto_Thumb_Browser *tb, const char *title, const char *text)
{
Evas_Object *popup, *box, *label, *ic, *button;
evas_object_freeze_events_set(tb->main, EINA_TRUE);
popup = elm_popup_add(tb->ephoto->win);
elm_object_part_text_set(popup, "title,text", title);
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
box = elm_box_add(popup);
elm_box_horizontal_set(box, EINA_FALSE);
evas_object_size_hint_weight_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(box);
label = elm_label_add(box);
elm_object_text_set(label, text);
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, label);
evas_object_show(label);
ic = elm_icon_add(popup);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(popup);
elm_object_text_set(button, _("Ok"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _complete_ok, popup);
elm_object_part_content_set(popup, "button1", button);
evas_object_show(button);
evas_object_data_set(popup, "thumb_browser", tb);
elm_object_part_content_set(popup, "default", box);
evas_object_show(popup);
}
static Evas_Object *
_processing(Ephoto_Thumb_Browser *tb, const char *title, const char *text)
{
Evas_Object *popup, *box, *label, *pb;
evas_object_freeze_events_set(tb->main, EINA_TRUE);
popup = elm_popup_add(tb->ephoto->win);
elm_object_part_text_set(popup, "title,text", title);
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
box = elm_box_add(popup);
elm_box_horizontal_set(box, EINA_FALSE);
evas_object_size_hint_weight_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(box);
label = elm_label_add(box);
elm_object_text_set(label, text);
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, label);
evas_object_show(label);
pb = elm_progressbar_add(box);
evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
elm_object_style_set(pb, "wheel");
elm_progressbar_pulse_set(pb, EINA_TRUE);
elm_box_pack_end(box, pb);
evas_object_show(pb);
elm_progressbar_pulse(pb, EINA_TRUE);
evas_object_data_set(popup, "thumb_browser", tb);
elm_object_part_content_set(popup, "default", box);
return popup;
}
static Eina_Bool
_move_idler_cb(void *data)
{
Evas_Object *popup = data;
Ephoto_Thumb_Browser *tb = evas_object_data_get(popup, "thumb_browser");
const char *destination = evas_object_data_get(popup, "destination");
const char *file;
int i;
if (!tb->idler_pos)
tb->idler_pos = eina_list_nth(tb->idler_pos, 0);
if (!tb->idler_pos)
{
ecore_idler_del(tb->idler);
tb->idler = NULL;
eina_list_free(tb->idler_pos);
tb->idler_pos = NULL;
if (tb->file_errors > 0)
{
char msg[PATH_MAX];
snprintf(msg, PATH_MAX, "%s %d %s.",
_("There was an error moving"), tb->file_errors,
ngettext("file", "files", tb->file_errors));
_complete(tb, _("Error"), msg);
}
tb->file_errors = 0;
tb->thumbs_only = 1;
ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory, NULL,
tb->dirs_only);
ephoto_title_set(tb->ephoto, tb->ephoto->config->directory);
evas_object_del(popup);
evas_object_freeze_events_set(tb->main, EINA_FALSE);
elm_object_focus_set(tb->main, EINA_TRUE);
return EINA_FALSE;
}
for (i = 0; i < 5; i++)
{
file = eina_list_data_get(tb->idler_pos);
if (!file)
break;
if (ecore_file_exists(file) && ecore_file_is_dir(destination) &&
!strncmp("image/", efreet_mime_type_get(file), 6))
{
char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX];
int ret;
snprintf(fp, PATH_MAX, "%s", file);
snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
if (ecore_file_exists(dest))
{
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
basename(fp));
if (ecore_file_exists(extra))
{
int count;
for (count = 2; ecore_file_exists(extra); count++)
{
memset(extra, 0, sizeof(extra));
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
destination, count, basename(fp));
}
}
ret = ecore_file_mv(file, extra);
}
else
ret = ecore_file_mv(file, dest);
if (