ephoto core simplification - part 1 (UNFINISHED!!!!)

I'm rewriting parts of ephoto to simplify it, one of the things is to
avoid lots of nesting of layouts to get a simple preview
image.

So far just the thumb directory is done to the point it shows the
contents of a directory, it will do nothing on selection and
clicks. There is no toolbar either, as this is going to be replaced
later on.

EFL bugs so far:
 * eio_file_cancel() is not playing nice with ecore_pipe, with errors like: "ecore_pipe.c:517 _ecore_pipe_read() An unhandled error (ret: -1 errno: 9)occurred while reading from the pipe the length"

 * evas/edje map is broken WRT clipping! if I have map { on: 1;
   rotation.z: 10;} and this part is clipped to some other part, the
   clipper will be ignored!

Sorry, but I couldn't finish it now, trying to do it later today and
tomorrow. I still need to add the elm_genlist_item_prepend(),
elm_genlist_item_insert_before() and elm_genlist_item_insert_after()
to get the sorted insert to work.



SVN revision: 53237
v-1.6.0
Gustavo Sverzut Barbieri 13 years ago
parent 73d91bfa90
commit e21422bf65
  1. 980
      data/themes/default/ephoto.edc
  2. 2
      src/bin/ephoto.c
  3. 28
      src/bin/ephoto.h
  4. 4
      src/bin/ephoto_config.c
  5. 212
      src/bin/ephoto_directory_thumb.c
  6. 10
      src/bin/ephoto_flow_browser.c
  7. 59
      src/bin/ephoto_main.c
  8. 11
      src/bin/ephoto_preferences.c
  9. 2
      src/bin/ephoto_slideshow.c
  10. 482
      src/bin/ephoto_thumb_browser.c

