Example #1
0
    def generate_editor_fields(self):
        self.password_entry_headerlabel = Granite.HeaderLabel(
            "Choose a Password")

        self.password_entry = Granite.ValidatedEntry()
        self.password_entry.props.activates_default = True
        self.password_entry.props.hexpand = True
        self.password_entry.props.visibility = False
        self.password_entry.connect("changed", self.on_password_entry_changed)

        self.password_levelbar = Gtk.LevelBar().new_for_interval(0.0, 100.0)
        self.password_levelbar.props.mode = Gtk.LevelBarMode.CONTINUOUS
        self.password_levelbar.add_offset_value("low", 30.0)
        self.password_levelbar.add_offset_value("middle", 50.0)
        self.password_levelbar.add_offset_value("high", 80.0)
        self.password_levelbar.add_offset_value("full", 100.0)

        self.password_error_label = Gtk.Label(
            "<span font_size=\"small\">{0}</span>".format("."))
        self.password_error_label.props.halign = Gtk.Align.END
        self.password_error_label.props.justify = Gtk.Justification.RIGHT
        self.password_error_label.props.max_width_chars = 55
        self.password_error_label.props.use_markup = True
        self.password_error_label.props.wrap = True
        self.password_error_label.props.xalign = 1
        self.password_error_revealer = Gtk.Revealer()
        self.password_error_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE
        self.password_error_revealer.add(self.password_error_label)
        self.password_error_revealer.get_child().get_style_context().add_class(
            Gtk.STYLE_CLASS_WARNING)

        self.confirm_headerlabel = Granite.HeaderLabel("Confirm Password")

        self.confirm_entry = Granite.ValidatedEntry()
        self.confirm_entry.props.activates_default = True
        self.confirm_entry.props.sensitive = False
        self.confirm_entry.props.visibility = False
        self.confirm_entry.connect("changed", self.on_confirm_entry_changed)

        self.confirm_entry_label = Gtk.Label(
            "<span font_size=\"small\">{0}</span>".format("."))
        self.confirm_entry_label.props.halign = Gtk.Align.END
        self.confirm_entry_label.props.justify = Gtk.Justification.RIGHT
        self.confirm_entry_label.props.max_width_chars = 55
        self.confirm_entry_label.props.use_markup = True
        self.confirm_entry_label.props.wrap = True
        self.confirm_entry_label.props.xalign = 1
        self.confirm_entry_revealer = Gtk.Revealer()
        self.confirm_entry_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE
        self.confirm_entry_revealer.add(self.confirm_entry_label)
        self.confirm_entry_revealer.get_child().get_style_context().add_class(
            Gtk.STYLE_CLASS_ERROR)

        self.add(self.password_entry_headerlabel)
        self.add(self.password_entry)
        self.add(self.password_levelbar)
        self.add(self.password_error_revealer)
        self.add(self.confirm_headerlabel)
        self.add(self.confirm_entry)
        self.add(self.confirm_entry_revealer)
