Ephoto: Use Enlightenment's thumbnailer to achieve better thumbnailing.
This commit is contained in:
parent
c2a555939d
commit
d62984608a
|
@ -5,6 +5,8 @@ rm -f config.cache
|
|||
|
||||
AC_INIT([ephoto], [0.9.99], [enlightenment-devel@lists.sourceforge.net])
|
||||
|
||||
AC_CHECK_HEADERS([dirent.h limits.h math.h arpa/inet.h netinet/in.h])
|
||||
|
||||
AC_PREREQ([2.60])
|
||||
AC_CONFIG_SRCDIR([configure.ac])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
@ -45,6 +47,8 @@ PKG_CHECK_MODULES([EFL], [
|
|||
eina >= 1.7.0
|
||||
evas >= 1.7.0
|
||||
ecore >= 1.7.0
|
||||
ecore-file >= 1.7.0
|
||||
ecore-ipc >= 1.7.0
|
||||
edje >= 1.7.0
|
||||
eo >= 1.7.0
|
||||
eio >= 1.7.0
|
||||
|
|
|
@ -20,17 +20,38 @@ endif
|
|||
|
||||
ephoto_SOURCES = \
|
||||
ephoto.c \
|
||||
ephoto_main.c \
|
||||
ephoto_bcg.c \
|
||||
ephoto_color.c \
|
||||
ephoto_config.c \
|
||||
ephoto_cropper.c \
|
||||
ephoto_editor.c \
|
||||
ephoto_filters.c \
|
||||
ephoto_hsv.c \
|
||||
ephoto_ipc.c \
|
||||
ephoto_main.c \
|
||||
ephoto_thumb.c \
|
||||
ephoto_thumb_browser.c \
|
||||
ephoto_single_browser.c \
|
||||
ephoto_slideshow.c \
|
||||
ephoto_cropper.c \
|
||||
ephoto_bcg.c \
|
||||
ephoto_hsv.c \
|
||||
ephoto_filters.c \
|
||||
ephoto_color.c \
|
||||
ephoto_editor.c
|
||||
ephoto_slideshow.c
|
||||
|
||||
internal_bindir = $(datadir)/$(PACKAGE)
|
||||
internal_bin_PROGRAMS = ephoto_thumbnail
|
||||
|
||||
ephoto_thumbnail_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wshadow \
|
||||
@EFL_CFLAGS@
|
||||
|
||||
ephoto_thumbnail_LDADD = @EFL_LIBS@
|
||||
|
||||
ephoto_thumbnail_SOURCES = \
|
||||
ephoto_thumbnailer.c \
|
||||
ephoto_ipc.c \
|
||||
ephoto_thumb.c
|
||||
|
||||
noinst_HEADERS = ephoto.h
|
||||
EXTRA_DIST = ephoto.h
|
||||
|
|
|
@ -9,7 +9,6 @@ elm_main(int argc, char **argv)
|
|||
|
||||
eio_init();
|
||||
elm_need_efreet();
|
||||
elm_need_ethumb();
|
||||
elm_language_set("");
|
||||
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
|
||||
elm_app_info_set(elm_main, "ephoto", "themes/crop.edj");
|
||||
|
@ -22,6 +21,10 @@ elm_main(int argc, char **argv)
|
|||
|
||||
if (!efreet_mime_init())
|
||||
printf("Could not initialize Efreet_Mime!\n");
|
||||
if (!e_ipc_init())
|
||||
printf("Could not initialize IPC!\n");
|
||||
if (!e_thumb_init())
|
||||
printf("Could not initialize Thumbnailer!\n");
|
||||
|
||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||
|
||||
|
@ -71,6 +74,7 @@ elm_main(int argc, char **argv)
|
|||
elm_run();
|
||||
|
||||
end:
|
||||
e_thumb_shutdown();
|
||||
efreet_mime_shutdown();
|
||||
eio_shutdown();
|
||||
|
||||
|
|
|
@ -5,9 +5,17 @@
|
|||
# include "config.h"
|
||||
# endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <dirent.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <math.h>
|
||||
# include <Eet.h>
|
||||
# include <Ecore.h>
|
||||
# include <Ecore_Evas.h>
|
||||
# include <Ecore_Ipc.h>
|
||||
# include <Ecore_File.h>
|
||||
# include <Efreet_Mime.h>
|
||||
# include <Elementary.h>
|
||||
|
@ -16,13 +24,6 @@
|
|||
# include <Edje.h>
|
||||
# include <Evas.h>
|
||||
# include <Eio.h>
|
||||
# include <Ethumb_Client.h>
|
||||
# include <limits.h>
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <dirent.h>
|
||||
|
||||
# ifdef HAVE_PO
|
||||
# include <locale.h>
|
||||
|
@ -36,6 +37,9 @@
|
|||
# define ngettext(String1, String2, Var) Var == 1 ? String1 : String2
|
||||
#endif
|
||||
|
||||
# define USE_IPC
|
||||
|
||||
/*local types*/
|
||||
typedef struct _Ephoto_Config Ephoto_Config;
|
||||
typedef struct _Ephoto Ephoto;
|
||||
typedef struct _Ephoto_Entry Ephoto_Entry;
|
||||
|
@ -44,7 +48,9 @@ typedef struct _Ephoto_Event_Entry_Create Ephoto_Event_Entry_Create;
|
|||
typedef enum _Ephoto_State Ephoto_State;
|
||||
typedef enum _Ephoto_Orient Ephoto_Orient;
|
||||
typedef enum _Ephoto_Sort Ephoto_Sort;
|
||||
typedef enum _Ephoto_Ipc_Domain Ephoto_Ipc_Domain;
|
||||
|
||||
/*main window functions*/
|
||||
Evas_Object *ephoto_window_add(const char *path);
|
||||
void ephoto_title_set(Ephoto *ephoto, const char *title);
|
||||
void ephoto_thumb_size_set(Ephoto *ephoto, int size);
|
||||
|
@ -54,11 +60,13 @@ void ephoto_thumb_path_set(Evas_Object *obj, const char *path);
|
|||
void ephoto_directory_set(Ephoto *ephoto, const char *path,
|
||||
Elm_Object_Item *expanded, Eina_Bool dirs_only, Eina_Bool thumbs_only);
|
||||
|
||||
/*config panel functions*/
|
||||
Eina_Bool ephoto_config_init(Ephoto *em);
|
||||
void ephoto_config_save(Ephoto *em);
|
||||
void ephoto_config_free(Ephoto *em);
|
||||
void ephoto_config_main(Ephoto *em);
|
||||
|
||||
/*single image functions*/
|
||||
Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_single_browser_entries_set(Evas_Object *obj, Eina_List *entries);
|
||||
void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
|
@ -72,22 +80,40 @@ void ephoto_single_browser_cancel_editing(Evas_Object *main,
|
|||
Evas_Object *image);
|
||||
/* smart callbacks called: "back" - the user wants to go back to the previous
|
||||
* screen. */
|
||||
|
||||
/*slideshow functions*/
|
||||
Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_slideshow_entries_set(Evas_Object *obj, Eina_List *entries);
|
||||
void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
|
||||
/* smart callbacks called: "back" - the user wants to go back to the previous
|
||||
* screen. */
|
||||
|
||||
/*thumbnail browser functions*/
|
||||
Evas_Object *ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_thumb_browser_fsel_clear(Ephoto *ephoto);
|
||||
void ephoto_thumb_browser_top_dir_set(Ephoto *ephoto, const char *dir);
|
||||
void ephoto_thumb_browser_insert(Ephoto *ephoto, Ephoto_Entry *entry);
|
||||
void ephoto_thumb_browser_remove(Ephoto *ephoto, Ephoto_Entry *entry);
|
||||
void ephoto_thumb_browser_update(Ephoto *ephoto, 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. */
|
||||
|
||||
/*thumbnailing functions taken from enlightenment*/
|
||||
int e_thumb_init(void);
|
||||
int e_thumb_shutdown(void);
|
||||
Evas_Object *e_thumb_icon_add(Evas *evas);
|
||||
void e_thumb_icon_file_set(Evas_Object *obj, const char *file, const char *key);
|
||||
void e_thumb_icon_size_set(Evas_Object *obj, int w, int h);
|
||||
void e_thumb_icon_begin(Evas_Object *obj);
|
||||
void e_thumb_icon_end(Evas_Object *obj);
|
||||
void e_thumb_icon_rethumb(Evas_Object *obj);
|
||||
const char *e_thumb_sort_id_get(Evas_Object *obj);
|
||||
void e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e);
|
||||
void e_thumb_client_del(Ecore_Ipc_Event_Client_Del *e);
|
||||
int e_ipc_init(void);
|
||||
int e_ipc_shutdown(void);
|
||||
|
||||
/*editing functions*/
|
||||
Evas_Object *ephoto_editor_add(Evas_Object *parent, const char *title,
|
||||
const char *data_name, void *data);
|
||||
void ephoto_editor_del(Evas_Object *obj);
|
||||
|
@ -105,6 +131,8 @@ void ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image);
|
|||
void ephoto_filter_old_photo(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image);
|
||||
|
||||
/*data types and structures*/
|
||||
|
||||
enum _Ephoto_State
|
||||
{
|
||||
EPHOTO_STATE_THUMB,
|
||||
|
@ -132,6 +160,11 @@ enum _Ephoto_Sort
|
|||
EPHOTO_SORT_MODTIME_DESCENDING
|
||||
};
|
||||
|
||||
enum _Ephoto_Ipc_Domain
|
||||
{
|
||||
EPHOTO_IPC_DOMAIN_THUMB
|
||||
};
|
||||
|
||||
struct _Ephoto_Config
|
||||
{
|
||||
int config_version;
|
||||
|
@ -219,6 +252,7 @@ struct _Ephoto_Event_Entry_Create
|
|||
Ephoto_Entry *entry;
|
||||
};
|
||||
|
||||
/*ephoto file functions*/
|
||||
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path,
|
||||
const char *label, Eina_File_Type type);
|
||||
Eina_Bool ephoto_entry_exists(Ephoto *ephoto, const char *path);
|
||||
|
@ -230,6 +264,7 @@ void ephoto_entry_free_listener_del(Ephoto_Entry *entry,
|
|||
void ephoto_entries_free(Ephoto *ephoto);
|
||||
int ephoto_entries_cmp(const void *pa, const void *pb);
|
||||
|
||||
/*check if image can be loaded*/
|
||||
static inline Eina_Bool
|
||||
_ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
||||
{
|
||||
|
@ -264,6 +299,7 @@ _ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/*check if image can be saved*/
|
||||
static inline Eina_Bool
|
||||
_ephoto_file_image_can_save(const char *ext)
|
||||
{
|
||||
|
@ -283,6 +319,7 @@ _ephoto_file_image_can_save(const char *ext)
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/*event types*/
|
||||
extern int EPHOTO_EVENT_ENTRY_CREATE;
|
||||
extern int EPHOTO_EVENT_POPULATE_START;
|
||||
extern int EPHOTO_EVENT_POPULATE_END;
|
||||
|
|
|
@ -630,25 +630,9 @@ _thumb_gen_size_changed_timer_cb(void *data)
|
|||
|
||||
EINA_LIST_FOREACH(ephoto->thumbs, l, o)
|
||||
{
|
||||
Ethumb_Thumb_Format format;
|
||||
|
||||
format = (Ethumb_Thumb_Format) (uintptr_t)
|
||||
evas_object_data_get(o, "ephoto_format");
|
||||
if (format)
|
||||
{
|
||||
elm_thumb_format_set(o, format);
|
||||
if (format == ETHUMB_THUMB_FDO)
|
||||
{
|
||||
if (ephoto->config->thumb_gen_size < 256)
|
||||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_NORMAL);
|
||||
else
|
||||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_LARGE);
|
||||
}
|
||||
else
|
||||
elm_thumb_size_set(o, ephoto->thumb_gen_size,
|
||||
e_thumb_icon_size_set(o, ephoto->thumb_gen_size,
|
||||
ephoto->thumb_gen_size);
|
||||
elm_thumb_reload(o);
|
||||
}
|
||||
e_thumb_icon_rethumb(o);
|
||||
}
|
||||
end:
|
||||
ephoto->timer.thumb_regen = NULL;
|
||||
|
@ -682,6 +666,7 @@ _thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|||
{
|
||||
Ephoto *ephoto = data;
|
||||
|
||||
e_thumb_icon_end(obj);
|
||||
ephoto->thumbs = eina_list_remove(ephoto->thumbs, obj);
|
||||
}
|
||||
|
||||
|
@ -698,16 +683,29 @@ ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
|
|||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
o = elm_icon_add(parent);
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
}
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
ephoto_thumb_path_set(o, path);
|
||||
{
|
||||
o = e_thumb_icon_add(parent);
|
||||
e_thumb_icon_file_set(o, path, NULL);
|
||||
e_thumb_icon_size_set(o, ephoto->thumb_gen_size,
|
||||
ephoto->thumb_gen_size);
|
||||
e_thumb_icon_begin(o);
|
||||
}
|
||||
}
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
{
|
||||
o = e_thumb_icon_add(parent);
|
||||
e_thumb_icon_file_set(o, path, NULL);
|
||||
e_thumb_icon_size_set(o, ephoto->thumb_gen_size,
|
||||
ephoto->thumb_gen_size);
|
||||
e_thumb_icon_begin(o);
|
||||
}
|
||||
}
|
||||
else
|
||||
o = e_thumb_icon_add(parent);
|
||||
if (!o)
|
||||
return NULL;
|
||||
|
||||
|
@ -720,16 +718,13 @@ ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
|
|||
void
|
||||
ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
||||
{
|
||||
Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO;
|
||||
const char *group = NULL;
|
||||
const char *ext = strrchr(path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "jpg") == 0) || (strcasecmp(ext, "jpeg") == 0))
|
||||
format = ETHUMB_THUMB_JPEG;
|
||||
else if ((strcasecmp(ext, "edj") == 0))
|
||||
if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
if (edje_file_group_exists(path, "e/desktop/background"))
|
||||
group = "e/desktop/background";
|
||||
|
@ -741,16 +736,11 @@ ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
|||
edje_file_collection_list_free(g);
|
||||
}
|
||||
elm_image_file_set(obj, path, group);
|
||||
evas_object_data_set(obj, "ephoto_format", NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
elm_thumb_format_set(obj, format);
|
||||
evas_object_data_set(obj, "ephoto_format", (void *) (uintptr_t) format);
|
||||
elm_thumb_crop_align_set(obj, 0.5, 0.5);
|
||||
elm_thumb_aspect_set(obj, ETHUMB_THUMB_CROP);
|
||||
elm_thumb_orientation_set(obj, ETHUMB_THUMB_ORIENT_ORIGINAL);
|
||||
elm_thumb_file_set(obj, path, group);
|
||||
e_thumb_icon_file_set(obj, path, group);
|
||||
e_thumb_icon_begin(obj);
|
||||
}
|
||||
|
||||
Ephoto_Entry *
|
||||
|
|
|
@ -312,7 +312,10 @@ _ephoto_thumb_file_icon_get(void *data, Evas_Object *obj,
|
|||
return NULL;
|
||||
|
||||
if (e)
|
||||
{
|
||||
thumb = ephoto_thumb_add(e->ephoto, obj, e->path);
|
||||
evas_object_show(thumb);
|
||||
}
|
||||
return thumb;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue