Exemple #1
0
 def plugin_info(button):
     from zim.gui.preferencesdialog import PreferencesDialog
     dialog = PreferencesDialog(self.ui,
                                "Plugins",
                                select_plugin=name)
     dialog.run()
     self.ui.reload_page()
Exemple #2
0
	def testSetSimpleValue(self):
		preferences = ConfigManager.get_config_dict('preferences.conf')
		window = MyWindow()

		dialog = PreferencesDialog(window)
		self.assertEqual(dialog.forms['Interface']['toggle_on_ctrlspace'], False)
		dialog.assert_response_ok()
		self.assertEqual(preferences['GtkInterface']['toggle_on_ctrlspace'], False)

		dialog = PreferencesDialog(window)
		dialog.forms['Interface']['toggle_on_ctrlspace'] = True
		dialog.assert_response_ok()
		self.assertEqual(preferences['GtkInterface']['toggle_on_ctrlspace'], True)
    def testConfigurePlugin(self):
        from zim.plugins.journal import JournalPlugin
        plugin = JournalPlugin()

        window = MyWindow()
        pref_dialog = PreferencesDialog(window)
        dialog = PluginConfigureDialog(pref_dialog, plugin)
        dialog.assert_response_ok()
Exemple #4
0
    def show_preferences(self):
        '''Menu action to show the L{PreferencesDialog}'''
        from zim.gui.preferencesdialog import PreferencesDialog
        PreferencesDialog(self.widget).run()

        # Loading plugins can modify the index state
        if not self.notebook.index.is_uptodate:
            self.reload_index(update_only=True)
Exemple #5
0
	def testSelectPlugins(self):
		window = MyWindow()

		pref_dialog = PreferencesDialog(window)
		treeview = pref_dialog.plugins_tab.treeview
		for name in window.__pluginmanager__.list_installed_plugins():
			pref_dialog.plugins_tab.select_plugin(name)
			model, iter = treeview.get_selection().get_selected()
			self.assertEqual(model[iter][0], name)

			path = model.get_path(iter)
			wasactive = model[iter][1]
			model.do_toggle_path(path)
			if wasactive:
				self.assertEqual(model[iter][1], False)
			else:
				self.assertEqual(model[iter][1], model[iter][2]) # active matched activatable

		pref_dialog.do_response_cancel()
    def testConfigurePlugin(self):
        config = VirtualConfigManager()

        from zim.plugins.journal import JournalPlugin
        plugin = JournalPlugin()

        window = MyWindow(config)
        pref_dialog = PreferencesDialog(window, config)
        dialog = PluginConfigureDialog(pref_dialog, plugin)
        dialog.assert_response_ok()
    def testSetSimpleValue(self):
        config = VirtualConfigManager()
        preferences = config.get_config_dict('<profile>/preferences.conf')

        dialog = PreferencesDialog(MyWindow(config), config)
        self.assertEqual(dialog.forms['Interface']['toggle_on_ctrlspace'],
                         False)
        dialog.assert_response_ok()
        self.assertEqual(preferences['GtkInterface']['toggle_on_ctrlspace'],
                         False)

        dialog = PreferencesDialog(MyWindow(config), config)
        dialog.forms['Interface']['toggle_on_ctrlspace'] = True
        dialog.assert_response_ok()
        self.assertEqual(preferences['GtkInterface']['toggle_on_ctrlspace'],
                         True)
Exemple #8
0
	def testChangeFont(self):
		preferences = ConfigManager.get_config_dict('preferences.conf')
		window = MyWindow()

		text_style = ConfigManager.get_config_dict('style.conf')
		text_style['TextView'].setdefault('font', None, str)
		text_style['TextView']['font'] = 'Sans 12'

		dialog = PreferencesDialog(window)
		self.assertEqual(dialog.forms['Interface']['use_custom_font'], True)
		dialog.assert_response_ok()
		self.assertEqual(text_style['TextView']['font'], 'Sans 12')
		self.assertFalse(any(['use_custom_font' in d for d in list(preferences.values())]))

		text_style['TextView']['font'] = 'Sans 12'
		dialog = PreferencesDialog(window)
		self.assertEqual(dialog.forms['Interface']['use_custom_font'], True)
		dialog.forms['Interface']['use_custom_font'] = False
		dialog.assert_response_ok()
		self.assertEqual(text_style['TextView']['font'], None)
		self.assertFalse(any(['use_custom_font' in d for d in list(preferences.values())]))
