@feature Moved toolbars to left side panels. Removed grid directory browsing.
Moved the toolbars to panels on the left side in order to make better use of space. Removed the ability to browse using the grid as it is redundant with the entry and file selector.
This commit is contained in:
parent
27709d6126
commit
ba54326c1e
|
@ -106,6 +106,7 @@ struct _Ephoto
|
||||||
{
|
{
|
||||||
Evas_Object *win;
|
Evas_Object *win;
|
||||||
Evas_Object *bg;
|
Evas_Object *bg;
|
||||||
|
Evas_Object *panel;
|
||||||
Evas_Object *pager;
|
Evas_Object *pager;
|
||||||
|
|
||||||
Evas_Object *thumb_browser;
|
Evas_Object *thumb_browser;
|
||||||
|
@ -139,8 +140,6 @@ struct _Ephoto_Entry
|
||||||
Ephoto *ephoto;
|
Ephoto *ephoto;
|
||||||
Elm_Object_Item *item;
|
Elm_Object_Item *item;
|
||||||
Eina_List *free_listeners;
|
Eina_List *free_listeners;
|
||||||
Eina_Bool is_dir : 1;
|
|
||||||
Eina_Bool is_up : 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ephoto_Event_Entry_Create
|
struct _Ephoto_Event_Entry_Create
|
||||||
|
@ -153,7 +152,6 @@ 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__)
|
||||||
|
|
|
@ -259,18 +259,6 @@ 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;
|
|
||||||
if (a->is_dir == b->is_dir)
|
|
||||||
return strcoll(a->basename, b->basename);
|
|
||||||
else if (a->is_dir)
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -279,26 +267,8 @@ _ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_
|
||||||
Ephoto_Event_Entry_Create *ev;
|
Ephoto_Event_Entry_Create *ev;
|
||||||
|
|
||||||
e = ephoto_entry_new(ephoto, info->path, info->path + info->name_start);
|
e = ephoto_entry_new(ephoto, info->path, info->path + info->name_start);
|
||||||
if (info->type == EINA_FILE_DIR) e->is_dir = EINA_TRUE;
|
|
||||||
else if (info->type == EINA_FILE_REG) e->is_dir = EINA_FALSE;
|
|
||||||
else e->is_dir = !_ephoto_eina_file_direct_info_image_useful(info);
|
|
||||||
|
|
||||||
if (!ephoto->entries)
|
|
||||||
ephoto->entries = eina_list_append(ephoto->entries, e);
|
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;
|
||||||
|
|
||||||
|
@ -311,7 +281,7 @@ _ephoto_populate_filter(void *data __UNUSED__, Eio_File *handler __UNUSED__, con
|
||||||
const char *bname = info->path + info->name_start;
|
const char *bname = info->path + info->name_start;
|
||||||
|
|
||||||
if (bname[0] == '.') return EINA_FALSE;
|
if (bname[0] == '.') return EINA_FALSE;
|
||||||
if (info->type == EINA_FILE_DIR) return EINA_TRUE;
|
if (info->type == EINA_FILE_DIR) return EINA_FALSE;
|
||||||
|
|
||||||
return _ephoto_eina_file_direct_info_image_useful(info);
|
return _ephoto_eina_file_direct_info_image_useful(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ struct _Ephoto_Single_Browser
|
||||||
Ephoto *ephoto;
|
Ephoto *ephoto;
|
||||||
Evas_Object *main;
|
Evas_Object *main;
|
||||||
Evas_Object *bar;
|
Evas_Object *bar;
|
||||||
Evas_Object *edje;
|
Evas_Object *table;
|
||||||
|
Evas_Object *panel;
|
||||||
Evas_Object *viewer;
|
Evas_Object *viewer;
|
||||||
const char *pending_path;
|
const char *pending_path;
|
||||||
Ephoto_Entry *entry;
|
Ephoto_Entry *entry;
|
||||||
|
@ -422,25 +423,16 @@ _mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *ev
|
||||||
static Ephoto_Entry *
|
static Ephoto_Entry *
|
||||||
_first_entry_find(Ephoto_Single_Browser *sb)
|
_first_entry_find(Ephoto_Single_Browser *sb)
|
||||||
{
|
{
|
||||||
const Eina_List *l;
|
|
||||||
Ephoto_Entry *entry;
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(sb->ephoto, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sb->ephoto, NULL);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(sb->ephoto->entries, l, entry)
|
return eina_list_nth(sb->ephoto->entries, 0);
|
||||||
if (!entry->is_dir) return entry;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Ephoto_Entry *
|
static Ephoto_Entry *
|
||||||
_last_entry_find(Ephoto_Single_Browser *sb)
|
_last_entry_find(Ephoto_Single_Browser *sb)
|
||||||
{
|
{
|
||||||
const Eina_List *l;
|
|
||||||
Ephoto_Entry *entry;
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(sb->ephoto, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sb->ephoto, NULL);
|
||||||
|
return eina_list_last_data_get(sb->ephoto->entries);
|
||||||
EINA_LIST_REVERSE_FOREACH(sb->ephoto->entries, l, entry)
|
|
||||||
if (!entry->is_dir) return entry;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ephoto_Orient
|
Ephoto_Orient
|
||||||
|
@ -490,14 +482,19 @@ _ephoto_single_browser_recalc(Ephoto_Single_Browser *sb)
|
||||||
if (sb->entry)
|
if (sb->entry)
|
||||||
{
|
{
|
||||||
const char *bname = ecore_file_file_get(sb->entry->path);
|
const char *bname = ecore_file_file_get(sb->entry->path);
|
||||||
|
|
||||||
|
elm_table_clear(sb->table, EINA_FALSE);
|
||||||
|
|
||||||
sb->viewer = _viewer_add(sb->main, sb->entry->path);
|
sb->viewer = _viewer_add(sb->main, sb->entry->path);
|
||||||
elm_layout_box_append(sb->main, "elm.box.content", sb->viewer);
|
elm_table_pack(sb->table, sb->viewer, 0, 0, 4, 1);
|
||||||
evas_object_show(sb->viewer);
|
evas_object_show(sb->viewer);
|
||||||
evas_object_event_callback_add
|
evas_object_event_callback_add
|
||||||
(sb->viewer, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel, sb);
|
(sb->viewer, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel, sb);
|
||||||
ephoto_title_set(sb->ephoto, bname);
|
ephoto_title_set(sb->ephoto, bname);
|
||||||
sb->orient = ephoto_file_orient_get(sb->entry->path);
|
sb->orient = ephoto_file_orient_get(sb->entry->path);
|
||||||
_orient_apply(sb);
|
_orient_apply(sb);
|
||||||
|
|
||||||
|
elm_table_pack(sb->table, sb->panel, 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
elm_object_focus_set(sb->main, EINA_TRUE);
|
elm_object_focus_set(sb->main, EINA_TRUE);
|
||||||
|
@ -566,8 +563,7 @@ _next_entry(Ephoto_Single_Browser *sb)
|
||||||
Eina_List *node;
|
Eina_List *node;
|
||||||
EINA_SAFETY_ON_NULL_RETURN(sb->entry);
|
EINA_SAFETY_ON_NULL_RETURN(sb->entry);
|
||||||
|
|
||||||
node = eina_list_search_sorted_list(sb->ephoto->entries, ephoto_entries_cmp,
|
node = eina_list_data_find_list(sb->ephoto->entries, sb->entry);
|
||||||
sb->entry);
|
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
if ((node = node->next))
|
if ((node = node->next))
|
||||||
entry = node->data;
|
entry = node->data;
|
||||||
|
@ -587,15 +583,10 @@ _prev_entry(Ephoto_Single_Browser *sb)
|
||||||
Ephoto_Entry *entry = NULL;
|
Ephoto_Entry *entry = NULL;
|
||||||
EINA_SAFETY_ON_NULL_RETURN(sb->entry);
|
EINA_SAFETY_ON_NULL_RETURN(sb->entry);
|
||||||
|
|
||||||
node = eina_list_search_sorted_list(sb->ephoto->entries, ephoto_entries_cmp,
|
node = eina_list_data_find_list(sb->ephoto->entries, sb->entry);
|
||||||
sb->entry);
|
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
if ((node = node->prev))
|
if ((node = node->prev))
|
||||||
{
|
|
||||||
entry = node->data;
|
entry = node->data;
|
||||||
if (entry->is_dir)
|
|
||||||
entry = NULL;
|
|
||||||
}
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
entry = _last_entry_find(sb);
|
entry = _last_entry_find(sb);
|
||||||
if (entry)
|
if (entry)
|
||||||
|
@ -801,38 +792,47 @@ _ephoto_single_entry_create(void *data, int type __UNUSED__, void *event __UNUSE
|
||||||
Evas_Object *
|
Evas_Object *
|
||||||
ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
||||||
{
|
{
|
||||||
Evas_Object *layout = elm_layout_add(parent);
|
Evas_Object *box = elm_box_add(parent);
|
||||||
Elm_Object_Item *icon;
|
Elm_Object_Item *icon;
|
||||||
Ephoto_Single_Browser *sb;
|
Ephoto_Single_Browser *sb;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(layout, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
|
||||||
|
|
||||||
sb = calloc(1, sizeof(Ephoto_Single_Browser));
|
sb = calloc(1, sizeof(Ephoto_Single_Browser));
|
||||||
EINA_SAFETY_ON_NULL_GOTO(sb, error);
|
EINA_SAFETY_ON_NULL_GOTO(sb, error);
|
||||||
sb->ephoto = ephoto;
|
|
||||||
sb->main = layout;
|
|
||||||
sb->edje = elm_layout_edje_get(layout);
|
|
||||||
|
|
||||||
|
sb->ephoto = ephoto;
|
||||||
|
sb->main = box;
|
||||||
|
|
||||||
|
evas_object_size_hint_weight_set(sb->main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(sb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
evas_object_event_callback_add(sb->main, EVAS_CALLBACK_DEL, _main_del, sb);
|
evas_object_event_callback_add(sb->main, EVAS_CALLBACK_DEL, _main_del, sb);
|
||||||
evas_object_event_callback_add
|
evas_object_event_callback_add
|
||||||
(sb->main, EVAS_CALLBACK_KEY_DOWN, _key_down, sb);
|
(sb->main, EVAS_CALLBACK_KEY_DOWN, _key_down, sb);
|
||||||
evas_object_data_set(sb->main, "single_browser", sb);
|
evas_object_data_set(sb->main, "single_browser", sb);
|
||||||
|
|
||||||
if (!elm_layout_theme_set(sb->main, "layout", "application", "toolbar-vbox"))
|
sb->table = elm_table_add(sb->main);
|
||||||
{
|
evas_object_size_hint_weight_set(sb->table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
ERR("Could not load style 'toolbar-vbox' from theme!");
|
evas_object_size_hint_align_set(sb->table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
goto error;
|
elm_box_pack_end(sb->main, sb->table);
|
||||||
}
|
evas_object_show(sb->table);
|
||||||
sb->bar = edje_object_part_external_object_get(sb->edje, "elm.external.toolbar");
|
|
||||||
if (!sb->bar)
|
sb->panel = elm_panel_add(sb->table);
|
||||||
{
|
EINA_SAFETY_ON_NULL_GOTO(sb->panel, error);
|
||||||
ERR("Could not find toolbar in layout!");
|
elm_panel_orient_set(sb->panel, ELM_PANEL_ORIENT_LEFT);
|
||||||
goto error;
|
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_toolbar_homogeneous_set(sb->bar, EINA_FALSE);
|
elm_panel_hidden_set(sb->panel, EINA_TRUE);
|
||||||
elm_toolbar_shrink_mode_set(sb->bar, ELM_TOOLBAR_SHRINK_MENU);
|
elm_table_pack(sb->table, sb->panel, 0, 0, 1, 1);
|
||||||
elm_toolbar_menu_parent_set(sb->bar, parent);
|
evas_object_show(sb->panel);
|
||||||
|
|
||||||
|
sb->bar = elm_toolbar_add(sb->panel);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(sb->bar, error);
|
||||||
|
elm_toolbar_horizontal_set(sb->bar, EINA_FALSE);
|
||||||
|
elm_toolbar_shrink_mode_set(sb->bar, ELM_TOOLBAR_SHRINK_SCROLL);
|
||||||
elm_toolbar_select_mode_set(sb->bar, ELM_OBJECT_SELECT_MODE_NONE);
|
elm_toolbar_select_mode_set(sb->bar, ELM_OBJECT_SELECT_MODE_NONE);
|
||||||
|
evas_object_size_hint_weight_set(sb->bar, 0.0, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(sb->bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
|
||||||
icon = elm_toolbar_item_append(sb->bar, "go-home", "Back", _back, sb);
|
icon = elm_toolbar_item_append(sb->bar, "go-home", "Back", _back, sb);
|
||||||
elm_toolbar_item_priority_set(icon, 150);
|
elm_toolbar_item_priority_set(icon, 150);
|
||||||
|
@ -868,6 +868,9 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
||||||
icon = elm_toolbar_item_append(sb->bar, "go-last", "Last", _go_last, sb);
|
icon = elm_toolbar_item_append(sb->bar, "go-last", "Last", _go_last, sb);
|
||||||
elm_toolbar_item_priority_set(icon, 60);
|
elm_toolbar_item_priority_set(icon, 60);
|
||||||
|
|
||||||
|
elm_object_content_set(sb->panel, sb->bar);
|
||||||
|
evas_object_show(sb->bar);
|
||||||
|
|
||||||
sb->handlers = eina_list_append
|
sb->handlers = eina_list_append
|
||||||
(sb->handlers, ecore_event_handler_add
|
(sb->handlers, ecore_event_handler_add
|
||||||
(EPHOTO_EVENT_POPULATE_END, _ephoto_single_populate_end, sb));
|
(EPHOTO_EVENT_POPULATE_END, _ephoto_single_populate_end, sb));
|
||||||
|
|
|
@ -202,7 +202,6 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
||||||
EINA_LIST_FOREACH(ss->ephoto->entries, l, itr)
|
EINA_LIST_FOREACH(ss->ephoto->entries, l, itr)
|
||||||
{
|
{
|
||||||
Elm_Object_Item *slideshow_item;
|
Elm_Object_Item *slideshow_item;
|
||||||
if (itr->is_dir) continue;
|
|
||||||
slideshow_item = elm_slideshow_item_add(ss->slideshow, &_item_cls, itr);
|
slideshow_item = elm_slideshow_item_add(ss->slideshow, &_item_cls, itr);
|
||||||
if (itr == entry) elm_slideshow_item_show(slideshow_item);
|
if (itr == entry) elm_slideshow_item_show(slideshow_item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,11 @@ struct _Ephoto_Thumb_Browser
|
||||||
{
|
{
|
||||||
Ephoto *ephoto;
|
Ephoto *ephoto;
|
||||||
Evas_Object *main;
|
Evas_Object *main;
|
||||||
|
Evas_Object *table;
|
||||||
Evas_Object *bar;
|
Evas_Object *bar;
|
||||||
Evas_Object *edje;
|
|
||||||
Evas_Object *entry;
|
Evas_Object *entry;
|
||||||
Evas_Object *grid;
|
Evas_Object *grid;
|
||||||
|
Evas_Object *panel;
|
||||||
Eio_File *ls;
|
Eio_File *ls;
|
||||||
Eina_List *todo_items;
|
Eina_List *todo_items;
|
||||||
Eina_List *grid_items;
|
Eina_List *grid_items;
|
||||||
|
@ -48,16 +49,6 @@ _grid_items_free(Ephoto_Thumb_Browser *tb)
|
||||||
tb->grid_items = NULL;
|
tb->grid_items = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Ephoto_Entry *
|
|
||||||
_first_file_entry_find(Ephoto_Thumb_Browser *tb)
|
|
||||||
{
|
|
||||||
const Eina_List *l;
|
|
||||||
Ephoto_Entry *entry;
|
|
||||||
EINA_LIST_FOREACH(tb->ephoto->entries, l, entry)
|
|
||||||
if (!entry->is_dir) return entry;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_ephoto_thumb_item_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
|
_ephoto_thumb_item_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
|
||||||
{
|
{
|
||||||
|
@ -65,30 +56,6 @@ _ephoto_thumb_item_text_get(void *data, Evas_Object *obj __UNUSED__, const char
|
||||||
return strdup(e->label);
|
return strdup(e->label);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_ephoto_thumb_up_icon_get(void *data __UNUSED__, Evas_Object *obj, const char *part __UNUSED__)
|
|
||||||
{
|
|
||||||
Evas_Object *ic;
|
|
||||||
|
|
||||||
ic = elm_icon_add(obj);
|
|
||||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
||||||
elm_icon_standard_set(ic, "go-up");
|
|
||||||
|
|
||||||
return ic;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_ephoto_thumb_dir_icon_get(void *data __UNUSED__, Evas_Object *obj, const char *part __UNUSED__)
|
|
||||||
{
|
|
||||||
Evas_Object *ic;
|
|
||||||
|
|
||||||
ic = elm_icon_add(obj);
|
|
||||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
||||||
elm_icon_standard_set(ic, "folder");
|
|
||||||
|
|
||||||
return ic;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_ephoto_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part __UNUSED__)
|
_ephoto_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part __UNUSED__)
|
||||||
{
|
{
|
||||||
|
@ -107,65 +74,17 @@ _ephoto_thumb_item_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static Elm_Gengrid_Item_Class _ephoto_thumb_up_class;
|
|
||||||
static Elm_Gengrid_Item_Class _ephoto_thumb_dir_class;
|
|
||||||
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_Object_Item *ia = pa;
|
|
||||||
const Ephoto_Entry *a, *b = pb;
|
|
||||||
|
|
||||||
a = elm_object_item_data_get(ia);
|
|
||||||
|
|
||||||
if (a->is_dir == b->is_dir)
|
|
||||||
return strcoll(a->basename, b->basename);
|
|
||||||
else if (a->is_dir)
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
ic = &_ephoto_thumb_file_class;
|
||||||
(tb->grid_items, _entry_cmp, e, &near_cmp);
|
|
||||||
|
|
||||||
if (near_node)
|
|
||||||
near_item = near_node->data;
|
|
||||||
|
|
||||||
if (e->is_dir) ic = &_ephoto_thumb_dir_class;
|
|
||||||
else ic = &_ephoto_thumb_file_class;
|
|
||||||
|
|
||||||
if (!near_item)
|
|
||||||
{
|
|
||||||
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
|
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
|
||||||
tb->grid_items = eina_list_append(tb->grid_items, e->item);
|
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);
|
||||||
|
@ -177,27 +96,6 @@ _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_up_item_add_if_required(Ephoto_Thumb_Browser *tb)
|
|
||||||
{
|
|
||||||
Ephoto_Entry *entry;
|
|
||||||
char *parent_dir;
|
|
||||||
|
|
||||||
if ((strcmp(tb->ephoto->config->directory, "/") == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
parent_dir = ecore_file_dir_get(tb->ephoto->config->directory);
|
|
||||||
if (!parent_dir) return;
|
|
||||||
|
|
||||||
entry = ephoto_entry_new(tb->ephoto, parent_dir, PARENT_DIR);
|
|
||||||
free(parent_dir);
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
|
||||||
entry->is_up = EINA_TRUE;
|
|
||||||
entry->is_dir = EINA_TRUE;
|
|
||||||
entry->item = elm_gengrid_item_append
|
|
||||||
(tb->grid, &_ephoto_thumb_up_class, entry, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_todo_items_process(void *data)
|
_todo_items_process(void *data)
|
||||||
{
|
{
|
||||||
|
@ -224,9 +122,6 @@ _ephoto_thumb_selected(void *data, Evas_Object *o __UNUSED__, void *event_info)
|
||||||
|
|
||||||
elm_gengrid_item_selected_set(it, EINA_FALSE);
|
elm_gengrid_item_selected_set(it, EINA_FALSE);
|
||||||
|
|
||||||
if (e->is_dir)
|
|
||||||
ephoto_directory_set(tb->ephoto, e->path);
|
|
||||||
else
|
|
||||||
evas_object_smart_callback_call(tb->main, "view", e);
|
evas_object_smart_callback_call(tb->main, "view", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,12 +187,9 @@ _view_single(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
||||||
Ephoto_Entry *entry;
|
Ephoto_Entry *entry;
|
||||||
|
|
||||||
if (it) entry = elm_object_item_data_get(it);
|
if (it) entry = elm_object_item_data_get(it);
|
||||||
else entry = _first_file_entry_find(tb);
|
else entry = eina_list_nth(tb->ephoto->entries, 0);
|
||||||
|
|
||||||
if (!entry) return;
|
if (!entry) return;
|
||||||
if (entry->is_dir)
|
|
||||||
ephoto_directory_set(tb->ephoto, entry->path);
|
|
||||||
else
|
|
||||||
evas_object_smart_callback_call(tb->main, "view", entry);
|
evas_object_smart_callback_call(tb->main, "view", entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +201,7 @@ _slideshow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
|
||||||
Ephoto_Entry *entry;
|
Ephoto_Entry *entry;
|
||||||
|
|
||||||
if (it) entry = elm_object_item_data_get(it);
|
if (it) entry = elm_object_item_data_get(it);
|
||||||
else entry = _first_file_entry_find(tb);
|
else entry = eina_list_nth(tb->ephoto->entries, 0);
|
||||||
|
|
||||||
if (!entry) return;
|
if (!entry) return;
|
||||||
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
||||||
|
@ -345,7 +237,7 @@ _key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event
|
||||||
Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
Elm_Object_Item *it = elm_gengrid_selected_item_get(tb->grid);
|
||||||
Ephoto_Entry *entry;
|
Ephoto_Entry *entry;
|
||||||
if (it) entry = elm_object_item_data_get(it);
|
if (it) entry = elm_object_item_data_get(it);
|
||||||
else entry = _first_file_entry_find(tb);
|
else entry = eina_list_nth(tb->grid_items, 0);
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
evas_object_smart_callback_call(tb->main, "slideshow", entry);
|
||||||
|
@ -389,7 +281,6 @@ _ephoto_thumb_populate_start(void *data, int type __UNUSED__, void *event __UNUS
|
||||||
_grid_items_free(tb);
|
_grid_items_free(tb);
|
||||||
elm_gengrid_clear(tb->grid);
|
elm_gengrid_clear(tb->grid);
|
||||||
elm_fileselector_path_set(tb->entry, tb->ephoto->config->directory);
|
elm_fileselector_path_set(tb->entry, tb->ephoto->config->directory);
|
||||||
_up_item_add_if_required(tb);
|
|
||||||
|
|
||||||
return ECORE_CALLBACK_PASS_ON;
|
return ECORE_CALLBACK_PASS_ON;
|
||||||
}
|
}
|
||||||
|
@ -434,28 +325,16 @@ _ephoto_thumb_entry_create(void *data, int type __UNUSED__, void *event)
|
||||||
Evas_Object *
|
Evas_Object *
|
||||||
ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
||||||
{
|
{
|
||||||
Evas_Object *layout = elm_layout_add(parent);
|
Evas_Object *box = elm_box_add(parent);
|
||||||
Elm_Object_Item *icon;
|
Elm_Object_Item *icon;
|
||||||
Evas_Object *min, *max, *ic;
|
Evas_Object *min, *max, *ic;
|
||||||
Ephoto_Thumb_Browser *tb;
|
Ephoto_Thumb_Browser *tb;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(layout, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(box, NULL);
|
||||||
|
|
||||||
tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
|
tb = calloc(1, sizeof(Ephoto_Thumb_Browser));
|
||||||
EINA_SAFETY_ON_NULL_GOTO(tb, error);
|
EINA_SAFETY_ON_NULL_GOTO(tb, error);
|
||||||
|
|
||||||
_ephoto_thumb_up_class.item_style = "default";
|
|
||||||
_ephoto_thumb_up_class.func.text_get = _ephoto_thumb_item_text_get;
|
|
||||||
_ephoto_thumb_up_class.func.content_get = _ephoto_thumb_up_icon_get;
|
|
||||||
_ephoto_thumb_up_class.func.state_get = NULL;
|
|
||||||
_ephoto_thumb_up_class.func.del = _ephoto_thumb_item_del;
|
|
||||||
|
|
||||||
_ephoto_thumb_dir_class.item_style = "default";
|
|
||||||
_ephoto_thumb_dir_class.func.text_get = _ephoto_thumb_item_text_get;
|
|
||||||
_ephoto_thumb_dir_class.func.content_get = _ephoto_thumb_dir_icon_get;
|
|
||||||
_ephoto_thumb_dir_class.func.state_get = NULL;
|
|
||||||
_ephoto_thumb_dir_class.func.del = _ephoto_thumb_item_del;
|
|
||||||
|
|
||||||
_ephoto_thumb_file_class.item_style = "thumb";
|
_ephoto_thumb_file_class.item_style = "thumb";
|
||||||
_ephoto_thumb_file_class.func.text_get = _ephoto_thumb_item_text_get;
|
_ephoto_thumb_file_class.func.text_get = _ephoto_thumb_item_text_get;
|
||||||
_ephoto_thumb_file_class.func.content_get = _ephoto_thumb_file_icon_get;
|
_ephoto_thumb_file_class.func.content_get = _ephoto_thumb_file_icon_get;
|
||||||
|
@ -465,40 +344,15 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
||||||
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
|
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
|
||||||
|
|
||||||
tb->ephoto = ephoto;
|
tb->ephoto = ephoto;
|
||||||
tb->edje = elm_layout_edje_get(layout);
|
tb->main = box;
|
||||||
tb->main = layout;
|
|
||||||
|
|
||||||
|
evas_object_size_hint_weight_set(tb->main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(tb->main, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
evas_object_event_callback_add(tb->main, EVAS_CALLBACK_DEL, _main_del, tb);
|
evas_object_event_callback_add(tb->main, EVAS_CALLBACK_DEL, _main_del, tb);
|
||||||
evas_object_event_callback_add
|
evas_object_event_callback_add
|
||||||
(tb->main, EVAS_CALLBACK_KEY_DOWN, _key_down, tb);
|
(tb->main, EVAS_CALLBACK_KEY_DOWN, _key_down, tb);
|
||||||
evas_object_data_set(tb->main, "thumb_browser", tb);
|
evas_object_data_set(tb->main, "thumb_browser", tb);
|
||||||
|
|
||||||
if (!elm_layout_theme_set(tb->main, "layout", "application", "toolbar-vbox"))
|
|
||||||
{
|
|
||||||
ERR("Could not load style 'toolbar-vbox' from theme!");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
tb->bar = edje_object_part_external_object_get(tb->edje, "elm.external.toolbar");
|
|
||||||
if (!tb->bar)
|
|
||||||
{
|
|
||||||
ERR("Could not find toolbar in layout!");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
elm_toolbar_homogeneous_set(tb->bar, EINA_FALSE);
|
|
||||||
elm_toolbar_shrink_mode_set(tb->bar, ELM_TOOLBAR_SHRINK_MENU);
|
|
||||||
elm_toolbar_menu_parent_set(tb->bar, parent);
|
|
||||||
elm_toolbar_select_mode_set(tb->bar, ELM_OBJECT_SELECT_MODE_NONE);
|
|
||||||
|
|
||||||
elm_toolbar_item_append(tb->bar, "image", "View Single", _view_single, tb);
|
|
||||||
elm_toolbar_item_append(tb->bar, "media-playback-start", "Slideshow", _slideshow, tb);
|
|
||||||
icon = elm_toolbar_item_append(tb->bar, "zoom-in", "Zoom In", _zoom_in, tb);
|
|
||||||
max = elm_object_item_widget_get(icon);
|
|
||||||
icon = elm_toolbar_item_append(tb->bar, "zoom-out", "Zoom Out", _zoom_out, tb);
|
|
||||||
min = elm_object_item_widget_get(icon);
|
|
||||||
evas_object_data_set(max, "min", min);
|
|
||||||
evas_object_data_set(min, "max", max);
|
|
||||||
|
|
||||||
ic = elm_icon_add(tb->main);
|
ic = elm_icon_add(tb->main);
|
||||||
elm_icon_standard_set(ic, "folder");
|
elm_icon_standard_set(ic, "folder");
|
||||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||||
|
@ -516,10 +370,16 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
||||||
(tb->entry, "file,chosen", _changed_dir, tb);
|
(tb->entry, "file,chosen", _changed_dir, tb);
|
||||||
evas_object_smart_callback_add
|
evas_object_smart_callback_add
|
||||||
(tb->entry, "activated", _changed_dir_text, tb);
|
(tb->entry, "activated", _changed_dir_text, tb);
|
||||||
|
elm_box_pack_end(tb->main, tb->entry);
|
||||||
evas_object_show(tb->entry);
|
evas_object_show(tb->entry);
|
||||||
elm_layout_box_append(tb->main, "elm.box.content", tb->entry);
|
|
||||||
|
|
||||||
tb->grid = elm_gengrid_add(tb->main);
|
tb->table = elm_table_add(tb->main);
|
||||||
|
evas_object_size_hint_weight_set(tb->table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(tb->table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
elm_box_pack_end(tb->main, tb->table);
|
||||||
|
evas_object_show(tb->table);
|
||||||
|
|
||||||
|
tb->grid = elm_gengrid_add(tb->table);
|
||||||
EINA_SAFETY_ON_NULL_GOTO(tb->grid, error);
|
EINA_SAFETY_ON_NULL_GOTO(tb->grid, error);
|
||||||
evas_object_size_hint_weight_set
|
evas_object_size_hint_weight_set
|
||||||
(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
@ -538,7 +398,36 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
|
||||||
_zoom_set(tb, tb->ephoto->config->thumb_size);
|
_zoom_set(tb, tb->ephoto->config->thumb_size);
|
||||||
|
|
||||||
evas_object_show(tb->grid);
|
evas_object_show(tb->grid);
|
||||||
elm_layout_box_append(tb->main, "elm.box.content", tb->grid);
|
elm_table_pack(tb->table, tb->grid, 0, 0, 4, 1);
|
||||||
|
|
||||||
|
tb->panel = elm_panel_add(tb->table);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(tb->panel, error);
|
||||||
|
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_table_pack(tb->table, tb->panel, 0, 0, 1, 1);
|
||||||
|
evas_object_show(tb->panel);
|
||||||
|
|
||||||
|
tb->bar = elm_toolbar_add(tb->panel);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(tb->bar, error);
|
||||||
|
elm_toolbar_horizontal_set(tb->bar, EINA_FALSE);
|
||||||
|
elm_toolbar_shrink_mode_set(tb->bar, ELM_TOOLBAR_SHRINK_SCROLL);
|
||||||
|
elm_toolbar_select_mode_set(tb->bar, ELM_OBJECT_SELECT_MODE_NONE);
|
||||||
|
evas_object_size_hint_weight_set(tb->bar, 0.0, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(tb->bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
|
||||||
|
elm_toolbar_item_append(tb->bar, "image", "View Single", _view_single, tb);
|
||||||
|
elm_toolbar_item_append(tb->bar, "media-playback-start", "Slideshow", _slideshow, tb);
|
||||||
|
icon = elm_toolbar_item_append(tb->bar, "zoom-in", "Zoom In", _zoom_in, tb);
|
||||||
|
max = elm_object_item_widget_get(icon);
|
||||||
|
icon = elm_toolbar_item_append(tb->bar, "zoom-out", "Zoom Out", _zoom_out, tb);
|
||||||
|
min = elm_object_item_widget_get(icon);
|
||||||
|
evas_object_data_set(max, "min", min);
|
||||||
|
evas_object_data_set(min, "max", max);
|
||||||
|
|
||||||
|
elm_object_content_set(tb->panel, tb->bar);
|
||||||
|
evas_object_show(tb->bar);
|
||||||
|
|
||||||
tb->handlers = eina_list_append
|
tb->handlers = eina_list_append
|
||||||
(tb->handlers, ecore_event_handler_add
|
(tb->handlers, ecore_event_handler_add
|
||||||
|
|
Loading…
Reference in New Issue