Use elm_layout for the images. Use a hash to keep a match of files and their corresponding thumb_path.

SVN revision: 50005
This commit is contained in:
titan 2010-07-02 21:35:51 +00:00 committed by titan
parent 0f3b22a98a
commit 6926304983
4 changed files with 42 additions and 77 deletions

View File

@ -11,26 +11,9 @@ collections
} }
group group
{ {
name: "/ephoto/thumb/shadow"; name: "/ephoto/thumb";
min: 198 136;
parts parts
{ {
part
{
name: "ephoto.swallow.content";
type: SWALLOW;
mouse_events: 1;
description
{
state: "default" 0.0;
min: 1 1;
max: 176 117;
visible: 1;
rel1.relative: 0.0 0.0;
rel2.relative: 1.0 1.0;
color: 255 255 255 255;
}
}
part part
{ {
name: "background"; name: "background";
@ -39,24 +22,11 @@ collections
description description
{ {
state: "default" 0.0; state: "default" 0.0;
min: 198 136;
rel1.to: "ephoto.swallow.content";
rel1.offset: 4 2;
rel2.to: "ephoto.swallow.content";
rel2.offset: -5 3;
color: 255 255 255 255; color: 255 255 255 255;
image.normal: "thumb_shadow.png"; image.normal: "thumb_shadow.png";
image.border: 12 12 7 13; image.border: 12 12 7 13;
} }
} }
}
}
group
{
name: "/ephoto/thumb/image";
min: 176 117;
parts
{
part part
{ {
name: "clipper"; name: "clipper";
@ -66,8 +36,10 @@ collections
{ {
state: "default" 0.0; state: "default" 0.0;
visible: 1; visible: 1;
min: 1 1; rel1.to: "background";
max: 176 117; rel1.offset: 12 7;
rel2.to: "background";
rel2.offset: -13 -14;
color: 255 255 255 255; color: 255 255 255 255;
} }
} }
@ -81,8 +53,6 @@ collections
{ {
state: "default" 0.0; state: "default" 0.0;
visible: 1; visible: 1;
min: 1 1;
max: 176 117;
rel1.to: "clipper"; rel1.to: "clipper";
rel1.relative: 0.0 0.0; rel1.relative: 0.0 0.0;
rel2.to: "clipper"; rel2.to: "clipper";

View File

@ -51,7 +51,8 @@ struct _Ephoto
Evas_Object *thumb_browser; Evas_Object *thumb_browser;
Evas_Object *thumb_slider; Evas_Object *thumb_slider;
Evas_Object *toolbar; Evas_Object *toolbar;
Eina_List *images; Eina_Hash *thumbs_images;
Eina_List *images;
}; };
typedef struct _Ephoto Ephoto; typedef struct _Ephoto Ephoto;
extern Ephoto *em; extern Ephoto *em;

View File

@ -5,11 +5,13 @@ Ephoto *em;
/*Inline Callbacks*/ /*Inline Callbacks*/
static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info); static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_free_hash(void *data);
/*Create the main ephoto window*/ /*Create the main ephoto window*/
void ephoto_create_main_window(void) void ephoto_create_main_window(void)
{ {
em = calloc(1, sizeof(Ephoto)); em = calloc(1, sizeof(Ephoto));
em->thumbs_images = eina_hash_string_superfast_new(_ephoto_free_hash);
/*Setup the main window*/ /*Setup the main window*/
em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC); em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
@ -46,9 +48,20 @@ static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event
evas_object_del(em->box); evas_object_del(em->box);
evas_object_del(em->bg); evas_object_del(em->bg);
evas_object_del(em->win); evas_object_del(em->win);
if (em->images); if (em->thumbs_images)
eina_hash_free(em->thumbs_images);
if (em->images)
eina_list_free(em->images); eina_list_free(em->images);
free(em); free(em);
elm_exit(); elm_exit();
} }
/*Free the eina hash*/
static void _ephoto_free_hash(void *data)
{
char *item;
item = data;
free(item);
}

View File

@ -240,17 +240,10 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id,
const char *thumb_path, const char *thumb_key, const char *thumb_path, const char *thumb_key,
Eina_Bool success) Eina_Bool success)
{ {
Evas_Object *o;
o = ephoto_thumb_add();
evas_object_image_size_set(o, 176, 117);
ephoto_thumb_fill_inside_set(o, 0);
ephoto_thumb_file_set(o, thumb_path, 176, 117);
evas_object_data_set(o, "file", strdup(file));
if (success) if (success)
{ {
elm_gengrid_item_append(em->thumb_browser, &eg, o, NULL, NULL); eina_hash_add(em->thumbs_images, strdup(file), strdup(thumb_path));
elm_gengrid_item_append(em->thumb_browser, &eg, file, NULL, NULL);
} }
} }
@ -258,12 +251,11 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id,
static char * static char *
_ephoto_get_label(const void *data, Evas_Object *obj, const char *part) _ephoto_get_label(const void *data, Evas_Object *obj, const char *part)
{ {
Evas_Object *o; char *file;
char *file, *bname; const char *bname;
o = (Evas_Object *)data; file = (char *)data;
file = evas_object_data_get(o, "file");
bname = basename(file); bname = basename(file);
return strdup(bname); return strdup(bname);
@ -273,37 +265,26 @@ _ephoto_get_label(const void *data, Evas_Object *obj, const char *part)
static Evas_Object * static Evas_Object *
_ephoto_get_icon(const void *data, Evas_Object *obj, const char *part) _ephoto_get_icon(const void *data, Evas_Object *obj, const char *part)
{ {
Evas_Object *edje, *thumb, *o; char *file, *path;
Evas_Object *thumb, *o;
o = (Evas_Object *)data; file = (char *)data;
path = (char *)eina_hash_find(em->thumbs_images, file);
if (!strcmp(part, "elm.swallow.icon")) if (!strcmp(part, "elm.swallow.icon"))
{ {
thumb = edje_object_add(evas_object_evas_get(em->thumb_browser)); thumb = elm_layout_add(em->win);
edje_object_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"/ephoto/thumb/shadow"); "/ephoto/thumb");
evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(thumb); evas_object_show(thumb);
evas_object_resize(thumb, 198, 136);
evas_object_size_hint_aspect_set(thumb, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
evas_object_size_hint_align_set(thumb, 0.5, 0.5);
evas_object_size_hint_fill_set(thumb, 1.0, 1.0);
evas_object_size_hint_min_set(thumb, 198, 136);
evas_object_size_hint_max_set(thumb, 198, 136);
edje = edje_object_add(evas_object_evas_get(em->thumb_browser)); o = ephoto_thumb_add();
edje_object_file_set(edje, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", evas_object_image_size_set(o, 176, 117);
"/ephoto/thumb/image"); ephoto_thumb_fill_inside_set(o, 0);
evas_object_show(edje); ephoto_thumb_file_set(o, path, 176, 117);
edje_object_part_swallow(edje, "ephoto.swallow.content", o); elm_layout_content_set(thumb, "ephoto.swallow.content", o);
edje_object_part_swallow(thumb, "ephoto.swallow.content", edje);
evas_object_resize(o, 176, 117);
evas_object_size_hint_min_set(o, 176, 117);
evas_object_size_hint_max_set(o, 176, 117);
evas_object_resize(edje, 176, 117);
evas_object_size_hint_min_set(edje, 176, 117);
evas_object_size_hint_max_set(edje, 176, 117);
return thumb; return thumb;
} }