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
This commit is contained in:
Gustavo Sverzut Barbieri 2010-10-09 19:13:35 +00:00
parent 73d91bfa90
commit e21422bf65
10 changed files with 1083 additions and 685 deletions

View File

@ -118,302 +118,607 @@ collections
} }
} }
group group { name: "elm/gengrid/item/up/ephoto";
{ data.item: "labels" "elm.text.label";
name: "elm/gengrid/item/ephoto/default"; images {
data.item: "labels" "elm.text"; set { name: "up";
data.item: "icons" "elm.swallow.icon elm.swallow.end"; image {
images image: "up-128.png" COMP;
{ size: 1 1 128 128;
image: "bt_sm_base1.png" COMP; }
image: "bt_sm_shine.png" COMP; image {
image: "bt_sm_hilight.png" COMP; image: "up-256.png" COMP;
} size: 129 129 256 256;
parts }
{ image {
part image: "up-512.png" COMP;
{ size: 257 257 512 512;
name: "event"; }
type: RECT; }
repeat_events: 1; image: "bt_sm_base1.png" COMP;
description image: "bt_sm_shine.png" COMP;
{ image: "bt_sm_hilight.png" COMP;
state: "default" 0.0; }
color: 0 0 0 0; parts {
} part { name: "event";
} type: RECT;
part repeat_events: 1;
{ description { state: "default" 0.0;
name: "bg"; color: 0 0 0 0;
clip_to: "disclip"; }
mouse_events: 0; }
description
{ part { name: "bg";
state: "default" 0.0; mouse_events: 0;
visible: 0; description { state: "default" 0.0;
color: 255 255 255 0; visible: 0;
rel1 color: 255 255 255 0;
{ rel1.offset: -3 -3;
relative: 0.0 0.0; rel2.offset: 2 2;
offset: -5 -5; image { normal: "bt_sm_base1.png";
} border: 6 6 6 6;
rel2 }
{ image.middle: SOLID;
relative: 1.0 1.0; }
offset: 4 4; description { state: "selected" 0.0;
} inherit: "default" 0.0;
image visible: 1;
{ color: 255 255 255 255;
normal: "bt_sm_base1.png"; }
border: 6 6 6 6; }
}
image.middle: SOLID; part { name: "img";
} type: IMAGE;
description mouse_events: 0;
{ description {
state: "selected" 0.0; state: "default" 0.0;
inherit: "default" 0.0; aspect_preference: BOTH;
visible: 1; aspect: 1.0 1.0;
color: 255 255 255 255; image.normal: "up";
rel1 rel2 { to_y: "elm.text.label";
{ relative: 1.0 0.0;
relative: 0.0 0.0; offset: -1 -2;
offset: -2 -2; }
} }
rel2 }
{
relative: 1.0 1.0; part { name: "elm.text.label";
offset: 1 1; type: TEXT;
} effect: SOFT_SHADOW;
} mouse_events: 0;
} scale: 1;
part description { state: "default" 0.0;
{ color: 0 0 0 255;
name: "elm.swallow.pad"; color3: 0 0 0 0;
type: SWALLOW; align: 0.5 1.0;
description rel1 { relative: 0.0 1.0;
{ offset: 2 -25;
state: "default" 0.0; }
fixed: 1 0; rel2 { relative: 1.0 1.0;
align: 0.0 0.5; offset: -3 -3;
rel1 }
{ text { font: "Sans";
relative: 0.0 1.0; size: 10;
offset: 0 -10; min: 0 1;
} align: 0.5 0.0;
rel2 }
{ }
to_y: "elm.text"; description { state: "selected" 0.0;
relative: 0.0 0.0; inherit: "default" 0.0;
offset: -1 -1; color: 224 224 224 255;
} color3: 0 0 0 64;
} }
} }
part
{ part { name: "fg1";
name: "elm.swallow.icon"; mouse_events: 0;
clip_to: "disclip"; description { state: "default" 0.0;
type: SWALLOW; visible: 0;
description color: 255 255 255 0;
{ rel1.offset: -3 -3;
state: "default" 0.0; rel2 { relative: 1.0 0.5;
fixed: 1 0; offset: 2 -1;
align: 0.5 0.5; }
rel1 image { normal: "bt_sm_hilight.png";
{ border: 6 6 6 0;
relative: 0.0 0.0; }
offset: -1 4; }
} description { state: "selected" 0.0;
rel2 inherit: "default" 0.0;
{ visible: 1;
to_y: "elm.swallow.pad"; color: 255 255 255 255;
relative: 1.0 0.0; }
offset: -1 -5; }
}
} part { name: "fg2";
} mouse_events: 0;
part description { state: "default" 0.0;
{ visible: 0;
name: "elm.swallow.end"; color: 255 255 255 0;
clip_to: "disclip"; rel1.offset: -3 -3;
type: SWALLOW; rel2.offset: 2 2;
description image { normal: "bt_sm_shine.png";
{ border: 6 6 6 0;
state: "default" 0.0; }
fixed: 1 0; }
align: 1.0 0.0; description { state: "selected" 0.0;
aspect: 1.0 1.0; inherit: "default" 0.0;
aspect_preference: HORIZONTAL; visible: 1;
rel1 color: 255 255 255 255;
{ }
relative: 1.0 0.0; }
offset: -5 -5;
} programs {
rel2 program {
{ signal: "elm,state,selected";
relative: 1.0 1.0; source: "elm";
offset: 5 5; action: STATE_SET "selected" 0.0;
} target: "bg";
} target: "fg1";
} target: "fg2";
part target: "elm.text.label";
{ }
name: "elm.text"; program {
clip_to: "disclip"; signal: "elm,state,unselected";
type: TEXT; source: "elm";
effect: SOFT_SHADOW; action: STATE_SET "default" 0.0;
mouse_events: 0; target: "bg";
scale: 1; target: "fg1";
description target: "fg2";
{ target: "elm.text.label";
state: "default" 0.0; transition: LINEAR 0.1;
rel1 }
{ }
relative: 0.0 1.0; }
offset: 0 -25; }
}
rel2 group { name: "elm/gengrid/item/file/ephoto";
{ data {
relative: 1.0 1.0; item: "icons" "elm.swallow.icon";
offset: -1 -1; item: "labels" "elm.text.label";
} }
color: 0 0 0 255; images {
color3: 0 0 0 0; image: "bt_sm_base1.png" COMP;
text image: "bt_sm_shine.png" COMP;
{ image: "bt_sm_hilight.png" COMP;
font: "Sans"; }
size: 10; parts {
min: 0 1; part { name: "event";
align: 0.5 0.0; type: RECT;
} repeat_events: 1;
} description { state: "default" 0.0;
description color: 0 0 0 0;
{ }
state: "selected" 0.0; }
inherit: "default" 0.0;
color: 224 224 224 255; part { name: "bg";
color3: 0 0 0 64; mouse_events: 0;
} description { state: "default" 0.0;
} visible: 0;
part color: 255 255 255 0;
{ rel1.offset: -3 -3;
name: "fg1"; rel2.offset: 2 2;
clip_to: "disclip"; image { normal: "bt_sm_base1.png";
mouse_events: 0; border: 6 6 6 6;
description }
{ image.middle: SOLID;
state: "default" 0.0; }
visible: 0; description { state: "selected" 0.0;
color: 255 255 255 0; inherit: "default" 0.0;
rel1.to: "bg"; visible: 1;
rel2.relative: 1.0 0.5; color: 255 255 255 255;
rel2.to: "bg"; }
image }
{
normal: "bt_sm_hilight.png"; part { name: "border-shadow";
border: 6 6 6 0; type: IMAGE;
} mouse_events: 0;
} description { state: "default" 0.0;
description rel1 { to: "elm.swallow.icon";
{ offset: -18 -18;
state: "selected" 0.0; }
inherit: "default" 0.0; rel2 { to_x: "elm.swallow.icon";
visible: 1; to_y: "elm.text.label";
color: 255 255 255 255; offset: 17 17;
} }
} image { normal: "thumb_shadow.png";
part border: 17 17 17 17;
{ middle: NONE;
name: "fg2"; }
clip_to: "disclip"; }
mouse_events: 0; }
description
{ part { name: "border";
state: "default" 0.0; type: RECT;
visible: 0; mouse_events: 0;
color: 255 255 255 0; description { state: "default" 0.0;
rel1.to: "bg"; rel1 { to: "border-shadow";
rel2.to: "bg"; offset: 16 16;
image }
{ rel2 { to: "border-shadow";
normal: "bt_sm_shine.png"; offset: -15 -15;
border: 6 6 6 0; }
} }
} }
description
{ part { name: "elm.swallow.icon";
state: "selected" 0.0; type: SWALLOW;
inherit: "default" 0.0; mouse_events: 0;
visible: 1; description {
color: 255 255 255 255; state: "default" 0.0;
} aspect_preference: BOTH;
} aspect: 1.0 1.0;
part rel1.offset: 0 8;
{ rel2 { to_y: "elm.text.label";
name: "disclip"; relative: 1.0 0.0;
type: RECT; offset: -1 -2;
description }
{ }
state: "default" 0.0; }
rel1.to: "bg";
rel2.to: "bg"; part { name: "elm.text.label";
} type: TEXT;
description effect: SOFT_SHADOW;
{ mouse_events: 0;
state: "disabled" 0.0; scale: 1;
inherit: "default" 0.0; description { state: "default" 0.0;
color: 255 255 255 64; color: 0 0 0 255;
} color3: 0 0 0 0;
} align: 0.5 1.0;
} rel1 { relative: 0.0 1.0;
programs offset: 2 -30;
{ }
// signal: elm,state,%s,active rel2 { relative: 1.0 1.0;
// a "check" item named %s went active offset: -3 -15;
// signal: elm,state,%s,passive }
// a "check" item named %s went passive text { font: "Sans";
// default is passive size: 10;
program min: 0 1;
{ align: 0.5 0.0;
name: "go_active"; }
signal: "elm,state,selected"; }
source: "elm"; }
action: STATE_SET "selected" 0.0;
target: "bg"; part { name: "fg1";
target: "fg1"; mouse_events: 0;
target: "fg2"; description { state: "default" 0.0;
target: "elm.text"; visible: 0;
} color: 255 255 255 0;
program rel1.offset: -3 -3;
{ rel2 { relative: 1.0 0.5;
name: "go_passive"; offset: 2 -1;
signal: "elm,state,unselected"; }
source: "elm"; image { normal: "bt_sm_hilight.png";
action: STATE_SET "default" 0.0; border: 6 6 6 0;
target: "bg"; }
target: "fg1"; }
target: "fg2"; description { state: "selected" 0.0;
target: "elm.text"; inherit: "default" 0.0;
transition: LINEAR 0.1; visible: 1;
} color: 255 255 255 255;
program }
{ }
name: "go_disabled";
signal: "elm,state,disabled"; part { name: "fg2";
source: "elm"; mouse_events: 0;
action: STATE_SET "disabled" 0.0; description { state: "default" 0.0;
target: "disclip"; visible: 0;
} color: 255 255 255 0;
program rel1.offset: -3 -3;
{ rel2.offset: 2 2;
name: "go_enabled"; image { normal: "bt_sm_shine.png";
signal: "elm,state,enabled"; border: 6 6 6 0;
source: "elm"; }
action: STATE_SET "default" 0.0; }
target: "disclip"; 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 group
{ {
name: "ephoto/main/layout"; 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"; group { name: "/ephoto/directory/no-preview";
images { images {

View File

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

View File

@ -24,6 +24,7 @@
typedef struct _Ephoto_Config Ephoto_Config; typedef struct _Ephoto_Config Ephoto_Config;
typedef struct _Ephoto Ephoto; typedef struct _Ephoto Ephoto;
typedef struct _Ephoto_Entry Ephoto_Entry;
typedef enum _Ephoto_State Ephoto_State; typedef enum _Ephoto_State Ephoto_State;
typedef enum _Ephoto_Orient Ephoto_Orient; 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_create_main_window(const char *directory, const char *image);
void ephoto_thumb_size_set(int size); void ephoto_thumb_size_set(int size);
Evas_Object *ephoto_thumb_add(Evas_Object *parent, const char *path); Evas_Object *ephoto_thumb_add(Evas_Object *parent, const char *path);
void ephoto_thumb_path_set(Evas_Object *o, const char *path);
/* Configuration */ /* Configuration */
@ -57,11 +59,10 @@ void ephoto_hide_slideshow(void);
void ephoto_delete_slideshow(void); void ephoto_delete_slideshow(void);
/* Ephoto Directory Thumb */ /* 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*/ /*Ephoto Thumb Browser*/
Evas_Object *ephoto_create_thumb_browser(Evas_Object *parent); Evas_Object *ephoto_thumb_browser_add(Evas_Object *parent);
void ephoto_populate_thumbnails(Evas_Object *obj);
/* smart callbacks called: /* smart callbacks called:
* "selected" - an item in the thumb browser is selected. The selected file is passed as event_info argument. * "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. * "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 *slideshow_transition;
const char *editor; const char *editor;
int sort_images;
}; };
/*Ephoto Main Structure*/ /*Ephoto Main Structure*/
@ -112,8 +111,9 @@ struct _Ephoto
Evas_Object *slideshow; Evas_Object *slideshow;
Evas_Object *slideshow_notify; Evas_Object *slideshow_notify;
Evas_Object *thumb_browser; Evas_Object *thumb_browser;
Eina_List *entries;
Evas_Object *prefs_win; Evas_Object *prefs_win;
Eina_List *images;
Ephoto_State state; Ephoto_State state;
Ephoto_Config *config; Ephoto_Config *config;
@ -122,6 +122,22 @@ struct _Ephoto
Ecore_Timer *config_save; 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 Ephoto *em;
extern int __log_domain; extern int __log_domain;

View File

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

View File

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

View File

@ -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, evas_object_event_callback_add(ef->flow_browser, EVAS_CALLBACK_MOUSE_WHEEL,
_ephoto_mouse_wheel, ef); _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) for (i = 0; i < (sizeof (toolbar_items) / sizeof (char*)); ++i)
{ {
o = elm_toolbar_item_find_by_label(ef->toolbar, toolbar_items[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; Ephoto_Flow_Browser *ef = data;
ef->iter = em->images; // TODO: ef->iter = em->images;
ef->cur_image = eina_list_data_get(ef->iter); ef->cur_image = eina_list_data_get(ef->iter);
_ephoto_go_update(ef); _ephoto_go_update(ef);
@ -374,7 +374,7 @@ _ephoto_go_last(void *data, Evas_Object *obj, void *event_info)
{ {
Ephoto_Flow_Browser *ef = data; 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); ef->cur_image = eina_list_data_get(ef->iter);
_ephoto_go_update(ef); _ephoto_go_update(ef);
@ -387,7 +387,7 @@ _ephoto_go_next(void *data, Evas_Object *obj, void *event_info)
Ephoto_Flow_Browser *ef = data; Ephoto_Flow_Browser *ef = data;
ef->iter = eina_list_next(ef->iter); 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); 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; Ephoto_Flow_Browser *ef = data;
ef->iter = eina_list_prev(ef->iter); ef->iter = eina_list_prev(ef->iter);
/* TODO:
if (!ef->iter) if (!ef->iter)
ef->iter = eina_list_last(em->images); ef->iter = eina_list_last(em->images);
*/
ef->cur_image = eina_list_data_get(ef->iter); ef->cur_image = eina_list_data_get(ef->iter);

View File

@ -15,7 +15,7 @@ static void _ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void
static void static void
_ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info) _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); elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser);
evas_object_smart_callback_add(em->thumb_browser, evas_object_smart_callback_add(em->thumb_browser,
"selected", "selected",
@ -132,8 +132,7 @@ ephoto_create_main_window(const char *directory, const char *image)
} }
else else
{ {
em->thumb_browser = ephoto_create_thumb_browser(em->layout); em->thumb_browser = ephoto_thumb_browser_add(em->layout);
evas_object_show(em->thumb_browser);
elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser); elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser);
evas_object_smart_callback_add(em->thumb_browser, evas_object_smart_callback_add(em->thumb_browser,
"selected", "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->layout);
evas_object_del(em->bg); evas_object_del(em->bg);
if (em->images) ephoto_entries_free(em);
eina_list_free(em->images);
ephoto_config_free(em); ephoto_config_free(em);
free(em); free(em);
elm_exit(); elm_exit();
@ -232,16 +230,24 @@ Evas_Object *
ephoto_thumb_add(Evas_Object *parent, const char *path) ephoto_thumb_add(Evas_Object *parent, const char *path)
{ {
Evas_Object *o; 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(parent, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
o = elm_thumb_add(parent); o = elm_thumb_add(parent);
if (!o) return NULL; 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) if (ext)
{ {
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); ethumb_client_format_set(elm_thumb_ethumb_client_get(), format);
evas_object_data_set(o, "ephoto_format", (void*)(long)format); evas_object_data_set(o, "ephoto_format", (void*)(long)format);
elm_thumb_file_set(o, path, NULL); 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); Ephoto_Entry *
return o; 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);
} }

View File

@ -56,15 +56,6 @@ ephoto_show_preferences(Ephoto *em)
elm_box_pack_end(pg1, o); elm_box_pack_end(pg1, o);
evas_object_show(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",
_ephoto_preferences_item_change, em);
elm_box_pack_end(pg1, o);
evas_object_show(o);
elm_box_pack_end(box, pager); elm_box_pack_end(box, pager);
evas_object_show(pager); evas_object_show(pager);
@ -179,8 +170,6 @@ _ephoto_preferences_item_change(void *data, Evas_Object *obj, void *event_info)
eina_stringshare_replace( eina_stringshare_replace(
&em->config->editor, &em->config->editor,
eina_stringshare_add(elm_entry_entry_get(obj))); eina_stringshare_add(elm_entry_entry_get(obj)));
else if (!strcmp(key, "sort_images"))
em->config->sort_images = elm_check_state_get(obj);
ephoto_config_save(em, EINA_FALSE); ephoto_config_save(em, EINA_FALSE);
} }

View File

@ -70,6 +70,7 @@ ephoto_show_slideshow(int view, const char *current_image)
itc.func.del = NULL; itc.func.del = NULL;
elm_slideshow_clear(em->slideshow); elm_slideshow_clear(em->slideshow);
/* TODO:
l = em->images; l = em->images;
EINA_LIST_FOREACH(l, iter, image) EINA_LIST_FOREACH(l, iter, image)
{ {
@ -77,6 +78,7 @@ ephoto_show_slideshow(int view, const char *current_image)
if ((current_image) && (!strcmp(image, current_image))) if ((current_image) && (!strcmp(image, current_image)))
cur_item = item; cur_item = item;
} }
*/
if (cur_item) if (cur_item)
elm_slideshow_show(cur_item); elm_slideshow_show(cur_item);

View File

@ -4,31 +4,290 @@
#define SLIDER_MIN 128 #define SLIDER_MIN 128
#define PARENT_DIR "Up" #define PARENT_DIR "Up"
#define THEME_FILE PACKAGE_DATA_DIR"/themes/default/ephoto.edj"
typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data;
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser; typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
struct _Ephoto_Thumb_Data struct _Ephoto_Thumb_Browser
{ {
const char *thumb_path; Evas_Object *layout;
const char *file; Evas_Object *edje;
const char *basename; Evas_Object *grid;
Eina_Bool is_directory : 1; Eio_File *ls;
Eina_Bool is_up : 1;
}; };
static char *
_ephoto_thumb_item_label_get(void *data, Evas_Object *obj, const char *part)
{
Ephoto_Entry *e = data;
return strdup(e->label);
}
static Evas_Object *
_ephoto_thumb_dir_icon_get(void *data, Evas_Object *obj, const char *part)
{
Ephoto_Entry *e = data;
const char *f;
int n;
if (strncmp(part, "elm.swallow.icon.", sizeof("elm.swallow.icon.") - 1) != 0)
return NULL;
n = atoi(part + sizeof("elm.swallow.icon.") - 1);
if (n < 1)
return NULL;
n--;
f = eina_list_nth(e->dir_files, n);
if (f)
return ephoto_thumb_add(obj, f);
if (e->dir_files_checked)
return NULL;
return ephoto_directory_thumb_add(obj, e);
}
static Eina_Bool
_ephoto_thumb_dir_state_get(void *data, Evas_Object *obj, const char *part)
{
Ephoto_Entry *e = data;
int n;
if (strcmp(part, "have_files") == 0)
return !!e->dir_files;
if (strncmp(part, "have_file.", sizeof("have_file.") - 1) != 0)
return EINA_FALSE;
n = atoi(part + sizeof("have_file.") - 1);
if (n < 1)
return EINA_FALSE;
return n <= eina_list_count(e->dir_files);
}
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);
}
static void
_ephoto_thumb_item_del(void *data, Evas_Object *obj)
{
Ephoto_Entry *e = data;
e->item = NULL;
}
static const Elm_Gengrid_Item_Class _ephoto_thumb_dir_class = {
"dir",
{
_ephoto_thumb_item_label_get,
_ephoto_thumb_dir_icon_get,
_ephoto_thumb_dir_state_get,
_ephoto_thumb_item_del
}
};
static const Elm_Gengrid_Item_Class _ephoto_thumb_up_class = {
"up",
{
_ephoto_thumb_item_label_get,
NULL,
NULL,
_ephoto_thumb_item_del
}
};
static const Elm_Gengrid_Item_Class _ephoto_thumb_file_class = {
"file",
{
_ephoto_thumb_item_label_get,
_ephoto_thumb_file_icon_get,
NULL,
_ephoto_thumb_item_del
}
};
static void
_ephoto_populate_main(void *data, const Eina_File_Direct_Info *info)
{
Ephoto_Thumb_Browser *tb = data;
const Elm_Gengrid_Item_Class *ic;
Edje_Message_Int msg;
Ephoto_Entry *e;
e = ephoto_entry_new(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);
if (e->is_dir) ic = &_ephoto_thumb_dir_class;
else ic = &_ephoto_thumb_file_class;
/* TODO: add elm_gengrid_item_prepend(), elm_gengrid_item_insert_before(),
* elm_gengrid_item_insert_after().
* Then eina_list_search_sorted_near_list() to see where to insert it.
*/
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
if (!e->item)
{
ERR("could not add item to grid: path '%s'", info->path);
ephoto_entry_free(e);
return;
}
em->entries = eina_list_append(em->entries, e);
msg.val = eina_list_count(em->entries);
edje_object_message_send(tb->edje, EDJE_MESSAGE_INT, 1, &msg);
DBG("populate add '%s'", e->path);
}
static Eina_Bool
_ephoto_populate_filter(void *data, const Eina_File_Direct_Info *info)
{
const char *bname = info->path + info->name_start;
if (bname[0] == '.') return EINA_FALSE;
if (info->dirent->d_type == DT_DIR) return EINA_TRUE;
if (info->dirent->d_type == DT_UNKNOWN)
{
struct stat st;
if ((stat(info->path, &st) == 0) && (S_ISDIR(st.st_mode)))
return EINA_TRUE;
}
return _ephoto_eina_file_direct_info_image_useful(info);
}
static void
_ephoto_populate_end(void *data)
{
Ephoto_Thumb_Browser *tb = data;
tb->ls = NULL;
}
static void
_ephoto_populate_error(int error, void *data)
{
Ephoto_Thumb_Browser *tb = data;
if (error) ERR("could not populate: %s", strerror(error));
tb->ls = NULL;
edje_object_signal_emit(tb->edje, "populate,stop", "ephoto");
edje_object_signal_emit(tb->edje, "populate,error", "ephoto");
}
static void
_ephoto_populate_entries(Ephoto_Thumb_Browser *tb)
{
Ephoto_Entry *e;
char *parent_dir;
DBG("populate from '%s'", em->config->directory);
elm_gengrid_clear(tb->grid);
ephoto_entries_free(em);
parent_dir = ecore_file_dir_get(em->config->directory);
if (parent_dir)
{
e = ephoto_entry_new(parent_dir, PARENT_DIR);
free(parent_dir);
EINA_SAFETY_ON_NULL_RETURN(e);
e->is_up = 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! */
}
edje_object_signal_emit(tb->edje, "populate,start", "ephoto");
tb->ls = eio_file_direct_ls(em->config->directory,
_ephoto_populate_filter,
_ephoto_populate_main,
_ephoto_populate_end,
_ephoto_populate_error,
tb);
}
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);
free(tb);
}
Evas_Object *
ephoto_thumb_browser_add(Evas_Object *parent)
{
Evas_Object *layout = elm_layout_add(parent);
Ephoto_Thumb_Browser *tb;
EINA_SAFETY_ON_NULL_RETURN_VAL(layout, NULL);
tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
EINA_SAFETY_ON_NULL_GOTO(tb, error);
tb->layout = layout;
evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _layout_del, tb);
if (!elm_layout_file_set(layout, THEME_FILE, "ephoto/browser/layout"))
{
ERR("could not load group 'ephoto/browser/layout' from file %s",
THEME_FILE);
goto error;
}
tb->grid = elm_gengrid_add(layout);
EINA_SAFETY_ON_NULL_GOTO(tb->grid, error);
elm_object_style_set(tb->grid, "ephoto");
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);
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);
return layout;
error:
evas_object_del(layout);
return NULL;
}
#if 0
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
struct _Ephoto_Thumb_Browser struct _Ephoto_Thumb_Browser
{ {
Evas_Object *layout; Evas_Object *layout;
Evas_Object *thumb_browser; Evas_Object *thumb_browser;
Evas_Object *dir_label; Evas_Object *dir_label;
Evas_Object *toolbar; Evas_Object *toolbar;
Evas_Object *thumb_slider; Evas_Object *thumb_slider;
Evas_Object *thbox; Evas_Object *thbox;
Evas_Object *fsel_win; Evas_Object *fsel_win;
Elm_Gengrid_Item_Class eg; Elm_Gengrid_Item_Class eg;
Elm_Toolbar_Item *view_large; Elm_Toolbar_Item *view_large;
Eio_File *list; Eio_File *list;
}; };
#define THUMB_RATIO (256 / 192) #define THUMB_RATIO (256 / 192)
@ -51,7 +310,6 @@ static void _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_i
static void _ephoto_zoom_in(void *data, 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_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_zoom_regular_size(void *data, Evas_Object *obj, void *event_info);
static Ephoto_Thumb_Data *_ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path);
static void _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory); static void _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory);
static void _ephoto_populate_images(Ephoto_Thumb_Browser *tb); static void _ephoto_populate_images(Ephoto_Thumb_Browser *tb);
@ -119,8 +377,6 @@ ephoto_create_thumb_browser(Evas_Object *parent)
tb = calloc(1, sizeof(Ephoto_Thumb_Browser)); tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
tb->layout = elm_layout_add(parent); tb->layout = elm_layout_add(parent);
elm_layout_file_set(tb->layout, elm_layout_file_set(tb->layout,
PACKAGE_DATA_DIR "/themes/default/ephoto.edj", PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
@ -234,118 +490,6 @@ _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
/* Use ecore thread facility to avoid lock completly */ /* Use ecore thread facility to avoid lock completly */
/* Check directory type from another thread */
static Eina_Bool
_ephoto_populate_filter_directory(void *data, const Eina_File_Direct_Info *info)
{
const char *bname = info->path + info->name_start;
struct stat st;
if (bname[0] == '.') return EINA_FALSE;
if (info->dirent->d_type == DT_DIR) return EINA_TRUE;
if (info->dirent->d_type != DT_UNKNOWN) return EINA_FALSE;
return ((stat(info->path, &st) == 0) && (S_ISDIR(st.st_mode)));
}
/* Check image type from another thread */
static Eina_Bool
_ephoto_populate_filter_image(void *data, const Eina_File_Direct_Info *info)
{
return _ephoto_eina_file_direct_info_image_useful(info);
}
/*Done populating directories*/
static void
_ephoto_populate_end_directory(void *data)
{
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser *)data;
_ephoto_populate_images(tb);
}
/*Done populating images*/
static void
_ephoto_populate_end_image(void *data)
{
Ephoto_Thumb_Browser *tb = data;
const char *file;
tb->list = NULL;
if (!em->config->sort_images) return;
em->images = eina_list_sort(em->images, -1, EINA_COMPARE_CB(strcoll));
EINA_LIST_FREE(em->images, file)
{
_ephoto_thumbnail_add(tb, file);
eina_stringshare_del(file);
}
}
static void
_ephoto_populate_error(int error, void *data)
{
Ephoto_Thumb_Browser *tb = data;
/* We don't handle error case in ephoto */
tb->list = NULL;
}
/* Build the interface component after detection from main thread */
static void
_ephoto_populate_main_directory(void *data, const Eina_File_Direct_Info *info)
{
Ephoto_Thumb_Browser *tb = data;
Ephoto_Thumb_Data *td = _ephoto_thumbnail_add(tb, info->path);
td->is_directory = EINA_TRUE;
}
/* Build the interface component after detection from main thread */
static void
_ephoto_populate_main_image(void *data, const Eina_File_Direct_Info *info)
{
Ephoto_Thumb_Browser *tb = data;
Ephoto_Thumb_Data *td;
if (em->config->sort_images)
{
const char *file = eina_stringshare_add_length
(info->path, info->path_length);
em->images = eina_list_append(em->images, file);
return;
}
td = _ephoto_thumbnail_add(tb, info->path);
td->is_directory = !_ephoto_eina_file_direct_info_image_useful(info);
}
/*Create a thread to populate images*/
static void
_ephoto_populate_images(Ephoto_Thumb_Browser *tb)
{
tb->list = eio_file_direct_ls(em->config->directory,
_ephoto_populate_filter_image,
_ephoto_populate_main_image,
_ephoto_populate_end_image,
_ephoto_populate_error,
tb);
}
/* Start a thread to list images and directories in a directory without locking the interface */
void
ephoto_populate_thumbnails(Evas_Object *obj)
{
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
Ephoto_Thumb_Data *td = _ephoto_thumbnail_add(tb, PARENT_DIR);
td->is_directory = EINA_TRUE;
td->is_up = EINA_TRUE;
tb->list = eio_file_direct_ls(em->config->directory,
_ephoto_populate_filter_directory,
_ephoto_populate_main_directory,
_ephoto_populate_end_directory,
_ephoto_populate_error,
tb);
}
/*Zoom out the thumbnail size*/ /*Zoom out the thumbnail size*/
static void static void
_ephoto_zoom_out(void *data, Evas_Object *obj, void *event) _ephoto_zoom_out(void *data, Evas_Object *obj, void *event)
@ -400,6 +544,7 @@ _ephoto_slider_changed(void *data, Evas_Object *obj, void *event)
} }
/* Called when adding a directory or a file to elm_gengrid */ /* Called when adding a directory or a file to elm_gengrid */
/*
static Ephoto_Thumb_Data * static Ephoto_Thumb_Data *
_ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path) _ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path)
{ {
@ -410,13 +555,14 @@ _ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path)
elm_gengrid_item_append(tb->thumb_browser, &tb->eg, etd, NULL, NULL); elm_gengrid_item_append(tb->thumb_browser, &tb->eg, etd, NULL, NULL);
return etd; return etd;
} }
*/
/*Get the label for the icon in the grid*/ /*Get the label for the icon in the grid*/
static char * static char *
_ephoto_get_label(void *data, Evas_Object *obj, const char *part) _ephoto_get_label(void *data, Evas_Object *obj, const char *part)
{ {
Ephoto_Thumb_Data *etd = data; Ephoto_Entry *e = data;
return strdup(etd->basename); return strdup(e->basename);
} }
static Evas_Object * static Evas_Object *
@ -432,13 +578,13 @@ _ephoto_directory_up_add(Evas_Object *parent_obj)
static Evas_Object * static Evas_Object *
_ephoto_get_icon(void *data, Evas_Object *obj, const char *part) _ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
{ {
Ephoto_Thumb_Data *etd = data; Ephoto_Entry *e = data;
Evas_Object *thumb, *o; Evas_Object *thumb, *o;
if (strcmp(part, "elm.swallow.icon") != 0) return NULL; if (strcmp(part, "elm.swallow.icon") != 0) return NULL;
thumb = elm_layout_add(obj); thumb = elm_layout_add(obj);
if (etd->is_directory) if (e->is_dir)
elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"/ephoto/thumb/no_border"); "/ephoto/thumb/no_border");
else else
@ -447,33 +593,27 @@ _ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(thumb); evas_object_show(thumb);
if (etd->is_directory) if (e->is_dir)
{ {
if (etd->is_up) if (e->is_up)
o = _ephoto_directory_up_add(thumb); o = _ephoto_directory_up_add(thumb);
else else
o = ephoto_directory_thumb_add(thumb, etd->thumb_path); o = ephoto_directory_thumb_add(thumb, e->path);
} }
else else
o = ephoto_thumb_add(thumb, etd->thumb_path); o = ephoto_thumb_add(thumb, e->path);
elm_layout_content_set(thumb, "ephoto.swallow.content", o); elm_layout_content_set(thumb, "ephoto.swallow.content", o);
return thumb; return thumb;
} }
/*Get the state of the icon in the grid!*/
static Eina_Bool
_ephoto_get_state(void *data, Evas_Object *obj, const char *part)
{
return EINA_FALSE;
}
/*Delete the grid*/ /*Delete the grid*/
static void static void
_ephoto_grid_del(void *data, Evas_Object *obj) _ephoto_grid_del(void *data, Evas_Object *obj)
{ {
return; Ephoto_Entry *e = data;
e->item = NULL;
} }
/*Thumb clicked job*/ /*Thumb clicked job*/
@ -482,50 +622,36 @@ _ephoto_thumb_clicked_job(void *data)
{ {
const Eina_List *selected; const Eina_List *selected;
char *parent_dir; char *parent_dir;
Ephoto_Thumb_Data *etd; Ephoto_Entry *e;
Evas_Object *o;
Ephoto_Thumb_Browser *tb = data; Ephoto_Thumb_Browser *tb = data;
selected = elm_gengrid_selected_items_get(tb->thumb_browser); selected = elm_gengrid_selected_items_get(tb->thumb_browser);
o = eina_list_data_get(selected); e = elm_gengrid_item_data_get(eina_list_data_get(selected));
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)o); if (e->is_dir)
if (etd->is_directory)
{ {
if (!strcmp(etd->file, PARENT_DIR)) if (e->is_up)
{ {
parent_dir = ecore_file_dir_get(em->config->directory); parent_dir = ecore_file_dir_get(em->config->directory);
_ephoto_change_directory(tb, parent_dir); _ephoto_change_directory(tb, parent_dir);
free(parent_dir); free(parent_dir);
} }
else else
_ephoto_change_directory(tb, etd->file); _ephoto_change_directory(tb, e->path);
} }
else else
evas_object_smart_callback_call(tb->layout, "selected", (char *)etd->file); evas_object_smart_callback_call(tb->layout, "selected", (void*)e->path);
} }
/* Change the current directory showed in thumb browser. */ /* Change the current directory showed in thumb browser. */
static void static void
_ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory) _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory)
{ {
const Eina_List *l, *iter;
Elm_Gengrid_Item *item; Elm_Gengrid_Item *item;
Ephoto_Thumb_Data *etd;
if ((directory) && (eina_stringshare_replace(&em->config->directory, directory))) if ((directory) && (eina_stringshare_replace(&em->config->directory, directory)))
{ {
const char *s;
l = elm_gengrid_items_get(tb->thumb_browser);
EINA_LIST_FOREACH(l, iter, item)
{
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get(item);
eina_stringshare_del(etd->thumb_path);
eina_stringshare_del(etd->file);
free(etd);
}
elm_gengrid_clear(tb->thumb_browser); elm_gengrid_clear(tb->thumb_browser);
EINA_LIST_FREE(em->images, s) eina_stringshare_del(s); ephoto_entries_free(em);
ephoto_populate_thumbnails(tb->layout); ephoto_populate_thumbnails(tb->layout);
elm_label_label_set(tb->dir_label, em->config->directory); elm_label_label_set(tb->dir_label, em->config->directory);
_ephoto_set_title(em->config->directory); _ephoto_set_title(em->config->directory);
@ -596,7 +722,7 @@ _ephoto_view_large(void *data, Evas_Object *obj, void *event_info)
else else
{ {
/* _ephoto_thumb_clicked_job( eina_list_data_get(em->images)); */ /* _ephoto_thumb_clicked_job( eina_list_data_get(em->images)); */
evas_object_smart_callback_call(tb->layout, "selected", eina_list_data_get(em->images)); // TODO: evas_object_smart_callback_call(tb->layout, "selected", eina_list_data_get(em->images));
} }
@ -668,3 +794,5 @@ _ephoto_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
} }
em->thumb_browser = NULL; em->thumb_browser = NULL;
} }
#endif