2
# Kiwi: a Framework and Enhanced Widgets for Python
4
# Copyright (C) 2006 Async Open Source
6
# This library is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU Lesser General Public
8
# License as published by the Free Software Foundation; either
9
# version 2.1 of the License, or (at your option) any later version.
11
# This library is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# Lesser General Public License for more details.
16
# You should have received a copy of the GNU Lesser General Public
17
# License along with this library; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21
# Author(s): Ali Afshar <aafshar@gmail.com>
25
"""Filechooser widgets for the kiwi framework"""
29
from kiwi.ui.proxywidget import ProxyWidgetMixin
30
from kiwi.utils import PropertyObject, gsignal
32
class _FileChooserMixin(object):
33
"""Mixin to use common methods of the FileChooser interface"""
35
allowed_data_types = basestring,
37
gsignal('selection_changed', 'override')
38
def do_selection_changed(self):
39
self.emit('content-changed')
43
return self.get_filename()
45
def update(self, data):
48
self.set_filename(data)
50
class ProxyFileChooserWidget(_FileChooserMixin, PropertyObject,
51
gtk.FileChooserWidget, ProxyWidgetMixin):
52
__gtype_name__ = 'ProxyFileChooserWidget'
53
def __init__(self, action=gtk.FILE_CHOOSER_ACTION_OPEN, backend=None):
58
ProxyWidgetMixin.__init__(self)
59
PropertyObject.__init__(self, data_type=str)
60
gtk.FileChooserWidget.__init__(self, action=action, backend=backend)
62
class ProxyFileChooserButton(_FileChooserMixin, PropertyObject,
63
gtk.FileChooserButton, ProxyWidgetMixin):
64
__gtype_name__ = 'ProxyFileChooserButton'
65
def __init__(self, title=None, backend=None, dialog=None):
71
ProxyWidgetMixin.__init__(self)
72
PropertyObject.__init__(self, data_type=str)
74
# Broken, Broken PyGTK
75
if isinstance(title, str):
76
gtk.FileChooserButton.__init__(self, title, backend)
78
gtk.FileChooserButton.__init__(self, dialog or title)