aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Houston <smhouston88@gmail.com>2017-09-23 18:25:29 -0500
committerStephen Houston <smhouston88@gmail.com>2017-09-23 18:25:29 -0500
commit258b6f3b26b4ae8da4b2d9b55e12cd0bee22510c (patch)
tree879cd349e22a180e8c7a595a0e6463b12df1523d
parentEnter commit summary (diff)
downloadephoto-258b6f3b26b4ae8da4b2d9b55e12cd0bee22510c.tar.gz
Ephoto: Fix F2-Rename crash. Add Exif Data Property viewer.
-rw-r--r--meson.build26
-rw-r--r--src/bin/ephoto.h5
-rw-r--r--src/bin/ephoto_config.c133
-rw-r--r--src/bin/ephoto_file.c125
-rw-r--r--src/bin/ephoto_single_browser.c16
-rw-r--r--src/bin/ephoto_thumb_browser.c2
-rw-r--r--src/bin/meson.build3
7 files changed, 227 insertions, 83 deletions
diff --git a/meson.build b/meson.build
index 01ddeed..aae480f 100644
--- a/meson.build
+++ b/meson.build
@@ -13,9 +13,10 @@ cfg = configuration_data()
##### dependencies
efl_version = '>= 1.19.0'
-elm = dependency('elementary', required: true, version: efl_version)
-edje = dependency('edje', required: true, version: efl_version)
-eipc = dependency('ecore-ipc', required: true, version: efl_version)
+elm = dependency('elementary', required: true, version: efl_version)
+edje = dependency('edje', required: true, version: efl_version)
+eipc = dependency('ecore-ipc', required: true, version: efl_version)
+exif = dependency('libexif', required: false, version: '>= 0.6.0')
##### check for windows dependency
if build_machine.system() == 'windows'
win = dependency('evil', version: efl_version)
@@ -34,10 +35,7 @@ cc = meson.get_compiler('c')
##### get edje command
edje_cmd = join_paths(edje.get_pkgconfig_variable('prefix'),
'bin', 'edje_cc')
-##### translations
-if get_option('nls') == true
- subdir('po')
-endif
+
##### config.h
cfg.set_quoted('PACKAGE' , proj)
cfg.set_quoted('PACKAGE_NAME' , proj)
@@ -61,11 +59,25 @@ endif
##### Check for arpa/inet and netinet/in.h
if cc.has_header('arpa/inet.h') == true
cfg.set ('HAVE_ARPA_INET_H' , 1)
+else
+ cfg.set ('HAVE_ARPA_INET_H' , 0)
endif
if cc.has_header('netinet/in.h') == true
cfg.set ('HAVE_NETINET_IN_H' , 1)
+else
+ cfg.set ('HAVE_NETINET_IN_H' , 0)
+endif
+if exif.found() == true
+ cfg.set ('HAVE_LIBEXIF' , 1)
+else
+ cfg.set ('HAVE_LIBEXIF' , 0)
endif
configure_file(output: 'config.h', configuration: cfg)
+##### translations
+if get_option('nls') == true
+ subdir('po')
+endif
+
subdir('src')
subdir('data')
diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h
index d5626d7..961c501 100644
--- a/src/bin/ephoto.h
+++ b/src/bin/ephoto.h
@@ -159,6 +159,11 @@ void ephoto_filter_emboss(Ephoto *ephoto, Evas_Object *image);
void ephoto_filter_histogram_eq(Ephoto *ephoto, Evas_Object *image);
/*file functions*/
+#ifdef HAVE_LIBEXIF
+Eina_Bool ephoto_file_has_exif(const char *file);
+Eina_Hash *ephoto_file_get_exif_data(Ephoto *ephoto, const char *file);
+void ephoto_file_exif_data(Ephoto *ephoto, const char *file);
+#endif
void ephoto_file_save_image(Ephoto *ephoto, Ephoto_Entry *entry,
Evas_Object *image);
void ephoto_file_save_image_as(Ephoto *ephoto, Ephoto_Entry *entry,
diff --git a/src/bin/ephoto_config.c b/src/bin/ephoto_config.c
index 0d87649..892333d 100644
--- a/src/bin/ephoto_config.c
+++ b/src/bin/ephoto_config.c
@@ -144,7 +144,7 @@ _config_general(Ephoto *ephoto, Evas_Object *parent)
elm_spinner_step_set(spinner, .05);
elm_spinner_value_set(spinner, ephoto->config->left_size);
elm_spinner_min_max_set(spinner, 0, 1);
- EPHOTO_EXPAND(spinner);
+ EPHOTO_WEIGHT(spinner, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
EPHOTO_FILL(spinner);
elm_table_pack(table, spinner, 0, 6, 1, 1);
evas_object_show(spinner);
@@ -248,7 +248,7 @@ _config_slideshow(Ephoto *ephoto, Evas_Object *parent)
check = elm_check_add(table);
elm_object_text_set(check, _("Moving Slideshow"));
- EPHOTO_ALIGN(check, 0.5, 0.5);
+ EPHOTO_ALIGN(check, 0.5, 0.0);
elm_check_state_set(check, ephoto->config->movess);
elm_table_pack(table, check, 0, 0, 2, 1);
evas_object_show(check);
@@ -305,30 +305,20 @@ _config_slideshow(Ephoto *ephoto, Evas_Object *parent)
static Evas_Object *
_config_settings(Ephoto *ephoto, Evas_Object *parent, Eina_Bool slideshow)
{
- Evas_Object *frame, *vbox;
+ Evas_Object *box;
- frame = elm_frame_add(parent);
- if (!slideshow)
- elm_object_text_set(frame, _("General"));
- else
- elm_object_text_set(frame, _("Slideshow"));
- EPHOTO_EXPAND(frame);
- EPHOTO_FILL(frame);
- evas_object_show(frame);
-
- vbox = elm_box_add(frame);
- elm_box_horizontal_set(vbox, EINA_FALSE);
- EPHOTO_EXPAND(vbox);
- EPHOTO_FILL(vbox);
- elm_object_content_set(frame, vbox);
- evas_object_show(vbox);
+ box = elm_box_add(parent);
+ elm_box_horizontal_set(box, EINA_FALSE);
+ EPHOTO_EXPAND(box);
+ EPHOTO_FILL(box);
+ evas_object_show(box);
if (!slideshow)
- _config_general(ephoto, vbox);
+ _config_general(ephoto, box);
else
- _config_slideshow(ephoto, vbox);
+ _config_slideshow(ephoto, box);
- return frame;
+ return box;
}
static void
@@ -389,29 +379,16 @@ _link_anchor(void *data, Evas_Object *obj, void *event_info)
static Evas_Object *
_config_bindings(Evas_Object *parent)
{
- Evas_Object *frame, *box, *scroller, *entry;
+ Evas_Object *box, *entry;
Eina_Strbuf *sbuf = eina_strbuf_new();
- frame = elm_frame_add(parent);
- elm_object_text_set(frame, _("Bindings"));
- EPHOTO_EXPAND(frame);
- EPHOTO_FILL(frame);
- evas_object_show(frame);
-
box = elm_box_add(parent);
elm_box_horizontal_set(box, EINA_FALSE);
EPHOTO_EXPAND(box);
EPHOTO_FILL(box);
- elm_object_content_set(frame, box);
evas_object_show(box);
- scroller = elm_scroller_add(box);
- EPHOTO_EXPAND(scroller);
- EPHOTO_FILL(scroller);
- elm_box_pack_end(box, scroller);
- evas_object_show(scroller);
-
- entry = elm_entry_add(scroller);
+ entry = elm_entry_add(box);
elm_entry_editable_set(entry, EINA_FALSE);
elm_entry_line_wrap_set(entry, ELM_WRAP_NONE);
EPHOTO_WEIGHT(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -465,38 +442,24 @@ _config_bindings(Evas_Object *parent)
"<b>End:</b> Navigate Last<br/>"
"<b>Escape:</b> Quit Slideshow<br/>"));
elm_object_text_set(entry, eina_strbuf_string_get(sbuf));
- elm_object_content_set(scroller, entry);
+ elm_box_pack_end(box, entry);
evas_object_show(entry);
- return frame;
+ return box;
}
static Evas_Object *
_config_about(Evas_Object *parent)
{
- Evas_Object *frame, *box, *entry, *img, *lbl;
- Evas_Object *scroller;
+ Evas_Object *box, *entry, *img, *lbl;
Eina_Strbuf *sbuf = eina_strbuf_new();
char ver[PATH_MAX];
FILE *f;
- frame = elm_frame_add(parent);
- elm_object_text_set(frame, _("About"));
- EPHOTO_EXPAND(frame);
- EPHOTO_FILL(frame);
- evas_object_show(frame);
-
- scroller = elm_scroller_add(frame);
- EPHOTO_EXPAND(scroller);
- EPHOTO_FILL(scroller);
- elm_object_content_set(frame, scroller);
- evas_object_show(scroller);
-
- box = elm_box_add(frame);
+ box = elm_box_add(parent);
elm_box_horizontal_set(box, EINA_FALSE);
EPHOTO_EXPAND(box);
EPHOTO_FILL(box);
- elm_object_content_set(scroller, box);
evas_object_show(box);
img = elm_image_add(box);
@@ -512,7 +475,7 @@ _config_about(Evas_Object *parent)
lbl = elm_label_add(box);
elm_object_text_set(lbl, ver);
- EPHOTO_EXPAND(lbl);
+ EPHOTO_WEIGHT(lbl, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
EPHOTO_FILL(lbl);
elm_box_pack_end(box, lbl);
evas_object_show(lbl);
@@ -586,7 +549,7 @@ _config_about(Evas_Object *parent)
elm_box_pack_end(box, entry);
evas_object_show(entry);
- return frame;
+ return box;
}
static void
@@ -598,11 +561,17 @@ _list_clicked(void *data, Evas_Object *o, void *event EINA_UNUSED)
Evas_Object *slideshow = evas_object_data_get(o, "slideshow");
Evas_Object *kb = evas_object_data_get(o, "bindings");
Evas_Object *about = evas_object_data_get(o, "about");
+ Evas_Object *pager = evas_object_data_get(o, "pager");
evas_object_hide(settings);
evas_object_hide(slideshow);
evas_object_hide(kb);
evas_object_hide(about);
+ elm_box_unpack(pager, settings);
+ elm_box_unpack(pager, slideshow);
+ elm_box_unpack(pager, kb);
+ elm_box_unpack(pager, about);
+ elm_box_pack_end(pager, page);
evas_object_show(page);
}
@@ -677,8 +646,8 @@ save_end:
void
ephoto_config_main(Ephoto *ephoto)
{
- Evas_Object *popup, *table, *list, *ic;
- Evas_Object *slideshow, *settings, *kb, *about;
+ Evas_Object *popup, *box, *scroller, *table, *list, *ic;
+ Evas_Object *slideshow, *settings, *kb, *about, *pager;
Elm_Object_Item *slideshowi, *settingsi, *kbi, *abouti;
popup = elm_popup_add(ephoto->win);
@@ -687,32 +656,49 @@ ephoto_config_main(Ephoto *ephoto)
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
evas_object_smart_callback_add(popup, "block,clicked", _config_save_cb, popup);
- table = elm_table_add(popup);
+ box = elm_box_add(popup);
+ EPHOTO_EXPAND(box);
+ EPHOTO_FILL(box);
+ evas_object_size_hint_min_set(box, ephoto->config->window_width / 2,
+ ephoto->config->window_height / 2);
+ evas_object_show(box);
+
+ scroller = elm_scroller_add(box);
+ EPHOTO_EXPAND(scroller);
+ EPHOTO_FILL(scroller);
+ elm_box_pack_end(box, scroller);
+ evas_object_show(scroller);
+
+ table = elm_table_add(scroller);
elm_table_homogeneous_set(table, EINA_FALSE);
EPHOTO_EXPAND(table);
EPHOTO_FILL(table);
-
- settings = _config_settings(ephoto, table, EINA_FALSE);
- elm_table_pack(table, settings, 1, 0, 1, 1);
- kb = _config_bindings(table);
- elm_table_pack(table, kb, 1, 0, 1, 1);
- about = _config_about(table);
- elm_table_pack(table, about, 1, 0, 1, 1);
- slideshow = _config_settings(ephoto, table, EINA_TRUE);
- elm_table_pack(table, slideshow, 1, 0, 1, 1);
+ evas_object_show(table);
list = elm_list_add(table);
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_scroller_content_min_limit(list, 1, 1);
- EPHOTO_EXPAND(list);
+ EPHOTO_WEIGHT(list, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
EPHOTO_FILL(list);
elm_table_pack(table, list, 0, 0, 1, 1);
evas_object_show(list);
+ pager = elm_box_add(table);
+ EPHOTO_EXPAND(pager);
+ EPHOTO_FILL(pager);
+ elm_table_pack(table, pager, 1, 0, 2, 1);
+ evas_object_show(pager);
+
+ settings = _config_settings(ephoto, pager, EINA_FALSE);
+ kb = _config_bindings(pager);
+ about = _config_about(pager);
+ slideshow = _config_settings(ephoto, pager, EINA_TRUE);
+
evas_object_data_set(list, "settings", settings);
evas_object_data_set(list, "slideshow", slideshow);
evas_object_data_set(list, "bindings", kb);
evas_object_data_set(list, "about", about);
+ evas_object_data_set(list, "pager", pager);
ic = elm_icon_add(list);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
@@ -748,14 +734,13 @@ ephoto_config_main(Ephoto *ephoto)
elm_object_item_data_set(slideshowi, slideshow);
elm_object_item_data_set(kbi, kb);
elm_object_item_data_set(abouti, about);
- evas_object_hide(slideshow);
- evas_object_hide(kb);
- evas_object_hide(about);
+ _list_clicked(settings, NULL, NULL);
elm_list_item_selected_set(settingsi, EINA_TRUE);
- evas_object_show(table);
- elm_object_content_set(popup, table);
+ elm_object_content_set(scroller, table);
+
+ elm_object_content_set(popup, box);
evas_object_data_set(popup, "ephoto", ephoto);
evas_object_show(popup);
diff --git a/src/bin/ephoto_file.c b/src/bin/ephoto_file.c
index f83f5a4..66dddf0 100644
--- a/src/bin/ephoto_file.c
+++ b/src/bin/ephoto_file.c
@@ -1,4 +1,129 @@
#include "ephoto.h"
+#ifdef HAVE_LIBEXIF
+#include <libexif/exif-data.h>
+
+Eina_Bool
+ephoto_file_has_exif(const char *file)
+{
+ ExifData *ed = exif_data_new_from_file(file);
+
+ ed = exif_data_new_from_file(file);
+ if (!ed) return EINA_FALSE;
+
+ exif_data_unref(ed);
+ return EINA_TRUE;
+}
+
+Eina_Hash *
+ephoto_file_get_exif_data(Ephoto *ephoto EINA_UNUSED, const char *file)
+{
+ ExifData *ed = exif_data_new_from_file(file);
+ ExifEntry *ee = NULL;
+ Eina_Hash *hash = eina_hash_string_superfast_new(NULL);
+ unsigned int tag, val;
+ const char *title = NULL;
+ char value[1024];
+
+ if (!ed) return NULL;
+ for (tag = 0; tag < 0xffff; tag++)
+ {
+ title = exif_tag_get_title(tag);
+ for (val = 0; val < EXIF_IFD_COUNT; val++)
+ {
+ ee = exif_content_get_entry(ed->ifd[val], tag);
+ if (ee)
+ {
+ exif_entry_ref(ee);
+ exif_entry_get_value(ee, value, 1024);
+ eina_hash_add(hash, eina_stringshare_add(title),
+ eina_stringshare_add(value));
+ exif_entry_unref(ee);
+ }
+ }
+ }
+ exif_data_unref(ed);
+ return hash;
+}
+
+static void
+_exif_save_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Evas_Object *popup = data;
+
+ evas_object_del(popup);
+}
+
+void
+ephoto_file_exif_data(Ephoto *ephoto, const char *file)
+{
+ Eina_Hash *hash = NULL;
+ Eina_Iterator *it = NULL;
+ Eina_Hash_Tuple *t = NULL;
+ Evas_Object *popup, *box, *scroller, *list, *label, *entry;
+ const char *key = NULL, *value = NULL;
+ int i = 0;
+
+ hash = ephoto_file_get_exif_data(ephoto, file);
+
+ popup = elm_popup_add(ephoto->win);
+ elm_popup_scrollable_set(popup, EINA_TRUE);
+ elm_object_part_text_set(popup, "title,text", _("Image Properties"));
+ elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
+ evas_object_smart_callback_add(popup, "block,clicked", _exif_save_cb, popup);
+
+ box = elm_box_add(popup);
+ EPHOTO_EXPAND(box);
+ EPHOTO_FILL(box);
+ evas_object_size_hint_min_set(box, ephoto->config->window_width / 2,
+ ephoto->config->window_height / 2);
+ evas_object_show(box);
+
+ scroller = elm_scroller_add(box);
+ EPHOTO_EXPAND(scroller);
+ EPHOTO_FILL(scroller);
+ elm_box_pack_end(box, scroller);
+ evas_object_show(scroller);
+
+ list = elm_table_add(scroller);
+ elm_table_homogeneous_set(list, EINA_FALSE);
+ EPHOTO_EXPAND(list);
+ EPHOTO_FILL(list);
+ elm_object_content_set(scroller, list);
+ evas_object_show(list);
+
+ it = eina_hash_iterator_tuple_new(hash);
+ EINA_ITERATOR_FOREACH(it, t)
+ {
+ key = t->key;
+ value = t->data;
+
+ label = elm_label_add(list);
+ elm_object_text_set(label, key);
+ EPHOTO_ALIGN(label, 0.0, 0.5);
+ elm_table_pack(list, label, 0, i, 1, 1);
+ evas_object_show(label);
+
+ entry = elm_entry_add(list);
+ elm_entry_single_line_set(entry, EINA_TRUE);
+ elm_entry_scrollable_set(entry, EINA_TRUE);
+ elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
+ elm_object_text_set(entry, value);
+ EPHOTO_EXPAND(entry);
+ EPHOTO_FILL(entry);
+ elm_table_pack(list, entry, 1, i, 1, 1);
+ evas_object_show(entry);
+
+ i++;
+ }
+ eina_iterator_free(it);
+
+ evas_object_data_set(popup, "ephoto", ephoto);
+ elm_object_part_content_set(popup, "default", box);
+ evas_object_show(popup);
+}
+#endif
static void
_complete_ok(void *data, Evas_Object *obj EINA_UNUSED,
diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c
index eda1b98..c20ac7e 100644
--- a/src/bin/ephoto_single_browser.c
+++ b/src/bin/ephoto_single_browser.c
@@ -1092,6 +1092,17 @@ _upload_image(void *data, Evas_Object *obj EINA_UNUSED,
}
static void
+_view_exif(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Ephoto_Single_Browser *sb = data;
+
+#ifdef HAVE_LIBEXIF
+ ephoto_file_exif_data(sb->ephoto, sb->entry->path);
+#endif
+}
+
+static void
_delete_image(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
@@ -1905,6 +1916,11 @@ _add_edit_menu_items(Ephoto_Single_Browser *sb, Evas_Object *menu)
_delete_image, sb);
elm_menu_item_add(menu, menu_it, "document-send", _("Upload"), _upload_image,
sb);
+#ifdef HAVE_LIBEXIF
+ if (ephoto_file_has_exif(sb->entry->path))
+ elm_menu_item_add(menu, menu_it, "document-properties", _("Properties"),
+ _view_exif, sb);
+#endif
elm_menu_item_separator_add(menu, NULL);
elm_menu_item_add(menu, NULL, "zoom-fit", _("Zoom Fit"), _zoom_fit_cb,
sb);
diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c
index 8de8b52..b7073b7 100644
--- a/src/bin/ephoto_thumb_browser.c
+++ b/src/bin/ephoto_thumb_browser.c
@@ -1765,7 +1765,7 @@ _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
if (it)
{
evas_object_data_del(tb->main, "rename_item");
- evas_object_data_set(tb->main, "rename_item", tb);
+ evas_object_data_set(tb->main, "rename_item", it);
_grid_menu_rename_cb(tb, NULL, NULL);
}
}
diff --git a/src/bin/meson.build b/src/bin/meson.build
index fe87d16..73b194f 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -2,7 +2,8 @@ inc = include_directories('.', '../..')
deps = [
elm,
edje,
- eipc
+ eipc,
+ exif
]
executable('ephoto', [
'ephoto.c',