From 4b8960b93105179509fd8a50c2139cd31d77ec06 Mon Sep 17 00:00:00 2001 From: Stephen Houston Date: Tue, 17 May 2011 20:02:53 +0000 Subject: [PATCH] Ephoto: Add in the new changes k-s and I have been working on. SVN revision: 59474 --- data/themes/default/ephoto.edc | 472 ------------- data/themes/default/images/Makefile.am | 3 - data/themes/default/images/thumb_shadow.png | Bin 1087 -> 0 bytes mkinstalldirs~ | 162 +++++ po/POTFILES.in | 5 +- src/bin/Makefile.am | 9 +- src/bin/ephoto.h | 52 +- src/bin/ephoto_flow_browser.c | 619 ---------------- src/bin/ephoto_list_browser.c | 321 +++++++++ src/bin/ephoto_main.c | 341 ++++----- src/bin/ephoto_preferences.c | 189 ----- src/bin/ephoto_single_browser.c | 738 +------------------- src/bin/ephoto_slideshow.c | 192 ----- src/bin/ephoto_thumb_browser.c | 290 +------- 14 files changed, 668 insertions(+), 2725 deletions(-) delete mode 100644 data/themes/default/images/thumb_shadow.png create mode 100755 mkinstalldirs~ delete mode 100644 src/bin/ephoto_flow_browser.c create mode 100644 src/bin/ephoto_list_browser.c delete mode 100644 src/bin/ephoto_preferences.c delete mode 100644 src/bin/ephoto_slideshow.c diff --git a/data/themes/default/ephoto.edc b/data/themes/default/ephoto.edc index a3018a2..91a4565 100644 --- a/data/themes/default/ephoto.edc +++ b/data/themes/default/ephoto.edc @@ -5,143 +5,6 @@ external: "elm"; collections { images { - image: "thumb_shadow.png" COMP; - } - group - { - name: "ephoto/layout/simple"; - parts - { - part - { - name: "layout"; - type: RECT; - description - { - state: "default" 0.0; - rel1.relative: 0.0 0.0; - rel1.offset: 0 0; - rel2.relative: 1.0 1.0; - rel2.offset: -1 -1; - color: 255 255 255 0; - } - } - part - { - name: "ephoto.content.swallow"; - type: SWALLOW; - description - { - rel1.to_y: "ephoto.toolbar.swallow"; - rel1.relative: 0.0 1.0; - rel1.offset: -1 1; - } - } - part - { - name: "ephoto.toolbar.swallow"; - type: SWALLOW; - description - { - state: "default" 0.0; - align: 0.5 0.0; - rel1.relative: 0.0 0.0; - rel2.relative: 1.0 0.0; - rel2.offset: -1 47; - fixed: 1 1; - } - } - } - } - group - { - name: "ephoto/layout/simple/autohide"; - parts - { - part - { - name: "layout"; - type: RECT; - description - { - state: "default" 0.0; - rel1.relative: 0.0 0.0; - rel1.offset: 0 0; - rel2.relative: 1.0 1.0; - rel2.offset: -1 -1; - color: 255 255 255 0; - } - } - part - { - name: "ephoto.content.swallow"; - type: SWALLOW; - description - { - rel1.to: "layout"; - rel2.to: "layout"; - } - } - part - { - name: "ephoto.toolbar.swallow"; - type: SWALLOW; - description - { - state: "default" 0.0; - align: 0.5 1.0; - rel1.relative: 0.0 1.0; - rel2.relative: 1.0 1.0; - fixed: 1 1; - visible: 0; - } - description - { - state: "visible" 0.0; - inherit: "default" 0.0; - color: 0 0 0 255; - visible: 1; - } - } - part - { - name: "toolbar_event"; - type: RECT; - mouse_events: 1; - repeat_events: 1; - description - { - state: "default" 0.0; - align: 0.5 1.0; - rel1.to: "ephoto.toolbar.swallow"; - rel2.to: "ephoto.toolbar.swallow"; - color: 255 255 255 0; - } - } - } - programs - { - program - { - name: "go_visible"; - signal: "mouse,clicked,1"; - source: "toolbar_event"; - filter: "ephoto.toolbar.swallow" "default" 0.0; - action: STATE_SET "visible" 0.0; - transition: LINEAR 0.4; - target: "ephoto.toolbar.swallow"; - } - program - { - name: "go_hidden"; - signal: "hide"; - source: "toolbar_event"; - filter: "ephoto.toolbar.swallow" "visible" 0.0; - action: STATE_SET "default" 0.0; - transition: LINEAR 0.4; - target: "ephoto.toolbar.swallow"; - } - } } group { @@ -327,339 +190,4 @@ collections { } } } - group - { - name: "flow_image"; - parts - { - part - { - name: "event"; - type: RECT; - repeat_events: 1; - description - { - state: "default" 0.0; - color: 0 0 0 0; - } - } - part - { - name: "border-shadow"; - type: IMAGE; - mouse_events: 0; - description - { - state: "default" 0.0; - rel1 - { - to: "image"; - offset: -18 -18; - } - rel2 - { - to: "image"; - 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: "image"; - type: SWALLOW; - mouse_events: 0; - description - { - state: "default" 0.0; - aspect_preference: BOTH; - aspect: 1.0 1.0; - rel1.offset : 0 8; - rel2.offset : -1 -2; - } - } - } - } - group - { - name: "flow"; - parts - { - part - { - name: "offscreen_left"; - type: SWALLOW; - mouse_events: 1; - description - { - state: default 0.0; - fixed: 1 1; - visible: 0; - rel1.relative : 0.0 0.3; - rel1.offset : 0 0; - rel2.relative : 0.0 0.7; - rel2.offset : 0 0; - } - description - { - state: right 0.0; - visible: 1; - rel1.relative : 0.0 0.3; - rel1.offset : 0 0; - rel2.relative : 0.2 0.7; - rel2.offset : 0 0; - } - description - { - state: left 0.0; - visible: 0; - rel1.relative : 1.0 0.3; - rel1.offset : 0 0; - rel2.relative : 1.0 0.7; - rel2.offset : 0 0; - } - } - part - { - name: "left"; - type: SWALLOW; - mouse_events: 1; - description - { - state: default 0.0; - visible: 1; - rel1.relative : 0.0 0.3; - rel1.offset : 0 0; - rel2.relative : 0.2 0.7; - rel2.offset : 0 0; - } - description - { - state: right 0.0; - rel1.relative : 0.2 0.2; - rel1.offset : 0 0; - rel2.relative : 0.8 0.8; - rel2.offset : 0 0; - } - description - { - state: left 0.0; - rel1.relative : 0.0 0.3; - rel1.offset : 0 0; - rel2.relative : 0.0 0.7; - rel2.offset : 0 0; - } - description - { - state: full 0.0; - inherit: default 0.0; - visible: 0; - } - } - part - { - name: "offscreen_right"; - type: SWALLOW; - mouse_events: 1; - description - { - state: default 0.0; - fixed: 1 1; - visible: 0; - rel1.relative : 1.0 0.3; - rel1.offset : 0 0; - rel2.relative : 1.0 0.7; - rel2.offset : 0 0; - } - description - { - state: right 0.0; - visible: 0; - rel1.relative : 0.0 0.3; - rel1.offset : 0 0; - rel2.relative : 0.0 0.7; - rel2.offset : 0 0; - } - description - { - state: left 0.0; - visible: 1; - rel1.relative : 0.8 0.3; - rel1.offset : 0 0; - rel2.relative : 1.0 0.7; - rel2.offset : 0 0; - } - } - part - { - name: "right"; - type: SWALLOW; - mouse_events: 1; - description - { - state: default 0.0; - visible: 1; - rel1.relative : 0.8 0.3; - rel1.offset : 0 0; - rel2.relative : 1.0 0.7; - rel2.offset : 0 0; - } - description - { - state: right 0.0; - rel1.relative : 1.0 0.3; - rel1.offset : 0 0; - rel2.relative : 1.0 0.7; - rel2.offset : 0 0; - } - description - { - state: left 0.0; - rel1.relative : 0.2 0.2; - rel1.offset : 0 0; - rel2.relative : 0.8 0.8; - rel2.offset : 0 0; - } - description - { - state: full 0.0; - inherit: default 0.0; - visible: 0; - } - } - part - { - name: "center"; - type: SWALLOW; - mouse_events: 1; - description - { - state: default 0.0; - rel1.relative : 0.2 0.2; - rel1.offset : 0 0; - rel2.relative : 0.8 0.8; - rel2.offset : 0 0; - } - description - { - state: right 0.0; - rel1.relative : 0.8 0.3; - rel1.offset : 0 0; - rel2.relative : 1.0 0.7; - rel2.offset : 0 0; - } - description - { - state: left 0.0; - rel1.relative : 0.0 0.3; - rel1.offset : 0 0; - rel2.relative : 0.2 0.7; - rel2.offset : 0 0; - } - description - { - state: full 0.0; - rel1.relative : 0.0 0.0; - rel1.offset : 0 0; - rel2.relative : 1.0 1.0; - rel2.offset : -1 -1; - } - } - } - programs - { - program - { - name: "right"; - signal: "right"; - source: "ephoto"; - action: STATE_SET right 0.0; - transition: LINEAR 0.4; - target: "offscreen_right"; - target: "right"; - target: "center"; - target: "left"; - target: "offscreen_left"; - after: "done"; - } - program - { - name: "left"; - signal: "left"; - source: "ephoto"; - action: STATE_SET left 0.0; - transition: LINEAR 0.4; - target: "offscreen_left"; - target: "left"; - target: "center"; - target: "right"; - target: "offscreen_right"; - after: "done"; - } - program - { - name: "full"; - signal: "full"; - source: "ephoto"; - action: STATE_SET full 0.0; - transition: LINEAR 0.2; - target: "left"; - target: "right"; - target: "center"; - } - program - { - name: "full_reset"; - signal: "full_reset"; - source: "ephoto"; - action: STATE_SET default 0.0; - transition: LINEAR 0.2; - target: "left"; - target: "right"; - target: "center"; - } - program - { - name: "done"; - action: SIGNAL_EMIT "done" "ephoto"; - } - program - { - name: "reset"; - signal: "reset"; - source: "ephoto"; - action: STATE_SET default 0.0; - target: "offscreen_right"; - target: "right"; - target: "center"; - target: "left"; - target: "offscreen_left"; - } - } - } } diff --git a/data/themes/default/images/Makefile.am b/data/themes/default/images/Makefile.am index a3b35fc..3b8551d 100644 --- a/data/themes/default/images/Makefile.am +++ b/data/themes/default/images/Makefile.am @@ -1,5 +1,2 @@ MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = \ -thumb_shadow.png - diff --git a/data/themes/default/images/thumb_shadow.png b/data/themes/default/images/thumb_shadow.png deleted file mode 100644 index 8e666708f86ef5eb9357a015530b8f278cd6155a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1087 zcmV-F1i<@=P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ige? z5f&wK&*1j}00X~CL_t(|+U;B0a-%Q|l?}B08XorlzhNKpHCrzBzS!*Io2(fLUhZu#WZq{J>vIVY_F~X{S#K(G>FR|p}t0OojH&guK?(4NiZ9}BY`yR z_!X<`*>MWE-$Q`O97~{6M3^V8x&+*_^J;A{8^K#RXBixORXM-*-$aQa(ZB`Elh}7;^wThrzYX1MqAV=nJ-w zz)|gcB6<_XAds-d6ue;T2!1A_iIFU64U#BogEkfB;D-SCJ&cd=Isg$!0G}w5}l;UfiFb?$@b9)yoHsg$K!Dd_;DO5 z%prnaV2&;v`{2b;{fSbVC@(yO#3(+T=0NRRNzhfaUl5n;l_?|gmDv@E8t8bYf zKutJX1|cC+M;=?52wA}ywnTsxewSo(53L4JMhjZl)#_MSlzyJ?+7px_L)XZjqD?qH zqrJEmJdX-zOUKN!iiABHU>n&GHHj?KX!bsA<7bQ5qBa1(G7a1(G7P%qhX(~D)-T&(iusRy<~z-AI`C2;=>2*{PmH=6)| z02V4+Ai$B_Gf-Mo6#=>0{MrBktFS0)lh~sHSeial9FS1$4{U{fNrlR#0Rk47i>vih zwo>)6^c1VJXUhyExLQ-tYCvlBTO(klpIszs4e*7KhrlEFsR05eAOVTUg~l)Gl@1WS zK7wzdF7U}nSWBR(&>w(RRBrbjeb?!~YX6~1+X4YAi%`YLklH%NY7jO<#SV~Ik;UeS zc#bzn@LF9>cITMiiJCVB;GabF4@mf=?+y|vGI)&!q+)GsM3VY(;=?9-ZHo*a3xIZ- zbhyu`zoDOPCP)IY$S~7+O;WP}-f2?gUO5>LTEJH+u6`dT^6ECZl^wf;+EZ;5;Lece z{@hL%InkIxYVsO9pNp +# Created: 1993-05-16 +# Public domain. +# +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' +IFS=" "" $nl" +errstatus=0 +dirmode= + +usage="\ +Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... + +Create each directory DIR (with mode MODE, if specified), including all +leading file name components. + +Report bugs to ." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" + exit $? + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --version) + echo "$0 $scriptversion" + exit $? + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and +# mkdir -p a/c at the same time, both will detect that a is missing, +# one will create a, then the other will try to create a and die with +# a "File exists" error. This is a problem when calling mkinstalldirs +# from a parallel make. We use --version in the probe to restrict +# ourselves to GNU mkdir, which is thread-safe. +case $dirmode in + '') + if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + test -d ./-p && rmdir ./-p + test -d ./--version && rmdir ./--version + fi + ;; + *) + if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && + test ! -d ./--version; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + else + # Clean up after NextStep and OpenStep mkdir. + for d in ./-m ./-p ./--version "./$dirmode"; + do + test -d $d && rmdir $d + done + fi + ;; +esac + +for file +do + case $file in + /*) pathcomp=/ ;; + *) pathcomp= ;; + esac + oIFS=$IFS + IFS=/ + set fnord $file + shift + IFS=$oIFS + + for d + do + test "x$d" = x && continue + + pathcomp=$pathcomp$d + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr= + chmod "$dirmode" "$pathcomp" || lasterr=$? + + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi + + pathcomp=$pathcomp/ + done +done + +exit $errstatus + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/po/POTFILES.in b/po/POTFILES.in index ee71baf..a85180b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ src/bin/ephoto.c -src/bin/ephoto_flow_browser.c +src/bin/ephoto_config.c src/bin/ephoto_main.c -src/bin/ephoto_slideshow.c +src/bin/ephoto_list_browser.c src/bin/ephoto_thumb_browser.c +src/bin/ephoto_single_browser.c diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index b499c2e..90809a4 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -17,11 +17,10 @@ _sources = \ ephoto.c \ ephoto_main.c \ ephoto_config.c \ - ephoto_preferences.c \ - ephoto_thumb_browser.c \ - ephoto_single_browser.c \ - ephoto_flow_browser.c \ - ephoto_slideshow.c + ephoto_list_browser.c \ + ephoto_thumb_browser.c \ + ephoto_single_browser.c + _libs = @ELEMENTARY_LIBS@ @EFREET_MIME_LIBS@ @EIO_LIBS@ @EXIF_LIBS@ @EET_LIBS@ diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index 2295f07..da2216d 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -39,8 +39,11 @@ void ephoto_title_set(Ephoto *ephoto, const char *title); void ephoto_thumb_size_set(Ephoto *ephoto, int size); Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path); void ephoto_thumb_path_set(Evas_Object *o, const char *path); +Evas_Object *ephoto_list_icon_add(Ephoto *ephoto, Evas_Object *parent, const char *standard); void ephoto_directory_set(Ephoto *ephoto, const char *path); -void ephoto_auto_hide_toolbar(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__); +void ephoto_promote_list_browser(Ephoto *ephoto); +void ephoto_promote_thumb_browser(Ephoto *ephoto); +void ephoto_promote_single_browser(Ephoto *ephoto, Ephoto_Entry *e); /*Get the exif orientation of a JPEG*/ Ephoto_Orient ephoto_file_orient_get(const char *path); @@ -50,43 +53,24 @@ Eina_Bool ephoto_config_init(Ephoto *em); void ephoto_config_save(Ephoto *em, Eina_Bool instant); void ephoto_config_free(Ephoto *em); -/*Single Browser Functions/Callbacks*/ -Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent); -void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry); -void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path); - /* smart callbacks called: - * "back" - the user wants to go back to the previous screen. - * "slideshow" - the user wants to view a slideshow. - */ +/*List Browser*/ +Evas_Object *ephoto_list_browser_add(Ephoto *ephoto, Evas_Object *parent); +void ephoto_list_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry); -/*Flow Browser Functions/Callbacks*/ -Evas_Object *ephoto_flow_browser_add(Ephoto *e, Evas_Object *parent); -void ephoto_flow_browser_entry_set(Evas_Object *obj __UNUSED__, Ephoto_Entry *entry); -/* smart callbacks called: - * "back" - the user wants to go back to the previous screen. - * "slideshow" - the user wants to view a slideshow. - */ - -/*Slideshow Functions/Callbacks*/ -Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent); -void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry); - /* smart callbacks called: - * "back" - the user want to go back to the previous screen. - */ - -/*Main Thumb Browser Function*/ +/*Thumb Browser*/ Evas_Object *ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent); void ephoto_thumb_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry); -/* smart callbacks called: - * "selected" - an item in the thumb browser is selected. The selected Ephoto_Entry is passed as event_info argument. - */ +/*Single Browser*/ +Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent); +void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry); +void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path); /*Ephoto View*/ enum _Ephoto_State { + EPHOTO_STATE_LIST, EPHOTO_STATE_THUMB, - EPHOTO_STATE_FLOW, EPHOTO_STATE_SINGLE, EPHOTO_STATE_SLIDESHOW }; @@ -122,15 +106,19 @@ struct _Ephoto { Evas_Object *win; Evas_Object *bg; + Evas_Object *layout; + Evas_Object *edje; Evas_Object *pager; + Evas_Object *help_but; + Evas_Object *list_browser; Evas_Object *thumb_browser; - Evas_Object *flow_browser; Evas_Object *single_browser; Evas_Object *slideshow; Eina_List *entries; Eina_List *thumbs; + Eina_List *dirs; int thumb_gen_size; struct { @@ -156,6 +144,7 @@ struct _Ephoto_Entry const char *label; Ephoto *ephoto; Elm_Gengrid_Item *item; + Elm_Genlist_Item *list_item; Eina_List *free_listeners; }; @@ -210,7 +199,8 @@ _ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info) } /*Ephoto Event Handlers*/ -extern int EPHOTO_EVENT_ENTRY_CREATE; +extern int EPHOTO_EVENT_ENTRY_CREATE_DIR; +extern int EPHOTO_EVENT_ENTRY_CREATE_THUMB; extern int EPHOTO_EVENT_POPULATE_START; extern int EPHOTO_EVENT_POPULATE_END; extern int EPHOTO_EVENT_POPULATE_ERROR; diff --git a/src/bin/ephoto_flow_browser.c b/src/bin/ephoto_flow_browser.c deleted file mode 100644 index 63cd389..0000000 --- a/src/bin/ephoto_flow_browser.c +++ /dev/null @@ -1,619 +0,0 @@ -#include "ephoto.h" - -static Elm_Genlist_Item_Class egli; - -typedef struct _Ephoto_Flow_Browser Ephoto_Flow_Browser; -struct _Ephoto_Flow_Browser -{ - Eina_Bool key_down; - Eina_Bool mouse_wheel; - Eina_List *current_index; - Eina_List *items; - Elm_Genlist_Item *egi; - Evas_Object *box; - Evas_Object *edje; - Evas_Object *layout; - Evas_Object *list; - Evas_Object *main_layout; - Evas_Object *images[5]; - Evas_Object *img_edje[5]; - Evas_Object *toolbar; - Ephoto_Entry *entry; - Ephoto *ephoto; - char *swallows[5]; - int flow_direct; - int selected_handled; - struct { - Elm_Toolbar_Item *go_back; - Elm_Toolbar_Item *go_prev; - Elm_Toolbar_Item *go_next; - Elm_Toolbar_Item *slideshow; - } action; -}; - - -static void -_entry_free(void *data, const Ephoto_Entry *entry __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - - efb->entry = NULL; -} - -static Evas_Object * -_add_image_edje(const char *swallow, Evas_Object *parent) -{ - Evas_Object *o; - - o = elm_layout_add(parent); - elm_layout_file_set - (o, THEME_FILE, "flow_image"); - elm_layout_content_set(parent, swallow, o); - evas_object_show(o); - - return o; -} - -static Evas_Object * -_add_image(Evas_Object *swallow, Evas_Object *parent) -{ - Evas_Object *o; - - o = elm_thumb_add(parent); - elm_object_style_set(o, "noframe"); - elm_layout_content_set(swallow, "image", o); - evas_object_show(o); - - return o; -} - -static void -_flow_browser_image_set(Ephoto_Flow_Browser *efb) -{ - Eina_List *prevv, *prev, *next, *nextt; - Ephoto_Entry *pp, *p, *n, *nn, *c; - int i; - - prev = eina_list_prev(efb->current_index); - if (!eina_list_data_get(prev)) - prev = eina_list_last(efb->items); - prevv = eina_list_prev(prev); - if (!eina_list_data_get(prevv)) - prevv = eina_list_last(efb->items); - next = eina_list_next(efb->current_index); - if (!eina_list_data_get(next)) - next = eina_list_nth_list(efb->items, 0); - nextt = eina_list_next(next); - if (!eina_list_data_get(nextt)) - nextt = eina_list_nth_list(efb->items, 0); - - pp = eina_list_data_get(prevv); - p = eina_list_data_get(prev); - c = eina_list_data_get(efb->current_index); - n = eina_list_data_get(next); - nn = eina_list_data_get(nextt); - - for (i = 0; i < 5; i++) - { - elm_layout_content_unset(efb->layout, efb->swallows[i]); - elm_layout_content_unset(efb->img_edje[i], "image"); - } - - elm_thumb_file_set(efb->images[0], pp->path, NULL); - elm_layout_content_set(efb->img_edje[0], "image", efb->images[0]); - elm_layout_content_set(efb->layout, "offscreen_left", efb->img_edje[0]); - elm_thumb_file_set(efb->images[1], p->path, NULL); - elm_layout_content_set(efb->img_edje[1], "image", efb->images[1]); - elm_layout_content_set(efb->layout, "left", efb->img_edje[1]); - elm_thumb_file_set(efb->images[2], c->path, NULL); - elm_layout_content_set(efb->img_edje[2], "image", efb->images[2]); - elm_layout_content_set(efb->layout, "center", efb->img_edje[2]); - elm_thumb_file_set(efb->images[3], n->path, NULL); - elm_layout_content_set(efb->img_edje[3], "image", efb->images[3]); - elm_layout_content_set(efb->layout, "right", efb->img_edje[3]); - elm_thumb_file_set(efb->images[4], nn->path, NULL); - elm_layout_content_set(efb->img_edje[4], "image", efb->images[4]); - elm_layout_content_set(efb->layout, "offscreen_right", efb->img_edje[4]); - - elm_object_focus(efb->main_layout); -} - -static void -_flow_done(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - Evas_Object *edje; - - edje = elm_layout_edje_get(efb->layout); - edje_object_freeze(edje); - - if (efb->flow_direct == 0) - { - efb->current_index = eina_list_prev(efb->current_index); - if (!eina_list_data_get(efb->current_index)) - efb->current_index = eina_list_last(efb->items); - _flow_browser_image_set(efb); - } - else - { - efb->current_index = eina_list_next(efb->current_index); - if (!eina_list_data_get(efb->current_index)) - efb->current_index = eina_list_nth_list(efb->items, 0); - _flow_browser_image_set(efb); - } - - edje_object_signal_emit(edje, "reset", "ephoto"); - edje_object_thaw(edje); - - elm_toolbar_item_disabled_set(efb->action.go_prev, EINA_FALSE); - elm_toolbar_item_disabled_set(efb->action.go_next, EINA_FALSE); - elm_genlist_no_select_mode_set(efb->list, EINA_FALSE); - efb->mouse_wheel = EINA_FALSE; - efb->key_down = EINA_FALSE; - efb->selected_handled = 0; -} - -static void -_flow_back(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - - elm_toolbar_item_selected_set(efb->action.go_back, EINA_FALSE); - - evas_object_key_ungrab(efb->main_layout, "Escape", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Left", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Right", 0, 0); - evas_object_key_ungrab(efb->main_layout, "BackSpace", 0, 0); - evas_object_key_ungrab(efb->main_layout, "space", 0, 0); - - efb->entry = eina_list_data_get(efb->current_index); - - elm_object_unfocus(efb->main_layout); - evas_object_smart_callback_call(efb->main_layout, "back", efb->entry); -} - -static void -_flow_prev(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Elm_Genlist_Item *egi; - Ephoto_Flow_Browser *efb = data; - Evas_Object *edje; - - elm_toolbar_item_selected_set(efb->action.go_prev, EINA_FALSE); - - elm_toolbar_item_disabled_set(efb->action.go_prev, EINA_TRUE); - elm_toolbar_item_disabled_set(efb->action.go_next, EINA_TRUE); - efb->mouse_wheel = EINA_TRUE; - efb->key_down = EINA_TRUE; - - edje = elm_layout_edje_get(efb->layout); - - egi = elm_genlist_item_prev_get(efb->egi); - if (!egi) - egi = elm_genlist_last_item_get(efb->list); - elm_genlist_item_bring_in(egi); - efb->egi = egi; - efb->selected_handled = 1; - elm_genlist_item_selected_set(egi, EINA_TRUE); - elm_genlist_no_select_mode_set(efb->list, EINA_TRUE); - - efb->flow_direct = 0; - edje_object_signal_emit(edje, "right", "ephoto"); -} - -static void -_flow_next(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Elm_Genlist_Item *egi; - Ephoto_Flow_Browser *efb = data; - Evas_Object *edje; - - elm_toolbar_item_selected_set(efb->action.go_next, EINA_FALSE); - - elm_toolbar_item_disabled_set(efb->action.go_prev, EINA_TRUE); - elm_toolbar_item_disabled_set(efb->action.go_next, EINA_TRUE); - efb->mouse_wheel = EINA_TRUE; - efb->key_down = EINA_TRUE; - - edje = elm_layout_edje_get(efb->layout); - - egi = elm_genlist_item_next_get(efb->egi); - if (!egi) - egi = elm_genlist_first_item_get(efb->list); - elm_genlist_item_bring_in(egi); - efb->egi = egi; - efb->selected_handled = 1; - elm_genlist_item_selected_set(egi, EINA_TRUE); - elm_genlist_no_select_mode_set(efb->list, EINA_TRUE); - - efb->flow_direct = 1; - edje_object_signal_emit(edje, "left", "ephoto"); -} - -static void -_center_image_clicked(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - - evas_object_key_ungrab(efb->main_layout, "Escape", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Left", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Right", 0, 0); - evas_object_key_ungrab(efb->main_layout, "BackSpace", 0, 0); - evas_object_key_ungrab(efb->main_layout, "space", 0, 0); - - efb->entry = eina_list_data_get(efb->current_index); - - elm_object_unfocus(efb->main_layout); - evas_object_smart_callback_call(efb->main_layout, "single", efb->entry); -} - -static void -_flow_single(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - - evas_object_key_ungrab(efb->main_layout, "Escape", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Left", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Right", 0, 0); - evas_object_key_ungrab(efb->main_layout, "BackSpace", 0, 0); - evas_object_key_ungrab(efb->main_layout, "space", 0, 0); - - efb->entry = eina_list_data_get(efb->current_index); - - elm_object_unfocus(efb->main_layout); - evas_object_smart_callback_call(efb->main_layout, "single", efb->entry); -} - -static void -_show_slideshow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - - elm_toolbar_item_selected_set(efb->action.slideshow, EINA_FALSE); - - evas_object_key_ungrab(efb->main_layout, "Escape", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Left", 0, 0); - evas_object_key_ungrab(efb->main_layout, "Right", 0, 0); - evas_object_key_ungrab(efb->main_layout, "BackSpace", 0, 0); - evas_object_key_ungrab(efb->main_layout, "space", 0, 0); - - elm_object_unfocus(efb->main_layout); - evas_object_smart_callback_call(efb->main_layout, "slideshow", efb->entry); -} - -static void -_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto_Flow_Browser *efb = data; - Evas_Event_Key_Down *ev = event_info; - const char *k = ev->keyname; - - if (efb->key_down) - return; - efb->key_down = EINA_TRUE; - - if (!strcmp(k, "Escape")) - _flow_back(efb, NULL, NULL); - if (!strcmp(k, "Left") || !strcmp(k, "BackSpace")) - _flow_prev(efb, NULL, NULL); - if (!strcmp(k, "Right") || !strcmp(k, "space")) - _flow_next(efb, NULL, NULL); -} - -static void -_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto_Flow_Browser *efb = data; - Evas_Event_Mouse_Wheel *ev = event_info; - - if (efb->mouse_wheel) - return; - efb->mouse_wheel = EINA_TRUE; - - if (ev->z > 0) - _flow_next(efb, NULL, NULL); - else - _flow_prev(efb, NULL, NULL); -} - -static void -_layout_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Flow_Browser *efb = data; - - if (efb->entry) - ephoto_entry_free_listener_del(efb->entry, _entry_free, efb); - - free(efb); -} - -static Elm_Toolbar_Item * -_toolbar_item_add(Ephoto_Flow_Browser *efb, const char *icon, const char *label, int priority, Evas_Smart_Cb cb) -{ - Elm_Toolbar_Item *item = elm_toolbar_item_append(efb->toolbar, icon, label, - cb, efb); - elm_toolbar_item_priority_set(item, priority); - return item; -} - -static char * -_gl_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) -{ - Ephoto_Entry *en = data; - char *label = (char *)en->basename; - return strdup(label); -} - -static Evas_Object * -_gl_icon_get(void *data __UNUSED__, Evas_Object *obj, const char *part) -{ - Evas_Object *o = NULL; - - if (!strcmp(part, "elm.swallow.end")) - return o; - - o = elm_icon_add(obj); - elm_icon_standard_set(o, "image"); - evas_object_size_hint_aspect_set(o, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - - return o; -} - -static Eina_Bool -_gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) -{ - return EINA_FALSE; -} - -static void -_gl_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__) -{ -} - -static int -_entry_cmp(const void *pa, const void *pb) -{ - const Ephoto_Entry *a = pa, *b = pb; - int ret, s; - - s = strcmp(a->basename, b->basename); - if (s > 0) - ret = 1; - else if (s < 0) - ret = -1; - else - ret = 0; - return ret; -} - -static void -_gl_sel(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Elm_Genlist_Item *egi, *egip, *egin; - Ephoto_Entry *en; - Ephoto_Flow_Browser *efb = data; - - egi = event_info; - if (!efb->egi || efb->selected_handled) - { - efb->selected_handled = 0; - return; - } - - egin = elm_genlist_item_next_get(efb->egi); - if (!egin) - egin = elm_genlist_first_item_get(efb->list); - egip = elm_genlist_item_prev_get(efb->egi); - if (!egip) - egip = elm_genlist_last_item_get(efb->list); - - if (egi == egin) - _flow_next(efb, NULL, NULL); - else if (egi == egip) - _flow_prev(efb, NULL, NULL); - else - { - en = elm_genlist_item_data_get(egi); - efb->current_index = eina_list_search_sorted_list - (efb->items, _entry_cmp, en); - efb->egi = egi; - _flow_browser_image_set(efb); - } -} - -Evas_Object * -ephoto_flow_browser_add(Ephoto *e, Evas_Object *parent) -{ - Ephoto_Flow_Browser *efb; - int i; - - efb = calloc(1, sizeof(Ephoto_Flow_Browser)); - - efb->swallows[0] = "offscreen_left"; - efb->swallows[1] = "left"; - efb->swallows[2] = "center"; - efb->swallows[3] = "right"; - efb->swallows[4] = "offscreen_right"; - efb->key_down = EINA_FALSE; - efb->mouse_wheel = EINA_FALSE; - efb->ephoto = e; - efb->selected_handled = 0; - - egli.item_style = "default"; - egli.func.label_get = _gl_label_get; - egli.func.icon_get = _gl_icon_get; - egli.func.state_get = _gl_state_get; - egli.func.del = _gl_del; - - efb->main_layout = elm_layout_add(parent); - efb->edje = elm_layout_edje_get(efb->main_layout); - evas_object_event_callback_add - (efb->main_layout, EVAS_CALLBACK_DEL, _layout_del, efb); - evas_object_event_callback_add - (efb->main_layout, EVAS_CALLBACK_KEY_DOWN, _key_down, efb); - evas_object_data_set(efb->main_layout, "flow_browser", efb); - - if (efb->ephoto->config->autohide_toolbar) - { - edje_object_signal_callback_add - (efb->edje, "mouse,clicked,1", "toolbar_event", - ephoto_auto_hide_toolbar, efb->ephoto); - if (!elm_layout_file_set - (efb->main_layout, THEME_FILE, "ephoto/layout/simple/autohide")) - { - ERR("could not load style 'ephoto/layout/simple/autohide' from theme"); - goto error; - } - } - else - { - if (!elm_layout_file_set - (efb->main_layout, THEME_FILE, "ephoto/layout/simple")) - { - ERR("could not load style 'ephoto/layout/simple' from theme"); - goto error; - } - } - - efb->toolbar = elm_toolbar_add(efb->main_layout); - elm_toolbar_homogenous_set(efb->toolbar, EINA_TRUE); - elm_toolbar_mode_shrink_set(efb->toolbar, ELM_TOOLBAR_SHRINK_MENU); - elm_toolbar_menu_parent_set(efb->toolbar, parent); - evas_object_size_hint_weight_set(efb->toolbar, 0.0, 0.0); - evas_object_size_hint_align_set(efb->toolbar, EVAS_HINT_FILL, 0.0); - - efb->action.go_back = _toolbar_item_add - (efb, "edit-undo", "Back", 120, _flow_back); - efb->action.go_prev = _toolbar_item_add - (efb, "go-previous", "Previous", 100, _flow_prev); - efb->action.go_next = _toolbar_item_add - (efb, "go-next", "Next", 80, _flow_next); - efb->action.slideshow = _toolbar_item_add - (efb, "media-playback-start", "Slideshow", 70, _show_slideshow); - - elm_layout_content_set - (efb->main_layout, "ephoto.toolbar.swallow", efb->toolbar); - evas_object_show(efb->toolbar); - - efb->box = elm_panes_add(efb->main_layout); - elm_panes_horizontal_set(efb->box, EINA_TRUE); - evas_object_size_hint_weight_set - (efb->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(efb->box); - - efb->layout = elm_layout_add(efb->main_layout); - elm_layout_file_set - (efb->layout, THEME_FILE, "flow"); - evas_object_size_hint_weight_set - (efb->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_fill_set - (efb->layout, EVAS_HINT_FILL, EVAS_HINT_EXPAND); - elm_panes_content_left_set(efb->box, efb->layout); - evas_object_show(efb->layout); - evas_object_event_callback_add - (efb->layout, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel, efb); - edje_object_signal_callback_add - (elm_layout_edje_get(efb->layout), "done", "ephoto", _flow_done, efb); - - efb->list = elm_genlist_add(efb->main_layout); - elm_genlist_bounce_set(efb->list, EINA_FALSE, EINA_TRUE); - elm_genlist_height_for_width_mode_set(efb->list, EINA_TRUE); - elm_genlist_compress_mode_set(efb->list, EINA_TRUE); - elm_genlist_longpress_timeout_set(efb->list, 0.5); - evas_object_size_hint_weight_set(efb->list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(efb->list, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_panes_content_right_set(efb->box, efb->list); - evas_object_show(efb->list); - - elm_panes_content_left_size_set(efb->box, 0.4); - - elm_layout_content_set - (efb->main_layout, "ephoto.content.swallow", efb->box); - - - for (i = 0; i < 5; i++) - { - efb->img_edje[i] = _add_image_edje(efb->swallows[i], efb->layout); - efb->images[i] = _add_image(efb->img_edje[i], efb->layout); - if (i == 2) - evas_object_event_callback_add - (efb->img_edje[2], EVAS_CALLBACK_MOUSE_DOWN, _center_image_clicked, efb); - } - - elm_object_focus_custom_chain_append(efb->main_layout, efb->layout, NULL); - - return efb->main_layout; - - error: - evas_object_del(efb->main_layout); - return NULL; -} - -void -ephoto_flow_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry) -{ - Ephoto_Flow_Browser *efb = evas_object_data_get(obj, "flow_browser"); - Eina_Bool same_file = EINA_FALSE; - Eina_List *l; - Ephoto_Entry *itr; - - if (!evas_object_key_grab(efb->main_layout, "Escape", 0, 0, 1)) - printf("Couldn't grab Escape key\n"); - if (!evas_object_key_grab(efb->main_layout, "Left", 0, 0, 1)) - printf("Couldn't grab Left key\n"); - if (!evas_object_key_grab(efb->main_layout, "Right", 0, 0, 1)) - printf("Couldn't grab Right key\n"); - if (!evas_object_key_grab(efb->main_layout, "BackSpace", 0, 0, 1)) - printf("Couldn't grab BackSpace key\n"); - if (!evas_object_key_grab(efb->main_layout, "space", 0, 0, 1)) - printf("Couldn't grab space key\n"); - - if (efb->entry) - { - ephoto_entry_free_listener_del(efb->entry, _entry_free, efb); - if (entry && entry->path == efb->entry->path) - same_file = EINA_TRUE; - } - - efb->entry = entry; - - if (entry) - ephoto_entry_free_listener_add(entry, _entry_free, efb); - if (!efb->entry) - { - elm_toolbar_item_disabled_set(efb->action.go_prev, EINA_TRUE); - elm_toolbar_item_disabled_set(efb->action.go_next, EINA_TRUE); - elm_toolbar_item_disabled_set(efb->action.slideshow, EINA_TRUE); - return; - } - else - { - elm_toolbar_item_disabled_set(efb->action.go_prev, EINA_FALSE); - elm_toolbar_item_disabled_set(efb->action.go_next, EINA_FALSE); - elm_toolbar_item_disabled_set(efb->action.slideshow, EINA_FALSE); - } - elm_genlist_clear(efb->list); - eina_list_free(efb->items); - efb->items = NULL; - EINA_LIST_FOREACH(efb->ephoto->entries, l, itr) - { - Elm_Genlist_Item *egi; - - egi = elm_genlist_item_append(efb->list, &egli, - (void *)itr, - NULL, ELM_GENLIST_ITEM_NONE, - _gl_sel, efb); - evas_object_smart_callback_add - (efb->list, "clicked", _flow_single, efb); - efb->items = eina_list_append(efb->items, itr); - if (itr == entry) - { - efb->current_index = eina_list_last(efb->items); - elm_genlist_item_bring_in(egi); - elm_genlist_item_selected_set(egi, EINA_TRUE); - efb->egi = egi; - } - } - _flow_browser_image_set(efb); -} - diff --git a/src/bin/ephoto_list_browser.c b/src/bin/ephoto_list_browser.c new file mode 100644 index 0000000..298039a --- /dev/null +++ b/src/bin/ephoto_list_browser.c @@ -0,0 +1,321 @@ +#include "ephoto.h" + +#define TODO_ITEM_MIN_BATCH 16 + +#define PARENT_DIR "Up" + +typedef struct _Ephoto_List_Browser Ephoto_List_Browser; + +struct _Ephoto_List_Browser +{ + Ephoto *ephoto; + Ephoto_Entry *entry; + Evas_Object *list; + Eio_File *ls; + Eina_List *todo_items; + Eina_List *list_items; + Eina_List *handlers; + + struct { + Ecore_Animator *todo_items; + } animator; + Eina_Bool list_deleted : 1; +}; + +static Elm_Genlist_Item_Class _ephoto_list_item_class; +static Elm_Genlist_Item_Class _ephoto_list_up_item_class; +static Ephoto_Entry *up_entry; + +static void +_todo_items_free(Ephoto_List_Browser *lb) +{ + eina_list_free(lb->todo_items); + lb->todo_items = NULL; +} + +static void +_list_items_free(Ephoto_List_Browser *lb) +{ + eina_list_free(lb->list_items); + lb->list_items = NULL; +} + +static char * +_ephoto_list_item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) +{ + Ephoto_Entry *e = data; + return strdup(e->label); +} + +static Evas_Object * +_ephoto_list_item_icon_get(void *data, Evas_Object *obj, const char *part) +{ + Ephoto_Entry *e = data; + if (strcmp(part, "elm.swallow.end")) + return ephoto_list_icon_add(e->ephoto, obj, "folder"); + else + return NULL; +} + +static Evas_Object * +_ephoto_list_item_up_icon_get(void *data, Evas_Object *obj, const char *part) +{ + Ephoto_Entry *e = data; + if (strcmp(part, "elm.swallow.end")) + return ephoto_list_icon_add(e->ephoto, obj, "go-up"); + else + return NULL; +} + +static void +_ephoto_list_item_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__) +{ + +} + +static void +_change_dir(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + Ephoto_Entry *e = data; + + ephoto_directory_set(e->ephoto, e->path); +} + +static int +_entry_cmp(const void *pa, const void *pb) +{ + const Ephoto_Entry *a = pa, *b = pb; + int ret, s; + + s = strcmp(a->basename, b->basename); + if (s > 0) + ret = 1; + else if (s < 0) + ret = -1; + else + ret = 0; + return ret; +} + +static void +_entry_item_add(Ephoto_List_Browser *lb, Ephoto_Entry *e) +{ + const Elm_Genlist_Item_Class *ic; + + ic = &_ephoto_list_item_class; + + if (!lb->list_items) + { + e->list_item = elm_genlist_item_append + (lb->list, ic, e, NULL, ELM_GENLIST_ITEM_NONE, _change_dir, e); + lb->list_items = eina_list_append(lb->list_items, e); + } + else + { + int near_cmp; + Ephoto_Entry *near_entry; + Elm_Genlist_Item *near_item; + Eina_List *near_node = eina_list_search_sorted_near_list + (lb->list_items, _entry_cmp, e, &near_cmp); + + near_entry = near_node->data; + near_item = near_entry->list_item; + if (near_cmp < 0) + { + e->list_item = elm_genlist_item_insert_after + (lb->list, ic, e, NULL, near_item, ELM_GENLIST_ITEM_NONE, _change_dir, e); + lb->list_items = eina_list_append_relative_list + (lb->list_items, e, near_node); + } + else + { + e->list_item = elm_genlist_item_insert_before + (lb->list, ic, e, NULL, near_item, ELM_GENLIST_ITEM_NONE, _change_dir, e); + lb->list_items = eina_list_prepend_relative_list + (lb->list_items, e, near_node); + } + } + if (e->list_item) + elm_genlist_item_data_set(e->list_item, e); + else + { + ERR("could not add item to list: path '%s'", e->path); + ephoto_entry_free(e); + return; + } +} + +static Eina_Bool +_todo_items_process(void *data) +{ + Ephoto_List_Browser *lb = data; + Ephoto_Entry *entry; + + if ((lb->ls) && (eina_list_count(lb->todo_items) < TODO_ITEM_MIN_BATCH)) + return EINA_TRUE; + + lb->animator.todo_items = NULL; + + EINA_LIST_FREE(lb->todo_items, entry) + _entry_item_add(lb, entry); + + return EINA_FALSE; +} + +static void +_list_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) +{ + Ephoto_List_Browser *lb = data; + Ecore_Event_Handler *handler; + + _todo_items_free(lb); + _list_items_free(lb); + EINA_LIST_FREE(lb->handlers, handler) + ecore_event_handler_del(handler); + + if (lb->animator.todo_items) + { + ecore_animator_del(lb->animator.todo_items); + lb->animator.todo_items = NULL; + } + if (lb->ls) + { + lb->list_deleted = EINA_TRUE; + eio_file_cancel(lb->ls); + return; + } + free(lb); +} + +static Eina_Bool +_ephoto_list_populate_start(void *data, int type __UNUSED__, void *event __UNUSED__) +{ + Ephoto_List_Browser *lb = data; + char *parent_dir; + + _todo_items_free(lb); + _list_items_free(lb); + elm_genlist_clear(lb->list); + + parent_dir = ecore_file_dir_get(lb->ephoto->config->directory); + if (parent_dir && strcmp(lb->ephoto->config->directory, "/")) + { + Elm_Genlist_Item_Class *ic; + + if (up_entry) + ephoto_entry_free(up_entry); + up_entry = ephoto_entry_new(lb->ephoto, parent_dir, "Up"); + ic = &_ephoto_list_up_item_class; + elm_genlist_item_append + (lb->list, ic, up_entry, NULL, ELM_GENLIST_ITEM_NONE, _change_dir, up_entry); + } + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_ephoto_list_populate_end(void *data, int type __UNUSED__, void *event __UNUSED__) +{ + Ephoto_List_Browser *lb = data; + + lb->ls = NULL; + if (lb->list_deleted) + { + free(lb); + return ECORE_CALLBACK_PASS_ON; + } + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_ephoto_list_populate_error(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) +{ + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_ephoto_list_entry_create(void *data, int type __UNUSED__, void *event) +{ + Ephoto_List_Browser *lb = data; + Ephoto_Event_Entry_Create *ev = event; + Ephoto_Entry *e; + + e = ev->entry; + lb->todo_items = eina_list_append(lb->todo_items, e); + + if (!lb->animator.todo_items) + lb->animator.todo_items = ecore_animator_add(_todo_items_process, lb); + + return ECORE_CALLBACK_PASS_ON; +} + +Evas_Object * +ephoto_list_browser_add(Ephoto *ephoto, Evas_Object *parent) +{ + Ephoto_List_Browser *lb; + char *parent_dir; + + lb = calloc(1, sizeof(Ephoto_List_Browser)); + EINA_SAFETY_ON_NULL_GOTO(lb, error); + lb->ephoto = ephoto; + + _ephoto_list_item_class.item_style = "default"; + _ephoto_list_item_class.func.label_get = _ephoto_list_item_label_get; + _ephoto_list_item_class.func.icon_get = _ephoto_list_item_icon_get; + _ephoto_list_item_class.func.state_get = NULL; + _ephoto_list_item_class.func.del = _ephoto_list_item_del; + + _ephoto_list_up_item_class.item_style = "default"; + _ephoto_list_up_item_class.func.label_get = _ephoto_list_item_label_get; + _ephoto_list_up_item_class.func.icon_get = _ephoto_list_item_up_icon_get; + _ephoto_list_up_item_class.func.state_get = NULL; + _ephoto_list_up_item_class.func.del = _ephoto_list_item_del; + + lb->list = elm_genlist_add(parent); + elm_genlist_multi_select_set(lb->list, EINA_FALSE); + elm_genlist_horizontal_mode_set(lb->list, EINA_FALSE); + evas_object_data_set(lb->list, "list_browser", lb); + evas_object_event_callback_add(lb->list, EVAS_CALLBACK_DEL, _list_del, lb); + evas_object_show(lb->list); + + parent_dir = ecore_file_dir_get(lb->ephoto->config->directory); + if (parent_dir) + { + Elm_Genlist_Item_Class *ic; + + ic = &_ephoto_list_up_item_class; + up_entry = ephoto_entry_new(lb->ephoto, parent_dir, "Up"); + elm_genlist_item_append + (lb->list, ic, up_entry, NULL, ELM_GENLIST_ITEM_NONE, _change_dir, up_entry); + } + lb->handlers = eina_list_append + (lb->handlers, ecore_event_handler_add + (EPHOTO_EVENT_POPULATE_START, _ephoto_list_populate_start, lb)); + + lb->handlers = eina_list_append + (lb->handlers, ecore_event_handler_add + (EPHOTO_EVENT_POPULATE_END, _ephoto_list_populate_end, lb)); + + lb->handlers = eina_list_append + (lb->handlers, ecore_event_handler_add + (EPHOTO_EVENT_POPULATE_ERROR, _ephoto_list_populate_error, lb)); + + lb->handlers = eina_list_append + (lb->handlers, ecore_event_handler_add + (EPHOTO_EVENT_ENTRY_CREATE_DIR, _ephoto_list_entry_create, lb)); + + return lb->list; + + error: + evas_object_del(lb->list); + return NULL; +} + +void +ephoto_list_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry) +{ + Ephoto_List_Browser *lb = evas_object_data_get(obj, "list_browser"); + lb->entry = entry; +} + diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index d7dfa2a..9066d65 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -1,6 +1,7 @@ #include "ephoto.h" -int EPHOTO_EVENT_ENTRY_CREATE = 0; +int EPHOTO_EVENT_ENTRY_CREATE_DIR = 0; +int EPHOTO_EVENT_ENTRY_CREATE_THUMB = 0; int EPHOTO_EVENT_POPULATE_START = 0; int EPHOTO_EVENT_POPULATE_END = 0; int EPHOTO_EVENT_POPULATE_ERROR = 0; @@ -20,155 +21,18 @@ _ephoto_state_set(Ephoto *ephoto, Ephoto_State state) } static void -_ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry) -{ - DBG("entry '%s'", entry ? entry->path : ""); - - ephoto_single_browser_entry_set(ephoto->single_browser, NULL); - ephoto_slideshow_entry_set(ephoto->slideshow, NULL); - elm_pager_content_promote(ephoto->pager, ephoto->thumb_browser); - _ephoto_state_set(ephoto, EPHOTO_STATE_THUMB); - - if ((entry) && (entry->item)) elm_gengrid_item_bring_in(entry->item); - ephoto_thumb_browser_entry_set(ephoto->thumb_browser, entry); -} - -static void -_ephoto_flow_browser_show(Ephoto *ephoto, Ephoto_Entry *entry) -{ - DBG("entry '%s'", entry->path); - ephoto_flow_browser_entry_set(ephoto->flow_browser, entry); - elm_pager_content_promote(ephoto->pager, ephoto->flow_browser); - elm_object_focus(ephoto->flow_browser); - _ephoto_state_set(ephoto, EPHOTO_STATE_FLOW); -} - -static void -_ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry) -{ - DBG("entry '%s'", entry->path); - ephoto_single_browser_entry_set(ephoto->single_browser, entry); - elm_pager_content_promote(ephoto->pager, ephoto->single_browser); - _ephoto_state_set(ephoto, EPHOTO_STATE_SINGLE); -} - -static void -_ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry) -{ - DBG("entry '%s'", entry->path); - ephoto_slideshow_entry_set(ephoto->slideshow, entry); - elm_pager_content_promote(ephoto->pager, ephoto->slideshow); - _ephoto_state_set(ephoto, EPHOTO_STATE_SLIDESHOW); -} - -static void -_ephoto_single_browser_back(void *data, Evas_Object *obj __UNUSED__, void *event_info) +_back_clicked(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - switch (ephoto->prev_state) + + switch (ephoto->state) { - case EPHOTO_STATE_THUMB: - _ephoto_thumb_browser_show(ephoto, entry); - break; - case EPHOTO_STATE_FLOW: - _ephoto_flow_browser_show(ephoto, entry); - break; - default: - ERR("unhandled previous state %d", ephoto->prev_state); + case EPHOTO_STATE_SINGLE : ephoto_promote_thumb_browser(ephoto); break; + case EPHOTO_STATE_THUMB : ephoto_promote_list_browser(ephoto); break; + case EPHOTO_STATE_LIST : break; + default : break; } -} - -static void -_ephoto_flow_browser_back(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - _ephoto_thumb_browser_show(ephoto, entry); -} - -static void -_ephoto_slideshow_back(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - switch (ephoto->prev_state) - { - case EPHOTO_STATE_SINGLE: - _ephoto_single_browser_show(ephoto, entry); - break; - case EPHOTO_STATE_THUMB: - _ephoto_thumb_browser_show(ephoto, entry); - break; - case EPHOTO_STATE_FLOW: - _ephoto_flow_browser_show(ephoto, entry); - break; - default: - ERR("unhandled previous state %d", ephoto->prev_state); - } - elm_win_fullscreen_set(ephoto->win, EINA_FALSE); -} - -static void -_ephoto_thumb_browser_view(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - if (!entry) - entry = eina_list_nth(ephoto->entries, 0); - _ephoto_single_browser_show(ephoto, entry); -} - -static void -_ephoto_thumb_browser_flow(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - if (!entry) - entry = eina_list_nth(ephoto->entries, 0); - _ephoto_flow_browser_show(ephoto, entry); -} - -static void -_ephoto_thumb_browser_changed_directory(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto *ephoto = data; - ephoto_single_browser_entry_set(ephoto->single_browser, NULL); - ephoto_slideshow_entry_set(ephoto->slideshow, NULL); -} - -static void -_ephoto_thumb_browser_slideshow(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - if (!entry) - entry = eina_list_nth(ephoto->entries, 0); - _ephoto_slideshow_show(ephoto, entry); -} - -static void -_ephoto_flow_browser_slideshow(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - _ephoto_slideshow_show(ephoto, entry); -} - -static void -_ephoto_flow_browser_single(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - _ephoto_single_browser_show(ephoto, entry); -} - -static void -_ephoto_single_browser_slideshow(void *data, Evas_Object *obj __UNUSED__, void *event_info) -{ - Ephoto *ephoto = data; - Ephoto_Entry *entry = event_info; - _ephoto_slideshow_show(ephoto, entry); + ephoto_title_set(ephoto, ephoto->config->directory); } static void @@ -184,10 +48,13 @@ ephoto_window_add(const char *path) { Ephoto *ephoto = calloc(1, sizeof(Ephoto)); Ethumb_Client *client = elm_thumb_ethumb_client_get(); + Evas_Object *o; char buf[PATH_MAX]; + int w, h; EINA_SAFETY_ON_NULL_RETURN_VAL(ephoto, NULL); - EPHOTO_EVENT_ENTRY_CREATE = ecore_event_type_new(); + EPHOTO_EVENT_ENTRY_CREATE_DIR = ecore_event_type_new(); + EPHOTO_EVENT_ENTRY_CREATE_THUMB = ecore_event_type_new(); EPHOTO_EVENT_POPULATE_START = ecore_event_type_new(); EPHOTO_EVENT_POPULATE_END = ecore_event_type_new(); EPHOTO_EVENT_POPULATE_ERROR = ecore_event_type_new(); @@ -224,14 +91,63 @@ ephoto_window_add(const char *path) elm_win_resize_object_add(ephoto->win, ephoto->bg); evas_object_show(ephoto->bg); + ephoto->layout = elm_layout_add(ephoto->win); + if (!ephoto->layout) + { + evas_object_del(ephoto->win); + return NULL; + } + if (!elm_layout_theme_set + (ephoto->layout, "layout", "application", "content-back")) + { + ERR("Content-back"); + evas_object_del(ephoto->win); + return NULL; + } + evas_object_size_hint_weight_set + (ephoto->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_fill_set(ephoto->layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_win_resize_object_add(ephoto->win, ephoto->layout); + ephoto->edje = elm_layout_edje_get(ephoto->layout); + edje_object_signal_callback_add(ephoto->edje, "elm,action,back", "", + _back_clicked, ephoto); + evas_object_show(ephoto->layout); + + o = edje_object_part_external_object_get(ephoto->edje, "back"); + evas_object_geometry_get(o, 0, 0, &w, &h); + ephoto->pager = elm_pager_add(ephoto->win); elm_object_style_set(ephoto->pager, "fade_invisible"); evas_object_size_hint_weight_set (ephoto->pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_fill_set (ephoto->pager, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_win_resize_object_add(ephoto->win, ephoto->pager); evas_object_show(ephoto->pager); + elm_layout_content_set(ephoto->layout, "elm.swallow.content", ephoto->pager); + + ephoto->help_but = elm_button_add(ephoto->win); + o = elm_icon_add(ephoto->help_but); + elm_icon_standard_set(o, "help-browser"); + evas_object_size_hint_aspect_set(o, EVAS_ASPECT_CONTROL_BOTH, 1, 1); + elm_button_icon_set(ephoto->help_but, o); + evas_object_size_hint_weight_set + (ephoto->help_but, 0.0, 0.0); + evas_object_size_hint_fill_set + (ephoto->help_but, 0.0, 0.0); + evas_object_size_hint_min_set(ephoto->help_but, w, h); + evas_object_size_hint_max_set(ephoto->help_but, w, h); + evas_object_show(ephoto->help_but); + elm_layout_content_set(ephoto->layout, "elm.swallow.end", ephoto->help_but); + + + ephoto->list_browser = ephoto_list_browser_add(ephoto, ephoto->pager); + if (!ephoto->list_browser) + { + ERR("could not add list browser"); + evas_object_del(ephoto->win); + return NULL; + } + elm_pager_content_push(ephoto->pager, ephoto->list_browser); ephoto->thumb_browser = ephoto_thumb_browser_add(ephoto, ephoto->pager); if (!ephoto->thumb_browser) @@ -241,32 +157,6 @@ ephoto_window_add(const char *path) return NULL; } elm_pager_content_push(ephoto->pager, ephoto->thumb_browser); - evas_object_smart_callback_add - (ephoto->thumb_browser, "view", _ephoto_thumb_browser_view, ephoto); - evas_object_smart_callback_add - (ephoto->thumb_browser, "flow", _ephoto_thumb_browser_flow, ephoto); - evas_object_smart_callback_add - (ephoto->thumb_browser, "changed,directory", - _ephoto_thumb_browser_changed_directory, ephoto); - evas_object_smart_callback_add - (ephoto->thumb_browser, "slideshow", - _ephoto_thumb_browser_slideshow, ephoto); - - ephoto->flow_browser = ephoto_flow_browser_add(ephoto, ephoto->pager); - if (!ephoto->flow_browser) - { - ERR("could not add flow browser"); - evas_object_del(ephoto->win); - return NULL; - } - elm_pager_content_push(ephoto->pager, ephoto->flow_browser); - evas_object_smart_callback_add - (ephoto->flow_browser, "back", _ephoto_flow_browser_back, ephoto); - evas_object_smart_callback_add - (ephoto->flow_browser, "slideshow", - _ephoto_flow_browser_slideshow, ephoto); - evas_object_smart_callback_add - (ephoto->flow_browser, "single", _ephoto_flow_browser_single, ephoto); ephoto->single_browser = ephoto_single_browser_add(ephoto, ephoto->pager); if (!ephoto->single_browser) @@ -276,22 +166,6 @@ ephoto_window_add(const char *path) return NULL; } elm_pager_content_push(ephoto->pager, ephoto->single_browser); - evas_object_smart_callback_add - (ephoto->single_browser, "back", _ephoto_single_browser_back, ephoto); - evas_object_smart_callback_add - (ephoto->single_browser, "slideshow", - _ephoto_single_browser_slideshow, ephoto); - - ephoto->slideshow = ephoto_slideshow_add(ephoto, ephoto->pager); - if (!ephoto->slideshow) - { - ERR("could not add slideshow"); - evas_object_del(ephoto->win); - return NULL; - } - elm_pager_content_push(ephoto->pager, ephoto->slideshow); - evas_object_smart_callback_add - (ephoto->slideshow, "back", _ephoto_slideshow_back, ephoto); if ((!path) || (!ecore_file_exists(path))) { @@ -308,22 +182,20 @@ ephoto_window_add(const char *path) if (ecore_file_is_dir(path)) { + ephoto_promote_list_browser(ephoto); ephoto_directory_set(ephoto, path); - _ephoto_thumb_browser_show(ephoto, NULL); } else { + ephoto_single_browser_path_pending_set(ephoto->single_browser, path); + ephoto_promote_single_browser(ephoto, NULL); char *dir = ecore_file_dir_get(path); ephoto_directory_set(ephoto, dir); free(dir); - ephoto_single_browser_path_pending_set(ephoto->single_browser, path); - - elm_pager_content_promote(ephoto->pager, ephoto->single_browser); - ephoto->state = EPHOTO_STATE_SINGLE; } /* TODO restore size from last run as well? */ - evas_object_resize(ephoto->win, 900, 600); + evas_object_resize(ephoto->win, 800, 600); evas_object_show(ephoto->win); return ephoto->win; @@ -334,8 +206,34 @@ ephoto_title_set(Ephoto *ephoto, const char *title) { char buf[1024] = "Ephoto"; - if (title) snprintf(buf, sizeof(buf), "%s - Ephoto", title); + if (title) snprintf(buf, sizeof(buf), "Ephoto - %s", title); elm_win_title_set(ephoto->win, buf); + edje_object_part_text_set(ephoto->edje, "elm.text.title", title); +} + +void +ephoto_promote_list_browser(Ephoto *ephoto) +{ + elm_pager_content_promote(ephoto->pager, ephoto->list_browser); + edje_object_signal_emit(ephoto->edje, "elm,back,hide", "elm"); + _ephoto_state_set(ephoto, EPHOTO_STATE_LIST); +} + +void +ephoto_promote_thumb_browser(Ephoto *ephoto) +{ + elm_pager_content_promote(ephoto->pager, ephoto->thumb_browser); + edje_object_signal_emit(ephoto->edje, "elm,back,show", "elm"); + _ephoto_state_set(ephoto, EPHOTO_STATE_THUMB); +} + +void +ephoto_promote_single_browser(Ephoto *ephoto, Ephoto_Entry *e) +{ + elm_pager_content_promote(ephoto->pager, ephoto->single_browser); + if (e) + ephoto_single_browser_entry_set(ephoto->single_browser, e); + _ephoto_state_set(ephoto, EPHOTO_STATE_SINGLE); } static int @@ -368,7 +266,14 @@ _ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_ ev = calloc(1, sizeof(Ephoto_Event_Entry_Create)); ev->entry = e; - ecore_event_add(EPHOTO_EVENT_ENTRY_CREATE, ev, NULL, NULL); + if (ecore_file_is_dir(info->path)) + ecore_event_add(EPHOTO_EVENT_ENTRY_CREATE_DIR, ev, NULL, NULL); + else + { + ecore_event_add(EPHOTO_EVENT_ENTRY_CREATE_THUMB, ev, NULL, NULL); + if (ephoto->state == EPHOTO_STATE_LIST) + ephoto_promote_thumb_browser(ephoto); + } } static Eina_Bool @@ -378,7 +283,10 @@ _ephoto_populate_filter(void *data __UNUSED__, Eio_File *handler __UNUSED__, con if (bname[0] == '.') return EINA_FALSE; - return _ephoto_eina_file_direct_info_image_useful(info); + if (ecore_file_is_dir(info->path)) + return EINA_TRUE; + else + return _ephoto_eina_file_direct_info_image_useful(info); } static void @@ -537,6 +445,23 @@ ephoto_thumb_path_set(Evas_Object *o, const char *path) elm_thumb_file_set(o, path, NULL); } +Evas_Object * +ephoto_list_icon_add(Ephoto *ephoto, Evas_Object *parent, const char *standard) +{ + Evas_Object *o; + + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); + + o = elm_icon_add(parent); + if (!o) return NULL; + + if (standard) elm_icon_standard_set(o, standard); + evas_object_size_hint_aspect_set(o, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + ephoto->dirs = eina_list_append(ephoto->dirs, o); + + return o; +} + Ephoto_Entry * ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label) { @@ -605,21 +530,3 @@ ephoto_entries_free(Ephoto *ephoto) EINA_LIST_FREE(ephoto->entries, entry) ephoto_entry_free(entry); } -Eina_Bool -_toolbar_hide(void *data) -{ - Evas_Object *edje = data; - - edje_object_signal_emit(edje, "hide", "toolbar_event"); - - return EINA_TRUE; -} - -void -ephoto_auto_hide_toolbar(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__) -{ - Ecore_Timer *timer; - - timer = ecore_timer_add(5, _toolbar_hide, obj); -} - diff --git a/src/bin/ephoto_preferences.c b/src/bin/ephoto_preferences.c deleted file mode 100644 index a36c2d1..0000000 --- a/src/bin/ephoto_preferences.c +++ /dev/null @@ -1,189 +0,0 @@ -#include "ephoto.h" - -#if 0 -static void _ephoto_preferences_pager_switch(void *data, Evas_Object *obj, void *event_info); -static void _ephoto_preferences_hide(void *data, Evas_Object *obj, void *event_info); -static void _ephoto_preferences_item_change(void *data, Evas_Object *obj, void *event_info); -static void _ephoto_preferences_slideshow_transition(void *data, Evas_Object *obj, void *event_info); - -static void -_ephoto_key_pressed(void *data, Evas *e, Evas_Object *obj, void *event_data) -{ - Evas_Event_Key_Down *eku; - eku = (Evas_Event_Key_Down *)event_data; - if (!strcmp(eku->key, "Escape")) - _ephoto_preferences_hide(data, NULL, NULL); -} - -void -ephoto_show_preferences(Ephoto *em) -{ - if (!em->prefs_win) - { - Evas_Object *o, *tb, *box, *pager, *pg1, *pg2, *pg3, *scr; - const Eina_List *transitions, *l; - const char *transition; - - em->prefs_win = o = elm_win_inwin_add(em->win); - elm_object_style_set(o, "minimal"); - - box = elm_box_add(em->prefs_win); - evas_object_show(box); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_inwin_content_set(o, box); - - tb = elm_toolbar_add(box); - elm_toolbar_homogenous_set(tb, EINA_FALSE); - evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.5); - - elm_box_pack_end(box, tb); - evas_object_show(tb); - - pager = elm_pager_add(box); - - pg1 = elm_box_add(pager); - evas_object_size_hint_weight_set(pg1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(pg1); - elm_pager_content_push(pager, pg1); - evas_object_data_set(pg1, "pager", pager); - elm_toolbar_item_append(tb, NULL, "General", _ephoto_preferences_pager_switch, pg1); - - elm_box_pack_end(box, pager); - evas_object_show(pager); - - pg2 = elm_table_add(pager); - evas_object_size_hint_weight_set(pg2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(pg2); - elm_pager_content_push(pager, pg2); - evas_object_data_set(pg2, "pager", pager); - elm_toolbar_item_append(tb, NULL, "Slideshow", _ephoto_preferences_pager_switch, pg2); - - o = elm_label_add(pg2); - elm_label_label_set(o, "Delay:"); - evas_object_show(o); - elm_table_pack(pg2, o, 0, 0, 1, 1); - - o = elm_spinner_add(pg2); - elm_spinner_label_format_set(o, "%1.1f seconds"); - elm_spinner_step_set(o, 0.1); - elm_spinner_min_max_set(o, 1.0, 10.0); - elm_spinner_value_set(o, em->config->slideshow_timeout); - evas_object_data_set(o, "config", "slideshow_timeout"); - evas_object_smart_callback_add(o, "delay,changed", - _ephoto_preferences_item_change, em); - evas_object_show(o); - elm_table_pack(pg2, o, 1, 0, 1, 1); - - o = elm_label_add(pg2); - elm_label_label_set(o, "Transition:"); - evas_object_show(o); - elm_table_pack(pg2, o, 0, 1, 1, 1); - - o = elm_hoversel_add(pg2); - elm_hoversel_hover_parent_set(o, em->win); - elm_hoversel_label_set(o, em->config->slideshow_transition); - transitions = elm_slideshow_transitions_get(em->slideshow); - EINA_LIST_FOREACH(transitions, l, transition) - { - elm_hoversel_item_add(o, transition, NULL, ELM_ICON_NONE, _ephoto_preferences_slideshow_transition, em); - } - evas_object_show(o); - elm_table_pack(pg2, o, 1, 1, 1, 1); - - pg3 = elm_box_add(pager); - evas_object_size_hint_weight_set(pg3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(pg3); - elm_pager_content_push(pager, pg3); - evas_object_data_set(pg3, "pager", pager); - elm_toolbar_item_append(tb, NULL, "External Editor", _ephoto_preferences_pager_switch, pg3); - - o = elm_label_add(pg3); - elm_label_label_set(o, "Image editor:"); - elm_box_pack_end(pg3, o); - evas_object_show(o); - - scr = elm_scroller_add(pg3); - elm_box_pack_end(pg3, scr); - elm_scroller_bounce_set(scr, EINA_TRUE, EINA_FALSE); - evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(scr, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(scr); - - o = elm_entry_add(pg3); - elm_entry_single_line_set(o, EINA_TRUE); - evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_entry_entry_set(o, em->config->editor); - evas_object_data_set(o, "config", "editor"); - evas_object_smart_callback_add(o, "changed", - _ephoto_preferences_item_change, em); - elm_scroller_content_set(scr, o); - evas_object_show(o); - - o = elm_button_add(box); - elm_button_label_set(o, "Close"); - evas_object_size_hint_align_set(o, 1.0, 0.5); - evas_object_smart_callback_add(o, "clicked", _ephoto_preferences_hide, em); - elm_box_pack_end(box, o); - evas_object_show(o); - - - evas_object_event_callback_add(em->prefs_win, EVAS_CALLBACK_KEY_DOWN, - _ephoto_key_pressed, em); - - elm_toolbar_item_selected_set(elm_toolbar_first_item_get(tb), - EINA_TRUE); - elm_pager_content_promote(pager, pg1); - } - - elm_win_inwin_activate(em->prefs_win); - evas_object_focus_set(em->prefs_win, EINA_TRUE); -} - -static void -_ephoto_preferences_pager_switch(void *data, Evas_Object *obj, void *event_info) -{ - Evas_Object *o = data; - Evas_Object *pager = evas_object_data_get(o, "pager"); - - elm_pager_content_promote(pager, o); -} - -static void -_ephoto_preferences_item_change(void *data, Evas_Object *obj, void *event_info) -{ - Ephoto *em = data; - const char *key = evas_object_data_get(obj, "config"); - - if (!strcmp(key, "slideshow_timeout")) - em->config->slideshow_timeout = elm_spinner_value_get(obj); - else if (!strcmp(key, "editor")) - eina_stringshare_replace( - &em->config->editor, - eina_stringshare_add(elm_entry_entry_get(obj))); - - ephoto_config_save(em, EINA_FALSE); -} - -static void -_ephoto_preferences_slideshow_transition(void *data, Evas_Object *obj, void *event_info) -{ - Ephoto *em = data; - Elm_Hoversel_Item *it = event_info; - const char *transition = elm_hoversel_item_label_get(it); - - elm_hoversel_label_set(obj, transition); - em->config->slideshow_transition = transition; - ephoto_config_save(em, EINA_FALSE); -} - -static void -_ephoto_preferences_hide(void *data, Evas_Object *obj, void *event_info) -{ - Ephoto *em = data; - - evas_object_hide(em->prefs_win); - evas_object_focus_set(em->thumb_browser, EINA_TRUE); -} - -#endif diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c index 5089102..dc84af4 100644 --- a/src/bin/ephoto_single_browser.c +++ b/src/bin/ephoto_single_browser.c @@ -8,8 +8,8 @@ * elm_photocam and elm_image rotates their images internally. * Rotating the scroller is not correct and was rejected by Raster and others. */ -#define ROTATION 1 -#define ZOOM_STEP 0.2 + +#define ROTATION 0 typedef struct _Ephoto_Single_Browser Ephoto_Single_Browser; typedef struct _Ephoto_Viewer Ephoto_Viewer; @@ -17,28 +17,8 @@ typedef struct _Ephoto_Viewer Ephoto_Viewer; struct _Ephoto_Single_Browser { Ephoto *ephoto; - Evas_Object *layout; - Evas_Object *edje; + Evas_Object *box; Evas_Object *viewer; - Evas_Object *toolbar; - struct { - Elm_Toolbar_Item *back; - Elm_Toolbar_Item *zoom_in; - Elm_Toolbar_Item *zoom_out; - Elm_Toolbar_Item *zoom_1; - Elm_Toolbar_Item *zoom_fit; - Elm_Toolbar_Item *go_first; - Elm_Toolbar_Item *go_prev; - Elm_Toolbar_Item *go_next; - Elm_Toolbar_Item *go_last; -#ifdef ROTATION - Elm_Toolbar_Item *rotate_counterclock; - Elm_Toolbar_Item *rotate_clock; - Elm_Toolbar_Item *flip_horiz; - Elm_Toolbar_Item *flip_vert; -#endif - Elm_Toolbar_Item *slideshow; - } action; const char *pending_path; Ephoto_Entry *entry; Ephoto_Orient orient; @@ -55,27 +35,6 @@ struct _Ephoto_Viewer Eina_Bool fit:1; }; -static void _zoom_set(Ephoto_Single_Browser *sb, double zoom); -static void _zoom_in(Ephoto_Single_Browser *sb); -static void _zoom_out(Ephoto_Single_Browser *sb); - -static Eina_Bool -_path_is_jpeg(const char *path_stringshared) -{ - size_t len = eina_stringshare_strlen(path_stringshared); - const char *ext; - - if (len < sizeof(".jpg")) return EINA_FALSE; - ext = path_stringshared + len - (sizeof(".jpg") - 1); - if (strcasecmp(ext, ".jpg") == 0) return EINA_TRUE; - - if (len < sizeof(".jpeg")) return EINA_FALSE; - ext = path_stringshared + len - (sizeof(".jpeg") - 1); - if (strcasecmp(ext, ".jpeg") == 0) return EINA_TRUE; - - return EINA_FALSE; -} - static void _viewer_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { @@ -100,7 +59,7 @@ _viewer_add(Evas_Object *parent, const char *path) if (err != EVAS_LOAD_ERROR_NONE) goto load_error; evas_object_image_size_get(v->image, &w, &h); evas_object_size_hint_align_set(v->image, 0.5, 0.5); - evas_object_size_hint_weight_set(v->image, 1.0, 1.0); + evas_object_size_hint_weight_set(v->image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_min_set(v->image, w, h); evas_object_size_hint_max_set(v->image, w, h); evas_object_resize(v->image, w, h); @@ -159,29 +118,6 @@ _viewer_resized(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi _viewer_zoom_fit_apply(data); } -static void -_viewer_zoom_set(Evas_Object *obj, double zoom) -{ - Ephoto_Viewer *v = evas_object_data_get(obj, "viewer"); - EINA_SAFETY_ON_NULL_RETURN(v); - _viewer_zoom_apply(v, zoom); - - if (v->fit) - { - evas_object_event_callback_del_full - (v->scroller, EVAS_CALLBACK_RESIZE, _viewer_resized, v); - v->fit = EINA_FALSE; - } -} - -static double -_viewer_zoom_get(Evas_Object *obj) -{ - Ephoto_Viewer *v = evas_object_data_get(obj, "viewer"); - EINA_SAFETY_ON_NULL_RETURN_VAL(v, 0.0); - return v->zoom; -} - static void _viewer_zoom_fit(Evas_Object *obj) { @@ -197,230 +133,6 @@ _viewer_zoom_fit(Evas_Object *obj) _viewer_zoom_fit_apply(v); } -static void -_orient_apply(Ephoto_Single_Browser *sb) -{ -#ifdef ROTATION - unsigned int *im_data, *im_data_new; - int inde, ind, i, j, ni, nj, ew, eh, nw, nh; - Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer"); - - im_data = evas_object_image_data_get(v->image, FALSE); - evas_object_image_size_get(v->image, &ew, &eh); - inde = 0; - - switch (sb->orient) - { - case EPHOTO_ORIENT_90: - im_data_new = malloc(sizeof(unsigned int) * ew * eh); - nw = eh; - nh = ew; - for (i = 0; i < nh; i++) - { - for (j = 0; j < nw; j++) - { - ni = nw - j - 1; - nj = i; - - ind = ni * nh + nj; - - im_data_new[inde] = im_data[ind]; - - inde++; - } - } - evas_object_image_size_set(v->image, nw, nh); - evas_object_image_data_set(v->image, im_data_new); - evas_object_image_data_update_add(v->image, 0, 0, nw, nh); - _viewer_zoom_fit_apply(v); - break; - case EPHOTO_ORIENT_270: - im_data_new = malloc(sizeof(unsigned int) * ew * eh); - nw = eh; - nh = ew; - for (i = 0; i < nh; i++) - { - for (j = 0; j < nw; j++) - { - ni = j; - nj = nh - i - 1; - - ind = ni * nh + nj; - - im_data_new[inde] = im_data[ind]; - - inde++; - } - } - evas_object_image_size_set(v->image, nw, nh); - evas_object_image_data_set(v->image, im_data_new); - evas_object_image_data_update_add(v->image, 0, 0, nw, nh); - _viewer_zoom_fit_apply(v); - break; - case EPHOTO_ORIENT_FLIP_HORIZ: - im_data_new = malloc(sizeof(unsigned int) * ew * eh); - for (i = 0; i < eh; i++) - { - for (j = 0; j < ew; j++) - { - ni = i; - nj = ew - j - 1; - - ind = ni * ew + nj; - - im_data_new[inde] = im_data[ind]; - - inde++; - } - } - evas_object_image_size_set(v->image, ew, eh); - evas_object_image_data_set(v->image, im_data_new); - evas_object_image_data_update_add(v->image, 0, 0, ew, eh); - break; - case EPHOTO_ORIENT_FLIP_VERT: - im_data_new = malloc(sizeof(unsigned int) * ew * eh); - for (i = 0; i < eh; i++) - { - for (j = 0; j < ew; j++) - { - ni = eh - i - 1; - nj = j; - - ind = ni * ew + nj; - - im_data_new[inde] = im_data[ind]; - - inde++; - } - } - evas_object_image_size_set(v->image, ew, eh); - evas_object_image_data_set(v->image, im_data_new); - evas_object_image_data_update_add(v->image, 0, 0, ew, eh); - - break; - default: - return; - } -#else - (void)sb; -#endif -} - -#ifdef ROTATION -static void -_rotate_counterclock(Ephoto_Single_Browser *sb) -{ - sb->orient = EPHOTO_ORIENT_270; - _orient_apply(sb); -} - -static void -_rotate_clock(Ephoto_Single_Browser *sb) -{ - sb->orient = EPHOTO_ORIENT_90; - _orient_apply(sb); -} - -static void -_flip_horiz(Ephoto_Single_Browser *sb) -{ - sb->orient = EPHOTO_ORIENT_FLIP_HORIZ; - _orient_apply(sb); -} - -static void -_flip_vert(Ephoto_Single_Browser *sb) -{ - sb->orient = EPHOTO_ORIENT_FLIP_VERT; - _orient_apply(sb); -} -#endif - -static void -_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) -{ - Ephoto_Single_Browser *sb = data; - Evas_Event_Mouse_Wheel *ev = event_info; - if (!evas_key_modifier_is_set(ev->modifiers, "Control")) return; - - if (ev->z > 0) _zoom_in(sb); - else _zoom_out(sb); -} - -static Ephoto_Entry * -_first_entry_find(Ephoto_Single_Browser *sb) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(sb->ephoto, NULL); - - return eina_list_nth(sb->entries, 0); -} - -static Ephoto_Entry * -_last_entry_find(Ephoto_Single_Browser *sb) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(sb->ephoto, NULL); - - return eina_list_data_get(eina_list_last(sb->entries)); -} - -static void -_ephoto_single_browser_toolbar_eval(Ephoto_Single_Browser *sb) -{ - if (!sb->entry) - { - elm_toolbar_item_disabled_set(sb->action.go_first, EINA_TRUE); - elm_toolbar_item_disabled_set(sb->action.go_prev, EINA_TRUE); - elm_toolbar_item_disabled_set(sb->action.go_next, EINA_TRUE); - elm_toolbar_item_disabled_set(sb->action.go_last, EINA_TRUE); - elm_toolbar_item_disabled_set(sb->action.slideshow, EINA_TRUE); - } - else - { - Eina_Bool is_first = sb->entry == _first_entry_find(sb); - Eina_Bool is_last = sb->entry == _last_entry_find(sb); - - elm_toolbar_item_disabled_set(sb->action.go_first, is_first); - elm_toolbar_item_disabled_set(sb->action.go_prev, is_first); - elm_toolbar_item_disabled_set(sb->action.go_next, is_last); - elm_toolbar_item_disabled_set(sb->action.go_last, is_last); - elm_toolbar_item_disabled_set(sb->action.slideshow, EINA_FALSE); - } -} - -Ephoto_Orient -ephoto_file_orient_get(const char *path) -{ -#ifndef HAVE_LIBEXIF - return EPHOTO_ORIENT_0; -#else - Ephoto_Orient orient = EPHOTO_ORIENT_0; - ExifData *exif; - ExifEntry *entry; - ExifByteOrder bo; - - if (!_path_is_jpeg(path)) return orient; - - exif = exif_data_new_from_file(path); - if (!exif) goto end; - bo = exif_data_get_byte_order(exif); - entry = exif_data_get_entry(exif, EXIF_TAG_ORIENTATION); - if (!entry) goto end_entry; - - orient = exif_get_short(entry->data, bo); - DBG("orient=%d", orient); - if ((orient < 1) || (orient > 8)) - { - ERR("exif orient not supported: %d", orient); - orient = EPHOTO_ORIENT_0; - } - - end_entry: - exif_data_free(exif); - end: - return orient; -#endif -} - static void _ephoto_single_browser_recalc(Ephoto_Single_Browser *sb) { @@ -433,321 +145,32 @@ _ephoto_single_browser_recalc(Ephoto_Single_Browser *sb) if (sb->entry) { const char *bname = ecore_file_file_get(sb->entry->path); - sb->viewer = _viewer_add(sb->layout, sb->entry->path); - elm_layout_content_set - (sb->layout, "ephoto.content.swallow", sb->viewer); + sb->viewer = _viewer_add(sb->box, sb->entry->path); + elm_box_pack_end(sb->box, sb->viewer); evas_object_show(sb->viewer); - evas_object_event_callback_add - (sb->viewer, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel, sb); -// edje_object_part_text_set(sb->edje, "elm.text.title", bname); - ephoto_title_set(sb->ephoto, bname);; + ephoto_title_set(sb->ephoto, bname); + _viewer_zoom_fit(sb->viewer); } - elm_object_focus(sb->layout); - - _ephoto_single_browser_toolbar_eval(sb); + elm_object_focus(sb->box); } static void -_zoom_set(Ephoto_Single_Browser *sb, double zoom) -{ - DBG("zoom %f", zoom); - if (zoom <= 0.0) return; - _viewer_zoom_set(sb->viewer, zoom); -} - -static void -_zoom_fit(Ephoto_Single_Browser *sb) -{ - if (sb->viewer) _viewer_zoom_fit(sb->viewer); -} - -static void -_zoom_in(Ephoto_Single_Browser *sb) -{ - double change = (1.0 + ZOOM_STEP); - _viewer_zoom_set(sb->viewer, _viewer_zoom_get(sb->viewer) * change); -} - -static void -_zoom_out(Ephoto_Single_Browser *sb) -{ - double change = (1.0 - ZOOM_STEP); - _viewer_zoom_set(sb->viewer, _viewer_zoom_get(sb->viewer) * change); -} - -static void -_zoom_in_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.zoom_in, EINA_FALSE); - _zoom_in(sb); -} - -static void -_zoom_out_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.zoom_out, EINA_FALSE); - _zoom_out(sb); -} - -static void -_zoom_1_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.zoom_1, EINA_FALSE); - _zoom_set(sb, 1.0); -} - -static void -_zoom_fit_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.zoom_fit, EINA_FALSE); - _zoom_fit(sb); -} - -static void -_next_entry(Ephoto_Single_Browser *sb) -{ - Eina_List *next; - Ephoto_Entry *entry = NULL; - EINA_SAFETY_ON_NULL_RETURN(sb->entry); - - next = eina_list_next(sb->current_index); - if (!eina_list_data_get(next)) - next = eina_list_nth_list(sb->entries, 0); - entry = eina_list_data_get(next); - - if (entry) - { - DBG("next is '%s'", entry->path); - ephoto_single_browser_entry_set(sb->layout, entry); - } -} - -static void -_prev_entry(Ephoto_Single_Browser *sb) -{ - Eina_List *prev; - Ephoto_Entry *entry = NULL; - EINA_SAFETY_ON_NULL_RETURN(sb->entry); - - prev = eina_list_prev(sb->current_index); - if (!eina_list_data_get(prev)) - prev = eina_list_last(sb->entries); - entry = eina_list_data_get(prev); - - if (entry) - { - DBG("prev is '%s'", entry->path); - ephoto_single_browser_entry_set(sb->layout, entry); - } -} - -static void -_first_entry(Ephoto_Single_Browser *sb) -{ - Ephoto_Entry *entry = _first_entry_find(sb); - if (!entry) return; - DBG("first is '%s'", entry->path); - ephoto_single_browser_entry_set(sb->layout, entry); -} - -static void -_last_entry(Ephoto_Single_Browser *sb) -{ - Ephoto_Entry *entry = _last_entry_find(sb); - if (!entry) return; - DBG("last is '%s'", entry->path); - ephoto_single_browser_entry_set(sb->layout, entry); -} - -static void -_go_first(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.go_first, EINA_FALSE); - _first_entry(sb); -} - -static void -_go_prev(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.go_prev, EINA_FALSE); - _prev_entry(sb); -} - -static void -_go_next(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.go_next, EINA_FALSE); - _next_entry(sb); -} - -static void -_go_last(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.go_last, EINA_FALSE); - _last_entry(sb); -} - -#ifdef ROTATION -static void -_go_rotate_counterclock(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.rotate_counterclock, EINA_FALSE); - _rotate_counterclock(sb); -} - -static void -_go_rotate_clock(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.rotate_clock, EINA_FALSE); - _rotate_clock(sb); -} - -static void -_go_flip_horiz(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.flip_horiz, EINA_FALSE); - _flip_horiz(sb); -} - -static void -_go_flip_vert(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.flip_vert, EINA_FALSE); - _flip_vert(sb); -} -#endif - -static void -_slideshow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.slideshow, EINA_FALSE); - if (sb->entry) - evas_object_smart_callback_call(sb->layout, "slideshow", sb->entry); -} - -static void -_back(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - elm_toolbar_item_selected_set(sb->action.back, EINA_FALSE); - evas_object_smart_callback_call(sb->layout, "back", sb->entry); -} - -static void -_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) -{ - Ephoto_Single_Browser *sb = data; - Evas_Event_Key_Down *ev = event_info; - Eina_Bool ctrl = evas_key_modifier_is_set(ev->modifiers, "Control"); - Eina_Bool shift = evas_key_modifier_is_set(ev->modifiers, "Shift"); - const char *k = ev->keyname; - - DBG("key pressed '%s'", k); - if (ctrl) - { - if ((!strcmp(k, "plus")) || (!strcmp(k, "equal"))) - _zoom_in(sb); - else if (!strcmp(k, "minus")) - _zoom_out(sb); - else if (!strcmp(k, "0")) - { - if (shift) _zoom_fit(sb); - else _zoom_set(sb, 1.0); - } - - return; - } - - if (!strcmp(k, "Escape")) - evas_object_smart_callback_call(sb->layout, "back", sb->entry); - else if (!strcmp(k, "Left") || !strcmp(k, "BackSpace")) - _prev_entry(sb); - else if (!strcmp(k, "Right") || !strcmp(k, "space")) - _next_entry(sb); - else if (!strcmp(k, "Home")) - _first_entry(sb); - else if (!strcmp(k, "End")) - _last_entry(sb); -#if ROTATION - else if (!strcmp(k, "bracketleft")) - { - if (!shift) _rotate_counterclock(sb); - else _flip_horiz(sb); - } - else if (!strcmp(k, "bracketright")) - { - if (!shift) _rotate_clock(sb); - else _flip_vert(sb); - } -#endif - else if (!strcmp(k, "F5")) - { - if (sb->entry) - evas_object_smart_callback_call(sb->layout, "slideshow", sb->entry); - } -} - -static void -_entry_free(void *data, const Ephoto_Entry *entry __UNUSED__) -{ - Ephoto_Single_Browser *sb = data; - sb->entry = NULL; -} - -static void -_layout_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) +_box_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) { Ephoto_Single_Browser *sb = data; Ecore_Event_Handler *handler; EINA_LIST_FREE(sb->handlers, handler) ecore_event_handler_del(handler); - if (sb->entry) - ephoto_entry_free_listener_del(sb->entry, _entry_free, sb); if (sb->pending_path) eina_stringshare_del(sb->pending_path); free(sb); } -static Elm_Toolbar_Item * -_toolbar_item_add(Ephoto_Single_Browser *sb, const char *icon, const char *label, int priority, Evas_Smart_Cb cb) -{ - Elm_Toolbar_Item *item = elm_toolbar_item_append(sb->toolbar, icon, label, - cb, sb); - elm_toolbar_item_priority_set(item, priority); - return item; -} - -static Elm_Toolbar_Item * -_toolbar_item_separator_add(Ephoto_Single_Browser *sb) -{ - Elm_Toolbar_Item *it = elm_toolbar_item_append - (sb->toolbar, NULL, NULL, NULL, NULL); - elm_toolbar_item_separator_set(it, EINA_TRUE); - return it; -} - static Eina_Bool -_ephoto_single_populate_end(void *data, int type __UNUSED__, void *event __UNUSED__) +_ephoto_single_populate_end(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) { - Ephoto_Single_Browser *sb = data; - - _ephoto_single_browser_toolbar_eval(sb); - return ECORE_CALLBACK_PASS_ON; } @@ -761,8 +184,6 @@ _ephoto_single_entry_create(void *data, int type __UNUSED__, void *event __UNUSE e = ev->entry; if (!sb->entry && sb->pending_path && e->path == sb->pending_path) { - DBG("Adding entry %p for path %s", e, sb->pending_path); - eina_stringshare_del(sb->pending_path); sb->pending_path = NULL; ephoto_single_browser_entry_set(sb->ephoto->single_browser, e); @@ -774,104 +195,20 @@ _ephoto_single_entry_create(void *data, int type __UNUSED__, void *event __UNUSE Evas_Object * ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent) { - Evas_Object *layout = elm_layout_add(parent); Ephoto_Single_Browser *sb; - EINA_SAFETY_ON_NULL_RETURN_VAL(layout, NULL); - sb = calloc(1, sizeof(Ephoto_Single_Browser)); EINA_SAFETY_ON_NULL_GOTO(sb, error); sb->ephoto = ephoto; - sb->layout = layout; - sb->edje = elm_layout_edje_get(layout); - evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _layout_del, sb); - evas_object_event_callback_add - (layout, EVAS_CALLBACK_KEY_DOWN, _key_down, sb); - evas_object_data_set(layout, "single_browser", sb); - if (sb->ephoto->config->autohide_toolbar) - { - edje_object_signal_callback_add - (sb->edje, "mouse,clicked,1", "toolbar_event", - ephoto_auto_hide_toolbar, sb->ephoto); - if (!elm_layout_file_set - (layout, THEME_FILE, "ephoto/layout/simple/autohide")) - { - ERR("could not load style 'ephoto/layout/simple/autohide' from theme"); - goto error; - } - } - else - { - if (!elm_layout_file_set - (layout, THEME_FILE, "ephoto/layout/simple")) - { - ERR("could not load style 'ephoto/layout/simple' from theme"); - goto error; - } - } - - sb->toolbar = elm_toolbar_add(sb->layout); - elm_toolbar_homogenous_set(sb->toolbar, EINA_FALSE); - elm_toolbar_mode_shrink_set(sb->toolbar, ELM_TOOLBAR_SHRINK_MENU); - elm_toolbar_menu_parent_set(sb->toolbar, parent); - evas_object_size_hint_weight_set(sb->toolbar, 0.0, 0.0); - evas_object_size_hint_align_set(sb->toolbar, EVAS_HINT_FILL, 0.0); - - sb->action.back = _toolbar_item_add - (sb, "edit-undo", "Back", 200, _back); - - _toolbar_item_separator_add(sb); - - sb->action.slideshow = _toolbar_item_add - (sb, "media-playback-start", "Slideshow", 150, _slideshow); - - sb->action.zoom_in = _toolbar_item_add - (sb, "zoom-in", "Zoom In", 100, _zoom_in_cb); - sb->action.zoom_out = _toolbar_item_add - (sb, "zoom-out", "Zoom Out", 80, _zoom_out_cb); - sb->action.zoom_1 = _toolbar_item_add - (sb, "zoom-original", "Zoom 1:1", 50, _zoom_1_cb); - sb->action.zoom_fit = _toolbar_item_add - (sb, "zoom-fit-best", "Zoom Fit", 40, _zoom_fit_cb); - - _toolbar_item_separator_add(sb); - - sb->action.go_first = _toolbar_item_add(sb, "go-first", "First", 50, _go_first); - sb->action.go_prev = _toolbar_item_add - (sb, "go-previous", "Previous", 100, _go_prev); - sb->action.go_next = _toolbar_item_add(sb, "go-next", "Next", 50, _go_next); - sb->action.go_last = _toolbar_item_add(sb, "go-last", "Last", 50, _go_last); - - _toolbar_item_separator_add(sb); - -#ifdef ROTATION - sb->action.rotate_counterclock = _toolbar_item_add - (sb, "object-rotate-left", "Rotate Left", 50, _go_rotate_counterclock); - sb->action.rotate_clock = _toolbar_item_add - (sb, "object-rotate-right", "Rotate Right", 30, _go_rotate_clock); - sb->action.flip_horiz = _toolbar_item_add - (sb, "object-flip-horizontal", "Flip Horiz.", 30, _go_flip_horiz); - sb->action.flip_vert = _toolbar_item_add - (sb, "object-flip-vertical", "Flip Vert.", 30, _go_flip_vert); - - elm_toolbar_item_tooltip_text_set - (sb->action.rotate_counterclock, - "Rotate object to the left (counter-clockwise)"); - elm_toolbar_item_tooltip_text_set - (sb->action.rotate_clock, "Rotate object to the right (clockwise)"); - - elm_toolbar_item_tooltip_text_set - (sb->action.flip_horiz, "Flip object horizontally"); - elm_toolbar_item_tooltip_text_set - (sb->action.flip_vert, "Flip object vertically"); -#endif - - _ephoto_single_browser_toolbar_eval(sb); - - elm_layout_content_set - (sb->layout, "ephoto.toolbar.swallow", sb->toolbar); - evas_object_show(sb->toolbar); + sb->box = elm_box_add(parent); + evas_object_size_hint_weight_set + (sb->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_fill_set + (sb->box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_event_callback_add(sb->box, EVAS_CALLBACK_DEL, _box_del, sb); + evas_object_data_set(sb->box, "single_browser", sb); + evas_object_show(sb->box); sb->handlers = eina_list_append (sb->handlers, ecore_event_handler_add @@ -879,12 +216,12 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent) sb->handlers = eina_list_append (sb->handlers, ecore_event_handler_add - (EPHOTO_EVENT_ENTRY_CREATE, _ephoto_single_entry_create, sb)); + (EPHOTO_EVENT_ENTRY_CREATE_THUMB, _ephoto_single_entry_create, sb)); - return layout; + return sb->box; error: - evas_object_del(layout); + evas_object_del(sb->box); return NULL; } @@ -892,39 +229,11 @@ void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry) { Ephoto_Single_Browser *sb = evas_object_data_get(obj, "single_browser"); - Eina_List *l; - Ephoto_Entry *itr; - Eina_Bool same_file = EINA_FALSE; EINA_SAFETY_ON_NULL_RETURN(sb); - DBG("entry %p, was %p", entry, sb->entry); - - if (sb->entry) - { - ephoto_entry_free_listener_del(sb->entry, _entry_free, sb); - if (entry && entry->path == sb->entry->path) - same_file = EINA_TRUE; - } - sb->entry = entry; - if (entry) - ephoto_entry_free_listener_add(entry, _entry_free, sb); - - if (!sb->entry || same_file) - _ephoto_single_browser_toolbar_eval(sb); - else - { - _ephoto_single_browser_recalc(sb); - _zoom_fit(sb); - } - eina_list_free(sb->entries); - sb->entries = NULL; - EINA_LIST_FOREACH(sb->ephoto->entries, l, itr) - { - sb->entries = eina_list_append(sb->entries, itr); - if (itr == entry) sb->current_index = eina_list_last(sb->entries); - } + _ephoto_single_browser_recalc(sb); } void @@ -936,3 +245,4 @@ ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path) DBG("Setting pending path '%s'", path); sb->pending_path = eina_stringshare_add(path); } + diff --git a/src/bin/ephoto_slideshow.c b/src/bin/ephoto_slideshow.c deleted file mode 100644 index 5041f4f..0000000 --- a/src/bin/ephoto_slideshow.c +++ /dev/null @@ -1,192 +0,0 @@ -#include "ephoto.h" - -typedef struct _Ephoto_Slideshow Ephoto_Slideshow; - -struct _Ephoto_Slideshow -{ - Ephoto *ephoto; - Evas_Object *slideshow; - Ephoto_Entry *entry; -}; - -static void -_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) -{ - Ephoto_Slideshow *ss = data; - Evas_Event_Key_Down *ev = event_info; - const char *k = ev->keyname; - - if (!strcmp(k, "Escape")) - { - Evas_Object *win = ss->ephoto->win; - Elm_Slideshow_Item *item; - Ephoto_Entry *entry; - - if (elm_win_fullscreen_get(win)) - elm_win_fullscreen_set(win, EINA_FALSE); - - item = elm_slideshow_item_current_get(ss->slideshow); - if (item) entry = elm_slideshow_item_data_get(item); - else entry = ss->entry; - evas_object_smart_callback_call(ss->slideshow, "back", entry); - } - else if (!strcmp(k, "F11")) - { - Evas_Object *win = ss->ephoto->win; - elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win)); - } -} - -static void -_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Slideshow *ss = data; - evas_object_smart_callback_call(ss->slideshow, "back", ss->entry); -} - -static void -_entry_free(void *data, const Ephoto_Entry *entry __UNUSED__) -{ - Ephoto_Slideshow *ss = data; - ss->entry = NULL; -} - -static void -_slideshow_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Slideshow *ss = data; - if (ss->entry) - ephoto_entry_free_listener_del(ss->entry, _entry_free, ss); - free(ss); -} - -Evas_Object * -ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent) -{ - Evas_Object *slideshow = elm_slideshow_add(parent); - Ephoto_Slideshow *ss; - - EINA_SAFETY_ON_NULL_RETURN_VAL(slideshow, NULL); - - ss = calloc(1, sizeof(Ephoto_Slideshow)); - EINA_SAFETY_ON_NULL_GOTO(ss, error); - ss->ephoto = ephoto; - ss->slideshow = slideshow; - evas_object_event_callback_add - (slideshow, EVAS_CALLBACK_DEL, _slideshow_del, ss); - evas_object_event_callback_add - (slideshow, EVAS_CALLBACK_KEY_DOWN, _key_down, ss); - evas_object_event_callback_add - (slideshow, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, ss); - evas_object_data_set(slideshow, "slideshow", ss); - - elm_slideshow_loop_set(slideshow, EINA_TRUE); - elm_slideshow_layout_set(slideshow, "fullscreen"); - evas_object_size_hint_weight_set - (slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(slideshow, EVAS_HINT_FILL, EVAS_HINT_FILL); - - return ss->slideshow; - - error: - evas_object_del(slideshow); - return NULL; -} - -static void -_image_resized(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *image, void *event_info __UNUSED__) -{ - Evas_Map *map = evas_map_new(4); - Evas_Coord cx, cy, x, y, w, h; - int orient = (long)evas_object_data_get(image, "orient"); - - evas_object_geometry_get(image, &x, &y, &w, &h); - evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0); - cx = x + w / 2; - cy = y + h / 2; - - switch (orient) - { - case EPHOTO_ORIENT_0: - break; - case EPHOTO_ORIENT_90: - evas_map_util_rotate(map, 90.0, cx, cy); - evas_object_map_enable_set(image, EINA_TRUE); - evas_object_map_set(image, map); - printf("rotated 90 around %d,%d (%dx%d)\n", cx, cy, w, h); - break; - case EPHOTO_ORIENT_180: - evas_map_util_rotate(map, 180.0, cx, cy); - evas_object_map_enable_set(image, EINA_TRUE); - evas_object_map_set(image, map); - printf("rotated 180 around %d,%d (%d,%d %dx%d)\n", cx, cy, x, y, w, h); - break; - case EPHOTO_ORIENT_270: - evas_map_util_rotate(map, 270.0, cx, cy); - evas_object_map_enable_set(image, EINA_TRUE); - evas_object_map_set(image, map); - printf("rotated 270 around %d,%d (%dx%d)\n", cx, cy, w, h); - break; - default: - ERR("unknown orient %d", orient); - } - - evas_map_free(map); -} - -static Evas_Object * -_slideshow_item_get(void *data, Evas_Object *obj) -{ - Ephoto_Entry *entry = data; - /* TODO use viewer from ephoto_single_browser.c */ - /* TODO consider using exif rotation, see ephoto_single_browser.c */ - Evas_Object *image = elm_photo_add(obj); - elm_photo_file_set(image, entry->path); - elm_photo_fill_inside_set(image, EINA_TRUE); - elm_object_style_set(image, "shadow"); - - evas_object_data_set - (image, "orient", (void*)(long)ephoto_file_orient_get(entry->path)); - evas_object_event_callback_add - (image, EVAS_CALLBACK_RESIZE, _image_resized, NULL); - - return image; -} - -static const Elm_Slideshow_Item_Class _item_cls = {{_slideshow_item_get, NULL}}; - -void -ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry) -{ - Ephoto_Slideshow *ss = evas_object_data_get(obj, "slideshow"); - Ephoto_Config *conf; - Ephoto_Entry *itr; - const Eina_List *l; - EINA_SAFETY_ON_NULL_RETURN(ss); - - conf = ss->ephoto->config; - - DBG("entry %p, was %p", entry, ss->entry); - - if (ss->entry) - ephoto_entry_free_listener_del(ss->entry, _entry_free, ss); - - ss->entry = entry; - - if (entry) - ephoto_entry_free_listener_add(entry, _entry_free, ss); - - elm_slideshow_loop_set(ss->slideshow, EINA_TRUE); /* move to config? */ - elm_slideshow_transition_set(ss->slideshow, conf->slideshow_transition); - elm_slideshow_timeout_set(ss->slideshow, conf->slideshow_timeout); - elm_slideshow_clear(ss->slideshow); - if (!entry) return; - - elm_win_fullscreen_set(ss->ephoto->win, EINA_TRUE); - EINA_LIST_FOREACH(ss->ephoto->entries, l, itr) - { - Elm_Slideshow_Item *item; - item = elm_slideshow_item_add(ss->slideshow, &_item_cls, itr); - if (itr == entry) elm_slideshow_show(item); - } -} diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c index 16fdeb5..6242e46 100644 --- a/src/bin/ephoto_thumb_browser.c +++ b/src/bin/ephoto_thumb_browser.c @@ -6,32 +6,17 @@ #define TODO_ITEM_MIN_BATCH 16 -#define PARENT_DIR "Up" - typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser; struct _Ephoto_Thumb_Browser { Ephoto *ephoto; Ephoto_Entry *entry; - Evas_Object *layout; - Evas_Object *box; - Evas_Object *edje; - Evas_Object *fsel; Evas_Object *grid; - Evas_Object *toolbar; - Evas_Object *overlay; Eio_File *ls; Eina_List *todo_items; Eina_List *grid_items; Eina_List *handlers; - struct { - Elm_Toolbar_Item *flow; - Elm_Toolbar_Item *zoom_in; - Elm_Toolbar_Item *zoom_out; - Elm_Toolbar_Item *view_single; - Elm_Toolbar_Item *slideshow; - } action; struct { Ecore_Animator *todo_items; } animator; @@ -52,12 +37,6 @@ _grid_items_free(Ephoto_Thumb_Browser *tb) tb->grid_items = NULL; } -static Ephoto_Entry * -_first_file_entry_find(Ephoto_Thumb_Browser *tb) -{ - return eina_list_nth(tb->ephoto->entries, 0); -} - static char * _ephoto_thumb_item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) { @@ -65,7 +44,6 @@ _ephoto_thumb_item_label_get(void *data, Evas_Object *obj __UNUSED__, const char return strdup(e->label); } - static Evas_Object * _ephoto_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part __UNUSED__) { @@ -161,7 +139,6 @@ static Eina_Bool _todo_items_process(void *data) { Ephoto_Thumb_Browser *tb = data; - Edje_Message_Int msg; Ephoto_Entry *entry; if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH)) @@ -172,9 +149,6 @@ _todo_items_process(void *data) EINA_LIST_FREE(tb->todo_items, entry) _entry_item_add(tb, entry); - msg.val = eina_list_count(tb->ephoto->entries); - edje_object_message_send(tb->edje, EDJE_MESSAGE_INT, 1, &msg); - return EINA_FALSE; } @@ -187,25 +161,7 @@ _ephoto_thumb_selected(void *data, Evas_Object *o __UNUSED__, void *event_info) elm_gengrid_item_selected_set(it, EINA_FALSE); - evas_object_smart_callback_call(tb->layout, "view", e); -} - -static void -_changed_dir(void *data, Evas_Object *o __UNUSED__, void *event_info) -{ - Ephoto_Thumb_Browser *tb = data; - const char *path = event_info; - if (!path) return; - ephoto_directory_set(tb->ephoto, path); -} - -static void -_changed_dir_text(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - const char *path = elm_fileselector_entry_path_get(tb->fsel); - if (ecore_file_is_dir(path)) - ephoto_directory_set(tb->ephoto, path); + ephoto_promote_single_browser(tb->ephoto, e); } static void @@ -216,118 +172,10 @@ _zoom_set(Ephoto_Thumb_Browser *tb, int zoom) ephoto_thumb_size_set(tb->ephoto, zoom); elm_gengrid_item_size_set(tb->grid, zoom, zoom); - - elm_toolbar_item_disabled_set(tb->action.zoom_out, zoom == ZOOM_MIN); - elm_toolbar_item_disabled_set(tb->action.zoom_in, zoom == ZOOM_MAX); } static void -_zoom_in(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - elm_toolbar_item_selected_set(tb->action.zoom_in, EINA_FALSE); - _zoom_set(tb, tb->ephoto->config->thumb_size + ZOOM_STEP); -} - -static void -_zoom_out(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - elm_toolbar_item_selected_set(tb->action.zoom_out, EINA_FALSE); - _zoom_set(tb, tb->ephoto->config->thumb_size - ZOOM_STEP); -} - -static void -_view_single(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid); - Ephoto_Entry *entry; - - elm_toolbar_item_selected_set(tb->action.view_single, EINA_FALSE); - - if (it) entry = elm_gengrid_item_data_get(it); - else entry = tb->entry; - if (!entry) - entry = _first_file_entry_find(tb); - if (!entry) return; - evas_object_smart_callback_call(tb->layout, "view", entry); -} - -static void -_slideshow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid); - Ephoto_Entry *entry; - - elm_toolbar_item_selected_set(tb->action.slideshow, EINA_FALSE); - - if (it) entry = elm_gengrid_item_data_get(it); - else entry = tb->entry; - if (!entry) - entry = _first_file_entry_find(tb); - if (!entry) return; - evas_object_smart_callback_call(tb->layout, "slideshow", entry); -} - -static void -_flow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid); - Ephoto_Entry *entry; - - elm_toolbar_item_selected_set(tb->action.flow, EINA_FALSE); - - if (it) entry = elm_gengrid_item_data_get(it); - else entry = tb->entry; - if (!entry) - entry = _first_file_entry_find(tb); - if (!entry) return; - evas_object_smart_callback_call(tb->layout, "flow", entry); -} - -static void -_key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) -{ - Ephoto_Thumb_Browser *tb = data; - Evas_Event_Key_Down *ev = event_info; - Eina_Bool alt = evas_key_modifier_is_set(ev->modifiers, "Alt"); - const char *k = ev->keyname; - - if (alt) - { - if (!strcmp(k, "Up")) - { - if (strcmp(tb->ephoto->config->directory, "/") != 0) - { - char *parent = ecore_file_dir_get - (tb->ephoto->config->directory); - if (parent) - ephoto_directory_set(tb->ephoto, parent); - free(parent); - } - } - - return; - } - - if (!strcmp(k, "F5")) - { - Elm_Gengrid_Item *it = elm_gengrid_selected_item_get(tb->grid); - Ephoto_Entry *entry; - if (it) entry = elm_gengrid_item_data_get(it); - else entry = _first_file_entry_find(tb); - - if (entry) - evas_object_smart_callback_call(tb->layout, "slideshow", entry); - } -} - - -static void -_layout_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) +_grid_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) { Ephoto_Thumb_Browser *tb = data; Ecore_Event_Handler *handler; @@ -351,28 +199,14 @@ _layout_del(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *eve free(tb); } -static Elm_Toolbar_Item * -_toolbar_item_add(Ephoto_Thumb_Browser *tb, const char *icon, const char *label, int priority, Evas_Smart_Cb cb) -{ - Elm_Toolbar_Item *item = elm_toolbar_item_append(tb->toolbar, icon, label, - cb, tb); - elm_toolbar_item_priority_set(item, priority); - return item; -} - static Eina_Bool _ephoto_thumb_populate_start(void *data, int type __UNUSED__, void *event __UNUSED__) { Ephoto_Thumb_Browser *tb = data; - evas_object_smart_callback_call(tb->layout, "changed,directory", NULL); - _todo_items_free(tb); _grid_items_free(tb); elm_gengrid_clear(tb->grid); - elm_fileselector_entry_path_set(tb->fsel, tb->ephoto->config->directory); - - edje_object_signal_emit(tb->edje, "populate,start", "ephoto"); return ECORE_CALLBACK_PASS_ON; } @@ -389,18 +223,12 @@ _ephoto_thumb_populate_end(void *data, int type __UNUSED__, void *event __UNUSED return ECORE_CALLBACK_PASS_ON; } - edje_object_signal_emit(tb->edje, "populate,stop", "ephoto"); - return ECORE_CALLBACK_PASS_ON; } static Eina_Bool -_ephoto_thumb_populate_error(void *data, int type __UNUSED__, void *event __UNUSED__) +_ephoto_thumb_populate_error(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) { - Ephoto_Thumb_Browser *tb = data; - - edje_object_signal_emit(tb->edje, "populate,error", "ephoto"); - return ECORE_CALLBACK_PASS_ON; } @@ -420,114 +248,16 @@ _ephoto_thumb_entry_create(void *data, int type __UNUSED__, void *event) return ECORE_CALLBACK_PASS_ON; } -static void -_ephoto_up_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - char *parent_dir; - - parent_dir = ecore_file_dir_get(tb->ephoto->config->directory); - if (!parent_dir) - return; - ephoto_directory_set(tb->ephoto, parent_dir); -} - Evas_Object * ephoto_thumb_browser_add(Ephoto *ephoto, 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->ephoto = ephoto; - tb->layout = layout; - tb->edje = elm_layout_edje_get(layout); - evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _layout_del, tb); - evas_object_event_callback_add - (layout, EVAS_CALLBACK_KEY_DOWN, _key_down, tb); - evas_object_data_set(layout, "thumb_browser", tb); - if (tb->ephoto->config->autohide_toolbar) - { - edje_object_signal_callback_add - (tb->edje, "mouse,clicked,1", "toolbar_event", - ephoto_auto_hide_toolbar, tb->ephoto); - if (!elm_layout_file_set - (layout, THEME_FILE, "ephoto/layout/simple/autohide")) - { - ERR("could not load style 'ephoto/layout/simple/autohide' from theme"); - goto error; - } - } - else - { - if (!elm_layout_file_set - (layout, THEME_FILE, "ephoto/layout/simple")) - { - ERR("could not load style 'ephoto/layout/simple' from theme"); - goto error; - } - } - - tb->toolbar = elm_toolbar_add(tb->layout); - elm_toolbar_homogeneous_set(tb->toolbar, EINA_FALSE); - elm_toolbar_mode_shrink_set(tb->toolbar, ELM_TOOLBAR_SHRINK_MENU); - elm_toolbar_menu_parent_set(tb->toolbar, parent); - evas_object_size_hint_weight_set(tb->toolbar, 0.0, 0.0); - evas_object_size_hint_align_set(tb->toolbar, EVAS_HINT_FILL, 0.0); - - tb->action.flow = _toolbar_item_add - (tb, "image", "Flow", 120, _flow); - tb->action.slideshow = _toolbar_item_add - (tb, "media-playback-start", "Slideshow", 100, _slideshow); - tb->action.zoom_in = _toolbar_item_add - (tb, "zoom-in", "Zoom In", 50, _zoom_in); - tb->action.zoom_out = _toolbar_item_add - (tb, "zoom-out", "Zoom Out", 50, _zoom_out); - tb->action.view_single = _toolbar_item_add - (tb, "image", "Single", 50, _view_single); - - elm_layout_content_set - (tb->layout, "ephoto.toolbar.swallow", tb->toolbar); - evas_object_show(tb->toolbar); - - tb->box = elm_box_add(tb->layout); - elm_box_horizontal_set(tb->box, EINA_FALSE); - elm_box_homogeneous_set(tb->box, EINA_FALSE); - evas_object_size_hint_weight_set - (tb->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(tb->box); - - tb->fsel = elm_fileselector_entry_add(layout); - EINA_SAFETY_ON_NULL_GOTO(tb->fsel, error); - evas_object_size_hint_weight_set(tb->fsel, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(tb->fsel, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_fileselector_entry_button_label_set(tb->fsel, "Choose..."); - elm_fileselector_entry_folder_only_set(tb->fsel, EINA_TRUE); - evas_object_smart_callback_add - (tb->fsel, "file,chosen", _changed_dir, tb); - evas_object_smart_callback_add - (tb->fsel, "activated", _changed_dir_text, tb); - evas_object_show(tb->fsel); - elm_box_pack_end(tb->box, tb->fsel); - - tb->overlay = elm_layout_add(layout); - elm_layout_file_set - (tb->overlay, THEME_FILE, "ephoto,thumb,grid"); - evas_object_size_hint_weight_set - (tb->overlay, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set - (tb->overlay, EVAS_HINT_FILL, EVAS_HINT_FILL); - edje_object_signal_callback_add - (elm_layout_edje_get(tb->overlay), "ephoto.signal.up", "ephoto", - _ephoto_up_clicked, tb); - evas_object_show(tb->overlay); - elm_box_pack_end(tb->box, tb->overlay); - - tb->grid = elm_gengrid_add(tb->overlay); + tb->grid = elm_gengrid_add(parent); EINA_SAFETY_ON_NULL_GOTO(tb->grid, error); elm_gengrid_align_set(tb->grid, 0.5, 0.5); elm_gengrid_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE); @@ -538,11 +268,9 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) evas_object_smart_callback_add (tb->grid, "selected", _ephoto_thumb_selected, tb); _zoom_set(tb, tb->ephoto->config->thumb_size); + evas_object_event_callback_add(tb->grid, EVAS_CALLBACK_DEL, _grid_del, tb); + evas_object_data_set(tb->grid, "thumb_browser", tb); evas_object_show(tb->grid); - elm_layout_content_set - (tb->overlay, "ephoto.swallow.content.thumb", tb->grid); - - elm_layout_content_set(tb->layout, "ephoto.content.swallow", tb->box); tb->handlers = eina_list_append (tb->handlers, ecore_event_handler_add @@ -558,12 +286,12 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) tb->handlers = eina_list_append (tb->handlers, ecore_event_handler_add - (EPHOTO_EVENT_ENTRY_CREATE, _ephoto_thumb_entry_create, tb)); + (EPHOTO_EVENT_ENTRY_CREATE_THUMB, _ephoto_thumb_entry_create, tb)); - return layout; + return tb->grid; error: - evas_object_del(layout); + evas_object_del(tb->grid); return NULL; }