|
|
|
@ -1,5 +1,31 @@ |
|
|
|
|
#include "ephoto.h" |
|
|
|
|
|
|
|
|
|
typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data; |
|
|
|
|
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser; |
|
|
|
|
|
|
|
|
|
struct _Ephoto_Thumb_Data |
|
|
|
|
{ |
|
|
|
|
char *thumb_path; |
|
|
|
|
char *file; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct _Ephoto_Thumb_Browser |
|
|
|
|
{
|
|
|
|
|
Evas_Object *layout; |
|
|
|
|
Evas_Object *thumb_browser; |
|
|
|
|
Evas_Object *dir_label; |
|
|
|
|
Evas_Object *toolbar; |
|
|
|
|
Evas_Object *thumb_slider; |
|
|
|
|
Evas_Object *thbox; |
|
|
|
|
Evas_Object *fsel_win; |
|
|
|
|
Elm_Gengrid_Item_Class eg; |
|
|
|
|
Ethumb_Client *ec; |
|
|
|
|
const char *current_directory; |
|
|
|
|
int cur_val; |
|
|
|
|
Eio_File *list; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*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); |
|
|
|
@ -16,178 +42,143 @@ static void _ephoto_thumb_clicked(void *data, Evas_Object *obj, void *event_info |
|
|
|
|
static void _ephoto_view_large(void *data, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _ephoto_change_directory(void *data, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _ephoto_view_slideshow(void *data, Evas_Object *obj, void *event_info); |
|
|
|
|
|
|
|
|
|
/*Inline Variables*/ |
|
|
|
|
static Elm_Gengrid_Item_Class eg; |
|
|
|
|
static Ethumb_Client *ec; |
|
|
|
|
static const char *current_directory; |
|
|
|
|
static int cur_val; |
|
|
|
|
static Eio_File *list = NULL; |
|
|
|
|
static Evas_Object *toolbar, *dir_label, *thumb_slider, *thbox; |
|
|
|
|
|
|
|
|
|
typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data; |
|
|
|
|
struct _Ephoto_Thumb_Data |
|
|
|
|
{ |
|
|
|
|
const char *thumb_path; |
|
|
|
|
const char *file; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static void _ephoto_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); |
|
|
|
|
/*Create the thumbnail browser object*/ |
|
|
|
|
void |
|
|
|
|
ephoto_create_thumb_browser(const char *directory) |
|
|
|
|
Evas_Object * |
|
|
|
|
ephoto_create_thumb_browser(Evas_Object *parent, const char *directory) |
|
|
|
|
{ |
|
|
|
|
Evas_Object *o; |
|
|
|
|
char buf[PATH_MAX]; |
|
|
|
|
Ephoto_Thumb_Browser *tb; |
|
|
|
|
|
|
|
|
|
tb = calloc(1, sizeof(Ephoto_Thumb_Browser)); |
|
|
|
|
|
|
|
|
|
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/default/ephoto.edj"); |
|
|
|
|
|
|
|
|
|
ec = ethumb_client_connect(_ephoto_thumber_connected, NULL, NULL); |
|
|
|
|
tb->ec = ethumb_client_connect(_ephoto_thumber_connected, tb, NULL); |
|
|
|
|
|
|
|
|
|
tb->layout = elm_layout_add(parent); |
|
|
|
|
elm_layout_file_set(tb->layout,
|
|
|
|
|
PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
|
|
|
|
"ephoto/browser/layout"); |
|
|
|
|
|
|
|
|
|
evas_object_size_hint_weight_set(tb->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
|
|
|
|
evas_object_size_hint_fill_set(tb->layout, EVAS_HINT_FILL, EVAS_HINT_FILL); |
|
|
|
|
evas_object_show(tb->layout); |
|
|
|
|
|
|
|
|
|
if (!directory) |
|
|
|
|
{ |
|
|
|
|
getcwd(buf, PATH_MAX); |
|
|
|
|
current_directory = eina_stringshare_add(buf); |
|
|
|
|
tb->current_directory = eina_stringshare_add(buf); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
current_directory = eina_stringshare_add(directory); |
|
|
|
|
tb->current_directory = eina_stringshare_add(directory); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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_layout_content_set(em->layout, "ephoto.location.swallow", thbox); |
|
|
|
|
//elm_box_pack_end(em->box, thbox);
|
|
|
|
|
|
|
|
|
|
dir_label = elm_label_add(em->win); |
|
|
|
|
elm_label_label_set(dir_label, current_directory); |
|
|
|
|
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", |
|
|
|
|
_ephoto_slider_changed, NULL); |
|
|
|
|
|
|
|
|
|
em->thumb_browser = elm_gengrid_add(em->win); |
|
|
|
|
elm_gengrid_align_set(em->thumb_browser, 0.5, 0.5); |
|
|
|
|
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"); |
|
|
|
|
evas_object_smart_callback_add(em->thumb_browser, "clicked", _ephoto_thumb_clicked, NULL); |
|
|
|
|
elm_layout_content_set(em->layout, "ephoto.thumb.swallow", em->thumb_browser); |
|
|
|
|
|
|
|
|
|
toolbar = elm_toolbar_add(em->win); |
|
|
|
|
elm_toolbar_icon_size_set(toolbar, 24); |
|
|
|
|
elm_toolbar_homogenous_set(toolbar, EINA_TRUE); |
|
|
|
|
elm_toolbar_scrollable_set(toolbar, EINA_FALSE); |
|
|
|
|
|
|
|
|
|
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_layout_content_set(em->layout, "ephoto.toolbar.swallow", toolbar); |
|
|
|
|
|
|
|
|
|
o = elm_icon_add(em->win); |
|
|
|
|
tb->thbox = elm_box_add(tb->layout); |
|
|
|
|
elm_box_horizontal_set(tb->thbox, EINA_TRUE); |
|
|
|
|
evas_object_size_hint_weight_set(tb->thbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL); |
|
|
|
|
evas_object_size_hint_fill_set(tb->thbox, EVAS_HINT_FILL, EVAS_HINT_FILL); |
|
|
|
|
elm_layout_content_set(tb->layout, "ephoto.location.swallow", tb->thbox); |
|
|
|
|
|
|
|
|
|
tb->dir_label = elm_label_add(tb->thbox); |
|
|
|
|
elm_label_label_set(tb->dir_label, tb->current_directory); |
|
|
|
|
evas_object_size_hint_weight_set(tb->dir_label, EVAS_HINT_EXPAND, 0.0); |
|
|
|
|
evas_object_size_hint_align_set(tb->dir_label, 0.01, 0.5); |
|
|
|
|
elm_box_pack_end(tb->thbox, tb->dir_label); |
|
|
|
|
|
|
|
|
|
tb->thumb_slider = elm_slider_add(tb->thbox); |
|
|
|
|
elm_slider_label_set(tb->thumb_slider, "Thumb Size:"); |
|
|
|
|
elm_slider_span_size_set(tb->thumb_slider, 100); |
|
|
|
|
elm_slider_min_max_set(tb->thumb_slider, 0, 100); |
|
|
|
|
elm_slider_value_set(tb->thumb_slider, 50); |
|
|
|
|
elm_box_pack_end(tb->thbox, tb->thumb_slider); |
|
|
|
|
evas_object_smart_callback_add(tb->thumb_slider, "changed", |
|
|
|
|
_ephoto_slider_changed, tb); |
|
|
|
|
evas_object_show(tb->thumb_slider); |
|
|
|
|
evas_object_show(tb->dir_label); |
|
|
|
|
|
|
|
|
|
tb->thumb_browser = elm_gengrid_add(tb->layout); |
|
|
|
|
elm_gengrid_align_set(tb->thumb_browser, 0.5, 0.5); |
|
|
|
|
elm_gengrid_item_size_set(tb->thumb_browser, 256, 192); |
|
|
|
|
elm_gengrid_horizontal_set(tb->thumb_browser, EINA_TRUE); |
|
|
|
|
evas_object_size_hint_align_set(tb->thumb_browser, EVAS_HINT_FILL, EVAS_HINT_FILL); |
|
|
|
|
evas_object_size_hint_weight_set(tb->thumb_browser, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
|
|
|
|
evas_object_size_hint_fill_set(tb->thumb_browser, EVAS_HINT_FILL, EVAS_HINT_FILL); |
|
|
|
|
|
|
|
|
|
elm_object_style_set(tb->thumb_browser, "ephoto"); |
|
|
|
|
evas_object_smart_callback_add(tb->thumb_browser, "clicked", _ephoto_thumb_clicked, tb); |
|
|
|
|
elm_layout_content_set(tb->layout, "ephoto.thumb.swallow", tb->thumb_browser); |
|
|
|
|
|
|
|
|
|
tb->toolbar = elm_toolbar_add(tb->layout); |
|
|
|
|
elm_toolbar_icon_size_set(tb->toolbar, 24); |
|
|
|
|
elm_toolbar_homogenous_set(tb->toolbar, EINA_TRUE); |
|
|
|
|
elm_toolbar_scrollable_set(tb->toolbar, EINA_FALSE); |
|
|
|
|
|
|
|
|
|
evas_object_size_hint_weight_set(tb->toolbar, EVAS_HINT_EXPAND, 0.0); |
|
|
|
|
evas_object_size_hint_align_set(tb->toolbar, EVAS_HINT_FILL, 0.5); |
|
|
|
|
|
|
|
|
|
elm_layout_content_set(tb->layout, "ephoto.toolbar.swallow", tb->toolbar); |
|
|
|
|
|
|
|
|
|
o = elm_icon_add(tb->toolbar); |
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/change_directory.png", NULL); |
|
|
|
|
elm_toolbar_item_add(toolbar, o, "Change Directory", _ephoto_change_directory, NULL); |
|
|
|
|
elm_toolbar_item_add(tb->toolbar, o, "Change Directory", _ephoto_change_directory, tb); |
|
|
|
|
|
|
|
|
|
o = elm_icon_add(em->win); |
|
|
|
|
o = elm_icon_add(tb->toolbar); |
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/filter.png", NULL); |
|
|
|
|
elm_toolbar_item_add(toolbar, o, "Filter", NULL, NULL); |
|
|
|
|
elm_toolbar_item_add(tb->toolbar, o, "Filter", NULL, NULL); |
|
|
|
|
|
|
|
|
|
o = elm_icon_add(em->win); |
|
|
|
|
o = elm_icon_add(tb->toolbar); |
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/view_presentation.png", NULL); |
|
|
|
|
elm_toolbar_item_add(toolbar, o, "View Large", _ephoto_view_large, NULL); |
|
|
|
|
elm_toolbar_item_add(tb->toolbar, o, "View Large", _ephoto_view_large, tb); |
|
|
|
|
|
|
|
|
|
o = elm_icon_add(em->win); |
|
|
|
|
o = elm_icon_add(tb->toolbar); |
|
|
|
|
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/play_slideshow.png", NULL); |
|
|
|
|
elm_toolbar_item_add(toolbar, o, "Play Slideshow", _ephoto_view_slideshow, 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; |
|
|
|
|
elm_toolbar_item_add(tb->toolbar, o, "Play Slideshow", _ephoto_view_slideshow, tb); |
|
|
|
|
|
|
|
|
|
tb->cur_val = 50; |
|
|
|
|
|
|
|
|
|
tb->eg.item_style = "ephoto"; |
|
|
|
|
tb->eg.func.label_get = _ephoto_get_label; |
|
|
|
|
tb->eg.func.icon_get = _ephoto_get_icon; |
|
|
|
|
tb->eg.func.state_get = _ephoto_get_state; |
|
|
|
|
tb->eg.func.del = _ephoto_grid_del; |
|
|
|
|
|
|
|
|
|
evas_object_data_set(tb->layout, "thumb_browser", tb); |
|
|
|
|
evas_object_event_callback_add(tb->layout, EVAS_CALLBACK_DEL, _ephoto_del_cb, tb); |
|
|
|
|
evas_object_event_callback_add(tb->layout, EVAS_CALLBACK_SHOW, _ephoto_show_cb, tb); |
|
|
|
|
return tb->layout; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Show the thumbnail browser*/ |
|
|
|
|
void |
|
|
|
|
ephoto_show_thumb_browser(void) |
|
|
|
|
static void |
|
|
|
|
_ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
evas_object_show(toolbar); |
|
|
|
|
evas_object_show(em->thumb_browser); |
|
|
|
|
evas_object_show(dir_label); |
|
|
|
|
evas_object_show(thumb_slider); |
|
|
|
|
evas_object_show(thbox); |
|
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser"); |
|
|
|
|
|
|
|
|
|
if (current_directory) |
|
|
|
|
/* evas_object_show(tb->toolbar); */ |
|
|
|
|
/* evas_object_show(tb->thumb_browser); */ |
|
|
|
|
/* evas_object_show(tb->dir_label); */ |
|
|
|
|
/* evas_object_show(tb->thumb_slider); */ |
|
|
|
|
/* evas_object_show(tb->thbox); */ |
|
|
|
|
|
|
|
|
|
if (tb->current_directory) |
|
|
|
|
{ |
|
|
|
|
char *buffer; |
|
|
|
|
int length; |
|
|
|
|
|
|
|
|
|
length = strlen(current_directory) + strlen("Ephoto - ") + 1; |
|
|
|
|
length = strlen(tb->current_directory) + strlen("Ephoto - ") + 1; |
|
|
|
|
buffer = alloca(length); |
|
|
|
|
snprintf(buffer, length, "Ephoto - %s", current_directory); |
|
|
|
|
snprintf(buffer, length, "Ephoto - %s", tb->current_directory); |
|
|
|
|
elm_win_title_set(em->win, buffer); |
|
|
|
|
} else { |
|
|
|
|
elm_win_title_set(em->win, "Ephoto"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Hide the thumbnail browser*/ |
|
|
|
|
void |
|
|
|
|
ephoto_hide_thumb_browser(void) |
|
|
|
|
{ |
|
|
|
|
evas_object_hide(toolbar); |
|
|
|
|
evas_object_hide(em->thumb_browser); |
|
|
|
|
evas_object_hide(dir_label); |
|
|
|
|
evas_object_hide(thumb_slider); |
|
|
|
|
evas_object_hide(thbox); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Destroy the thumbnail browser*/ |
|
|
|
|
void |
|
|
|
|
ephoto_delete_thumb_browser(void) |
|
|
|
|
{ |
|
|
|
|
const Eina_List *items, *l, *iter; |
|
|
|
|
Elm_Gengrid_Item *item; |
|
|
|
|
Ephoto_Thumb_Data *etd; |
|
|
|
|
|
|
|
|
|
items = elm_toolbar_item_get_all(toolbar); |
|
|
|
|
while (items) |
|
|
|
|
{ |
|
|
|
|
evas_object_del(eina_list_data_get(items)); |
|
|
|
|
items = eina_list_next(items); |
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
eina_stringshare_del(current_directory); |
|
|
|
|
evas_object_del(toolbar); |
|
|
|
|
evas_object_del(em->thumb_browser); |
|
|
|
|
evas_object_del(dir_label); |
|
|
|
|
evas_object_del(thumb_slider); |
|
|
|
|
evas_object_del(thbox); |
|
|
|
|
ethumb_client_disconnect(ec); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Use ecore thread facility to avoid lock completly */ |
|
|
|
|
|
|
|
|
|
/* Check image type from another thread */ |
|
|
|
@ -208,16 +199,18 @@ _ephoto_populate_filter(const void *data, const char *file) |
|
|
|
|
static void |
|
|
|
|
_ephoto_populate_end(const void *data) |
|
|
|
|
{ |
|
|
|
|
list = NULL; |
|
|
|
|
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser *)data; |
|
|
|
|
|
|
|
|
|
efreet_mime_shutdown(); |
|
|
|
|
tb->list = NULL; |
|
|
|
|
efreet_mime_shutdown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_ephoto_populate_error(int error, const void *data) |
|
|
|
|
{ |
|
|
|
|
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data; |
|
|
|
|
/* We don't handle error case in ephoto */ |
|
|
|
|
list = NULL; |
|
|
|
|
tb->list = NULL; |
|
|
|
|
|
|
|
|
|
efreet_mime_shutdown(); |
|
|
|
|
} |
|
|
|
@ -226,39 +219,42 @@ _ephoto_populate_error(int error, const void *data) |
|
|
|
|
static void |
|
|
|
|
_ephoto_populate_main(const void *data, const char *file) |
|
|
|
|
{ |
|
|
|
|
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data; |
|
|
|
|
const char *thumb; |
|
|
|
|
|
|
|
|
|
file = eina_stringshare_ref(file); |
|
|
|
|
|
|
|
|
|
em->images = eina_list_append(em->images, file); |
|
|
|
|
ethumb_client_file_set(ec, file, NULL); |
|
|
|
|
if (!ethumb_client_thumb_exists(ec)) |
|
|
|
|
ethumb_client_file_set(tb->ec, file, NULL); |
|
|
|
|
if (!ethumb_client_thumb_exists(tb->ec)) |
|
|
|
|
{ |
|
|
|
|
ethumb_client_generate(ec, _ephoto_thumbnail_generated, NULL, NULL); |
|
|
|
|
ethumb_client_generate(tb->ec, _ephoto_thumbnail_generated, tb, NULL); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ethumb_client_thumb_path_get(ec, &thumb, NULL); |
|
|
|
|
_ephoto_thumbnail_generated(NULL, ec, 0, file, NULL, |
|
|
|
|
ethumb_client_thumb_path_get(tb->ec, &thumb, NULL); |
|
|
|
|
_ephoto_thumbnail_generated(tb, tb->ec, 0, file, NULL, |
|
|
|
|
thumb, NULL, EINA_TRUE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Start a thread to list images in a directory without locking the interface */ |
|
|
|
|
void |
|
|
|
|
ephoto_populate_thumbnails(void) |
|
|
|
|
ephoto_populate_thumbnails(Evas_Object *obj) |
|
|
|
|
{ |
|
|
|
|
if (!current_directory) return ; |
|
|
|
|
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser"); |
|
|
|
|
|
|
|
|
|
if (!tb->current_directory) return ; |
|
|
|
|
|
|
|
|
|
if (!efreet_mime_init()) |
|
|
|
|
fprintf(stderr, "Could not init efreet_mime!\n"); |
|
|
|
|
|
|
|
|
|
list = eio_file_ls(current_directory, |
|
|
|
|
tb->list = eio_file_ls(tb->current_directory, |
|
|
|
|
_ephoto_populate_filter, |
|
|
|
|
_ephoto_populate_main, |
|
|
|
|
_ephoto_populate_end, |
|
|
|
|
_ephoto_populate_error, |
|
|
|
|
NULL); |
|
|
|
|
tb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Change the thumbnail size*/ |
|
|
|
@ -266,32 +262,34 @@ static void |
|
|
|
|
_ephoto_slider_changed(void *data, Evas_Object *obj, void *event) |
|
|
|
|
{ |
|
|
|
|
int w, h, val; |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
|
|
|
|
|
val = elm_slider_value_get(thumb_slider); |
|
|
|
|
elm_gengrid_item_size_get(em->thumb_browser, &w, &h); |
|
|
|
|
if (val < cur_val) |
|
|
|
|
val = elm_slider_value_get(tb->thumb_slider); |
|
|
|
|
elm_gengrid_item_size_get(tb->thumb_browser, &w, &h); |
|
|
|
|
if (val < tb->cur_val) |
|
|
|
|
{ |
|
|
|
|
w -= cur_val-val; |
|
|
|
|
h -= cur_val-val; |
|
|
|
|
w -= tb->cur_val-val; |
|
|
|
|
h -= tb->cur_val-val; |
|
|
|
|
} |
|
|
|
|
else if (val > cur_val) |
|
|
|
|
else if (val > tb->cur_val) |
|
|
|
|
{ |
|
|
|
|
w += val-cur_val; |
|
|
|
|
h += val-cur_val; |
|
|
|
|
w += val-tb->cur_val; |
|
|
|
|
h += val-tb->cur_val; |
|
|
|
|
} |
|
|
|
|
elm_gengrid_item_size_set(em->thumb_browser, w, h); |
|
|
|
|
cur_val = val; |
|
|
|
|
elm_gengrid_item_size_set(tb->thumb_browser, w, h); |
|
|
|
|
tb->cur_val = val; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Callback when the client is connected*/ |
|
|
|
|
static void _ephoto_thumber_connected(void *data, Ethumb_Client *client, Eina_Bool success) |
|
|
|
|
{ |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
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(); |
|
|
|
|
ethumb_client_fdo_set(tb->ec, ETHUMB_THUMB_LARGE); |
|
|
|
|
ethumb_client_format_set(tb->ec, ETHUMB_THUMB_FDO); |
|
|
|
|
ethumb_client_aspect_set(tb->ec, ETHUMB_THUMB_KEEP_ASPECT); |
|
|
|
|
ephoto_populate_thumbnails(tb->layout); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -306,6 +304,7 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id, |
|
|
|
|
const char *thumb_path, const char *thumb_key,
|
|
|
|
|
Eina_Bool success) |
|
|
|
|
{ |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
if (success) |
|
|
|
|
{ |
|
|
|
|
Ephoto_Thumb_Data *etd; |
|
|
|
@ -314,7 +313,7 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id, |
|
|
|
|
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); |
|
|
|
|
elm_gengrid_item_append(tb->thumb_browser, &tb->eg, etd, NULL, NULL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -343,13 +342,13 @@ _ephoto_get_icon(const void *data, Evas_Object *obj, const char *part) |
|
|
|
|
|
|
|
|
|
if (!strcmp(part, "elm.swallow.icon")) |
|
|
|
|
{ |
|
|
|
|
thumb = elm_layout_add(em->win); |
|
|
|
|
thumb = elm_layout_add(obj); |
|
|
|
|
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); |
|
|
|
|
evas_object_show(thumb); |
|
|
|
|
|
|
|
|
|
o = elm_bg_add(em->win); |
|
|
|
|
o = elm_bg_add(thumb); |
|
|
|
|
elm_bg_file_set(o, etd->thumb_path, NULL); |
|
|
|
|
evas_object_resize(o, 176, 117); |
|
|
|
|
|
|
|
|
@ -382,9 +381,12 @@ _ephoto_thumb_clicked_job(void *data) |
|
|
|
|
const char *file; |
|
|
|
|
|
|
|
|
|
file = data; |
|
|
|
|
|
|
|
|
|
/* evas_object_smart_callback_call(ef->flow_browser, "selected", file); */ |
|
|
|
|
|
|
|
|
|
ephoto_hide_thumb_browser(); |
|
|
|
|
ephoto_show_flow_browser(file); |
|
|
|
|
/* em->flow_browser = ephoto_create_flow_browser(em->layout); */ |
|
|
|
|
/* ephoto_flow_browser_image_set(em->flow_browser, file); */ |
|
|
|
|
/* elm_layout_content_set(em->layout, "ephoto.content.swallow", em->flow_browser); */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Check to see if the thumbnail was double clicked*/ |
|
|
|
@ -394,18 +396,21 @@ _ephoto_thumb_clicked(void *data, Evas_Object *obj, void *event_info) |
|
|
|
|
const Eina_List *selected; |
|
|
|
|
Ephoto_Thumb_Data *etd; |
|
|
|
|
Evas_Object *o; |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
|
|
|
|
|
selected = elm_gengrid_selected_items_get(em->thumb_browser); |
|
|
|
|
selected = elm_gengrid_selected_items_get(tb->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); |
|
|
|
|
evas_object_smart_callback_call(tb->layout, "selected", etd->file); |
|
|
|
|
// ecore_job_add(_ephoto_thumb_clicked_job, etd->file);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*File Selector is shown*/ |
|
|
|
|
static void |
|
|
|
|
_ephoto_fileselector_shown(void *data, Evas *e, Evas_Object *obj, void *event_info) |
|
|
|
|
{ |
|
|
|
|
elm_fileselector_path_set(obj, current_directory); |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
elm_fileselector_path_set(obj, tb->current_directory); |
|
|
|
|
evas_render(em->e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -414,18 +419,16 @@ static void |
|
|
|
|
_ephoto_directory_chosen(void *data, Evas_Object *obj, void *event_info) |
|
|
|
|
{ |
|
|
|
|
const Eina_List *l, *iter; |
|
|
|
|
Evas_Object *win; |
|
|
|
|
Elm_Gengrid_Item *item; |
|
|
|
|
Ephoto_Thumb_Data *etd; |
|
|
|
|
const char *directory; |
|
|
|
|
|
|
|
|
|
win = (Evas_Object *)data; |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
|
|
|
|
|
directory = elm_fileselector_selected_get(obj); |
|
|
|
|
|
|
|
|
|
if ((directory) && (eina_stringshare_replace(¤t_directory, directory))) |
|
|
|
|
if ((directory) && (eina_stringshare_replace(&tb->current_directory, directory))) |
|
|
|
|
{ |
|
|
|
|
l = elm_gengrid_items_get(em->thumb_browser); |
|
|
|
|
l = elm_gengrid_items_get(tb->thumb_browser); |
|
|
|
|
EINA_LIST_FOREACH(l, iter, item) |
|
|
|
|
{ |
|
|
|
|
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get(item); |
|
|
|
@ -433,28 +436,28 @@ _ephoto_directory_chosen(void *data, Evas_Object *obj, void *event_info) |
|
|
|
|
eina_stringshare_del(etd->file); |
|
|
|
|
free(etd); |
|
|
|
|
} |
|
|
|
|
elm_gengrid_clear(em->thumb_browser); |
|
|
|
|
elm_gengrid_clear(tb->thumb_browser); |
|
|
|
|
eina_list_free(em->images); |
|
|
|
|
em->images = NULL; |
|
|
|
|
ephoto_populate_thumbnails(); |
|
|
|
|
elm_label_label_set(dir_label, current_directory); |
|
|
|
|
ephoto_populate_thumbnails(tb->layout); |
|
|
|
|
elm_label_label_set(tb->dir_label, tb->current_directory); |
|
|
|
|
|
|
|
|
|
if (current_directory) |
|
|
|
|
if (tb->current_directory) |
|
|
|
|
{ |
|
|
|
|
char *buffer; |
|
|
|
|
int length; |
|
|
|
|
|
|
|
|
|
length = strlen(current_directory) + strlen("Ephoto - ") + 1; |
|
|
|
|
length = strlen(tb->current_directory) + strlen("Ephoto - ") + 1; |
|
|
|
|
buffer = alloca(length); |
|
|
|
|
snprintf(buffer, length, "Ephoto - %s", current_directory); |
|
|
|
|
snprintf(buffer, length, "Ephoto - %s", tb->current_directory); |
|
|
|
|
elm_win_title_set(em->win, buffer); |
|
|
|
|
} else { |
|
|
|
|
elm_win_title_set(em->win, "Ephoto"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
evas_object_del(obj); |
|
|
|
|
evas_object_del(win); |
|
|
|
|
elm_toolbar_item_unselect_all(toolbar); |
|
|
|
|
|
|
|
|
|
evas_object_del(tb->fsel_win); |
|
|
|
|
elm_toolbar_item_unselect_all(tb->toolbar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Show the flow browser*/ |
|
|
|
@ -464,53 +467,83 @@ _ephoto_view_large(void *data, Evas_Object *obj, void *event_info) |
|
|
|
|
const Eina_List *selected; |
|
|
|
|
Evas_Object *o; |
|
|
|
|
Ephoto_Thumb_Data *etd; |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
|
|
|
|
|
ephoto_hide_thumb_browser(); |
|
|
|
|
|
|
|
|
|
selected = elm_gengrid_selected_items_get(em->thumb_browser); |
|
|
|
|
selected = elm_gengrid_selected_items_get(tb->thumb_browser); |
|
|
|
|
|
|
|
|
|
/* em->flow_browser = ephoto_create_flow_browser(em->layout); */ |
|
|
|
|
|
|
|
|
|
if (eina_list_data_get(selected)) |
|
|
|
|
{ |
|
|
|
|
o = eina_list_data_get(selected); |
|
|
|
|
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)o); |
|
|
|
|
ephoto_show_flow_browser(etd->file); |
|
|
|
|
/* _ephoto_thumb_clicked_job(etd->file); */ |
|
|
|
|
evas_object_smart_callback_call(tb->layout, "selected", etd->file); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ephoto_show_flow_browser(eina_list_data_get(em->images)); |
|
|
|
|
/* _ephoto_thumb_clicked_job( eina_list_data_get(em->images)); */ |
|
|
|
|
evas_object_smart_callback_call(tb->layout, "selected", eina_list_data_get(em->images)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
elm_toolbar_item_unselect_all(toolbar); |
|
|
|
|
|
|
|
|
|
elm_toolbar_item_unselect_all(tb->toolbar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*Change directory*/ |
|
|
|
|
static void |
|
|
|
|
_ephoto_change_directory(void *data, Evas_Object *obj, void *event_info) |
|
|
|
|
{ |
|
|
|
|
Evas_Object *win, *fsel; |
|
|
|
|
Evas_Object *fsel; |
|
|
|
|
Ephoto_Thumb_Browser *tb = data; |
|
|
|
|
|
|
|
|
|
win = elm_win_inwin_add(em->win); |
|
|
|
|
tb->fsel_win = elm_win_inwin_add(em->win); |
|
|
|
|
|
|
|
|
|
fsel = elm_fileselector_add(em->win); |
|
|
|
|
fsel = elm_fileselector_add(tb->fsel_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); |
|
|
|
|
elm_fileselector_path_set(fsel, tb->current_directory); |
|
|
|
|
evas_object_event_callback_add(fsel, EVAS_CALLBACK_SHOW, |
|
|
|
|
_ephoto_fileselector_shown, tb); |
|
|
|
|
evas_object_smart_callback_add(fsel, "done",
|
|
|