本文整理汇总了Python中gi.repository.Gdk.SELECTION_PRIMARY属性的典型用法代码示例。如果您正苦于以下问题:Python Gdk.SELECTION_PRIMARY属性的具体用法?Python Gdk.SELECTION_PRIMARY怎么用?Python Gdk.SELECTION_PRIMARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gdk
的用法示例。
在下文中一共展示了Gdk.SELECTION_PRIMARY属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_max_input
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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)
示例2: copy_name
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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")
示例3: test_read_board
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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'))
示例4: test_update_board
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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())
示例5: test_clipboard
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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)
示例6: callback
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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)
示例7: __init__
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
def __init__(self):
self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
self._selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
示例8: __init__
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
def __init__(self, app):
self.clipBoard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
self.selection = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
self.app = app
示例9: __on_copy_activate
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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)
示例10: __init__
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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
示例11: get_clipboard_contents
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import SELECTION_PRIMARY [as 别名]
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