From 7e85451343612be71b2e2b707a7861c75f55250a Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Tue, 27 Aug 2013 19:22:00 +0200 Subject: [PATCH 1/2] Original layout working directory patch by MoMaT --- terminatorlib/terminal.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 00611b42..8f5eaf73 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -95,6 +95,7 @@ class Terminal(gtk.VBox): custom_encoding = None custom_font_size = None layout_command = None + directory = None fgcolor_active = None fgcolor_inactive = None @@ -1259,7 +1260,11 @@ class Terminal(gtk.VBox): details[1])) command = 'telnet %s %s' % (details[0], details[1]) - if options and options.working_directory and \ + # working directory set in layout config + if self.directory: + self.set_cwd(self.directory) + # working directory given as argument + elif options and options.working_directory and \ options.working_directory != '': self.set_cwd(options.working_directory) options.working_directory = '' @@ -1502,6 +1507,8 @@ class Terminal(gtk.VBox): self.really_create_group(self.titlebar, layout['group']) if layout.has_key('title') and layout['title'] != '': self.titlebar.set_custom_string(layout['title']) + if layout.has_key('directory') and layout['directory'] != '': + self.directory = layout['directory'] def scroll_by_page(self, pages): """Scroll up or down in pages""" From f49e8a2356781dde0ceb1c0e97b033bde207adce Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Tue, 27 Aug 2013 19:22:57 +0200 Subject: [PATCH 2/2] Additional GUI code to use working dirs --- terminatorlib/preferences.glade | 27 ++++++++++++++++++++++++++- terminatorlib/prefseditor.py | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 4db13347..aad9ba1c 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -3492,7 +3492,7 @@ True False - 2 + 3 2 12 6 @@ -3557,6 +3557,31 @@ + + + True + False + Working directoy + + + 2 + 3 + + + + + True + True + + + + + 1 + 2 + 2 + 3 + + diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index c2b7330d..46c4aca5 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -1265,6 +1265,10 @@ class PrefsEditor: """A different command has been entered for this item""" self.layouteditor.on_layout_profile_command_activate(widget) + def on_layout_profile_workingdir_changed(self, widget): + """A different working directory has been entered for this item""" + self.layouteditor.on_layout_profile_workingdir_activate(widget) + def on_layout_name_edited(self, cell, path, newtext): """Update a layout name""" oldname = cell.get_property('text') @@ -1458,6 +1462,13 @@ class LayoutEditor: else: widget.set_sensitive(True) + command = self.builder.get_object('layout_profile_command') + chooser = self.builder.get_object('layout_profile_chooser') + workdir = self.builder.get_object('layout_profile_workingdir') + command.set_sensitive(False) + chooser.set_sensitive(False) + workdir.set_sensitive(False) + def on_layout_item_selection_changed(self, selection): """A different item in the layout was selected""" (treemodel, rowiter) = selection.get_selected() @@ -1473,14 +1484,17 @@ class LayoutEditor: layout_item = layout[self.layout_item] command = self.builder.get_object('layout_profile_command') chooser = self.builder.get_object('layout_profile_chooser') + workdir = self.builder.get_object('layout_profile_workingdir') if layout_item['type'] != 'Terminal': command.set_sensitive(False) chooser.set_sensitive(False) + workdir.set_sensitive(False) return command.set_sensitive(True) chooser.set_sensitive(True) + workdir.set_sensitive(True) if layout_item.has_key('command') and layout_item['command'] != '': command.set_text(layout_item['command']) else: @@ -1491,6 +1505,11 @@ class LayoutEditor: else: chooser.set_active(0) + if layout_item.has_key('directory') and layout_item['directory'] != '': + workdir.set_text(layout_item['directory']) + else: + workdir.set_text('') + def on_layout_profile_chooser_changed(self, widget): """A new profile has been selected for this item""" if not self.layout_item: @@ -1507,6 +1526,13 @@ class LayoutEditor: layout[self.layout_item]['command'] = command self.config.save() + def on_layout_profile_workingdir_activate(self, widget): + """A new working directory has been entered for this item""" + workdir = widget.get_text() + layout = self.config.layout_get_config(self.layout_name) + layout[self.layout_item]['directory'] = workdir + self.config.save() + if __name__ == '__main__': import util util.DEBUG = True