Exemple #9
0
	def testPreferencesDialog(self):
		'''Test PreferencesDialog'''
		from zim.gui.preferencesdialog import PreferencesDialog, PluginConfigureDialog
		import zim.gui.pageview

		gui = zim.gui.GtkInterface()
		gui.register_preferences('GtkInterface', zim.gui.ui_preferences)
		gui.register_preferences('PageView', zim.gui.pageview.ui_preferences)
		with FilterFailedToLoadPlugin():
			# may miss dependencies for e.g. versioncontrol
			gui.load_plugins()
		self.ui.preferences_register = gui.preferences_register
		self.ui.preferences = gui.preferences
		self.ui.plugins = gui.plugins

		## Test get/set simple value
		self.assertEquals(self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)
		dialog = PreferencesDialog(self.ui)
		self.assertEquals(dialog.forms['Interface']['toggle_on_ctrlspace'], False)
		dialog.assert_response_ok()
		self.assertEquals(self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)

		dialog = PreferencesDialog(self.ui)
		dialog.forms['Interface']['toggle_on_ctrlspace'] = True
		dialog.assert_response_ok()
		self.assertEquals(self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], True)

		## Test font button
		zim.gui.pageview.PageView.style['TextView']['font'] = 'Sans 12'
		dialog = PreferencesDialog(self.ui)
		self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
		dialog.assert_response_ok()
		self.assertEqual(zim.gui.pageview.PageView.style['TextView']['font'], 'Sans 12')
		self.assertFalse(any(['use_custom_font' in d for d in self.ui.preferences.values()]))

		zim.gui.pageview.PageView.style['TextView']['font'] = 'Sans 12'
		dialog = PreferencesDialog(self.ui)
		self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
		dialog.forms['Interface']['use_custom_font'] = False
		dialog.assert_response_ok()
		self.assertEqual(zim.gui.pageview.PageView.style['TextView']['font'], None)
		self.assertFalse(any(['use_custom_font' in d for d in self.ui.preferences.values()]))

		## Plugin Config dialog
		from zim.plugins import get_plugin
		klass = get_plugin('calendar')
		pref_dialog = PreferencesDialog(self.ui)
		dialog = PluginConfigureDialog(pref_dialog, klass)
		dialog.assert_response_ok()
Exemple #10
0
    def testPreferencesDialog(self):
        '''Test PreferencesDialog'''
        from zim.gui.preferencesdialog import PreferencesDialog, PluginConfigureDialog

        self.clear_tmp_dir()

        gui = setupGtkInterface(self)
        gui.register_preferences('GtkInterface', zim.gui.ui_preferences)
        gui.register_preferences('PageView', zim.gui.pageview.ui_preferences)
        self.ui.preferences_register = gui.preferences_register
        self.ui.preferences = gui.preferences
        self.ui.plugins = gui.plugins
        self.ui.config = gui.config

        ## Test get/set simple value
        self.assertEquals(
            self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)
        dialog = PreferencesDialog(self.ui)
        self.assertEquals(dialog.forms['Interface']['toggle_on_ctrlspace'],
                          False)
        dialog.assert_response_ok()
        self.assertEquals(
            self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)

        dialog = PreferencesDialog(self.ui)
        dialog.forms['Interface']['toggle_on_ctrlspace'] = True
        dialog.assert_response_ok()
        self.assertEquals(
            self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], True)

        ## Test font button
        text_style = gui.config.get_config_dict('<profile>/style.conf')
        text_style['TextView']['font'] = 'Sans 12'
        dialog = PreferencesDialog(self.ui)
        self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
        dialog.assert_response_ok()
        self.assertEqual(text_style['TextView']['font'], 'Sans 12')
        self.assertFalse(
            any(['use_custom_font' in d
                 for d in self.ui.preferences.values()]))

        text_style['TextView']['font'] = 'Sans 12'
        dialog = PreferencesDialog(self.ui)
        self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
        dialog.forms['Interface']['use_custom_font'] = False
        dialog.assert_response_ok()
        self.assertEqual(text_style['TextView']['font'], None)
        self.assertFalse(
            any(['use_custom_font' in d
                 for d in self.ui.preferences.values()]))

        ## Plugin Config dialog
        from zim.plugins.calendar import CalendarPlugin
        plugin = CalendarPlugin()
        pref_dialog = PreferencesDialog(self.ui)
        dialog = PluginConfigureDialog(pref_dialog, plugin)
        dialog.assert_response_ok()

        ## Try plugins + cancel
        pref_dialog = PreferencesDialog(self.ui)
        treeview = pref_dialog.plugins_tab.treeview
        for name in self.ui.plugins.list_installed_plugins():
            pref_dialog.plugins_tab.select_plugin(name)
            model, iter = treeview.get_selection().get_selected()
            self.assertEqual(model[iter][0], name)

            path = model.get_path(iter)
            wasactive = model[iter][1]
            model.do_toggle_path(path)
            if wasactive:
                self.assertEqual(model[iter][1], False)
            else:
                self.assertEqual(model[iter][1],
                                 model[iter][2])  # active matched activatable

        pref_dialog.do_response_cancel()
