예제 #1
0
파일: user.py 프로젝트: palob/formiko
    def load(self):
        directory = get_user_config_dir()
        cp = SmartParser()
        cp.read("%s/formiko.ini" % directory)
        cp.smart_get(self, 'preview', int)
        cp.smart_get(self, 'auto_scroll', smart_bool)

        cp.smart_get(self, 'parser')
        if self.parser not in PARSERS:
            log_default_handler("Application", LogLevelFlags.LEVEL_WARNING,
                                "Unknow parser `%s' in config, set default."
                                % self.parser)
            self.parser = 'rst'
        cp.smart_get(self, 'writer')
        cp.smart_get(self, 'style')
        cp.smart_get(self, 'custom_style', smart_bool)

        cp.smart_get(self.editor, 'period_save', smart_bool, 'editor')
        cp.smart_get(self.editor, 'check_spelling', smart_bool, 'editor')
        cp.smart_get(self.editor, 'spell_lang', str, 'editor')
        cp.smart_get(self.editor, 'spaces_instead_of_tabs', smart_bool,
                     'editor')
        cp.smart_get(self.editor, 'tab_width', int, 'editor')
        cp.smart_get(self.editor, 'auto_indent', smart_bool, 'editor')
        cp.smart_get(self.editor, 'line_numbers', smart_bool, 'editor')
        cp.smart_get(self.editor, 'right_margin', smart_bool, 'editor')
        cp.smart_get(self.editor, 'current_line', smart_bool, 'editor')
        cp.smart_get(self.editor, 'text_wrapping', smart_bool, 'editor')
        cp.smart_get(self.editor, 'white_chars', smart_bool, 'editor')
예제 #2
0
    def do_command_line(self, command_line):
        options = command_line.get_options_dict()
        arguments = command_line.get_arguments()[1:]
        last = arguments[-1:][0] if arguments else ''

        if options.contains("vim"):
            log_default_handler("Application", LogLevelFlags.LEVEL_WARNING,
                                "Use formiko-vim instead", None)
            editor = 'vim'
        elif options.contains("source-view"):
            log_default_handler(None, LogLevelFlags.LEVEL_WARNING,
                                "Use formiko instead", None)
            editor = 'source'
        else:
            editor = 'source'

        if self.get_application_id() == "cz.zeropage.Formiko.vim":
            editor = 'vim'

        if editor == 'vim':
            display = Display.get_default()
            log_default_handler(None, LogLevelFlags.LEVEL_DEBUG,
                                "Backend is %s" % display.__class__.__name__,
                                None)
            if display.__class__.__name__ != "X11Display":
                log_default_handler(None, LogLevelFlags.LEVEL_CRITICAL,
                                    "Vim is supported only on X11 backend",
                                    None)
                return 1

        if editor == 'source':  # vim have disabled accels for conflict itself
            self.set_accels()

        if options.contains("preview") and last and last != '-':
            self.new_window(None, join(command_line.get_cwd(), last))
        elif last and last[0] != '-':
            self.new_window(editor, join(command_line.get_cwd(), last))
        else:
            self.new_window(editor)

        return 0
예제 #3
0
    def do_command_line(self, command_line):
        options = command_line.get_options_dict()
        arguments = command_line.get_arguments()[1:]
        last = arguments[-1:][0] if arguments else ''

        if options.contains("vim"):
            log_default_handler("Application", LogLevelFlags.LEVEL_WARNING,
                                "Use formiko-vim instead", 0)
            editor = 'vim'
        elif options.contains("source-view"):
            log_default_handler("Application", LogLevelFlags.LEVEL_WARNING,
                                "Use formiko instead", 0)
            editor = 'source'
        else:
            editor = 'source'

        if self.get_application_id() == "cz.zeropage.formiko.vim":
            editor = 'vim'

        if editor == 'vim':
            display = Display.get_default()
            if display.__class__.__name__ != "X11Display":
                log_default_handler("Application", LogLevelFlags.LEVEL_ERROR,
                                    "Vim is supported only on X11 backend")

        if editor == 'source':  # vim have disabled accels for conflict itself
            self.set_accels()

        if options.contains("preview") and last and last != '-':
            self.new_window(None, join(command_line.get_cwd(), last))
        elif last and last[0] != '-':
            self.new_window(editor, join(command_line.get_cwd(), last))
        else:
            self.new_window(editor)

        return 0