Example #2
0
    def render_writeas(self, content_grid):
        self.writeas_login = Gtk.Entry(hexpand=True, placeholder_text=_("Login"))
        self.writeas_password = Gtk.Entry(hexpand=True, placeholder_text=_("Password"), visibility=False)
        self.writeas_login_button = Gtk.Button(label=_("Login"))
        self.writeas_login_button.connect("clicked", self.on_writeas_login)
        self.writeas_logout_button = Gtk.Button(label=_("Logout"), hexpand=True)
        self.writeas_logout_button.connect("clicked", self.on_writeas_logout)

        content_grid.attach(Granite.HeaderLabel("Write.as"), 0, 3, 3, 1)

        self.writeas_login_revealer = Gtk.Revealer()
        self.writeas_login_revealer.set_transition_type(Gtk.RevealerTransitionType.CROSSFADE)
        login_grid = Gtk.Grid(column_spacing=12, row_spacing=6)
        login_grid.attach(Gtk.Label(_("Login:"******"Password:"******"changed", self.on_settings_changed)
    def __init__(self, zettel=Zettel(), letters_per_line = 80):
        super().__init__()
        self._letters_per_line = letters_per_line

        self.text_label = Gtk.Label()
        self.text_label.set_line_wrap(True)
        self.text_label.set_justify(Gtk.Justification.FILL) 
        self.text_label.set_max_width_chars(letters_per_line)

        self.title_label = Granite.HeaderLabel()
        self.tag_label = Gtk.Label()
        self.name_label = Gtk.Label()

        self.text_label.set_selectable(True)
        self.title_label.set_selectable(True)
        self.tag_label.set_selectable(True)
        self.name_label.set_selectable(True)

        self.set_zettel(zettel)

        self.attach(self.title_label, 0, 0, 1, 1)
        self.attach_next_to(self.name_label, self.title_label,
                             Gtk.PositionType.RIGHT, 1, 1)
        self.attach_next_to(self.tag_label, self.title_label,
                        Gtk.PositionType.BOTTOM, 1, 1)
        self.attach_next_to(self.text_label, self.tag_label,
                        Gtk.PositionType.BOTTOM, 1, 1)  

        self.text_label.show()
        self.tag_label.show()
        self.name_label.show()
        self.title_label.show()
Example #4
0
    def render_medium(self, content_grid):
        self.medium_token = Gtk.Entry(hexpand=True, placeholder_text=_("Token"))
        self.medium_token.set_text(self.settings.get_string('medium-personal-token'))
        self.medium_token.connect("changed", self.on_medium_token)

        self.medium_link = Gtk.LinkButton("https://medium.com/me/settings")
        self.medium_link.set_label(_("Create Integration token and copy it here"))

        content_grid.attach(Granite.HeaderLabel("Medium.com"), 0, 0, 3, 1)
        content_grid.attach(Gtk.Label(_("Personal Token:"), halign=Gtk.Align.END), 0, 1, 1, 1)
        content_grid.attach(self.medium_token, 1, 1, 2, 1)
        content_grid.attach(self.medium_link, 0, 2, 3, 1)
Example #5
0
    def generate_authenticate_fields(self):

        self.current_password_entry = Gtk.Entry()
        self.current_password_entry.props.visibility = False
        self.current_password_entry.set_icon_tooltip_text(
            Gtk.EntryIconPosition.SECONDARY, "Press to authenticate")

        if self.type != "authenticate":
            self.current_password_headerlabel = Granite.HeaderLabel(
                "Current Password")
            self.add(self.current_password_headerlabel)

            self.current_password_entry.connect(
                "icon-release", self.on_current_password_entry_icon_release)
            self.current_password_entry.connect(
                "focus-out-event", self.on_current_password_entry_focus_out)

        self.current_password_entry.connect(
            "changed", self.on_current_password_entry_changed)
        self.current_password_entry.connect(
            "activate", self.on_current_password_entry_activated)

        self.current_password_error_label = Gtk.Label(
            "<span font_size=\"small\">{0}</span>".format(
                "Authentication failed"))
        self.current_password_error_label.props.halign = Gtk.Align.END
        self.current_password_error_label.props.justify = Gtk.Justification.RIGHT
        self.current_password_error_label.props.max_width_chars = 55
        self.current_password_error_label.props.use_markup = True
        self.current_password_error_label.props.wrap = True
        self.current_password_error_label.props.xalign = 1
        self.current_password_error_revealer = Gtk.Revealer()
        self.current_password_error_revealer.props.transition_type = Gtk.RevealerTransitionType.CROSSFADE
        self.current_password_error_revealer.add(
            self.current_password_error_label)
        self.current_password_error_revealer.get_child().get_style_context(
        ).add_class(Gtk.STYLE_CLASS_ERROR)

        self.add(self.current_password_entry)
        self.add(self.current_password_error_revealer)
Example #6
0
    def __init__(self, folder_title=None):
        super().__init__(title=_("Create folder"))

        self.set_default_size(300, 100)
        self.set_modal(True)
        self.set_transient_for(Gtk.Application.get_default().props.active_window)

        header = Granite.HeaderLabel(_('Create folder'), halign=Gtk.Align.CENTER)

        self.entry = Gtk.Entry(placeholder_text=_('Folder name'), hexpand=True)
        self.entry.set_text(folder_title)
        self.entry.connect('activate', lambda entry: self.response(Gtk.ResponseType.ACCEPT))

        layout = Gtk.Grid(row_spacing=12, margin_start=12, margin_end=12)
        layout.attach(header, 0, 0, 1, 1)
        layout.attach(self.entry, 0, 1, 1, 1)

        self.get_content_area().add(layout)
        self.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)

        suggested_button = self.add_button(_("Create"), Gtk.ResponseType.ACCEPT)
        suggested_button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION)

        self.show_all()
