~ubuntu-branches/ubuntu/hardy/pida/hardy

« back to all changes in this revision

Viewing changes to contrib/kiwi/kiwi/ui/widgets/filechooser.py

  • Committer: Bazaar Package Importer
  • Author(s): Jan Luebbe
  • Date: 2007-09-05 17:54:09 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070905175409-ty9f6qpuctyjv1sd
Tags: 0.5.1-2
* Depend on librsvg2-common, which is not pulled in by the other depends
  (closes: #394860)
* gvim is no alternative for python-gnome2 and python-gnome2-extras
  (closes: #436431)
* Pida now uses ~/.pida2, so it can no longer be confused by old
  configurations (closes: #421378)
* Culebra is no longer supported by upstream (closes: #349009)
* Update manpage (closes: #440375)
* Update watchfile (pida is now called PIDA)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Kiwi: a Framework and Enhanced Widgets for Python
 
3
#
 
4
# Copyright (C) 2006 Async Open Source
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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
 
19
# USA
 
20
#
 
21
# Author(s): Ali Afshar <aafshar@gmail.com>
 
22
#
 
23
 
 
24
 
 
25
"""Filechooser widgets for the kiwi framework"""
 
26
 
 
27
import gtk
 
28
 
 
29
from kiwi.ui.proxywidget import ProxyWidgetMixin
 
30
from kiwi.utils import PropertyObject, gsignal
 
31
 
 
32
class _FileChooserMixin(object):
 
33
    """Mixin to use common methods of the FileChooser interface"""
 
34
 
 
35
    allowed_data_types = basestring,
 
36
 
 
37
    gsignal('selection_changed', 'override')
 
38
    def do_selection_changed(self):
 
39
        self.emit('content-changed')
 
40
        self.chain()
 
41
 
 
42
    def read(self):
 
43
        return self.get_filename()
 
44
 
 
45
    def update(self, data):
 
46
        if data is None:
 
47
            return
 
48
        self.set_filename(data)
 
49
 
 
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):
 
54
        """
 
55
        @param action:
 
56
        @param backend:
 
57
        """
 
58
        ProxyWidgetMixin.__init__(self)
 
59
        PropertyObject.__init__(self, data_type=str)
 
60
        gtk.FileChooserWidget.__init__(self, action=action, backend=backend)
 
61
 
 
62
class ProxyFileChooserButton(_FileChooserMixin, PropertyObject,
 
63
                             gtk.FileChooserButton, ProxyWidgetMixin):
 
64
    __gtype_name__ = 'ProxyFileChooserButton'
 
65
    def __init__(self, title=None, backend=None, dialog=None):
 
66
        """
 
67
        @param title:
 
68
        @param backend:
 
69
        @param dialog:
 
70
        """
 
71
        ProxyWidgetMixin.__init__(self)
 
72
        PropertyObject.__init__(self, data_type=str)
 
73
 
 
74
        # Broken, Broken PyGTK
 
75
        if isinstance(title, str):
 
76
            gtk.FileChooserButton.__init__(self, title, backend)
 
77
        else:
 
78
            gtk.FileChooserButton.__init__(self, dialog or title)