2010-07-01 11:49:22 -07:00
|
|
|
#include "ephoto.h"
|
|
|
|
|
|
|
|
/*Callbacks*/
|
|
|
|
static void _ephoto_slider_changed(void *data, Evas_Object *obj, void *event_info);
|
|
|
|
static void _ephoto_thumber_connected(void *data, Ethumb_Client *client, Eina_Bool success);
|
|
|
|
static void _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id,
|
|
|
|
const char *file, const char *key,
|
|
|
|
const char *thumb_path, const char *thumb_key,
|
|
|
|
Eina_Bool success);
|
|
|
|
static char *_ephoto_get_label(const void *data, Evas_Object *obj, const char *part);
|
|
|
|
static Evas_Object *_ephoto_get_icon(const void *data, Evas_Object *obj, const char *part);
|
|
|
|
static Eina_Bool _ephoto_get_state(const void *data, Evas_Object *obj, const char *part);
|
|
|
|
static void _ephoto_grid_del(const void *data, Evas_Object *obj);
|
2010-07-14 16:23:54 -07:00
|
|
|
static void _ephoto_thumb_clicked_job(void *data);
|
|
|
|
static void _ephoto_thumb_clicked(void *data, Evas_Object *obj, void *event_info);
|
2010-07-05 14:07:53 -07:00
|
|
|
static void _ephoto_view_large(void *data, Evas_Object *obj, void *event_info);
|
2010-07-07 19:37:45 -07:00
|
|
|
static void _ephoto_change_directory(void *data, Evas_Object *obj, void *event_info);
|
2010-07-27 19:06:03 -07:00
|
|
|
static void _ephoto_view_slideshow(void *data, Evas_Object *obj, void *event_info);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
/*Inline Variables*/
|
|
|
|
static Elm_Gengrid_Item_Class eg;
|
|
|
|
static Ethumb_Client *ec;
|
2010-07-07 20:39:52 -07:00
|
|
|
static const char *current_directory;
|
2010-07-01 11:49:22 -07:00
|
|
|
static int cur_val;
|
2010-07-23 04:00:44 -07:00
|
|
|
static Eio_File *list = NULL;
|
2010-07-05 14:07:53 -07:00
|
|
|
static Evas_Object *toolbar, *dir_label, *thumb_slider, *thbox;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-07 21:25:28 -07:00
|
|
|
typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data;
|
|
|
|
struct _Ephoto_Thumb_Data
|
|
|
|
{
|
|
|
|
const char *thumb_path;
|
|
|
|
const char *file;
|
|
|
|
};
|
|
|
|
|
2010-07-01 11:49:22 -07:00
|
|
|
/*Create the thumbnail browser object*/
|
|
|
|
void
|
2010-07-10 14:52:14 -07:00
|
|
|
ephoto_create_thumb_browser(const char *directory)
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
|
|
|
|
|
|
|
|
ec = ethumb_client_connect(_ephoto_thumber_connected, NULL, NULL);
|
|
|
|
|
2010-07-10 14:52:14 -07:00
|
|
|
if (!directory)
|
|
|
|
{
|
|
|
|
getcwd(buf, PATH_MAX);
|
|
|
|
current_directory = eina_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current_directory = eina_stringshare_add(directory);
|
|
|
|
}
|
2010-07-05 14:07:53 -07:00
|
|
|
toolbar = elm_toolbar_add(em->win);
|
|
|
|
elm_toolbar_icon_size_set(toolbar, 24);
|
|
|
|
elm_toolbar_homogenous_set(toolbar, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0.5);
|
|
|
|
elm_box_pack_end(em->box, toolbar);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
o = elm_icon_add(em->win);
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/change_directory.png", NULL);
|
2010-07-07 19:37:45 -07:00
|
|
|
elm_toolbar_item_add(toolbar, o, "Change Directory", _ephoto_change_directory, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
o = elm_icon_add(em->win);
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/filter.png", NULL);
|
2010-07-05 14:07:53 -07:00
|
|
|
elm_toolbar_item_add(toolbar, o, "Filter", NULL, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
o = elm_icon_add(em->win);
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/view_presentation.png", NULL);
|
2010-07-05 14:07:53 -07:00
|
|
|
elm_toolbar_item_add(toolbar, o, "View Large", _ephoto_view_large, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
o = elm_icon_add(em->win);
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/play_slideshow.png", NULL);
|
2010-07-27 19:06:03 -07:00
|
|
|
elm_toolbar_item_add(toolbar, o, "Play Slideshow", _ephoto_view_slideshow, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
em->thumb_browser = elm_gengrid_add(em->win);
|
|
|
|
elm_gengrid_align_set(em->thumb_browser, 0.5, 0.6);
|
|
|
|
elm_gengrid_item_size_set(em->thumb_browser, 208, 146);
|
|
|
|
elm_gengrid_horizontal_set(em->thumb_browser, EINA_TRUE);
|
|
|
|
evas_object_size_hint_align_set(em->thumb_browser, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set(em->thumb_browser, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(em->thumb_browser, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(em->thumb_browser, "ephoto");
|
2010-07-14 16:23:54 -07:00
|
|
|
evas_object_smart_callback_add(em->thumb_browser, "clicked", _ephoto_thumb_clicked, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
elm_box_pack_end(em->box, em->thumb_browser);
|
|
|
|
|
2010-07-05 14:07:53 -07:00
|
|
|
thbox = elm_box_add(em->win);
|
|
|
|
elm_box_horizontal_set(thbox, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(thbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_fill_set(thbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(em->box, thbox);
|
|
|
|
|
|
|
|
dir_label = elm_label_add(em->win);
|
|
|
|
elm_label_label_set(dir_label, buf);
|
|
|
|
evas_object_size_hint_weight_set(dir_label, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(dir_label, 0.01, 0.5);
|
|
|
|
elm_box_pack_end(thbox, dir_label);
|
|
|
|
|
|
|
|
thumb_slider = elm_slider_add(em->win);
|
|
|
|
elm_slider_label_set(thumb_slider, "Thumb Size:");
|
|
|
|
elm_slider_span_size_set(thumb_slider, 100);
|
|
|
|
elm_slider_min_max_set(thumb_slider, 0, 100);
|
|
|
|
elm_slider_value_set(thumb_slider, 50);
|
|
|
|
elm_box_pack_end(thbox, thumb_slider);
|
|
|
|
evas_object_smart_callback_add(thumb_slider, "changed",
|
2010-07-01 11:49:22 -07:00
|
|
|
_ephoto_slider_changed, NULL);
|
|
|
|
cur_val = 50;
|
|
|
|
|
|
|
|
eg.item_style = "ephoto";
|
|
|
|
eg.func.label_get = _ephoto_get_label;
|
|
|
|
eg.func.icon_get = _ephoto_get_icon;
|
|
|
|
eg.func.state_get = _ephoto_get_state;
|
|
|
|
eg.func.del = _ephoto_grid_del;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Show the thumbnail browser*/
|
|
|
|
void
|
|
|
|
ephoto_show_thumb_browser(void)
|
|
|
|
{
|
2010-07-05 14:07:53 -07:00
|
|
|
evas_object_show(toolbar);
|
2010-07-01 11:49:22 -07:00
|
|
|
evas_object_show(em->thumb_browser);
|
2010-07-05 14:07:53 -07:00
|
|
|
evas_object_show(dir_label);
|
|
|
|
evas_object_show(thumb_slider);
|
|
|
|
evas_object_show(thbox);
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Hide the thumbnail browser*/
|
|
|
|
void
|
|
|
|
ephoto_hide_thumb_browser(void)
|
|
|
|
{
|
2010-07-05 14:07:53 -07:00
|
|
|
evas_object_hide(toolbar);
|
2010-07-01 11:49:22 -07:00
|
|
|
evas_object_hide(em->thumb_browser);
|
2010-07-05 14:07:53 -07:00
|
|
|
evas_object_hide(dir_label);
|
|
|
|
evas_object_hide(thumb_slider);
|
|
|
|
evas_object_hide(thbox);
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Destroy the thumbnail browser*/
|
|
|
|
void
|
|
|
|
ephoto_delete_thumb_browser(void)
|
|
|
|
{
|
2010-07-07 21:25:28 -07:00
|
|
|
const Eina_List *items, *l, *iter;
|
|
|
|
Elm_Gengrid_Item *item;
|
|
|
|
Ephoto_Thumb_Data *etd;
|
2010-07-03 10:00:58 -07:00
|
|
|
|
2010-07-05 14:07:53 -07:00
|
|
|
items = elm_toolbar_item_get_all(toolbar);
|
2010-07-03 10:00:58 -07:00
|
|
|
while (items)
|
|
|
|
{
|
|
|
|
evas_object_del(eina_list_data_get(items));
|
|
|
|
items = eina_list_next(items);
|
|
|
|
}
|
2010-07-07 21:25:28 -07:00
|
|
|
l = elm_gengrid_items_get(em->thumb_browser);
|
|
|
|
EINA_LIST_FOREACH(l, iter, item)
|
|
|
|
{
|
|
|
|
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get(item);
|
|
|
|
eina_stringshare_del(etd->thumb_path);
|
|
|
|
eina_stringshare_del(etd->file);
|
|
|
|
free(etd);
|
|
|
|
}
|
2010-07-07 20:39:52 -07:00
|
|
|
eina_stringshare_del(current_directory);
|
2010-07-05 14:07:53 -07:00
|
|
|
evas_object_del(toolbar);
|
2010-07-01 11:49:22 -07:00
|
|
|
evas_object_del(em->thumb_browser);
|
2010-07-05 14:07:53 -07:00
|
|
|
evas_object_del(dir_label);
|
|
|
|
evas_object_del(thumb_slider);
|
|
|
|
evas_object_del(thbox);
|
2010-07-01 11:49:22 -07:00
|
|
|
ethumb_client_disconnect(ec);
|
|
|
|
}
|
|
|
|
|
2010-07-02 04:17:59 -07:00
|
|
|
/* Use ecore thread facility to avoid lock completly */
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-22 09:15:16 -07:00
|
|
|
/* Check image type from another thread */
|
|
|
|
static Eina_Bool
|
2010-08-03 10:14:54 -07:00
|
|
|
_ephoto_populate_filter(const void *data, const char *file)
|
2010-07-02 04:17:59 -07:00
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
2010-08-03 10:57:10 -07:00
|
|
|
printf("%s\n", file);
|
|
|
|
if (!(type = efreet_mime_type_get(file)))
|
2010-07-22 09:15:16 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
if (!strncmp(type, "image", 5))
|
|
|
|
return EINA_TRUE;
|
2010-07-02 04:17:59 -07:00
|
|
|
|
2010-07-22 09:15:16 -07:00
|
|
|
return EINA_FALSE;
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
|
2010-07-05 14:07:53 -07:00
|
|
|
/*Done populating images*/
|
2010-07-01 11:49:22 -07:00
|
|
|
static void
|
2010-08-03 10:57:10 -07:00
|
|
|
_ephoto_populate_end(const void *data)
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
2010-07-22 09:15:16 -07:00
|
|
|
list = NULL;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-22 09:15:16 -07:00
|
|
|
efreet_mime_shutdown();
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
|
2010-07-22 09:15:16 -07:00
|
|
|
/* Build the interface component after detection from main thread */
|
2010-07-02 04:17:59 -07:00
|
|
|
static void
|
2010-08-03 10:14:54 -07:00
|
|
|
_ephoto_populate_main(const void *data, const char *file)
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
2010-07-02 04:17:59 -07:00
|
|
|
const char *thumb;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-22 09:15:16 -07:00
|
|
|
file = eina_stringshare_ref(file);
|
|
|
|
|
|
|
|
em->images = eina_list_append(em->images, file);
|
|
|
|
ethumb_client_file_set(ec, file, NULL);
|
2010-07-02 04:17:59 -07:00
|
|
|
if (!ethumb_client_thumb_exists(ec))
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
2010-07-02 04:17:59 -07:00
|
|
|
ethumb_client_generate(ec, _ephoto_thumbnail_generated, NULL, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
2010-07-02 04:17:59 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ethumb_client_thumb_path_get(ec, &thumb, NULL);
|
2010-07-22 09:15:16 -07:00
|
|
|
_ephoto_thumbnail_generated(NULL, ec, 0, file, NULL,
|
2010-07-02 04:17:59 -07:00
|
|
|
thumb, NULL, EINA_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start a thread to list images in a directory without locking the interface */
|
|
|
|
void
|
|
|
|
ephoto_populate_thumbnails(void)
|
|
|
|
{
|
2010-07-07 19:37:45 -07:00
|
|
|
if (!current_directory) return ;
|
2010-07-02 04:17:59 -07:00
|
|
|
|
2010-07-22 09:15:16 -07:00
|
|
|
if (!efreet_mime_init())
|
|
|
|
fprintf(stderr, "Could not init efreet_mime!\n");
|
|
|
|
|
|
|
|
list = eio_file_ls(current_directory,
|
|
|
|
_ephoto_populate_filter,
|
|
|
|
_ephoto_populate_main,
|
|
|
|
_ephoto_populate_end,
|
2010-07-23 04:00:44 -07:00
|
|
|
_ephoto_populate_end, /* We don't handle error case in ephoto */
|
2010-07-22 09:15:16 -07:00
|
|
|
NULL);
|
2010-07-02 04:17:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Change the thumbnail size*/
|
|
|
|
static void
|
|
|
|
_ephoto_slider_changed(void *data, Evas_Object *obj, void *event)
|
|
|
|
{
|
2010-07-02 21:42:22 -07:00
|
|
|
int w, h, val;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-05 14:07:53 -07:00
|
|
|
val = elm_slider_value_get(thumb_slider);
|
2010-07-02 21:42:22 -07:00
|
|
|
elm_gengrid_item_size_get(em->thumb_browser, &w, &h);
|
|
|
|
if (val < cur_val)
|
|
|
|
{
|
|
|
|
w -= cur_val-val;
|
|
|
|
h -= cur_val-val;
|
|
|
|
}
|
|
|
|
else if (val > cur_val)
|
|
|
|
{
|
|
|
|
w += val-cur_val;
|
|
|
|
h += val-cur_val;
|
|
|
|
}
|
|
|
|
elm_gengrid_item_size_set(em->thumb_browser, w, h);
|
|
|
|
cur_val = val;
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Callback when the client is connected*/
|
|
|
|
static void _ephoto_thumber_connected(void *data, Ethumb_Client *client, Eina_Bool success)
|
|
|
|
{
|
|
|
|
if (success == EINA_TRUE)
|
|
|
|
{
|
|
|
|
ethumb_client_fdo_set(ec, ETHUMB_THUMB_LARGE);
|
|
|
|
ethumb_client_format_set(ec, ETHUMB_THUMB_FDO);
|
|
|
|
ethumb_client_aspect_set(ec, ETHUMB_THUMB_KEEP_ASPECT);
|
|
|
|
ephoto_populate_thumbnails();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Could not connect to ethumb!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Callback when the thumbnail has been generated!*/
|
|
|
|
static void
|
|
|
|
_ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id,
|
|
|
|
const char *file, const char *key,
|
|
|
|
const char *thumb_path, const char *thumb_key,
|
|
|
|
Eina_Bool success)
|
|
|
|
{
|
|
|
|
if (success)
|
|
|
|
{
|
2010-07-07 21:25:28 -07:00
|
|
|
Ephoto_Thumb_Data *etd;
|
|
|
|
|
|
|
|
etd = calloc(1, sizeof(etd));
|
|
|
|
etd->thumb_path = eina_stringshare_add(thumb_path);
|
|
|
|
etd->file = eina_stringshare_add(file);
|
|
|
|
|
|
|
|
elm_gengrid_item_append(em->thumb_browser, &eg, etd, NULL, NULL);
|
2010-07-01 11:49:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Get the label for the icon in the grid*/
|
|
|
|
static char *
|
|
|
|
_ephoto_get_label(const void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
2010-07-02 14:35:51 -07:00
|
|
|
const char *bname;
|
2010-07-07 21:25:28 -07:00
|
|
|
Ephoto_Thumb_Data *etd;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-07 21:25:28 -07:00
|
|
|
etd = (Ephoto_Thumb_Data *)data;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-07-07 21:25:28 -07:00
|
|
|
bname = basename(etd->file);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
return strdup(bname);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Get the image for the icon in the grid*/
|
|
|
|
static Evas_Object *
|
|
|
|
_ephoto_get_icon(const void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
2010-07-02 14:35:51 -07:00
|
|
|
Evas_Object *thumb, *o;
|
2010-07-07 21:25:28 -07:00
|
|
|
Ephoto_Thumb_Data *etd;
|
|
|
|
|
|
|
|
etd = (Ephoto_Thumb_Data *)data;
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
if (!strcmp(part, "elm.swallow.icon"))
|
|
|
|
{
|
2010-07-02 14:35:51 -07:00
|
|
|
thumb = elm_layout_add(em->win);
|
|
|
|
elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
|
|
|
"/ephoto/thumb");
|
|
|
|
evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2010-07-01 11:49:22 -07:00
|
|
|
evas_object_show(thumb);
|
2010-07-02 14:35:51 -07:00
|
|
|
|
2010-07-03 10:00:58 -07:00
|
|
|
o = elm_bg_add(em->win);
|
2010-07-07 21:25:28 -07:00
|
|
|
elm_bg_file_set(o, etd->thumb_path, NULL);
|
2010-07-03 10:00:58 -07:00
|
|
|
evas_object_resize(o, 176, 117);
|
2010-07-02 14:35:51 -07:00
|
|
|
|
|
|
|
elm_layout_content_set(thumb, "ephoto.swallow.content", o);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
|
|
|
return thumb;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Get the state of the icon in the grid!*/
|
|
|
|
static Eina_Bool
|
|
|
|
_ephoto_get_state(const void *data, Evas_Object *obj, const char *part)
|
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Delete the grid*/
|
|
|
|
static void
|
|
|
|
_ephoto_grid_del(const void *data, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-14 16:23:54 -07:00
|
|
|
/*Thumb clicked job*/
|
|
|
|
static void
|
|
|
|
_ephoto_thumb_clicked_job(void *data)
|
|
|
|
{
|
|
|
|
const char *file;
|
|
|
|
|
|
|
|
file = data;
|
|
|
|
|
|
|
|
ephoto_hide_thumb_browser();
|
|
|
|
ephoto_show_flow_browser(file);
|
|
|
|
}
|
|
|
|
|
2010-07-05 15:58:16 -07:00
|
|
|
/*Check to see if the thumbnail was double clicked*/
|
|
|
|
static void
|
2010-07-14 16:23:54 -07:00
|
|
|
_ephoto_thumb_clicked(void *data, Evas_Object *obj, void *event_info)
|
2010-07-05 15:58:16 -07:00
|
|
|
{
|
|
|
|
const Eina_List *selected;
|
2010-07-07 21:25:28 -07:00
|
|
|
Ephoto_Thumb_Data *etd;
|
2010-07-05 15:58:16 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
|
2010-07-14 16:23:54 -07:00
|
|
|
selected = elm_gengrid_selected_items_get(em->thumb_browser);
|
|
|
|
o = eina_list_data_get(selected);
|
|
|
|
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)o);
|
|
|
|
ecore_job_add(_ephoto_thumb_clicked_job, etd->file);
|
2010-07-05 15:58:16 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 19:06:03 -07:00
|
|
|
/*File Selector is shown*/
|
2010-07-07 19:37:45 -07:00
|
|
|
static void
|
|
|
|
_ephoto_fileselector_shown(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
elm_fileselector_path_set(obj, current_directory);
|
|
|
|
evas_render(em->e);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Directory has been chosen*/
|
|
|
|
static void
|
|
|
|
_ephoto_directory_chosen(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2010-07-07 21:25:28 -07:00
|
|
|
const Eina_List *l, *iter;
|
2010-07-07 19:37:45 -07:00
|
|
|
Evas_Object *win;
|
2010-07-07 21:25:28 -07:00
|
|
|
Elm_Gengrid_Item *item;
|
|
|
|
Ephoto_Thumb_Data *etd;
|
2010-07-07 19:37:45 -07:00
|
|
|
const char *directory;
|
|
|
|
|
|
|
|
win = (Evas_Object *)data;
|
|
|
|
|
|
|
|
directory = elm_fileselector_selected_get(obj);
|
|
|
|
|
2010-07-08 11:53:18 -07:00
|
|
|
if ((directory) && (eina_stringshare_replace(¤t_directory, directory)))
|
2010-07-07 19:37:45 -07:00
|
|
|
{
|
2010-07-08 11:53:18 -07:00
|
|
|
l = elm_gengrid_items_get(em->thumb_browser);
|
|
|
|
EINA_LIST_FOREACH(l, iter, item)
|
|
|
|
{
|
|
|
|
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get(item);
|
|
|
|
eina_stringshare_del(etd->thumb_path);
|
|
|
|
eina_stringshare_del(etd->file);
|
|
|
|
free(etd);
|
|
|
|
}
|
|
|
|
elm_gengrid_clear(em->thumb_browser);
|
|
|
|
eina_list_free(em->images);
|
|
|
|
em->images = NULL;
|
|
|
|
ephoto_populate_thumbnails();
|
|
|
|
elm_label_label_set(dir_label, current_directory);
|
2010-07-07 19:37:45 -07:00
|
|
|
}
|
|
|
|
evas_object_del(obj);
|
|
|
|
evas_object_del(win);
|
|
|
|
elm_toolbar_item_unselect_all(toolbar);
|
|
|
|
}
|
|
|
|
|
2010-07-05 14:07:53 -07:00
|
|
|
/*Show the flow browser*/
|
|
|
|
static void
|
|
|
|
_ephoto_view_large(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2010-07-05 15:58:16 -07:00
|
|
|
const Eina_List *selected;
|
|
|
|
Evas_Object *o;
|
2010-07-07 21:25:28 -07:00
|
|
|
Ephoto_Thumb_Data *etd;
|
2010-07-05 15:58:16 -07:00
|
|
|
|
2010-07-05 14:07:53 -07:00
|
|
|
ephoto_hide_thumb_browser();
|
2010-07-05 15:58:16 -07:00
|
|
|
|
|
|
|
selected = elm_gengrid_selected_items_get(em->thumb_browser);
|
|
|
|
|
|
|
|
if (eina_list_data_get(selected))
|
|
|
|
{
|
|
|
|
o = eina_list_data_get(selected);
|
2010-07-07 21:25:28 -07:00
|
|
|
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)o);
|
|
|
|
ephoto_show_flow_browser(etd->file);
|
2010-07-05 15:58:16 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ephoto_show_flow_browser(eina_list_data_get(em->images));
|
|
|
|
}
|
2010-07-05 14:07:53 -07:00
|
|
|
|
|
|
|
elm_toolbar_item_unselect_all(toolbar);
|
|
|
|
}
|
2010-07-07 19:37:45 -07:00
|
|
|
|
|
|
|
/*Change directory*/
|
|
|
|
static void
|
|
|
|
_ephoto_change_directory(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *fsel;
|
|
|
|
|
|
|
|
win = elm_win_inwin_add(em->win);
|
|
|
|
|
|
|
|
fsel = elm_fileselector_add(em->win);
|
|
|
|
elm_fileselector_folder_only_set(fsel, EINA_TRUE);
|
|
|
|
elm_fileselector_buttons_ok_cancel_set(fsel, EINA_TRUE);
|
|
|
|
evas_object_event_callback_add(fsel, EVAS_CALLBACK_SHOW,
|
|
|
|
_ephoto_fileselector_shown, NULL);
|
|
|
|
evas_object_smart_callback_add(fsel, "done",
|
|
|
|
_ephoto_directory_chosen, win);
|
|
|
|
|
|
|
|
elm_win_inwin_content_set(win, fsel);
|
|
|
|
elm_win_inwin_activate(win);
|
|
|
|
|
|
|
|
evas_object_show(fsel);
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
|
|
|
|
2010-07-27 19:06:03 -07:00
|
|
|
/*Show slideshow*/
|
|
|
|
static void
|
|
|
|
_ephoto_view_slideshow(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
ephoto_hide_thumb_browser();
|
|
|
|
ephoto_show_slideshow(0, NULL);
|
|
|
|
elm_toolbar_item_unselect_all(toolbar);
|
|
|
|
}
|