# Copyright (C) 2007-2013 various contributors (see AUTHORS)
#
# This file is part of Python-EFL.
#
# Python-EFL is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# Python-EFL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this Python-EFL. If not, see .
"""
Store Elementary Store
Store is an abstracting API that is intended to farm off fetching of data
to threads running asynchronously from the mainloop that actually fetch
data needed for a genlist (or possibly future other widgets) so scrolling
never blocks waiting on IO (though normally this should be the users
job - if using genlist, to ensure all data genlist needs is in memory at
the time it needs it, and if it isn't to queue and defer a fetch and let
genlist know later when its ready. Store actually does this and implements
the infrastructure of this, leaving the actual fetch and convert up to
functions provided by the user).
It is possible for store to run inline without a thread, but this is
highly inadvisable. you can disable this with::
st.fetch_thread = False
Store works first by creating a store, setting up functions to list items
and fetch items. Currently the only store type supported is the
filesystem store, which will list the files inside a directory (not
recursively) and then hand each file it finds (the file path) to the
list function for evaluation.
The list function may look at filename, may open the file or do
anything it likes to determine something about the file. Either it
filters it out (returns EINA_FALSE) and it is discarded or it
returns EINA_TRUE and also provides a "sort id" which is a string
store uses to figure out sorting. This string could be the filename, or
some data based on its contents. The strings are sorted alphabetically
like any normal ASCII strings, with case being important. As this listing
function runs in a thread, it can do blocking IO and parsing without
hurting the fluidity of the main loop and GUI. The list function also
returns information on how to map fields in the source file to elements
of the genlist item. For example, how the fetcher reads the private
data struct of the user (what memory offset in the struct the data is at)
and what type is there (it's a label of some sort, an icon, or with a
custom mapping function that figures it out itself and creates the
content needed for the genlist item).
Store then uses this sort id to build (over time) a sorted list of items
that then map 1:1 to genlist items. When these items are visible and
need content, Store calls the fetch function per item, which is responsible
for fetching the data from the given item and returning data to store
so it can map this to some item content. This function also runs in a
thread, and thus can do blocking IO work to later return the data. Sorting
is optional and can be enabled or disabled too.
When items are no longer needed, store will cal the unfetch function to
free data in memory about that item that is no longer needed. This function
is called in the mainloop and is expected to take minimal or almost no time
to simply free up memory resources.
Enumerations
------------
.. _Elm_Store_Item_Mapping_Type:
.. rubric:: Store item mapping types
.. data:: ELM_STORE_ITEM_MAPPING_NONE
None
.. data:: ELM_STORE_ITEM_MAPPING_LABEL
const_char * -> label
.. data:: ELM_STORE_ITEM_MAPPING_STATE
Eina_Bool -> state
.. data:: ELM_STORE_ITEM_MAPPING_ICON
char * -> icon path
.. data:: ELM_STORE_ITEM_MAPPING_PHOTO
char * -> photo path
.. data:: ELM_STORE_ITEM_MAPPING_CUSTOM
item->custom(it->data, it, part) -> void * (-> any)
"""
from libc.string cimport strdup
from cpython cimport Py_INCREF, Py_DECREF
from efl.eo cimport _ctouni, _touni
from object cimport Object
from object_item cimport _object_item_to_python
from genlist cimport GenlistItemClass
import traceback
PyEval_InitThreads()
cdef Eina_Bool store_fs_item_list_cb(void *data, Elm_Store_Item_Info *info) with gil:
"""Function to call for listing an item (filesystem)"""
cdef StoreItemInfoFilesystem ifs = StoreItemInfoFilesystem.__new__(StoreItemInfoFilesystem)
ifs.info_fs = info
func, args, kwargs =