okra pushed a commit to branch master.

http://git.enlightenment.org/apps/ephoto.git/commit/?id=9ec91c1297723918316111dc889a8961cc1c17a6

commit 9ec91c1297723918316111dc889a8961cc1c17a6
Author: Stephen okra Houston <smhousto...@gmail.com>
Date:   Thu Feb 25 16:43:14 2016 -0600

    Ephoto: More monitor work
---
 src/bin/ephoto_main.c           |  15 ++++-
 src/bin/ephoto_single_browser.c | 132 +++++++++++++++++++---------------------
 2 files changed, 74 insertions(+), 73 deletions(-)

diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c
index 5235f5a..82a6b7b 100644
--- a/src/bin/ephoto_main.c
+++ b/src/bin/ephoto_main.c
@@ -470,9 +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));
+
+   printf("Howdy %s\n", ev->filename);
    
    if (strcmp(ephoto->config->directory, dir))
-     return ECORE_CALLBACK_PASS_ON;
+     return ECORE_CALLBACK_RENEW;
 
    if (evas_object_image_extension_can_load_get(ev->filename))
      {
@@ -552,6 +554,8 @@ _monitor_modified(void *data, int type EINA_UNUSED, void 
*event)
    Eio_Monitor_Event *ev = event;
    char file[PATH_MAX], dir[PATH_MAX];
 
+   printf("Doody %s\n", ev->filename);
+
    snprintf(file, PATH_MAX, "%s", ev->filename);
    snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
 
@@ -562,6 +566,7 @@ _monitor_modified(void *data, int type EINA_UNUSED, void 
*event)
      {
         Eina_List *l;
         Ephoto_Entry *entry;
+        int found = 0;
 
         EINA_LIST_FOREACH(ephoto->entries, l, entry)
           {
@@ -574,11 +579,17 @@ _monitor_modified(void *data, int type EINA_UNUSED, void 
*event)
                     }
                   else
                     {
-                       ephoto_thumb_browser_update(ephoto, entry);
+                       if (!entry->item)
+                         ephoto_thumb_browser_insert(ephoto, entry);
+                       else
+                         ephoto_thumb_browser_update(ephoto, entry);
                     }
+                  found = 1;
                   break;
                }
           }
+        if (!found)
+          _monitor_created(ephoto, 0, ev);
      }
    return ECORE_CALLBACK_PASS_ON;
 }
diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c
index 2cf1396..dc43f83 100644
--- a/src/bin/ephoto_single_browser.c
+++ b/src/bin/ephoto_single_browser.c
@@ -47,7 +47,6 @@ struct _Ephoto_Viewer
    double zoom;
    Eina_Bool fit:1;
    Eina_Bool zoom_first:1;
-   Eina_Bool modified:1;
 };
 
 static void _zoom_set(Ephoto_Single_Browser *sb, double zoom);
@@ -71,33 +70,6 @@ _viewer_del(void *data, Evas *e EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED,
    free(v);
 }
 
