From e50e1d1d4754294ff08ad3fbafaffd3752f4fa3e Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 20 Jan 2008 16:11:42 +0000 Subject: [PATCH] Use --ui=rox to select ROX user interface. --- lib/reinteract/main.py | 31 ++++++++++++++++++++++++---- lib/reinteract/{rox_adaptor.py => rox_ui.py} | 2 +- 2 files changed, 28 insertions(+), 5 deletions(-) rename lib/reinteract/{rox_adaptor.py => rox_ui.py} (88%) diff --git a/lib/reinteract/main.py b/lib/reinteract/main.py index 1cd43d1..541d07a 100644 --- a/lib/reinteract/main.py +++ b/lib/reinteract/main.py @@ -13,12 +13,13 @@ from optparse import OptionParser usage = "usage: %prog [options]" op = OptionParser(usage=usage) -op.add_option("-u", "--ui", type="choice", choices=("standard", "hildon"), - default="standard", help=("which user interface to use (standard or " +op.add_option("-u", "--ui", type="choice", choices=("standard", "hildon", "rox"), + default="standard", help=("which user interface to use (standard, rox or " "hildon), default=%default")) options, args = op.parse_args() use_hildon = False +use_rox = False if options.ui == "hildon": try: @@ -26,6 +27,9 @@ if options.ui == "hildon": use_hildon = True except ImportError, e: print "Error importing hildon. Falling back to standard ui." +elif options.ui == "rox": + import rox_ui + use_rox = True notebook = Notebook() @@ -150,8 +154,27 @@ def on_save(action): buf.save() def save_as(): - from reinteract.rox_adaptor import save_with_rox_savebox - save_with_rox_savebox(buf) + if use_rox: + rox_ui.save_with_rox_savebox(buf) + return + + if use_hildon: + chooser = hildon.FileChooserDialog(w, gtk.FILE_CHOOSER_ACTION_SAVE) + else: + chooser = gtk.FileChooserDialog("Save As...", w, gtk.FILE_CHOOSER_ACTION_SAVE, + (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_SAVE, gtk.RESPONSE_OK)) + chooser.set_default_response(gtk.RESPONSE_OK) + response = chooser.run() + filename = None + if response == gtk.RESPONSE_OK: + filename = chooser.get_filename() + + if filename != None: + buf.save(filename) + notebook.set_path([os.path.dirname(os.path.abspath(filename))]) + + chooser.destroy() def on_save_as(action): save_as() diff --git a/lib/reinteract/rox_adaptor.py b/lib/reinteract/rox_ui.py similarity index 88% rename from lib/reinteract/rox_adaptor.py rename to lib/reinteract/rox_ui.py index 0915bc2..a70d113 100644 --- a/lib/reinteract/rox_adaptor.py +++ b/lib/reinteract/rox_ui.py @@ -1,7 +1,7 @@ from rox import saving class ShellBufferSaveable(saving.Saveable): - """Adapt ShellBuffer to ROX saving protocol.""" + """Save a ShellBuffer using the ROX saving protocol.""" def __init__(self, buf): self.buf = buf -- 2.11.4.GIT