@ -118,302 +118,607 @@ collections
}
}
group
{
name: "elm/gengrid/item/ephoto/default";
data.item: "labels" "elm.text";
data.item: "icons" "elm.swallow.icon elm.swallow.end";
images
{
image: "bt_sm_base1.png" COMP;
image: "bt_sm_shine.png" COMP;
image: "bt_sm_hilight.png" COMP;
}
parts
{
part
{
name: "event";
type: RECT;
repeat_events: 1;
description
{
state: "default" 0.0;
color: 0 0 0 0;
}
}
part
{
name: "bg";
clip_to: "disclip";
mouse_events: 0;
description
{
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1
{
relative: 0.0 0.0;
offset: -5 -5;
}
rel2
{
relative: 1.0 1.0;
offset: 4 4;
}
image
{
normal: "bt_sm_base1.png";
border: 6 6 6 6;
}
image.middle: SOLID;
}
description
{
state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
rel1
{
relative: 0.0 0.0;
offset: -2 -2;
}
rel2
{
relative: 1.0 1.0;
offset: 1 1;
}
}
}
part
{
name: "elm.swallow.pad";
type: SWALLOW;
description
{
state: "default" 0.0;
fixed: 1 0;
align: 0.0 0.5;
rel1
{
relative: 0.0 1.0;
offset: 0 -10;
}
rel2
{
to_y: "elm.text";
relative: 0.0 0.0;
offset: -1 -1;
}
}
}
part
{
name: "elm.swallow.icon";
clip_to: "disclip";
type: SWALLOW;
description
{
state: "default" 0.0;
fixed: 1 0;
align: 0.5 0.5;
rel1
{
relative: 0.0 0.0;
offset: -1 4;
}
rel2
{
to_y: "elm.swallow.pad";
relative: 1.0 0.0;
offset: -1 -5;
}
}
}
part
{
name: "elm.swallow.end";
clip_to: "disclip";
type: SWALLOW;
description
{
state: "default" 0.0;
fixed: 1 0;
align: 1.0 0.0;
aspect: 1.0 1.0;
aspect_preference: HORIZONTAL;
rel1
{
relative: 1.0 0.0;
offset: -5 -5;
}
rel2
{
relative: 1.0 1.0;
offset: 5 5;
}
}
}
part
{
name: "elm.text";
clip_to: "disclip";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
scale: 1;
description
{
state: "default" 0.0;
rel1
{
relative: 0.0 1.0;
offset: 0 -25;
}
rel2
{
relative: 1.0 1.0;
offset: -1 -1;
}
color: 0 0 0 255;
color3: 0 0 0 0;
text
{
font: "Sans";
size: 10;
min: 0 1;
align: 0.5 0.0;
}
}
description
{
state: "selected" 0.0;
inherit: "default" 0.0;
color: 224 224 224 255;
color3: 0 0 0 64;
}
}
part
{
name: "fg1";
clip_to: "disclip";
mouse_events: 0;
description
{
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.to: "bg";
rel2.relative: 1.0 0.5;
rel2.to: "bg";
image
{
normal: "bt_sm_hilight.png";
border: 6 6 6 0;
}
}
description
{
state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part
{
name: "fg2";
clip_to: "disclip";
mouse_events: 0;
description
{
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.to: "bg";
rel2.to: "bg";
image
{
normal: "bt_sm_shine.png";
border: 6 6 6 0;
}
}
description
{
state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part
{
name: "disclip";
type: RECT;
description
{
state: "default" 0.0;
rel1.to: "bg";
rel2.to: "bg";
}
description
{
state: "disabled" 0.0;
inherit: "default" 0.0;
color: 255 255 255 64;
}
}
}
programs
{
// signal: elm,state,%s,active
// a "check" item named %s went active
// signal: elm,state,%s,passive
// a "check" item named %s went passive
// default is passive
program
{
name: "go_active";
signal: "elm,state,selected";
source: "elm";
action: STATE_SET "selected" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
target: "elm.text";
}
program
{
name: "go_passive";
signal: "elm,state,unselected";
source: "elm";
action: STATE_SET "default" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
target: "elm.text";
transition: LINEAR 0.1;
}
program
{
name: "go_disabled";
signal: "elm,state,disabled";
source: "elm";
action: STATE_SET "disabled" 0.0;
target: "disclip";
}
program
{
name: "go_enabled";
signal: "elm,state,enabled";
source: "elm";
action: STATE_SET "default" 0.0;
target: "disclip";
}
}
}
group { name: "elm/gengrid/item/up/ephoto";
data.item: "labels" "elm.text.label";
images {
set { name: "up";
image {
image: "up-128.png" COMP;
size: 1 1 128 128;
}
image {
image: "up-256.png" COMP;
size: 129 129 256 256;
}
image {
image: "up-512.png" COMP;
size: 257 257 512 512;
}
}
image: "bt_sm_base1.png" COMP;
image: "bt_sm_shine.png" COMP;
image: "bt_sm_hilight.png" COMP;
}
parts {
part { name: "event";
type: RECT;
repeat_events: 1;
description { state: "default" 0.0;
color: 0 0 0 0;
}
}
part { name: "bg";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2.offset: 2 2;
image { normal: "bt_sm_base1.png";
border: 6 6 6 6;
}
image.middle: SOLID;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part { name: "img";
type: IMAGE;
mouse_events: 0;
description {
state: "default" 0.0;
aspect_preference: BOTH;
aspect: 1.0 1.0;
image.normal: "up";
rel2 { to_y: "elm.text.label";
relative: 1.0 0.0;
offset: -1 -2;
}
}
}
part { name: "elm.text.label";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
color: 0 0 0 255;
color3: 0 0 0 0;
align: 0.5 1.0;
rel1 { relative: 0.0 1.0;
offset: 2 -25;
}
rel2 { relative: 1.0 1.0;
offset: -3 -3;
}
text { font: "Sans";
size: 10;
min: 0 1;
align: 0.5 0.0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
color: 224 224 224 255;
color3: 0 0 0 64;
}
}
part { name: "fg1";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2 { relative: 1.0 0.5;
offset: 2 -1;
}
image { normal: "bt_sm_hilight.png";
border: 6 6 6 0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part { name: "fg2";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2.offset: 2 2;
image { normal: "bt_sm_shine.png";
border: 6 6 6 0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
programs {
program {
signal: "elm,state,selected";
source: "elm";
action: STATE_SET "selected" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
target: "elm.text.label";
}
program {
signal: "elm,state,unselected";
source: "elm";
action: STATE_SET "default" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
target: "elm.text.label";
transition: LINEAR 0.1;
}
}
}
}
group { name: "elm/gengrid/item/file/ephoto";
data {
item: "icons" "elm.swallow.icon";
item: "labels" "elm.text.label";
}
images {
image: "bt_sm_base1.png" COMP;
image: "bt_sm_shine.png" COMP;
image: "bt_sm_hilight.png" COMP;
}
parts {
part { name: "event";
type: RECT;
repeat_events: 1;
description { state: "default" 0.0;
color: 0 0 0 0;
}
}
part { name: "bg";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2.offset: 2 2;
image { normal: "bt_sm_base1.png";
border: 6 6 6 6;
}
image.middle: SOLID;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part { name: "border-shadow";
type: IMAGE;
mouse_events: 0;
description { state: "default" 0.0;
rel1 { to: "elm.swallow.icon";
offset: -18 -18;
}
rel2 { to_x: "elm.swallow.icon";
to_y: "elm.text.label";
offset: 17 17;
}
image { normal: "thumb_shadow.png";
border: 17 17 17 17;
middle: NONE;
}
}
}
part { name: "border";
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
rel1 { to: "border-shadow";
offset: 16 16;
}
rel2 { to: "border-shadow";
offset: -15 -15;
}
}
}
part { name: "elm.swallow.icon";
type: SWALLOW;
mouse_events: 0;
description {
state: "default" 0.0;
aspect_preference: BOTH;
aspect: 1.0 1.0;
rel1.offset: 0 8;
rel2 { to_y: "elm.text.label";
relative: 1.0 0.0;
offset: -1 -2;
}
}
}
part { name: "elm.text.label";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
color: 0 0 0 255;
color3: 0 0 0 0;
align: 0.5 1.0;
rel1 { relative: 0.0 1.0;
offset: 2 -30;
}
rel2 { relative: 1.0 1.0;
offset: -3 -15;
}
text { font: "Sans";
size: 10;
min: 0 1;
align: 0.5 0.0;
}
}
}
part { name: "fg1";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2 { relative: 1.0 0.5;
offset: 2 -1;
}
image { normal: "bt_sm_hilight.png";
border: 6 6 6 0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part { name: "fg2";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2.offset: 2 2;
image { normal: "bt_sm_shine.png";
border: 6 6 6 0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
programs {
program {
signal: "elm,state,selected";
source: "elm";
action: STATE_SET "selected" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
}
program {
signal: "elm,state,unselected";
source: "elm";
action: STATE_SET "default" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
transition: LINEAR 0.1;
}
}
}
}
group { name: "elm/gengrid/item/dir/ephoto";
data {
item: "icons" "elm.swallow.icon.1 elm.swallow.icon.2 elm.swallow.icon.3 elm.swallow.icon.4";
item: "labels" "elm.text.label";
item: "states" "have_files";
}
images {
set { name: "directory";
image {
image: "directory-128.png" COMP;
size: 1 1 128 128;
}
image {
image: "directory-256.png" COMP;
size: 129 129 256 256;
}
image {
image: "directory-512.png" COMP;
size: 257 257 512 512;
}
}
image: "bt_sm_base1.png" COMP;
image: "bt_sm_shine.png" COMP;
image: "bt_sm_hilight.png" COMP;
}
parts {
part { name: "event";
type: RECT;
repeat_events: 1;
description { state: "default" 0.0;
color: 0 0 0 0;
}
}
part { name: "bg";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2.offset: 2 2;
image { normal: "bt_sm_base1.png";
border: 6 6 6 6;
}
image.middle: SOLID;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part { name: "img";
type: IMAGE;
mouse_events: 0;
description {
state: "default" 0.0;
aspect_preference: BOTH;
aspect: 1.0 1.0;
image.normal: "directory";
rel2 { to_y: "elm.text.label";
relative: 1.0 0.0;
offset: -1 -2;
}
}
}
part { name: "have-files-clipper";
type: RECT;
description { state: "default" 0.0;
color: 255 255 255 0;
visible: 0;
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
color: 255 255 255 255;
visible: 1;
}
}
part { name: "icon_box_margin";
type: RECT;
mouse_events: 0;
clip_to: "have-files-clipper";
description {
state: "default" 0.0;
color: 0 0 0 255;
rel1 { to: "icon_box";
offset: -1 -1;
}
rel2 { to: "icon_box";
offset: 0 0;
}
}
}
part { name: "icon_box";
type: RECT;
mouse_events: 0;
clip_to: "have-files-clipper";
description {
state: "default" 0.0;
color: 255 255 255 255;
align: 1.0 1.0;
min: 32 32;
rel1 {
relative: 0.25 0.25;
offset: 0 0;
}
rel2 {
relative: 1.0 0.0;
offset: -11 -4;
to_y: "elm.text.label";
}
}
}
part { name: "elm.swallow.icon.1";
type: SWALLOW;
mouse_events: 0;
clip_to: "have-files-clipper";
description {
state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
to: "icon_box";
}
rel2 {
relative: 0.5 0.5;
offset: -1 -1;
to: "icon_box";
}
}
}
part { name: "elm.swallow.icon.2";
type: SWALLOW;
mouse_events: 0;
clip_to: "have-files-clipper";
description {
state: "default" 0.0;
rel1 {
relative: 0.5 0.0;
to: "icon_box";
}
rel2 {
relative: 1.0 0.5;
offset: -1 -1;
to: "icon_box";
}
}
}
part { name: "elm.swallow.icon.3";
type: SWALLOW;
mouse_events: 0;
clip_to: "have-files-clipper";
description {
state: "default" 0.0;
rel1 {
relative: 0.0 0.5;
to: "icon_box";
}
rel2 {
relative: 0.5 1.0;
offset: -1 -1;
to: "icon_box";
}
}
}
part { name: "elm.swallow.icon.4";
type: SWALLOW;
mouse_events: 0;
clip_to: "have-files-clipper";
description {
state: "default" 0.0;
rel1 {
relative: 0.5 0.5;
to: "icon_box";
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
to: "icon_box";
}
}
}
part { name: "elm.text.label";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
color: 0 0 0 255;
color3: 0 0 0 0;
align: 0.5 1.0;
rel1 { relative: 0.0 1.0;
offset: 2 -30;
}
rel2 { relative: 1.0 1.0;
offset: -3 -15;
}
text { font: "Sans";
size: 10;
min: 0 1;
align: 0.5 0.0;
}
}
}
part { name: "fg1";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2 { relative: 1.0 0.5;
offset: 2 -1;
}
image { normal: "bt_sm_hilight.png";
border: 6 6 6 0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part { name: "fg2";
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1.offset: -3 -3;
rel2.offset: 2 2;
image { normal: "bt_sm_shine.png";
border: 6 6 6 0;
}
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
programs {
program {
signal: "elm,state,selected";
source: "elm";
action: STATE_SET "selected" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
}
program {
signal: "elm,state,unselected";
source: "elm";
action: STATE_SET "default" 0.0;
target: "bg";
target: "fg1";
target: "fg2";
transition: LINEAR 0.1;
}
program {
signal: "elm,state,have_files,active";
source: "elm";
action: STATE_SET "visible" 0.0;
target: "have-files-clipper";
}
}
}
}
group
{
name: "ephoto/main/layout";
@ -575,89 +880,6 @@ collections
}
}
group { name: "/ephoto/directory/thumb/layout";
data.item: "thumbs" "3";
parts {
part { name: "ephoto.swallow.thumb1";
type: SWALLOW;
description {
state: "default" 0.0;
map.on: 0;
}
}
part { name: "ephoto.swallow.thumb2";
type: SWALLOW;
description {
state: "default" 0.0;
map {
on: 1;
rotation.z: 20;
}
}
}
part { name: "ephoto.swallow.thumb3";
type: SWALLOW;
description {
state: "default" 0.0;
map {
on: 1;
rotation.z: -20;
}
}
}
}
programs {
program { name: "load";
signal: "load";
script {
new Float:val;
custom_state(PART:"ephoto.swallow.thumb3", "default", 0.0);
custom_state(PART:"ephoto.swallow.thumb2", "default", 0.0);
val = randf();
val = 40 * val - 20;
set_state_val(PART:"ephoto.swallow.thumb3", STATE_MAP_ROT_Z, val);
val = randf();
val = 40 * val - 20;
set_state_val(PART:"ephoto.swallow.thumb2", STATE_MAP_ROT_Z, val);
set_state(PART:"ephoto.swallow.thumb2", "custom", 0.0);
set_state(PART:"ephoto.swallow.thumb3", "custom", 0.0);
}
}
}
}
group { name: "/ephoto/directory/up";
images {
set { name: "up";
image {
image: "up-128.png" COMP;
size: 1 1 128 128;
}
image {
image: "up-256.png" COMP;
size: 129 129 256 256;
}
image {
image: "up-512.png" COMP;
size: 257 257 512 512;
}
}
}
parts {
part { name: "img";
type: IMAGE;
mouse_events: 0;
description {
state: "default" 0.0;
aspect_preference: BOTH;
aspect: 1.0 1.0;
image.normal: "up";
}
}
}
}
group { name: "/ephoto/directory/no-preview";
images {

@ -15,6 +15,8 @@ main(int argc, char **argv)
elm_need_ethumb();
elm_init(argc, argv);
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR"/themes/default/ephoto.edj");
if (!efreet_mime_init())
fprintf(stderr, "Could not init efreet_mime!\n");

@ -24,6 +24,7 @@
typedef struct _Ephoto_Config Ephoto_Config;
typedef struct _Ephoto Ephoto;
typedef struct _Ephoto_Entry Ephoto_Entry;
typedef enum _Ephoto_State Ephoto_State;
typedef enum _Ephoto_Orient Ephoto_Orient;
@ -32,6 +33,7 @@ typedef enum _Ephoto_Orient Ephoto_Orient;
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);
void ephoto_thumb_path_set(Evas_Object *o, const char *path);
/* Configuration */
@ -57,11 +59,10 @@ void ephoto_hide_slideshow(void);
void ephoto_delete_slideshow(void);
/* Ephoto Directory Thumb */
Evas_Object *ephoto_directory_thumb_add(Evas_Object *parent, const char *path);
Evas_Object *ephoto_directory_thumb_add(Evas_Object *parent, Ephoto_Entry *e);
/*Ephoto Thumb Browser*/
Evas_Object *ephoto_create_thumb_browser(Evas_Object *parent);
void ephoto_populate_thumbnails(Evas_Object *obj);
Evas_Object *ephoto_thumb_browser_add(Evas_Object *parent);
/* 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.
@ -97,8 +98,6 @@ struct _Ephoto_Config
const char *slideshow_transition;
const char *editor;
int sort_images;
};
/*Ephoto Main Structure*/
@ -112,8 +111,9 @@ struct _Ephoto
Evas_Object *slideshow;
Evas_Object *slideshow_notify;
Evas_Object *thumb_browser;
Eina_List *entries;
Evas_Object *prefs_win;
Eina_List *images;
Ephoto_State state;
Ephoto_Config *config;
@ -122,6 +122,22 @@ struct _Ephoto
Ecore_Timer *config_save;
};
struct _Ephoto_Entry
{
const char *path;
const char *basename; /* pointer inside path */
const char *label;
Elm_Gengrid_Item *item;
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;
};
Ephoto_Entry *ephoto_entry_new(const char *path, const char *label);
void ephoto_entry_free(Ephoto_Entry *entry);
void ephoto_entries_free(Ephoto *em);
extern Ephoto *em;
extern int __log_domain;

@ -30,7 +30,6 @@ ephoto_config_init(Ephoto *em)
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);
C_VAL(D, T, sort_images, EET_T_INT);
switch (_ephoto_config_load(em))
{
@ -45,7 +44,6 @@ ephoto_config_init(Ephoto *em)
eina_stringshare_add("fade");
em->config->editor =
eina_stringshare_add("gimp %s");
em->config->sort_images = 1;
break;
case -1:
if (em->config->config_version < 2)
@ -58,8 +56,6 @@ ephoto_config_init(Ephoto *em)
if (em->config->config_version < 3)
em->config->editor =
eina_stringshare_add("gimp %s");
if (em->config->config_version < 4)
em->config->sort_images = 1;
if (em->config->config_version < 5)
em->config->thumb_gen_size = 256;

@ -1,24 +1,35 @@
#include "ephoto.h"
typedef struct _Directory_Thumb Directory_Thumb;
struct _Directory_Thumb
typedef struct _Ephoto_Directory_Thumb Ephoto_Directory_Thumb;
struct _Ephoto_Directory_Thumb
{
Evas_Object *layout;
Eio_File *file;
Eina_List *frames;
const char *path;
int theme_thumb_count;
Eio_File *ls;
Eina_List *objs;
Ephoto_Entry *entry;
};
static Eina_Hash *_pending_dirs = NULL;
static void
_layout_del(void *data, Evas *e, Evas_Object *layout, void *event_info)
_ephoto_directory_thumb_free(Ephoto_Directory_Thumb *dt)
{
Directory_Thumb *dt = data;
if (dt->file) eio_file_cancel(dt->file);
eina_list_free(dt->frames);
eina_stringshare_del(dt->path);
if (dt->ls) eio_file_cancel(dt->ls);
eina_hash_del(_pending_dirs, dt->entry->path, dt);
free(dt);
if (!eina_hash_population(_pending_dirs))
{
eina_hash_free(_pending_dirs);
_pending_dirs = NULL;
}
}
static void
_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Ephoto_Directory_Thumb *dt = data;
dt->objs = eina_list_remove(dt->objs, obj);
if (!dt->objs) _ephoto_directory_thumb_free(dt);
}
static Eina_Bool
@ -30,107 +41,104 @@ _populate_filter(void *data, const Eina_File_Direct_Info *info)
static void
_populate_end(void *data)
{
Directory_Thumb *dt = (Directory_Thumb*) data;
dt->file = NULL;
Ephoto_Directory_Thumb *dt = data;
Evas_Object *obj;
dt->ls = NULL;
EINA_LIST_FREE(dt->objs, obj)
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, _obj_del, dt);
dt->entry->dir_files_checked = EINA_TRUE;
if (dt->entry->item)
elm_gengrid_item_update(dt->entry->item);
_ephoto_directory_thumb_free(dt);
}
static void
_populate_error(int error, void *data)
{
Directory_Thumb *dt = (Directory_Thumb*)data;
dt->file = NULL;
Ephoto_Directory_Thumb *dt = data;
if (error) ERR("could not populate: %s", strerror(error));
_populate_end(dt);
}
static void
_populate_main(void *data, const Eina_File_Direct_Info *info)
{
Evas_Object *frame, *image;
int position;
Directory_Thumb *dt = data;
char buf[4096];
position = eina_list_count(dt->frames);
if (position > dt->theme_thumb_count)
{
if (dt->file)
{
eio_file_cancel(dt->file);
dt->file = NULL;
}
return;
}
frame = elm_layout_add(dt->layout);
if (!elm_layout_file_set
(frame, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb"))
ERR("could not load group '/ephoto/thumb' from file '%s'",
PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(frame);
image = ephoto_thumb_add(frame, info->path);
elm_object_style_set(image, "ephoto");
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_layout_content_set(frame, "ephoto.swallow.content", image);
snprintf(buf, sizeof(buf), "ephoto.swallow.thumb%d", position);
elm_layout_content_set(dt->layout, buf, frame);
dt->frames = eina_list_append(dt->frames, frame);
Ephoto_Directory_Thumb *dt = data;
Evas_Object *obj;
const char *file;
if (!dt->objs) return;
obj = dt->objs->data;
file = eina_stringshare_add(info->path);
DBG("populate thumbnail %p with path '%s'", obj, file);
dt->objs = eina_list_remove_list(dt->objs, dt->objs);
dt->entry->dir_files = eina_list_append(dt->entry->dir_files, file);
ephoto_thumb_path_set(obj, file);
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, _obj_del, dt);
if ((!dt->objs) && (dt->ls))
{
eio_file_cancel(dt->ls);
dt->ls = NULL;
}
}
Evas_Object *
ephoto_directory_thumb_add(Evas_Object *parent, const char *path)
ephoto_directory_thumb_add(Evas_Object *parent, Ephoto_Entry *entry)
{
Directory_Thumb *dt;
Evas_Object *thumb, *placeholder;
const char *s;
dt = calloc(1, sizeof( Directory_Thumb));
dt->path = eina_stringshare_add(path);
dt->layout = elm_layout_add(parent);
if (!elm_layout_file_set
(dt->layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"/ephoto/directory/thumb/layout"))
ERR("could not load group '/ephoto/directory/thumb/layout' from file '%s'",
PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
evas_object_size_hint_weight_set
(dt->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(dt->layout);
evas_object_data_set(dt->layout, "dt", dt);
evas_object_event_callback_add
(dt->layout, EVAS_CALLBACK_DEL, _layout_del, dt);
thumb = elm_layout_add(dt->layout);
if (!elm_layout_file_set
(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"/ephoto/thumb/no_border"))
ERR("could not load group '/ephoto/thumb/no_border' from file '%s'",
PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
//evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_layout_content_set(dt->layout, "ephoto.swallow.thumb1", thumb);
placeholder = edje_object_add(evas_object_evas_get(dt->layout));
edje_object_file_set
(placeholder, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"/ephoto/directory/no-preview");
elm_layout_content_set(thumb, "ephoto.swallow.content", placeholder);
s = edje_object_data_get(elm_layout_edje_get(dt->layout), "thumbs");
if (s)
{
dt->theme_thumb_count = atoi(s);
if (dt->theme_thumb_count > 0)
dt->file = eio_file_direct_ls(path,
_populate_filter,
_populate_main,
_populate_end,
_populate_error,
dt);
}
return dt->layout;
Ephoto_Directory_Thumb *dt;
Evas_Object *obj;
if (_pending_dirs)
dt = eina_hash_find(_pending_dirs, entry->path);
else
{
dt = NULL;
_pending_dirs = eina_hash_stringshared_new(NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(_pending_dirs, NULL);
}
obj = ephoto_thumb_add(parent, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
if (!dt)
{
dt = calloc(1, sizeof(Ephoto_Directory_Thumb));
if (!dt)
{
ERR("could not allocate memory for Ephoto_Directory_Thumb");
evas_object_del(obj);
return NULL;
}
dt->entry = entry;
dt->ls = eio_file_direct_ls(entry->path,
_populate_filter,
_populate_main,
_populate_end,
_populate_error,
dt);
if (!dt->ls)
{
ERR("could not create eio_file_direct_ls(%s)", entry->path);
evas_object_del(obj);
free(dt);
return NULL;
}
eina_hash_add(_pending_dirs, entry->path, dt);
DBG("start thread to lookup inside '%s' for thumbnails.", entry->path);
}
else
DBG("thread already started, wait for thumbnails in '%s'", entry->path);
dt->objs = eina_list_append(dt->objs, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _obj_del, dt);
return obj;
}

@ -256,7 +256,7 @@ ephoto_flow_browser_image_set(Evas_Object *obj, const char *current_image)
evas_object_event_callback_add(ef->flow_browser, EVAS_CALLBACK_MOUSE_WHEEL,
_ephoto_mouse_wheel, ef);
ef->iter = eina_list_data_find_list(em->images, current_image);
// TODO: ef->iter = eina_list_data_find_list(em->images, current_image);
for (i = 0; i < (sizeof (toolbar_items) / sizeof (char*)); ++i)
{
o = elm_toolbar_item_find_by_label(ef->toolbar, toolbar_items[i]);
@ -362,7 +362,7 @@ _ephoto_go_first(void *data, Evas_Object *obj, void *event_info)
{
Ephoto_Flow_Browser *ef = data;
ef->iter = em->images;
// TODO: ef->iter = em->images;
ef->cur_image = eina_list_data_get(ef->iter);
_ephoto_go_update(ef);
@ -374,7 +374,7 @@ _ephoto_go_last(void *data, Evas_Object *obj, void *event_info)
{
Ephoto_Flow_Browser *ef = data;
ef->iter = eina_list_last(em->images);
// TODO: ef->iter = eina_list_last(em->images);
ef->cur_image = eina_list_data_get(ef->iter);
_ephoto_go_update(ef);
@ -387,7 +387,7 @@ _ephoto_go_next(void *data, Evas_Object *obj, void *event_info)
Ephoto_Flow_Browser *ef = data;
ef->iter = eina_list_next(ef->iter);
if (!ef->iter) ef->iter = em->images;
// TODO: if (!ef->iter) ef->iter = em->images;
ef->cur_image = eina_list_data_get(ef->iter);
@ -401,8 +401,10 @@ _ephoto_go_previous(void *data, Evas_Object *obj, void *event_info)
Ephoto_Flow_Browser *ef = data;
ef->iter = eina_list_prev(ef->iter);
/* TODO:
if (!ef->iter)
ef->iter = eina_list_last(em->images);
*/
ef->cur_image = eina_list_data_get(ef->iter);

@ -15,7 +15,7 @@ static void _ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void
static void
_ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info)
{
em->thumb_browser = ephoto_create_thumb_browser(em->layout);
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",
@ -132,8 +132,7 @@ ephoto_create_main_window(const char *directory, const char *image)
}
else
{
em->thumb_browser = ephoto_create_thumb_browser(em->layout);
evas_object_show(em->thumb_browser);
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",
@ -158,8 +157,7 @@ _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info)
evas_object_del(em->layout);
evas_object_del(em->bg);
if (em->images)
eina_list_free(em->images);
ephoto_entries_free(em);
ephoto_config_free(em);
free(em);
elm_exit();
@ -232,16 +230,24 @@ Evas_Object *
ephoto_thumb_add(Evas_Object *parent, const char *path)
{
Evas_Object *o;
const char *ext;
Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO;
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
o = elm_thumb_add(parent);
if (!o) return NULL;
ext = strrchr(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);
return o;
}
void
ephoto_thumb_path_set(Evas_Object *o, const char *path)
{
Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO;
const char *ext = strrchr(path, '.');
if (ext)
{
ext++;
@ -253,8 +259,35 @@ ephoto_thumb_add(Evas_Object *parent, const char *path)
ethumb_client_format_set(elm_thumb_ethumb_client_get(), format);
evas_object_data_set(o, "ephoto_format", (void*)(long)format);
elm_thumb_file_set(o, path, NULL);
elm_object_style_set(o, "noframe");
_thumbs = eina_list_append(_thumbs, o);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, NULL);
return o;
}
Ephoto_Entry *
ephoto_entry_new(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->path = eina_stringshare_add(path);
entry->basename = ecore_file_file_get(entry->path);
entry->label = eina_stringshare_add(label);
return entry;
}
void
ephoto_entry_free(Ephoto_Entry *entry)
{
const char *s;
EINA_SAFETY_ON_NULL_RETURN(entry);
eina_stringshare_del(entry->path);
eina_stringshare_del(entry->label);
EINA_LIST_FREE(entry->dir_files, s) eina_stringshare_del(s);
free(entry);
}
void
ephoto_entries_free(Ephoto *em)
{
Ephoto_Entry *e;
EINA_LIST_FREE(em->entries, e) ephoto_entry_free(e);
}

@ -56,15 +56,6 @@ ephoto_show_preferences(Ephoto *em)
elm_box_pack_end(pg1, o);
evas_object_show(o);
o = elm_check_add(pg1);
elm_check_label_set(o, "Sort images");
elm_check_state_set(o, em->config->sort_images);
evas_object_data_set(o, "config", "sort_images");
evas_object_smart_callback_add(o, "changed",