2010-07-01 11:49:22 -07:00
|
|
|
#include "ephoto.h"
|
|
|
|
|
2010-10-10 11:57:48 -07:00
|
|
|
#define ZOOM_MAX 512
|
|
|
|
#define ZOOM_MIN 128
|
|
|
|
#define ZOOM_STEP 32
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
#define TODO_ITEM_MIN_BATCH 16
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
#define PARENT_DIR "Up"
|
|
|
|
|
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;
|
|
|
|
Evas_Object *bar;
|
2011-06-29 12:49:24 -07:00
|
|
|
Evas_Object *entry;
|
2010-10-09 12:13:35 -07:00
|
|
|
Evas_Object *grid;
|
2011-02-24 14:26:47 -08:00
|
|
|
Eio_File *ls;
|
2011-02-21 17:55:08 -08:00
|
|
|
Eina_List *todo_items;
|
|
|
|
Eina_List *grid_items;
|
2011-02-24 14:26:47 -08:00
|
|
|
Eina_List *handlers;
|
2011-06-28 15:26:16 -07:00
|
|
|
struct {
|
2011-11-30 21:09:59 -08:00
|
|
|
Elm_Object_Item *zoom_in;
|
|
|
|
Elm_Object_Item *zoom_out;
|
|
|
|
Elm_Object_Item *view_single;
|
|
|
|
Elm_Object_Item *slideshow;
|
2011-06-28 15:26:16 -07:00
|
|
|
} action;
|
2011-02-21 17:55:08 -08:00
|
|
|
struct {
|
2011-02-24 14:26:47 -08:00
|
|
|
Ecore_Animator *todo_items;
|
2011-02-21 17:55:08 -08:00
|
|
|
} animator;
|
2011-06-28 15:26:16 -07:00
|
|
|
Eina_Bool main_deleted : 1;
|
2010-10-09 12:13:35 -07:00
|
|
|
};
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
|
|
|
_todo_items_free(Ephoto_Thumb_Browser *tb)
|
2010-10-09 18:13:53 -07:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
eina_list_free(tb->todo_items);
|
|
|
|
tb->todo_items = NULL;
|
2010-10-13 19:37:37 -07:00
|
|
|
}
|
2010-10-09 18:13:53 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
|
|
|
_grid_items_free(Ephoto_Thumb_Browser *tb)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
eina_list_free(tb->grid_items);
|
|
|
|
tb->grid_items = NULL;
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
static Ephoto_Entry *
|
|
|
|
_first_file_entry_find(Ephoto_Thumb_Browser *tb)
|
|
|
|
{
|
|
|
|
const Eina_List *l;
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
EINA_LIST_FOREACH(tb->ephoto->entries, l, entry)
|
|
|
|
if (!entry->is_dir) return entry;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static char *
|
2011-12-01 00:32:43 -08:00
|
|
|
_ephoto_thumb_item_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
Ephoto_Entry *e = data;
|
|
|
|
return strdup(e->label);
|
2010-10-09 18:13:53 -07:00
|
|
|
}
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_ephoto_thumb_dir_icon_get(void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
|
|
|
Ephoto_Entry *e = data;
|
|
|
|
const char *f;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (strncmp(part, "elm.swallow.icon.", sizeof("elm.swallow.icon.") - 1) != 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
n = atoi(part + sizeof("elm.swallow.icon.") - 1);
|
|
|
|
if (n < 1)
|
|
|
|
return NULL;
|
|
|
|
n--;
|
|
|
|
|
|
|
|
f = eina_list_nth(e->dir_files, n);
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
o = ephoto_thumb_add(e->ephoto, obj, f);
|
|
|
|
//elm_object_style_set(o, "default");
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e->dir_files_checked)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ephoto_directory_thumb_add(obj, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_dir_state_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
|
|
|
|
{
|
|
|
|
Ephoto_Entry *e = data;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (strcmp(part, "have_files") == 0)
|
|
|
|
return !!e->dir_files;
|
|
|
|
|
|
|
|
if (strncmp(part, "have_file.", sizeof("have_file.") - 1) != 0)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
n = atoi(part + sizeof("have_file.") - 1);
|
|
|
|
if (n < 1)
|
|
|
|
return EINA_FALSE;
|
|
|
|
return n <= (int)eina_list_count(e->dir_files);
|
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static Evas_Object *
|
|
|
|
_ephoto_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part __UNUSED__)
|
2010-10-10 11:57:48 -07:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Entry *e = data;
|
|
|
|
return ephoto_thumb_add(e->ephoto, obj, e->path);
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
2010-10-10 11:57:48 -07:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
static void
|
2011-02-24 14:26:47 -08:00
|
|
|
_ephoto_thumb_item_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
/* FIXME: the entry is already freed when changing directories
|
|
|
|
* One solution is to take care of this cleaning when manually removing
|
|
|
|
* some grid items
|
|
|
|
Ephoto_Entry *e = data;
|
|
|
|
e->item = NULL;
|
|
|
|
*/
|
2010-10-10 11:57:48 -07:00
|
|
|
}
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
static const Elm_Gengrid_Item_Class _ephoto_thumb_up_class = {
|
|
|
|
"ephoto-up",
|
|
|
|
{
|
2011-12-01 00:32:43 -08:00
|
|
|
_ephoto_thumb_item_text_get,
|
2011-06-28 15:26:16 -07:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
_ephoto_thumb_item_del
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Elm_Gengrid_Item_Class _ephoto_thumb_dir_class = {
|
|
|
|
"ephoto-album-preview",
|
|
|
|
{
|
2011-12-01 00:32:43 -08:00
|
|
|
_ephoto_thumb_item_text_get,
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_thumb_dir_icon_get,
|
|
|
|
_ephoto_thumb_dir_state_get,
|
|
|
|
_ephoto_thumb_item_del
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static const Elm_Gengrid_Item_Class _ephoto_thumb_file_class = {
|
|
|
|
"thumb",
|
|
|
|
{
|
2011-12-01 00:32:43 -08:00
|
|
|
_ephoto_thumb_item_text_get,
|
2011-02-24 14:26:47 -08:00
|
|
|
_ephoto_thumb_file_icon_get,
|
|
|
|
NULL,
|
|
|
|
_ephoto_thumb_item_del
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-03-04 13:50:07 -08:00
|
|
|
static int
|
|
|
|
_entry_cmp(const void *pa, const void *pb)
|
|
|
|
{
|
2011-06-28 15:26:16 -07:00
|
|
|
const Elm_Gengrid_Item *ia = pa;
|
|
|
|
const Ephoto_Entry *a, *b = pb;
|
|
|
|
|
|
|
|
a = elm_gengrid_item_data_get(ia);
|
|
|
|
|
|
|
|
if (a->is_dir == b->is_dir)
|
|
|
|
return strcoll(a->basename, b->basename);
|
|
|
|
else if (a->is_dir)
|
|
|
|
return -1;
|
2011-03-04 13:50:07 -08:00
|
|
|
else
|
2011-06-28 15:26:16 -07:00
|
|
|
return 1;
|
2011-03-04 13:50:07 -08:00
|
|
|
}
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
static void
|
2011-02-24 14:26:47 -08:00
|
|
|
_entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
|
2010-10-10 11:57:48 -07:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
const Elm_Gengrid_Item_Class *ic;
|
2011-06-28 15:26:16 -07:00
|
|
|
int near_cmp;
|
|
|
|
Elm_Gengrid_Item *near_item = NULL;
|
|
|
|
Eina_List *near_node = NULL;
|
|
|
|
|
|
|
|
near_node = eina_list_search_sorted_near_list
|
|
|
|
(tb->grid_items, _entry_cmp, e, &near_cmp);
|
|
|
|
|
|
|
|
if (near_node)
|
|
|
|
near_item = near_node->data;
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
if (e->is_dir) ic = &_ephoto_thumb_dir_class;
|
|
|
|
else ic = &_ephoto_thumb_file_class;
|
|
|
|
|
|
|
|
if (!near_item)
|
2011-03-04 13:50:07 -08:00
|
|
|
{
|
|
|
|
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
|
2011-06-28 15:26:16 -07:00
|
|
|
tb->grid_items = eina_list_append(tb->grid_items, e->item);
|
2011-03-04 13:50:07 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (near_cmp < 0)
|
|
|
|
{
|
|
|
|
e->item = elm_gengrid_item_insert_after
|
2011-06-28 15:26:16 -07:00
|
|
|
(tb->grid, ic, e, near_item, NULL, NULL);
|
|
|
|
tb->grid_items = eina_list_append_relative
|
|
|
|
(tb->grid_items, e->item, near_item);
|
2011-03-04 13:50:07 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e->item = elm_gengrid_item_insert_before
|
2011-06-28 15:26:16 -07:00
|
|
|
(tb->grid, ic, e, near_item, NULL, NULL);
|
|
|
|
tb->grid_items = eina_list_prepend_relative
|
|
|
|
(tb->grid_items, e->item, near_item);
|
2011-03-04 13:50:07 -08:00
|
|
|
}
|
|
|
|
}
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
if (e->item)
|
|
|
|
elm_gengrid_item_data_set(e->item, e);
|
|
|
|
else
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
ERR("could not add item to grid: path '%s'", e->path);
|
|
|
|
ephoto_entry_free(e);
|
|
|
|
return;
|
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
static void
|
|
|
|
_up_item_add_if_required(Ephoto_Thumb_Browser *tb)
|
|
|
|
{
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
char *parent_dir;
|
|
|
|
|
|
|
|
if ((strcmp(tb->ephoto->config->directory, "/") == 0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
parent_dir = ecore_file_dir_get(tb->ephoto->config->directory);
|
|
|
|
if (!parent_dir) return;
|
|
|
|
|
|
|
|
entry = ephoto_entry_new(tb->ephoto, parent_dir, PARENT_DIR);
|
|
|
|
free(parent_dir);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(entry);
|
|
|
|
entry->is_up = EINA_TRUE;
|
|
|
|
entry->is_dir = EINA_TRUE;
|
|
|
|
entry->item = elm_gengrid_item_append
|
|
|
|
(tb->grid, &_ephoto_thumb_up_class, entry, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
static Eina_Bool
|
2011-02-24 14:26:47 -08:00
|
|
|
_todo_items_process(void *data)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2011-02-21 17:55:08 -08:00
|
|
|
Ephoto_Entry *entry;
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH))
|
2011-02-21 17:55:08 -08:00
|
|
|
return EINA_TRUE;
|
2010-10-10 11:57:48 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
tb->animator.todo_items = NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(tb->todo_items, entry)
|
|
|
|
_entry_item_add(tb, entry);
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
|
|
|
_ephoto_thumb_selected(void *data, Evas_Object *o __UNUSED__, void *event_info)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Elm_Gengrid_Item *it = event_info;
|
|
|
|
Ephoto_Entry *e = elm_gengrid_item_data_get(it);
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2011-11-30 21:09:59 -08:00
|
|
|
elm_gengrid_item_selected_set(it, EINA_FALSE);
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
if (e->is_dir)
|
|
|
|
ephoto_directory_set(tb->ephoto, e->path);
|
|
|
|
else
|
|
|
|
evas_object_smart_callback_call(tb->main, "view", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_changed_dir_text(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2011-11-03 09:32:47 -07:00
|
|
|
const char *path = elm_entry_entry_get(tb->entry);
|
2011-06-28 15:26:16 -07:00
|
|
|
if (ecore_file_is_dir(path))
|
|
|
|
ephoto_directory_set(tb->ephoto, path);
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
|
|
|
_zoom_set(Ephoto_Thumb_Browser *tb, int zoom)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
if (zoom > ZOOM_MAX) zoom = ZOOM_MAX;
|
|
|
|
else if (zoom < ZOOM_MIN) zoom = ZOOM_MIN;
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
ephoto_thumb_size_set(tb->ephoto, zoom);
|
|
|
|
elm_gengrid_item_size_set(tb->grid, zoom, zoom);
|
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
2011-06-28 15:26:16 -07:00
|
|
|
_zoom_in(void *data, Evas_Object *o, void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Object *min = evas_object_data_get(o, "min");
|
|
|
|
int zoom = tb->ephoto->config->thumb_size + ZOOM_STEP;
|
|
|
|
_zoom_set(tb, zoom);
|
|
|
|
if (zoom >= ZOOM_MAX) elm_object_disabled_set(o, EINA_TRUE);
|
|
|
|
if (zoom > ZOOM_MIN) elm_object_disabled_set(min, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_zoom_out(void *data, Evas_Object *o, void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Object *max = evas_object_data_get(o, "max");
|
|
|
|
int zoom = tb->ephoto->config->thumb_size - ZOOM_STEP;
|
|
|
|
_zoom_set(tb, zoom);
|
|
|
|
if (zoom <= ZOOM_MIN) elm_object_disabled_set(o, EINA_TRUE);
|
|
|
|
if (zoom < ZOOM_MAX) elm_object_disabled_set(max, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_view_single(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
|
|
|
|
if (it) entry = elm_gengrid_item_data_get(it);
|
|
|
|
else entry = _first_file_entry_find(tb);
|
|
|
|
|
|
|
|
if (!entry) return;
|
|
|
|
if (entry->is_dir)
|
|
|
|
ephoto_directory_set(tb->ephoto, entry->path);
|
|
|
|
else
|
|
|
|
evas_object_smart_callback_call(tb->main, "view", entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_slideshow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
|
|
|
|
if (it) entry = elm_gengrid_item_data_get(it);
|
|
|
|
else entry = _first_file_entry_find(tb);
|
|
|
|
|
|
|
|
if (!entry) return;
|
|
|
|
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
|
|
|
|
{
|
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
|
|
|
Eina_Bool alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
|
|
|
const char *k = ev->keyname;
|
|
|
|
|
|
|
|
if (alt)
|
|
|
|
{
|
|
|
|
if (!strcmp(k, "Up"))
|
|
|
|
{
|
|
|
|
if (strcmp(tb->ephoto->config->directory, "/") != 0)
|
|
|
|
{
|
|
|
|
char *parent = ecore_file_dir_get
|
|
|
|
(tb->ephoto->config->directory);
|
|
|
|
if (parent)
|
|
|
|
ephoto_directory_set(tb->ephoto, parent);
|
|
|
|
free(parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(k, "F5"))
|
|
|
|
{
|
|
|
|
Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
if (it) entry = elm_gengrid_item_data_get(it);
|
|
|
|
else entry = _first_file_entry_find(tb);
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_main_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
2011-02-10 15:41:02 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Ecore_Event_Handler *handler;
|
2011-02-10 15:41:02 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
_todo_items_free(tb);
|
|
|
|
_grid_items_free(tb);
|
|
|
|
EINA_LIST_FREE(tb->handlers, handler)
|
|
|
|
ecore_event_handler_del(handler);
|
2011-02-10 15:41:02 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
if (tb->animator.todo_items)
|
|
|
|
{
|
|
|
|
ecore_animator_del(tb->animator.todo_items);
|
|
|
|
tb->animator.todo_items = NULL;
|
|
|
|
}
|
|
|
|
if (tb->ls)
|
|
|
|
{
|
2011-06-28 15:26:16 -07:00
|
|
|
tb->main_deleted = EINA_TRUE;
|
2011-02-24 14:26:47 -08:00
|
|
|
eio_file_cancel(tb->ls);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
free(tb);
|
2011-02-10 15:41:02 -08:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_populate_start(void *data, int type __UNUSED__, void *event __UNUSED__)
|
2010-11-13 17:51:16 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_smart_callback_call(tb->main, "changed,directory", NULL);
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
_todo_items_free(tb);
|
|
|
|
_grid_items_free(tb);
|
2011-11-30 21:09:59 -08:00
|
|
|
elm_gengrid_clear(tb->grid);
|
2011-11-03 09:32:47 -07:00
|
|
|
elm_entry_entry_set(tb->entry, tb->ephoto->config->directory);
|
2011-06-28 16:22:44 -07:00
|
|
|
_up_item_add_if_required(tb);
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2010-11-30 13:52:49 -08:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_populate_end(void *data, int type __UNUSED__, void *event __UNUSED__)
|
2010-11-30 13:52:49 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
2011-02-13 19:04:20 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
tb->ls = NULL;
|
2011-06-28 15:26:16 -07:00
|
|
|
if (tb->main_deleted)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
free(tb);
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
2011-02-13 19:04:20 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
2010-10-10 18:10:27 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static Eina_Bool
|
2011-05-17 13:02:53 -07:00
|
|
|
_ephoto_thumb_populate_error(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2010-10-10 18:10:27 -07:00
|
|
|
}
|
2011-02-14 13:16:13 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_thumb_entry_create(void *data, int type __UNUSED__, void *event)
|
2011-02-14 13:16:13 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb = data;
|
|
|
|
Ephoto_Event_Entry_Create *ev = event;
|
|
|
|
Ephoto_Entry *e;
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
e = ev->entry;
|
|
|
|
tb->todo_items = eina_list_append(tb->todo_items, e);
|
2011-02-14 13:16:13 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
if (!tb->animator.todo_items)
|
|
|
|
tb->animator.todo_items = ecore_animator_add(_todo_items_process, tb);
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2011-06-28 16:17:32 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_button_add(Evas_Object *box, const char *image)
|
|
|
|
{
|
|
|
|
Evas_Object *but, *ic;
|
|
|
|
|
|
|
|
but = elm_button_add(box);
|
|
|
|
|
|
|
|
ic = elm_icon_add(but);
|
|
|
|
elm_icon_file_set(ic, image, NULL);
|
2011-06-29 07:58:37 -07:00
|
|
|
evas_object_size_hint_min_set(ic, 16, 16);
|
2011-06-29 08:24:01 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2011-06-28 16:17:32 -07:00
|
|
|
|
2011-11-03 09:32:47 -07:00
|
|
|
elm_object_content_set(but, ic);
|
2011-06-28 16:17:32 -07:00
|
|
|
evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(box, but);
|
|
|
|
evas_object_show(but);
|
|
|
|
|
|
|
|
return but;
|
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
Evas_Object *
|
|
|
|
ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|
|
|
{
|
2011-06-28 15:26:16 -07:00
|
|
|
Evas_Object *box = elm_box_add(parent);
|
2011-06-28 16:17:32 -07:00
|
|
|
Evas_Object *but, *min, *max;
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Thumb_Browser *tb;
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
|
|
|
|
|
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
|
|
|
|
|
|
|
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
tb->ephoto = ephoto;
|
2011-06-28 15:26:16 -07:00
|
|
|
tb->main = box;
|
|
|
|
elm_box_horizontal_set(tb->main, EINA_FALSE);
|
|
|
|
elm_box_homogeneous_set(tb->main, EINA_FALSE);
|
|
|
|
evas_object_event_callback_add(tb->main, EVAS_CALLBACK_DEL, _main_del, tb);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(tb->main, EVAS_CALLBACK_KEY_DOWN, _key_down, tb);
|
|
|
|
evas_object_data_set(tb->main, "thumb_browser", tb);
|
|
|
|
|
|
|
|
tb->bar = elm_box_add(tb->main);
|
|
|
|
elm_box_horizontal_set(tb->bar, EINA_TRUE);
|
|
|
|
elm_box_homogeneous_set(tb->bar, EINA_FALSE);
|
|
|
|
evas_object_size_hint_weight_set(tb->bar, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(tb->bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(tb->bar);
|
|
|
|
elm_box_pack_end(tb->main, tb->bar);
|
|
|
|
|
2011-06-28 16:17:32 -07:00
|
|
|
but = _button_add(tb->bar, PACKAGE_DATA_DIR "/images/single.png");
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _view_single, tb);
|
|
|
|
|
2011-06-28 16:17:32 -07:00
|
|
|
but = _button_add(tb->bar, PACKAGE_DATA_DIR "/images/slideshow.png");
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _slideshow, tb);
|
|
|
|
|
2011-11-03 09:32:47 -07:00
|
|
|
tb->entry = elm_entry_add(tb->bar);
|
2011-06-29 12:49:24 -07:00
|
|
|
EINA_SAFETY_ON_NULL_GOTO(tb->entry, error);
|
|
|
|
evas_object_size_hint_weight_set(tb->entry, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(tb->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2011-11-03 09:32:47 -07:00
|
|
|
elm_entry_single_line_set(tb->entry, EINA_TRUE);
|
|
|
|
elm_entry_scrollable_set(tb->entry, EINA_TRUE);
|
|
|
|
elm_entry_scrollbar_policy_set(tb->entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_smart_callback_add
|
2011-06-29 12:49:24 -07:00
|
|
|
(tb->entry, "activated", _changed_dir_text, tb);
|
|
|
|
evas_object_show(tb->entry);
|
|
|
|
elm_box_pack_end(tb->bar, tb->entry);
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-06-28 16:17:32 -07:00
|
|
|
but = _button_add(tb->bar, PACKAGE_DATA_DIR "/images/zoom-in.png");
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _zoom_in, tb);
|
|
|
|
max = but;
|
|
|
|
|
2011-06-28 16:17:32 -07:00
|
|
|
but = _button_add(tb->bar, PACKAGE_DATA_DIR "/images/zoom-out.png");
|
2011-06-28 15:26:16 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _zoom_out, tb);
|
|
|
|
min = but;
|
|
|
|
|
|
|
|
evas_object_data_set(max, "min", min);
|
|
|
|
evas_object_data_set(min, "max", max);
|
|
|
|
|
|
|
|
tb->grid = elm_gengrid_add(tb->main);
|
2011-02-24 14:26:47 -08:00
|
|
|
EINA_SAFETY_ON_NULL_GOTO(tb->grid, error);
|
2011-06-28 15:26:16 -07:00
|
|
|
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);
|
|
|
|
|
2012-01-04 00:23:45 -08:00
|
|
|
elm_gengrid_align_set(tb->grid, 0.0, 0.0);
|
2011-11-30 21:09:59 -08:00
|
|
|
elm_gengrid_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE);
|
2011-02-24 14:26:47 -08:00
|
|
|
evas_object_size_hint_align_set
|
|
|
|
(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set
|
|
|
|
(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
evas_object_smart_callback_add
|
|
|
|
(tb->grid, "selected", _ephoto_thumb_selected, tb);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
_zoom_set(tb, tb->ephoto->config->thumb_size);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
evas_object_show(tb->grid);
|
2011-06-28 15:26:16 -07:00
|
|
|
elm_box_pack_end(tb->main, tb->grid);
|
2011-03-07 14:02:12 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
tb->handlers = eina_list_append
|
|
|
|
(tb->handlers, ecore_event_handler_add
|
|
|
|
(EPHOTO_EVENT_POPULATE_START, _ephoto_thumb_populate_start, tb));
|
|
|
|
|
|
|
|
tb->handlers = eina_list_append
|
|
|
|
(tb->handlers, ecore_event_handler_add
|
|
|
|
(EPHOTO_EVENT_POPULATE_END, _ephoto_thumb_populate_end, tb));
|
|
|
|
|
|
|
|
tb->handlers = eina_list_append
|
|
|
|
(tb->handlers, ecore_event_handler_add
|
|
|
|
(EPHOTO_EVENT_POPULATE_ERROR, _ephoto_thumb_populate_error, tb));
|
|
|
|
|
|
|
|
tb->handlers = eina_list_append
|
|
|
|
(tb->handlers, ecore_event_handler_add
|
2011-06-28 15:26:16 -07:00
|
|
|
(EPHOTO_EVENT_ENTRY_CREATE, _ephoto_thumb_entry_create, tb));
|
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
|
|
|
|
2011-02-24 14:26:47 -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
|
|
|
}
|