Beispiel #1
0
    def setup_toolbar(self):
        activity_button = ActivityToolbarButton(self)
        self.toolbar.insert(activity_button, -1)

        self.toolbar.insert(Gtk.SeparatorToolItem(), -1)

        edit_toolbar = EditToolbar()
        self.toolbar.insert(
            ToolbarButton(
                page=edit_toolbar, icon_name="toolbar-edit"), -1)

        edit_toolbar.insert(Gtk.SeparatorToolItem(), -1)

        self.button_bold = ToggleToolButton("format-text-bold")
        self.button_bold.set_tooltip(_("Bold"))
        self.button_bold.props.accelerator = "<Ctrl>B"
        self.button_bold.connect(
            "toggled", lambda button: self.edit.toggle_bold())
        edit_toolbar.insert(self.button_bold, -1)

        self.button_italic = ToggleToolButton("format-text-italic")
        self.button_italic.set_tooltip(_("Italic"))
        self.button_italic.props.accelerator = "<Ctrl>I"
        self.button_italic.connect(
            "toggled", lambda button: self.edit.toggle_italic())
        edit_toolbar.insert(self.button_italic, -1)

        self.button_underline = ToggleToolButton("format-text-underline")
        self.button_underline.set_tooltip(_("Underline"))
        self.button_underline.props.accelerator = "<Ctrl>U"
        self.button_underline.connect(
            "toggled", lambda button: self.edit.toggle_underline())
        edit_toolbar.insert(self.button_underline, -1)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self.toolbar.insert(separator, -1)

        stop_button = StopButton(self)
        self.toolbar.insert(stop_button, -1)

        self.toolbarbox.show_all()
        edit_toolbar.show_all()
