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
{
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 {

View File

@ -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");

View File

@ -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;

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_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;

View File

@ -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];
Ephoto_Directory_Thumb *dt = data;
Evas_Object *obj;
const char *file;
position = eina_list_count(dt->frames);
if (!dt->objs) return;
if (position > dt->theme_thumb_count)
{
if (dt->file)
{
eio_file_cancel(dt->file);
dt->file = NULL;
}
return;
}
obj = dt->objs->data;
file = eina_stringshare_add(info->path);
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);
DBG("populate thumbnail %p with path '%s'", obj, file);
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);
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);
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);
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;
Ephoto_Directory_Thumb *dt;
Evas_Object *obj;
dt = calloc(1, sizeof( Directory_Thumb));
dt->path = eina_stringshare_add(path);
dt->layout = elm_layout_add(parent);
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);
}
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);
obj = ephoto_thumb_add(parent, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
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);
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;
}
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);
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);
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);
}
dt->objs = eina_list_append(dt->objs, obj);
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,
_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);

View File

@ -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);
}

View File

@ -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",
_ephoto_preferences_item_change, em);
elm_box_pack_end(pg1, o);
evas_object_show(o);
elm_box_pack_end(box, pager);
evas_object_show(pager);
@ -179,8 +170,6 @@ _ephoto_preferences_item_change(void *data, Evas_Object *obj, void *event_info)
eina_stringshare_replace(
&em->config->editor,
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);
}

View File

@ -70,6 +70,7 @@ ephoto_show_slideshow(int view, const char *current_image)
itc.func.del = NULL;
elm_slideshow_clear(em->slideshow);
/* TODO:
l = em->images;
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)))
cur_item = item;
}
*/
if (cur_item)
elm_slideshow_show(cur_item);

View File

@ -4,31 +4,290 @@
#define SLIDER_MIN 128
#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;
struct _Ephoto_Thumb_Data
struct _Ephoto_Thumb_Browser
{
const char *thumb_path;
const char *file;
const char *basename;
Eina_Bool is_directory : 1;
Eina_Bool is_up : 1;
Evas_Object *layout;
Evas_Object *edje;
Evas_Object *grid;
Eio_File *ls;
};
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
{
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;
{
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)
@ -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_out(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_populate_images(Ephoto_Thumb_Browser *tb);
@ -119,8 +377,6 @@ ephoto_create_thumb_browser(Evas_Object *parent)
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);
elm_layout_file_set(tb->layout,
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 */
/* 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*/
static void
_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 */
/*
static Ephoto_Thumb_Data *
_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);
return etd;
}
*/
/*Get the label for the icon in the grid*/
static char *
_ephoto_get_label(void *data, Evas_Object *obj, const char *part)
{
Ephoto_Thumb_Data *etd = data;
return strdup(etd->basename);
Ephoto_Entry *e = data;
return strdup(e->basename);
}
static Evas_Object *
@ -432,13 +578,13 @@ _ephoto_directory_up_add(Evas_Object *parent_obj)
static Evas_Object *
_ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
{
Ephoto_Thumb_Data *etd = data;
Ephoto_Entry *e = data;
Evas_Object *thumb, *o;
if (strcmp(part, "elm.swallow.icon") != 0) return NULL;
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",
"/ephoto/thumb/no_border");
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_show(thumb);
if (etd->is_directory)
if (e->is_dir)
{
if (etd->is_up)
if (e->is_up)
o = _ephoto_directory_up_add(thumb);
else
o = ephoto_directory_thumb_add(thumb, etd->thumb_path);
o = ephoto_directory_thumb_add(thumb, e->path);
}
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);
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*/
static void
_ephoto_grid_del(void *data, Evas_Object *obj)
{
return;
Ephoto_Entry *e = data;
e->item = NULL;
}
/*Thumb clicked job*/
@ -482,50 +622,36 @@ _ephoto_thumb_clicked_job(void *data)
{
const Eina_List *selected;
char *parent_dir;
Ephoto_Thumb_Data *etd;
Evas_Object *o;
Ephoto_Entry *e;
Ephoto_Thumb_Browser *tb = data;
selected = elm_gengrid_selected_items_get(tb->thumb_browser);
o = eina_list_data_get(selected);
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)o);
if (etd->is_directory)
e = elm_gengrid_item_data_get(eina_list_data_get(selected));
if (e->is_dir)
{
if (!strcmp(etd->file, PARENT_DIR))
{
parent_dir = ecore_file_dir_get(em->config->directory);
_ephoto_change_directory(tb, parent_dir);
free(parent_dir);
}
else
_ephoto_change_directory(tb, etd->file);
if (e->is_up)
{
parent_dir = ecore_file_dir_get(em->config->directory);
_ephoto_change_directory(tb, parent_dir);
free(parent_dir);
}
else
_ephoto_change_directory(tb, e->path);
}
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. */
static void
_ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory)
{
const Eina_List *l, *iter;
Elm_Gengrid_Item *item;
Ephoto_Thumb_Data *etd;
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);
EINA_LIST_FREE(em->images, s) eina_stringshare_del(s);
ephoto_entries_free(em);
ephoto_populate_thumbnails(tb->layout);
elm_label_label_set(tb->dir_label, 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
{
/* _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;
}
#endif