Skip to content
Snippets Groups Projects
Commit 74b6ba5c authored by Dicson's avatar Dicson
Browse files

coding style

parent 3b860457
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,15 @@ from plugins.helpers import log_calls, log ...@@ -36,6 +36,15 @@ from plugins.helpers import log_calls, log
from plugins.helpers import GajimPluginActivateException from plugins.helpers import GajimPluginActivateException
from common.exceptions import PluginsystemError from common.exceptions import PluginsystemError
(
PLUGIN,
NAME,
ACTIVE,
ACTIVATABLE,
ICON,
) = range(5)
class PluginsWindow(object): class PluginsWindow(object):
'''Class for Plugins window''' '''Class for Plugins window'''
...@@ -65,12 +74,13 @@ class PluginsWindow(object): ...@@ -65,12 +74,13 @@ class PluginsWindow(object):
self.installed_plugins_treeview.set_rules_hint(True) self.installed_plugins_treeview.set_rules_hint(True)
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
col = gtk.TreeViewColumn(_('Plugin'), renderer, text=1) col = gtk.TreeViewColumn(_('Plugin'), renderer, text=NAME)
self.installed_plugins_treeview.append_column(col) self.installed_plugins_treeview.append_column(col)
renderer = gtk.CellRendererToggle() renderer = gtk.CellRendererToggle()
renderer.connect('toggled', self.installed_plugins_toggled_cb) renderer.connect('toggled', self.installed_plugins_toggled_cb)
col = gtk.TreeViewColumn(_('Active'), renderer, active=2, activatable=3) col = gtk.TreeViewColumn(_('Active'), renderer, active=ACTIVE,
activatable=ACTIVATABLE)
self.installed_plugins_treeview.append_column(col) self.installed_plugins_treeview.append_column(col)
# connect signal for selection change # connect signal for selection change
...@@ -99,9 +109,9 @@ class PluginsWindow(object): ...@@ -99,9 +109,9 @@ class PluginsWindow(object):
def installed_plugins_treeview_selection_changed(self, treeview_selection): def installed_plugins_treeview_selection_changed(self, treeview_selection):
model, iter = treeview_selection.get_selected() model, iter = treeview_selection.get_selected()
if iter: if iter:
plugin = model.get_value(iter, 0) plugin = model.get_value(iter, PLUGIN)
plugin_name = model.get_value(iter, 1) plugin_name = model.get_value(iter, NAME)
is_active = model.get_value(iter, 2) is_active = model.get_value(iter, ACTIVE)
self._display_installed_plugin_info(plugin) self._display_installed_plugin_info(plugin)
else: else:
...@@ -157,8 +167,8 @@ class PluginsWindow(object): ...@@ -157,8 +167,8 @@ class PluginsWindow(object):
@log_calls('PluginsWindow') @log_calls('PluginsWindow')
def installed_plugins_toggled_cb(self, cell, path): def installed_plugins_toggled_cb(self, cell, path):
is_active = self.installed_plugins_model[path][2] is_active = self.installed_plugins_model[path][ACTIVE]
plugin = self.installed_plugins_model[path][0] plugin = self.installed_plugins_model[path][PLUGIN]
if is_active: if is_active:
gajim.plugin_manager.deactivate_plugin(plugin) gajim.plugin_manager.deactivate_plugin(plugin)
...@@ -170,7 +180,7 @@ class PluginsWindow(object): ...@@ -170,7 +180,7 @@ class PluginsWindow(object):
transient_for=self.window) transient_for=self.window)
return return
self.installed_plugins_model[path][2] = not is_active self.installed_plugins_model[path][ACTIVE] = not is_active
@log_calls('PluginsWindow') @log_calls('PluginsWindow')
def on_plugins_window_destroy(self, widget): def on_plugins_window_destroy(self, widget):
...@@ -187,9 +197,9 @@ class PluginsWindow(object): ...@@ -187,9 +197,9 @@ class PluginsWindow(object):
selection = self.installed_plugins_treeview.get_selection() selection = self.installed_plugins_treeview.get_selection()
model, iter = selection.get_selected() model, iter = selection.get_selected()
if iter: if iter:
plugin = model.get_value(iter, 0) plugin = model.get_value(iter, PLUGIN)
plugin_name = model.get_value(iter, 1) plugin_name = model.get_value(iter, NAME)
is_active = model.get_value(iter, 2) is_active = model.get_value(iter, ACTIVE)
result = plugin.config_dialog.run(self.window) result = plugin.config_dialog.run(self.window)
...@@ -205,9 +215,9 @@ class PluginsWindow(object): ...@@ -205,9 +215,9 @@ class PluginsWindow(object):
selection = self.installed_plugins_treeview.get_selection() selection = self.installed_plugins_treeview.get_selection()
model, iter = selection.get_selected() model, iter = selection.get_selected()
if iter: if iter:
plugin = model.get_value(iter, 0) plugin = model.get_value(iter, PLUGIN)
plugin_name = model.get_value(iter, 1).decode('utf-8') plugin_name = model.get_value(iter, NAME).decode('utf-8')
is_active = model.get_value(iter, 2) is_active = model.get_value(iter, ACTIVE)
try: try:
gajim.plugin_manager.remove_plugin(plugin) gajim.plugin_manager.remove_plugin(plugin)
except PluginsystemError, e: except PluginsystemError, e:
...@@ -234,8 +244,8 @@ class PluginsWindow(object): ...@@ -234,8 +244,8 @@ class PluginsWindow(object):
model = self.installed_plugins_model model = self.installed_plugins_model
for row in xrange(len(model)): for row in xrange(len(model)):
if plugin == model[row][0]: if plugin == model[row][PLUGIN]:
model.remove(model.get_iter((row, 0))) model.remove(model.get_iter((row, PLUGIN)))
break break
iter_ = model.append([plugin, plugin.name, False, iter_ = model.append([plugin, plugin.name, False,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment