ouch, refactor part 2 -- less is more, so get nothing ;-)

okay, still yet another partial code, it's far from ready, don't even
checkout until you're ready to code.

preferences, flow_browser, slideshow are temporarily gone.

still no toolbar in main window, layout redone using EXTERNAL... when
it go back, it will be in the same form as eve/enjoy.



SVN revision: 53238
v-1.6.0
Gustavo Sverzut Barbieri 12 years ago
parent e21422bf65
commit 9652a108bf
  1. 106
      data/themes/default/ephoto.edc
  2. 42
      src/bin/ephoto.c
  3. 98
      src/bin/ephoto.h
  4. 246
      src/bin/ephoto_config.c
  5. 2
      src/bin/ephoto_directory_thumb.c
  6. 29
      src/bin/ephoto_flow_browser.c
  7. 235
      src/bin/ephoto_main.c
  8. 3
      src/bin/ephoto_preferences.c
  9. 2
      src/bin/ephoto_slideshow.c
  10. 621
      src/bin/ephoto_thumb_browser.c

@ -3,6 +3,10 @@ fonts
font: "Vera.ttf" "default";
}
externals {
external: "elm";
}
collections
{
images
@ -719,64 +723,94 @@ collections
}
}
group
{
name: "ephoto/main/layout";
group { name: "ephoto/main/layout";
data.item: "initial_size" "480 800";
parts {
part {
name: "ephoto.content.swallow";
part { name: "ephoto.swallow.content";
type: SWALLOW;
description {
state: "default" 0.0;
description { state: "default" 0.0;
}
}
}
}
group
{
name: "ephoto/browser/layout";
group { name: "ephoto/browser/layout";
parts {
part {
name: "bg";
type: RECT;
part { name: "ephoto.location";
type: EXTERNAL;
source: "elm/scrolled_entry";
description {
state: "default" 0.0;
color: 10 10 10 0;
rel2 {
relative: 0.0 0.0;
offset: -3 64;
to_x: "ephoto.fileselector";
}
params {
bool: "editable" 1;
bool: "single line" 1;
}
}
}
part {
name: "ephoto.thumb.swallow";
type: SWALLOW;
part { name: "ephoto.fileselector";
type: EXTERNAL;
source: "elm/fileselector_button";
description {
state: "default" 0.0;
rel1.to: "ephoto.location.swallow";
rel1.relative: 0 1;
rel2.to: "ephoto.toolbar.swallow";
rel2.relative: 1 0;
align: 1.0 0.0;
rel1 { relative: 1.0 0.0;
offset: -100 3;
}
rel2 { relative: 1.0 0.0;
offset: -4 58;
}
params {
string: "icon" "folder";
bool: "folder only" 1;
bool: "inwin mode" 1;
}
}
}
part {
name: "ephoto.location.swallow";
type: SWALLOW;
description {
state: "default" 0.0;
rel2.relative: 1 0;
rel2.offset: 0 64;
programs {
program {
signal: "activated";
source: "ephoto.location";
action: PARAM_COPY "ephoto.location" "text" "ephoto.fileselector" "path";
after: "announce-location";
}
program {
signal: "file,chosen";
source: "ephoto.fileselector";
action: PARAM_COPY "ephoto.fileselector" "path" "ephoto.location" "text";
after: "announce-location";
}
program { name: "announce-location";
action: SIGNAL_EMIT "location,changed" "ephoto";
}
program {
signal: "location,set";
source: "ephoto";
action: PARAM_COPY "ephoto.location" "text" "ephoto.fileselector" "path";
}
}
part {
name: "ephoto.toolbar.swallow";
part { name: "ephoto.thumb.swallow";
type: SWALLOW;
description {
color: 0 255 0 255;
state: "default" 0.0;
rel1.relative: 0 1;
rel1.offset: 0 -63;
state: "default" 0.0;
rel1 { to: "ephoto.location";
relative: 0.0 1.0;
}
}
}
}
}
}
group
{
name: "ephoto/flow/layout";

@ -38,6 +38,7 @@ main(int argc, char **argv)
goto end_log_domain;
}
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
DBG("Logging initialized");
if (argc > 2)
@ -49,7 +50,12 @@ main(int argc, char **argv)
}
else if (argc < 2)
{
ephoto_create_main_window(NULL, NULL);
Evas_Object *win = ephoto_window_add(NULL);
if (!win)
{
r = 1;
goto end;
}
}
else if (!strncmp(argv[1], "--help", 6))
{
@ -57,30 +63,22 @@ main(int argc, char **argv)
r = 0;
goto end;
}
else if (ecore_file_is_dir(argv[1]))
else
{
char *real = ecore_file_realpath(argv[1]);
ephoto_create_main_window(real, NULL);
free(real);
}
else if (ecore_file_exists(argv[1]))
{
char *directory, *real;
const char *image;
image = eina_stringshare_add(argv[1]);
directory = ecore_file_dir_get(argv[1]);
real = ecore_file_realpath(directory);
ephoto_create_main_window(real, image);
free(directory);
if (!real)
{
printf("invalid file or directory: '%s'\n", argv[1]);
r = 1;
goto end;
}
Evas_Object *win = ephoto_window_add(real);
free(real);
}
else
{
printf("Incorrect Argument!\n");
_ephoto_display_usage();
r = 1;
goto end;
if (!win)
{
r = 1;
goto end;
}
}
elm_run();

@ -22,6 +22,8 @@
#include <dirent.h>
#include "config.h"
#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;
@ -30,9 +32,9 @@ typedef enum _Ephoto_State Ephoto_State;
typedef enum _Ephoto_Orient Ephoto_Orient;
/*Main Functions*/
void ephoto_create_main_window(const char *directory, const char *image);
void ephoto_thumb_size_set(int size);
Evas_Object *ephoto_thumb_add(Evas_Object *parent, const char *path);
Evas_Object *ephoto_window_add(const char *path);
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);
@ -45,10 +47,10 @@ void ephoto_config_free(Ephoto *em);
void ephoto_show_preferences(Ephoto *em);
/*Ephoto Flow Browser*/
Evas_Object *ephoto_create_flow_browser(Evas_Object *parent);
Evas_Object *ephoto_flow_browser_add(Ephoto *ephoto, Evas_Object *parent);
void ephoto_flow_browser_image_set(Evas_Object *obj, const char *current_image);
/* smart callbacks called:
* "delete,request" - the user requested to delete the flow browser, typically called when go_back button is pressed or Escape key is typed.
* "back" - the user requested to delete the flow browser, typically called when go_back button is pressed or Escape key is typed.
*/
@ -62,7 +64,9 @@ void ephoto_delete_slideshow(void);
Evas_Object *ephoto_directory_thumb_add(Evas_Object *parent, Ephoto_Entry *e);
/*Ephoto Thumb Browser*/
Evas_Object *ephoto_thumb_browser_add(Evas_Object *parent);
Evas_Object *ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent);
void ephoto_thumb_browser_directory_set(Evas_Object *obj, const char *path);
/* smart callbacks called:
* "selected" - an item in the thumb browser is selected. The selected file is passed as event_info argument.
* "directory,changed" - the user selected a new directory. The selected directory is passed as event_info argument.
@ -71,55 +75,64 @@ Evas_Object *ephoto_thumb_browser_add(Evas_Object *parent);
/* Enum for the state machine */
enum _Ephoto_State
{
EPHOTO_STATE_THUMB,
EPHOTO_STATE_FLOW,
EPHOTO_STATE_SLIDESHOW
EPHOTO_STATE_THUMB,
EPHOTO_STATE_FLOW,
EPHOTO_STATE_SLIDESHOW
};
enum _Ephoto_Orient
{
EPHOTO_ORIENT_0,
EPHOTO_ORIENT_90,
EPHOTO_ORIENT_180,
EPHOTO_ORIENT_270
EPHOTO_ORIENT_0,
EPHOTO_ORIENT_90,
EPHOTO_ORIENT_180,
EPHOTO_ORIENT_270
};
/* 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.
*/
struct _Ephoto_Config
{
int config_version;
int config_version;
int thumb_size;
int thumb_gen_size;
int thumb_size;
int thumb_gen_size;
int remember_directory;
const char *directory;
int remember_directory;
const char *directory;
double slideshow_timeout;
const char *slideshow_transition;
double slideshow_timeout;
const char *slideshow_transition;
const char *editor;
const char *editor;
};
/*Ephoto Main Structure*/
struct _Ephoto
{
Evas *e;
Evas_Object *win;
Evas_Object *bg;
Evas_Object *layout;
Evas_Object *flow_browser;
Evas_Object *slideshow;
Evas_Object *slideshow_notify;
Evas_Object *thumb_browser;
Eina_List *entries;
Evas_Object *prefs_win;
Ephoto_State state;
Ephoto_Config *config;
Eet_Data_Descriptor *config_edd;
Ecore_Timer *config_save;
Evas_Object *win;
Evas_Object *bg;
Evas_Object *layout;
Evas_Object *thumb_browser;
Evas_Object *flow_browser;
Evas_Object *slideshow;
Eina_List *entries;
Eina_List *thumbs; /* live thumbs that need to be regenerated on changes */
int thumb_gen_size; /* pending value for thumb_regen */
struct {
Ecore_Timer *thumb_regen;
} timer;
Evas_Object *prefs_win;
Ephoto_State state;
Ephoto_Config *config;
};
struct _Ephoto_Entry
@ -127,6 +140,7 @@ struct _Ephoto_Entry
const char *path;
const char *basename; /* pointer inside path */
const char *label;
Ephoto *ephoto;
Elm_Gengrid_Item *item;
Eina_List *dir_files; /* if dir, here contain files with preview */
Eina_Bool dir_files_checked : 1;
@ -134,11 +148,9 @@ struct _Ephoto_Entry
Eina_Bool is_up : 1;
};
Ephoto_Entry *ephoto_entry_new(const char *path, const char *label);
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label);
void ephoto_entry_free(Ephoto_Entry *entry);
void ephoto_entries_free(Ephoto *em);
extern Ephoto *em;
void ephoto_entries_free(Ephoto *ephoto);
extern int __log_domain;
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)

@ -2,160 +2,160 @@
#define CONFIG_VERSION 5
static int _ephoto_config_load(Ephoto *em);
static int _ephoto_config_load(Ephoto *ephoto);
static Eina_Bool _ephoto_on_config_save(void *data);
static Eet_Data_Descriptor *edd = NULL;
static Ecore_Timer *save_timer = NULL;
Eina_Bool
ephoto_config_init(Ephoto *em)
ephoto_config_init(Ephoto *ephoto)
{
Eet_Data_Descriptor_Class eddc;
Eet_Data_Descriptor_Class eddc;
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 (!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;
}
em->config_edd = eet_data_descriptor_stream_new(&eddc);
if (!edd) edd = eet_data_descriptor_stream_new(&eddc);
#undef T
#undef D
#define T Ephoto_Config
#define D em->config_edd
#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, remember_directory, 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);
switch (_ephoto_config_load(em))
{
case 0:
/* Start a new config */
em->config->config_version = CONFIG_VERSION;
em->config->thumb_size = 256;
em->config->thumb_gen_size = 256;
em->config->remember_directory = 1;
em->config->slideshow_timeout = 4.0;
em->config->slideshow_transition =
eina_stringshare_add("fade");
em->config->editor =
eina_stringshare_add("gimp %s");
break;
case -1:
if (em->config->config_version < 2)
{
em->config->remember_directory = 1;
em->config->slideshow_timeout = 4.0;
em->config->slideshow_transition =
eina_stringshare_add("fade");
}
if (em->config->config_version < 3)
em->config->editor =
eina_stringshare_add("gimp %s");
if (em->config->config_version < 5)
em->config->thumb_gen_size = 256;
/* Incremental additions */
em->config->config_version = CONFIG_VERSION;
break;
default:
return EINA_TRUE;
}
ephoto_config_save(em, EINA_FALSE);
return EINA_TRUE;
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, remember_directory, 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);
switch (_ephoto_config_load(ephoto))
{
case 0:
/* Start a new config */
ephoto->config->config_version = CONFIG_VERSION;
ephoto->config->thumb_size = 256;
ephoto->config->thumb_gen_size = 256;
ephoto->config->remember_directory = 1;
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->remember_directory = 1;
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:
return EINA_TRUE;
}
ephoto_config_save(ephoto, EINA_FALSE);
return EINA_TRUE;
}
void
ephoto_config_save(Ephoto *em, Eina_Bool instant)
ephoto_config_save(Ephoto *ephoto, Eina_Bool instant)
{
if (em->config_save)
{
ecore_timer_del(em->config_save);
em->config_save = NULL;
}
if (instant)
_ephoto_on_config_save(em);
else
em->config_save = ecore_timer_add(5, _ephoto_on_config_save, em);
if (save_timer)
{
ecore_timer_del(save_timer);
save_timer = NULL;
}
if (instant)
_ephoto_on_config_save(ephoto);
else
save_timer = ecore_timer_add(5.0, _ephoto_on_config_save, ephoto);
}
void
ephoto_config_free(Ephoto *em)
ephoto_config_free(Ephoto *ephoto)
{
free(em->config);
em->config = NULL;
free(ephoto->config);
ephoto->config = NULL;
}
static int
_ephoto_config_load(Ephoto *em)
_ephoto_config_load(Ephoto *ephoto)
{
Eet_File *ef;
char buf[4096], buf2[4096];
snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME"));
ecore_file_mkpath(buf2);
snprintf(buf, sizeof(buf), "%s/ephoto.cfg", buf2);
ef = eet_open(buf, EET_FILE_MODE_READ);
if (!ef)
{
ephoto_config_free(em);
em->config = calloc(1, sizeof(Ephoto_Config));
return 0;
}
em->config = eet_data_read(ef, em->config_edd, "config");
eet_close(ef);
if (em->config->config_version > CONFIG_VERSION)
{
ephoto_config_free(em);
em->config = calloc(1, sizeof(Ephoto_Config));
return 0;
}
if (em->config->config_version < CONFIG_VERSION)
return -1;
return 1;
Eet_File *ef;
char buf[4096], buf2[4096];
snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME"));
ecore_file_mkpath(buf2);
snprintf(buf, sizeof(buf), "%s/ephoto.cfg", buf2);
ef = eet_open(buf, EET_FILE_MODE_READ);
if (!ef)
{
ephoto_config_free(ephoto);
ephoto->config = calloc(1, sizeof(Ephoto_Config));
return 0;
}
ephoto->config = eet_data_read(ef, edd, "config");
eet_close(ef);
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;
return 1;
}
static Eina_Bool
_ephoto_on_config_save(void *data)
{
Ephoto *em = data;
Eet_File *ef;
char buf[4096], buf2[4096];
int ret;
Ephoto *ephoto = data;
Eet_File *ef;
char buf[4096], buf2[4096];
snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME"));
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME"));
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
if (ef)
{
eet_data_write(ef, em->config_edd, "config", em->config, 1);
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
if (!ef) goto save_end;
if (eet_close(ef))
goto save_end;
eet_data_write(ef, edd, "config", ephoto->config, 1);
if (eet_close(ef)) goto save_end;
ret = ecore_file_mv(buf2, buf);
if (!ret)
goto save_end;
if (!ecore_file_mv(buf2, buf)) goto save_end;
DBG("Config saved");
ecore_file_unlink(buf2);
}
INF("Config saved");
save_end:
if (em->config_save)
ecore_timer_del(em->config_save);
em->config_save = NULL;
return ECORE_CALLBACK_CANCEL;
ecore_file_unlink(buf2);
if (save_timer)
{
ecore_timer_del(save_timer);
save_timer = NULL;
}
return ECORE_CALLBACK_CANCEL;
}

@ -104,7 +104,7 @@ ephoto_directory_thumb_add(Evas_Object *parent, Ephoto_Entry *entry)
EINA_SAFETY_ON_NULL_RETURN_VAL(_pending_dirs, NULL);
}
obj = ephoto_thumb_add(parent, NULL);
obj = ephoto_thumb_add(entry->ephoto, parent, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
if (!dt)

@ -4,6 +4,31 @@
#include <libexif/exif-data.h>
#endif
Evas_Object *
ephoto_flow_browser_add(Ephoto *ephoto, Evas_Object *parent)
{
Evas_Object *layout = elm_layout_add(parent);
EINA_SAFETY_ON_NULL_RETURN_VAL(layout, NULL);
if (!elm_layout_file_set(layout, THEME_FILE, "ephoto/flow/layout"))
{
evas_object_del(layout);
return NULL;
}
/* TODO */
return layout;
}
void
ephoto_flow_browser_image_set(Evas_Object *obj, const char *path)
{
/* TODO */
}
#if 0
/*Callbacks*/
static void _ephoto_go_back(void *data, Evas_Object *obj, void *event_info);
@ -418,7 +443,7 @@ _ephoto_go_slideshow(void *data, Evas_Object *obj, void *event_info)
Ephoto_Flow_Browser *ef = data;
// FIXME
//ephoto_hide_flow_browser();
ephoto_show_slideshow(1, ef->cur_image);
// TODO ephoto_show_slideshow(1, ef->cur_image);
elm_toolbar_item_unselect_all(ef->toolbar);
}
@ -528,3 +553,5 @@ _ephoto_zoom_regular_size(void *data, Evas_Object *obj, void *event)
Ephoto_Flow_Browser *ef = data;
elm_photocam_zoom_mode_set(ef->image, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
}
#endif