Beispiel #2
0
    def setup_toolbar(self):
        activity_button = ActivityToolbarButton(self)
        self.toolbar.insert(activity_button, -1)

        self.toolbar.insert(Gtk.SeparatorToolItem(), -1)

        edit_toolbar = EditToolbar()
        self.toolbar.insert(ToolbarButton(page=edit_toolbar, icon_name="toolbar-edit"), -1)

        edit_toolbar.insert(Gtk.SeparatorToolItem(), -1)

        self.button_bold = ToggleToolButton("format-text-bold")
        self.button_bold.set_tooltip(_("Bold"))
        self.button_bold.props.accelerator = "<Ctrl>B"
        self.button_bold.connect("toggled", lambda button: self.edit.toggle_bold())
        edit_toolbar.insert(self.button_bold, -1)

        self.button_italic = ToggleToolButton("format-text-italic")
        self.button_italic.set_tooltip(_("Italic"))
        self.button_italic.props.accelerator = "<Ctrl>I"
        self.button_italic.connect("toggled", lambda button: self.edit.toggle_italic())
        edit_toolbar.insert(self.button_italic, -1)

        self.button_underline = ToggleToolButton("format-text-underline")
        self.button_underline.set_tooltip(_("Underline"))
        self.button_underline.props.accelerator = "<Ctrl>B"
        self.button_underline.connect("toggled", lambda button: self.edit.toggle_underline())
        edit_toolbar.insert(self.button_underline, -1)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self.toolbar.insert(separator, -1)

        stop_button = StopButton(self)
        self.toolbar.insert(stop_button, -1)

        self.toolbarbox.show_all()
        edit_toolbar.show_all()
    def make_toolbar(self):
        def make_separator(toolbar, expand=True):
            separator = Gtk.SeparatorToolItem()
            separator.props.draw = not expand
            separator.set_expand(expand)
            toolbar.insert(separator, -1)

        toolbar_box = ToolbarBox()
        toolbar = toolbar_box.toolbar

        activity_button = ToolButton()
        activity_button.set_icon_widget(ActivityIcon(None))
        toolbar.insert(activity_button, -1)

        toolbar.insert(Gtk.SeparatorToolItem(), -1)

        toolbar_file = Gtk.Toolbar()
        boton_toolbar_file = ToolbarButton(page=toolbar_file, icon_name='txt')
        toolbar.add(boton_toolbar_file)

        toolbar_edit = EditToolbar()
        button_toolbar_edit = ToolbarButton(page=toolbar_edit,
                                            icon_name='toolbar-edit')
        toolbar.insert(button_toolbar_edit, -1)

        toolbar_view = Gtk.Toolbar()
        boton_toolbar_view = ToolbarButton(page=toolbar_view,
                                           icon_name='toolbar-view')
        toolbar.insert(boton_toolbar_view, -1)

        self.button_undo = toolbar_edit.undo
        self.button_undo.props.accelerator = '<Ctrl>Z'
        self.button_undo.set_sensitive(False)
        toolbar_edit.undo.connect('clicked', self.undo)

        self.button_redo = toolbar_edit.redo
        self.button_redo.props.accelerator = '<Ctrl><Mayus>Z'
        self.button_redo.set_sensitive(False)
        self.button_redo.connect('clicked', self.redo)

        self.entry_search = IconEntry()
        item_entry = Gtk.ToolItem()
        self.entry_search.set_size_request(250, -1)
        self.entry_search.set_placeholder_text('Search...')
        self.entry_search.set_icon_from_name(Gtk.EntryIconPosition.SECONDARY,
                                             'search')
        self.entry_search.connect('changed', self.search_text)
        self.entry_search.connect('activate', self.search_text, True)
        item_entry.add(self.entry_search)
        toolbar_edit.insert(item_entry, -1)

        self.entry_replace = IconEntry()
        item_entry = Gtk.ToolItem()
        self.entry_replace.set_size_request(250, -1)
        self.entry_replace.set_placeholder_text('Replace...')
        self.entry_replace.connect('activate', self.replace_text)
        item_entry.add(self.entry_replace)
        toolbar_edit.insert(item_entry, -1)

        button_new = ToolButton('new-file')
        button_new.props.accelerator = '<Ctrl>N'
        button_new.connect('clicked', lambda w: self.new_page())
        button_new.set_tooltip(_('New file'))
        toolbar_file.insert(button_new, -1)

        button_open = ToolButton('fileopen')
        button_open.props.accelerator = '<Ctrl>O'
        button_open.set_tooltip(_('Open file from file system'))
        button_open.connect('clicked', self.file_chooser_open)
        toolbar_file.insert(button_open, -1)

        self.button_save = ToolButton('filesave')
        self.button_save.props.accelerator = '<Ctrl>S'
        self.button_save.set_tooltip(_('Save file to the file system'))
        self.button_save.connect('clicked', self.file_chooser_save)
        toolbar_file.insert(self.button_save, -1)

        button_save_as = ToolButton('save-as')
        button_save_as.props.accelerator = '<Ctrl><Mayus>S'
        button_save_as.set_tooltip(_('Save as file to the file system'))
        button_save_as.connect('clicked', self.file_chooser_save, True)
        toolbar_file.insert(button_save_as, -1)

        make_separator(toolbar_file, False)

        button_print = ToolButton('printer')
        button_print.props.accelerator = '<Ctrl>I'
        button_print.set_tooltip(_('Print file'))
        button_print.connect('clicked', self.print_file)
        toolbar_file.insert(button_print, -1)

        make_separator(toolbar_edit, False)

        button_clock = ToolButton('clock')
        button_clock.props.accelerator = '<Ctrl>T'
        button_clock.set_tooltip(_('Insert date and time'))
        button_clock.connect('clicked', self.insert_date_and_time)
        toolbar_edit.insert(button_clock, -1)

        button_wrap_none = Gtk.RadioToolButton()
        button_wrap_none.set_icon_name('wrap-none')
        button_wrap_none.connect("toggled", self.wrap_mode_changed, 'none')
        toolbar_view.insert(button_wrap_none, -1)

        button_wrap_char = Gtk.RadioToolButton.new_from_widget(
            button_wrap_none)
        button_wrap_char.set_icon_name('format-justify-fill')
        button_wrap_char.connect("toggled", self.wrap_mode_changed, 'char')
        toolbar_view.insert(button_wrap_char, -1)

        button_wrap_word = Gtk.RadioToolButton.new_from_widget(
            button_wrap_none)
        button_wrap_word.set_icon_name('format-justify-left')
        button_wrap_word.connect("toggled", self.wrap_mode_changed, 'word')
        toolbar_view.insert(button_wrap_word, -1)

        if self.conf['wrap-mode'] == 'none':
            button_wrap_none.set_active(True)

        elif self.conf['wrap-mode'] == 'char':
            button_wrap_none.set_active(True)

        elif self.conf['wrap-mode'] == 'word':
            button_wrap_none.set_active(True)

        make_separator(toolbar_view, False)

        item_font_size = FontSize()
        item_font_size.set_font_size(self.conf['font-size'])
        item_font_size.connect('changed', self.font_size_changed)
        toolbar_view.insert(item_font_size, -1)

        combo_font = FontComboBox(self.conf['font'])
        combo_font.connect('changed', self.font_changed)
        toolbar_view.insert(combo_font, -1)

        make_separator(toolbar_view, False)

        button_numbers = ToggleToolButton('show-numbers')
        button_numbers.props.accelerator = '<Ctrl><Mayus>N'
        button_numbers.set_tooltip(_('Show line numbers'))
        button_numbers.set_active(self.conf['show-line-numbers'])
        button_numbers.connect('toggled', self.show_numbers_changed)
        toolbar_view.insert(button_numbers, -1)

        button_right_line = ToggleToolButton('show-right-line')
        button_right_line.props.accelerator = '<Ctrl>L'
        button_right_line.set_tooltip(_('Show a line in a specific position'))
        button_right_line.set_active(self.conf['show-right-line'])
        button_right_line.connect('toggled', self.show_right_line_changed)
        toolbar_view.insert(button_right_line, -1)

        self.spinner_right_line = Spinner(self.conf['right-line-pos'], 1, 150)
        self.spinner_right_line.set_sensitive(self.conf['show-right-line'])
        self.spinner_right_line.connect('value-changed',
                                        self.right_line_pos_changed)
        toolbar_view.insert(self.spinner_right_line, -1)

        make_separator(toolbar_view, False)

        combo_styles = ComboStyles(self.conf['theme'])
        combo_styles.connect('theme-changed', self.theme_changed)
        toolbar_view.insert(combo_styles, -1)

        make_separator(toolbar, True)

        button_stop = ToolButton('activity-stop')
        button_stop.props.accelerator = '<Ctrl>Q'
        button_stop.connect('clicked', self._exit)
        toolbar.insert(button_stop, -1)

        toolbar_file.show_all()
        toolbar_edit.show_all()
        toolbar_view.show_all()

        toolbar_edit.copy.hide()
        toolbar_edit.paste.hide()

        self.set_toolbar_box(toolbar_box)