parent
ae03e70576
commit
1547ddaa81
|
@ -29,7 +29,7 @@ elm_main(int argc, char **argv)
|
|||
elm_need_ethumb();
|
||||
elm_init(argc, argv);
|
||||
|
||||
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR"/themes/default/ephoto.edj");
|
||||
elm_theme_extension_add(NULL, THEME_FILE);
|
||||
|
||||
if (!efreet_mime_init())
|
||||
fprintf(stderr, "Could not init efreet_mime!\n");
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#define THEME_FILE PACKAGE_DATA_DIR"/themes/default/ephoto.edj"
|
||||
|
||||
/*Typedefs*/
|
||||
typedef struct _Ephoto_Config Ephoto_Config;
|
||||
typedef struct _Ephoto Ephoto;
|
||||
typedef struct _Ephoto_Entry Ephoto_Entry;
|
||||
|
@ -32,6 +33,7 @@ typedef struct _Ephoto_Event_Entry_Create Ephoto_Event_Entry_Create;
|
|||
typedef enum _Ephoto_State Ephoto_State;
|
||||
typedef enum _Ephoto_Orient Ephoto_Orient;
|
||||
|
||||
/*Main Gui Functions/Callbacks*/
|
||||
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);
|
||||
|
@ -40,12 +42,15 @@ void ephoto_thumb_path_set(Evas_Object *o, const char *path);
|
|||
void ephoto_directory_set(Ephoto *ephoto, const char *path);
|
||||
void ephoto_auto_hide_toolbar(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__);
|
||||
|
||||
/*Get the exif orientation of a JPEG*/
|
||||
Ephoto_Orient ephoto_file_orient_get(const char *path);
|
||||
|
||||
/*Config Functions/Callbacks*/
|
||||
Eina_Bool ephoto_config_init(Ephoto *em);
|
||||
void ephoto_config_save(Ephoto *em, Eina_Bool instant);
|
||||
void ephoto_config_free(Ephoto *em);
|
||||
|
||||
/*Single Browser Functions/Callbacks*/
|
||||
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);
|
||||
|
@ -54,6 +59,7 @@ void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char
|
|||
* "slideshow" - the user wants to view a slideshow.
|
||||
*/
|
||||
|
||||
/*Flow Browser Functions/Callbacks*/
|
||||
Evas_Object *ephoto_flow_browser_add(Ephoto *e, Evas_Object *parent);
|
||||
void ephoto_flow_browser_entry_set(Evas_Object *obj __UNUSED__, Ephoto_Entry *entry);
|
||||
/* smart callbacks called:
|
||||
|
@ -61,18 +67,21 @@ void ephoto_flow_browser_entry_set(Evas_Object *obj __UNUSED__, Ephoto_E
|
|||
* "slideshow" - the user wants to view a slideshow.
|
||||
*/
|
||||
|
||||
/*Slideshow Functions/Callbacks*/
|
||||
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.
|
||||
*/
|
||||
|
||||
/*Main Thumb Browser Function*/
|
||||
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.
|
||||
*/
|
||||
|
||||
/*Ephoto View*/
|
||||
enum _Ephoto_State
|
||||
{
|
||||
EPHOTO_STATE_THUMB,
|
||||
|
@ -81,7 +90,8 @@ enum _Ephoto_State
|
|||
EPHOTO_STATE_SLIDESHOW
|
||||
};
|
||||
|
||||
enum _Ephoto_Orient /* matches with exif orientation tag */
|
||||
/*Ephoto Orientation*/
|
||||
enum _Ephoto_Orient
|
||||
{
|
||||
EPHOTO_ORIENT_0 = 1,
|
||||
EPHOTO_ORIENT_FLIP_HORIZ = 2,
|
||||
|
@ -93,29 +103,20 @@ enum _Ephoto_Orient /* matches with exif orientation tag */
|
|||
EPHOTO_ORIENT_270 = 8
|
||||
};
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
/*Ephoto Config*/
|
||||
struct _Ephoto_Config
|
||||
{
|
||||
int config_version;
|
||||
const char *editor;
|
||||
double slideshow_timeout;
|
||||
const char *slideshow_transition;
|
||||
|
||||
/* these should be per-window */
|
||||
int thumb_size;
|
||||
int thumb_gen_size;
|
||||
int autohide_toolbar;
|
||||
int best_fit_images;
|
||||
int thumb_size;
|
||||
int thumb_gen_size;
|
||||
double slideshow_timeout;
|
||||
const char *directory;
|
||||
|
||||
const char *slideshow_transition;
|
||||
};
|
||||
|
||||
/*Ephoto Main*/
|
||||
struct _Ephoto
|
||||
{
|
||||
Evas_Object *win;
|
||||
|
@ -128,9 +129,9 @@ struct _Ephoto
|
|||
Evas_Object *slideshow;
|
||||
|
||||
Eina_List *entries;
|
||||
Eina_List *thumbs; /* live thumbs that need to be regenerated on changes */
|
||||
Eina_List *thumbs;
|
||||
|
||||
int thumb_gen_size; /* pending value for thumb_regen */
|
||||
int thumb_gen_size;
|
||||
struct {
|
||||
Ecore_Timer *thumb_regen;
|
||||
} timer;
|
||||
|
@ -146,10 +147,11 @@ struct _Ephoto
|
|||
Ephoto_Config *config;
|
||||
};
|
||||
|
||||
/*Ephoto Entry*/
|
||||
struct _Ephoto_Entry
|
||||
{
|
||||
const char *path;
|
||||
const char *basename; /* pointer inside path */
|
||||
const char *basename;
|
||||
const char *label;
|
||||
Ephoto *ephoto;
|
||||
Elm_Gengrid_Item *item;
|
||||
|
@ -161,21 +163,24 @@ struct _Ephoto_Event_Entry_Create
|
|||
Ephoto_Entry *entry;
|
||||
};
|
||||
|
||||
/*Ephoto Entry Functions/Callbacks*/
|
||||
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);
|
||||
|
||||
/*Ephoto Logging*/
|
||||
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__)
|
||||
|
||||
/*Checks to determine if a file is an image*/
|
||||
static inline Eina_Bool
|
||||
_ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
||||
{
|
||||
const char /* *type, */ *bname, *ext;
|
||||
const char *bname, *ext;
|
||||
|
||||
bname = info->path + info->name_start;
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
|
@ -200,11 +205,9 @@ _ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
|||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/*Ephoto Event Handlers*/
|
||||
extern int EPHOTO_EVENT_ENTRY_CREATE;
|
||||
extern int EPHOTO_EVENT_POPULATE_START;
|
||||
extern int EPHOTO_EVENT_POPULATE_END;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
#define CONFIG_VERSION 5
|
||||
#define CONFIG_VERSION 6
|
||||
|
||||
static int _ephoto_config_load(Ephoto *ephoto);
|
||||
static Eina_Bool _ephoto_on_config_save(void *data);
|
||||
|
@ -13,53 +13,42 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
|
||||
if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "Ephoto_Config", sizeof(Ephoto_Config)))
|
||||
if (!eet_eina_stream_data_descriptor_class_set
|
||||
(&eddc, sizeof (eddc), "Ephoto_Config", sizeof(Ephoto_Config)))
|
||||
{
|
||||
ERR("Unable to create the config data descriptor!");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!edd) edd = eet_data_descriptor_stream_new(&eddc);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Ephoto_Config
|
||||
#define D edd
|
||||
#define C_VAL(edd, type, member, dtype) EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
|
||||
C_VAL(D, T, config_version, EET_T_INT);
|
||||
C_VAL(D, T, thumb_size, EET_T_INT);
|
||||
C_VAL(D, T, thumb_gen_size, EET_T_INT);
|
||||
C_VAL(D, T, autohide_toolbar, EET_T_INT);
|
||||
C_VAL(D, T, best_fit_images, EET_T_INT);
|
||||
C_VAL(D, T, directory, EET_T_STRING);
|
||||
C_VAL(D, T, slideshow_timeout, EET_T_DOUBLE);
|
||||
C_VAL(D, T, slideshow_transition, EET_T_STRING);
|
||||
C_VAL(D, T, editor, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "config_version", config_version, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "autohide_toolbar", autohide_toolbar, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "best_fit_images", best_fit_images, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "thumb_gen_size", thumb_gen_size, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "thumb_size", thumb_size, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "slideshow_timeout", slideshow_timeout, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "directory", directory, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC
|
||||
(edd, Ephoto_Config, "slideshow_transition", slideshow_transition, EET_T_STRING);
|
||||
switch (_ephoto_config_load(ephoto))
|
||||
{
|
||||
case 0:
|
||||
/* Start a new config */
|
||||
ephoto->config->config_version = CONFIG_VERSION;
|
||||
ephoto->config->autohide_toolbar = 0;
|
||||
ephoto->config->best_fit_images = 0;
|
||||
ephoto->config->thumb_gen_size = 256;
|
||||
ephoto->config->thumb_size = 256;
|
||||
ephoto->config->thumb_gen_size = 256;
|
||||
ephoto->config->slideshow_timeout = 4.0;
|
||||
ephoto->config->slideshow_transition = eina_stringshare_add("fade");
|
||||
ephoto->config->editor = eina_stringshare_add("gimp %s");
|
||||
break;
|
||||
|
||||
case -1:
|
||||
/* Incremental additions */
|
||||
if (ephoto->config->config_version < 2)
|
||||
{
|
||||
ephoto->config->slideshow_timeout = 4.0;
|
||||
ephoto->config->slideshow_transition = eina_stringshare_add("fade");
|
||||
}
|
||||
if (ephoto->config->config_version < 3)
|
||||
ephoto->config->editor = eina_stringshare_add("gimp %s");
|
||||
|
||||
if (ephoto->config->config_version < 5)
|
||||
ephoto->config->thumb_gen_size = 256;
|
||||
|
||||
ephoto->config->config_version = CONFIG_VERSION;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -113,16 +102,25 @@ _ephoto_config_load(Ephoto *ephoto)
|
|||
ephoto->config = eet_data_read(ef, edd, "config");
|
||||
eet_close(ef);
|
||||
|
||||
if (ephoto->config->config_version > CONFIG_VERSION)
|
||||
if (!ephoto->config)
|
||||
{
|
||||
DBG("Warning! No configuration found! Writing a new"
|
||||
"default configuration!\n");
|
||||
return 0;
|
||||
}
|
||||
else if (ephoto->config->config_version > CONFIG_VERSION)
|
||||
{
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ephoto->config->config_version < CONFIG_VERSION)
|
||||
return -1;
|
||||
|
||||
else if (ephoto->config->config_version < CONFIG_VERSION)
|
||||
{
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ _add_image_edje(const char *swallow, Evas_Object *parent)
|
|||
|
||||
o = elm_layout_add(parent);
|
||||
elm_layout_file_set
|
||||
(o, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "flow_image");
|
||||
(o, THEME_FILE, "flow_image");
|
||||
elm_layout_content_set(parent, swallow, o);
|
||||
evas_object_show(o);
|
||||
|
||||
|
@ -343,8 +343,7 @@ ephoto_flow_browser_add(Ephoto *e, Evas_Object *parent)
|
|||
(efb->edje, "mouse,clicked,1", "toolbar_event",
|
||||
ephoto_auto_hide_toolbar, efb->ephoto);
|
||||
if (!elm_layout_file_set
|
||||
(efb->main_layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto/layout/simple/autohide"))
|
||||
(efb->main_layout, THEME_FILE, "ephoto/layout/simple/autohide"))
|
||||
{
|
||||
ERR("could not load style 'ephoto/layout/simple/autohide' from theme");
|
||||
goto error;
|
||||
|
@ -353,8 +352,7 @@ ephoto_flow_browser_add(Ephoto *e, Evas_Object *parent)
|
|||
else
|
||||
{
|
||||
if (!elm_layout_file_set
|
||||
(efb->main_layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto/layout/simple"))
|
||||
(efb->main_layout, THEME_FILE, "ephoto/layout/simple"))
|
||||
{
|
||||
ERR("could not load style 'ephoto/layout/simple' from theme");
|
||||
goto error;
|
||||
|
@ -383,7 +381,7 @@ ephoto_flow_browser_add(Ephoto *e, Evas_Object *parent)
|
|||
|
||||
efb->layout = elm_layout_add(efb->main_layout);
|
||||
elm_layout_file_set
|
||||
(efb->layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "flow");
|
||||
(efb->layout, THEME_FILE, "flow");
|
||||
evas_object_size_hint_weight_set
|
||||
(efb->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set
|
||||
|
|
|
@ -795,8 +795,7 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
(sb->edje, "mouse,clicked,1", "toolbar_event",
|
||||
ephoto_auto_hide_toolbar, sb->ephoto);
|
||||
if (!elm_layout_file_set
|
||||
(layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto/layout/simple/autohide"))
|
||||
(layout, THEME_FILE, "ephoto/layout/simple/autohide"))
|
||||
{
|
||||
ERR("could not load style 'ephoto/layout/simple/autohide' from theme");
|
||||
goto error;
|
||||
|
@ -805,8 +804,7 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
else
|
||||
{
|
||||
if (!elm_layout_file_set
|
||||
(layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto/layout/simple"))
|
||||
(layout, THEME_FILE, "ephoto/layout/simple"))
|
||||
{
|
||||
ERR("could not load style 'ephoto/layout/simple' from theme");
|
||||
goto error;
|
||||
|
|
|
@ -452,8 +452,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
(tb->edje, "mouse,clicked,1", "toolbar_event",
|
||||
ephoto_auto_hide_toolbar, tb->ephoto);
|
||||
if (!elm_layout_file_set
|
||||
(layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto/layout/simple/autohide"))
|
||||
(layout, THEME_FILE, "ephoto/layout/simple/autohide"))
|
||||
{
|
||||
ERR("could not load style 'ephoto/layout/simple/autohide' from theme");
|
||||
goto error;
|
||||
|
@ -462,8 +461,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
else
|
||||
{
|
||||
if (!elm_layout_file_set
|
||||
(layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto/layout/simple"))
|
||||
(layout, THEME_FILE, "ephoto/layout/simple"))
|
||||
{
|
||||
ERR("could not load style 'ephoto/layout/simple' from theme");
|
||||
goto error;
|
||||
|
@ -514,8 +512,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
|
||||
tb->overlay = elm_layout_add(layout);
|
||||
elm_layout_file_set
|
||||
(tb->overlay, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"ephoto,thumb,grid");
|
||||
(tb->overlay, THEME_FILE, "ephoto,thumb,grid");
|
||||
evas_object_size_hint_weight_set
|
||||
(tb->overlay, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set
|
||||
|
|
Loading…
Reference in New Issue