diff --git a/emesene/gui/gtkui/ExtensionList.py b/emesene/gui/gtkui/ExtensionList.py index 5fce56da1..0084f81e1 100644 --- a/emesene/gui/gtkui/ExtensionList.py +++ b/emesene/gui/gtkui/ExtensionList.py @@ -198,9 +198,9 @@ def on_cursor_changed(self, list_view, type_, extra_button=None): '''called when a row is selected''' if extra_button is None: extra_button = self.no_button - model, iter_ = list_view.get_selection().get_selected() - if iter_ is not None: - value = model.get_value(iter_, 2) + + value = self.get_selected_name(list_view) + if value is not None: if value in self.download_list.get(type_, []): self.download_item = value self.download_button.show() @@ -209,6 +209,19 @@ def on_cursor_changed(self, list_view, type_, extra_button=None): self.download_button.hide() extra_button.show() + def get_selected_name(self, list_view=None): + '''Gets the current selected name in the list view.''' + if list_view is None: # Q: is this really necessary, same goes for L197's list_view + # TypeError: on_cursor_changed() takes at most 2 arguments (3 given) <-- where is this even coming from.. + list_view = self.list_view + + model, iter = list_view.get_selection().get_selected() + if iter is not None: + name = model.get_value(iter, 2) + return name + else: + return None # Q: should something be done here? + def on_change_source(self, combobox): '''called when the source is changed''' self.thc_cur_name = combobox.get_active_text() diff --git a/emesene/gui/gtkui/PluginWindow.py b/emesene/gui/gtkui/PluginWindow.py index 695f3d1a3..e95c16b8e 100644 --- a/emesene/gui/gtkui/PluginWindow.py +++ b/emesene/gui/gtkui/PluginWindow.py @@ -23,7 +23,7 @@ import e3 from pluginmanager import get_pluginmanager -from ExtensionList import ExtensionDownloadList +from ExtensionList import ExtensionDownloadList # uh.. is this safe? class PluginMainVBox(ExtensionDownloadList): def __init__(self, session, init_path): @@ -69,45 +69,42 @@ def on_toggled(self, widget, path, model, type_): def on_cursor_changed(self, list_view, type_='plugin'): '''called when a row is selected''' + ExtensionDownloadList.on_cursor_changed(self, list_view, type_, self.config_button) def on_start(self, *args): '''start the selected plugin''' - sel = self.list_view.get_selection() - model, iter = sel.get_selected() - if iter is not None: - name = model.get_value(iter, 2) + name = self.get_selected_name() + if name is not None: pluginmanager = get_pluginmanager() pluginmanager.plugin_start(name, self.session) if name not in self.session.config.l_active_plugins: self.session.config.l_active_plugins.append(name) + model, iter = self.list_view.get_selection().get_selected() model.set_value(iter, 0, bool(pluginmanager.plugin_is_active(name))) self.on_cursor_changed(self.list_view) def on_stop(self, *args): '''stop the selected plugin''' - sel = self.list_view.get_selection() - model, iter = sel.get_selected() - if iter is not None: - name = model.get_value(iter, 2) + name = self.get_selected_name() + if name is not None: pluginmanager = get_pluginmanager() pluginmanager.plugin_stop(name) if name in self.session.config.l_active_plugins: self.session.config.l_active_plugins.remove(name) + model, iter = self.list_view.get_selection().get_selected() model.set_value(iter, 0, pluginmanager.plugin_is_active(name)) + self.on_cursor_changed(self.list_view) def on_config(self, *args): '''Called when user hits the Preferences button''' - - sel = self.list_view.get_selection() - model, iter = sel.get_selected() - if iter is not None: - name = model.get_value(iter, 2) + name = self.get_selected_name() + if name is not None: pluginmanager = get_pluginmanager() if pluginmanager.plugin_is_active(name):