1
# -*- coding: utf-8 -*-
3
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
4
#Copyright (c) 2005 Ali Afshar aafshar@gmail.com
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:
13
#The above copyright notice and this permission notice shall be included in
14
#all copies or substantial portions of the Software.
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
27
class FolderDialog(gtk.FileChooserDialog):
28
TITLE = 'Select Directory'
29
ACTION = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
31
def __init__(self, responsecb):
32
gtk.FileChooserDialog.__init__(self, title=self.TITLE,
35
buttons=(gtk.STOCK_OK,
39
self.connect('response', responsecb)
41
def connect_widgets(self):
44
class FolderButton(gtk.HBox):
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)
57
self.entry.set_text(self.dialog.get_filename())
59
def show_dialog(self):
61
self.dialog = self.DTYPE(self.cb_response)
62
self.dialog.connect('destroy', self.cb_destroy)
63
entrytext = self.entry.get_text()
65
self.dialog.set_filename(self.entry.get_text())
66
#self.dialog.set_transient_for(self.pida.mainwindow)
69
def cb_response(self, d, resp):
71
if resp == gtk.RESPONSE_ACCEPT:
74
def cb_destroy(self, *args):
78
def cb_open(self, *args):
81
def get_filename(self):
82
return self.entry.get_text()
84
get_text = get_filename
86
def set_filename(self, fn):
87
self.entry.set_text(fn)
89
set_text = set_filename
91
class FileDialog(FolderDialog):
93
ACTION = gtk.FILE_CHOOSER_ACTION_OPEN
95
def connect_widgets(self):
98
self.connect('file-activated', cb)
100
class FileButton(FolderButton):