diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 09:27:57 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 09:27:57 -0700 |
commit | 928ccf929c26a5344c224303b5108e99c2eb597a (patch) | |
tree | 6d371148311fe4467b0c9a208e9c36d24380c75e /kiwi/ui/widgets/checkbutton.py |
Imported Upstream version 1.9.8
Diffstat (limited to 'kiwi/ui/widgets/checkbutton.py')
-rw-r--r-- | kiwi/ui/widgets/checkbutton.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/kiwi/ui/widgets/checkbutton.py b/kiwi/ui/widgets/checkbutton.py new file mode 100644 index 0000000..f7bf5c1 --- /dev/null +++ b/kiwi/ui/widgets/checkbutton.py @@ -0,0 +1,69 @@ +# +# Kiwi: a Framework and Enhanced Widgets for Python +# +# Copyright (C) 2003-2005 Async Open Source +# +# This library 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. +# +# This library 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 library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +# +# Author(s): Christian Reis <kiko@async.com.br> +# Gustavo Rahal <gustavo@async.com.br> +# Johan Dahlin <jdahlin@async.com.br> +# Lorenzo Gil Sanchez <lgs@sicem.biz> +# + +"""GtkCheckButton support for the Kiwi Framework""" + +import gtk + +from kiwi.python import deprecationwarn +from kiwi.ui.proxywidget import ProxyWidgetMixin +from kiwi.utils import PropertyObject, gsignal, type_register + +class ProxyCheckButton(PropertyObject, gtk.CheckButton, ProxyWidgetMixin): + __gtype_name__ = 'ProxyCheckButton' + + # changed allowed data types because checkbuttons can only + # accept bool values + allowed_data_types = bool, + + def __init__(self): + ProxyWidgetMixin.__init__(self) + PropertyObject.__init__(self, data_type=bool) + gtk.CheckButton.__init__(self) + + gsignal('toggled', 'override') + def do_toggled(self): + self.emit('content-changed') + self.chain() + + def read(self): + return self.get_active() + + def update(self, data): + if data is None: + self.set_active(False); + return + + # No conversion to string needed, we only accept bool + self.set_active(data) + +class CheckButton(ProxyCheckButton): + def __init__(self): + deprecationwarn( + 'CheckButton is deprecated, use ProxyCheckButton instead', + stacklevel=3) + ProxyCheckButton.__init__(self) +type_register(CheckButton) |