Add patch from MoMaT plus additional GUI code. Closes LP#1157422

This commit is contained in:
Stephen Boddy 2013-08-27 19:40:05 +02:00
commit c8b6268835
3 changed files with 60 additions and 2 deletions

View File

@ -3492,7 +3492,7 @@
<object class="GtkTable" id="table1"> <object class="GtkTable" id="table1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="n_rows">2</property> <property name="n_rows">3</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">12</property> <property name="column_spacing">12</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
@ -3557,6 +3557,31 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Working directoy</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="layout_profile_workingdir">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<signal name="changed" handler="on_layout_profile_workingdir_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@ -1265,6 +1265,10 @@ class PrefsEditor:
"""A different command has been entered for this item""" """A different command has been entered for this item"""
self.layouteditor.on_layout_profile_command_activate(widget) 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): def on_layout_name_edited(self, cell, path, newtext):
"""Update a layout name""" """Update a layout name"""
oldname = cell.get_property('text') oldname = cell.get_property('text')
@ -1458,6 +1462,13 @@ class LayoutEditor:
else: else:
widget.set_sensitive(True) 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): def on_layout_item_selection_changed(self, selection):
"""A different item in the layout was selected""" """A different item in the layout was selected"""
(treemodel, rowiter) = selection.get_selected() (treemodel, rowiter) = selection.get_selected()
@ -1473,14 +1484,17 @@ class LayoutEditor:
layout_item = layout[self.layout_item] layout_item = layout[self.layout_item]
command = self.builder.get_object('layout_profile_command') command = self.builder.get_object('layout_profile_command')
chooser = self.builder.get_object('layout_profile_chooser') chooser = self.builder.get_object('layout_profile_chooser')
workdir = self.builder.get_object('layout_profile_workingdir')
if layout_item['type'] != 'Terminal': if layout_item['type'] != 'Terminal':
command.set_sensitive(False) command.set_sensitive(False)
chooser.set_sensitive(False) chooser.set_sensitive(False)
workdir.set_sensitive(False)
return return
command.set_sensitive(True) command.set_sensitive(True)
chooser.set_sensitive(True) chooser.set_sensitive(True)
workdir.set_sensitive(True)
if layout_item.has_key('command') and layout_item['command'] != '': if layout_item.has_key('command') and layout_item['command'] != '':
command.set_text(layout_item['command']) command.set_text(layout_item['command'])
else: else:
@ -1491,6 +1505,11 @@ class LayoutEditor:
else: else:
chooser.set_active(0) 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): def on_layout_profile_chooser_changed(self, widget):
"""A new profile has been selected for this item""" """A new profile has been selected for this item"""
if not self.layout_item: if not self.layout_item:
@ -1507,6 +1526,13 @@ class LayoutEditor:
layout[self.layout_item]['command'] = command layout[self.layout_item]['command'] = command
self.config.save() 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__': if __name__ == '__main__':
import util import util
util.DEBUG = True util.DEBUG = True

View File

@ -95,6 +95,7 @@ class Terminal(gtk.VBox):
custom_encoding = None custom_encoding = None
custom_font_size = None custom_font_size = None
layout_command = None layout_command = None
directory = None
fgcolor_active = None fgcolor_active = None
fgcolor_inactive = None fgcolor_inactive = None
@ -1259,7 +1260,11 @@ class Terminal(gtk.VBox):
details[1])) details[1]))
command = 'telnet %s %s' % (details[0], 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 != '': options.working_directory != '':
self.set_cwd(options.working_directory) self.set_cwd(options.working_directory)
options.working_directory = '' options.working_directory = ''
@ -1502,6 +1507,8 @@ class Terminal(gtk.VBox):
self.really_create_group(self.titlebar, layout['group']) self.really_create_group(self.titlebar, layout['group'])
if layout.has_key('title') and layout['title'] != '': if layout.has_key('title') and layout['title'] != '':
self.titlebar.set_custom_string(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): def scroll_by_page(self, pages):
"""Scroll up or down in pages""" """Scroll up or down in pages"""