refactor, improve sizing of icons.
use super-duper-nice edje features to choose image based on the current object size and provide icons at 128, 256 and 512 so we're always high quality. SVN revision: 53212
This commit is contained in:
parent
dc2f3c47c9
commit
e434b9aaee
|
@ -627,5 +627,67 @@ collections
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
group { name: "/ephoto/directory/up";
|
||||
images {
|
||||
set { name: "up";
|
||||
image {
|
||||
image: "up-128.png" COMP;
|
||||
size: 1 1 128 128;
|
||||
}
|
||||
image {
|
||||
image: "up-256.png" COMP;
|
||||
size: 129 129 256 256;
|
||||
}
|
||||
image {
|
||||
image: "up-512.png" COMP;
|
||||
size: 257 257 512 512;
|
||||
}
|
||||
}
|
||||
}
|
||||
parts {
|
||||
part { name: "img";
|
||||
type: IMAGE;
|
||||
mouse_events: 0;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
aspect_preference: BOTH;
|
||||
aspect: 1.0 1.0;
|
||||
image.normal: "up";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group { name: "/ephoto/directory/no-preview";
|
||||
images {
|
||||
set { name: "directory";
|
||||
image {
|
||||
image: "directory-128.png" COMP;
|
||||
size: 1 1 128 128;
|
||||
}
|
||||
image {
|
||||
image: "directory-256.png" COMP;
|
||||
size: 129 129 256 256;
|
||||
}
|
||||
image {
|
||||
image: "directory-512.png" COMP;
|
||||
size: 257 257 512 512;
|
||||
}
|
||||
}
|
||||
}
|
||||
parts {
|
||||
part { name: "img";
|
||||
type: IMAGE;
|
||||
mouse_events: 0;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
aspect_preference: BOTH;
|
||||
aspect: 1.0 1.0;
|
||||
image.normal: "directory";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,4 +4,8 @@ EXTRA_DIST = \
|
|||
thumb_shadow.png \
|
||||
bt_sm_base1.png \
|
||||
bt_sm_shine.png \
|
||||
bt_sm_hilight.png
|
||||
bt_sm_hilight.png \
|
||||
up-128.png \
|
||||
up-256.png \
|
||||
up-512.png
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
|
@ -19,6 +19,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include "config.h"
|
||||
|
||||
typedef struct _Ephoto_Config Ephoto_Config;
|
||||
|
@ -123,4 +124,29 @@ extern int __log_domain;
|
|||
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(__log_domain, __VA_ARGS__)
|
||||
|
||||
static inline Eina_Bool
|
||||
_ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
||||
{
|
||||
const char *type, *bname, *ext;
|
||||
|
||||
bname = info->path + info->name_start;
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
if ((info->dirent->d_type != DT_REG) && (info->dirent->d_type != DT_UNKNOWN))
|
||||
return EINA_FALSE;
|
||||
|
||||
ext = info->path + info->path_length - 1;
|
||||
for (; ext > bname; ext--) if (*ext == '.') break;
|
||||
if (*ext == '.')
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "jpg") == 0) ||
|
||||
(strcasecmp(ext, "jpeg") == 0) ||
|
||||
(strcasecmp(ext, "png") == 0))
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
if (!(type = efreet_mime_type_get(info->path))) return EINA_FALSE;
|
||||
return strncmp(type, "image/", sizeof("image/") - 1) == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,22 +22,9 @@ _layout_del(void *data, Evas *e, Evas_Object *layout, void *event_info)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_populate_filter(void *data, const char *file)
|
||||
_populate_filter(void *data, const Eina_File_Direct_Info *info)
|
||||
{
|
||||
const char *type, *basename;
|
||||
|
||||
/* TODO: eio_file_ls_direct() and get more useful parameter than file */
|
||||
basename = ecore_file_file_get(file);
|
||||
if ((!basename) || (basename[0] == '.'))
|
||||
return EINA_FALSE;
|
||||
|
||||
/* TODO: speed up case for jpg/jpeg/png */
|
||||
if (!(type = efreet_mime_type_get(file)))
|
||||
return EINA_FALSE;
|
||||
if (!strncmp(type, "image", 5))
|
||||
return EINA_TRUE;
|
||||
|
||||
return EINA_FALSE;
|
||||
return _ephoto_eina_file_direct_info_image_useful(info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -55,7 +42,7 @@ _populate_error(int error, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
_populate_main(void *data, const char *file)
|
||||
_populate_main(void *data, const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Evas_Object *frame, *image;
|
||||
int position;
|
||||
|
@ -83,7 +70,7 @@ _populate_main(void *data, const char *file)
|
|||
evas_object_show(frame);
|
||||
|
||||
image = elm_thumb_add(frame);
|
||||
elm_thumb_file_set(image, file, NULL);
|
||||
elm_thumb_file_set(image, info->path, NULL);
|
||||
elm_object_style_set(image, "ephoto");
|
||||
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
@ -127,9 +114,10 @@ ephoto_directory_thumb_add(Evas_Object *parent, const char *path)
|
|||
//evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_layout_content_set(dt->layout, "ephoto.swallow.thumb1", thumb);
|
||||
|
||||
placeholder = elm_image_add(thumb);
|
||||
elm_image_file_set
|
||||
(placeholder, PACKAGE_DATA_DIR "/images/change_directory.png", NULL);
|
||||
placeholder = edje_object_add(evas_object_evas_get(dt->layout));
|
||||
edje_object_file_set
|
||||
(placeholder, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"/ephoto/directory/no-preview");
|
||||
elm_layout_content_set(thumb, "ephoto.swallow.content", placeholder);
|
||||
|
||||
s = edje_object_data_get(elm_layout_edje_get(dt->layout), "thumbs");
|
||||
|
@ -140,12 +128,12 @@ ephoto_directory_thumb_add(Evas_Object *parent, const char *path)
|
|||
/* TODO: fix "Up" to be another type of directory and do not need
|
||||
* to check for existence here */
|
||||
if ((dt->theme_thumb_count > 0) && (ecore_file_exists(path)))
|
||||
dt->file = eio_file_ls(path,
|
||||
_populate_filter,
|
||||
_populate_main,
|
||||
_populate_end,
|
||||
_populate_error,
|
||||
dt);
|
||||
dt->file = eio_file_direct_ls(path,
|
||||
_populate_filter,
|
||||
_populate_main,
|
||||
_populate_end,
|
||||
_populate_error,
|
||||
dt);
|
||||
}
|
||||
|
||||
return dt->layout;
|
||||
|
|
|
@ -13,7 +13,8 @@ struct _Ephoto_Thumb_Data
|
|||
const char *thumb_path;
|
||||
const char *file;
|
||||
const char *basename;
|
||||
Eina_Bool is_directory;
|
||||
Eina_Bool is_directory : 1;
|
||||
Eina_Bool is_up : 1;
|
||||
};
|
||||
|
||||
struct _Ephoto_Thumb_Browser
|
||||
|
@ -50,7 +51,7 @@ static void _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_i
|
|||
static void _ephoto_zoom_in(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _ephoto_zoom_out(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _ephoto_zoom_regular_size(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path, Eina_Bool is_dir);
|
||||
static Ephoto_Thumb_Data *_ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path);
|
||||
static void _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory);
|
||||
static void _ephoto_populate_images(Ephoto_Thumb_Browser *tb);
|
||||
|
||||
|
@ -237,37 +238,23 @@ _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
|
||||
/* Check directory type from another thread */
|
||||
static Eina_Bool
|
||||
_ephoto_populate_filter_directory(void *data, const char *file)
|
||||
_ephoto_populate_filter_directory(void *data, const Eina_File_Direct_Info *info)
|
||||
{
|
||||
const char *basename;
|
||||
const char *bname = info->path + info->name_start;
|
||||
struct stat st;
|
||||
|
||||
/* TODO: eio_file_ls_direct() and get more useful parameter than file */
|
||||
basename = ecore_file_file_get(file);
|
||||
if ((!basename) || (basename[0] == '.'))
|
||||
return EINA_FALSE;
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
if (info->dirent->d_type == DT_DIR) return EINA_TRUE;
|
||||
|
||||
return ((stat(file, &st) == 0) && (S_ISDIR(st.st_mode)));
|
||||
if (info->dirent->d_type != DT_UNKNOWN) return EINA_FALSE;
|
||||
return ((stat(info->path, &st) == 0) && (S_ISDIR(st.st_mode)));
|
||||
}
|
||||
|
||||
/* Check image type from another thread */
|
||||
static Eina_Bool
|
||||
_ephoto_populate_filter_image(void *data, const char *file)
|
||||
_ephoto_populate_filter_image(void *data, const Eina_File_Direct_Info *info)
|
||||
{
|
||||
const char *type, *basename;
|
||||
|
||||
/* TODO: eio_file_ls_direct() and get more useful parameter than file */
|
||||
basename = ecore_file_file_get(file);
|
||||
if ((!basename) || (basename[0] == '.'))
|
||||
return EINA_FALSE;
|
||||
|
||||
/* TODO: speed up case for jpg/jpeg/png */
|
||||
if (!(type = efreet_mime_type_get(file)))
|
||||
return EINA_FALSE;
|
||||
if (!strncmp(type, "image", 5))
|
||||
return EINA_TRUE;
|
||||
|
||||
return EINA_FALSE;
|
||||
return _ephoto_eina_file_direct_info_image_useful(info);
|
||||
}
|
||||
|
||||
/*Done populating directories*/
|
||||
|
@ -282,93 +269,83 @@ _ephoto_populate_end_directory(void *data)
|
|||
static void
|
||||
_ephoto_populate_end_image(void *data)
|
||||
{
|
||||
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser *)data;
|
||||
Ephoto_Thumb_Browser *tb = data;
|
||||
const char *file;
|
||||
|
||||
tb->list = NULL;
|
||||
tb->list = NULL;
|
||||
|
||||
if (em->config->sort_images)
|
||||
{
|
||||
Eina_List *l;
|
||||
const char *file;
|
||||
em->images = eina_list_sort(em->images,
|
||||
eina_list_count(em->images),
|
||||
EINA_COMPARE_CB(strcoll));
|
||||
EINA_LIST_FOREACH(em->images, l, file)
|
||||
{
|
||||
_ephoto_thumbnail_add(tb, file, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
if (!em->config->sort_images) return;
|
||||
|
||||
em->images = eina_list_sort(em->images, -1, EINA_COMPARE_CB(strcoll));
|
||||
EINA_LIST_FREE(em->images, file)
|
||||
{
|
||||
_ephoto_thumbnail_add(tb, file);
|
||||
eina_stringshare_del(file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_error(int error, void *data)
|
||||
{
|
||||
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data;
|
||||
/* We don't handle error case in ephoto */
|
||||
tb->list = NULL;
|
||||
Ephoto_Thumb_Browser *tb = data;
|
||||
/* We don't handle error case in ephoto */
|
||||
tb->list = NULL;
|
||||
}
|
||||
|
||||
/* Build the interface component after detection from main thread */
|
||||
static void
|
||||
_ephoto_populate_main_directory(void *data, const char *file)
|
||||
_ephoto_populate_main_directory(void *data, const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data;
|
||||
_ephoto_thumbnail_add(tb, file, EINA_TRUE);
|
||||
Ephoto_Thumb_Browser *tb = data;
|
||||
Ephoto_Thumb_Data *td = _ephoto_thumbnail_add(tb, info->path);
|
||||
td->is_directory = EINA_TRUE;
|
||||
}
|
||||
|
||||
/* Build the interface component after detection from main thread */
|
||||
static void
|
||||
_ephoto_populate_main_image(void *data, const char *file)
|
||||
_ephoto_populate_main_image(void *data, const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data;
|
||||
const char *type;
|
||||
|
||||
file = eina_stringshare_ref(file);
|
||||
Ephoto_Thumb_Browser *tb = data;
|
||||
Ephoto_Thumb_Data *td;
|
||||
|
||||
if (em->config->sort_images)
|
||||
{
|
||||
const char *file = eina_stringshare_add_length
|
||||
(info->path, info->path_length);
|
||||
em->images = eina_list_append(em->images, file);
|
||||
if (em->config->sort_images) return;
|
||||
|
||||
if (!(type = efreet_mime_type_get(file)))
|
||||
return;
|
||||
if (!strncmp(type, "image", 5))
|
||||
{
|
||||
em->images = eina_list_append(em->images, file);
|
||||
|
||||
_ephoto_thumbnail_add(tb, file, EINA_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ephoto_thumbnail_add(tb, file, EINA_TRUE);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
td = _ephoto_thumbnail_add(tb, info->path);
|
||||
td->is_directory = !_ephoto_eina_file_direct_info_image_useful(info);
|
||||
}
|
||||
|
||||
/*Create a thread to populate images*/
|
||||
static void
|
||||
_ephoto_populate_images(Ephoto_Thumb_Browser *tb)
|
||||
{
|
||||
tb->list = eio_file_ls(em->config->directory,
|
||||
_ephoto_populate_filter_image,
|
||||
_ephoto_populate_main_image,
|
||||
_ephoto_populate_end_image,
|
||||
_ephoto_populate_error,
|
||||
tb);
|
||||
tb->list = eio_file_direct_ls(em->config->directory,
|
||||
_ephoto_populate_filter_image,
|
||||
_ephoto_populate_main_image,
|
||||
_ephoto_populate_end_image,
|
||||
_ephoto_populate_error,
|
||||
tb);
|
||||
}
|
||||
|
||||
/* Start a thread to list images and directories in a directory without locking the interface */
|
||||
void
|
||||
ephoto_populate_thumbnails(Evas_Object *obj)
|
||||
{
|
||||
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
|
||||
|
||||
_ephoto_thumbnail_add(tb, PARENT_DIR, EINA_TRUE);
|
||||
tb->list = eio_file_ls(em->config->directory,
|
||||
_ephoto_populate_filter_directory,
|
||||
_ephoto_populate_main_directory,
|
||||
_ephoto_populate_end_directory,
|
||||
_ephoto_populate_error,
|
||||
tb);
|
||||
Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser");
|
||||
Ephoto_Thumb_Data *td = _ephoto_thumbnail_add(tb, PARENT_DIR);
|
||||
td->is_directory = EINA_TRUE;
|
||||
td->is_up = EINA_TRUE;
|
||||
tb->list = eio_file_direct_ls(em->config->directory,
|
||||
_ephoto_populate_filter_directory,
|
||||
_ephoto_populate_main_directory,
|
||||
_ephoto_populate_end_directory,
|
||||
_ephoto_populate_error,
|
||||
tb);
|
||||
}
|
||||
|
||||
/*Zoom out the thumbnail size*/
|
||||
|
@ -428,17 +405,15 @@ _ephoto_slider_changed(void *data, Evas_Object *obj, void *event)
|
|||
}
|
||||
|
||||
/* Called when adding a directory or a file to elm_gengrid */
|
||||
static void
|
||||
_ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path, Eina_Bool is_dir)
|
||||
static Ephoto_Thumb_Data *
|
||||
_ephoto_thumbnail_add(Ephoto_Thumb_Browser *tb, const char *path)
|
||||
{
|
||||
Ephoto_Thumb_Data *etd;
|
||||
|
||||
etd = calloc(1, sizeof(*etd));
|
||||
etd->thumb_path = eina_stringshare_add(path);
|
||||
etd->file = eina_stringshare_add(path);
|
||||
etd->basename = ecore_file_file_get(etd->file);
|
||||
etd->is_directory = is_dir;
|
||||
elm_gengrid_item_append(tb->thumb_browser, &tb->eg, etd, NULL, NULL);
|
||||
Ephoto_Thumb_Data *etd = calloc(1, sizeof(*etd));
|
||||
etd->file = eina_stringshare_add(path);
|
||||
etd->thumb_path = eina_stringshare_ref(etd->file);
|
||||
etd->basename = ecore_file_file_get(etd->file);
|
||||
elm_gengrid_item_append(tb->thumb_browser, &tb->eg, etd, NULL, NULL);
|
||||
return etd;
|
||||
}
|
||||
|
||||
/*Get the label for the icon in the grid*/
|
||||
|
@ -449,6 +424,15 @@ _ephoto_get_label(void *data, Evas_Object *obj, const char *part)
|
|||
return strdup(etd->basename);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_ephoto_directory_up_add(Evas_Object *parent_obj)
|
||||
{
|
||||
Evas_Object *obj = edje_object_add(evas_object_evas_get(parent_obj));
|
||||
edje_object_file_set(obj, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
|
||||
"/ephoto/directory/up");
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*Get the image for the icon in the grid*/
|
||||
static Evas_Object *
|
||||
_ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
|
||||
|
@ -470,7 +454,10 @@ _ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
|
|||
|
||||
if (etd->is_directory)
|
||||
{
|
||||
o = ephoto_directory_thumb_add(thumb, etd->thumb_path);
|
||||
if (etd->is_up)
|
||||
o = _ephoto_directory_up_add(thumb);
|
||||
else
|
||||
o = ephoto_directory_thumb_add(thumb, etd->thumb_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -535,6 +522,8 @@ _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory)
|
|||
|
||||
if ((directory) && (eina_stringshare_replace(&em->config->directory, directory)))
|
||||
{
|
||||
const char *s;
|
||||
|
||||
l = elm_gengrid_items_get(tb->thumb_browser);
|
||||
EINA_LIST_FOREACH(l, iter, item)
|
||||
{
|
||||
|
@ -544,8 +533,7 @@ _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory)
|
|||
free(etd);
|
||||
}
|
||||
elm_gengrid_clear(tb->thumb_browser);
|
||||
eina_list_free(em->images);
|
||||
em->images = NULL;
|
||||
EINA_LIST_FREE(em->images, s) eina_stringshare_del(s);
|
||||
ephoto_populate_thumbnails(tb->layout);
|
||||
elm_label_label_set(tb->dir_label, em->config->directory);
|
||||
_ephoto_set_title(em->config->directory);
|
||||
|
|
Loading…
Reference in New Issue