def testPropertiesDialog(self): '''Test PropertiesDialog''' from zim.gui.propertiesdialog import PropertiesDialog self.ui.readonly = True dialog = PropertiesDialog(self.ui) dialog.assert_response_ok() from zim.config import INIConfigFile notebook = self.ui.notebook file = notebook.dir.file('notebook.zim') notebook.config = NotebookConfig(file) self.ui.readonly = False config1 = { 'name': 'Notebook Foo', 'interwiki': None, 'home': Path('Home'), 'icon': './icon.png', 'document_root': File('/foo').path, # win32 save test 'shared': False, 'profile': None, } config2 = { 'name': 'Notebook Bar', 'interwiki': 'FooBar', 'home': Path('HomeSweetHome'), 'icon': './picture.png', 'document_root': File('/bar').path, # win32 save test 'shared': True, 'profile': 'foo', } notebook.save_properties(**config1) for key in config1: self.assertEqual(notebook.config['Notebook'][key], config1[key]) dialog = PropertiesDialog(self.ui) dialog.assert_response_ok() for key in config1: self.assertEqual(notebook.config['Notebook'][key], config1[key]) self.assertEqual(notebook.name, config1['name']) self.assertEqual(notebook.get_home_page(), config1['home']) self.assertEqual(notebook.icon, notebook.dir.file(config1['icon']).path) self.assertEqual(notebook.document_root, Dir(config1['document_root'])) dialog = PropertiesDialog(self.ui) dialog.form.update(config2) dialog.assert_response_ok() for key in config1: self.assertEqual(notebook.config['Notebook'][key], config2[key]) self.assertEqual(notebook.name, config2['name']) self.assertEqual(notebook.get_home_page(), config2['home']) self.assertEqual(notebook.icon, notebook.dir.file(config2['icon']).path) self.assertEqual(notebook.document_root, Dir(config2['document_root']))
def show_properties(self): '''Menu action to show the L{PropertiesDialog}''' from zim.gui.propertiesdialog import PropertiesDialog PropertiesDialog(self.widget, self.notebook).run() # Changing plugin properties can modify the index state if not self.notebook.index.is_uptodate: self.reload_index(update_only=True)
def runTest(self): manager = PluginManager() preferences = manager.config.get_config_dict( '<profile>/preferences.conf') self.assertFalse(preferences.modified) for name in list_plugins(): klass = get_plugin_class(name) if klass.check_dependencies_ok(): manager.load_plugin(name) self.assertIn(name, manager) self.assertFalse( preferences.modified, 'Plugin "%s" modified the preferences while loading' % name) self.assertTrue(len(manager) > 3) for i, name in enumerate(manager): manager[name].preferences.emit('changed') # Checking for exceptions and infinite recursion self.assertTrue(i > 0) #~ self.assertTrue(preferences.modified) # If "False" the check while loading the plugins is not valid # FIXME this detection is broken due to autosave in ConfigManager ... notebook = tests.new_notebook(self.get_tmp_name()) ui = setupGtkInterface(self, notebook=notebook) dialog = PropertiesDialog(ui) # random dialog for obj in ( notebook, notebook.index, ui.mainwindow, ui.mainwindow.pageview, dialog, ): manager.extend(obj) for i, name in enumerate(manager): manager[name].preferences.emit('changed') # Checking for exceptions and infinite recursion for name in manager: #~ print "REMOVE:", name self.assertIsInstance(manager[name], PluginClass) manager.remove_plugin(name) self.assertNotIn(name, manager) self.assertTrue(len(manager) == 0)
def testPropertiesDialog(self): '''Test PropertiesDialog''' from zim.gui.propertiesdialog import PropertiesDialog self.ui.readonly = True dialog = PropertiesDialog(self.ui) dialog.assert_response_ok() from zim.config import INIConfigFile notebook = self.ui.notebook file = notebook.dir.file('notebook.zim') notebook.config = NotebookConfig(file) self.ui.readonly = False config1 = { 'name': 'Notebook Foo', 'interwiki': None, 'home': Path('Home'), 'icon': './icon.png', 'document_root': File('/foo').path, # win32 save test 'profile': None, } config2 = { 'name': 'Notebook Bar', 'interwiki': 'FooBar', 'home': Path('HomeSweetHome'), 'icon': './picture.png', 'document_root': File('/bar').path, # win32 save test 'profile': 'foo', } notebook.save_properties(**config1) for key in config1: self.assertEqual(notebook.config['Notebook'][key], config1[key]) dialog = PropertiesDialog(self.ui) dialog.assert_response_ok() for key in config1: self.assertEqual(notebook.config['Notebook'][key], config1[key]) self.assertEqual(notebook.name, config1['name']) self.assertEqual(notebook.get_home_page(), config1['home']) self.assertEqual(notebook.icon, notebook.dir.file(config1['icon']).path) self.assertEqual(notebook.document_root, Dir(config1['document_root'])) dialog = PropertiesDialog(self.ui) dialog.form.update(config2) dialog.assert_response_ok() for key in config1: self.assertEqual(notebook.config['Notebook'][key], config2[key]) self.assertEqual(notebook.name, config2['name']) self.assertEqual(notebook.get_home_page(), config2['home']) self.assertEqual(notebook.icon, notebook.dir.file(config2['icon']).path) self.assertEqual(notebook.document_root, Dir(config2['document_root']))
def show_properties(self): '''Menu action to show the L{PropertiesDialog}''' from zim.gui.propertiesdialog import PropertiesDialog PropertiesDialog(self.widget, self.config, self.notebook).run()
def on_properties_button_clicked(self, button): from zim.gui.propertiesdialog import PropertiesDialog PropertiesDialog(self.dialog.main_window, self.dialog.main_window.notebook, chosen_plugin=self._current_plugin).run()