Python gi.repository.Gdk.SELECTION_PRIMARY Examples
The following are 11
code examples of gi.repository.Gdk.SELECTION_PRIMARY().
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: tests.py From clipster with GNU Affero General Public License v3.0 | 6 votes |
def test_max_input(self, mock_socket): """Test that the max_input limit works.""" max_input = self.config.getint('clipster', 'max_input') header = "SEND:PRIMARY:0:" # Set the text to be the same length as max_input # so that total length (plus header) exceeds it. text = "x" * max_input conn = mock_socket.connect # Make mock conn.recv simulate bufsize 'trimming' conn.recv.side_effect = lambda l: (header + text)[:l] # Set up a fake conn fileno and client_msgs dictionary conn.fileno.return_value = 0 self.daemon.client_msgs = {0: []} while True: if not self.daemon.socket_recv(conn, None): break text = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY).wait_for_text() # check that text length has been trimmed to max_input self.assertEqual(len(header) + len(text), max_input)
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: tests.py From clipster with GNU Affero General Public License v3.0 | 5 votes |
def test_read_board(self): """Test reading from a previously set clipboard.""" msg = "clipster test text." primary = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) primary.set_text(msg, -1) self.assertEqual(msg, self.daemon.read_board('primary'))
Example #4
Source File: tests.py From clipster with GNU Affero General Public License v3.0 | 5 votes |
def test_update_board(self): """Test Updating the clipboard.""" msg = "clipster test text.\n" self.daemon.update_board('primary', msg) primary = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) self.assertEqual(msg, primary.wait_for_text())
Example #5
Source File: fileactions_test.py From vimiv with MIT License | 5 votes |
def test_clipboard(self): """Copy image name to clipboard.""" def compare_text(clipboard, text, expected_text): self.compare_result = False self.compare_result = text == expected_text name = self.vimiv.get_pos(True) basename = os.path.basename(name) abspath = os.path.abspath(name) clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) primary = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) # Copy basename and abspath to clipboard self.vimiv["clipboard"].copy_name(False) # Check if the info message is displayed correctly self.check_statusbar("INFO: Copied " + basename + " to clipboard") clipboard.request_text(compare_text, basename) self.assertTrue(self.compare_result) self.vimiv["clipboard"].copy_name(True) clipboard.request_text(compare_text, abspath) self.assertTrue(self.compare_result) # Toggle to primary and copy basename self.run_command("set copy_to_primary!") self.vimiv["clipboard"].copy_name(False) primary.request_text(compare_text, basename) self.assertTrue(self.compare_result) # Toggle back to clipboard and copy basename self.run_command("set copy_to_primary!") self.vimiv["clipboard"].copy_name(False) clipboard.request_text(compare_text, basename) self.assertTrue(self.compare_result)
Example #6
Source File: terminator_search.py From terminator-search with MIT License | 5 votes |
def callback(self, menuitems, menu, terminal): # retrive the context of clipboard self.clipboard = Gtk.Clipboard.get(Gdk.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)
Example #7
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 #8
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 #9
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 #10
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 #11
Source File: clipboard.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def get_clipboard_contents(targetname): '''Convenience function to get data from clipboard''' myclipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) atom = Gdk.Atom.intern(targetname, False) selection = myclipboard.wait_for_contents(atom) assert selection is not None return selection.data