~ubuntu-branches/ubuntu/karmic/pida/karmic

« back to all changes in this revision

Viewing changes to pida/pidagtk/filedialogs.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
 
# -*- coding: utf-8 -*- 
2
 
 
3
 
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
4
 
#Copyright (c) 2005 Ali Afshar aafshar@gmail.com
5
 
 
6
 
#Permission is hereby granted, free of charge, to any person obtaining a copy
7
 
#of this software and associated documentation files (the "Software"), to deal
8
 
#in the Software without restriction, including without limitation the rights
9
 
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 
#copies of the Software, and to permit persons to whom the Software is
11
 
#furnished to do so, subject to the following conditions:
12
 
 
13
 
#The above copyright notice and this permission notice shall be included in
14
 
#all copies or substantial portions of the Software.
15
 
 
16
 
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 
#SOFTWARE.
23
 
 
24
 
import gtk
25
 
import icons
26
 
 
27
 
class FolderDialog(gtk.FileChooserDialog):
28
 
    TITLE = 'Select Directory'
29
 
    ACTION = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
30
 
 
31
 
    def __init__(self, responsecb):
32
 
        gtk.FileChooserDialog.__init__(self, title=self.TITLE,
33
 
                                             parent=None,
34
 
                                             action=self.ACTION,
35
 
                                             buttons=(gtk.STOCK_OK,
36
 
gtk.RESPONSE_ACCEPT,
37
 
                                                gtk.STOCK_CANCEL,
38
 
gtk.RESPONSE_REJECT))
39
 
        self.connect('response', responsecb)
40
 
 
41
 
    def connect_widgets(self):
42
 
        pass
43
 
 
44
 
class FolderButton(gtk.HBox):
45
 
    DTYPE = FolderDialog
46
 
 
47
 
    def __init__(self):
48
 
        gtk.HBox.__init__(self)
49
 
        self.entry = gtk.Entry()
50
 
        self.pack_start(self.entry)
51
 
        self.but = icons.icons.get_button('gtk-open')
52
 
        self.but.connect('clicked', self.cb_open)
53
 
        self.pack_start(self.but, expand=False)
54
 
        self.dialog = None
55
 
 
56
 
    def update(self):
57
 
        self.entry.set_text(self.dialog.get_filename())
58
 
 
59
 
    def show_dialog(self):
60
 
        if not self.dialog:
61
 
            self.dialog = self.DTYPE(self.cb_response)
62
 
            self.dialog.connect('destroy', self.cb_destroy)
63
 
        entrytext = self.entry.get_text()
64
 
        if entrytext:
65
 
            self.dialog.set_filename(self.entry.get_text())
66
 
        #self.dialog.set_transient_for(self.pida.mainwindow)
67
 
        self.dialog.show()
68
 
 
69
 
    def cb_response(self, d, resp):
70
 
        self.dialog.hide()
71
 
        if resp == gtk.RESPONSE_ACCEPT:
72
 
            self.update()
73
 
        
74
 
    def cb_destroy(self, *args):
75
 
        self.dialog.destroy()
76
 
        self.dialog = None
77
 
 
78
 
    def cb_open(self, *args):
79
 
        self.show_dialog()
80
 
 
81
 
    def get_filename(self):
82
 
        return self.entry.get_text()
83
 
 
84
 
    get_text = get_filename
85
 
 
86
 
    def set_filename(self, fn):
87
 
        self.entry.set_text(fn)
88
 
 
89
 
    set_text = set_filename
90
 
 
91
 
class FileDialog(FolderDialog):
92
 
    TITLE = 'Select File'
93
 
    ACTION = gtk.FILE_CHOOSER_ACTION_OPEN
94
 
 
95
 
    def connect_widgets(self):
96
 
        def cb(*args):
97
 
            self.response(1)
98
 
        self.connect('file-activated', cb)
99
 
        
100
 
class FileButton(FolderButton):
101
 
    DTYPE = FileDialog
102