-static Eina_Bool
-_monitor_modified(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
-{
-   Ephoto_Single_Browser *sb = data;
-   Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
-
-   if (!ecore_file_exists(sb->entry->path))
-     ephoto_entry_free(sb->ephoto, sb->entry);
-   else
-     v->modified = EINA_TRUE;
-   return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_monitor_closed(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
-{
-   Ephoto_Single_Browser *sb = data;
-   Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
-
-   if (v->modified == EINA_TRUE)
-     {
-        ephoto_single_browser_entry_set(sb->main, sb->entry);
-        v->modified = EINA_FALSE;
-     }
-   return ECORE_CALLBACK_PASS_ON;
-}
-
 static Evas_Object *
 _image_create_icon(void *data, Evas_Object *parent, Evas_Coord *xoff,
     Evas_Coord *yoff)
@@ -179,6 +151,63 @@ _image_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
    _1s_hold = NULL;
 }
 
+static const char *
+_get_edje_group(const char  *path)
+{
+   const char *group = NULL;
+   const char *ext = strrchr(path, '.');
+
+   if (ext)
+     {
+        ext++;
+        if ((strcasecmp(ext, "edj") == 0))
+          {
+             if (edje_file_group_exists(path, "e/desktop/background"))
+                group = "e/desktop/background";
+             else
+               {
+                  Eina_List *g = edje_file_collection_list(path);
+
+                  group = eina_list_data_get(g);
+                  edje_file_collection_list_free(g);
+               }
+          }
+     }
+   return group;
+}
+
+static Eina_Bool
+_monitor_modified(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
+{
+   Ephoto_Single_Browser *sb = data;
+   Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
+
+   printf("Cutie\n");
+
+   if (!ecore_file_exists(sb->entry->path))
+     ephoto_entry_free(sb->ephoto, sb->entry);
+   else
+     {
+        Evas_Object *tmp;
+        Evas_Coord w, h;
+        const char *group = _get_edje_group(sb->entry->path);
+
+        tmp = evas_object_image_add(evas_object_evas_get(v->table));
+        evas_object_image_file_set(tmp, sb->entry->path, group);
+        evas_object_image_size_get(tmp, &w, &h);
+        evas_object_del(tmp);
+
+        if (w > 0 && h > 0)
+          {
+             evas_object_hide(v->image);
+             elm_image_file_set(v->image, sb->entry->path, group);
+             evas_object_show(v->image);
+          }
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 static Evas_Object *
 _viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
 {
@@ -188,25 +217,8 @@ _viewer_add(Evas_Object *parent, const char *path, 
Ephoto_Single_Browser *sb)
    v->zoom_first = EINA_TRUE;
 
    Evas_Coord w, h;
-   const char *group = NULL;
-   const char *ext = strrchr(path, '.');
-
-   if (ext)
-     {
-       ext++;
-       if ((strcasecmp(ext, "edj") == 0))
-         {
-            if (edje_file_group_exists(path, "e/desktop/background"))
-               group = "e/desktop/background";
-            else
-              {
-                 Eina_List *g = edje_file_collection_list(path);
+   const char *group = _get_edje_group(path);
 
-                 group = eina_list_data_get(g);
-                 edje_file_collection_list_free(g);
-              }
-         }
-     }
    v->scroller = elm_scroller_add(parent);
    evas_object_size_hint_weight_set(v->scroller, EVAS_HINT_EXPAND,
        EVAS_HINT_EXPAND);
@@ -229,7 +241,7 @@ _viewer_add(Evas_Object *parent, const char *path, 
Ephoto_Single_Browser *sb)
    elm_image_file_set(v->image, path, group);
    err = evas_object_image_load_error_get(elm_image_object_get(v->image));
    if (err != EVAS_LOAD_ERROR_NONE)
-      goto error;
+     goto error;
    evas_object_image_size_get(elm_image_object_get(v->image), &w, &h);
    elm_drop_target_add(v->image, ELM_SEL_FORMAT_IMAGE, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL);
@@ -252,9 +264,6 @@ _viewer_add(Evas_Object *parent, const char *path, 
Ephoto_Single_Browser *sb)
    v->handlers = eina_list_append(v->handlers,
        ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED,
            _monitor_modified, sb));
-   v->handlers = eina_list_append(v->handlers,
-       ecore_event_handler_add(EIO_MONITOR_FILE_CLOSED, _monitor_closed, sb));
-
    return v->scroller;
 
   error:
@@ -2882,27 +2891,8 @@ ephoto_single_browser_cancel_editing(Evas_Object *main, 
Evas_Object *image)
          }
         else
          {
-            const char *group = NULL;
-            const char *ext = strrchr(sb->entry->path, '.');
-
-            if (ext)
-              {
-                 ext++;
-                 if ((strcasecmp(ext, "edj") == 0))
-                   {
-                      if (edje_file_group_exists(sb->entry->path,
-                              "e/desktop/background"))
-                         group = "e/desktop/background";
-                      else
-                        {
-                           Eina_List *g =
-                               edje_file_collection_list(sb->entry->path);
-                           group = eina_list_data_get(g);
-                           edje_file_collection_list_free(g);
-                        }
-                      elm_image_file_set(image, sb->entry->path, group);
-                   }
-              }
+            const char *group = _get_edje_group(sb->entry->path);
+             elm_image_file_set(image, sb->entry->path, group);
          }
        evas_object_freeze_events_set(sb->bar, EINA_FALSE);
        elm_object_disabled_set(sb->bar, EINA_FALSE);

-- 


Reply via email to