okra pushed a commit to branch master.

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

commit f7f6c9c59f763f5f1de795a626f335679e6af967
Author: Stephen Houston <smhousto...@gmail.com>
Date:   Tue Nov 18 15:35:24 2014 -0600

    Ephoto: Make the thumb browser alphabetical again. Default panel to 
visible. Show files in selector.
---
 src/bin/ephoto.h                |  1 +
 src/bin/ephoto_main.c           | 22 ++++++++++++++++++-
 src/bin/ephoto_single_browser.c |  2 +-
 src/bin/ephoto_thumb_browser.c  | 48 ++++++++++++++++++++++++++++++++++++-----
 4 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h
index 9e21fa3..0315898 100644
--- a/src/bin/ephoto.h
+++ b/src/bin/ephoto.h
@@ -152,6 +152,7 @@ void          ephoto_entry_free(Ephoto_Entry *entry);
 void          ephoto_entry_free_listener_add(Ephoto_Entry *entry, void 
(*cb)(void *data, const Ephoto_Entry *entry), const void *data);
 void          ephoto_entry_free_listener_del(Ephoto_Entry *entry, void 
(*cb)(void *data, const Ephoto_Entry *entry), const void *data);
 void          ephoto_entries_free(Ephoto *ephoto);
+int          ephoto_entries_cmp(const void *pa, const void *pb);
 
 extern int __log_domain;
 #define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c
index 1857933..3004055 100644
--- a/src/bin/ephoto_main.c
+++ b/src/bin/ephoto_main.c
@@ -259,6 +259,13 @@ ephoto_title_set(Ephoto *ephoto, const char *title)
    elm_win_title_set(ephoto->win, buf);
 }
 
+int
+ephoto_entries_cmp(const void *pa, const void *pb)
+{
+   const Ephoto_Entry *a = pa, *b = pb;
+   return strcoll(a->basename, b->basename);
+}
+
 static void
 _ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const 
Eina_File_Direct_Info *info)
 {
@@ -268,7 +275,20 @@ _ephoto_populate_main(void *data, Eio_File *handler 
__UNUSED__, const Eina_File_
 
    e = ephoto_entry_new(ephoto, info->path, info->path + info->name_start);
 
-   ephoto->entries = eina_list_append(ephoto->entries, e);
+   if (!ephoto->entries)
+     ephoto->entries = eina_list_append(ephoto->entries, e);
+   else
+     {
+        int near_cmp;
+        Eina_List *near_node = eina_list_search_sorted_near_list
+          (ephoto->entries, ephoto_entries_cmp, e, &near_cmp);
+        if (near_cmp < 0)
+          ephoto->entries = eina_list_append_relative_list
+            (ephoto->entries, e, near_node);
+        else
+          ephoto->entries = eina_list_prepend_relative_list
+            (ephoto->entries, e, near_node);
+     }
    ev = calloc(1, sizeof(Ephoto_Event_Entry_Create));
    ev->entry = e;
 
diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c
index 9f8204a..7785be7 100644
--- a/src/bin/ephoto_single_browser.c
+++ b/src/bin/ephoto_single_browser.c
@@ -822,7 +822,7 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object 
*parent)
    elm_panel_orient_set(sb->panel, ELM_PANEL_ORIENT_LEFT);
    evas_object_size_hint_weight_set(sb->panel, 0.0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(sb->panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_panel_hidden_set(sb->panel, EINA_TRUE);
+   elm_panel_hidden_set(sb->panel, EINA_FALSE);
    elm_table_pack(sb->table, sb->panel, 0, 0, 1, 1);
    evas_object_show(sb->panel);
    
diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c
index c7c316c..7b2ef88 100644
--- a/src/bin/ephoto_thumb_browser.c
+++ b/src/bin/ephoto_thumb_browser.c
@@ -76,16 +76,54 @@ _ephoto_thumb_item_del(void *data __UNUSED__, Evas_Object 
*obj __UNUSED__)
 
 static Elm_Gengrid_Item_Class _ephoto_thumb_file_class;
 
+static int
+_entry_cmp(const void *pa, const void *pb)
+{
+   const Elm_Gengrid_Item *ia = pa;
+   const Ephoto_Entry *a, *b = pb;
+
+   a = elm_object_item_data_get(ia);
+
+   return strcoll(a->basename, b->basename);
+}
+
 static void
 _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
 {
    const Elm_Gengrid_Item_Class *ic;
+   int near_cmp;
+   Elm_Object_Item *near_item = NULL;
+   Eina_List *near_node = NULL;
 
-   ic = &_ephoto_thumb_file_class;
+   near_node = eina_list_search_sorted_near_list
+     (tb->grid_items, _entry_cmp, e, &near_cmp);
+   if (near_node)
+     near_item = near_node->data;
 
-   e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
-   tb->grid_items = eina_list_append(tb->grid_items, e->item);
+   ic = &_ephoto_thumb_file_class;
 
+   if (!near_item)
+     {
+        e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
+        tb->grid_items = eina_list_append(tb->grid_items, e->item);
+     }
+   else
+     {
+        if (near_cmp < 0)
+          {
+             e->item = elm_gengrid_item_insert_after
+               (tb->grid, ic, e, near_item, NULL, NULL);
+             tb->grid_items = eina_list_append_relative
+               (tb->grid_items, e->item, near_item);
+          }
+        else
+          {
+             e->item = elm_gengrid_item_insert_before
+               (tb->grid, ic, e, near_item, NULL, NULL);
+             tb->grid_items = eina_list_prepend_relative
+               (tb->grid_items, e->item, near_item);
+          }
+     }
    if (e->item)
      elm_object_item_data_set(e->item, e);
    else
@@ -363,7 +401,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object 
*parent)
    evas_object_size_hint_align_set(tb->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_object_text_set(tb->entry, "Choose");
    elm_object_part_content_set(tb->entry, "button icon", ic);
-   elm_fileselector_folder_only_set(tb->entry, EINA_TRUE);
+   elm_fileselector_folder_only_set(tb->entry, EINA_FALSE);
    elm_fileselector_entry_inwin_mode_set(tb->entry, EINA_TRUE);
    elm_fileselector_expandable_set(tb->entry, EINA_FALSE);
    evas_object_smart_callback_add
@@ -405,7 +443,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object 
*parent)
    elm_panel_orient_set(tb->panel, ELM_PANEL_ORIENT_LEFT);
    evas_object_size_hint_weight_set(tb->panel, 0.0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(tb->panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_panel_hidden_set(tb->panel, EINA_TRUE);
+   elm_panel_hidden_set(tb->panel, EINA_FALSE);
    elm_table_pack(tb->table, tb->panel, 0, 0, 1, 1);
    evas_object_show(tb->panel);
 

-- 


Reply via email to