ocarina/ocarina/fsselect.py

50 lines
1.2 KiB
Python

# Bryan Schumaker (June 2010)
import gtk
import gobject
#FS_OK = gobject.signal_new("filesystem_ok", gtk.FileChooserDialog,
# gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
# (gtk.Dialog, int))
#print FS_OK
#print gobject.signal_query(FS_OK)
#print gobject.signal_query(gtk.RESPONSE_OK)
def make_chooser(title, action):
buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK)
chooser = gtk.FileChooserDialog(title, action=action, buttons=buttons)
chooser.connect("response", response)
return chooser
def response(*args):
print "here?"
print args
def run_chooser(chooser):
file = None
if chooser.run() == gtk.RESPONSE_OK:
file = chooser.get_filename()
chooser.hide()
return file
# Use for selecting a file through the GUI
def file(title="Select a song"):
chooser = makeChooser(title, gtk.FILE_CHOOSER_ACTION_OPEN)
return runChooser(chooser)
# Use for selecting a directory through the GUI
def dir(title="Select a directory"):
chooser = makeChooser(title, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
return runChooser(chooser)
def save(title="Select a location"):
chooser = makeChooser(title, gtk.FILE_CHOOSER_ACTION_SAVE)
return runChooser(chooser)