Python gi.repository.Gdk.SELECTION_CLIPBOARD Examples
The following are 30
code examples of gi.repository.Gdk.SELECTION_CLIPBOARD().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gdk
, or try the search function
.
Example #1
Source File: taskview.py From gtg with GNU General Public License v3.0 | 7 votes |
def copy_clipboard(self, widget, param=None): clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) # First, we analyse the selection to put in our own # GTG clipboard a selection with description of subtasks bounds = self.buff.get_selection_bounds() if not bounds: return start, stop = self.buff.get_selection_bounds() self.clipboard.copy(start, stop, bullet=self.bullet1) text = self.clipboard.paste_text() clip.set_text(text, len(text)) clip.store() if param == "cut": self.buff.delete_selection(False, True) self.stop_emission("cut_clipboard") else: self.stop_emission("copy_clipboard") # Called on paste.
Example #2
Source File: fileactions.py From vimiv with MIT License | 6 votes |
def copy_name(self, abspath=False): """Copy image name to clipboard. Args: abspath: Use absolute path or only the basename. """ # Get name to copy name = self._app.get_pos(True) if abspath: name = os.path.abspath(name) else: name = os.path.basename(name) # Set clipboard clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) \ if settings["copy_to_primary"].get_value() \ else Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) # Text to clipboard clipboard.set_text(name, -1) # Info message message = "Copied <b>" + name + "</b> to %s" % \ ("primary" if settings["copy_to_primary"].get_value() else "clipboard") self._app["statusbar"].message(message, "info")
Example #3
Source File: Pyperclip.py From MIA-Dictionary-Addon with GNU General Public License v3.0 | 6 votes |
def init_gi_clipboard(): import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) def copy_gi(text): cb.set_text(text, -1) cb.store() def paste_gi(): clipboardContents = cb.wait_for_text() # for python 2, returns None if the clipboard is blank. if clipboardContents is None: return '' else: return clipboardContents return copy_gi, paste_gi
Example #4
Source File: main_window.py From ebook-viewer with GNU General Public License v3.0 | 5 votes |
def __on_copy_activate(self, widget): """ Provides dirty clipboard hack to get selection from inside of WebKit :param widget: """ primary_selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) selection_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) # It does wait some short time for that text, it seems to update every now and then # Can get selection from anywhere in the system, no real way to tell selection_clipboard.set_text(primary_selection.wait_for_text(), -1)
Example #5
Source File: BoardView.py From pychess with GNU General Public License v3.0 | 5 votes |
def copy_pgn(self): output = StringIO() clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(pgn.save(output, self.model), -1)
Example #6
Source File: BoardView.py From pychess with GNU General Public License v3.0 | 5 votes |
def copy_fen(self): clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) fen = self.model.getBoardAtPly(self.shown, self.shown_variation_idx).asFen() clipboard.set_text(fen, -1)
Example #7
Source File: websession.py From badKarma with GNU General Public License v3.0 | 5 votes |
def copy_payload(self, widget, payload): """ Copy payload to clipboard """ clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(payload, -1)
Example #8
Source File: pyspc_gui.py From pyspc with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent): Gtk.Dialog.__init__(self, "File Dialog", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_default_size(500, 550) box = self.get_content_area() self.verticalbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3) box.add(self.verticalbox) self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) from_file = Gtk.Button("From File") from_file.connect("clicked", self.on_file) from_clipboard = Gtk.Button("Clipboard") from_clipboard.connect("clicked", self.on_clipboard) hbox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, homogeneous=True) hbox1.pack_start(from_file, True, True, 0) hbox1.pack_start(from_clipboard, True, True, 0) self.verticalbox.pack_start(hbox1, False, False, 0) # Just holding the Place for real treeview widget self.scrollable_treelist = Gtk.Label() self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0) self.show_all()
Example #9
Source File: interface.py From autokey with GNU General Public License v3.0 | 5 votes |
def __init__(self): self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) self._selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
Example #10
Source File: scripting.py From autokey with GNU General Public License v3.0 | 5 votes |
def __init__(self, app): self.clipBoard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) self.selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) self.app = app
Example #11
Source File: results.py From runsqlrun with MIT License | 5 votes |
def copy_value_to_clipboard(self, value): clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(str(value), -1)
Example #12
Source File: clipboard.py From Authenticator with GNU General Public License v2.0 | 5 votes |
def set(string): """ Copy a string to the clipboard. :param string: the string to copy. :type string: str """ clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(string, -1)
Example #13
Source File: App.py From bcloud with GNU General Public License v3.0 | 5 votes |
def update_clipboard(self, text): '''将文本复制到系统剪贴板里面''' clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(text, -1) self.toast(_('{0} copied to clipboard'.format(text)))
Example #14
Source File: backend_gtk3.py From CogAlg with MIT License | 5 votes |
def trigger(self, *args, **kwargs): clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) window = self.canvas.get_window() x, y, width, height = window.get_geometry() pb = Gdk.pixbuf_get_from_window(window, x, y, width, height) clipboard.set_image(pb) # Define the file to use as the GTk icon
Example #15
Source File: main_window.py From Apostrophe with GNU General Public License v3.0 | 5 votes |
def copy_html_to_clipboard(self, _widget=None, _date=None): """Copies only html without headers etc. to Clipboard """ output = helpers.pandoc_convert(self.text_view.get_text()) clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(output, -1) clipboard.store()
Example #16
Source File: window.py From drawing with GNU General Public License v3.0 | 5 votes |
def build_image_from_clipboard(self, *args): """Open a new tab with the image in the clipboard. If the clipboard is empty, the new image will be blank.""" cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) pixbuf = cb.wait_for_image() self.build_new_tab(pixbuf=pixbuf)
Example #17
Source File: window.py From drawing with GNU General Public License v3.0 | 5 votes |
def copy_operation(self): cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) cb.set_image(self.get_active_image().selection.get_pixbuf())
Example #18
Source File: window.py From drawing with GNU General Public License v3.0 | 5 votes |
def action_paste(self, *args): """By default, this action pastes an image, but if there is no image in the clipboard, it will paste text using the text tool. Once the text tool is active, this action is disabled to not interfer with the default behavior of ctrl+v provided by the GTK text entry.""" cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) pixbuf = cb.wait_for_image() if pixbuf is not None: self.force_selection() self.get_selection_tool().import_selection(pixbuf) else: string = cb.wait_for_text() if string is not None: self.tools['text'].force_text_tool(string)
Example #19
Source File: clipboard.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def __init__(self, name): '''Constructor @param name: clipboard name, can be either "CLIPBOARD" or "PRIMARY", see C{Gtk.Clipboard} for details. ''' assert name in ('CLIPBOARD', 'PRIMARY') atom = Gdk.SELECTION_CLIPBOARD if name == 'CLIPBOARD' else Gdk.SELECTION_PRIMARY self.clipboard = Gtk.Clipboard.get(atom) self.data = None
Example #20
Source File: TimelinePedigreeView.py From addons-source with GNU General Public License v2.0 | 5 votes |
def copy_person_to_clipboard_cb(self, obj, person_handle): """ Renders the person data into some lines of text and puts that into the clipboard """ person = self.dbstate.db.get_person_from_handle(person_handle) if person: clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(self.format_helper.format_person(person, 11), -1) return True return False
Example #21
Source File: clipboard.py From Authenticator with GNU General Public License v2.0 | 5 votes |
def clear(): """Clear the clipboard.""" clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.clear()
Example #22
Source File: nautilus_copy_path.py From nautilus-copy-path with MIT License | 5 votes |
def __init__(self): self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
Example #23
Source File: gui_utilities.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def gtk_treeview_selection_to_clipboard(treeview, columns=0): """ Copy the currently selected values from the specified columns in the treeview to the users clipboard. If no value is selected in the treeview, then the clipboard is left unmodified. If multiple values are selected, they will all be placed in the clipboard on separate lines. :param treeview: The treeview instance to get the selection from. :type treeview: :py:class:`Gtk.TreeView` :param column: The column numbers to retrieve the value for. :type column: int, list, tuple """ treeview_selection = treeview.get_selection() (model, tree_paths) = treeview_selection.get_selected_rows() if not tree_paths: return if isinstance(columns, int): columns = (columns,) tree_iters = map(model.get_iter, tree_paths) selection_lines = [] for ti in tree_iters: values = (model.get_value(ti, column) for column in columns) values = (('' if value is None else str(value)) for value in values) selection_lines.append(' '.join(values).strip()) selection_lines = os.linesep.join(selection_lines) clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(selection_lines, -1)
Example #24
Source File: backend_gtk3.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def trigger(self, *args, **kwargs): clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) window = self.canvas.get_window() x, y, width, height = window.get_geometry() pb = Gdk.pixbuf_get_from_window(window, x, y, width, height) clipboard.set_image(pb) # Define the file to use as the GTk icon
Example #25
Source File: QuiltView.py From addons-source with GNU General Public License v2.0 | 5 votes |
def copy_person_to_clipboard(self, obj, person_handle): """ Renders the person data into some lines of text and puts that into the clipboard. """ person = self.dbstate.db.get_person_from_handle(person_handle) if person: cb = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(), Gdk.SELECTION_CLIPBOARD) cb.set_text(self.format_helper.format_person(person, 11), -1) return True return False
Example #26
Source File: HtreePedigreeView.py From addons-source with GNU General Public License v2.0 | 5 votes |
def cb_copy_person_to_clipboard(self, obj, person_handle): """ Renders the person data into some lines of text and puts that into the clipboard """ person = self.dbstate.db.get_person_from_handle(person_handle) if person: clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(), Gdk.SELECTION_CLIPBOARD) clipboard.set_text(self.format_helper.format_person(person, 11), -1) return True return False
Example #27
Source File: HtreePedigreeView.py From addons-source with GNU General Public License v2.0 | 5 votes |
def cb_copy_family_to_clipboard(self, obj, family_handle): """ Renders the family data into some lines of text and puts that into the clipboard """ family = self.dbstate.db.get_family_from_handle(family_handle) if family: clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(), Gdk.SELECTION_CLIPBOARD) clipboard.set_text(self.format_helper.format_relation(family, 11), -1) return True return False
Example #28
Source File: graphview.py From addons-source with GNU General Public License v2.0 | 5 votes |
def copy_person_to_clipboard(self, obj): """ Renders the person data into some lines of text and puts that into the clipboard. """ person_handle = obj.get_data() person = self.dbstate.db.get_person_from_handle(person_handle) if person: _cb = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(), Gdk.SELECTION_CLIPBOARD) format_helper = FormattingHelper(self.dbstate) _cb.set_text(format_helper.format_person(person, 11), -1) return True return False
Example #29
Source File: taskview.py From gtg with GNU General Public License v3.0 | 5 votes |
def paste_clipboard(self, widget, param=None): clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) # if the clipboard text is the same are our own internal # clipboard text, it means that we can paste from our own clipboard # else, that we can empty it. our_paste = self.clipboard.paste_text() if our_paste is not None and clip.wait_for_text() == our_paste: # first, we delete the current selection self.buff.delete_selection(False, True) for line in self.clipboard.paste(): if line[0] == 'text': self.buff.insert_at_cursor(line[1]) if line[0] == 'subtask': tid = line[1] self.new_subtask_callback(tid=tid) mark = self.buff.get_insert() line_nbr = self.buff.get_iter_at_mark(mark).get_line() # we must paste the \n before inserting the subtask # else, we will start another subtask self.buff.insert_at_cursor("\n") self.write_subtask(self.buff, line_nbr, tid) # we handle ourselves the pasting self.stop_emission("paste_clipboard") else: # we keep the normal pasting by not interupting the signal self.clipboard.clear() # Function called each time the user inputs a letter
Example #30
Source File: taskview.py From gtg with GNU General Public License v3.0 | 5 votes |
def __copy_link(self, menu_item, anchor): clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(anchor, -1) clipboard.store()