2010-07-01 11:49:22 -07:00
|
|
|
#include "ephoto.h"
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
int EPHOTO_EVENT_ENTRY_CREATE = 0;
|
2011-02-21 17:55:08 -08:00
|
|
|
int EPHOTO_EVENT_POPULATE_START = 0;
|
|
|
|
int EPHOTO_EVENT_POPULATE_END = 0;
|
|
|
|
int EPHOTO_EVENT_POPULATE_ERROR = 0;
|
2016-03-23 13:14:21 -07:00
|
|
|
int EPHOTO_EVENT_EDITOR_RESET = 0;
|
|
|
|
int EPHOTO_EVENT_EDITOR_APPLY = 0;
|
|
|
|
int EPHOTO_EVENT_EDITOR_CANCEL = 0;
|
2011-02-21 17:55:08 -08:00
|
|
|
|
|
|
|
typedef struct _Ephoto_Entry_Free_Listener Ephoto_Entry_Free_Listener;
|
|
|
|
struct _Ephoto_Entry_Free_Listener
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
void (*cb) (void *data, const Ephoto_Entry *dead);
|
2011-02-21 17:55:08 -08:00
|
|
|
const void *data;
|
|
|
|
};
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
typedef struct _Ephoto_Dir_Data Ephoto_Dir_Data;
|
|
|
|
struct _Ephoto_Dir_Data
|
|
|
|
{
|
|
|
|
Ephoto *ephoto;
|
2015-12-01 15:02:19 -08:00
|
|
|
Elm_Object_Item *expanded;
|
2015-11-24 14:21:21 -08:00
|
|
|
Eina_Bool dirs_only;
|
2015-12-01 15:02:19 -08:00
|
|
|
Eina_Bool thumbs_only;
|
2015-11-24 14:21:21 -08:00
|
|
|
};
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
|
|
|
_ephoto_state_set(Ephoto *ephoto, Ephoto_State state)
|
|
|
|
{
|
|
|
|
ephoto->prev_state = ephoto->state;
|
|
|
|
ephoto->state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|
|
|
{
|
|
|
|
ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
|
|
|
|
ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
|
2015-01-25 14:47:58 -08:00
|
|
|
elm_naviframe_item_promote(ephoto->tb);
|
2014-11-23 13:44:24 -08:00
|
|
|
elm_object_focus_set(ephoto->thumb_browser, EINA_TRUE);
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_state_set(ephoto, EPHOTO_STATE_THUMB);
|
2015-01-24 13:19:25 -08:00
|
|
|
ephoto_title_set(ephoto, ephoto->config->directory);
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_update_info_label(ephoto);
|
|
|
|
elm_box_clear(ephoto->controls_left);
|
|
|
|
elm_box_clear(ephoto->controls_right);
|
|
|
|
ephoto->blocking = EINA_FALSE;
|
|
|
|
ephoto->menu_blocking = EINA_FALSE;
|
|
|
|
ephoto->hover_blocking = EINA_FALSE;
|
|
|
|
ephoto->editor_blocking = EINA_FALSE;
|
|
|
|
ephoto_thumb_browser_show_controls(ephoto);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2012-03-08 22:22:03 -08:00
|
|
|
if ((entry) && (entry->item))
|
2016-01-25 17:53:44 -08:00
|
|
|
elm_gengrid_item_bring_in(entry->item, ELM_GENGRID_ITEM_SCROLLTO_IN);
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|
|
|
{
|
2015-12-02 18:45:35 -08:00
|
|
|
if (ephoto->selentries)
|
2016-01-20 07:56:10 -08:00
|
|
|
ephoto_single_browser_entries_set(ephoto->single_browser,
|
|
|
|
ephoto->selentries);
|
2016-01-01 15:04:25 -08:00
|
|
|
else if (ephoto->searchentries)
|
2016-01-20 07:56:10 -08:00
|
|
|
ephoto_single_browser_entries_set(ephoto->single_browser,
|
|
|
|
ephoto->searchentries);
|
2015-12-02 18:45:35 -08:00
|
|
|
else
|
2016-01-20 07:56:10 -08:00
|
|
|
ephoto_single_browser_entries_set(ephoto->single_browser,
|
|
|
|
ephoto->entries);
|
2016-01-01 15:04:25 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
ephoto_single_browser_entry_set(ephoto->single_browser, entry);
|
2012-03-27 00:49:29 -07:00
|
|
|
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->single_browser);
|
2014-11-23 13:44:24 -08:00
|
|
|
elm_object_focus_set(ephoto->single_browser, EINA_TRUE);
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_state_set(ephoto, EPHOTO_STATE_SINGLE);
|
2016-05-26 15:44:43 -07:00
|
|
|
|
|
|
|
elm_box_clear(ephoto->controls_left);
|
|
|
|
elm_box_clear(ephoto->controls_right);
|
|
|
|
ephoto->blocking = EINA_FALSE;
|
|
|
|
ephoto->menu_blocking = EINA_FALSE;
|
|
|
|
ephoto->hover_blocking = EINA_FALSE;
|
|
|
|
ephoto->editor_blocking = EINA_FALSE;
|
|
|
|
ephoto_single_browser_show_controls(ephoto);
|
|
|
|
ephoto_single_browser_adjust_offsets(ephoto);
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_slideshow_show_controls(ephoto);
|
|
|
|
|
2015-12-02 18:45:35 -08:00
|
|
|
if (ephoto->selentries)
|
|
|
|
ephoto_slideshow_entries_set(ephoto->slideshow, ephoto->selentries);
|
2016-01-01 15:04:25 -08:00
|
|
|
else if (ephoto->searchentries)
|
|
|
|
ephoto_slideshow_entries_set(ephoto->slideshow, ephoto->searchentries);
|
2015-12-02 18:45:35 -08:00
|
|
|
else
|
|
|
|
ephoto_slideshow_entries_set(ephoto->slideshow, ephoto->entries);
|
2011-06-28 15:26:16 -07:00
|
|
|
ephoto_slideshow_entry_set(ephoto->slideshow, entry);
|
2012-03-27 00:49:29 -07:00
|
|
|
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->slideshow);
|
2014-11-23 13:44:24 -08:00
|
|
|
elm_object_focus_set(ephoto->slideshow, EINA_TRUE);
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_state_set(ephoto, EPHOTO_STATE_SLIDESHOW);
|
2016-05-26 15:44:43 -07:00
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,controls,hide", "ephoto");
|
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,folders,hide", "ephoto");
|
|
|
|
ephoto->folders_toggle = EINA_FALSE;
|
|
|
|
ephoto->blocking = EINA_FALSE;
|
|
|
|
ephoto->menu_blocking = EINA_FALSE;
|
|
|
|
ephoto->hover_blocking = EINA_FALSE;
|
|
|
|
ephoto->editor_blocking = EINA_FALSE;
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_single_browser_back(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
2011-06-28 15:26:16 -07:00
|
|
|
Ephoto_Entry *entry = event_info;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2015-12-02 18:45:35 -08:00
|
|
|
ephoto->selentries = NULL;
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_thumb_browser_show(ephoto, entry);
|
|
|
|
}
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_slideshow_back(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Entry *entry = event_info;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
switch (ephoto->prev_state)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
case EPHOTO_STATE_SINGLE:
|
|
|
|
_ephoto_single_browser_show(ephoto, entry);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EPHOTO_STATE_THUMB:
|
2015-12-02 18:45:35 -08:00
|
|
|
ephoto->selentries = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_thumb_browser_show(ephoto, entry);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-12-02 18:45:35 -08:00
|
|
|
ephoto->selentries = NULL;
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_thumb_browser_show(ephoto, entry);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_thumb_browser_view(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Entry *entry = event_info;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_single_browser_show(ephoto, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_thumb_browser_changed_directory(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2015-12-02 18:45:35 -08:00
|
|
|
ephoto->selentries = NULL;
|
2011-06-28 15:26:16 -07:00
|
|
|
ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
|
|
|
|
ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_thumb_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Entry *entry = event_info;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_slideshow_show(ephoto, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_single_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2011-06-28 15:26:16 -07:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Ephoto_Entry *entry = event_info;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
_ephoto_slideshow_show(ephoto, entry);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
2016-03-25 13:45:18 -07:00
|
|
|
Ecore_Event_Handler *handler;
|
|
|
|
|
|
|
|
if (ephoto->file_idler)
|
|
|
|
ecore_idler_del(ephoto->file_idler);
|
|
|
|
if (ephoto->file_idler_pos)
|
|
|
|
eina_list_free(ephoto->file_idler_pos);
|
|
|
|
if (ephoto->upload_handlers)
|
|
|
|
EINA_LIST_FREE(ephoto->upload_handlers, handler)
|
|
|
|
ecore_event_handler_del(handler);
|
|
|
|
if (ephoto->url_up)
|
|
|
|
ecore_con_url_free(ephoto->url_up);
|
|
|
|
if (ephoto->url_ret)
|
|
|
|
free(ephoto->url_ret);
|
|
|
|
if (ephoto->upload_error)
|
|
|
|
free(ephoto->upload_error);
|
2016-01-19 11:58:28 -08:00
|
|
|
if (ephoto->top_directory)
|
|
|
|
eina_stringshare_del(ephoto->top_directory);
|
2015-11-24 14:21:21 -08:00
|
|
|
if (ephoto->timer.thumb_regen)
|
2016-01-19 11:58:28 -08:00
|
|
|
ecore_timer_del(ephoto->timer.thumb_regen);
|
|
|
|
if (ephoto->monitor)
|
2016-02-29 09:15:52 -08:00
|
|
|
ecore_file_monitor_del(ephoto->monitor);
|
2016-05-26 15:44:43 -07:00
|
|
|
if (ephoto->overlay_timer)
|
|
|
|
ecore_timer_del(ephoto->overlay_timer);
|
2014-11-18 19:18:22 -08:00
|
|
|
ephoto_config_save(ephoto);
|
2011-02-24 14:26:47 -08:00
|
|
|
free(ephoto);
|
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static void
|
|
|
|
_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Evas_Object *but = evas_object_data_get(ephoto->layout, "folder_button");
|
|
|
|
Evas_Coord x, y, w, h, bx, by, bw, bh, cx, cy;
|
|
|
|
|
2016-05-31 09:48:40 -07:00
|
|
|
if (eina_list_count(ephoto->entries) < 1)
|
|
|
|
return;
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_pointer_canvas_xy_get(evas_object_evas_get(ephoto->dir_browser), &cx, &cy);
|
|
|
|
evas_object_geometry_get(ephoto->dir_browser, &x, &y, &w, &h);
|
|
|
|
evas_object_geometry_get(but, &bx, &by, &bw, &bh);
|
|
|
|
|
|
|
|
if (cx >= x && cx <= x+w)
|
|
|
|
{
|
|
|
|
if (cy >= y && cy <= y+h)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cx >= bx && cx <= bx+bw)
|
|
|
|
{
|
|
|
|
if (cy >= by && cy <= by+bh)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,folders,hide", "ephoto");
|
|
|
|
ephoto->folders_toggle = EINA_FALSE;
|
|
|
|
elm_object_tooltip_text_set(but, _("Show Folders"));
|
|
|
|
}
|
|
|
|
|
2014-11-18 19:18:22 -08:00
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-11-18 19:18:22 -08:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
2016-04-08 09:49:40 -07:00
|
|
|
Evas_Coord w, h;
|
2014-11-18 19:18:22 -08:00
|
|
|
|
|
|
|
evas_object_geometry_get(ephoto->win, 0, 0, &w, &h);
|
|
|
|
if (w && h)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->config->window_width = w;
|
|
|
|
ephoto->config->window_height = h;
|
2014-11-18 19:18:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Edje_Object *edje = elm_layout_edje_get(ephoto->layout);
|
|
|
|
|
|
|
|
if (ephoto->blocking || ephoto->menu_blocking ||
|
|
|
|
ephoto->right_blocking || ephoto->hover_blocking ||
|
|
|
|
ephoto->editor_blocking)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
|
|
|
edje_object_signal_emit(edje, "ephoto,controls,hide", "ephoto");
|
|
|
|
if (ephoto->folders_toggle)
|
|
|
|
edje_object_signal_emit(edje, "ephoto,folders,hide", "ephoto");
|
|
|
|
ecore_timer_del(ephoto->overlay_timer);
|
|
|
|
ephoto->overlay_timer = NULL;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
2016-04-01 13:29:46 -07:00
|
|
|
static void
|
2016-05-26 15:44:43 -07:00
|
|
|
_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
Edje_Object *edje = elm_layout_edje_get(ephoto->layout);
|
|
|
|
|
|
|
|
if (ephoto->blocking || ephoto->menu_blocking ||
|
|
|
|
ephoto->right_blocking || ephoto->hover_blocking ||
|
|
|
|
ephoto->editor_blocking)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ephoto->overlay_timer)
|
|
|
|
ecore_timer_del(ephoto->overlay_timer);
|
|
|
|
ephoto->overlay_timer = NULL;
|
|
|
|
edje_object_signal_emit(edje, "ephoto,controls,show", "ephoto");
|
|
|
|
if (ephoto->folders_toggle)
|
|
|
|
edje_object_signal_emit(edje, "ephoto,folders,show", "ephoto");
|
|
|
|
ephoto->overlay_timer = ecore_timer_add(3.0, _timer_cb, ephoto);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_out_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
ephoto->blocking = EINA_FALSE;
|
2016-05-27 10:49:53 -07:00
|
|
|
|
|
|
|
if (ephoto->overlay_timer)
|
|
|
|
ecore_timer_del(ephoto->overlay_timer);
|
|
|
|
ephoto->overlay_timer = ecore_timer_add(3.0, _timer_cb, ephoto);
|
2016-05-26 15:44:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
ephoto->blocking = EINA_TRUE;
|
2016-05-27 10:49:53 -07:00
|
|
|
|
|
|
|
ecore_timer_del(ephoto->overlay_timer);
|
|
|
|
ephoto->overlay_timer = NULL;
|
2016-05-26 15:44:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_folder_icon_clicked(void *data, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
|
|
|
|
if (!ephoto->folders_toggle)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,folders,show", "ephoto");
|
|
|
|
ephoto->folders_toggle = EINA_TRUE;
|
2016-05-29 08:33:06 -07:00
|
|
|
if (elm_object_text_get(obj))
|
|
|
|
elm_object_text_set(obj, _("Hide Folders"));
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_tooltip_text_set(obj, _("Hide Folders"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,folders,hide", "ephoto");
|
|
|
|
ephoto->folders_toggle = EINA_FALSE;
|
2016-05-29 08:33:06 -07:00
|
|
|
if (elm_object_text_get(obj))
|
|
|
|
elm_object_text_set(obj, _("Show Folders"));
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_tooltip_text_set(obj, _("Show Folders"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Ephoto Thumb Browser Main Callbacks*/
|
|
|
|
static void
|
|
|
|
_slideshow_icon_clicked(void *data, Evas_Object *obj EINA_UNUSED,
|
2016-04-01 13:29:46 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
|
|
|
|
if (ephoto->state == EPHOTO_STATE_THUMB)
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_thumb_browser_slideshow(ephoto->thumb_browser);
|
2016-04-01 13:29:46 -07:00
|
|
|
else if (ephoto->state == EPHOTO_STATE_SINGLE)
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_single_browser_slideshow(ephoto->single_browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_settings_icon_clicked(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
|
|
|
|
ephoto_config_main(ephoto);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Toggle determines whether to toggle folder visibility, or just force visible*/
|
|
|
|
void
|
|
|
|
ephoto_show_folders(Ephoto *ephoto, Eina_Bool toggle)
|
|
|
|
{
|
|
|
|
Evas_Object *but = evas_object_data_get(ephoto->layout, "folder_button");
|
|
|
|
if (!ephoto->folders_toggle || !toggle)
|
|
|
|
{
|
|
|
|
_mouse_move_cb(ephoto, NULL, NULL, NULL);
|
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,folders,show", "ephoto");
|
|
|
|
ephoto->folders_toggle = EINA_TRUE;
|
|
|
|
elm_object_tooltip_text_set(but, _("Hide Folders"));
|
|
|
|
}
|
|
|
|
else if (ephoto->folders_toggle && toggle)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(elm_layout_edje_get(ephoto->layout),
|
|
|
|
"ephoto,folders,hide", "ephoto");
|
|
|
|
ephoto->folders_toggle = EINA_FALSE;
|
|
|
|
elm_object_tooltip_text_set(but, _("Show Folders"));
|
|
|
|
}
|
2016-04-01 13:29:46 -07:00
|
|
|
}
|
|
|
|
|
2010-10-09 18:13:53 -07:00
|
|
|
Evas_Object *
|
2011-02-21 17:55:08 -08:00
|
|
|
ephoto_window_add(const char *path)
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto *ephoto = calloc(1, sizeof(Ephoto));
|
2016-05-26 15:44:43 -07:00
|
|
|
Evas_Object *ic, *but;
|
2011-02-24 14:26:47 -08:00
|
|
|
char buf[PATH_MAX];
|
2016-05-29 08:33:06 -07:00
|
|
|
int ret;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ephoto, NULL);
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
EPHOTO_EVENT_ENTRY_CREATE = ecore_event_type_new();
|
2011-02-21 17:55:08 -08:00
|
|
|
EPHOTO_EVENT_POPULATE_START = ecore_event_type_new();
|
|
|
|
EPHOTO_EVENT_POPULATE_END = ecore_event_type_new();
|
|
|
|
EPHOTO_EVENT_POPULATE_ERROR = ecore_event_type_new();
|
2016-03-23 13:14:21 -07:00
|
|
|
EPHOTO_EVENT_EDITOR_RESET = ecore_event_type_new();
|
|
|
|
EPHOTO_EVENT_EDITOR_APPLY = ecore_event_type_new();
|
|
|
|
EPHOTO_EVENT_EDITOR_CANCEL = ecore_event_type_new();
|
2011-02-21 17:55:08 -08:00
|
|
|
|
2015-12-02 18:45:35 -08:00
|
|
|
ephoto->selentries = NULL;
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto->blocking = EINA_FALSE;
|
|
|
|
ephoto->menu_blocking = EINA_FALSE;
|
|
|
|
ephoto->hover_blocking = EINA_FALSE;
|
|
|
|
ephoto->folders_toggle = EINA_FALSE;
|
|
|
|
ephoto->editor_blocking = EINA_FALSE;
|
2015-02-22 11:46:54 -08:00
|
|
|
ephoto->win = elm_win_util_standard_add("ephoto", "Ephoto");
|
2010-10-09 18:13:53 -07:00
|
|
|
if (!ephoto->win)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
free(ephoto);
|
|
|
|
return NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_event_callback_add(ephoto->win, EVAS_CALLBACK_FREE,
|
|
|
|
_win_free, ephoto);
|
2016-01-20 07:56:10 -08:00
|
|
|
evas_object_event_callback_add(ephoto->win, EVAS_CALLBACK_RESIZE,
|
|
|
|
_resize_cb, ephoto);
|
2011-02-24 14:26:47 -08:00
|
|
|
elm_win_autodel_set(ephoto->win, EINA_TRUE);
|
|
|
|
|
|
|
|
if (!ephoto_config_init(ephoto))
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_del(ephoto->win);
|
|
|
|
return NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
if ((ephoto->config->thumb_gen_size != 128) &&
|
|
|
|
(ephoto->config->thumb_gen_size != 256) &&
|
|
|
|
(ephoto->config->thumb_gen_size != 512))
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto_thumb_size_set(ephoto, ephoto->config->thumb_size);
|
2010-10-09 18:13:53 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto->layout = elm_layout_add(ephoto->win);
|
|
|
|
elm_layout_file_set(ephoto->layout, PACKAGE_DATA_DIR "/themes/ephoto.edj",
|
|
|
|
"ephoto,main,layout");
|
|
|
|
evas_object_size_hint_weight_set(ephoto->layout, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(ephoto->layout, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
evas_object_event_callback_add(ephoto->layout, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_mouse_move_cb, ephoto);
|
|
|
|
evas_object_event_callback_add(ephoto->layout, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_mouse_up_cb, ephoto);
|
|
|
|
elm_win_resize_object_add(ephoto->win, ephoto->layout);
|
|
|
|
evas_object_show(ephoto->layout);
|
|
|
|
|
2012-03-27 00:49:29 -07:00
|
|
|
ephoto->pager = elm_naviframe_add(ephoto->win);
|
2016-04-01 13:29:46 -07:00
|
|
|
elm_object_focus_allow_set(ephoto->pager, EINA_FALSE);
|
2014-11-23 13:44:24 -08:00
|
|
|
elm_naviframe_prev_btn_auto_pushed_set(ephoto->pager, EINA_FALSE);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_size_hint_weight_set(ephoto->pager, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(ephoto->pager, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_layout_content_set(ephoto->layout, "ephoto.swallow.main", ephoto->pager);
|
2010-10-12 15:54:20 -07:00
|
|
|
evas_object_show(ephoto->pager);
|
2011-05-17 13:02:53 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto->thumb_browser = ephoto_thumb_browser_add(ephoto, ephoto->layout);
|
2011-05-17 13:02:53 -07:00
|
|
|
if (!ephoto->thumb_browser)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_del(ephoto->win);
|
|
|
|
return NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->tb =
|
|
|
|
elm_naviframe_item_push(ephoto->pager, NULL, NULL, NULL,
|
|
|
|
ephoto->thumb_browser, "overlap");
|
2015-01-25 14:47:58 -08:00
|
|
|
elm_naviframe_item_title_enabled_set(ephoto->tb, EINA_FALSE, EINA_FALSE);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_smart_callback_add(ephoto->thumb_browser, "view",
|
|
|
|
_ephoto_thumb_browser_view, ephoto);
|
|
|
|
evas_object_smart_callback_add(ephoto->thumb_browser, "changed,directory",
|
|
|
|
_ephoto_thumb_browser_changed_directory, ephoto);
|
|
|
|
evas_object_smart_callback_add(ephoto->thumb_browser, "slideshow",
|
|
|
|
_ephoto_thumb_browser_slideshow, ephoto);
|
2016-05-26 15:44:43 -07:00
|
|
|
|
|
|
|
ephoto->single_browser = ephoto_single_browser_add(ephoto, ephoto->layout);
|
2011-02-24 14:26:47 -08:00
|
|
|
if (!ephoto->single_browser)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_del(ephoto->win);
|
|
|
|
return NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->sb =
|
|
|
|
elm_naviframe_item_insert_after(ephoto->pager, ephoto->tb, NULL, NULL,
|
|
|
|
NULL, ephoto->single_browser, "overlap");
|
2015-01-25 14:47:58 -08:00
|
|
|
elm_naviframe_item_title_enabled_set(ephoto->sb, EINA_FALSE, EINA_FALSE);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_smart_callback_add(ephoto->single_browser, "back",
|
|
|
|
_ephoto_single_browser_back, ephoto);
|
|
|
|
evas_object_smart_callback_add(ephoto->single_browser, "slideshow",
|
|
|
|
_ephoto_single_browser_slideshow, ephoto);
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto->slideshow = ephoto_slideshow_add(ephoto, ephoto->layout);
|
2011-06-28 15:26:16 -07:00
|
|
|
if (!ephoto->slideshow)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_del(ephoto->win);
|
|
|
|
return NULL;
|
2011-06-28 15:26:16 -07:00
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->sl =
|
|
|
|
elm_naviframe_item_insert_after(ephoto->pager, ephoto->sb, NULL, NULL,
|
|
|
|
NULL, ephoto->slideshow, "overlap");
|
2015-01-25 14:47:58 -08:00
|
|
|
elm_naviframe_item_title_enabled_set(ephoto->sl, EINA_FALSE, EINA_FALSE);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_smart_callback_add(ephoto->slideshow, "back",
|
|
|
|
_ephoto_slideshow_back, ephoto);
|
2010-10-12 16:46:36 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto->dir_browser = ephoto_directory_browser_add(ephoto, ephoto->layout);
|
|
|
|
elm_layout_content_set(ephoto->layout, "ephoto.swallow.folders",
|
|
|
|
ephoto->dir_browser);
|
|
|
|
evas_object_event_callback_add(ephoto->dir_browser, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_mouse_in_cb, ephoto);
|
|
|
|
evas_object_event_callback_add(ephoto->dir_browser, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_mouse_out_cb, ephoto);
|
|
|
|
evas_object_show(ephoto->dir_browser);
|
|
|
|
|
|
|
|
ephoto->statusbar = elm_box_add(ephoto->layout);
|
|
|
|
elm_object_tree_focus_allow_set(ephoto->statusbar, EINA_FALSE);
|
|
|
|
elm_box_horizontal_set(ephoto->statusbar, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(ephoto->statusbar,
|
|
|
|
EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(ephoto->statusbar, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
elm_layout_content_set(ephoto->layout, "ephoto.swallow.controls",
|
|
|
|
ephoto->statusbar);
|
|
|
|
evas_object_event_callback_add(ephoto->statusbar, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_mouse_in_cb, ephoto);
|
|
|
|
evas_object_event_callback_add(ephoto->statusbar, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_mouse_out_cb, ephoto);
|
|
|
|
evas_object_show(ephoto->statusbar);
|
|
|
|
|
|
|
|
ic = elm_icon_add(ephoto->statusbar);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
2016-05-29 08:33:06 -07:00
|
|
|
ret = elm_icon_standard_set(ic, "folder");
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2016-05-29 08:33:06 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
but = elm_button_add(ephoto->statusbar);
|
|
|
|
elm_object_part_content_set(but, "icon", ic);
|
2016-05-29 08:33:06 -07:00
|
|
|
if (!ret)
|
|
|
|
elm_object_text_set(but, _("Show Folders"));
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_smart_callback_add(but, "clicked", _folder_icon_clicked, ephoto);
|
|
|
|
elm_object_tooltip_text_set(but, _("Show Folders"));
|
|
|
|
elm_object_tooltip_orient_set(but, ELM_TOOLTIP_ORIENT_RIGHT);
|
|
|
|
elm_box_pack_end(ephoto->statusbar, but);
|
|
|
|
evas_object_show(but);
|
|
|
|
evas_object_data_set(ephoto->layout, "folder_button", but);
|
|
|
|
|
|
|
|
ephoto->controls_left = elm_box_add(ephoto->statusbar);
|
|
|
|
elm_box_horizontal_set(ephoto->controls_left, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(ephoto->controls_left,
|
|
|
|
0.0, 0.0);
|
|
|
|
evas_object_size_hint_align_set(ephoto->controls_left, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(ephoto->statusbar, ephoto->controls_left);
|
|
|
|
evas_object_show(ephoto->controls_left);
|
|
|
|
|
|
|
|
ephoto->infolabel = elm_label_add(ephoto->statusbar);
|
|
|
|
elm_object_style_set(ephoto->infolabel, "info");
|
|
|
|
elm_label_line_wrap_set(ephoto->infolabel, ELM_WRAP_MIXED);
|
|
|
|
elm_object_text_set(ephoto->infolabel, _("Information"));
|
|
|
|
evas_object_size_hint_weight_set(ephoto->infolabel,
|
|
|
|
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(ephoto->infolabel, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_aspect_set(ephoto->infolabel, EVAS_ASPECT_CONTROL_HORIZONTAL,
|
|
|
|
1, 1);
|
|
|
|
elm_box_pack_end(ephoto->statusbar, ephoto->infolabel);
|
|
|
|
evas_object_show(ephoto->infolabel);
|
|
|
|
|
|
|
|
ephoto->controls_right = elm_box_add(ephoto->statusbar);
|
|
|
|
elm_box_horizontal_set(ephoto->controls_right, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(ephoto->controls_right,
|
|
|
|
0.0, 0.0);
|
|
|
|
evas_object_size_hint_align_set(ephoto->controls_right, EVAS_HINT_FILL,
|
|
|
|
EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(ephoto->statusbar, ephoto->controls_right);
|
|
|
|
evas_object_show(ephoto->controls_right);
|
|
|
|
|
|
|
|
ic = elm_icon_add(ephoto->statusbar);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
2016-05-29 08:33:06 -07:00
|
|
|
ret = elm_icon_standard_set(ic, "media-playback-start");
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2016-05-29 08:33:06 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
but = elm_button_add(ephoto->statusbar);
|
|
|
|
elm_object_part_content_set(but, "icon", ic);
|
2016-05-29 08:33:06 -07:00
|
|
|
if (!ret)
|
|
|
|
elm_object_text_set(but, _("Slideshow"));
|
|
|
|
evas_object_smart_callback_add(but, "clicked",
|
|
|
|
_slideshow_icon_clicked, ephoto);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_tooltip_text_set(but, _("Slideshow"));
|
|
|
|
elm_object_tooltip_orient_set(but, ELM_TOOLTIP_ORIENT_TOP);
|
|
|
|
elm_box_pack_end(ephoto->statusbar, but);
|
|
|
|
evas_object_show(but);
|
|
|
|
|
|
|
|
ic = elm_icon_add(ephoto->statusbar);
|
|
|
|
evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),
|
|
|
|
20*elm_config_scale_get());
|
2016-05-29 08:33:06 -07:00
|
|
|
ret = elm_icon_standard_set(ic, "preferences-other");
|
2016-05-26 15:44:43 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
2016-05-29 08:33:06 -07:00
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
but = elm_button_add(ephoto->statusbar);
|
|
|
|
elm_object_part_content_set(but, "icon", ic);
|
2016-05-29 08:33:06 -07:00
|
|
|
if (!ret)
|
|
|
|
elm_object_text_set(but, _("Settings"));
|
|
|
|
evas_object_smart_callback_add(but, "clicked",
|
|
|
|
_settings_icon_clicked, ephoto);
|
2016-05-26 15:44:43 -07:00
|
|
|
elm_object_tooltip_text_set(but, _("Settings"));
|
|
|
|
elm_object_tooltip_orient_set(but, ELM_TOOLTIP_ORIENT_LEFT);
|
|
|
|
elm_box_pack_end(ephoto->statusbar, but);
|
|
|
|
evas_object_show(but);
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
if ((!path) || (!ecore_file_exists(path)))
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
if (ephoto->config->open)
|
|
|
|
{
|
|
|
|
if (!strcmp(ephoto->config->open, "Last"))
|
|
|
|
path = ephoto->config->directory;
|
|
|
|
else
|
|
|
|
path = ephoto->config->open;
|
|
|
|
if ((path) && (!ecore_file_exists(path)))
|
|
|
|
path = NULL;
|
|
|
|
}
|
2015-11-03 06:07:32 -08:00
|
|
|
else if (!ephoto->config->open || path)
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
if (getcwd(buf, sizeof(buf)))
|
|
|
|
path = buf;
|
|
|
|
else
|
|
|
|
path = getenv("HOME");
|
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
if (ecore_file_is_dir(path))
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2016-05-26 15:44:43 -07:00
|
|
|
eina_stringshare_replace(&ephoto->config->directory,
|
|
|
|
ecore_file_realpath(path));
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_thumb_browser_show(ephoto, NULL);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
else
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
char *dir = ecore_file_dir_get(path);
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
eina_stringshare_replace(&ephoto->config->directory,
|
|
|
|
ecore_file_realpath(dir));
|
2015-11-24 14:21:21 -08:00
|
|
|
free(dir);
|
|
|
|
ephoto_single_browser_path_pending_set(ephoto->single_browser, path);
|
|
|
|
|
|
|
|
elm_naviframe_item_simple_promote(ephoto->pager,
|
|
|
|
ephoto->single_browser);
|
2016-05-26 18:04:56 -07:00
|
|
|
ephoto_single_browser_show_controls(ephoto);
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->state = EPHOTO_STATE_SINGLE;
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto_directory_browser_top_dir_set(ephoto, ephoto->config->directory);
|
|
|
|
ephoto_directory_browser_initialize_structure(ephoto);
|
2015-11-24 14:21:21 -08:00
|
|
|
evas_object_resize(ephoto->win, ephoto->config->window_width,
|
|
|
|
ephoto->config->window_height);
|
2011-02-24 14:26:47 -08:00
|
|
|
evas_object_show(ephoto->win);
|
|
|
|
|
2016-05-26 15:44:43 -07:00
|
|
|
ephoto->overlay_timer = ecore_timer_add(5.0, _timer_cb, ephoto);
|
|
|
|
|
2010-10-09 18:13:53 -07:00
|
|
|
return ephoto->win;
|
|
|
|
}
|
|
|
|
|
2011-02-10 15:41:02 -08:00
|
|
|
void
|
2011-02-24 14:26:47 -08:00
|
|
|
ephoto_title_set(Ephoto *ephoto, const char *title)
|
2011-02-10 15:41:02 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
char buf[1024] = "Ephoto";
|
|
|
|
|
2015-02-20 08:07:50 -08:00
|
|
|
if (title)
|
2014-11-19 08:50:35 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
snprintf(buf, sizeof(buf), "Ephoto - %s", title);
|
|
|
|
elm_win_title_set(ephoto->win, buf);
|
2014-11-19 08:50:35 -08:00
|
|
|
}
|
|
|
|
else
|
2015-11-24 14:21:21 -08:00
|
|
|
elm_win_title_set(ephoto->win, "Ephoto");
|
2011-02-10 15:41:02 -08:00
|
|
|
}
|
|
|
|
|
2014-11-18 13:35:24 -08:00
|
|
|
int
|
|
|
|
ephoto_entries_cmp(const void *pa, const void *pb)
|
|
|
|
{
|
|
|
|
const Ephoto_Entry *a = pa, *b = pb;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2014-11-18 13:35:24 -08:00
|
|
|
return strcoll(a->basename, b->basename);
|
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED,
|
|
|
|
const Eina_File_Direct_Info *info)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Dir_Data *ed = data;
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Entry *e;
|
|
|
|
Ephoto_Event_Entry_Create *ev;
|
|
|
|
|
2016-03-15 14:45:20 -07:00
|
|
|
if (ephoto_entry_exists(ed->ephoto, info->path))
|
|
|
|
return;
|
2015-11-24 14:21:21 -08:00
|
|
|
e = ephoto_entry_new(ed->ephoto, info->path, info->path + info->name_start,
|
|
|
|
info->type);
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2015-01-24 16:37:43 -08:00
|
|
|
if (e->is_dir)
|
2016-01-19 11:58:28 -08:00
|
|
|
e->parent = ed->expanded;
|
2014-11-18 13:35:24 -08:00
|
|
|
else
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
if (!ed->ephoto->entries)
|
|
|
|
ed->ephoto->entries = eina_list_append(ed->ephoto->entries, e);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int near_cmp;
|
|
|
|
Eina_List *near_node =
|
|
|
|
eina_list_search_sorted_near_list(ed->ephoto->entries,
|
|
|
|
ephoto_entries_cmp, e, &near_cmp);
|
|
|
|
|
|
|
|
if (near_cmp < 0)
|
|
|
|
ed->ephoto->entries =
|
|
|
|
eina_list_append_relative_list(ed->ephoto->entries, e,
|
|
|
|
near_node);
|
|
|
|
else
|
|
|
|
ed->ephoto->entries =
|
|
|
|
eina_list_prepend_relative_list(ed->ephoto->entries, e,
|
|
|
|
near_node);
|
|
|
|
}
|
|
|
|
e->parent = NULL;
|
2014-11-18 13:35:24 -08:00
|
|
|
}
|
2011-06-28 15:26:16 -07:00
|
|
|
ev = calloc(1, sizeof(Ephoto_Event_Entry_Create));
|
|
|
|
ev->entry = e;
|
|
|
|
|
|
|
|
ecore_event_add(EPHOTO_EVENT_ENTRY_CREATE, ev, NULL, NULL);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_populate_filter(void *data, Eio_File *handler EINA_UNUSED,
|
|
|
|
const Eina_File_Direct_Info *info)
|
2010-11-13 17:51:16 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Dir_Data *ed = data;
|
2011-02-24 14:26:47 -08:00
|
|
|
const char *bname = info->path + info->name_start;
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
if (bname[0] == '.')
|
|
|
|
return EINA_FALSE;
|
2016-01-19 11:58:28 -08:00
|
|
|
if (info->type == EINA_FILE_DIR && !ed->thumbs_only)
|
2015-12-01 15:02:19 -08:00
|
|
|
{
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
if (!ed->dirs_only)
|
|
|
|
return _ephoto_eina_file_direct_info_image_useful(info);
|
|
|
|
else
|
|
|
|
return EINA_FALSE;
|
2010-11-13 17:51:16 -08:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
static void
|
2015-01-18 14:47:32 -08:00
|
|
|
_ephoto_populate_end(void *data, Eio_File *handler EINA_UNUSED)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Dir_Data *ed = data;
|
|
|
|
|
|
|
|
ed->ephoto->ls = NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2015-12-29 07:21:12 -08:00
|
|
|
ephoto_single_browser_entries_set(ed->ephoto->single_browser,
|
|
|
|
ed->ephoto->entries);
|
2011-02-24 14:26:47 -08:00
|
|
|
ecore_event_add(EPHOTO_EVENT_POPULATE_END, NULL, NULL, NULL);
|
2015-11-24 14:21:21 -08:00
|
|
|
free(ed);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_populate_error(void *data, Eio_File *handler, int error EINA_UNUSED)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Dir_Data *ed = data;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
ecore_event_add(EPHOTO_EVENT_POPULATE_ERROR, NULL, NULL, NULL);
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_populate_end(ed->ephoto, handler);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_ephoto_populate_entries(Ephoto_Dir_Data *ed)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Entry *entry;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2016-01-19 11:58:28 -08:00
|
|
|
if (ed->thumbs_only)
|
2015-12-02 17:11:29 -08:00
|
|
|
EINA_LIST_FREE(ed->ephoto->entries, entry)
|
|
|
|
ephoto_entry_free(entry->ephoto, entry);
|
2016-01-20 07:21:27 -08:00
|
|
|
else if (!ed->dirs_only)
|
2015-12-01 15:02:19 -08:00
|
|
|
ephoto_entries_free(ed->ephoto);
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
ed->ephoto->ls =
|
|
|
|
eio_file_stat_ls(ed->ephoto->config->directory, _ephoto_populate_filter,
|
2016-01-20 07:56:10 -08:00
|
|
|
_ephoto_populate_main, _ephoto_populate_end, _ephoto_populate_error,
|
|
|
|
ed);
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
ecore_event_add(EPHOTO_EVENT_POPULATE_START, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ephoto_change_dir(void *data)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Dir_Data *ed = data;
|
|
|
|
|
|
|
|
ed->ephoto->job.change_dir = NULL;
|
|
|
|
_ephoto_populate_entries(ed);
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
2016-02-29 09:15:52 -08:00
|
|
|
static void
|
|
|
|
_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
|
|
|
|
Ecore_File_Event event, const char *path)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
2016-01-20 07:15:39 -08:00
|
|
|
char file[PATH_MAX], dir[PATH_MAX];
|
2016-01-19 13:10:37 -08:00
|
|
|
|
2016-02-29 09:15:52 -08:00
|
|
|
snprintf(file, PATH_MAX, "%s", path);
|
2016-01-20 14:46:49 -08:00
|
|
|
snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
|
2016-02-25 14:43:14 -08:00
|
|
|
|
2016-01-20 07:15:39 -08:00
|
|
|
if (strcmp(ephoto->config->directory, dir))
|
2016-02-29 09:15:52 -08:00
|
|
|
return;
|
2016-01-19 11:58:28 -08:00
|
|
|
|
2016-02-29 09:15:52 -08:00
|
|
|
if (evas_object_image_extension_can_load_get(path))
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
if (event == ECORE_FILE_EVENT_CREATED_FILE)
|
2016-03-15 14:45:20 -07:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
Ephoto_Entry *entry;
|
|
|
|
char buf[PATH_MAX];
|
2016-01-19 11:58:28 -08:00
|
|
|
|
2016-03-15 14:45:20 -07:00
|
|
|
if (ephoto_entry_exists(ephoto, path))
|
|
|
|
return;
|
2016-02-29 09:15:52 -08:00
|
|
|
snprintf(buf, PATH_MAX, "%s", path);
|
|
|
|
entry = ephoto_entry_new(ephoto, path, basename(buf),
|
|
|
|
EINA_FILE_REG);
|
|
|
|
ephoto_single_browser_path_created(ephoto->single_browser, entry);
|
|
|
|
if (!ephoto->entries)
|
|
|
|
{
|
|
|
|
ephoto->entries = eina_list_append(ephoto->entries, entry);
|
|
|
|
}
|
2016-01-19 11:58:28 -08:00
|
|
|
else
|
2016-02-29 09:15:52 -08:00
|
|
|
{
|
|
|
|
int near_cmp;
|
|
|
|
Eina_List *near_node =
|
|
|
|
eina_list_search_sorted_near_list(ephoto->entries,
|
|
|
|
ephoto_entries_cmp, entry, &near_cmp);
|
|
|
|
|
|
|
|
if (near_cmp < 0)
|
|
|
|
ephoto->entries =
|
|
|
|
eina_list_append_relative_list(ephoto->entries, entry,
|
|
|
|
near_node);
|
|
|
|
else
|
|
|
|
ephoto->entries =
|
|
|
|
eina_list_prepend_relative_list(ephoto->entries, entry,
|
|
|
|
near_node);
|
|
|
|
}
|
|
|
|
ephoto_thumb_browser_insert(ephoto, entry);
|
|
|
|
return;
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
2016-02-29 09:15:52 -08:00
|
|
|
else if (event == ECORE_FILE_EVENT_DELETED_FILE)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ephoto->entries, l, entry)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
if (!strcmp(entry->path, path))
|
|
|
|
{
|
|
|
|
ephoto_thumb_browser_remove(ephoto, entry);
|
|
|
|
ephoto_entry_free(ephoto, entry);
|
|
|
|
break;
|
|
|
|
}
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
2016-02-29 09:15:52 -08:00
|
|
|
return;
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
2016-02-29 09:15:52 -08:00
|
|
|
else if (event == ECORE_FILE_EVENT_MODIFIED)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ephoto->entries, l, entry)
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
if (!strcmp(entry->path, path))
|
2016-01-19 11:58:28 -08:00
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
if (!ecore_file_exists(entry->path))
|
|
|
|
{
|
|
|
|
elm_object_item_del(entry->item);
|
|
|
|
ephoto_entry_free(ephoto, entry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!entry->item)
|
|
|
|
ephoto_thumb_browser_insert(ephoto, entry);
|
|
|
|
else
|
|
|
|
ephoto_thumb_browser_update(ephoto, entry);
|
|
|
|
}
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
2016-03-15 14:45:20 -07:00
|
|
|
|
|
|
|
if (ephoto_entry_exists(ephoto, path))
|
|
|
|
return;
|
2016-02-29 09:15:52 -08:00
|
|
|
snprintf(buf, PATH_MAX, "%s", path);
|
|
|
|
entry = ephoto_entry_new(ephoto, path, basename(buf),
|
|
|
|
EINA_FILE_REG);
|
|
|
|
ephoto_single_browser_path_created(ephoto->single_browser, entry);
|
|
|
|
if (!ephoto->entries)
|
|
|
|
{
|
|
|
|
ephoto->entries = eina_list_append(ephoto->entries, entry);
|
2016-01-20 07:15:39 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-29 09:15:52 -08:00
|
|
|
int near_cmp;
|
|
|
|
Eina_List *near_node =
|
|
|
|
eina_list_search_sorted_near_list(ephoto->entries,
|
|
|
|
ephoto_entries_cmp, entry, &near_cmp);
|
|
|
|
|
|
|
|
if (near_cmp < 0)
|
|
|
|
ephoto->entries =
|
|
|
|
eina_list_append_relative_list(ephoto->entries, entry,
|
|
|
|
near_node);
|
2016-02-25 14:43:14 -08:00
|
|
|
else
|
2016-02-29 09:15:52 -08:00
|
|
|
ephoto->entries =
|
|
|
|
eina_list_prepend_relative_list(ephoto->entries, entry,
|
|
|
|
near_node);
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
2016-02-29 09:15:52 -08:00
|
|
|
ephoto_thumb_browser_insert(ephoto, entry);
|
|
|
|
return;
|
2016-01-19 11:58:28 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
void
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
|
2015-12-01 15:02:19 -08:00
|
|
|
Eina_Bool dirs_only, Eina_Bool thumbs_only)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
Ephoto_Dir_Data *ed;
|
|
|
|
|
|
|
|
ed = malloc(sizeof(Ephoto_Dir_Data));
|
|
|
|
ed->ephoto = ephoto;
|
|
|
|
ed->expanded = expanded;
|
|
|
|
ed->dirs_only = dirs_only;
|
2015-12-01 15:02:19 -08:00
|
|
|
ed->thumbs_only = thumbs_only;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2016-04-08 09:49:40 -07:00
|
|
|
if (!ecore_file_can_read(path))
|
|
|
|
return;
|
|
|
|
|
2014-11-19 08:50:35 -08:00
|
|
|
ephoto_title_set(ephoto, NULL);
|
2016-01-20 07:56:10 -08:00
|
|
|
eina_stringshare_replace(&ephoto->config->directory,
|
|
|
|
ecore_file_realpath(path));
|
2015-11-24 14:21:21 -08:00
|
|
|
|
|
|
|
if (ed->ephoto->job.change_dir)
|
|
|
|
ecore_job_del(ed->ephoto->job.change_dir);
|
|
|
|
ed->ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ed);
|
2016-01-19 11:58:28 -08:00
|
|
|
if (ephoto->monitor)
|
2016-02-29 09:15:52 -08:00
|
|
|
ecore_file_monitor_del(ephoto->monitor);
|
|
|
|
ephoto->monitor = ecore_file_monitor_add(path, _monitor_cb, ephoto);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_thumb_gen_size_changed_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
const Eina_List *l;
|
|
|
|
Evas_Object *o;
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
if (ephoto->config->thumb_gen_size == ephoto->thumb_gen_size)
|
|
|
|
goto end;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
ephoto->config->thumb_gen_size = ephoto->thumb_gen_size;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ephoto->thumbs, l, o)
|
|
|
|
{
|
2016-03-24 10:16:05 -07:00
|
|
|
e_thumb_icon_size_set(o, ephoto->thumb_gen_size,
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->thumb_gen_size);
|
2016-03-24 10:16:05 -07:00
|
|
|
e_thumb_icon_rethumb(o);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
end:
|
2011-02-24 14:26:47 -08:00
|
|
|
ephoto->timer.thumb_regen = NULL;
|
|
|
|
return EINA_FALSE;
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-02-24 14:26:47 -08:00
|
|
|
ephoto_thumb_size_set(Ephoto *ephoto, int size)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
if (ephoto->config->thumb_size != size)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->config->thumb_size = size;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
if (size <= 128)
|
|
|
|
ephoto->thumb_gen_size = 128;
|
|
|
|
else if (size <= 256)
|
|
|
|
ephoto->thumb_gen_size = 256;
|
|
|
|
else
|
|
|
|
ephoto->thumb_gen_size = 512;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2015-11-24 14:21:21 -08:00
|
|
|
if (ephoto->timer.thumb_regen)
|
|
|
|
ecore_timer_del(ephoto->timer.thumb_regen);
|
|
|
|
ephoto->timer.thumb_regen =
|
|
|
|
ecore_timer_add(0.1, _thumb_gen_size_changed_timer_cb, ephoto);
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-24 14:21:21 -08:00
|
|
|
_thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
Ephoto *ephoto = data;
|
|
|
|
|
2016-03-24 10:16:05 -07:00
|
|
|
e_thumb_icon_end(obj);
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto->thumbs = eina_list_remove(ephoto->thumbs, obj);
|
2015-01-06 11:34:18 -08:00
|
|
|
}
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
Evas_Object *
|
|
|
|
ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
|
2011-06-30 09:04:18 -07:00
|
|
|
if (path)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
const char *ext = strrchr(path, '.');
|
|
|
|
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
ext++;
|
|
|
|
if ((strcasecmp(ext, "edj") == 0))
|
2016-03-24 10:16:05 -07:00
|
|
|
{
|
|
|
|
o = elm_icon_add(parent);
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
else
|
2016-03-24 10:16:05 -07:00
|
|
|
{
|
|
|
|
o = e_thumb_icon_add(parent);
|
|
|
|
e_thumb_icon_file_set(o, path, NULL);
|
|
|
|
e_thumb_icon_size_set(o, ephoto->thumb_gen_size,
|
|
|
|
ephoto->thumb_gen_size);
|
|
|
|
e_thumb_icon_begin(o);
|
|
|
|
}
|
2015-11-24 14:21:21 -08:00
|
|
|
}
|
2011-06-30 09:04:18 -07:00
|
|
|
else
|
2016-03-24 10:16:05 -07:00
|
|
|
{
|
|
|
|
o = e_thumb_icon_add(parent);
|
|
|
|
e_thumb_icon_file_set(o, path, NULL);
|
|
|
|
e_thumb_icon_size_set(o, ephoto->thumb_gen_size,
|
|
|
|
ephoto->thumb_gen_size);
|
|
|
|
e_thumb_icon_begin(o);
|
|
|
|
}
|
2011-06-30 09:04:18 -07:00
|
|
|
}
|
|
|
|
else
|
2016-03-24 10:16:05 -07:00
|
|
|
o = e_thumb_icon_add(parent);
|
2015-11-24 14:21:21 -08:00
|
|
|
if (!o)
|
|
|
|
return NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
ephoto->thumbs = eina_list_append(ephoto->thumbs, o);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, ephoto);
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
return o;
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-02-20 08:07:50 -08:00
|
|
|
ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
2011-06-30 09:04:18 -07:00
|
|
|
const char *group = NULL;
|
2011-02-24 14:26:47 -08:00
|
|
|
const char *ext = strrchr(path, '.');
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
if (ext)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
ext++;
|
2016-03-24 10:16:05 -07:00
|
|
|
if ((strcasecmp(ext, "edj") == 0))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
if (edje_file_group_exists(path, "e/desktop/background"))
|
|
|
|
group = "e/desktop/background";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_List *g = edje_file_collection_list(path);
|
|
|
|
|
|
|
|
group = eina_list_data_get(g);
|
|
|
|
edje_file_collection_list_free(g);
|
|
|
|
}
|
|
|
|
elm_image_file_set(obj, path, group);
|
|
|
|
return;
|
|
|
|
}
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
2016-03-24 10:16:05 -07:00
|
|
|
e_thumb_icon_file_set(obj, path, group);
|
|
|
|
e_thumb_icon_begin(obj);
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Ephoto_Entry *
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label,
|
|
|
|
Eina_File_Type type)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
|
|
|
Ephoto_Entry *entry;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
entry = calloc(1, sizeof(Ephoto_Entry));
|
2011-02-24 14:26:47 -08:00
|
|
|
entry->ephoto = ephoto;
|
2011-02-21 17:55:08 -08:00
|
|
|
entry->path = eina_stringshare_add(path);
|
|
|
|
entry->basename = ecore_file_file_get(entry->path);
|
|
|
|
entry->label = eina_stringshare_add(label);
|
2015-01-24 13:19:25 -08:00
|
|
|
if (type == EINA_FILE_DIR)
|
2015-11-24 14:21:21 -08:00
|
|
|
entry->is_dir = EINA_TRUE;
|
2015-01-24 13:19:25 -08:00
|
|
|
else
|
2015-11-24 14:21:21 -08:00
|
|
|
entry->is_dir = EINA_FALSE;
|
2011-02-21 17:55:08 -08:00
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2016-03-15 14:45:20 -07:00
|
|
|
Eina_Bool
|
|
|
|
ephoto_entry_exists(Ephoto *ephoto, const char *path)
|
|
|
|
{
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ephoto->entries, l, entry)
|
|
|
|
{
|
|
|
|
if (!strcmp(entry->path, path))
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
void
|
2015-12-02 17:11:29 -08:00
|
|
|
ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
|
|
|
Ephoto_Entry_Free_Listener *fl;
|
2015-12-02 17:11:29 -08:00
|
|
|
Eina_List *node;
|
2016-02-29 09:15:52 -08:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
EINA_LIST_FREE(entry->free_listeners, fl)
|
|
|
|
{
|
2015-11-24 14:21:21 -08:00
|
|
|
fl->cb((void *) fl->data, entry);
|
2011-02-21 17:55:08 -08:00
|
|
|
free(fl);
|
|
|
|
}
|
2016-01-19 11:58:28 -08:00
|
|
|
if (!entry->is_dir)
|
2015-12-02 17:11:29 -08:00
|
|
|
{
|
|
|
|
node = eina_list_data_find_list(ephoto->entries, entry);
|
|
|
|
ephoto->entries = eina_list_remove_list(ephoto->entries, node);
|
2015-12-02 18:45:35 -08:00
|
|
|
if (ephoto->selentries)
|
|
|
|
{
|
|
|
|
node = eina_list_data_find_list(ephoto->selentries, entry);
|
2016-01-20 07:56:10 -08:00
|
|
|
ephoto->selentries = eina_list_remove_list(ephoto->selentries,
|
|
|
|
node);
|
2015-12-02 18:45:35 -08:00
|
|
|
}
|
2015-12-02 17:11:29 -08:00
|
|
|
}
|
2011-02-21 17:55:08 -08:00
|
|
|
eina_stringshare_del(entry->path);
|
|
|
|
eina_stringshare_del(entry->label);
|
2016-01-19 11:58:28 -08:00
|
|
|
if (entry->monitor)
|
2016-02-29 09:15:52 -08:00
|
|
|
ecore_file_monitor_del(entry->monitor);
|
2011-02-21 17:55:08 -08:00
|
|
|
free(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb) (void *data,
|
|
|
|
const Ephoto_Entry *entry), const void *data)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
|
|
|
Ephoto_Entry_Free_Listener *fl;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
fl = malloc(sizeof(Ephoto_Entry_Free_Listener));
|
|
|
|
fl->cb = cb;
|
|
|
|
fl->data = data;
|
|
|
|
entry->free_listeners = eina_list_append(entry->free_listeners, fl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-11-24 14:21:21 -08:00
|
|
|
ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb) (void *data,
|
|
|
|
const Ephoto_Entry *entry), const void *data)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Ephoto_Entry_Free_Listener *fl;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
EINA_LIST_FOREACH(entry->free_listeners, l, fl)
|
|
|
|
{
|
|
|
|
if ((fl->cb == cb) && (fl->data == data))
|
2015-11-24 14:21:21 -08:00
|
|
|
{
|
|
|
|
entry->free_listeners =
|
|
|
|
eina_list_remove_list(entry->free_listeners, l);
|
|
|
|
break;
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-02-24 14:26:47 -08:00
|
|
|
ephoto_entries_free(Ephoto *ephoto)
|
2011-02-21 17:55:08 -08:00
|
|
|
{
|
|
|
|
Ephoto_Entry *entry;
|
2015-11-24 14:21:21 -08:00
|
|
|
|
2015-12-02 17:11:29 -08:00
|
|
|
EINA_LIST_FREE(ephoto->entries, entry) ephoto_entry_free(ephoto, entry);
|
2011-02-21 17:55:08 -08:00
|
|
|
}
|