2010-07-01 11:49:22 -07:00
|
|
|
#ifndef _EPHOTO_H_
|
|
|
|
#define _EPHOTO_H_
|
|
|
|
|
2010-10-11 21:58:04 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
2010-07-01 11:49:22 -07:00
|
|
|
#endif
|
|
|
|
|
2010-09-13 15:24:59 -07:00
|
|
|
#include <Eet.h>
|
2010-07-01 11:49:22 -07:00
|
|
|
#include <Ecore.h>
|
2011-02-24 14:26:47 -08:00
|
|
|
#include <Ecore_Evas.h>
|
2010-07-01 11:49:22 -07:00
|
|
|
#include <Ecore_File.h>
|
|
|
|
#include <Efreet_Mime.h>
|
|
|
|
#include <Elementary.h>
|
|
|
|
#include <Eina.h>
|
|
|
|
#include <Edje.h>
|
|
|
|
#include <Evas.h>
|
2010-07-22 09:15:16 -07:00
|
|
|
#include <Eio.h>
|
2010-10-15 10:40:03 -07:00
|
|
|
#include <Ethumb_Client.h>
|
2010-07-01 11:49:22 -07:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-10-08 14:43:57 -07:00
|
|
|
#include <dirent.h>
|
2010-07-01 11:49:22 -07:00
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
#define THEME_FILE PACKAGE_DATA_DIR"/themes/default/ephoto.edj"
|
|
|
|
|
|
|
|
typedef struct _Ephoto_Config Ephoto_Config;
|
|
|
|
typedef struct _Ephoto Ephoto;
|
|
|
|
typedef struct _Ephoto_Entry Ephoto_Entry;
|
|
|
|
typedef struct _Ephoto_Event_Entry_Create Ephoto_Event_Entry_Create;
|
|
|
|
|
|
|
|
typedef enum _Ephoto_State Ephoto_State;
|
|
|
|
typedef enum _Ephoto_Orient Ephoto_Orient;
|
|
|
|
|
|
|
|
Evas_Object *ephoto_window_add(const char *path);
|
|
|
|
void ephoto_title_set(Ephoto *ephoto, const char *title);
|
|
|
|
void ephoto_thumb_size_set(Ephoto *ephoto, int size);
|
|
|
|
Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path);
|
|
|
|
void ephoto_thumb_path_set(Evas_Object *o, const char *path);
|
|
|
|
void ephoto_directory_set(Ephoto *ephoto, const char *path);
|
|
|
|
|
|
|
|
Ephoto_Orient ephoto_file_orient_get(const char *path);
|
|
|
|
|
|
|
|
Eina_Bool ephoto_config_init(Ephoto *em);
|
|
|
|
void ephoto_config_save(Ephoto *em, Eina_Bool instant);
|
|
|
|
void ephoto_config_free(Ephoto *em);
|
|
|
|
|
2011-05-17 13:02:53 -07:00
|
|
|
Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
|
|
|
void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
|
|
|
void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path);
|
2011-06-28 15:26:16 -07:00
|
|
|
/* smart callbacks called:
|
|
|
|
* "back" - the user want to go back to the previous screen.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent);
|
|
|
|
void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
|
|
|
/* smart callbacks called:
|
|
|
|
* "back" - the user want to go back to the previous screen.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Evas_Object *ephoto_directory_thumb_add(Evas_Object *parent, Ephoto_Entry *e);
|
|
|
|
|
|
|
|
Evas_Object *ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
|
|
|
|
|
|
|
/* smart callbacks called:
|
|
|
|
* "selected" - an item in the thumb browser is selected. The selected Ephoto_Entry is passed as event_info argument.
|
|
|
|
*/
|
2010-10-09 18:13:53 -07:00
|
|
|
|
2010-09-13 09:40:33 -07:00
|
|
|
enum _Ephoto_State
|
|
|
|
{
|
2011-02-24 14:26:47 -08:00
|
|
|
EPHOTO_STATE_THUMB,
|
|
|
|
EPHOTO_STATE_SINGLE,
|
|
|
|
EPHOTO_STATE_SLIDESHOW
|
|
|
|
};
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
enum _Ephoto_Orient /* matches with exif orientation tag */
|
2011-02-24 14:26:47 -08:00
|
|
|
{
|
|
|
|
EPHOTO_ORIENT_0 = 1,
|
|
|
|
EPHOTO_ORIENT_FLIP_HORIZ = 2,
|
|
|
|
EPHOTO_ORIENT_180 = 3,
|
|
|
|
EPHOTO_ORIENT_FLIP_VERT = 4,
|
|
|
|
EPHOTO_ORIENT_FLIP_VERT_90 = 5,
|
|
|
|
EPHOTO_ORIENT_90 = 6,
|
|
|
|
EPHOTO_ORIENT_FLIP_HORIZ_90 = 7,
|
|
|
|
EPHOTO_ORIENT_270 = 8
|
|
|
|
};
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
/* TODO: split into window & global config, allow multi window
|
|
|
|
*
|
|
|
|
* This also requires single instance, as 2 instances changing the
|
|
|
|
* same configuration will lead to problems.
|
|
|
|
*
|
|
|
|
* Single instance is better done as DBus, using FDO standard methods.
|
|
|
|
*/
|
2011-02-24 14:26:47 -08:00
|
|
|
struct _Ephoto_Config
|
|
|
|
{
|
|
|
|
int config_version;
|
2011-06-28 15:26:16 -07:00
|
|
|
const char *editor;
|
|
|
|
double slideshow_timeout;
|
|
|
|
const char *slideshow_transition;
|
|
|
|
|
|
|
|
/* these should be per-window */
|
2011-03-15 13:09:37 -07:00
|
|
|
int thumb_size;
|
|
|
|
int thumb_gen_size;
|
2011-02-24 14:26:47 -08:00
|
|
|
const char *directory;
|
2011-06-28 15:26:16 -07:00
|
|
|
|
2010-09-13 15:24:59 -07:00
|
|
|
};
|
|
|
|
|
2010-07-01 11:49:22 -07:00
|
|
|
struct _Ephoto
|
|
|
|
{
|
2010-10-09 18:13:53 -07:00
|
|
|
Evas_Object *win;
|
|
|
|
Evas_Object *bg;
|
2010-10-12 15:54:20 -07:00
|
|
|
Evas_Object *pager;
|
2010-10-09 18:13:53 -07:00
|
|
|
|
|
|
|
Evas_Object *thumb_browser;
|
2011-02-24 14:26:47 -08:00
|
|
|
Evas_Object *single_browser;
|
2010-10-09 18:13:53 -07:00
|
|
|
Evas_Object *slideshow;
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
Eina_List *entries;
|
2011-06-28 15:26:16 -07:00
|
|
|
Eina_List *thumbs; /* live thumbs that need to be regenerated on changes */
|
2011-02-24 14:26:47 -08:00
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
int thumb_gen_size; /* pending value for thumb_regen */
|
2011-02-24 14:26:47 -08:00
|
|
|
struct {
|
|
|
|
Ecore_Timer *thumb_regen;
|
|
|
|
} timer;
|
|
|
|
struct {
|
|
|
|
Ecore_Job *change_dir;
|
|
|
|
} job;
|
|
|
|
|
|
|
|
Eio_File *ls;
|
|
|
|
|
|
|
|
Evas_Object *prefs_win;
|
2010-10-11 20:40:14 -07:00
|
|
|
Ephoto_State state, prev_state;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
Ephoto_Config *config;
|
2010-11-13 17:51:16 -08:00
|
|
|
};
|
|
|
|
|
2011-02-21 17:55:08 -08:00
|
|
|
struct _Ephoto_Entry
|
|
|
|
{
|
|
|
|
const char *path;
|
2011-06-28 15:26:16 -07:00
|
|
|
const char *basename; /* pointer inside path */
|
2011-02-21 17:55:08 -08:00
|
|
|
const char *label;
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto *ephoto;
|
2011-02-21 17:55:08 -08:00
|
|
|
Elm_Gengrid_Item *item;
|
|
|
|
Eina_List *free_listeners;
|
2011-06-28 15:26:16 -07:00
|
|
|
Eina_List *dir_files; /* if dir, here contain files with preview */
|
|
|
|
Eina_Bool dir_files_checked : 1;
|
|
|
|
Eina_Bool is_dir : 1;
|
|
|
|
Eina_Bool is_up : 1;
|
2011-02-21 17:55:08 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ephoto_Event_Entry_Create
|
|
|
|
{
|
|
|
|
Ephoto_Entry *entry;
|
|
|
|
};
|
|
|
|
|
2011-02-24 14:26:47 -08:00
|
|
|
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label);
|
|
|
|
void ephoto_entry_free(Ephoto_Entry *entry);
|
|
|
|
void ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
|
|
|
|
void ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
|
|
|
|
void ephoto_entries_free(Ephoto *ephoto);
|
|
|
|
|
|
|
|
extern int __log_domain;
|
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
|
|
|
|
#define INF(...) EINA_LOG_DOM_INFO(__log_domain, __VA_ARGS__)
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(__log_domain, __VA_ARGS__)
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
_ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
|
|
|
{
|
2011-06-28 15:26:16 -07:00
|
|
|
const char /* *type, */ *bname, *ext;
|
2011-02-24 14:26:47 -08:00
|
|
|
|
|
|
|
bname = info->path + info->name_start;
|
|
|
|
if (bname[0] == '.') return EINA_FALSE;
|
|
|
|
if ((info->type != EINA_FILE_REG) && (info->type != EINA_FILE_UNKNOWN))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ext = info->path + info->path_length - 1;
|
|
|
|
for (; ext > bname; ext--) if (*ext == '.') break;
|
|
|
|
if (*ext == '.')
|
|
|
|
{
|
|
|
|
ext++;
|
|
|
|
if ((strcasecmp(ext, "jpg") == 0) ||
|
|
|
|
(strcasecmp(ext, "jpeg") == 0) ||
|
2011-06-29 12:49:24 -07:00
|
|
|
(strcasecmp(ext, "png") == 0) ||
|
|
|
|
(strcasecmp(ext, "gif") == 0) ||
|
|
|
|
(strcasecmp(ext, "tif") == 0) ||
|
2011-06-30 09:04:18 -07:00
|
|
|
(strcasecmp(ext, "svg") == 0) ||
|
|
|
|
(strcasecmp(ext, "edj") == 0))
|
2011-02-24 14:26:47 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
2011-06-28 15:26:16 -07:00
|
|
|
/* seems that this does not play nice with threads */
|
|
|
|
//if (!(type = efreet_mime_type_get(info->path))) return EINA_FALSE;
|
|
|
|
//return strncmp(type, "image/", sizeof("image/") - 1) == 0;
|
2011-02-24 14:26:47 -08:00
|
|
|
}
|
|
|
|
|
2011-06-28 15:26:16 -07:00
|
|
|
extern int EPHOTO_EVENT_ENTRY_CREATE;
|
2011-02-21 17:55:08 -08:00
|
|
|
extern int EPHOTO_EVENT_POPULATE_START;
|
|
|
|
extern int EPHOTO_EVENT_POPULATE_END;
|
|
|
|
extern int EPHOTO_EVENT_POPULATE_ERROR;
|
|
|
|
|
2010-09-13 15:24:59 -07:00
|
|
|
#endif
|