Additional GUI code to use working dirs

This commit is contained in:
Stephen Boddy 2013-08-27 19:22:57 +02:00
parent 7e85451343
commit f49e8a2356
2 changed files with 52 additions and 1 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