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

@ -2863,6 +2863,9 @@
</child> </child>
<child> <child>
<object class="GtkHBox" id="hbox7"> <object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<child>
<object class="GtkVBox" id="vbox12">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkTreeView" id="pluginlist"> <object class="GtkTreeView" id="pluginlist">
@ -2897,6 +2900,22 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </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>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="pluginpanelabel"> <object class="GtkLabel" id="pluginpanelabel">
<property name="visible">True</property> <property name="visible">True</property>

View File

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