# 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 .
"""
.. image:: /images/multibuttonentry-preview.png
Widget description
------------------
A Multibuttonentry is a widget to allow a user enter text and manage
it as a number of buttons. Each text button is inserted by pressing the
"return" key. If there is no space in the current row, a new button is
added to the next row. When a text button is pressed, it will become
focused. Backspace removes the focus. When the Multibuttonentry loses
focus items longer than one line are shrunk to one line.
Typical use case of multibuttonentry is, composing emails/messages to a
group of addresses, each of which is an item that can be clicked for
further actions.
This widget emits the following signals, besides the ones sent from
:py:class:`LayoutClass`:
- ``item,selected`` - this is called when an item is selected by
api, user interaction, and etc. this is also called when a
user press back space while cursor is on the first field of
entry.
- ``item,added`` - when a new multi-button entry item is added.
- ``item,deleted`` - when a multi-button entry item is deleted.
- ``item,clicked`` - this is called when an item is clicked by user
interaction. Both "item,selected" and "item,clicked" are needed.
- ``clicked`` - when multi-button entry is clicked.
- ``focused`` - when multi-button entry is focused.
- ``unfocused`` - when multi-button entry is unfocused.
- ``expanded`` - when multi-button entry is expanded.
- ``contracted`` - when multi-button entry is contracted.
- ``expand,state,changed`` - when shrink mode state of
multi-button entry is changed.
Default text parts of the multibuttonentry widget that you can use for are:
- "default" - A label of the multibuttonentry
Default text parts of the multibuttonentry items that you can use for are:
- "default" - A label of the multibuttonentry item
"""
from cpython cimport PyUnicode_AsUTF8String, Py_DECREF, Py_INCREF
from efl.eo cimport _object_mapping_register, object_from_instance, PY_REFCOUNT
from efl.utils.conversions cimport _ctouni
from efl.evas cimport Object as evasObject
from libc.stdlib cimport free
from libc.string cimport strdup
from efl.eina cimport Eina_Stringshare, eina_stringshare_add, eina_stringshare_del, \
eina_stringshare_replace
from object cimport Object
import traceback
from object_item cimport _object_item_callback, \
_object_item_to_python, \
_object_item_list_to_python
cdef Eina_Bool _multibuttonentry_filter_callback(Evas_Object *obj, \
const_char *item_label, void *item_data, void *data) with gil:
cdef:
MultiButtonEntry mbe = object_from_instance(obj)
bint ret
(callback, a, ka) =