Ephoto: If multiple items are selected, only use those items for Single and Slideshow.

This commit is contained in:
Stephen Houston 2015-12-02 20:45:35 -06:00
parent b1fc28d881
commit aee6e9e408
5 changed files with 81 additions and 8 deletions

View File

@ -61,6 +61,7 @@ void ephoto_config_slideshow(Ephoto *em);
void ephoto_config_about(Ephoto *em); void ephoto_config_about(Ephoto *em);
Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent); Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent);
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_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
void ephoto_single_browser_path_pending_set(Evas_Object *obj, void ephoto_single_browser_path_pending_set(Evas_Object *obj,
const char *path); const char *path);
@ -72,6 +73,7 @@ void ephoto_single_browser_cancel_editing(Evas_Object *main,
/* smart callbacks called: "back" - the user wants to go back to the previous /* smart callbacks called: "back" - the user wants to go back to the previous
* screen. */ * screen. */
Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent); Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent);
void ephoto_slideshow_entries_set(Evas_Object *obj, Eina_List *entries);
void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry); void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
/* smart callbacks called: "back" - the user wants to go back to the previous /* smart callbacks called: "back" - the user wants to go back to the previous
@ -163,6 +165,7 @@ struct _Ephoto
Eina_List *entries; Eina_List *entries;
Eina_List *direntries; Eina_List *direntries;
Eina_List *selentries;
Eina_List *thumbs; Eina_List *thumbs;
int thumb_gen_size; int thumb_gen_size;

View File

@ -39,12 +39,19 @@ _ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
ephoto_title_set(ephoto, ephoto->config->directory); ephoto_title_set(ephoto, ephoto->config->directory);
if ((entry) && (entry->item)) if ((entry) && (entry->item))
elm_gengrid_item_bring_in(entry->item, ELM_GENGRID_ITEM_SCROLLTO_IN); {
elm_gengrid_item_selected_set(entry->item, EINA_TRUE);
elm_gengrid_item_bring_in(entry->item, ELM_GENGRID_ITEM_SCROLLTO_IN);
}
} }
static void static void
_ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry) _ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
{ {
if (ephoto->selentries)
ephoto_single_browser_entries_set(ephoto->single_browser, ephoto->selentries);
else
ephoto_single_browser_entries_set(ephoto->single_browser, ephoto->entries);
ephoto_single_browser_entry_set(ephoto->single_browser, entry); ephoto_single_browser_entry_set(ephoto->single_browser, entry);
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->single_browser); elm_naviframe_item_simple_promote(ephoto->pager, ephoto->single_browser);
elm_object_focus_set(ephoto->single_browser, EINA_TRUE); elm_object_focus_set(ephoto->single_browser, EINA_TRUE);
@ -54,6 +61,10 @@ _ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
static void static void
_ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry) _ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry)
{ {
if (ephoto->selentries)
ephoto_slideshow_entries_set(ephoto->slideshow, ephoto->selentries);
else
ephoto_slideshow_entries_set(ephoto->slideshow, ephoto->entries);
ephoto_slideshow_entry_set(ephoto->slideshow, entry); ephoto_slideshow_entry_set(ephoto->slideshow, entry);
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->slideshow); elm_naviframe_item_simple_promote(ephoto->pager, ephoto->slideshow);
elm_object_focus_set(ephoto->slideshow, EINA_TRUE); elm_object_focus_set(ephoto->slideshow, EINA_TRUE);
@ -67,6 +78,7 @@ _ephoto_single_browser_back(void *data, Evas_Object *obj EINA_UNUSED,
Ephoto *ephoto = data; Ephoto *ephoto = data;
Ephoto_Entry *entry = event_info; Ephoto_Entry *entry = event_info;
ephoto->selentries = NULL;
_ephoto_thumb_browser_show(ephoto, entry); _ephoto_thumb_browser_show(ephoto, entry);
} }
@ -84,10 +96,12 @@ _ephoto_slideshow_back(void *data, Evas_Object *obj EINA_UNUSED,
break; break;
case EPHOTO_STATE_THUMB: case EPHOTO_STATE_THUMB:
ephoto->selentries = NULL;
_ephoto_thumb_browser_show(ephoto, entry); _ephoto_thumb_browser_show(ephoto, entry);
break; break;
default: default:
ephoto->selentries = NULL;
_ephoto_thumb_browser_show(ephoto, entry); _ephoto_thumb_browser_show(ephoto, entry);
} }
} }
@ -108,6 +122,7 @@ _ephoto_thumb_browser_changed_directory(void *data,
{ {
Ephoto *ephoto = data; Ephoto *ephoto = data;
ephoto->selentries = NULL;
ephoto_single_browser_entry_set(ephoto->single_browser, NULL); ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
ephoto_slideshow_entry_set(ephoto->slideshow, NULL); ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
} }
@ -172,6 +187,7 @@ ephoto_window_add(const char *path)
EPHOTO_EVENT_POPULATE_END = ecore_event_type_new(); EPHOTO_EVENT_POPULATE_END = ecore_event_type_new();
EPHOTO_EVENT_POPULATE_ERROR = ecore_event_type_new(); EPHOTO_EVENT_POPULATE_ERROR = ecore_event_type_new();
ephoto->selentries = NULL;
ephoto->win = elm_win_util_standard_add("ephoto", "Ephoto"); ephoto->win = elm_win_util_standard_add("ephoto", "Ephoto");
if (!ephoto->win) if (!ephoto->win)
{ {
@ -642,6 +658,11 @@ ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry)
{ {
node = eina_list_data_find_list(ephoto->entries, entry); node = eina_list_data_find_list(ephoto->entries, entry);
ephoto->entries = eina_list_remove_list(ephoto->entries, node); ephoto->entries = eina_list_remove_list(ephoto->entries, node);
if (ephoto->selentries)
{
node = eina_list_data_find_list(ephoto->selentries, entry);
ephoto->selentries = eina_list_remove_list(ephoto->selentries, node);
}
} }
eina_stringshare_del(entry->path); eina_stringshare_del(entry->path);
eina_stringshare_del(entry->label); eina_stringshare_del(entry->label);

View File

@ -25,6 +25,7 @@ struct _Ephoto_Single_Browser
Ephoto_Orient orient; Ephoto_Orient orient;
Eina_List *handlers; Eina_List *handlers;
Eina_List *upload_handlers; Eina_List *upload_handlers;
Eina_List *entries;
Eina_Bool editing:1; Eina_Bool editing:1;
Eina_Bool cropping:1; Eina_Bool cropping:1;
unsigned int *edited_image_data; unsigned int *edited_image_data;
@ -598,13 +599,13 @@ _mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
static Ephoto_Entry * static Ephoto_Entry *
_first_entry_find(Ephoto_Single_Browser *sb) _first_entry_find(Ephoto_Single_Browser *sb)
{ {
return eina_list_nth(sb->ephoto->entries, 0); return eina_list_nth(sb->entries, 0);
} }
static Ephoto_Entry * static Ephoto_Entry *
_last_entry_find(Ephoto_Single_Browser *sb) _last_entry_find(Ephoto_Single_Browser *sb)
{ {
return eina_list_last_data_get(sb->ephoto->entries); return eina_list_last_data_get(sb->entries);
} }
static char * static char *
@ -819,7 +820,7 @@ _next_entry(Ephoto_Single_Browser *sb)
Ephoto_Entry *entry = NULL; Ephoto_Entry *entry = NULL;
Eina_List *node; Eina_List *node;
node = eina_list_data_find_list(sb->ephoto->entries, sb->entry); node = eina_list_data_find_list(sb->entries, sb->entry);
if (!node) if (!node)
return; return;
if ((node = node->next)) if ((node = node->next))
@ -837,7 +838,7 @@ _prev_entry(Ephoto_Single_Browser *sb)
{ {
Eina_List *node; Eina_List *node;
Ephoto_Entry *entry = NULL; Ephoto_Entry *entry = NULL;
node = eina_list_data_find_list(sb->ephoto->entries, sb->entry); node = eina_list_data_find_list(sb->entries, sb->entry);
if (!node) if (!node)
return; return;
if ((node = node->prev)) if ((node = node->prev))
@ -2429,7 +2430,7 @@ _entry_free(void *data, const Ephoto_Entry *entry)
if (entry == sb->entry) if (entry == sb->entry)
{ {
elm_object_item_del(entry->item); elm_object_item_del(entry->item);
if (eina_list_count(sb->ephoto->entries) <= 1) if (eina_list_count(sb->entries) <= 1)
evas_object_smart_callback_call(sb->main, "back", NULL); evas_object_smart_callback_call(sb->main, "back", NULL);
else else
_next_entry(sb); _next_entry(sb);
@ -2681,6 +2682,15 @@ ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent)
return NULL; return NULL;
} }
void
ephoto_single_browser_entries_set(Evas_Object *obj, Eina_List *entries)
{
Ephoto_Single_Browser *sb = evas_object_data_get(obj, "single_browser");
if (entries)
sb->entries = entries;
}
void void
ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry) ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
{ {

View File

@ -9,6 +9,7 @@ struct _Ephoto_Slideshow
Evas_Object *notify; Evas_Object *notify;
Evas_Object *bar; Evas_Object *bar;
Evas_Object *event; Evas_Object *event;
Eina_List *entries;
Elm_Object_Item *pause; Elm_Object_Item *pause;
Elm_Object_Item *pause_after; Elm_Object_Item *pause_after;
Elm_Object_Item *fullscreen; Elm_Object_Item *fullscreen;
@ -478,6 +479,15 @@ _slideshow_item_get(void *data, Evas_Object *obj)
static const Elm_Slideshow_Item_Class _item_cls = static const Elm_Slideshow_Item_Class _item_cls =
{ {_slideshow_item_get, NULL} }; { {_slideshow_item_get, NULL} };
void
ephoto_slideshow_entries_set(Evas_Object *obj, Eina_List *entries)
{
Ephoto_Slideshow *ss = evas_object_data_get(obj, "slideshow");
if (entries)
ss->entries = entries;
}
void void
ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry) ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
{ {
@ -529,7 +539,7 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
} }
} }
EINA_LIST_FOREACH(ss->ephoto->entries, l, itr) EINA_LIST_FOREACH(ss->entries, l, itr)
{ {
Elm_Object_Item *slideshow_item; Elm_Object_Item *slideshow_item;

View File

@ -572,9 +572,24 @@ _ephoto_thumb_activated(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info) void *event_info)
{ {
Ephoto_Thumb_Browser *tb = data; Ephoto_Thumb_Browser *tb = data;
Eina_List *selected, *s;
Elm_Object_Item *item;
Elm_Object_Item *it = event_info; Elm_Object_Item *it = event_info;
Ephoto_Entry *e = elm_object_item_data_get(it); Ephoto_Entry *e = elm_object_item_data_get(it);
elm_gengrid_item_selected_set(it, EINA_TRUE);
selected =
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
if (eina_list_count(selected) <= 1)
tb->ephoto->selentries = NULL;
else
{
EINA_LIST_FOREACH(selected, s, item)
{
tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
elm_object_item_data_get(item));
}
}
evas_object_smart_callback_call(tb->main, "view", e); evas_object_smart_callback_call(tb->main, "view", e);
} }
@ -625,6 +640,8 @@ _slideshow(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED) void *event_info EINA_UNUSED)
{ {
Ephoto_Thumb_Browser *tb = data; Ephoto_Thumb_Browser *tb = data;
Eina_List *selected, *s;
Elm_Object_Item *item;
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;
@ -635,6 +652,18 @@ _slideshow(void *data, Evas_Object *obj EINA_UNUSED,
if (!entry) if (!entry)
return; return;
selected =
eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
if (eina_list_count(selected) <= 1)
tb->ephoto->selentries = NULL;
else
{
EINA_LIST_FOREACH(selected, s, item)
{
tb->ephoto->selentries = eina_list_append(tb->ephoto->selentries,
elm_object_item_data_get(item));
}
}
evas_object_smart_callback_call(tb->main, "slideshow", entry); evas_object_smart_callback_call(tb->main, "slideshow", entry);
} }
@ -3450,7 +3479,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
elm_gengrid_align_set(tb->grid, 0.5, 0.0); elm_gengrid_align_set(tb->grid, 0.5, 0.0);
elm_gengrid_multi_select_set(tb->grid, EINA_TRUE); elm_gengrid_multi_select_set(tb->grid, EINA_TRUE);
elm_gengrid_multi_select_mode_set(tb->grid, elm_gengrid_multi_select_mode_set(tb->grid,
ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL); ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT);
elm_scroller_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE); elm_scroller_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE);
evas_object_smart_callback_add(tb->grid, "activated", evas_object_smart_callback_add(tb->grid, "activated",
_ephoto_thumb_activated, tb); _ephoto_thumb_activated, tb);