Пример #1
0
 def wrap_mode_from_bool(binding, from_value):
     if from_value:
         settings_mode = settings.get_enum('wrap-mode')
         if settings_mode == Gtk.WrapMode.NONE:
             mode = Gtk.WrapMode.WORD
         else:
             mode = settings_mode
     else:
         mode = Gtk.WrapMode.NONE
     return mode
Пример #2
0
 def wrap_mode_from_bool(binding, from_value):
     if from_value:
         settings_mode = settings.get_enum('wrap-mode')
         if settings_mode == Gtk.WrapMode.NONE:
             mode = Gtk.WrapMode.WORD
         else:
             mode = settings_mode
     else:
         mode = Gtk.WrapMode.NONE
     return mode
Пример #3
0
    def __init__(self, parent):
        Component.__init__(self, "preferences.ui", "preferencesdialog",
                           ["adjustment1", "adjustment2", "fileorderstore",
                            "sizegroup_editor", "timestampstore",
                            "mergeorderstore", "sizegroup_file_order_labels",
                            "sizegroup_file_order_combos",
                            'syntaxschemestore'])
        self.widget.set_transient_for(parent)

        bindings = [
            ('use-system-font', self.checkbutton_default_font, 'active'),
            ('custom-font', self.fontpicker, 'font'),
            ('indent-width', self.spinbutton_tabsize, 'value'),
            ('insert-spaces-instead-of-tabs', self.checkbutton_spaces_instead_of_tabs, 'active'),
            ('highlight-current-line', self.checkbutton_highlight_current_line, 'active'),
            ('show-line-numbers', self.checkbutton_show_line_numbers, 'active'),
            ('highlight-syntax', self.checkbutton_use_syntax_highlighting, 'active'),
            ('use-system-editor', self.system_editor_checkbutton, 'active'),
            ('custom-editor-command', self.custom_edit_command_entry, 'text'),
            ('folder-shallow-comparison', self.checkbutton_shallow_compare, 'active'),
            ('folder-ignore-symlinks', self.checkbutton_ignore_symlinks, 'active'),
            ('vc-show-commit-margin', self.checkbutton_show_commit_margin, 'active'),
            ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
            ('vc-break-commit-message', self.checkbutton_break_commit_lines, 'active'),
            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines, 'active'),
            # Sensitivity bindings must come after value bindings, or the key
            # writability in gsettings overrides manual sensitivity setting.
            ('vc-show-commit-margin', self.spinbutton_commit_margin, 'sensitive'),
            ('vc-show-commit-margin', self.checkbutton_break_commit_lines, 'sensitive'),
        ]
        for key, obj, attribute in bindings:
            settings.bind(key, obj, attribute, Gio.SettingsBindFlags.DEFAULT)

        settings.bind(
            'use-system-editor', self.custom_edit_command_entry, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)
        settings.bind(
            'use-system-font', self.fontpicker, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)

        self.checkbutton_wrap_text.bind_property(
            'active', self.checkbutton_wrap_word, 'sensitive',
            GObject.BindingFlags.DEFAULT)

        # TODO: Fix once bind_with_mapping is available
        self.checkbutton_show_whitespace.set_active(
            bool(settings.get_flags('draw-spaces')))

        wrap_mode = settings.get_enum('wrap-mode')
        self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
        self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)

        filefilter = FilterList("filename-filters", FilterEntry.SHELL)
        self.file_filters_vbox.pack_start(filefilter.widget, True, True, 0)

        textfilter = FilterList("text-filters", FilterEntry.REGEX)
        self.text_filters_vbox.pack_start(textfilter.widget, True, True, 0)

        columnlist = ColumnList("folder-columns")
        self.column_list_vbox.pack_start(columnlist.widget, True, True, 0)

        self.combo_timestamp.bind_to('folder-time-resolution')
        self.combo_file_order.bind_to('vc-left-is-local')
        self.combo_merge_order.bind_to('vc-merge-file-order')

        # Fill color schemes
        manager = GtkSource.StyleSchemeManager.get_default()
        for scheme_id in manager.get_scheme_ids():
            scheme = manager.get_scheme(scheme_id)
            self.syntaxschemestore.append([scheme_id, scheme.get_name()])
        self.combobox_style_scheme.bind_to('style-scheme')

        self.widget.show()
