2010-07-01 11:49:22 -07:00
|
|
|
#include "ephoto.h"
|
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
static void _ephoto_window_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__);
|
|
|
|
static void _ephoto_thumb_populate(void);
|
|
|
|
static Eina_Bool _ephoto_thumb_populate_filter(void *data __UNUSED__, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info);
|
|
|
|
static void _ephoto_thumb_populate_main(void *data __UNUSED__, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info);
|
|
|
|
static void _ephoto_thumb_populate_end(void *data __UNUSED__, Eio_File *handler __UNUSED__);
|
|
|
|
static void _ephoto_thumb_populate_error(void *data __UNUSED__, Eio_File *handler __UNUSED__, int error);
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2010-10-09 18:13:53 -07:00
|
|
|
Evas_Object *
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto_window_add(void)
|
2010-07-01 11:49:22 -07:00
|
|
|
{
|
2010-10-09 18:13:53 -07:00
|
|
|
ephoto->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
|
|
|
|
if (!ephoto->win)
|
2011-02-01 13:44:38 -08:00
|
|
|
return NULL;
|
|
|
|
evas_object_resize(ephoto->win, 600, 400);
|
|
|
|
ephoto_title_set("Ephoto - Picture Enlightenment");
|
|
|
|
evas_object_smart_callback_add
|
|
|
|
(ephoto->win, "delete,request", _ephoto_window_del, NULL);
|
|
|
|
evas_object_show(ephoto->win);
|
2010-10-09 18:13:53 -07:00
|
|
|
|
|
|
|
ephoto->bg = elm_bg_add(ephoto->win);
|
|
|
|
evas_object_size_hint_weight_set
|
|
|
|
(ephoto->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(ephoto->bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_win_resize_object_add(ephoto->win, ephoto->bg);
|
|
|
|
evas_object_show(ephoto->bg);
|
|
|
|
|
2010-10-12 15:54:20 -07:00
|
|
|
ephoto->pager = elm_pager_add(ephoto->win);
|
2011-02-01 13:44:38 -08:00
|
|
|
elm_object_style_set(ephoto->pager, "fade");
|
2010-10-09 18:13:53 -07:00
|
|
|
evas_object_size_hint_weight_set
|
2010-10-12 15:54:20 -07:00
|
|
|
(ephoto->pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2010-10-09 18:13:53 -07:00
|
|
|
evas_object_size_hint_fill_set
|
2010-10-12 15:54:20 -07:00
|
|
|
(ephoto->pager, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_win_resize_object_add(ephoto->win, ephoto->pager);
|
|
|
|
evas_object_show(ephoto->pager);
|
2010-10-09 18:13:53 -07:00
|
|
|
|
2011-02-10 16:09:33 -08:00
|
|
|
if (!ephoto->directory && !ephoto->file)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX], *cwd;
|
|
|
|
cwd = getcwd(buf, PATH_MAX);
|
|
|
|
ephoto->directory = eina_stringshare_add(cwd);
|
|
|
|
}
|
|
|
|
else if (ephoto->file)
|
|
|
|
ephoto->directory = eina_stringshare_add(ecore_file_dir_get(ephoto->file));
|
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto->flow_browser = ephoto_flow_browser_add();
|
2010-10-12 15:54:20 -07:00
|
|
|
elm_pager_content_push(ephoto->pager, ephoto->flow_browser);
|
2010-10-11 20:40:14 -07:00
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto->thumb_browser = ephoto_thumb_browser_add();
|
|
|
|
elm_pager_content_push(ephoto->pager, ephoto->thumb_browser);
|
2010-10-09 18:13:53 -07:00
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
elm_pager_content_promote(ephoto->pager, ephoto->thumb_browser);
|
|
|
|
ephoto->state = EPHOTO_STATE_THUMB;
|
2010-10-12 16:46:36 -07:00
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto->current_index = ephoto->images;
|
|
|
|
_ephoto_thumb_populate();
|
2010-10-12 15:54:20 -07:00
|
|
|
|
2010-10-09 18:13:53 -07:00
|
|
|
return ephoto->win;
|
|
|
|
}
|
|
|
|
|
2011-02-10 15:41:02 -08:00
|
|
|
void
|
|
|
|
ephoto_populate()
|
|
|
|
{
|
|
|
|
_ephoto_thumb_populate();
|
|
|
|
}
|
|
|
|
|
2010-10-10 18:10:27 -07:00
|
|
|
void
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto_title_set(const char *title)
|
2010-11-13 17:51:16 -08:00
|
|
|
{
|
2011-02-01 13:44:38 -08:00
|
|
|
elm_win_title_set(ephoto->win, title);
|
2010-11-13 17:51:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-01 13:44:38 -08:00
|
|
|
_ephoto_window_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2010-11-13 17:51:16 -08:00
|
|
|
{
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto_thumb_browser_del();
|
|
|
|
ephoto_flow_browser_del();
|
|
|
|
evas_object_del(ephoto->win);
|
2010-11-13 17:51:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-01 13:44:38 -08:00
|
|
|
_ephoto_thumb_populate(void)
|
2010-11-13 17:51:16 -08:00
|
|
|
{
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto->ls = eio_file_stat_ls(ephoto->directory,
|
|
|
|
_ephoto_thumb_populate_filter,
|
|
|
|
_ephoto_thumb_populate_main,
|
|
|
|
_ephoto_thumb_populate_end,
|
|
|
|
_ephoto_thumb_populate_error,
|
|
|
|
NULL);
|
2010-11-13 17:51:16 -08:00
|
|
|
}
|
|
|
|
|
2010-10-08 15:48:12 -07:00
|
|
|
static Eina_Bool
|
2011-02-01 13:44:38 -08:00
|
|
|
_ephoto_thumb_populate_filter(void *data __UNUSED__, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info)
|
2010-10-08 15:48:12 -07:00
|
|
|
{
|
2011-02-03 11:26:56 -08:00
|
|
|
const char *ext;
|
2011-02-03 11:18:36 -08:00
|
|
|
|
2011-02-03 11:26:56 -08:00
|
|
|
ext = strrchr(info->path, '.');
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
if ((!strncasecmp(ext, ".jpeg", 5)) ||
|
2011-02-03 11:30:59 -08:00
|
|
|
(!strncasecmp(ext, ".jpg", 4)) ||
|
|
|
|
(!strncasecmp(ext, ".png", 4)) ||
|
|
|
|
(!strncasecmp(ext, ".gif", 4)) ||
|
|
|
|
(!strncasecmp(ext, ".svg", 4)))
|
2011-02-03 11:26:56 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-08 15:48:12 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-01 13:44:38 -08:00
|
|
|
_ephoto_thumb_populate_main(void *data __UNUSED__, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info)
|
2010-10-09 12:13:35 -07:00
|
|
|
{
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto->images = eina_list_append(ephoto->images, info->path);
|
2010-10-09 12:13:35 -07:00
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto_thumb_browser_thumb_append(info->path);
|
|
|
|
if (ephoto->file && !strcmp(ephoto->file, info->path))
|
|
|
|
ephoto->current_index = ephoto->images;
|
2010-10-09 12:13:35 -07:00
|
|
|
}
|
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
static void
|
|
|
|
_ephoto_thumb_populate_end(void *data __UNUSED__, Eio_File *handler __UNUSED__)
|
2010-10-12 23:11:06 -07:00
|
|
|
{
|
2011-02-01 13:44:38 -08:00
|
|
|
ephoto->ls = NULL;
|
|
|
|
if (!ephoto->current_index)
|
|
|
|
ephoto->current_index = eina_list_nth_list(ephoto->images, 0);
|
2010-10-12 23:11:06 -07:00
|
|
|
}
|
|
|
|
|
2011-02-01 13:44:38 -08:00
|
|
|
static void
|
|
|
|
_ephoto_thumb_populate_error(void *data __UNUSED__, Eio_File *handler __UNUSED__, int error)
|
2010-10-12 23:11:06 -07:00
|
|
|
{
|
2011-02-01 13:44:38 -08:00
|
|
|
if (error)
|
|
|
|
printf("Error while populating images: %s\n", strerror(error));
|
2010-10-12 23:11:06 -07:00
|
|
|
}
|
|
|
|
|