コード例 #1
0
ファイル: preferencesdialog.py プロジェクト: thorhans/zimt
	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()
コード例 #2
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()