Ephoto: Make the thumb browser alphabetical again. Default panel to visible. Show files in selector.

This commit is contained in:
Stephen Houston 2014-11-18 15:35:24 -06:00
parent ba54326c1e
commit f7f6c9c59f
4 changed files with 66 additions and 7 deletions

View File

@ -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_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_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
void ephoto_entries_free(Ephoto *ephoto); void ephoto_entries_free(Ephoto *ephoto);
int ephoto_entries_cmp(const void *pa, const void *pb);
extern int __log_domain; extern int __log_domain;
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__) #define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)

View File

@ -259,6 +259,13 @@ ephoto_title_set(Ephoto *ephoto, const char *title)
elm_win_title_set(ephoto->win, buf); 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 static void
_ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info) _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); 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 = calloc(1, sizeof(Ephoto_Event_Entry_Create));
ev->entry = e; ev->entry = e;

View File

@ -822,7 +822,7 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
elm_panel_orient_set(sb->panel, ELM_PANEL_ORIENT_LEFT); 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_weight_set(sb->panel, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(sb->panel, EVAS_HINT_FILL, EVAS_HINT_FILL); 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); elm_table_pack(sb->table, sb->panel, 0, 0, 1, 1);
evas_object_show(sb->panel); evas_object_show(sb->panel);

View File

@ -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 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 static void
_entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e) _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
{ {
const Elm_Gengrid_Item_Class *ic; const Elm_Gengrid_Item_Class *ic;
int near_cmp;
Elm_Object_Item *near_item = NULL;
Eina_List *near_node = NULL;
near_node = eina_list_search_sorted_near_list
(tb->grid_items, _entry_cmp, e, &near_cmp);
if (near_node)
near_item = near_node->data;
ic = &_ephoto_thumb_file_class; ic = &_ephoto_thumb_file_class;
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL); if (!near_item)
tb->grid_items = eina_list_append(tb->grid_items, e->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) if (e->item)
elm_object_item_data_set(e->item, e); elm_object_item_data_set(e->item, e);
else 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); evas_object_size_hint_align_set(tb->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(tb->entry, "Choose"); elm_object_text_set(tb->entry, "Choose");
elm_object_part_content_set(tb->entry, "button icon", ic); 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_entry_inwin_mode_set(tb->entry, EINA_TRUE);
elm_fileselector_expandable_set(tb->entry, EINA_FALSE); elm_fileselector_expandable_set(tb->entry, EINA_FALSE);
evas_object_smart_callback_add 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); 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_weight_set(tb->panel, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(tb->panel, EVAS_HINT_FILL, EVAS_HINT_FILL); 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); elm_table_pack(tb->table, tb->panel, 0, 0, 1, 1);
evas_object_show(tb->panel); evas_object_show(tb->panel);