Example #7
0
    def __init__(self, transient_for, settings):
        super().__init__(transient_for=transient_for, modal=False)

        self.settings = settings
        self.set_default_size(340, 340)

        hints = Gdk.Geometry()
        hints.min_width = 340
        hints.min_height = 340
        self.set_geometry_hints(None, hints, Gdk.WindowHints.MIN_SIZE)

        self.set_border_width(5)
        self.set_deletable(False)
        self.set_title(_('Preferences'))

        self.toast = Granite.WidgetsToast(title=_("Toast"))

        indent_width = Gtk.SpinButton.new_with_range(1, 24, 1)
        indent_width.set_value(self.settings.get_int('indent-width'))
        indent_width.connect('value-changed', self.on_indent_width)

        self.sort_switch = Gtk.Switch(halign=Gtk.Align.START,
                                      valign=Gtk.Align.CENTER)
        self.sort_switch.set_state(self.settings.get_boolean('sort-desc'))
        self.sort_switch.connect("state-set", self.on_sort_desc)

        self.spellcheck_switch = Gtk.Switch(halign=Gtk.Align.START,
                                            valign=Gtk.Align.CENTER)
        self.spellcheck_switch.set_state(
            self.settings.get_boolean('spellcheck'))
        self.spellcheck_switch.connect("state-set", self.on_spellcheck)

        self.autosave_switch = Gtk.Switch(halign=Gtk.Align.START,
                                          valign=Gtk.Align.CENTER)
        self.autosave_switch.set_state(self.settings.get_boolean('autosave'))
        self.autosave_switch.connect("state-set", self.on_autosave)

        self.autoindent_switch = Gtk.Switch(halign=Gtk.Align.START,
                                            valign=Gtk.Align.CENTER)
        self.autoindent_switch.set_state(
            self.settings.get_boolean('autoindent'))
        self.autoindent_switch.connect("state-set", self.on_autoindent)

        self.spaces_tabs_switch = Gtk.Switch(halign=Gtk.Align.START,
                                             valign=Gtk.Align.CENTER)
        self.spaces_tabs_switch.set_state(
            self.settings.get_boolean('spaces-instead-of-tabs'))
        self.spaces_tabs_switch.connect("state-set", self.on_spaces_tabs)

        general_grid = Gtk.Grid(column_spacing=12, row_spacing=6)

        general_grid.attach(Granite.HeaderLabel(_("General")), 0, 0, 3, 1)
        general_grid.attach(
            Gtk.Label(_("Save files when changed:"), halign=Gtk.Align.END), 0,
            1, 1, 1)
        general_grid.attach(self.autosave_switch, 1, 1, 1, 1)
        general_grid.attach(
            Gtk.Label(_("Sort documents backwards:"), halign=Gtk.Align.END), 0,
            2, 1, 1)
        general_grid.attach(self.sort_switch, 1, 2, 1, 1)
        general_grid.attach(
            Gtk.Label(_("Spell checking:"), halign=Gtk.Align.END), 0, 3, 1, 1)
        general_grid.attach(self.spellcheck_switch, 1, 3, 1, 1)

        general_grid.attach(Granite.HeaderLabel(_("Tabs")), 0, 4, 3, 1)
        general_grid.attach(
            Gtk.Label(_("Automatic indentation:"), halign=Gtk.Align.END), 0, 5,
            1, 1)
        general_grid.attach(self.autoindent_switch, 1, 5, 1, 1)
        general_grid.attach(
            Gtk.Label(_("Insert spaces instead of tabs:"),
                      halign=Gtk.Align.END), 0, 6, 1, 1)
        general_grid.attach(self.spaces_tabs_switch, 1, 6, 1, 1)
        general_grid.attach(Gtk.Label(_("Tab width:"), halign=Gtk.Align.END),
                            0, 7, 1, 1)
        general_grid.attach(indent_width, 1, 7, 2, 1)

        # Interface grid
        interface_grid = Gtk.Grid(column_spacing=12, row_spacing=6)
        scrolled = Gtk.ScrolledWindow(hexpand=True, vexpand=True)

        self.dark_theme_switch = Gtk.Switch(halign=Gtk.Align.START,
                                            valign=Gtk.Align.CENTER)
        self.dark_theme_switch.set_state(
            self.settings.get_boolean('prefer-dark-theme'))
        self.dark_theme_switch.connect("state-set", self.on_dark_theme)

        style_chooser = GtkSource.StyleSchemeChooserWidget()
        style_chooser.connect('notify::style-scheme', self.on_scheme_changed)
        scrolled.add(style_chooser)

        scheme = GtkSource.StyleSchemeManager().get_scheme(
            self.settings.get_string('stylescheme'))
        if not scheme:
            scheme = GtkSource.StyleSchemeManager().get_scheme("classic")

        style_chooser.set_style_scheme(scheme)

        interface_grid.attach(Granite.HeaderLabel(_("Appearance")), 0, 0, 3, 1)
        interface_grid.attach(
            Gtk.Label(_("Prefer dark theme:"), halign=Gtk.Align.END), 0, 1, 2,
            1)
        interface_grid.attach(self.dark_theme_switch, 2, 1, 1, 1)
        interface_grid.attach(Granite.HeaderLabel(_("Styles")), 0, 2, 3, 1)
        interface_grid.attach(scrolled, 0, 3, 3, 1)

        # Export grid
        export_grid = Gtk.Grid(column_spacing=12, row_spacing=6)

        self.render_medium(export_grid)
        self.render_writeas(export_grid)

        # Main Stack
        main_stack = Gtk.Stack(margin=6, margin_bottom=18, margin_top=8)
        main_stack.add_titled(general_grid, "behavior", _("Behavior"))
        main_stack.add_titled(interface_grid, "interface", _("Interface"))
        main_stack.add_titled(export_grid, "export", _("Export"))

        main_stackswitcher = Gtk.StackSwitcher()
        main_stackswitcher.set_stack(main_stack)
        main_stackswitcher.set_halign(Gtk.Align.CENTER)

        main_grid = Gtk.Grid()
        main_grid.attach(main_stackswitcher, 0, 0, 1, 1)
        main_grid.attach(main_stack, 0, 1, 1, 1)

        self.overlay = Gtk.Overlay()
        self.overlay.add(main_grid)
        self.overlay.add_overlay(self.toast)
        self.get_content_area().add(self.overlay)

        close_button = Gtk.Button(label=_("Close"))
        close_button.connect('clicked', self.on_close_activated)
        self.add_action_widget(close_button, 0)
