From 2fee267dfee11bd687b4d780cb6b82924d59af3c Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <koslowski@kit.edu> Date: Thu, 23 Jul 2015 16:36:22 +0200 Subject: grc: open and update params from external editor --- grc/gui/Dialogs.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'grc/gui/Dialogs.py') diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index 6c01219dee..631dc0fd98 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -20,8 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import pygtk pygtk.require('2.0') import gtk -import Utils -import Actions + +from . import Utils, Actions, Constants class SimpleTextDisplay(gtk.TextView): @@ -234,3 +234,22 @@ def MissingXTermDialog(xterm): "\n" "(This message is shown only once)").format(xterm) ) + + +def ChooseEditorDialog(): + file_dialog = gtk.FileChooserDialog( + 'Open a Data File...', None, + gtk.FILE_CHOOSER_ACTION_OPEN, + ('gtk-cancel', gtk.RESPONSE_CANCEL, 'gtk-open', gtk.RESPONSE_OK) + ) + file_dialog.set_select_multiple(False) + file_dialog.set_local_only(True) + file_dialog.set_current_folder('/usr/bin') + response = file_dialog.run() + + if response == gtk.RESPONSE_OK: + file_path = file_dialog.get_filename() + Constants.prefs.set_string('grc', 'editor', file_path) + Constants.prefs.save() + Constants.EDITOR = file_path + file_dialog.destroy() -- cgit v1.2.3