示例#1
0
    def __init__(self, history_item):
        super().__init__()

        self.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.set_name('HistoryItemBox')
        self.connect('enter-notify-event', self._on_enter_event)
        self.connect('leave-notify-event', self._on_leave_event)

        self._weakref = weakref.ref(history_item, lambda w: self.destroy())
        self._preview = None
        self._kind_indicator = ItemKindIndicator(self.item.kind)
        self._label = ItemLabel()
        self._active_indicator = ActiveIndicator(self.item.kind)
        self._shortcut_hint = ShortcutHint()
        self.set_active(False)

        if (self.item.kind == HistoryItemKind.TEXT and self.item.links):
            self._infobox = LinksButton(self.item)
        elif (self.item.kind == HistoryItemKind.FILE
              and self.item.n_lines > 1):
            self._infobox = FilesButton(self.item)
        else:
            if (self.item.kind == HistoryItemKind.LINK
                    or self.item.kind == HistoryItemKind.FILE
                    or common.SETTINGS[common.SHOW_TEXT_INFO]):
                self._infobox = Infobox(self.item)
            else:
                # dummy
                self._infobox = Gtk.Box()

        self._grid = Gtk.Grid()
        self._grid.attach(self._kind_indicator, 1, 1, 1, 2)
        self._grid.attach(self._label, 2, 1, 1, 1)
        self._grid.attach(self._infobox, 2, 2, 1, 1)
        self._grid.attach(self._active_indicator, 0, 0, 3, 1)

        if (self.item.thumb_path and common.SETTINGS[common.SHOW_THUMBNAILS]):
            self._preview = ItemThumb(self.item.thumb_path, -1,
                                      common.SETTINGS[common.ITEM_MAX_HEIGHT])
            self._grid.attach(self._preview, 1, 1, 1, 2)

        overlay = Gtk.Overlay()
        overlay.add(self._grid)
        overlay.add_overlay(self._shortcut_hint)

        self.add(overlay)
        self.show_all()
示例#2
0
    def __init__(self):
        super().__init__(_('Preview'), ItemsProcessorPriority.HIGH)

        self._thumb_max_width = Previewer.THUMB_MAX_WIDTH
        self._thumb_max_height = Previewer.THUMB_MAX_HEIGHT

        self._thumb = ItemThumb()
        self._thumb.set_vexpand(True)
        self._thumb.set_hexpand(True)
        self._thumb.set_valign(Gtk.Align.CENTER)
        self._thumb.set_halign(Gtk.Align.CENTER)
        self._thumb.props.margin = ItemsProcessorBase.MARGIN
        self._thumb.show()

        self._thumb_eventbox = Gtk.EventBox()
        self._thumb_eventbox.set_no_show_all(True)
        self._thumb_eventbox.add(self._thumb)
        self._thumb_eventbox.connect('realize', self._change_cursor)
        self._thumb_eventbox.connect('button-release-event',
                                     self._on_thumb_button_release)
        self._thumb_eventbox.set_tooltip_text(
            _('Click to locate the file on disk'))
        self._thumb_eventbox.hide()

        self._path_entry = Gtk.Entry()
        self._path_entry.set_editable(False)
        self._path_entry.set_hexpand(True)
        self._path_entry.set_icon_from_icon_name(
            Gtk.EntryIconPosition.PRIMARY, 'system-file-manager-symbolic')
        self._path_entry.props.margin = ItemsProcessorBase.MARGIN

        self._text_window = TextWindow()
        self._text_window.set_no_show_all(True)
        self._text_window.textview.set_name('EditorTextView')
        self._text_window.textview.set_editable(False)
        self._text_window.hide()

        self.grid.set_name('PreviwerGrid')
        self.grid.attach(self._path_entry, 0, 0, 2, 1)
        self.grid.attach(self._thumb_eventbox, 0, 1, 2, 1)
        self.grid.attach(self._text_window, 0, 1, 2, 1)