Filesystem Selecting
Began experimenting with a filesystem selector that can select both files and directories.
This commit is contained in:
parent
2f562bcc81
commit
2aded0e67f
|
@ -44,3 +44,10 @@ class PauseButton(Button):
|
||||||
LS.event.invite("POSTSTOP", self.hide)
|
LS.event.invite("POSTSTOP", self.hide)
|
||||||
def clicked(self, button):
|
def clicked(self, button):
|
||||||
LS.music.pause()
|
LS.music.pause()
|
||||||
|
|
||||||
|
|
||||||
|
class OpenButton(Button):
|
||||||
|
def __init__(self):
|
||||||
|
Button.__init__(self, gtk.STOCK_OPEN)
|
||||||
|
def clicked(self, button):
|
||||||
|
print "OpenButton clicked"
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
# 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)
|
|
@ -30,6 +30,15 @@ class Bar(gtk.VBox):
|
||||||
self.contents.pack_start(widget, expand, fill)
|
self.contents.pack_start(widget, expand, fill)
|
||||||
|
|
||||||
|
|
||||||
|
class FilterBar(Bar):
|
||||||
|
def __init__(self):
|
||||||
|
Bar.__init__(self, False)
|
||||||
|
global button
|
||||||
|
global libsaria
|
||||||
|
|
||||||
|
self.pack(button.OpenButton())
|
||||||
|
|
||||||
|
|
||||||
class InfoBar(Bar):
|
class InfoBar(Bar):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Bar.__init__(self, True)
|
Bar.__init__(self, True)
|
||||||
|
@ -58,11 +67,7 @@ def init():
|
||||||
|
|
||||||
import button
|
import button
|
||||||
info = InfoBar()
|
info = InfoBar()
|
||||||
filter = Bar(False)
|
filter = FilterBar()
|
||||||
|
|
||||||
label2 = gtk.Label("Top label")
|
|
||||||
label2.show()
|
|
||||||
filter.pack(label2, True, True)
|
|
||||||
|
|
||||||
|
|
||||||
def get_info():
|
def get_info():
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Bryan Schumake (9/10/2010)
|
||||||
|
|
||||||
|
import ocarina
|
||||||
|
from ocarina import fsselect
|
||||||
|
|
||||||
|
gtk = ocarina.gtk
|
||||||
|
|
||||||
|
chooser = gtk.FileChooserWidget()
|
||||||
|
chooser.show()
|
||||||
|
|
||||||
|
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||||
|
|
||||||
|
win.add(chooser)
|
||||||
|
win.show()
|
||||||
|
|
||||||
|
raw_input(">>>")
|
||||||
|
print chooser
|
||||||
|
#chooser = fsselect.make_chooser("Test Chooser", gtk.FILE_CHOOSER_ACTION_OPEN)
|
||||||
|
#fsselect.run_chooser(chooser)
|
Loading…
Reference in New Issue