Пример #1
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()
Пример #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)
Пример #3
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()
Пример #4
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()
    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)
Пример #6
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())]))
Пример #7
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()