Пример #1
0
	def do_toggle_spellcheck(self, enable=None):
		#~ print 'do_toggle_spellcheck', enable
		if enable is None:
			action = self.actiongroup.get_action('toggle_spellcheck')
			enable = action.get_active()

		textview = self.ui.mainwindow.pageview.view
		if enable:
			if self.spell is None:
				lang = self.preferences['language'] or None
				try:
					self.spell = gtkspell.Spell(textview, lang)
				except:
					lang = lang or get_environ('LANG') or get_environ('LANGUAGE')
					ErrorDialog(self.ui, (
						_('Could not load spell checking for language: "%s"') % lang,
							# T: error message - %s is replaced with language codes like "en", "en_US"m or "nl_NL"
						_('This could mean you don\'t have the proper\ndictionaries installed')
							# T: error message explanation
					) ).run()
					return
				else:
					textview.gtkspell = self.spell # HACK used by hardcoded hook in pageview
			else:
				pass
		else:
			if self.spell is None:
				pass
			else:
				if textview.gtkspell \
				and textview.gtkspell == self.spell:
					textview.gtkspell.detach()
					textview.gtkspell = None
				self.spell = None

		self.uistate['active'] = enable
		return False # we can be called from idle event
Пример #2
0
def user_site_packages_directory():
	'''Get the per user site-packages directory

	In Python 2.6 the "Per-user site-packages Directory" feature has
	been introduced, see
	U{http://docs.python.org/whatsnew/2.6.html#pep-370-per-user-site-packages-directory}.
	This function backports this feature to Python 2.5.

	@returns: the per user site-packages directory.
	This directoy is part of the search path for plugin modules, so users
	can install plugins in locally.
	'''
	if os.name == 'nt':
		appdata = get_environ('APPDATA')
		if appdata:
			dir = Dir((appdata, 'Python/Python25/site-packages'))
			return dir.path
		else:
			return None
	else:
		dir = Dir('~/.local/lib/python2.5/site-packages')
		return dir.path
Пример #3
0
            handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
            rootlogger.addHandler(handler)
        except:
            err_stream.write('ERROR: Failed to set up logging')

    # Run actual server object
    server = Server()
    server.start()
    server.main()
    logger.debug('Server process %i quit', os.getpid())


if sys.platform == 'win32':
    # Windows named pipe
    from zim.config import get_environ
    SERVER_ADDRESS = '\\\\.\\pipe\\zimServer-%s' % get_environ('USER')
    SERVER_ADDRESS_FAMILY = 'AF_PIPE'
else:
    # Unix domain socket
    SERVER_ADDRESS = str(get_tmpdir().file('zim-server-socket').path)
        # BUG in multiprocess, name must be str instead of basestring
    SERVER_ADDRESS_FAMILY = 'AF_UNIX'


AUTHKEY_FILE = get_tmpdir().file('zim-server-authkey')
    # Zim always initializes the tmpdir with mode 700, so should be private


class Server(object):
    '''Main object in the server process, handling all communication'''