def _setup(self): """register core extensions""" extension.category_register("session", msn.Session, single_instance=True) extension.register("session", jabber.Session) extension.register("session", dummy.Session) extension.register("session", msn.Session) if papylib is not None: extension.register("session", papylib.Session) extension.set_default("session", papylib.Session) else: extension.set_default("session", msn.Session) extension.category_register("sound", e3.common.play_sound.play) extension.category_register("notification", e3.common.notification.Notification) extension.category_register("history exporter", e3.Logger.save_logs_as_txt) if self.config.session is None: default_id = extension.get_category("session").default_id self.config.session = default_id else: default_id = self.config.session extension.set_default_by_id("session", default_id) get_pluginmanager().scan_directory("plugins")
def _setup(self): '''register core extensions''' extension.category_register('session', msn.Session, single_instance=True) extension.register('session', jabber.Session) extension.register('session', dummy.Session) if papylib is not None: extension.register('session', papylib.Session) extension.set_default('session', papylib.Session) extension.category_register('sound', e3.common.play_sound.play) extension.category_register('notification', e3.common.notification.Notification) extension.category_register('history exporter', e3.Logger.save_logs_as_txt) if self.config.session is None: default_id = extension.get_category('session').default_id self.config.session = default_id else: default_id = self.config.session extension.set_default_by_id('session', default_id) get_pluginmanager().scan_directory('plugins')
def on_config(self, *args): '''Called when user hits the Preferences button''' pluginmanager = get_pluginmanager() name = self.get_selected_name(self.list_view) if name and pluginmanager.plugin_is_active(name): pluginmanager.plugin_config(name, self.session)
def on_login_succeed(self): '''callback called on login succeed''' self._save_login_dimensions() self.config.save(self.config_path) plugin_manager = get_pluginmanager() plugin_manager.scan_directory('plugins') plugin_dir = self.config_dir.join('plugins') if not os.path.exists(plugin_dir): os.makedirs(plugin_dir) plugin_manager.scan_directory(plugin_dir) self.draw_main_screen() self.session.config.get_or_set('l_active_plugins', []) for plugin in self.session.config.l_active_plugins: plugin_manager.plugin_start(plugin, self.session) # hack: where do we start this? how do we generalize for other # extensions? if plugin == "music": extension.get_and_instantiate('listening to', self.window.content) self.set_default_extensions_from_config() self._sync_emesene1() self.logged_in = True if self.network_checker is not None: self.network_checker.set_new_session(self.session)
def update_list(self): pluginmanager = get_pluginmanager() self.clear() for name in pluginmanager.get_plugins(): self.append((pluginmanager.plugin_is_active(name), self.prettify_name(name), name))
def on_cursor_changed(self, list_view, type_='plugin'): '''called when a row is selected''' name = self.get_selected_name(self.list_view) pluginmanager = get_pluginmanager() self.config_button.set_sensitive(pluginmanager.plugin_configurable(name)) DownloadList.on_cursor_changed(self, list_view, type_, self.config_button)
def on_start(self, name): '''start the selected plugin''' 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) self.on_cursor_changed(self.list_view)
def on_config(self, *args): '''stop the selected plugin''' sel = self.plugin_list_view.get_selection() model, iter = sel.get_selected() name = model.get_value(iter, 2) pluginmanager = get_pluginmanager() if pluginmanager.plugin_is_active(name): pluginmanager.plugin_config(name, self.session)
def on_stop(self, *args): '''stop the selected plugin''' sel = self.plugin_list_view.get_selection() model, iter = sel.get_selected() name = model.get_value(iter, 2) pluginmanager = get_pluginmanager() pluginmanager.plugin_stop(name) print pluginmanager.plugin_is_active(name), 'after stop' model.set_value(iter, 0, pluginmanager.plugin_is_active(name))
def on_start(self, *args): '''start the selected plugin''' sel = self.plugin_list_view.get_selection() model, iter = sel.get_selected() name = model.get_value(iter, 2) pluginmanager = get_pluginmanager() pluginmanager.plugin_start(name, self.session) print pluginmanager.plugin_is_active(name), 'after start' model.set_value(iter, 0, bool(pluginmanager.plugin_is_active(name)))
def on_stop(self, name): '''stop the selected plugin''' pluginmanager = get_pluginmanager() pluginmanager.plugin_stop(name) if name in self.session.config.l_active_plugins: self.session.config.l_active_plugins.remove(name) self.on_cursor_changed(self.list_view)
def on_update(self, widget=None, download=False, clear=False): if self.first or download or clear: self.clear_all() self.append(False, '<b>Installed</b>', 'installed', True, False) pluginmanager = get_pluginmanager() for name in pluginmanager.get_plugins(): self.append(pluginmanager.plugin_is_active(name), self.list_store.prettify_name(name, pluginmanager.plugin_description(name)), name) ExtensionDownloadList.on_update(self, widget, download, clear)
def on_toggled(self, widget, path, model, type_): '''called when the toggle button in list view is pressed''' pluginmanager = get_pluginmanager() name = model[path][2] if not model[path][0]: self.on_start(name) self.removable_list[type_].pop(name, None) else: self.on_stop(name) if model[path][5].startswith(self.config_dir.base_dir): self.removable_list[type_][name] = model[path][5] model[path][0] = pluginmanager.plugin_is_active(name)
def on_stop(self, *args): '''stop the selected plugin''' sel = self.plugin_list_view.get_selection() model, iter = sel.get_selected() if iter != None: name = model.get_value(iter, 2) 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.set_value(iter, 0, pluginmanager.plugin_is_active(name))
def on_start(self, *args): '''start the selected plugin''' name = self.get_selected_name(self.list_view) 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_start(self, *args): '''start the selected plugin''' sel = self.plugin_list_view.get_selection() model, iter = sel.get_selected() if iter != None: name = model.get_value(iter, 2) 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.set_value(iter, 0, bool(pluginmanager.plugin_is_active(name)))
def _setup_plugins(self): plugin_manager = get_pluginmanager() plugin_manager.scan_directory('plugins') plugin_dir = self.config_dir.join('plugins') if not os.path.exists(plugin_dir): os.makedirs(plugin_dir) plugin_manager.scan_directory(plugin_dir) self.session.config.get_or_set('l_active_plugins', []) for plugin in self.session.config.l_active_plugins: plugin_manager.plugin_start(plugin, self.session) self.set_default_extensions_from_config() self.window.content.replace_extensions()
def on_stop(self, *args): '''stop the selected plugin''' name = self.get_selected_name(self.list_view) 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 manipulate_plugin(self, name, func): '''Starts a plugin given a name name is the name of the plugin func is the code that can manipulate the plugin the func function takes a pluginmanager object.''' if name is not None: pluginmanager = get_pluginmanager() func(pluginmanager) model, iter = self.list_view.get_selection().get_selected() model.set_value(iter, 0, bool(pluginmanager.plugin_is_active(name))) return True return False
def show_update(self): '''called when the liststore need to be changed''' self.clear_all() self.update_amount = 0 for theme_type in self.themes.iterkeys(): first = True if theme_type not in self.update_list['themes']: self.update_list['themes'][theme_type] = {} for path in self.themes[theme_type].list(): if not self.check_updates('themes', theme_type, path): continue if first: self.append(False, '<b>' + self.theme_names[theme_type] + '</b>', theme_type, visible=False) first = False name = os.path.basename(path) label = self.themes[theme_type].get_name_from_path(path) self.update_list['themes'][theme_type][name] = path self.update_amount += 1 self.append(True, label, name, path=path, type_=theme_type) pluginmanager = get_pluginmanager() first = True if 'plugin' not in self.update_list['plugins']: self.update_list['plugins']['plugin'] = {} for name, plugin in pluginmanager.get_plugins(): path = plugin.path if not self.check_updates('plugins', 'plugin', path, plugin): continue if first: self.append(False, '<b>' + _('Plugins') + '</b>', 'installed', True, False) first = False self.update_list['plugins']['plugin'][name] = path self.update_amount += 1 self.append( True, self.prettify_name( name, description=pluginmanager.plugin_description(name)), name, path=path, type_='plugin')
def show_update(self): '''called when the liststore need to be changed''' self.removable_list = {} self.removable_list['plugin'] = {} self.clear_all() self.append(False, _('Installed'), 'installed', True, False) pluginmanager = get_pluginmanager() for name, plugin in pluginmanager.get_plugins(): is_active = pluginmanager.plugin_is_active(name) path = plugin.path if path.startswith(self.config_dir.base_dir) and not is_active: self.removable_list['plugin'][name] = path self.append(is_active, name, name, path=path, description=pluginmanager.plugin_description(name)) DownloadList.show_update(self)
def _setup_plugins(self): plugin_manager = get_pluginmanager() plugin_manager.scan_directory('plugins') plugin_dir = self.config_dir.join('plugins') if not os.path.exists(plugin_dir): os.makedirs(plugin_dir) plugin_manager.scan_directory(plugin_dir) self.session.config.get_or_set('l_active_plugins', []) for plugin in self.session.config.l_active_plugins: plugin_manager.plugin_start(plugin, self.session) # hack: where do we start this? how do we generalize for other # extensions? if plugin == "music" and self.window.content != None: extension.get_and_instantiate('listening to', self.window.content) self.set_default_extensions_from_config()
def on_login_succeed(self): '''callback called on login succeed''' self._save_login_dimensions() self.config.save(self.config_path) plugin_manager = get_pluginmanager() plugin_manager.scan_directory('plugins') self.draw_main_screen() for plugin in self.session.config.l_active_plugins: plugin_manager.plugin_start(plugin, self.session) # hack: where do we start this? how do we generalize for other # extensions? if plugin == "music": extension.get_and_instantiate('listening to', self.window.content) self.set_default_extensions_from_config()
def on_update(self, widget=None, download=False, clear=False): '''called when the liststore need to be changed''' self.removable_list = {} self.removable_list['plugin'] = {} if self.first or download or clear: self.clear_all() self.append(False, _('Installed'), 'installed', True, False) pluginmanager = get_pluginmanager() for name, plugin in pluginmanager.get_plugins(): is_active = pluginmanager.plugin_is_active(name) path = plugin.path if path.startswith(self.config_dir.base_dir) and not is_active: self.removable_list['plugin'][name] = path self.append(is_active, name, name, path=path, description=pluginmanager.plugin_description(name)) ExtensionDownloadList.on_update(self, widget, download, clear)
def show_update(self): '''called when the liststore need to be changed''' self.clear_all() self.update_amount = 0 for theme_type in self.themes.iterkeys(): first = True if theme_type not in self.update_list['themes']: self.update_list['themes'][theme_type] = {} for path in self.themes[theme_type].list(): if not self.check_updates('themes', theme_type, path): continue if first: self.append(False, '<b>'+self.theme_names[theme_type]+'</b>', theme_type, visible=False) first = False name = os.path.basename(path) label = self.themes[theme_type].get_name_from_path(path) self.update_list['themes'][theme_type][name] = path self.update_amount += 1 self.append(True, label, name, path=path, type_=theme_type) pluginmanager = get_pluginmanager() first = True if 'plugin' not in self.update_list['plugins']: self.update_list['plugins']['plugin'] = {} for name, plugin in pluginmanager.get_plugins(): path = plugin.path if not self.check_updates('plugins', 'plugin', path, plugin): continue if first: self.append(False, '<b>' + _('Plugins') + '</b>', 'installed', True, False) first = False self.update_list['plugins']['plugin'][name] = path self.update_amount += 1 self.append(True, self.prettify_name(name, description=pluginmanager.plugin_description(name)), name, path=path, type_='plugin')