Ephoto exif data: Don't forget to clean up the allocated mem.
This commit is contained in:
parent
9469522d9d
commit
8906abeb41
|
@ -161,7 +161,7 @@ void ephoto_filter_histogram_eq(Ephoto *ephoto, Evas_Object *image);
|
||||||
/*file functions*/
|
/*file functions*/
|
||||||
#ifdef HAVE_LIBEXIF
|
#ifdef HAVE_LIBEXIF
|
||||||
Eina_Bool ephoto_file_has_exif(const char *file);
|
Eina_Bool ephoto_file_has_exif(const char *file);
|
||||||
Eina_Hash *ephoto_file_get_exif_data(Ephoto *ephoto, const char *file);
|
Eina_List *ephoto_file_get_exif_data(const char *file);
|
||||||
void ephoto_file_exif_data(Ephoto *ephoto, const char *file);
|
void ephoto_file_exif_data(Ephoto *ephoto, const char *file);
|
||||||
#endif
|
#endif
|
||||||
void ephoto_file_save_image(Ephoto *ephoto, Ephoto_Entry *entry,
|
void ephoto_file_save_image(Ephoto *ephoto, Ephoto_Entry *entry,
|
||||||
|
|
|
@ -12,24 +12,31 @@ struct _Ephoto_Exif_Animator
|
||||||
int processed;
|
int processed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _Ephoto_Exif_Item Ephoto_Exif_Item;
|
||||||
|
struct _Ephoto_Exif_Item
|
||||||
|
{
|
||||||
|
unsigned int tag;
|
||||||
|
unsigned int ifd;
|
||||||
|
const char *title;
|
||||||
|
const char *value;
|
||||||
|
};
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
ephoto_file_has_exif(const char *file)
|
ephoto_file_has_exif(const char *file)
|
||||||
{
|
{
|
||||||
ExifData *ed = exif_data_new_from_file(file);
|
ExifData *ed = exif_data_new_from_file(file);
|
||||||
|
|
||||||
ed = exif_data_new_from_file(file);
|
|
||||||
if (!ed) return EINA_FALSE;
|
if (!ed) return EINA_FALSE;
|
||||||
|
|
||||||
exif_data_unref(ed);
|
exif_data_unref(ed);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Hash *
|
Eina_List *
|
||||||
ephoto_file_get_exif_data(Ephoto *ephoto EINA_UNUSED, const char *file)
|
ephoto_file_get_exif_data(const char *file)
|
||||||
{
|
{
|
||||||
ExifData *ed = exif_data_new_from_file(file);
|
ExifData *ed = exif_data_new_from_file(file);
|
||||||
ExifEntry *ee = NULL;
|
ExifEntry *ee = NULL;
|
||||||
Eina_Hash *hash = eina_hash_string_superfast_new(NULL);
|
Eina_List *list = NULL;
|
||||||
unsigned int tag, val;
|
unsigned int tag, val;
|
||||||
const char *title = NULL;
|
const char *title = NULL;
|
||||||
char value[1024];
|
char value[1024];
|
||||||
|
@ -43,26 +50,32 @@ ephoto_file_get_exif_data(Ephoto *ephoto EINA_UNUSED, const char *file)
|
||||||
ee = exif_content_get_entry(ed->ifd[val], tag);
|
ee = exif_content_get_entry(ed->ifd[val], tag);
|
||||||
if (ee)
|
if (ee)
|
||||||
{
|
{
|
||||||
|
Ephoto_Exif_Item *eei;
|
||||||
|
|
||||||
|
eei = calloc(1, sizeof(Ephoto_Exif_Item));
|
||||||
|
eei->tag = tag;
|
||||||
|
eei->ifd = val;
|
||||||
|
eei->title = title;
|
||||||
exif_entry_ref(ee);
|
exif_entry_ref(ee);
|
||||||
exif_entry_get_value(ee, value, 1024);
|
exif_entry_get_value(ee, value, 1024);
|
||||||
eina_hash_add(hash, eina_stringshare_add(title),
|
eei->value = eina_stringshare_add(value);
|
||||||
eina_stringshare_add(value));
|
list = eina_list_append(list, eei);
|
||||||
exif_entry_unref(ee);
|
exif_entry_unref(ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exif_data_unref(ed);
|
exif_data_unref(ed);
|
||||||
return hash;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_exif_items_process(void *data)
|
_exif_items_process(void *data)
|
||||||
{
|
{
|
||||||
Ephoto_Exif_Animator *animator = data;
|
Ephoto_Exif_Animator *animator = data;
|
||||||
Eina_Hash_Tuple *t;
|
|
||||||
Evas_Object *label, *entry;
|
Evas_Object *label, *entry;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const char *key, *value;
|
const char *value, *key;
|
||||||
|
Ephoto_Exif_Item *eei;
|
||||||
|
|
||||||
if (animator->processed == animator->count)
|
if (animator->processed == animator->count)
|
||||||
{
|
{
|
||||||
|
@ -70,13 +83,13 @@ _exif_items_process(void *data)
|
||||||
free(animator);
|
free(animator);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
EINA_LIST_FREE(animator->todo_items, t)
|
EINA_LIST_FREE(animator->todo_items, eei)
|
||||||
{
|
{
|
||||||
if (i > 3)
|
if (i > 3)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
||||||
key = t->key;
|
key = eei->title;
|
||||||
value = t->data;
|
value = eei->value;
|
||||||
|
|
||||||
label = elm_label_add(animator->parent);
|
label = elm_label_add(animator->parent);
|
||||||
elm_object_text_set(label, key);
|
elm_object_text_set(label, key);
|
||||||
|
@ -102,26 +115,39 @@ _exif_items_process(void *data)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_exif_list_free(Eina_List *list)
|
||||||
|
{
|
||||||
|
Ephoto_Exif_Item *eei;
|
||||||
|
|
||||||
|
EINA_LIST_FREE(list, eei)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(eei->value);
|
||||||
|
free(eei);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_exif_save_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
_exif_save_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Evas_Object *popup = data;
|
Evas_Object *popup = data;
|
||||||
|
Eina_List *list = evas_object_data_get(popup, "list");
|
||||||
|
|
||||||
|
_exif_list_free(list);
|
||||||
evas_object_del(popup);
|
evas_object_del(popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ephoto_file_exif_data(Ephoto *ephoto, const char *file)
|
ephoto_file_exif_data(Ephoto *ephoto, const char *file)
|
||||||
{
|
{
|
||||||
Eina_Hash *hash = NULL;
|
Eina_List *list = NULL, *l = NULL;
|
||||||
Eina_Iterator *it = NULL;
|
Evas_Object *popup, *box, *scroller, *table;
|
||||||
Eina_Hash_Tuple *t = NULL;
|
|
||||||
Evas_Object *popup, *box, *scroller, *list;
|
|
||||||
Ephoto_Exif_Animator *animator;
|
Ephoto_Exif_Animator *animator;
|
||||||
|
Ephoto_Exif_Item *eei;
|
||||||
|
|
||||||
hash = ephoto_file_get_exif_data(ephoto, file);
|
list = ephoto_file_get_exif_data(file);
|
||||||
if (!hash)
|
if (!list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
animator = calloc(1, sizeof(Ephoto_Exif_Animator));
|
animator = calloc(1, sizeof(Ephoto_Exif_Animator));
|
||||||
|
@ -148,24 +174,23 @@ ephoto_file_exif_data(Ephoto *ephoto, const char *file)
|
||||||
elm_box_pack_end(box, scroller);
|
elm_box_pack_end(box, scroller);
|
||||||
evas_object_show(scroller);
|
evas_object_show(scroller);
|
||||||
|
|
||||||
list = elm_table_add(scroller);
|
table = elm_table_add(scroller);
|
||||||
elm_table_homogeneous_set(list, EINA_FALSE);
|
elm_table_homogeneous_set(table, EINA_FALSE);
|
||||||
EPHOTO_EXPAND(list);
|
EPHOTO_EXPAND(table);
|
||||||
EPHOTO_FILL(list);
|
EPHOTO_FILL(table);
|
||||||
elm_object_content_set(scroller, list);
|
elm_object_content_set(scroller, table);
|
||||||
evas_object_show(list);
|
evas_object_show(table);
|
||||||
|
|
||||||
animator->parent = list;
|
animator->parent = table;
|
||||||
|
|
||||||
it = eina_hash_iterator_tuple_new(hash);
|
EINA_LIST_FOREACH(list, l, eei)
|
||||||
EINA_ITERATOR_FOREACH(it, t)
|
|
||||||
{
|
{
|
||||||
animator->todo_items = eina_list_append(animator->todo_items, t);
|
animator->todo_items = eina_list_append(animator->todo_items, eei);
|
||||||
animator->count++;
|
animator->count++;
|
||||||
}
|
}
|
||||||
animator->todo = ecore_idler_add(_exif_items_process, animator);
|
animator->todo = ecore_idler_add(_exif_items_process, animator);
|
||||||
eina_iterator_free(it);
|
|
||||||
|
|
||||||
|
evas_object_data_set(popup, "list", list);
|
||||||
evas_object_data_set(popup, "ephoto", ephoto);
|
evas_object_data_set(popup, "ephoto", ephoto);
|
||||||
elm_object_part_content_set(popup, "default", box);
|
elm_object_part_content_set(popup, "default", box);
|
||||||
evas_object_show(popup);
|
evas_object_show(popup);
|
||||||
|
|
Loading…
Reference in New Issue