예제 #4
0
파일: renderer.py 프로젝트: ondratu/formiko
 def on_print_failed(self, po, error):
     # FIXME: if dialog is used, application will lock :-(
     log_default_handler("Application", LogLevelFlags.LEVEL_WARNING,
                         error.message)
예제 #5
0
파일: renderer.py 프로젝트: palob/formiko
 def on_print_failed(self, po, error):
     # FIXME: if dialog is used, application will lock :-(
     log_default_handler("Application", LogLevelFlags.LEVEL_WARNING,
                         error.message)
예제 #6
0
파일: icons.py 프로젝트: Daguhh/formiko
        # this work to /opt /usr /usr/local prefixes
        if exists(join(bin_path, share_path)):
            return join(bin_path, share_path)
        if exists(join(bin_path, icons_path)):
            return join(bin_path, icons_path)
        bin_path = split(bin_path)[0]


ICON_PATH = get_path()

if ICON_PATH:
    icon_16 = Pixbuf.new_from_file_at_scale(ICON_PATH, 16, 16, True)
    icon_32 = Pixbuf.new_from_file_at_scale(ICON_PATH, 32, 32, True)
    icon_48 = Pixbuf.new_from_file_at_scale(ICON_PATH, 48, 48, True)
    icon_64 = Pixbuf.new_from_file_at_scale(ICON_PATH, 64, 64, True)
    icon_128 = Pixbuf.new_from_file_at_scale(ICON_PATH, 128, 128, True)
else:
    from gi.repository.Gtk import IconTheme
    from gi.repository.GLib import log_default_handler, LogLevelFlags

    log_default_handler(None, LogLevelFlags.LEVEL_FATAL,
                        "Formiko icon not found", 0)
    icon_theme = IconTheme.get_default()
    icon_16 = icon_theme.load_icon("text-editor-symbolic", 16, 0)
    icon_32 = icon_theme.load_icon("text-editor-symbolic", 32, 0)
    icon_48 = icon_theme.load_icon("text-editor-symbolic", 48, 0)
    icon_64 = icon_theme.load_icon("text-editor-symbolic", 64, 0)
    icon_128 = icon_theme.load_icon("text-editor-symbolic", 128, 0)

icon_list = [icon_16, icon_32, icon_48, icon_64, icon_128]
예제 #7
0
        # this work to /opt /usr /usr/local prefixes
        if exists(join(bin_path, share_path)):
            return join(bin_path, share_path)
        if exists(join(bin_path, icons_path)):
            return join(bin_path, icons_path)
        bin_path = split(bin_path)[0]


ICON_PATH = get_path()

if ICON_PATH:
    icon_16 = Pixbuf.new_from_file_at_scale(ICON_PATH, 16, 16, True)
    icon_32 = Pixbuf.new_from_file_at_scale(ICON_PATH, 32, 32, True)
    icon_48 = Pixbuf.new_from_file_at_scale(ICON_PATH, 48, 48, True)
    icon_64 = Pixbuf.new_from_file_at_scale(ICON_PATH, 64, 64, True)
    icon_128 = Pixbuf.new_from_file_at_scale(ICON_PATH, 128, 128, True)
else:
    from gi.repository.Gtk import IconTheme
    from gi.repository.GLib import log_default_handler, LogLevelFlags

    log_default_handler("Application", LogLevelFlags.LEVEL_ERROR,
                        "Formiko icon not found", 0)
    icon_theme = IconTheme.get_default()
    icon_16 = icon_theme.load_icon("text-editor-symbolic", 16, 0)
    icon_32 = icon_theme.load_icon("text-editor-symbolic", 32, 0)
    icon_48 = icon_theme.load_icon("text-editor-symbolic", 48, 0)
    icon_64 = icon_theme.load_icon("text-editor-symbolic", 64, 0)
    icon_128 = icon_theme.load_icon("text-editor-symbolic", 128, 0)

icon_list = [icon_16, icon_32, icon_48, icon_64, icon_128]