2013-02-17 11:35:20 -08:00
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2013-04-27 13:01:53 -07:00
|
|
|
.. image:: /images/dayselector-preview.png
|
|
|
|
|
2013-05-01 05:34:45 -07:00
|
|
|
Widget description
|
|
|
|
------------------
|
2013-04-04 08:00:45 -07:00
|
|
|
|
|
|
|
Dayselector displays all seven days of the week and allows the user to
|
|
|
|
select multiple days.
|
|
|
|
|
|
|
|
The selection can be toggle by just clicking on the day.
|
|
|
|
|
|
|
|
Dayselector also provides the functionality to check whether a day is
|
|
|
|
selected or not.
|
|
|
|
|
|
|
|
First day of the week is taken from config settings by default. It can be
|
|
|
|
altered by using the API :py:attr:`week_start` API.
|
|
|
|
|
|
|
|
APIs are provided for setting the duration of weekend
|
|
|
|
:py:attr:`weekend_start` and :py:attr:`weekend_length` does this job.
|
|
|
|
|
|
|
|
Two styles of weekdays and weekends are supported in Dayselector.
|
|
|
|
Application can emit signals on individual check objects for setting the
|
|
|
|
weekday, weekend styles.
|
|
|
|
|
|
|
|
Once the weekend start day or weekend length changes, all the weekday &
|
|
|
|
weekend styles will be reset to default style. It's the application's
|
|
|
|
responsibility to set the styles again by sending corresponding signals.
|
|
|
|
|
|
|
|
"day0" indicates Sunday, "day1" indicates Monday etc. continues and so,
|
|
|
|
"day6" indicates the Saturday part name.
|
|
|
|
|
|
|
|
Application can change individual day display string by using the API
|
|
|
|
:py:func:`elementary.object.Object.part_text_set()`.
|
|
|
|
|
|
|
|
:py:func:`elementary.object.Object.part_content_set()` API sets the
|
|
|
|
individual day object only if the passed one is a Check widget.
|
|
|
|
|
|
|
|
Check object representing a day can be set/get by the application by using
|
|
|
|
the elm_object_part_content_set/get APIs thus providing a way to handle
|
|
|
|
the different check styles for individual days.
|
|
|
|
|
|
|
|
This widget emits the following signals, besides the ones sent from
|
|
|
|
:py:class:`elementary.layout.Layout`:
|
|
|
|
|
|
|
|
- ``"dayselector,changed"`` - when the user changes the state of a day.
|
|
|
|
- ``"language,changed"`` - the program's language changed
|
|
|
|
|
|
|
|
Available styles for dayselector are:
|
|
|
|
|
|
|
|
- default
|
|
|
|
|
|
|
|
|
2013-05-01 05:34:45 -07:00
|
|
|
Enumerations
|
|
|
|
------------
|
|
|
|
|
2013-04-12 14:53:55 -07:00
|
|
|
.. _Elm_Dayselector_Day:
|
|
|
|
|
2013-04-27 07:43:22 -07:00
|
|
|
Dayselector days
|
|
|
|
================
|
2013-02-17 11:35:20 -08:00
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_SUN
|
|
|
|
|
|
|
|
Sunday
|
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_MON
|
|
|
|
|
|
|
|
Monday
|
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_TUE
|
|
|
|
|
|
|
|
Tuesday
|
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_WED
|
|
|
|
|
|
|
|
Wednesday
|
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_THU
|
|
|
|
|
|
|
|
Thursday
|
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_FRI
|
|
|
|
|
|
|
|
Friday
|
|
|
|
|
|
|
|
.. data:: ELM_DAYSELECTOR_SAT
|
|
|
|
|
|
|
|
Saturday
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2013-10-06 01:52:36 -07:00
|
|
|
from efl.evas cimport Evas_Object, const_Evas_Object, \
|
|
|
|
Object as evasObject
|
|
|
|
from efl.eo cimport object_from_instance, _object_mapping_register
|
|
|
|
from efl.utils.conversions cimport _ctouni, _touni
|
|
|
|
|
|
|
|
from object cimport Object
|
|
|
|
|
|
|
|
from efl.evas cimport Eina_Bool, Eina_List
|
|
|
|
from enums cimport Elm_Dayselector_Day
|
|
|
|
from libc.string cimport const_char
|
|
|
|
|
|
|
|
cdef extern from "Elementary.h":
|
|
|
|
Evas_Object *elm_dayselector_add(Evas_Object *parent)
|
|
|
|
void elm_dayselector_day_selected_set(Evas_Object *obj, Elm_Dayselector_Day day, Eina_Bool selected)
|
|
|
|
Eina_Bool elm_dayselector_day_selected_get(const_Evas_Object *obj, Elm_Dayselector_Day day)
|
|
|
|
void elm_dayselector_week_start_set(Evas_Object *obj, Elm_Dayselector_Day day)
|
|
|
|
Elm_Dayselector_Day elm_dayselector_week_start_get(const_Evas_Object *obj)
|
|
|
|
void elm_dayselector_weekend_start_set(Evas_Object *obj, Elm_Dayselector_Day day)
|
|
|
|
Elm_Dayselector_Day elm_dayselector_weekend_start_get(const_Evas_Object *obj)
|
|
|
|
void elm_dayselector_weekend_length_set(Evas_Object *obj, unsigned int length)
|
|
|
|
unsigned int elm_dayselector_weekend_length_get(const_Evas_Object *obj)
|
|
|
|
void elm_dayselector_weekdays_names_set(Evas_Object *obj, const_char *weekdays[])
|
|
|
|
Eina_List *elm_dayselector_weekdays_names_get(const_Evas_Object *obj)
|
2013-02-17 11:35:20 -08:00
|
|
|
|
2013-09-30 18:56:28 -07:00
|
|
|
from efl.utils.conversions cimport python_list_strings_to_array_of_strings, \
|
|
|
|
eina_list_strings_to_python_list
|
2013-02-17 11:35:20 -08:00
|
|
|
from layout_class cimport LayoutClass
|
|
|
|
|
|
|
|
cimport enums
|
|
|
|
|
|
|
|
ELM_DAYSELECTOR_SUN = enums.ELM_DAYSELECTOR_SUN
|
|
|
|
ELM_DAYSELECTOR_MON = enums.ELM_DAYSELECTOR_MON
|
|
|
|
ELM_DAYSELECTOR_TUE = enums.ELM_DAYSELECTOR_TUE
|
|
|
|
ELM_DAYSELECTOR_WED = enums.ELM_DAYSELECTOR_WED
|
|
|
|
ELM_DAYSELECTOR_THU = enums.ELM_DAYSELECTOR_THU
|
|
|
|
ELM_DAYSELECTOR_FRI = enums.ELM_DAYSELECTOR_FRI
|
|
|
|
ELM_DAYSELECTOR_SAT = enums.ELM_DAYSELECTOR_SAT
|
|
|
|
ELM_DAYSELECTOR_MAX = enums.ELM_DAYSELECTOR_MAX
|
|
|
|
|
|
|
|
cdef class Dayselector(LayoutClass):
|
|
|
|
|
2013-04-27 07:43:22 -07:00
|
|
|
"""This is the class that actually implements the widget."""
|
2013-02-17 11:35:20 -08:00
|
|
|
|
|
|
|
def __init__(self, evasObject parent):
|
|
|
|
self._set_obj(elm_dayselector_add(parent.obj))
|
|
|
|
|
|
|
|
def day_selected_set(self, day, selected):
|
|
|
|
"""day_selected_set(int day, bool selected)
|
|
|
|
|
|
|
|
Set the state of given Dayselector_Day.
|
|
|
|
|
|
|
|
:param day: The day that the user want to set state.
|
2013-04-27 07:43:22 -07:00
|
|
|
:type day: :ref:`Elm_Dayselector_Day`
|
2013-02-17 11:35:20 -08:00
|
|
|
:param selected: state of the day. ``True`` is selected.
|
|
|
|
:type selected: bool
|
|
|
|
|
|
|
|
"""
|
|
|
|
elm_dayselector_day_selected_set(self.obj, day, selected)
|
|
|
|
|
|
|
|
def day_selected_get(self, day):
|
2013-04-12 14:53:55 -07:00
|
|
|
"""day_selected_get(int day) -> bool
|
2013-02-17 11:35:20 -08:00
|
|
|
|
|
|
|
Get the state of given Dayselector_Day.
|
|
|
|
|
|
|
|
:param day: The day that the user want to know state.
|
2013-04-27 07:43:22 -07:00
|
|
|
:type day: :ref:`Elm_Dayselector_Day`
|
2013-02-17 11:35:20 -08:00
|
|
|
:return: ``True``, if the Day is selected
|
|
|
|
:rtype: bool
|
|
|
|
|
|
|
|
"""
|
|
|
|
return bool(elm_dayselector_day_selected_get(self.obj, day))
|
|
|
|
|
|
|
|
property week_start:
|
|
|
|
"""The starting day of Dayselector.
|
|
|
|
|
2013-04-27 07:43:22 -07:00
|
|
|
:type: :ref:`Elm_Dayselector_Day`
|
2013-02-17 11:35:20 -08:00
|
|
|
|
|
|
|
"""
|
|
|
|
def __get__(self):
|
|
|
|
return elm_dayselector_week_start_get(self.obj)
|
|
|
|
def __set__(self, day):
|
|
|
|
elm_dayselector_week_start_set(self.obj, day)
|
|
|
|
|
|
|
|
property weekend_start:
|
|
|
|
"""The weekend starting day of Dayselector.
|
|
|
|
|
2013-04-27 07:43:22 -07:00
|
|
|
:type: :ref:`Elm_Dayselector_Day`
|
2013-02-17 11:35:20 -08:00
|
|
|
|
|
|
|
"""
|
|
|
|
def __get__(self):
|
|
|
|
return elm_dayselector_weekend_start_get(self.obj)
|
|
|
|
def __set__(self, day):
|
|
|
|
elm_dayselector_weekend_start_set(self.obj, day)
|
|
|
|
|
|
|
|
property weekend_length:
|
|
|
|
"""The weekend length of Dayselector.
|
|
|
|
|
|
|
|
:type: int
|
|
|
|
|
|
|
|
"""
|
|
|
|
def __get__(self):
|
|
|
|
return elm_dayselector_weekend_length_get(self.obj)
|
|
|
|
def __set__(self, length):
|
|
|
|
elm_dayselector_weekend_length_set(self.obj, length)
|
|
|
|
|
2013-09-22 11:16:31 -07:00
|
|
|
property weekdays_names:
|
|
|
|
"""
|
|
|
|
|
|
|
|
Set weekdays names to be displayed by the Dayselector.
|
|
|
|
|
|
|
|
:param weekdays: List of seven strings to be used as weekday names.
|
|
|
|
|
|
|
|
.. warning:: It must have 7 elements, or it will access invalid memory.
|
|
|
|
|
|
|
|
By default or if set to None, weekdays abbreviations get from system are displayed:
|
|
|
|
E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
|
|
|
|
|
|
|
|
The first string should be related to Sunday, the second to Monday...
|
|
|
|
|
|
|
|
The usage should be like this::
|
|
|
|
|
|
|
|
dayselector.weekdays_names = ["Sunday", "Monday", "Tuesday",
|
|
|
|
"Wednesday", "Thursday", "Friday", "Saturday"]
|
|
|
|
|
|
|
|
:see: elm_dayselector_weekdays_name_get()
|
|
|
|
:see: elm_dayselector_weekend_start_set()
|
|
|
|
|
|
|
|
:since: 1.8
|
|
|
|
|
|
|
|
"""
|
|
|
|
def __set__(self, list weekdays):
|
|
|
|
# TODO: Add checks for list validity (len == 7 etc.)
|
|
|
|
elm_dayselector_weekdays_names_set(self.obj,
|
2013-09-30 18:56:28 -07:00
|
|
|
python_list_strings_to_array_of_strings(weekdays))
|
2013-09-22 11:16:31 -07:00
|
|
|
|
|
|
|
def __get__(self):
|
2013-09-30 18:56:28 -07:00
|
|
|
return eina_list_strings_to_python_list(
|
2013-09-22 11:16:31 -07:00
|
|
|
elm_dayselector_weekdays_names_get(self.obj)
|
|
|
|
)
|
|
|
|
|
2013-02-17 11:35:20 -08:00
|
|
|
def callback_dayselector_changed_add(self, func, *args, **kwargs):
|
|
|
|
"""when the user changes the state of a day."""
|
|
|
|
self._callback_add("dayselector,changed", func, *args, **kwargs)
|
|
|
|
|
|
|
|
def callback_dayselector_changed_del(self, func):
|
|
|
|
self._callback_del("dayselector,changed", func)
|
|
|
|
|
|
|
|
def callback_language_changed_add(self, func, *args, **kwargs):
|
|
|
|
"""the program's language changed"""
|
|
|
|
self._callback_add("language,changed", func, *args, **kwargs)
|
|
|
|
|
|
|
|
def callback_language_changed_del(self, func):
|
|
|
|
self._callback_del("language,changed", func)
|
|
|
|
|
|
|
|
|
|
|
|
_object_mapping_register("elm_dayselector", Dayselector)
|