Esempio n. 1
0
def get_clipboard_text():
    text = (
        Clipboard.get(selection=SELECTION_CLIPBOARD).wait_for_text()
        or Clipboard.get().wait_for_text()
    )
    if text:
        return text.strip()
    def callback(self, menuitems, menu, terminal):
        # retrive the context of clipboard
        self.clipboard = Clipboard.get(SELECTION_PRIMARY)
        self.content = self.clipboard.wait_for_text()

        # extract 5 character of the clipboard
        content_summary = self.content[0:10].strip()

        # make available search item in context menu if the clipboard isn't empty
        if len(content_summary) > 0 and content_summary != None:
            self.add_submenu(menu, ('Search For %s...' % (content_summary)),
                             terminal)
Esempio n. 3
0
 def copy_clipboard(self, clipboard: Gtk.Clipboard, buffer):
     surface = buffer.get_surface()
     cr = cairo.Context(surface)
     self._create_path(cr)
     left, top, right, bottom = cr.path_extents()
     left = math.floor(left)
     top = math.floor(top)
     right = math.ceil(right)
     bottom = math.ceil(bottom)
     width = right - left
     height = bottom - top
     assert 0 <= width and 0 <= height
     if width <= 0 or height <= 0:
         return
     copy = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
     cr = cairo.Context(copy)
     cr.translate(-left, -top)
     self._create_path(cr)
     cr.clip()
     cr.set_source_surface(surface, 0, 0)
     cr.paint()
     pixbuf = Gdk.pixbuf_get_from_surface(copy, 0, 0, width, height)
     clipboard.set_image(pixbuf)
Esempio n. 4
0
 def GetClipboard(selection):
     return Clipboard.get(CLIPBOARD_SELECTION[selection])
Esempio n. 5
0
 def GetClipboard(selection):
     return Clipboard.get(CLIPBOARD_SELECTION[selection])
Esempio n. 6
0
def get_clipboard_text():
    text = (Clipboard.get(SELECTION_CLIPBOARD).wait_for_text()
            or Clipboard.get(SELECTION_PRIMARY).wait_for_text())
    if text:
        return text.strip()
Esempio n. 7
0
 def copy_clipboard(self, clipboard: Gtk.Clipboard, buffer):
     clipboard.set_text(self.text, -1)