Example #8
0
    def __init__(self, settings):
        super().__init__()
        self.set_constrain_to(Gtk.PopoverConstraint.NONE)

        self.settings = settings

        self.export_plain = Gtk.Button(
            label=_("Text"),
            action_name="document.export",
            tooltip_text=_("Export document to plain text file"),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_plain.set_image(
            Gtk.Image.new_from_resource(f"{RESOURCE_PREFIX}/icons/text.svg"))

        self.export_markdown = Gtk.Button(
            label=_("Markdown"),
            action_name="document.export-markdown",
            tooltip_markup=Granite.markup_accel_tooltip(
                ("<Control><Shift>s", ), _("Export document to markdown")),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_markdown.set_image(
            Gtk.Image.new_from_resource(
                f"{RESOURCE_PREFIX}/icons/text-markdown.svg"))

        self.export_html = Gtk.Button(
            _("Html"),
            action_name="document.export-html",
            tooltip_text=_("Export document to HTML"),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_html.set_tooltip_text(_("Export document to HTML"))
        self.export_html.set_image(
            Gtk.Image.new_from_resource(
                f"{RESOURCE_PREFIX}/icons/text-html.svg"))

        self.export_pdf = Gtk.Button(
            _("Pdf"),
            action_name="document.export-pdf",
            tooltip_text=_("Export document to PDF"),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP,
        )
        self.export_pdf.set_tooltip_text(_("Export document to PDF"))
        self.export_pdf.set_image(
            Gtk.Image.new_from_resource(
                f"{RESOURCE_PREFIX}/icons/application-pdf.svg"))

        self.export_docx = Gtk.Button(
            _("Docx"),
            action_name="document.export-docx",
            tooltip_text=_("Export document to Docx"),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_docx.set_tooltip_text(_("Export document to Docx"))
        self.export_docx.set_image(
            Gtk.Image.new_from_resource(
                f"{RESOURCE_PREFIX}/icons/application-msword.svg"))

        export_grid_1 = Gtk.Grid()
        export_grid_1.attach(self.export_plain, 0, 1, 1, 1)
        export_grid_1.attach(self.export_markdown, 1, 1, 1, 1)
        export_grid_1.attach(self.export_html, 2, 1, 1, 1)

        export_grid_2 = Gtk.Grid()
        export_grid_2.attach(self.export_pdf, 0, 1, 1, 1)
        export_grid_2.attach(self.export_docx, 1, 1, 1, 1)

        self.carousel = Handy.Carousel()
        self.carousel_indicator = Handy.CarouselIndicatorLines(
            carousel=self.carousel)
        self.carousel.insert(export_grid_1, 0)
        self.carousel.insert(export_grid_2, 1)

        self.export_file = Gtk.ModelButton()
        self.export_file.get_child().destroy()
        self.export_file.add(
            Granite.AccelLabel(label=_("Export to file"),
                               accel_string='<Control><Shift>s'))
        self.export_file.set_action_name("document.export")

        self.export_medium = Gtk.ModelButton()
        self.export_medium.get_child().destroy()
        self.export_medium.add(Granite.AccelLabel(label=_("To Medium")))
        self.export_medium.set_action_name("document.export-medium")

        self.export_writeas = Gtk.ModelButton()
        self.export_writeas.get_child().destroy()
        self.export_writeas.add(Granite.AccelLabel(label=_("To Write.as")))
        self.export_writeas.set_action_name("document.export-writeas")

        menu_grid = Gtk.Grid(margin_bottom=3,
                             margin_top=3,
                             orientation=Gtk.Orientation.VERTICAL,
                             width_request=200)
        menu_grid.attach(
            Granite.HeaderLabel(_("Files"), margin_left=12, margin_right=12),
            0, 0, 3, 1)
        menu_grid.attach(self.carousel, 0, 1, 3, 1)
        menu_grid.attach(self.carousel_indicator, 0, 2, 3, 1)

        menu_grid.attach(
            Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                          margin_top=12), 0, 2, 3, 1)
        menu_grid.attach(
            Granite.HeaderLabel(_("Internet"), margin_left=12,
                                margin_right=12), 0, 3, 3, 1)
        menu_grid.attach(self.export_medium, 0, 4, 3, 1)
        menu_grid.attach(self.export_writeas, 0, 5, 3, 1)

        self.add(menu_grid)

        menu_grid.show_all()
        self.export_pdf.set_visible(False)
Example #9
0
    def __init__(self, settings):
        super().__init__()
        self.set_relative_to(None)

        self.settings = settings

        self.export_plain = Gtk.Button(
            label=_("Text"),
            action_name="document.export",
            tooltip_text=_("Export document to plain text file"),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_plain.set_image(
            Gtk.Image.new_from_resource("/com/github/tenderowl/norka/icons/text.svg"))

        self.export_markdown = Gtk.Button(
            label=_("Markdown"),
            action_name="document.export-markdown",
            tooltip_markup=Granite.markup_accel_tooltip(
                ("<Control><Shift>s",), _("Export document to markdown")),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_markdown.set_image(
            Gtk.Image.new_from_resource("/com/github/tenderowl/norka/icons/text-markdown.svg"))

        self.export_html = Gtk.Button(
            _("Html"),
            action_name="document.export-html",
            tooltip_text=_("Export document to HTML"),
            relief=Gtk.ReliefStyle.NONE,
            always_show_image=True,
            image_position=Gtk.PositionType.TOP)
        self.export_html.set_tooltip_text(_("Export document to HTML"))
        self.export_html.set_image(
            Gtk.Image.new_from_resource("/com/github/tenderowl/norka/icons/text-html.svg"))

        self.export_file = Gtk.ModelButton()
        self.export_file.get_child().destroy()
        self.export_file.add(Granite.AccelLabel(label=_("Export to file"), accel_string='<Control><Shift>s'))
        self.export_file.set_action_name("document.export")

        self.export_medium = Gtk.ModelButton()
        self.export_medium.get_child().destroy()
        self.export_medium.add(Granite.AccelLabel(label=_("To Medium")))
        self.export_medium.set_action_name("document.export-medium")

        self.export_writeas = Gtk.ModelButton()
        self.export_writeas.get_child().destroy()
        self.export_writeas.add(Granite.AccelLabel(label=_("To Write.as")))
        self.export_writeas.set_action_name("document.export-writeas")

        menu_grid = Gtk.Grid(margin_bottom=3, margin_top=3, orientation=Gtk.Orientation.VERTICAL, width_request=200)
        menu_grid.attach(Granite.HeaderLabel(_("Files"), margin_left=12, margin_right=12), 0, 0, 3, 1)
        menu_grid.attach(self.export_plain, 0, 1, 1, 1)
        menu_grid.attach(self.export_markdown, 1, 1, 1, 1)
        menu_grid.attach(self.export_html, 2, 1, 1, 1)

        menu_grid.attach(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin_top=12), 0, 2, 3, 1)
        menu_grid.attach(Granite.HeaderLabel(_("Internet"), margin_left=12, margin_right=12), 0, 3, 3, 1)
        menu_grid.attach(self.export_medium, 0, 4, 3, 1)
        menu_grid.attach(self.export_writeas, 0, 5, 3, 1)

        self.add(menu_grid)

        menu_grid.show_all()
Example #10
0
    def __init__(self, transient_for, settings):
        super().__init__(transient_for=transient_for, modal=False)

        self.settings = settings
        self.set_default_size(340, 300)

        self.set_border_width(5)
        self.set_deletable(False)
        self.set_title('Preferences')

        indent_width = Gtk.SpinButton.new_with_range(1, 24, 1)
        indent_width.set_value(self.settings.get_int('indent-width'))
        indent_width.connect('value-changed', self.on_indent_width)

        self.spellcheck_switch = Gtk.Switch(halign=Gtk.Align.START,
                                            valign=Gtk.Align.CENTER)
        self.spellcheck_switch.set_state(
            self.settings.get_boolean('spellcheck'))
        self.spellcheck_switch.connect("state-set", self.on_spellcheck)

        self.autosave_switch = Gtk.Switch(halign=Gtk.Align.START,
                                          valign=Gtk.Align.CENTER)
        self.autosave_switch.set_state(self.settings.get_boolean('autosave'))
        self.autosave_switch.connect("state-set", self.on_autosave)

        self.autoindent_switch = Gtk.Switch(halign=Gtk.Align.START,
                                            valign=Gtk.Align.CENTER)
        self.autoindent_switch.set_state(
            self.settings.get_boolean('autoindent'))
        self.autoindent_switch.connect("state-set", self.on_autoindent)

        self.spaces_tabs_switch = Gtk.Switch(halign=Gtk.Align.START,
                                             valign=Gtk.Align.CENTER)
        self.spaces_tabs_switch.set_state(
            self.settings.get_boolean('spaces-instead-of-tabs'))
        self.spaces_tabs_switch.connect("state-set", self.on_spaces_tabs)

        general_grid = Gtk.Grid(column_spacing=12, row_spacing=6)

        general_grid.attach(Granite.HeaderLabel("General"), 0, 0, 3, 1)
        general_grid.attach(
            Gtk.Label("Save files when changed:", halign=Gtk.Align.END), 0, 1,
            1, 1)
        general_grid.attach(self.autosave_switch, 1, 1, 1, 1)
        general_grid.attach(Gtk.Label("Spell checking:", halign=Gtk.Align.END),
                            0, 2, 1, 1)
        general_grid.attach(self.spellcheck_switch, 1, 2, 1, 1)

        general_grid.attach(Granite.HeaderLabel("Tabs"), 0, 3, 3, 1)
        general_grid.attach(
            Gtk.Label("Automatic indentation:", halign=Gtk.Align.END), 0, 4, 1,
            1)
        general_grid.attach(self.autoindent_switch, 1, 4, 1, 1)
        general_grid.attach(
            Gtk.Label("Insert spaces instead of tabs:", halign=Gtk.Align.END),
            0, 5, 1, 1)
        general_grid.attach(self.spaces_tabs_switch, 1, 5, 1, 1)
        general_grid.attach(Gtk.Label("Tab width:", halign=Gtk.Align.END), 0,
                            6, 1, 1)
        general_grid.attach(indent_width, 1, 6, 2, 1)

        interface_grid = Gtk.Grid(column_spacing=12, row_spacing=6)
        scrolled = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
        style_chooser = GtkSource.StyleSchemeChooserWidget()
        style_chooser.connect('notify::style-scheme', self.on_scheme_changed)
        scrolled.add(style_chooser)

        scheme = GtkSource.StyleSchemeManager().get_scheme(
            self.settings.get_string('stylescheme'))
        if not scheme:
            scheme = GtkSource.StyleSchemeManager().get_scheme("classic")

        style_chooser.set_style_scheme(scheme)

        interface_grid.attach(Granite.HeaderLabel("Styles"), 0, 0, 2, 1)
        interface_grid.attach(scrolled, 0, 2, 2, 1)

        main_stack = Gtk.Stack(margin=6, margin_bottom=18, margin_top=8)
        main_stack.add_titled(general_grid, "behavior", "Behavior")
        main_stack.add_titled(interface_grid, "interface", "Interface")

        main_stackswitcher = Gtk.StackSwitcher()
        main_stackswitcher.set_stack(main_stack)
        main_stackswitcher.set_halign(Gtk.Align.CENTER)

        main_grid = Gtk.Grid()
        main_grid.attach(main_stackswitcher, 0, 0, 1, 1)
        main_grid.attach(main_stack, 0, 1, 1, 1)

        self.get_content_area().add(main_grid)

        close_button = Gtk.Button(label="Close")
        close_button.connect('clicked', self.on_close_activated)
        self.add_action_widget(close_button, 0)