Пример #4
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.init_template()

        bindings = [
            ('use-system-font', self.checkbutton_default_font, 'active'),
            ('custom-font', self.fontpicker, 'font'),
            ('indent-width', self.spinbutton_tabsize, 'value'),
            ('insert-spaces-instead-of-tabs',
             self.checkbutton_spaces_instead_of_tabs, 'active'),  # noqa: E501
            ('highlight-current-line', self.checkbutton_highlight_current_line,
             'active'),  # noqa: E501
            ('show-line-numbers', self.checkbutton_show_line_numbers,
             'active'),  # noqa: E501
            ('highlight-syntax', self.checkbutton_use_syntax_highlighting,
             'active'),  # noqa: E501
            ('use-system-editor', self.system_editor_checkbutton, 'active'),
            ('custom-editor-command', self.custom_edit_command_entry, 'text'),
            ('folder-shallow-comparison', self.checkbutton_shallow_compare,
             'active'),  # noqa: E501
            ('folder-filter-text', self.checkbutton_folder_filter_text,
             'active'),  # noqa: E501
            ('folder-ignore-symlinks', self.checkbutton_ignore_symlinks,
             'active'),  # noqa: E501
            ('vc-show-commit-margin', self.checkbutton_show_commit_margin,
             'active'),  # noqa: E501
            ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
            ('vc-break-commit-message', self.checkbutton_break_commit_lines,
             'active'),  # noqa: E501
            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines,
             'active'),  # noqa: E501
            # Sensitivity bindings must come after value bindings, or the key
            # writability in gsettings overrides manual sensitivity setting.
            ('vc-show-commit-margin', self.spinbutton_commit_margin,
             'sensitive'),  # noqa: E501
            ('vc-show-commit-margin', self.checkbutton_break_commit_lines,
             'sensitive'),  # noqa: E501
        ]
        for key, obj, attribute in bindings:
            settings.bind(key, obj, attribute, Gio.SettingsBindFlags.DEFAULT)

        invert_bindings = [
            ('use-system-editor', self.custom_edit_command_entry, 'sensitive'),
            ('use-system-font', self.fontpicker, 'sensitive'),
            ('folder-shallow-comparison', self.checkbutton_folder_filter_text,
             'sensitive'),  # noqa: E501
        ]
        for key, obj, attribute in invert_bindings:
            settings.bind(
                key, obj, attribute, Gio.SettingsBindFlags.DEFAULT
                | Gio.SettingsBindFlags.INVERT_BOOLEAN)

        self.checkbutton_wrap_text.bind_property('active',
                                                 self.checkbutton_wrap_word,
                                                 'sensitive',
                                                 GObject.BindingFlags.DEFAULT)

        # TODO: Fix once bind_with_mapping is available
        self.checkbutton_show_whitespace.set_active(
            bool(settings.get_flags('draw-spaces')))

        wrap_mode = settings.get_enum('wrap-mode')
        self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
        self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)

        filefilter = FilterList(
            filter_type=FilterEntry.SHELL,
            settings_key="filename-filters",
        )
        self.file_filters_vbox.pack_start(filefilter, True, True, 0)

        textfilter = FilterList(
            filter_type=FilterEntry.REGEX,
            settings_key="text-filters",
        )
        self.text_filters_vbox.pack_start(textfilter, True, True, 0)

        columnlist = ColumnList(settings_key="folder-columns")
        self.column_list_vbox.pack_start(columnlist, True, True, 0)

        self.combo_timestamp.bind_to('folder-time-resolution')
        self.combo_file_order.bind_to('vc-left-is-local')
        self.combo_merge_order.bind_to('vc-merge-file-order')

        # Fill color schemes
        manager = GtkSource.StyleSchemeManager.get_default()
        for scheme_id in manager.get_scheme_ids():
            scheme = manager.get_scheme(scheme_id)
            self.syntaxschemestore.append([scheme_id, scheme.get_name()])
        self.combobox_style_scheme.bind_to('style-scheme')

        self.show()
Пример #5
0
    def __init__(self, parent):
        Component.__init__(self, "preferences.ui", "preferencesdialog",
                           ["adjustment1", "adjustment2", "fileorderstore",
                            "sizegroup_editor", "timestampstore",
                            "mergeorderstore", "sizegroup_file_order_labels",
                            "sizegroup_file_order_combos"])
        self.widget.set_transient_for(parent)

        bindings = [
            ('use-system-font', self.checkbutton_default_font, 'active'),
            ('custom-font', self.fontpicker, 'font'),
            ('indent-width', self.spinbutton_tabsize, 'value'),
            ('insert-spaces-instead-of-tabs', self.checkbutton_spaces_instead_of_tabs, 'active'),
            ('highlight-current-line', self.checkbutton_highlight_current_line, 'active'),
            ('show-line-numbers', self.checkbutton_show_line_numbers, 'active'),
            ('highlight-syntax', self.checkbutton_use_syntax_highlighting, 'active'),
            ('use-system-editor', self.system_editor_checkbutton, 'active'),
            ('custom-editor-command', self.custom_edit_command_entry, 'text'),
            ('folder-shallow-comparison', self.checkbutton_shallow_compare, 'active'),
            ('folder-ignore-symlinks', self.checkbutton_ignore_symlinks, 'active'),
            ('vc-show-commit-margin', self.checkbutton_show_commit_margin, 'active'),
            ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
            ('vc-break-commit-message', self.checkbutton_break_commit_lines, 'active'),
            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines, 'active'),
            # Sensitivity bindings must come after value bindings, or the key
            # writability in gsettings overrides manual sensitivity setting.
            ('vc-show-commit-margin', self.spinbutton_commit_margin, 'sensitive'),
            ('vc-show-commit-margin', self.checkbutton_break_commit_lines, 'sensitive'),
        ]
        for key, obj, attribute in bindings:
            settings.bind(key, obj, attribute, Gio.SettingsBindFlags.DEFAULT)

        settings.bind(
            'use-system-editor', self.custom_edit_command_entry, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)
        settings.bind(
            'use-system-font', self.fontpicker, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)

        self.checkbutton_wrap_text.bind_property(
            'active', self.checkbutton_wrap_word, 'sensitive',
            GObject.BindingFlags.DEFAULT)

        # TODO: Fix once bind_with_mapping is available
        self.checkbutton_show_whitespace.set_active(
            bool(settings.get_flags('draw-spaces')))

        wrap_mode = settings.get_enum('wrap-mode')
        self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
        self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)

        filefilter = FilterList("filename-filters", FilterEntry.SHELL)
        self.file_filters_vbox.pack_start(filefilter.widget, True, True, 0)

        textfilter = FilterList("text-filters", FilterEntry.REGEX)
        self.text_filters_vbox.pack_start(textfilter.widget, True, True, 0)

        columnlist = ColumnList("folder-columns")
        self.column_list_vbox.pack_start(columnlist.widget, True, True, 0)

        self.combo_timestamp.bind_to('folder-time-resolution')
        self.combo_file_order.bind_to('vc-left-is-local')
        self.combo_merge_order.bind_to('vc-merge-file-order')

        self.widget.show()