* ephoto: use eio to simplify and make a small nice example.

SVN revision: 50432
This commit is contained in:
Cedric BAIL 2010-07-22 16:15:16 +00:00
parent a1af3e8605
commit e2c35a285b
4 changed files with 41 additions and 46 deletions

View File

@ -153,6 +153,17 @@ PKG_CHECK_MODULES([ELEMENTARY], elementary,
] ]
) )
PKG_CHECK_MODULES([EIO], eio,
[
have_eio="Yes"
],
[
have_eio="No"
echo "Eio was not found by pkg-config!";
AC_MSG_ERROR([Ephoto needs eio to compile.])
]
)
AC_OUTPUT([ AC_OUTPUT([
Makefile Makefile
ephoto.spec ephoto.spec
@ -195,6 +206,7 @@ echo " Eina.............: $have_eina"
echo " Ethumb...........: $have_ethumb" echo " Ethumb...........: $have_ethumb"
echo " Elementary.......: $have_elementary" echo " Elementary.......: $have_elementary"
echo " Libexif .........: $have_exif" echo " Libexif .........: $have_exif"
echo " Eio...........: $have_eio"
echo echo
echo "Installation Path.........: $prefix" echo "Installation Path.........: $prefix"
echo echo

View File

@ -12,6 +12,6 @@ ephoto_SOURCES = \
ephoto_main.c \ ephoto_main.c \
ephoto_thumb_browser.c ephoto_thumb_browser.c
ephoto_CFLAGS = @EVAS_CFLAGS@ @EDJE_CFLAGS@ @EINA_CFLAGS@ @EFREET_MIME_CFLAGS@ @ETHUMB_CFLAGS@ @ELEMENTARY_CFLAGS@ -Wall -g ephoto_CFLAGS = @EVAS_CFLAGS@ @EDJE_CFLAGS@ @EINA_CFLAGS@ @EFREET_MIME_CFLAGS@ @ETHUMB_CFLAGS@ @ELEMENTARY_CFLAGS@ @EIO_CFLAGS@ -Wall -g
ephoto_LDADD = @EVAS_CFLAGS@ @EDJE_CFLAGS@ @EINA_LIBS@ @EFREET_MIME_LIBS@ @ETHUMB_LIBS@ @ELEMENTARY_LIBS@ ephoto_LDADD = @EVAS_CFLAGS@ @EDJE_CFLAGS@ @EINA_LIBS@ @EFREET_MIME_LIBS@ @ETHUMB_LIBS@ @ELEMENTARY_LIBS@ @EIO_LIBS@

View File

@ -15,12 +15,11 @@
#include <Evas.h> #include <Evas.h>
#include <Ethumb.h> #include <Ethumb.h>
#include <Ethumb_Client.h> #include <Ethumb_Client.h>
#include <dirent.h> #include <Eio.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include "config.h" #include "config.h"
/*Main Functions*/ /*Main Functions*/

View File

@ -21,7 +21,7 @@ static Elm_Gengrid_Item_Class eg;
static Ethumb_Client *ec; static Ethumb_Client *ec;
static const char *current_directory; static const char *current_directory;
static int cur_val; static int cur_val;
static Ecore_Thread *thread = NULL; static Eio_List *list = NULL;
static Evas_Object *toolbar, *dir_label, *thumb_slider, *thbox; static Evas_Object *toolbar, *dir_label, *thumb_slider, *thbox;
typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data; typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data;
@ -169,52 +169,40 @@ ephoto_delete_thumb_browser(void)
/* Use ecore thread facility to avoid lock completly */ /* Use ecore thread facility to avoid lock completly */
/* List image in a directory from another thread */ /* Check image type from another thread */
static void static Eina_Bool
_ephoto_access_disk(Ecore_Thread *thread, void *data) _ephoto_populate_filter(const char *file, void *data)
{ {
Eina_Iterator *it = data;
const char *file;
const char *type; const char *type;
if (!efreet_mime_init())
fprintf(stderr, "Could not init efreet_mime!\n");
EINA_ITERATOR_FOREACH(it, file) if (!(type = efreet_mime_type_get((const char *)file)))
{ return EINA_FALSE;
if (ecore_thread_check(thread)) break;
if (!(type = efreet_mime_type_get((const char *)file))) if (!strncmp(type, "image", 5))
continue; return EINA_TRUE;
fprintf(stderr, "[%s] => [%s]\n", file, type); return EINA_FALSE;
if (!strncmp(type, "image", 5))
if (ecore_thread_notify(thread, file))
continue ;
eina_stringshare_del(file);
}
efreet_mime_shutdown();
} }
/*Done populating images*/ /*Done populating images*/
static void static void
_ephoto_populate_end(void *data) _ephoto_populate_end(void *data)
{ {
Eina_Iterator *it = data; list = NULL;
eina_iterator_free(it); efreet_mime_shutdown();
thread = NULL;
} }
/* Build the interface component after detection from listing thread */ /* Build the interface component after detection from main thread */
static void static void
_ephoto_populate_notify(Ecore_Thread *thread, void *msg_data, void *data) _ephoto_populate_main(const char *file, void *data)
{ {
const char *thumb; const char *thumb;
char *path = msg_data;
em->images = eina_list_append(em->images, path); file = eina_stringshare_ref(file);
ethumb_client_file_set(ec, path, NULL);
em->images = eina_list_append(em->images, file);
ethumb_client_file_set(ec, file, NULL);
if (!ethumb_client_thumb_exists(ec)) if (!ethumb_client_thumb_exists(ec))
{ {
ethumb_client_generate(ec, _ephoto_thumbnail_generated, NULL, NULL); ethumb_client_generate(ec, _ephoto_thumbnail_generated, NULL, NULL);
@ -222,9 +210,8 @@ _ephoto_populate_notify(Ecore_Thread *thread, void *msg_data, void *data)
else else
{ {
ethumb_client_thumb_path_get(ec, &thumb, NULL); ethumb_client_thumb_path_get(ec, &thumb, NULL);
_ephoto_thumbnail_generated(NULL, ec, 0, path, NULL, _ephoto_thumbnail_generated(NULL, ec, 0, file, NULL,
thumb, NULL, EINA_TRUE); thumb, NULL, EINA_TRUE);
} }
} }
@ -232,19 +219,16 @@ _ephoto_populate_notify(Ecore_Thread *thread, void *msg_data, void *data)
void void
ephoto_populate_thumbnails(void) ephoto_populate_thumbnails(void)
{ {
Eina_Iterator *it;
if (!current_directory) return ; if (!current_directory) return ;
it = eina_file_ls(current_directory); if (!efreet_mime_init())
if (!it) return ; fprintf(stderr, "Could not init efreet_mime!\n");
printf("%s\n", current_directory);
thread = ecore_long_run(_ephoto_access_disk, list = eio_file_ls(current_directory,
_ephoto_populate_notify, _ephoto_populate_filter,
_ephoto_populate_end, _ephoto_populate_main,
_ephoto_populate_end, _ephoto_populate_end,
it, NULL);
EINA_FALSE);
} }
/*Change the thumbnail size*/ /*Change the thumbnail size*/