Esempio n. 1
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)
Esempio n. 2
0
    def __init__(self):
        super().__init__(title=_('Markup Help'))
        self.set_default_size(300, 340)

        h1_label = Gtk.Label(label=f'{self.span_text("#")} {_("Header")} 1',
                             halign=Gtk.Align.START,
                             use_markup=True)
        h1_keys = Granite.AccelLabel(accel_string='<Control>1')

        h2_label = Gtk.Label(label=f'{self.span_text("##")} {_("Header")} 2',
                             halign=Gtk.Align.START,
                             use_markup=True)
        h2_keys = Granite.AccelLabel(accel_string='<Control>2')

        h3_label = Gtk.Label(label=f'{self.span_text("###")} {_("Header")} 3',
                             halign=Gtk.Align.START,
                             use_markup=True)
        h3_keys = Granite.AccelLabel(accel_string='<Control>3')

        bold_label = Gtk.Label(
            label=f'{self.span_text("**")}{_("Bold")}{self.span_text("**")}',
            halign=Gtk.Align.START,
            use_markup=True)
        bold_keys = Granite.AccelLabel(accel_string='<Control>b')

        italic_label = Gtk.Label(
            label=f'{self.span_text("_")}{_("Italic")}{self.span_text("_")}',
            halign=Gtk.Align.START,
            use_markup=True)
        italic_keys = Granite.AccelLabel(accel_string='<Control>i')

        link_label = Gtk.Label(
            label=f'{self.span_text("[")}{_("Link title")}{self.span_text("]")}'
            f'{self.span_text("(")}{_("URL")}{self.span_text(")")}',
            halign=Gtk.Align.START,
            use_markup=True)
        link_keys = Granite.AccelLabel(accel_string='<Control>k')

        image_link_label = Gtk.Label(
            label=
            f'{self.span_text("![")}{_("Image title")}{self.span_text("]")}'
            f'{self.span_text("(")}{_("URL")}{self.span_text(")")}',
            halign=Gtk.Align.START,
            use_markup=True)
        image_link_keys = Granite.AccelLabel(accel_string='<Control><Shift>k')

        list_label = Gtk.Label(label=f'{self.span_text("-")} {_("List")}',
                               halign=Gtk.Align.START,
                               use_markup=True)
        list_keys = Granite.AccelLabel(accel_string='<Control>l')

        ordered_list_label = Gtk.Label(
            label=f'{self.span_text("1.")} {_("Ordered list")}',
            halign=Gtk.Align.START,
            use_markup=True)
        ordered_list_keys = Granite.AccelLabel(
            accel_string='<Control><Shift>l')

        quote_label = Gtk.Label(label=f'{self.span_text(">")} {_("Quote")}',
                                halign=Gtk.Align.START,
                                use_markup=True)
        quote_keys = Granite.AccelLabel(accel_string='<Control><Shift>j')

        code_label = Gtk.Label(
            label=
            f'{self.span_text("`")}{_("Inline code")}{self.span_text("`")}',
            halign=Gtk.Align.START,
            use_markup=True)
        code_keys = Granite.AccelLabel(accel_string='<Control><Shift>c')

        code_block_label = Gtk.Label(
            label=
            f'{self.span_text("```")}{_("Code block")}{self.span_text("```")}',
            halign=Gtk.Align.START,
            use_markup=True)
        code_block_keys = Granite.AccelLabel(accel_string='<Control><Alt>c')

        grid = Gtk.Grid(
            column_spacing=6,
            row_spacing=6,
            margin_start=12,
            margin_end=12,
            margin_top=12,
            margin_bottom=12,
        )

        grid.attach(h1_label, 1, 0, 1, 1)
        grid.attach(h1_keys, 2, 0, 1, 1)
        grid.attach(h2_label, 1, 1, 1, 1)
        grid.attach(h2_keys, 2, 1, 1, 1)
        grid.attach(h3_label, 1, 2, 1, 1)
        grid.attach(h3_keys, 2, 2, 1, 1)

        grid.attach(self.make_sep(), 1, 3, 3, 1)

        grid.attach(bold_label, 1, 4, 1, 1)
        grid.attach(bold_keys, 2, 4, 1, 1)
        grid.attach(italic_label, 1, 5, 1, 1)
        grid.attach(italic_keys, 2, 5, 1, 1)
        grid.attach(link_label, 1, 6, 1, 1)
        grid.attach(link_keys, 2, 6, 1, 1)
        grid.attach(image_link_label, 1, 7, 1, 1)
        grid.attach(image_link_keys, 2, 7, 1, 1)

        grid.attach(self.make_sep(), 1, 8, 3, 1)

        grid.attach(list_label, 1, 9, 1, 1)
        grid.attach(list_keys, 2, 9, 1, 1)
        grid.attach(ordered_list_label, 1, 10, 1, 1)
        grid.attach(ordered_list_keys, 2, 10, 1, 1)
        grid.attach(quote_label, 1, 11, 1, 1)
        grid.attach(quote_keys, 2, 11, 1, 1)

        grid.attach(self.make_sep(), 1, 13, 3, 1)

        grid.attach(code_label, 1, 14, 1, 1)
        grid.attach(code_keys, 2, 14, 1, 1)
        grid.attach(code_block_label, 1, 15, 1, 1)
        grid.attach(code_block_keys, 2, 15, 1, 1)

        self.get_content_area().add(grid)

        self.show_all()
Esempio n. 3
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()