Python-EFL: Fileselector 1,9 API additions.
* added property thumbnail_size * added function custom_filter_append * splitted the 3 tests in 3 different files * test rewritten to better match the C one. NOTE: custom_filter_append is leaking...need to find a proper way to unref Added a note in the TODO for this issue.
This commit is contained in:
parent
b32f95e3c4
commit
684aee077e
2
TODO
2
TODO
|
@ -3,6 +3,8 @@ BUGS
|
||||||
====
|
====
|
||||||
* EdjeEdit: PartState API does not work
|
* EdjeEdit: PartState API does not work
|
||||||
* Elm.Map: overlays_show segfaults, scrollers in examples are jumpy
|
* Elm.Map: overlays_show segfaults, scrollers in examples are jumpy
|
||||||
|
* Entry.markup_filter_append() and Fileselector.custom_filter_append() are
|
||||||
|
leaking badly, fix and check all other place that have the same issue.
|
||||||
|
|
||||||
Failing unit tests
|
Failing unit tests
|
||||||
------------------
|
------------------
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from efl.eina cimport Eina_Bool, const_Eina_List
|
from efl.eina cimport Eina_Bool, const_Eina_List
|
||||||
from efl.evas cimport Evas_Object, const_Evas_Object
|
from efl.evas cimport Evas_Object, const_Evas_Object, Evas_Coord
|
||||||
from enums cimport Elm_Fileselector_Mode, Elm_Fileselector_Sort
|
from enums cimport Elm_Fileselector_Mode, Elm_Fileselector_Sort
|
||||||
from libc.string cimport const_char
|
from libc.string cimport const_char
|
||||||
|
|
||||||
cdef extern from "Elementary.h":
|
cdef extern from "Elementary.h":
|
||||||
|
ctypedef Eina_Bool (*Elm_Fileselector_Filter_Func)(const_char *path, Eina_Bool dir, void *data)
|
||||||
|
|
||||||
Evas_Object * elm_fileselector_add(Evas_Object *parent)
|
Evas_Object * elm_fileselector_add(Evas_Object *parent)
|
||||||
void elm_fileselector_is_save_set(Evas_Object *obj, Eina_Bool is_save)
|
void elm_fileselector_is_save_set(Evas_Object *obj, Eina_Bool is_save)
|
||||||
Eina_Bool elm_fileselector_is_save_get(const_Evas_Object *obj)
|
Eina_Bool elm_fileselector_is_save_get(const_Evas_Object *obj)
|
||||||
|
@ -23,8 +25,11 @@ cdef extern from "Elementary.h":
|
||||||
const_char * elm_fileselector_selected_get(const_Evas_Object *obj)
|
const_char * elm_fileselector_selected_get(const_Evas_Object *obj)
|
||||||
const_Eina_List * elm_fileselector_selected_paths_get(const_Evas_Object *obj)
|
const_Eina_List * elm_fileselector_selected_paths_get(const_Evas_Object *obj)
|
||||||
Eina_Bool elm_fileselector_mime_types_filter_append(Evas_Object *obj, const_char *mime_types, const_char *filter_name)
|
Eina_Bool elm_fileselector_mime_types_filter_append(Evas_Object *obj, const_char *mime_types, const_char *filter_name)
|
||||||
|
Eina_Bool elm_fileselector_custom_filter_append(Evas_Object *obj, Elm_Fileselector_Filter_Func func, void *data, const_char *filter_name)
|
||||||
void elm_fileselector_filters_clear(Evas_Object *obj)
|
void elm_fileselector_filters_clear(Evas_Object *obj)
|
||||||
void elm_fileselector_hidden_visible_set(Evas_Object *obj, Eina_Bool visible)
|
void elm_fileselector_hidden_visible_set(Evas_Object *obj, Eina_Bool visible)
|
||||||
Eina_Bool elm_fileselector_hidden_visible_get(const_Evas_Object *obj)
|
Eina_Bool elm_fileselector_hidden_visible_get(const_Evas_Object *obj)
|
||||||
Elm_Fileselector_Sort elm_fileselector_sort_method_get(const_Evas_Object *obj)
|
Elm_Fileselector_Sort elm_fileselector_sort_method_get(const_Evas_Object *obj)
|
||||||
void elm_fileselector_sort_method_set(Evas_Object *obj, Elm_Fileselector_Sort method)
|
void elm_fileselector_sort_method_set(Evas_Object *obj, Elm_Fileselector_Sort method)
|
||||||
|
void elm_fileselector_thumbnail_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||||
|
void elm_fileselector_thumbnail_size_get(const_Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
|
||||||
|
|
|
@ -138,7 +138,7 @@ Fileselector sort method
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from cpython cimport PyUnicode_AsUTF8String
|
from cpython cimport PyUnicode_AsUTF8String, Py_INCREF
|
||||||
from libc.stdint cimport uintptr_t
|
from libc.stdint cimport uintptr_t
|
||||||
|
|
||||||
from efl.eo cimport _object_mapping_register
|
from efl.eo cimport _object_mapping_register
|
||||||
|
@ -148,6 +148,8 @@ from layout_class cimport LayoutClass
|
||||||
|
|
||||||
cimport enums
|
cimport enums
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
ELM_FILESELECTOR_LIST = enums.ELM_FILESELECTOR_LIST
|
ELM_FILESELECTOR_LIST = enums.ELM_FILESELECTOR_LIST
|
||||||
ELM_FILESELECTOR_GRID = enums.ELM_FILESELECTOR_GRID
|
ELM_FILESELECTOR_GRID = enums.ELM_FILESELECTOR_GRID
|
||||||
|
|
||||||
|
@ -165,6 +167,15 @@ def _cb_string_conv(uintptr_t addr):
|
||||||
cdef const_char *s = <const_char *>addr
|
cdef const_char *s = <const_char *>addr
|
||||||
return _ctouni(s) if s is not NULL else None
|
return _ctouni(s) if s is not NULL else None
|
||||||
|
|
||||||
|
cdef Eina_Bool py_elm_fileselector_custom_filter_cb(const_char *path, Eina_Bool is_dir, void *data) with gil:
|
||||||
|
cb_func, cb_data = <object>data
|
||||||
|
try:
|
||||||
|
return cb_func(_ctouni(path), is_dir, cb_data)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
cdef class Fileselector(LayoutClass):
|
cdef class Fileselector(LayoutClass):
|
||||||
|
|
||||||
"""This is the class that actually implements the widget."""
|
"""This is the class that actually implements the widget."""
|
||||||
|
@ -425,6 +436,7 @@ cdef class Fileselector(LayoutClass):
|
||||||
.. note:: first added filter will be the default filter at the moment.
|
.. note:: first added filter will be the default filter at the moment.
|
||||||
|
|
||||||
:seealso: :py:func:`~efl.elementary.need.need_efreet`
|
:seealso: :py:func:`~efl.elementary.need.need_efreet`
|
||||||
|
:seealso: :py:meth:`custom_filter_append`
|
||||||
:seealso: :py:meth:`filters_clear`
|
:seealso: :py:meth:`filters_clear`
|
||||||
|
|
||||||
.. versionadded:: 1.8
|
.. versionadded:: 1.8
|
||||||
|
@ -437,6 +449,36 @@ cdef class Fileselector(LayoutClass):
|
||||||
<const_char *>filter_name if filter_name is not None else NULL):
|
<const_char *>filter_name if filter_name is not None else NULL):
|
||||||
raise RuntimeWarning
|
raise RuntimeWarning
|
||||||
|
|
||||||
|
def custom_filter_append(self, func, data=None, filter_name=None):
|
||||||
|
"""custom_filter_append(func, data=None, filter_name=None)
|
||||||
|
|
||||||
|
Append custom filter into filter list.
|
||||||
|
|
||||||
|
:param func: The function to call when manipulating files and directories.
|
||||||
|
:type func: callable
|
||||||
|
:param data: The data to be passed to the function.
|
||||||
|
:param filter_name: The name to be displayed, "custom" will be displayed if None
|
||||||
|
:type filter_name: string
|
||||||
|
|
||||||
|
.. note:: filter function signature is: func(path, is_dir, data)
|
||||||
|
.. note:: first added filter will be the default filter at the moment.
|
||||||
|
|
||||||
|
:seealso: :py:meth:`mime_types_filter_append`
|
||||||
|
:seealso: :py:meth:`filters_clear`
|
||||||
|
|
||||||
|
.. versionadded:: 1.9
|
||||||
|
|
||||||
|
"""
|
||||||
|
cb_data = (func, data)
|
||||||
|
# TODO: This is now a ref leak. It should be stored somewhere and
|
||||||
|
# deleted in the remove method.
|
||||||
|
Py_INCREF(cb_data)
|
||||||
|
|
||||||
|
if isinstance(filter_name, unicode): filter_name = PyUnicode_AsUTF8String(filter_name)
|
||||||
|
elm_fileselector_custom_filter_append(self.obj,
|
||||||
|
py_elm_fileselector_custom_filter_cb, <void *>cb_data,
|
||||||
|
<const_char *>filter_name if filter_name is not None else NULL)
|
||||||
|
|
||||||
def filters_clear(self):
|
def filters_clear(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -478,6 +520,29 @@ cdef class Fileselector(LayoutClass):
|
||||||
def hidden_visible_get(self):
|
def hidden_visible_get(self):
|
||||||
return bool(elm_fileselector_hidden_visible_get(self.obj))
|
return bool(elm_fileselector_hidden_visible_get(self.obj))
|
||||||
|
|
||||||
|
property thumbnail_size:
|
||||||
|
""" The size (in pixels) for the thumbnail images.
|
||||||
|
|
||||||
|
:type: tuple (w, h)
|
||||||
|
|
||||||
|
.. versionadded:: 1.9
|
||||||
|
|
||||||
|
"""
|
||||||
|
def __set__(self, size):
|
||||||
|
elm_fileselector_thumbnail_size_set(self.obj, size[0], size[1])
|
||||||
|
|
||||||
|
def __get__(self):
|
||||||
|
cdef Evas_Coord w, h
|
||||||
|
elm_fileselector_thumbnail_size_get(self.obj, &w, &h)
|
||||||
|
return (w, h)
|
||||||
|
|
||||||
|
def thumbnail_size_set(self, w, h):
|
||||||
|
elm_fileselector_thumbnail_size_set(self.obj, w, h)
|
||||||
|
def thumbnail_size_get(self):
|
||||||
|
cdef Evas_Coord w, h
|
||||||
|
elm_fileselector_thumbnail_size_get(self.obj, &w, &h)
|
||||||
|
return (w, h)
|
||||||
|
|
||||||
def callback_activated_add(self, func, *args, **kwargs):
|
def callback_activated_add(self, func, *args, **kwargs):
|
||||||
"""the user activated a file. This can happen by
|
"""the user activated a file. This can happen by
|
||||||
double-clicking or pressing Enter key. (**event_info** is a
|
double-clicking or pressing Enter key. (**event_info** is a
|
||||||
|
|
|
@ -186,8 +186,8 @@ items = [
|
||||||
("Day Selector", "test_dayselector", "dayselector_clicked"),
|
("Day Selector", "test_dayselector", "dayselector_clicked"),
|
||||||
("Disk Selector", "test_diskselector", "diskselector_clicked"),
|
("Disk Selector", "test_diskselector", "diskselector_clicked"),
|
||||||
("File Selector", "test_fileselector", "fileselector_clicked"),
|
("File Selector", "test_fileselector", "fileselector_clicked"),
|
||||||
("Fileselector button", "test_fileselector", "fileselector_button_clicked"),
|
("Fileselector button", "test_fileselector_button", "fileselector_button_clicked"),
|
||||||
("Fileselector entry", "test_fileselector", "fileselector_entry_clicked"),
|
("Fileselector entry", "test_fileselector_entry", "fileselector_entry_clicked"),
|
||||||
("Flip Selector", "test_flipselector", "flipselector_clicked"),
|
("Flip Selector", "test_flipselector", "flipselector_clicked"),
|
||||||
("Hoversel", "test_hoversel", "hoversel_clicked"),
|
("Hoversel", "test_hoversel", "hoversel_clicked"),
|
||||||
("Index", "test_index", "index_clicked"),
|
("Index", "test_index", "index_clicked"),
|
||||||
|
|
|
@ -6,20 +6,27 @@ import os
|
||||||
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||||
from efl import elementary
|
from efl import elementary
|
||||||
from efl.elementary.window import StandardWindow
|
from efl.elementary.window import StandardWindow
|
||||||
from efl.elementary.box import Box
|
from efl.elementary.box import Box, ELM_BOX_LAYOUT_FLOW_HORIZONTAL
|
||||||
from efl.elementary.frame import Frame
|
from efl.elementary.frame import Frame
|
||||||
from efl.elementary.label import Label
|
from efl.elementary.label import Label
|
||||||
from efl.elementary.button import Button
|
from efl.elementary.button import Button
|
||||||
from efl.elementary.check import Check
|
from efl.elementary.check import Check
|
||||||
from efl.elementary.list import List
|
from efl.elementary.hoversel import Hoversel
|
||||||
from efl.elementary.fileselector import Fileselector, ELM_FILESELECTOR_SORT_LAST
|
from efl.elementary.radio import Radio
|
||||||
from efl.elementary.fileselector_button import FileselectorButton
|
from efl.elementary.slider import Slider
|
||||||
from efl.elementary.fileselector_entry import FileselectorEntry
|
|
||||||
from efl.elementary.separator import Separator
|
from efl.elementary.separator import Separator
|
||||||
|
from efl.elementary.fileselector import Fileselector, \
|
||||||
|
ELM_FILESELECTOR_SORT_LAST, ELM_FILESELECTOR_LIST, ELM_FILESELECTOR_GRID, \
|
||||||
|
ELM_FILESELECTOR_SORT_BY_FILENAME_ASC, ELM_FILESELECTOR_SORT_BY_FILENAME_DESC, \
|
||||||
|
ELM_FILESELECTOR_SORT_BY_TYPE_ASC, ELM_FILESELECTOR_SORT_BY_TYPE_DESC, \
|
||||||
|
ELM_FILESELECTOR_SORT_BY_SIZE_ASC, ELM_FILESELECTOR_SORT_BY_SIZE_DESC, \
|
||||||
|
ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC, ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC
|
||||||
|
|
||||||
|
|
||||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||||
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||||
|
|
||||||
|
|
||||||
def fs_cb_done(fs, selected, win):
|
def fs_cb_done(fs, selected, win):
|
||||||
win.delete()
|
win.delete()
|
||||||
|
|
||||||
|
@ -46,241 +53,203 @@ def ck_cb_buttons(bt, fs):
|
||||||
print("Toggle buttons_ok_cancel")
|
print("Toggle buttons_ok_cancel")
|
||||||
fs.buttons_ok_cancel = not fs.buttons_ok_cancel
|
fs.buttons_ok_cancel = not fs.buttons_ok_cancel
|
||||||
|
|
||||||
|
def ck_cb_multi_select(bt, fs):
|
||||||
|
print("Toggle multi_select")
|
||||||
|
fs.multi_select = not fs.multi_select
|
||||||
|
|
||||||
def ck_cb_hidden(bt, fs):
|
def ck_cb_hidden(bt, fs):
|
||||||
print("Toggle hidden_visible")
|
print("Toggle hidden_visible")
|
||||||
fs.hidden_visible = not fs.hidden_visible
|
fs.hidden_visible = not fs.hidden_visible
|
||||||
|
|
||||||
def bt_cb_sel_get(bt, fs):
|
def bt_cb_sel_get(bt, fs):
|
||||||
print("Get Selected:" + fs.selected_get())
|
print("Get Selected:" + fs.selected)
|
||||||
|
|
||||||
def bt_cb_path_get(bt, fs):
|
def bt_cb_path_get(bt, fs):
|
||||||
print("Get Path:" + fs.path_get())
|
print("Get Path:" + fs.path)
|
||||||
|
|
||||||
def bt_cb_mode_cycle(bt, fs):
|
def bt_cb_paths_get(bt, fs):
|
||||||
mode = fs.mode + 1
|
print("Get Path:" + str(fs.selected_paths))
|
||||||
fs.mode_set(mode if mode < 2 else 0)
|
|
||||||
|
|
||||||
def bt_cb_sort_cycle(bt, fs):
|
def rd_cb_mode(rd, fs):
|
||||||
sort_method = fs.sort_method + 1
|
mode = rd.value
|
||||||
fs.sort_method = sort_method if sort_method < ELM_FILESELECTOR_SORT_LAST else 0
|
fs.mode_set(mode)
|
||||||
|
|
||||||
|
def sl_cb_thumb_size(sl, fs):
|
||||||
|
val = int(sl.value)
|
||||||
|
fs.thumbnail_size = (val, val)
|
||||||
|
|
||||||
|
def hs_cb_sort_method(hs, item, fs, method):
|
||||||
|
fs.sort_method = method
|
||||||
|
|
||||||
|
def custom_filter_all(path, is_dir, data):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def custom_filter_edje(path, is_dir, data):
|
||||||
|
if is_dir or path.endswith(".edc") or path.endswith(".edj"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def fileselector_clicked(obj, item=None):
|
def fileselector_clicked(obj, item=None):
|
||||||
win = StandardWindow("fileselector", "File selector test", autodel=True,
|
win = StandardWindow("fileselector", "File selector test",
|
||||||
size=(240,350))
|
autodel=True, size=(500,500))
|
||||||
|
|
||||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||||
win.resize_object_add(vbox)
|
win.resize_object_add(box1)
|
||||||
vbox.show()
|
box1.show()
|
||||||
|
|
||||||
fs = Fileselector(win, is_save=True, expandable=True, folder_only=True,
|
fs = Fileselector(win, is_save=True, expandable=False, folder_only=False,
|
||||||
path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH,
|
path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH,
|
||||||
size_hint_align=FILL_BOTH)
|
size_hint_align=FILL_BOTH)
|
||||||
fs.callback_done_add(fs_cb_done, win)
|
fs.callback_done_add(fs_cb_done, win)
|
||||||
fs.callback_selected_add(fs_cb_selected, win)
|
fs.callback_selected_add(fs_cb_selected, win)
|
||||||
fs.callback_directory_open_add(fs_cb_directory_open, win)
|
fs.callback_directory_open_add(fs_cb_directory_open, win)
|
||||||
vbox.pack_end(fs)
|
box1.pack_end(fs)
|
||||||
fs.show()
|
fs.show()
|
||||||
|
|
||||||
sep = Separator(win, horizontal=True)
|
fs.custom_filter_append(custom_filter_all, filter_name="All Files")
|
||||||
vbox.pack_end(sep)
|
fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files")
|
||||||
|
fs.mime_types_filter_append(["text/*"], "Text Files")
|
||||||
|
fs.mime_types_filter_append(["image/*"], "Image Files")
|
||||||
|
|
||||||
|
|
||||||
|
sep = Separator(win)
|
||||||
|
box1.pack_end(sep)
|
||||||
sep.show()
|
sep.show()
|
||||||
|
|
||||||
hbox = Box(win, horizontal=True)
|
vbox = Box(win)
|
||||||
vbox.pack_end(hbox)
|
box1.pack_end(vbox)
|
||||||
hbox.show()
|
vbox.show()
|
||||||
|
|
||||||
|
# Options frame
|
||||||
|
fr = Frame(win, text="Options")
|
||||||
|
vbox.pack_end(fr)
|
||||||
|
fr.show()
|
||||||
|
|
||||||
|
fbox1 = Box(win)
|
||||||
|
fr.content = fbox1
|
||||||
|
fbox1.show()
|
||||||
|
|
||||||
|
fbox2 = Box(win, horizontal=True)
|
||||||
|
fbox1.pack_end(fbox2)
|
||||||
|
fbox2.show()
|
||||||
|
|
||||||
ck = Check(win, text="is_save", state=fs.is_save)
|
ck = Check(win, text="is_save", state=fs.is_save)
|
||||||
ck.callback_changed_add(ck_cb_is_save, fs)
|
ck.callback_changed_add(ck_cb_is_save, fs)
|
||||||
hbox.pack_end(ck)
|
fbox2.pack_end(ck)
|
||||||
ck.show()
|
ck.show()
|
||||||
|
|
||||||
ck = Check(win, text="folder_only", state=fs.folder_only)
|
ck = Check(win, text="folder_only", state=fs.folder_only)
|
||||||
ck.callback_changed_add(ck_cb_folder_only, fs)
|
ck.callback_changed_add(ck_cb_folder_only, fs)
|
||||||
hbox.pack_end(ck)
|
fbox2.pack_end(ck)
|
||||||
ck.show()
|
ck.show()
|
||||||
|
|
||||||
ck = Check(win, text="expandable", state=fs.expandable)
|
ck = Check(win, text="expandable", state=fs.expandable)
|
||||||
ck.callback_changed_add(ck_cb_expandable, fs)
|
ck.callback_changed_add(ck_cb_expandable, fs)
|
||||||
hbox.pack_end(ck)
|
fbox2.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
fbox2 = Box(win, horizontal=True)
|
||||||
|
fbox1.pack_end(fbox2)
|
||||||
|
fbox2.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="multiple selection", state=fs. multi_select)
|
||||||
|
ck.callback_changed_add(ck_cb_multi_select, fs)
|
||||||
|
fbox2.pack_end(ck)
|
||||||
ck.show()
|
ck.show()
|
||||||
|
|
||||||
ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
|
ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
|
||||||
ck.callback_changed_add(ck_cb_buttons, fs)
|
ck.callback_changed_add(ck_cb_buttons, fs)
|
||||||
hbox.pack_end(ck)
|
fbox2.pack_end(ck)
|
||||||
ck.show()
|
ck.show()
|
||||||
|
|
||||||
ck = Check(win, text="hidden", state=fs.hidden_visible)
|
ck = Check(win, text="hidden", state=fs.hidden_visible)
|
||||||
ck.callback_changed_add(ck_cb_hidden, fs)
|
ck.callback_changed_add(ck_cb_hidden, fs)
|
||||||
hbox.pack_end(ck)
|
fbox2.pack_end(ck)
|
||||||
ck.show()
|
ck.show()
|
||||||
|
|
||||||
hbox = Box(win, horizontal=True)
|
# Getters frame
|
||||||
vbox.pack_end(hbox)
|
fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH)
|
||||||
hbox.show()
|
vbox.pack_end(fr)
|
||||||
|
fr.show()
|
||||||
|
|
||||||
|
fbox = Box(win, horizontal=True)
|
||||||
|
fr.content = fbox
|
||||||
|
fbox.show()
|
||||||
|
|
||||||
bt = Button(win, text="selected_get")
|
bt = Button(win, text="selected_get")
|
||||||
bt.callback_clicked_add(bt_cb_sel_get, fs)
|
bt.callback_clicked_add(bt_cb_sel_get, fs)
|
||||||
hbox.pack_end(bt)
|
fbox.pack_end(bt)
|
||||||
bt.show()
|
bt.show()
|
||||||
|
|
||||||
bt = Button(win, text="path_get")
|
bt = Button(win, text="path_get")
|
||||||
bt.callback_clicked_add(bt_cb_path_get, fs)
|
bt.callback_clicked_add(bt_cb_path_get, fs)
|
||||||
hbox.pack_end(bt)
|
fbox.pack_end(bt)
|
||||||
bt.show()
|
bt.show()
|
||||||
|
|
||||||
bt = Button(win, text="mode cycle")
|
bt = Button(win, text="selected_paths")
|
||||||
bt.callback_clicked_add(bt_cb_mode_cycle, fs)
|
bt.callback_clicked_add(bt_cb_paths_get, fs)
|
||||||
hbox.pack_end(bt)
|
fbox.pack_end(bt)
|
||||||
bt.show()
|
bt.show()
|
||||||
|
|
||||||
bt = Button(win, text="sort_method cycle")
|
# Mode frame
|
||||||
bt.callback_clicked_add(bt_cb_sort_cycle, fs)
|
fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH)
|
||||||
hbox.pack_end(bt)
|
vbox.pack_end(fr)
|
||||||
bt.show()
|
fr.show()
|
||||||
|
|
||||||
win.resize(240, 350)
|
fbox = Box(win, horizontal=True)
|
||||||
win.show()
|
fr.content = fbox
|
||||||
|
fbox.show()
|
||||||
|
|
||||||
|
rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST)
|
||||||
|
rd.callback_changed_add(rd_cb_mode, fs)
|
||||||
|
fbox.pack_end(rd)
|
||||||
|
rd.show()
|
||||||
|
|
||||||
def fileselector_button_clicked(obj, item=None):
|
rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID)
|
||||||
win = StandardWindow("fileselector", "File selector test", autodel=True,
|
rd.callback_changed_add(rd_cb_mode, fs)
|
||||||
size=(240, 350))
|
rd.group_add(rdg)
|
||||||
|
fbox.pack_end(rd)
|
||||||
|
rd.show()
|
||||||
|
|
||||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
# Thumbsize frame
|
||||||
win.resize_object_add(vbox)
|
fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH)
|
||||||
vbox.show()
|
vbox.pack_end(fr)
|
||||||
|
fr.show()
|
||||||
|
|
||||||
fse = FileselectorButton(win, text="Select a file", inwin_mode=False,
|
sl = Slider(win, min_max=(4, 130), unit_format="%.0f px",
|
||||||
size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
|
value=fs.thumbnail_size[0])
|
||||||
vbox.pack_end(fse)
|
sl.callback_delay_changed_add(sl_cb_thumb_size, fs)
|
||||||
fse.show()
|
fr.content = sl
|
||||||
|
sl.show()
|
||||||
|
|
||||||
sep = Separator(win, horizontal=True)
|
# Sort method frame
|
||||||
vbox.pack_end(sep)
|
fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH)
|
||||||
sep.show()
|
vbox.pack_end(fr)
|
||||||
|
fr.show()
|
||||||
|
|
||||||
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
hs = Hoversel(win, text="File name (asc)")
|
||||||
vbox.pack_end(hbox)
|
sorts = (
|
||||||
hbox.show()
|
("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC),
|
||||||
|
("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC),
|
||||||
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC),
|
||||||
ck.callback_changed_add(ck_entry_cb_inwin, fse)
|
("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC),
|
||||||
hbox.pack_end(ck)
|
("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC),
|
||||||
ck.show()
|
("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC),
|
||||||
|
("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC),
|
||||||
ck = Check(win, text="folder_only", state=fse.folder_only)
|
("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC),
|
||||||
ck.callback_changed_add(ck_entry_cb_folder_only, fse)
|
)
|
||||||
hbox.pack_end(ck)
|
for sort in sorts:
|
||||||
ck.show()
|
hs.item_add(label=sort[0], callback=hs_cb_sort_method, fs=fs, method=sort[1])
|
||||||
|
fr.content = hs
|
||||||
ck = Check(win, text="is_save", state=fse.is_save)
|
hs.show()
|
||||||
ck.callback_changed_add(ck_entry_cb_is_save, fse)
|
|
||||||
hbox.pack_end(ck)
|
|
||||||
ck.show()
|
|
||||||
|
|
||||||
ck = Check(win, text="expandable", state=fse.expandable)
|
|
||||||
ck.callback_changed_add(ck_entry_cb_expandable, fse)
|
|
||||||
hbox.pack_end(ck)
|
|
||||||
ck.show()
|
|
||||||
|
|
||||||
win.show()
|
|
||||||
|
|
||||||
|
|
||||||
def ck_entry_cb_is_save(bt, fse):
|
|
||||||
print("Toggle is save")
|
|
||||||
fse.is_save = not fse.is_save
|
|
||||||
|
|
||||||
def ck_entry_cb_inwin(bt, fse):
|
|
||||||
print("Toggle inwin mode")
|
|
||||||
fse.inwin_mode = not fse.inwin_mode
|
|
||||||
|
|
||||||
def ck_entry_cb_folder_only(bt, fse):
|
|
||||||
print("Toggle folder_only")
|
|
||||||
fse.folder_only = not fse.folder_only
|
|
||||||
|
|
||||||
def ck_entry_cb_expandable(bt, fse):
|
|
||||||
print("Toggle expandable")
|
|
||||||
fse.expandable = not fse.expandable
|
|
||||||
|
|
||||||
|
|
||||||
def fileselector_entry_clicked(obj, item=None):
|
|
||||||
win = StandardWindow("fileselector", "File selector test", autodel=True,
|
|
||||||
size=(240, 150))
|
|
||||||
|
|
||||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
|
||||||
win.resize_object_add(vbox)
|
|
||||||
vbox.show()
|
|
||||||
|
|
||||||
fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
|
|
||||||
size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
|
|
||||||
vbox.pack_end(fse)
|
|
||||||
fse.show()
|
|
||||||
|
|
||||||
sep = Separator(win, horizontal=True)
|
|
||||||
vbox.pack_end(sep)
|
|
||||||
sep.show()
|
|
||||||
|
|
||||||
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
|
||||||
vbox.pack_end(hbox)
|
|
||||||
hbox.show()
|
|
||||||
|
|
||||||
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
|
||||||
ck.callback_changed_add(ck_entry_cb_inwin, fse)
|
|
||||||
hbox.pack_end(ck)
|
|
||||||
ck.show()
|
|
||||||
|
|
||||||
ck = Check(win, text="folder_only", state=fse.folder_only)
|
|
||||||
ck.callback_changed_add(ck_entry_cb_folder_only, fse)
|
|
||||||
hbox.pack_end(ck)
|
|
||||||
ck.show()
|
|
||||||
|
|
||||||
ck = Check(win, text="is_save", state=fse.is_save)
|
|
||||||
ck.callback_changed_add(ck_entry_cb_is_save, fse)
|
|
||||||
hbox.pack_end(ck)
|
|
||||||
ck.show()
|
|
||||||
|
|
||||||
ck = Check(win, text="expandable", state=fse.expandable)
|
|
||||||
ck.callback_changed_add(ck_entry_cb_expandable, fse)
|
|
||||||
hbox.pack_end(ck)
|
|
||||||
ck.show()
|
|
||||||
|
|
||||||
win.show()
|
win.show()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
elementary.init()
|
elementary.init()
|
||||||
win = StandardWindow("test", "python-elementary test application",
|
|
||||||
size=(320,520))
|
|
||||||
win.callback_delete_request_add(lambda o: elementary.exit())
|
|
||||||
|
|
||||||
box0 = Box(win, size_hint_weight=EXPAND_BOTH)
|
fileselector_clicked(None)
|
||||||
win.resize_object_add(box0)
|
|
||||||
box0.show()
|
|
||||||
|
|
||||||
lb = Label(win)
|
|
||||||
lb.text_set("Please select a test from the list below<br>"
|
|
||||||
"by clicking the test button to show the<br>"
|
|
||||||
"test window.")
|
|
||||||
lb.show()
|
|
||||||
|
|
||||||
fr = Frame(win, text="Information", content=lb)
|
|
||||||
box0.pack_end(fr)
|
|
||||||
fr.show()
|
|
||||||
|
|
||||||
items = [("Fileselector", fileselector_clicked),
|
|
||||||
("Fileselector Button", fileselector_button_clicked),
|
|
||||||
("Fileselector Entry", fileselector_entry_clicked),
|
|
||||||
]
|
|
||||||
|
|
||||||
li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
|
||||||
box0.pack_end(li)
|
|
||||||
li.show()
|
|
||||||
|
|
||||||
for item in items:
|
|
||||||
li.item_append(item[0], callback=item[1])
|
|
||||||
|
|
||||||
li.go()
|
|
||||||
|
|
||||||
win.show()
|
|
||||||
elementary.run()
|
elementary.run()
|
||||||
elementary.shutdown()
|
elementary.shutdown()
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||||
|
from efl import elementary
|
||||||
|
from efl.elementary.window import StandardWindow
|
||||||
|
from efl.elementary.box import Box
|
||||||
|
from efl.elementary.check import Check
|
||||||
|
from efl.elementary.fileselector_button import FileselectorButton
|
||||||
|
from efl.elementary.separator import Separator
|
||||||
|
|
||||||
|
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||||
|
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||||
|
|
||||||
|
def toggle_is_save(bt, fsb):
|
||||||
|
print("Toggle is save")
|
||||||
|
fsb.is_save = not fsb.is_save
|
||||||
|
|
||||||
|
def toggle_inwin(bt, fsb):
|
||||||
|
print("Toggle inwin mode")
|
||||||
|
fsb.inwin_mode = not fsb.inwin_mode
|
||||||
|
|
||||||
|
def toggle_folder_only(bt, fsb):
|
||||||
|
print("Toggle folder_only")
|
||||||
|
fsb.folder_only = not fsb.folder_only
|
||||||
|
|
||||||
|
def toggle_expandable(bt, fsb):
|
||||||
|
print("Toggle expandable")
|
||||||
|
fsb.expandable = not fsb.expandable
|
||||||
|
|
||||||
|
def fileselector_button_clicked(obj, item=None):
|
||||||
|
win = StandardWindow("fileselector", "File selector test",
|
||||||
|
autodel=True, size=(240, 350))
|
||||||
|
|
||||||
|
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||||
|
win.resize_object_add(vbox)
|
||||||
|
vbox.show()
|
||||||
|
|
||||||
|
fse = FileselectorButton(win, text="Select a file", inwin_mode=False,
|
||||||
|
size_hint_align=FILL_BOTH,
|
||||||
|
size_hint_weight=EXPAND_BOTH)
|
||||||
|
vbox.pack_end(fse)
|
||||||
|
fse.show()
|
||||||
|
|
||||||
|
sep = Separator(win, horizontal=True)
|
||||||
|
vbox.pack_end(sep)
|
||||||
|
sep.show()
|
||||||
|
|
||||||
|
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||||
|
vbox.pack_end(hbox)
|
||||||
|
hbox.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
||||||
|
ck.callback_changed_add(toggle_inwin, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="folder_only", state=fse.folder_only)
|
||||||
|
ck.callback_changed_add(toggle_folder_only, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="is_save", state=fse.is_save)
|
||||||
|
ck.callback_changed_add(toggle_is_save, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="expandable", state=fse.expandable)
|
||||||
|
ck.callback_changed_add(toggle_expandable, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
win.show()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
elementary.init()
|
||||||
|
|
||||||
|
fileselector_button_clicked(None)
|
||||||
|
|
||||||
|
elementary.run()
|
||||||
|
elementary.shutdown()
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||||
|
from efl import elementary
|
||||||
|
from efl.elementary.window import StandardWindow
|
||||||
|
from efl.elementary.box import Box
|
||||||
|
from efl.elementary.check import Check
|
||||||
|
from efl.elementary.fileselector_entry import FileselectorEntry
|
||||||
|
from efl.elementary.separator import Separator
|
||||||
|
|
||||||
|
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||||
|
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||||
|
|
||||||
|
|
||||||
|
def toggle_is_save(bt, fse):
|
||||||
|
print("Toggle is save")
|
||||||
|
fse.is_save = not fse.is_save
|
||||||
|
|
||||||
|
def toggle_inwin(bt, fse):
|
||||||
|
print("Toggle inwin mode")
|
||||||
|
fse.inwin_mode = not fse.inwin_mode
|
||||||
|
|
||||||
|
def toggle_folder_only(bt, fse):
|
||||||
|
print("Toggle folder_only")
|
||||||
|
fse.folder_only = not fse.folder_only
|
||||||
|
|
||||||
|
def toggle_expandable(bt, fse):
|
||||||
|
print("Toggle expandable")
|
||||||
|
fse.expandable = not fse.expandable
|
||||||
|
|
||||||
|
|
||||||
|
def fileselector_entry_clicked(obj, item=None):
|
||||||
|
win = StandardWindow("fileselector", "File selector test",
|
||||||
|
autodel=True, size=(240, 150))
|
||||||
|
|
||||||
|
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||||
|
win.resize_object_add(vbox)
|
||||||
|
vbox.show()
|
||||||
|
|
||||||
|
fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
|
||||||
|
size_hint_align=FILL_BOTH,
|
||||||
|
size_hint_weight=EXPAND_BOTH)
|
||||||
|
vbox.pack_end(fse)
|
||||||
|
fse.show()
|
||||||
|
|
||||||
|
sep = Separator(win, horizontal=True)
|
||||||
|
vbox.pack_end(sep)
|
||||||
|
sep.show()
|
||||||
|
|
||||||
|
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||||
|
vbox.pack_end(hbox)
|
||||||
|
hbox.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
||||||
|
ck.callback_changed_add(toggle_inwin, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="folder_only", state=fse.folder_only)
|
||||||
|
ck.callback_changed_add(toggle_folder_only, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="is_save", state=fse.is_save)
|
||||||
|
ck.callback_changed_add(toggle_is_save, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
ck = Check(win, text="expandable", state=fse.expandable)
|
||||||
|
ck.callback_changed_add(toggle_expandable, fse)
|
||||||
|
hbox.pack_end(ck)
|
||||||
|
ck.show()
|
||||||
|
|
||||||
|
win.show()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
elementary.init()
|
||||||
|
|
||||||
|
fileselector_entry_clicked(None)
|
||||||
|
|
||||||
|
elementary.run()
|
||||||
|
elementary.shutdown()
|
Loading…
Reference in New Issue