Exemple #11
0
	def testPreferencesDialog(self):
		'''Test PreferencesDialog'''
		from zim.gui.preferencesdialog import PreferencesDialog, PluginConfigureDialog

		self.clear_tmp_dir()

		gui = setupGtkInterface(self)
		gui.register_preferences('GtkInterface', zim.gui.ui_preferences)
		gui.register_preferences('PageView', zim.gui.pageview.ui_preferences)
		self.ui.preferences_register = gui.preferences_register
		self.ui.preferences = gui.preferences
		self.ui.plugins = gui.plugins
		self.ui.config = gui.config

		## Test get/set simple value
		self.assertEquals(self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)
		dialog = PreferencesDialog(self.ui)
		self.assertEquals(dialog.forms['Interface']['toggle_on_ctrlspace'], False)
		dialog.assert_response_ok()
		self.assertEquals(self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)

		dialog = PreferencesDialog(self.ui)
		dialog.forms['Interface']['toggle_on_ctrlspace'] = True
		dialog.assert_response_ok()
		self.assertEquals(self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], True)

		## Test font button
		text_style = gui.config.get_config_dict('<profile>/style.conf')
		text_style['TextView']['font'] = 'Sans 12'
		dialog = PreferencesDialog(self.ui)
		self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
		dialog.assert_response_ok()
		self.assertEqual(text_style['TextView']['font'], 'Sans 12')
		self.assertFalse(any(['use_custom_font' in d for d in self.ui.preferences.values()]))

		text_style['TextView']['font'] = 'Sans 12'
		dialog = PreferencesDialog(self.ui)
		self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
		dialog.forms['Interface']['use_custom_font'] = False
		dialog.assert_response_ok()
		self.assertEqual(text_style['TextView']['font'], None)
		self.assertFalse(any(['use_custom_font' in d for d in self.ui.preferences.values()]))

		## Plugin Config dialog
		from zim.plugins.calendar import CalendarPlugin
		plugin = CalendarPlugin()
		pref_dialog = PreferencesDialog(self.ui)
		dialog = PluginConfigureDialog(pref_dialog, plugin)
		dialog.assert_response_ok()
Exemple #12
0
    def testPreferencesDialog(self):
        '''Test PreferencesDialog'''
        from zim.gui.preferencesdialog import PreferencesDialog, PluginConfigureDialog

        self.clear_tmp_dir()

        gui = setupGtkInterface(self)
        gui.register_preferences('GtkInterface', zim.gui.ui_preferences)
        gui.register_preferences('PageView', zim.gui.pageview.ui_preferences)
        self.ui.preferences_register = gui.preferences_register
        self.ui.preferences = gui.preferences
        self.ui.plugins = gui.plugins
        self.ui.config = gui.config

        ## Test get/set simple value
        self.assertEquals(
            self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)
        dialog = PreferencesDialog(self.ui)
        self.assertEquals(dialog.forms['Interface']['toggle_on_ctrlspace'],
                          False)
        dialog.assert_response_ok()
        self.assertEquals(
            self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], False)

        dialog = PreferencesDialog(self.ui)
        dialog.forms['Interface']['toggle_on_ctrlspace'] = True
        dialog.assert_response_ok()
        self.assertEquals(
            self.ui.preferences['GtkInterface']['toggle_on_ctrlspace'], True)

        ## Test font button
        text_style = gui.config.get_config_dict('<profile>/style.conf')
        text_style['TextView']['font'] = 'Sans 12'
        dialog = PreferencesDialog(self.ui)
        self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
        dialog.assert_response_ok()
        self.assertEqual(text_style['TextView']['font'], 'Sans 12')
        self.assertFalse(
            any(['use_custom_font' in d
                 for d in self.ui.preferences.values()]))

        text_style['TextView']['font'] = 'Sans 12'
        dialog = PreferencesDialog(self.ui)
        self.assertEquals(dialog.forms['Interface']['use_custom_font'], True)
        dialog.forms['Interface']['use_custom_font'] = False
        dialog.assert_response_ok()
        self.assertEqual(text_style['TextView']['font'], None)
        self.assertFalse(
            any(['use_custom_font' in d
                 for d in self.ui.preferences.values()]))

        ## Plugin Config dialog
        from zim.plugins.calendar import CalendarPlugin
        plugin = CalendarPlugin()
        pref_dialog = PreferencesDialog(self.ui)
        dialog = PluginConfigureDialog(pref_dialog, plugin)
        dialog.assert_response_ok()
Exemple #13
0
					def plugin_info(button):
						from zim.gui.preferencesdialog import PreferencesDialog
						dialog = PreferencesDialog(self.ui, "Plugins", select_plugin=name)
						dialog.run()
						self.ui.reload_page()