Switch the plugin enabling/disabling to not work online, but to save the state for later

This commit is contained in:
Chris Jones 2010-06-21 22:44:09 +01:00
parent 51fe811b85
commit 70a66ee218
2 changed files with 50 additions and 31 deletions

View File

@ -2865,32 +2865,51 @@
<object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<child>
<object class="GtkTreeView" id="pluginlist">
<object class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">PluginListStore</property>
<property name="hadjustment">adjustment2</property>
<property name="vadjustment">adjustment3</property>
<property name="search_column">0</property>
<child>
<object class="GtkTreeViewColumn" id="plugincolumn1">
<property name="title">Plugin</property>
<property name="clickable">True</property>
<object class="GtkTreeView" id="pluginlist">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">PluginListStore</property>
<property name="hadjustment">adjustment2</property>
<property name="vadjustment">adjustment3</property>
<property name="search_column">0</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderertext15">
<signal name="toggled" handler="on_plugin_toggled"/>
<object class="GtkTreeViewColumn" id="plugincolumn1">
<property name="title">Plugin</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderertext15">
<signal name="toggled" handler="on_plugin_toggled"/>
</object>
<attributes>
<attribute name="active">1</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="cellrenderertext16"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<attributes>
<attribute name="active">1</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="cellrenderertext16"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Plugins will be enabled/disabled after restarting Terminator</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>

View File

@ -28,6 +28,7 @@ class PrefsEditor:
"""Class implementing the various parts of the preferences editor"""
config = None
registry = None
plugins = None
keybindings = None
window = None
builder = None
@ -266,11 +267,15 @@ class PrefsEditor:
widget = guiget('pluginlist')
liststore = widget.get_model()
self.registry = PluginRegistry()
plugins = self.registry.get_available_plugins()
self.pluginiters = {}
for plugin in plugins:
pluginlist = self.registry.get_available_plugins()
self.plugins = {}
for plugin in pluginlist:
self.plugins[plugin] = self.registry.is_enabled(plugin)
for plugin in self.plugins:
self.pluginiters[plugin] = liststore.append([plugin,
self.registry.is_enabled(plugin)])
self.plugins[plugin]])
selection = widget.get_selection()
selection.connect('changed', self.on_plugin_selection_changed)
if len(self.pluginiters) > 0:
@ -1020,16 +1025,11 @@ class PrefsEditor:
model = treeview.get_model()
plugin = model[path][0]
state = self.registry.is_enabled(plugin)
if state:
self.registry.disable(plugin)
else:
self.registry.enable(plugin)
state = self.registry.is_enabled(plugin)
self.plugins[plugin] = not self.plugins[plugin]
# Update the treeview
model[path][1] = state
model[path][1] = self.plugins[plugin]
enabled_plugins = self.registry.get_all_plugins().keys()
enabled_plugins = [x for x in self.plugins if self.plugins[x] == True]
self.config['enabled_plugins'] = enabled_plugins
self.config.save()