diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index 5a4b539..c828b60 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -64,6 +64,7 @@ void ephoto_single_browser_entries_set(Evas_Object *obj, Eina_List *entries); void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry); void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path); +void ephoto_single_browser_path_created(Evas_Object *obj, Ephoto_Entry *entry); void ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w, int h); @@ -82,6 +83,7 @@ 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. */ diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index e496687..5235f5a 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -470,11 +470,11 @@ _monitor_created(void *data, int type EINA_UNUSED, void *event) snprintf(file, PATH_MAX, "%s", ev->filename); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); - + if (strcmp(ephoto->config->directory, dir)) return ECORE_CALLBACK_PASS_ON; - if (!strncmp("image/", efreet_mime_type_get(ev->filename), 6)) + if (evas_object_image_extension_can_load_get(ev->filename)) { Eina_List *l; Ephoto_Entry *entry; @@ -488,6 +488,7 @@ _monitor_created(void *data, int type EINA_UNUSED, void *event) snprintf(buf, PATH_MAX, "%s", ev->filename); entry = ephoto_entry_new(ephoto, ev->filename, basename(buf), EINA_FILE_REG); + ephoto_single_browser_path_created(ephoto->single_browser, entry); if (!ephoto->entries) { ephoto->entries = eina_list_append(ephoto->entries, entry); @@ -519,7 +520,6 @@ _monitor_deleted(void *data, int type EINA_UNUSED, void *event) Ephoto *ephoto = data; Eio_Monitor_Event *ev = event; char file[PATH_MAX], dir[PATH_MAX]; - const char *mime; snprintf(file, PATH_MAX, "%s", ev->filename); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); @@ -527,8 +527,7 @@ _monitor_deleted(void *data, int type EINA_UNUSED, void *event) if (strcmp(ephoto->config->directory, dir)) return ECORE_CALLBACK_PASS_ON; - mime = efreet_mime_type_get(ev->filename); - if (!mime || !strncmp("image/", mime, 6)) + if (evas_object_image_extension_can_load_get(ev->filename)) { Eina_List *l; Ephoto_Entry *entry; @@ -559,7 +558,7 @@ _monitor_modified(void *data, int type EINA_UNUSED, void *event) if (strcmp(ephoto->config->directory, dir)) return ECORE_CALLBACK_PASS_ON; - if (!strncmp("image/", efreet_mime_type_get(ev->filename), 6)) + if (evas_object_image_extension_can_load_get(ev->filename)) { Eina_List *l; Ephoto_Entry *entry; @@ -575,8 +574,7 @@ _monitor_modified(void *data, int type EINA_UNUSED, void *event) } else { - ephoto_thumb_browser_remove(ephoto, entry); - ephoto_thumb_browser_insert(ephoto, entry); + ephoto_thumb_browser_update(ephoto, entry); } break; } diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c index 1cbf5a9..2cf1396 100644 --- a/src/bin/ephoto_single_browser.c +++ b/src/bin/ephoto_single_browser.c @@ -1202,15 +1202,19 @@ _save_image_as_overwrite(void *data, Evas_Object *obj EINA_UNUSED, return; } } + ephoto_single_browser_path_pending_set(sb->ephoto->single_browser, file); success = evas_object_image_save(elm_image_object_get(v->image), file, NULL, NULL); if (!success) - _failed_save(sb); + { + _failed_save(sb); + eina_stringshare_del(sb->pending_path); + sb->pending_path = NULL; + } else { char *dir = ecore_file_dir_get(file); - if (strcmp(dir, sb->ephoto->config->directory)) { ephoto_thumb_browser_fsel_clear(sb->ephoto); @@ -1218,8 +1222,6 @@ _save_image_as_overwrite(void *data, Evas_Object *obj EINA_UNUSED, ephoto_thumb_browser_top_dir_set(sb->ephoto, sb->ephoto->config->directory); free(dir); - ephoto_single_browser_path_pending_set(sb->ephoto->single_browser, - file); } } evas_object_del(popup); @@ -1243,11 +1245,29 @@ _save_image_as_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) Eina_Bool success; char buf[PATH_MAX]; - - if (!_ephoto_file_image_can_save(strrchr(selected, '.')+1)) - snprintf(buf, PATH_MAX, "%s.jpg", selected); - else - snprintf(buf, PATH_MAX, "%s", selected); + const char *ex, *ext; + + ex = strrchr(selected, '.'); + if (!ex) + { + snprintf(buf, PATH_MAX, "%s.jpg", selected); + } + else + { + ext = eina_stringshare_add((strrchr(selected, '.')+1)); + if (!_ephoto_file_image_can_save(ext)) + { + if (ext) + eina_stringshare_del(ext); + snprintf(buf, PATH_MAX, "%s.jpg", selected); + } + else + { + if (ext) + eina_stringshare_del(ext); + snprintf(buf, PATH_MAX, "%s", selected); + } + } if (ecore_file_exists(buf)) { Evas_Object *popup, *box, *label, *ic, *button; @@ -1313,11 +1333,17 @@ _save_image_as_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) } else { + ephoto_single_browser_path_pending_set(sb->ephoto-> + single_browser, buf); success = evas_object_image_save(elm_image_object_get(v->image), buf, NULL, NULL); if (!success) - _failed_save(sb); + { + _failed_save(sb); + eina_stringshare_del(sb->pending_path); + sb->pending_path = NULL; + } else { char *dir = ecore_file_dir_get(buf); @@ -1330,8 +1356,6 @@ _save_image_as_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ephoto_thumb_browser_top_dir_set(sb->ephoto, sb->ephoto->config->directory); free(dir); - ephoto_single_browser_path_pending_set(sb->ephoto-> - single_browser, buf); } } } @@ -2486,7 +2510,7 @@ _ephoto_single_entry_create(void *data, int type EINA_UNUSED, Ephoto_Entry *e; e = ev->entry; - if (!sb->entry && sb->pending_path && e->path == sb->pending_path) + if (sb->pending_path && !strcmp(e->path, sb->pending_path)) { eina_stringshare_del(sb->pending_path); sb->pending_path = NULL; @@ -2697,7 +2721,7 @@ ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry) sb->entry = entry; if (entry) - ephoto_entry_free_listener_add(entry, _entry_free, sb); + ephoto_entry_free_listener_add(entry, _entry_free, sb); _ephoto_single_browser_recalc(sb); if (sb->edited_image_data) @@ -2757,9 +2781,28 @@ ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path) { Ephoto_Single_Browser *sb = evas_object_data_get(obj, "single_browser"); + if (sb->pending_path) + { + eina_stringshare_del(sb->pending_path); + sb->pending_path = NULL; + } sb->pending_path = eina_stringshare_add(path); } + +void +ephoto_single_browser_path_created(Evas_Object *obj, Ephoto_Entry *entry) +{ + Ephoto_Single_Browser *sb = evas_object_data_get(obj, "single_browser"); + + if (sb->pending_path && !strcmp(entry->path, sb->pending_path)) + { + eina_stringshare_del(sb->pending_path); + sb->pending_path = NULL; + ephoto_single_browser_entry_set(sb->ephoto->single_browser, entry); + } +} + void ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w, int h) diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c index ea72125..f3e221b 100644 --- a/src/bin/ephoto_thumb_browser.c +++ b/src/bin/ephoto_thumb_browser.c @@ -507,6 +507,8 @@ _monitor_created(void *data, int type EINA_UNUSED, void *event) if (!entry) return ECORE_CALLBACK_PASS_ON; + if (!ecore_file_is_dir(ev->filename)) + return ECORE_CALLBACK_PASS_ON; snprintf(file, PATH_MAX, "%s", ev->filename); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); @@ -641,6 +643,8 @@ _monitor_modified(void *data, int type EINA_UNUSED, void *event) if (!entry) return ECORE_CALLBACK_PASS_ON; + if (!ecore_file_is_dir(ev->filename)) + return ECORE_CALLBACK_PASS_ON; snprintf(file, PATH_MAX, "%s", ev->filename); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); @@ -1397,7 +1401,7 @@ _move_idler_cb(void *data) if (!file) break; if (ecore_file_exists(file) && ecore_file_is_dir(destination) && - !strncmp("image/", efreet_mime_type_get(file), 6)) + evas_object_image_extension_can_load_get(file)) { char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX]; int ret; @@ -1496,7 +1500,7 @@ _copy_idler_cb(void *data) if (!file) break; if (ecore_file_exists(file) && ecore_file_is_dir(destination) && - !strncmp("image/", efreet_mime_type_get(file), 6)) + evas_object_image_extension_can_load_get(file)) { char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX]; int ret; @@ -3646,6 +3650,8 @@ _top_monitor_created(void *data, int type EINA_UNUSED, void *event) if (!tb) return ECORE_CALLBACK_PASS_ON; + if (!ecore_file_is_dir(ev->filename)) + return ECORE_CALLBACK_PASS_ON; snprintf(file, PATH_MAX, "%s", ev->filename); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); @@ -3728,6 +3734,8 @@ _top_monitor_modified(void *data, int type EINA_UNUSED, void *event) if (!tb) return ECORE_CALLBACK_PASS_ON; + if (!ecore_file_is_dir(ev->filename)) + return ECORE_CALLBACK_PASS_ON; snprintf(file, PATH_MAX, "%s", ev->filename); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); @@ -3847,6 +3855,29 @@ ephoto_thumb_browser_remove(Ephoto *ephoto, Ephoto_Entry *entry) } } +void +ephoto_thumb_browser_update(Ephoto *ephoto, Ephoto_Entry *entry) +{ + Ephoto_Thumb_Browser *tb = + evas_object_data_get(ephoto->thumb_browser, "thumb_browser"); + + if (!entry->is_dir) + { + Eina_File *f; + + tb->totsize -= entry->size; + + f = eina_file_open(entry->path, EINA_FALSE); + entry->size = eina_file_size_get(f); + tb->totsize += (double) entry->size; + eina_file_close(f); + + elm_gengrid_item_update(entry->item); + tb->totsize += entry->size; + _update_info_label(tb); + } +} + void ephoto_thumb_browser_top_dir_set(Ephoto *ephoto, const char *dir) { @@ -4048,9 +4079,9 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) EVAS_HINT_FILL); evas_object_size_hint_align_set(tb->direntry, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(tb->leftbox, tb->direntry); evas_object_smart_callback_add(tb->direntry, "activated", _ephoto_direntry_go, tb); + elm_box_pack_end(tb->leftbox, tb->direntry); evas_object_show(tb->direntry); tb->fsel = elm_genlist_add(tb->leftbox); @@ -4059,7 +4090,6 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) evas_object_size_hint_weight_set(tb->fsel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(tb->fsel, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(tb->leftbox, tb->fsel); evas_object_smart_callback_add(tb->fsel, "expand,request", _on_list_expand_req, tb); evas_object_smart_callback_add(tb->fsel, "contract,request", @@ -4070,6 +4100,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) evas_object_event_callback_add(tb->fsel, EVAS_CALLBACK_MOUSE_UP, _fsel_mouse_up_cb, tb); evas_object_data_set(tb->fsel, "thumb_browser", tb); + elm_box_pack_end(tb->leftbox, tb->fsel); evas_object_show(tb->fsel); elm_drop_item_container_add(tb->fsel, ELM_SEL_FORMAT_TARGETS, _drop_item_getcb, _drop_enter, tb, _drop_leave, tb, _drop_pos, tb, @@ -4095,11 +4126,11 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) EVAS_HINT_FILL); evas_object_size_hint_aspect_set(tb->nolabel, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - evas_object_show(tb->nolabel); if (!tb->ephoto->config->fsel_hide) elm_table_pack(tb->table, tb->nolabel, 1, 0, 4, 1); else elm_table_pack(tb->table, tb->nolabel, 0, 0, 5, 1); + evas_object_show(tb->nolabel); tb->gridbox = elm_box_add(tb->table); elm_box_horizontal_set(tb->gridbox, EINA_FALSE); @@ -4125,17 +4156,15 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) elm_drag_item_container_add(tb->grid, ANIM_TIME, DRAG_TIMEOUT, _dnd_item_get, _dnd_item_data_get); evas_object_data_set(tb->grid, "thumb_browser", tb); - - _zoom_set(tb, tb->ephoto->config->thumb_size); - elm_box_pack_end(tb->gridbox, tb->grid); evas_object_show(tb->grid); - if (!tb->ephoto->config->fsel_hide) elm_table_pack(tb->table, tb->gridbox, 1, 0, 4, 1); else elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1); + _zoom_set(tb, tb->ephoto->config->thumb_size); + tb->infolabel = elm_label_add(tb->table); elm_label_line_wrap_set(tb->infolabel, ELM_WRAP_WORD); elm_object_text_set(tb->infolabel, "Info Label"); @@ -4144,8 +4173,8 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) EVAS_HINT_FILL); evas_object_size_hint_aspect_set(tb->infolabel, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - evas_object_show(tb->infolabel); elm_table_pack(tb->table, tb->infolabel, 0, 1, 5, 1); + evas_object_show(tb->infolabel); tb->handlers = eina_list_append(tb->handlers,