@ -1,49 +1,140 @@
#include "ephoto.h"
/*Ephoto Main Global*/
Ephoto *em;
static void
_ephoto_flow_browser_delete(void *data, Evas_Object *obj, void *event_info)
{
Ephoto *ephoto = data;
ephoto->flow_browser = NULL;
elm_layout_content_set
(ephoto->layout, "ephoto.swallow.content", ephoto->thumb_browser);
ephoto->state = EPHOTO_STATE_THUMB;
}
static Eina_List *_thumbs = NULL;
static Ecore_Timer *_thumb_gen_size_changed_timer = NULL;
static void
_ephoto_flow_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
{
/* remove thumb browser without deleting it */
elm_layout_content_unset(ephoto->layout, "ephoto.swallow.content");
/*Inline Callbacks*/
static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void *event_info);
ephoto->flow_browser = ephoto_flow_browser_add(ephoto, ephoto->layout);
ephoto_flow_browser_image_set(ephoto->flow_browser, entry->path);
elm_layout_content_set
(ephoto->layout, "ephoto.swallow.content", ephoto->flow_browser);
/* Objects Callbacks */
static void
_ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info)
evas_object_smart_callback_add
(ephoto->flow_browser, "back", _ephoto_flow_browser_delete, ephoto);
ephoto->state = EPHOTO_STATE_FLOW;
}
static void
_ephoto_thumb_browser_view(void *data, Evas_Object *obj, void *event_info)
{
em->thumb_browser = ephoto_thumb_browser_add(em->layout);
elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser);
evas_object_smart_callback_add(em->thumb_browser,
"selected",
_ephoto_thumb_browser_selected_cb,
NULL);
em->state = EPHOTO_STATE_THUMB;
em->flow_browser = NULL;
Ephoto *ephoto = data;
Ephoto_Entry *entry = event_info;
_ephoto_flow_browser_show(ephoto, entry);
}
static void
_ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void *event_info)
static void
_win_del(void *data, Evas *e, Evas_Object *o, void *event_info)
{
const char *file = event_info;
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);
evas_object_smart_callback_add(em->flow_browser,
"delete,request",
_ephoto_flow_browser_delete_cb,
NULL);
em->state = EPHOTO_STATE_FLOW;
Ephoto *ephoto = data;
if (ephoto->timer.thumb_regen) ecore_timer_del(ephoto->timer.thumb_regen);
free(ephoto);
}
/*Create the main ephoto window*/
void
ephoto_create_main_window(const char *directory, const char *image)
Evas_Object *
ephoto_window_add(const char *path)
{
Ephoto *ephoto = calloc(1, sizeof(Ephoto));
Ethumb_Client *client = elm_thumb_ethumb_client_get();
Evas_Object *ed;
Evas_Coord mw, mh, iw, ih;
const char *s;
EINA_SAFETY_ON_NULL_RETURN_VAL(ephoto, NULL);
ephoto->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
if (!ephoto->win)
{
free(ephoto);
return NULL;
}
evas_object_event_callback_add
(ephoto->win, EVAS_CALLBACK_DEL, _win_del, ephoto);
elm_win_autodel_set(ephoto->win, EINA_TRUE);
evas_object_show(ephoto->win);
if (!ephoto_config_init(ephoto))
{
evas_object_del(ephoto->win);
return NULL;
}
if ((ephoto->config->thumb_gen_size != 128) &&
(ephoto->config->thumb_gen_size != 256) &&
(ephoto->config->thumb_gen_size != 512))
ephoto_thumb_size_set(ephoto, ephoto->config->thumb_size);
else if (client)
ethumb_client_size_set
(client, ephoto->config->thumb_gen_size, ephoto->config->thumb_gen_size);
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);
ephoto->layout = elm_layout_add(ephoto->win);
if (!elm_layout_file_set(ephoto->layout, THEME_FILE, "ephoto/main/layout"))
{
ERR("could not load group 'ephoto/main/layout' from file %s",
THEME_FILE);
evas_object_del(ephoto->win);
return NULL;
}
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);
elm_win_resize_object_add(ephoto->win, ephoto->layout);
evas_object_show(ephoto->layout);
ephoto->thumb_browser = ephoto_thumb_browser_add(ephoto, ephoto->layout);
if (!ephoto->thumb_browser)
{
ERR("could not add thumb browser");
evas_object_del(ephoto->win);
return NULL;
}
elm_layout_content_set
(ephoto->layout, "ephoto.swallow.content", ephoto->thumb_browser);
ed = elm_layout_edje_get(ephoto->layout);
edje_object_size_min_get(ed, &mw, &mh);
edje_object_size_min_restricted_calc(ed, &mw, &mh, mw, mh);
if (mw < 1) mw = 320;
if (mh < 1) mh = 240;
s = edje_object_data_get(ed, "initial_size");
if ((!s) || (sscanf(s, "%d %d", &iw, &ih) != 2)) iw = ih = 0;
if (iw < mw) iw = mw;
if (ih < mh) ih = mh;
evas_object_resize(ephoto->win, iw, ih);
if (!path)
ephoto_thumb_browser_directory_set
(ephoto->thumb_browser, ephoto->config->directory);
else if (ecore_file_is_dir(path))
ephoto_thumb_browser_directory_set(ephoto->thumb_browser, path);
else
ERR("loading file to be done");
return ephoto->win;
}
#if 0
char current_directory[PATH_MAX];
Ethumb_Client *client = elm_thumb_ethumb_client_get();
@ -83,13 +174,6 @@ ephoto_create_main_window(const char *directory, const char *image)
/* Add the main layout to the window */
em->layout = elm_layout_add(em->win);
elm_layout_file_set(em->layout,
PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"ephoto/main/layout");
elm_win_resize_object_add(em->win, em->layout);
evas_object_size_hint_weight_set(em->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(em->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(em->layout);
/* Prepare the slideshow beforehand, in order
@ -162,25 +246,33 @@ _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info)
free(em);
elm_exit();
}
#endif
static Eina_Bool
_thumb_gen_size_changed_timer_cb(void *data)
{
const int gen_size = (long)data;
Ephoto *ephoto = data;
Ethumb_Client *client;
const Eina_List *l;
Evas_Object *o;
if (em->config->thumb_gen_size == gen_size) goto end;
if (ephoto->config->thumb_gen_size == ephoto->thumb_gen_size) goto end;
INF("thumbnail generation size changed from %d to %d",
em->config->thumb_gen_size, gen_size);
ephoto->config->thumb_gen_size, ephoto->thumb_gen_size);
client = elm_thumb_ethumb_client_get();
em->config->thumb_gen_size = gen_size;
ethumb_client_size_set(client, gen_size, gen_size);
if (!client)
{
DBG("no client yet, try again later");
return EINA_TRUE;
}
EINA_LIST_FOREACH(_thumbs, l, o)
ephoto->config->thumb_gen_size = ephoto->thumb_gen_size;
ethumb_client_size_set
(client, ephoto->thumb_gen_size, ephoto->thumb_gen_size);
EINA_LIST_FOREACH(ephoto->thumbs, l, o)
{
Ethumb_Thumb_Format format;
format = (long)evas_object_data_get(o, "ephoto_format");
@ -189,45 +281,39 @@ _thumb_gen_size_changed_timer_cb(void *data)
}
end:
_thumb_gen_size_changed_timer = NULL;
ephoto->timer.thumb_regen = NULL;
return EINA_FALSE;
}
void
ephoto_thumb_size_set(int size)
ephoto_thumb_size_set(Ephoto *ephoto, int size)
{
int gen_size;
if (em->config->thumb_size != size)
if (ephoto->config->thumb_size != size)
{
INF("thumbnail display size changed from %d to %d",
em->config->thumb_size, size);
em->config->thumb_size = size;
ephoto_config_save(em, EINA_FALSE);
ephoto->config->thumb_size, size);
ephoto->config->thumb_size = size;
ephoto_config_save(ephoto, EINA_FALSE);
}
if (size <= 128) gen_size = 128;
else if (size <= 256) gen_size = 256;
else gen_size = 512;
if (size <= 128) ephoto->thumb_gen_size = 128;
else if (size <= 256) ephoto->thumb_gen_size = 256;
else ephoto->thumb_gen_size = 512;
if (_thumb_gen_size_changed_timer)
{
ecore_timer_del(_thumb_gen_size_changed_timer);
_thumb_gen_size_changed_timer = NULL;
}
_thumb_gen_size_changed_timer = ecore_timer_add
(0.1, _thumb_gen_size_changed_timer_cb, (void*)(long)gen_size);
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);
}
static void
_thumb_del(void *data, Evas *e, Evas_Object *o, void *event_info)
{
_thumbs = eina_list_remove(_thumbs, o);
Ephoto *ephoto = data;
ephoto->thumbs = eina_list_remove(ephoto->thumbs, o);
}
Evas_Object *
ephoto_thumb_add(Evas_Object *parent, const char *path)
ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
{
Evas_Object *o;
@ -238,8 +324,8 @@ ephoto_thumb_add(Evas_Object *parent, const char *path)
if (path) ephoto_thumb_path_set(o, path);
elm_object_style_set(o, "noframe");
_thumbs = eina_list_append(_thumbs, o);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, NULL);
ephoto->thumbs = eina_list_append(ephoto->thumbs, o);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, ephoto);
return o;
}
@ -262,12 +348,13 @@ ephoto_thumb_path_set(Evas_Object *o, const char *path)
}
Ephoto_Entry *
ephoto_entry_new(const char *path, const char *label)
ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label)
{
Ephoto_Entry *entry;
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
entry = calloc(1, sizeof(Ephoto_Entry));
EINA_SAFETY_ON_NULL_RETURN_VAL(entry, NULL);
entry->ephoto = ephoto;
entry->path = eina_stringshare_add(path);
entry->basename = ecore_file_file_get(entry->path);
entry->label = eina_stringshare_add(label);
@ -286,8 +373,8 @@ ephoto_entry_free(Ephoto_Entry *entry)
}
void
ephoto_entries_free(Ephoto *em)
ephoto_entries_free(Ephoto *ephoto)
{
Ephoto_Entry *e;
EINA_LIST_FREE(em->entries, e) ephoto_entry_free(e);
Ephoto_Entry *entry;
EINA_LIST_FREE(ephoto->entries, entry) ephoto_entry_free(entry);
}

@ -1,5 +1,6 @@
#include "ephoto.h"
#if 0
static void _ephoto_preferences_pager_switch(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_preferences_hide(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_preferences_item_change(void *data, Evas_Object *obj, void *event_info);
@ -194,3 +195,5 @@ _ephoto_preferences_hide(void *data, Evas_Object *obj, void *event_info)
evas_object_hide(em->prefs_win);
evas_object_focus_set(em->thumb_browser, EINA_TRUE);
}
#endif

@ -1,5 +1,6 @@
#include "ephoto.h"
#if 0
static Evas_Object *_ephoto_get_image(void *data, Evas_Object *obj);
static void _ephoto_end_slideshow(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _ephoto_switch_fullscreen();
@ -147,3 +148,4 @@ _ephoto_end_slideshow(void *data, Evas *e, Evas_Object *obj, void *event_info)
ephoto_hide_slideshow();
}
#endif

@ -4,16 +4,19 @@
#define SLIDER_MIN 128
#define PARENT_DIR "Up"
#define THEME_FILE PACKAGE_DATA_DIR"/themes/default/ephoto.edj"
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
struct _Ephoto_Thumb_Browser
{
Ephoto *ephoto;
Evas_Object *layout;
Evas_Object *edje;
Evas_Object *grid;
Eio_File *ls;
struct {
Ecore_Job *change_dir;
} job;
};
static char *
@ -40,7 +43,7 @@ _ephoto_thumb_dir_icon_get(void *data, Evas_Object *obj, const char *part)
f = eina_list_nth(e->dir_files, n);
if (f)
return ephoto_thumb_add(obj, f);
return ephoto_thumb_add(e->ephoto, obj, f);
if (e->dir_files_checked)
return NULL;
@ -70,7 +73,7 @@ static Evas_Object *
_ephoto_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part)
{
Ephoto_Entry *e = data;
return ephoto_thumb_add(obj, e->path);
return ephoto_thumb_add(e->ephoto, obj, e->path);
}
static void
@ -118,7 +121,7 @@ _ephoto_populate_main(void *data, const Eina_File_Direct_Info *info)
Edje_Message_Int msg;
Ephoto_Entry *e;
e = ephoto_entry_new(info->path, info->path + info->name_start);
e = ephoto_entry_new(tb->ephoto, info->path, info->path + info->name_start);
if (info->dirent->d_type == DT_DIR) e->is_dir = EINA_TRUE;
else if (info->dirent->d_type == DT_REG) e->is_dir = EINA_FALSE;
else e->is_dir = !_ephoto_eina_file_direct_info_image_useful(info);
@ -138,9 +141,9 @@ _ephoto_populate_main(void *data, const Eina_File_Direct_Info *info)
return;
}
em->entries = eina_list_append(em->entries, e);
tb->ephoto->entries = eina_list_append(tb->ephoto->entries, e);
msg.val = eina_list_count(em->entries);
msg.val = eina_list_count(tb->ephoto->entries);
edje_object_message_send(tb->edje, EDJE_MESSAGE_INT, 1, &msg);
DBG("populate add '%s'", e->path);
}
@ -182,27 +185,34 @@ _ephoto_populate_error(int error, void *data)
static void
_ephoto_populate_entries(Ephoto_Thumb_Browser *tb)
{
Ephoto_Entry *e;
Edje_External_Param param;
char *parent_dir;
DBG("populate from '%s'", em->config->directory);
DBG("populate from '%s'", tb->ephoto->config->directory);
elm_gengrid_clear(tb->grid);
ephoto_entries_free(em);
ephoto_entries_free(tb->ephoto);
parent_dir = ecore_file_dir_get(em->config->directory);
parent_dir = ecore_file_dir_get(tb->ephoto->config->directory);
if (parent_dir)
{
e = ephoto_entry_new(parent_dir, PARENT_DIR);
Ephoto_Entry *e = ephoto_entry_new(tb->ephoto, parent_dir, PARENT_DIR);
free(parent_dir);
EINA_SAFETY_ON_NULL_RETURN(e);
e->is_up = EINA_TRUE;
e->is_dir = EINA_TRUE;
e->item = elm_gengrid_item_append
(tb->grid, &_ephoto_thumb_up_class, e, NULL, NULL);
/* does not go into em->entries as it is always the first - no sort! */
/* does not go into entries as it is always the first - no sort! */
}
param.name = "text";
param.type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
param.s = tb->ephoto->config->directory;
edje_object_part_external_param_set(tb->edje, "ephoto.location", &param);
edje_object_signal_emit(tb->edje, "location,set", "ephoto");
edje_object_signal_emit(tb->edje, "populate,start", "ephoto");
tb->ls = eio_file_direct_ls(em->config->directory,
tb->ls = eio_file_direct_ls(tb->ephoto->config->directory,
_ephoto_populate_filter,
_ephoto_populate_main,
_ephoto_populate_end,
@ -210,16 +220,53 @@ _ephoto_populate_entries(Ephoto_Thumb_Browser *tb)
tb);
}
static void
_ephoto_thumb_change_dir(void *data)
{
Ephoto_Thumb_Browser *tb = data;
tb->job.change_dir = NULL;
_ephoto_populate_entries(tb);
}
static void
_ephoto_thumb_selected(void *data, Evas_Object *o, void *event_info)
{
Ephoto_Thumb_Browser *tb = data;
Elm_Gengrid_Item *it = event_info;
Ephoto_Entry *e = elm_gengrid_item_data_get(it);
if (e->is_dir)
ephoto_thumb_browser_directory_set(tb->layout, e->path);
else
evas_object_smart_callback_call(tb->layout, "view", e);
}
static void
_changed_dir(void *data, Evas_Object *o, const char *emission, const char *source)
{
Ephoto_Thumb_Browser *tb = data;
Edje_External_Param p;
p.name = "text";
p.type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
p.s = NULL;
if (!edje_object_part_external_param_get(tb->edje, "ephoto.location", &p))
return;
ephoto_thumb_browser_directory_set(tb->layout, p.s);
}
static void
_layout_del(void *data, Evas *e, Evas_Object *o, void *event_info)
{
Ephoto_Thumb_Browser *tb = data;
if (tb->ls) eio_file_cancel(tb->ls);
if (tb->job.change_dir) ecore_job_del(tb->job.change_dir);
free(tb);
}
Evas_Object *
ephoto_thumb_browser_add(Evas_Object *parent)
ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
{
Evas_Object *layout = elm_layout_add(parent);
Ephoto_Thumb_Browser *tb;
@ -228,8 +275,13 @@ ephoto_thumb_browser_add(Evas_Object *parent)
tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
EINA_SAFETY_ON_NULL_GOTO(tb, error);
tb->ephoto = ephoto;
tb->layout = layout;
tb->edje = elm_layout_edje_get(layout);
evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _layout_del, tb);
evas_object_data_set(layout, "thumb_browser", tb);
edje_object_signal_callback_add
(tb->edje, "location,changed", "ephoto", _changed_dir, tb);
if (!elm_layout_file_set(layout, THEME_FILE, "ephoto/browser/layout"))
{
@ -245,21 +297,16 @@ ephoto_thumb_browser_add(Evas_Object *parent)
elm_gengrid_align_set(tb->grid, 0.5, 0.5);
elm_gengrid_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE);
elm_gengrid_item_size_set
(tb->grid, em->config->thumb_size, em->config->thumb_size);
(tb->grid, tb->ephoto->config->thumb_size, tb->ephoto->config->thumb_size);
evas_object_size_hint_align_set
(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set
(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
/*
evas_object_smart_callback_add
(tb->grid, "selected", _ephoto_thumb_selected, tb);
evas_object_smart_callback_add
(tb->grid, "clicked", _ephoto_thumb_clicked, tb);
*/
elm_layout_content_set(tb->layout, "ephoto.thumb.swallow", tb->grid);
_ephoto_populate_entries(tb);
elm_layout_content_set(tb->layout, "ephoto.thumb.swallow", tb->grid);
return layout;
@ -268,531 +315,13 @@ ephoto_thumb_browser_add(Evas_Object *parent)
return NULL;
}
#if 0
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
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;
Elm_Toolbar_Item *view_large;
Eio_File *list;
};
#define THUMB_RATIO (256 / 192)
/*Callbacks*/
static void _ephoto_slider_changed(void *data, Evas_Object *obj, void *event_info);
static char *_ephoto_get_label(void *data, Evas_Object *obj, const char *part);
static Evas_Object *_ephoto_get_icon(void *data, Evas_Object *obj, const char *part);
static Eina_Bool _ephoto_get_state(void *data, Evas_Object *obj, const char *part);
static void _ephoto_grid_del(void *data, Evas_Object *obj);
static void _ephoto_thumb_clicked_job(void *data);
static void _ephoto_thumb_clicked(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_thumb_selected(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_window(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_view_slideshow(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_preferences(void *data, Evas_Object *obj, void *event_info);
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);
static void _ephoto_zoom_in(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_zoom_out(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_zoom_regular_size(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory)