def __init__(self, send_packet_cb, progress_cb=None, clipboards=CLIPBOARDS, filter_res=None): ClipboardProtocolHelperBase.__init__(self, send_packet_cb, progress_cb, clipboards, filter_res)
def __init__(self, send_packet_cb, progress_cb=None, local_clipboard="CLIPBOARD", remote_clipboard="CLIPBOARD"): self.local_clipboard = local_clipboard self.remote_clipboard = remote_clipboard ClipboardProtocolHelperBase.__init__(self, send_packet_cb, progress_cb, [local_clipboard])
def _munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data): log( "_munge_wire_selection_to_raw(%s, %s, %s, %s:%s:%s)", encoding, datatype, dataformat, type(data), len(data or ""), list(data or ""), ) if encoding == "atoms": import gtk.gdk gdk_atoms = [gtk.gdk.atom_intern(a) for a in data] atom_array = gdk_atom_array_from_gdk_atom_objects(gdk_atoms) bdata = struct.pack("=" + "Q" * len(atom_array), *atom_array) log( "_munge_wire_selection_to_raw(%s, %s, %s, %s:%s)=%s=%s=%s", encoding, datatype, dataformat, type(data), len(data or ""), gdk_atoms, atom_array, list(bdata), ) return bdata return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data)
def _munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data): if encoding==b"atoms" and gdk_atoms: atom_array = gdk_atoms.gdk_atom_array_from_atoms(data) bdata = struct.pack(b"@" + b"L" * len(atom_array), *atom_array) log("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s)=%s=%s=%s", encoding, datatype, dataformat, type(data), len(data or ""), data, atom_array, tuple(bdata)) return bdata return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data)
def __init__(self, *args, **kwargs): def getselection(name): v = kwargs.get("clipboard.%s" % name) #ie: clipboard.remote env_value = os.environ.get("XPRA_TRANSLATEDCLIPBOARD_%s_SELECTION" % name.upper()) selections = kwargs.get("clipboards.%s" % name) #ie: clipboards.remote assert selections, "no %s clipboards!" % name for x in (env_value, v): if x and x in selections: return x return selections[0] self.local_clipboard = getselection("local") self.remote_clipboard = getselection("remote") log("TranslatedClipboardProtocolHelper local=%s, remote=%s", self.local_clipboard, self.remote_clipboard) #the local clipboard cannot be changed! #we tell the superclass to only initialize this proxy: kwargs["clipboards.local"] = [self.local_clipboard] #this one can be changed (we send a packet to change the enabled selections) kwargs["clipboards.remote"] = [self.remote_clipboard] ClipboardProtocolHelperBase.__init__(self, *args, **kwargs)
def _munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data): log("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s:%s)", encoding, datatype, dataformat, type(data), len(data or ""), list(data or "")) if encoding == "atoms": import gtk.gdk gdk_atoms = [gtk.gdk.atom_intern(a) for a in data] atom_array = gdk_atom_array_from_gdk_atom_objects(gdk_atoms) bdata = struct.pack("@" + "L" * len(atom_array), *atom_array) log("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s)=%s=%s=%s", encoding, datatype, dataformat, type(data), len(data or ""), gdk_atoms, atom_array, list(bdata)) return bdata return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data)
def _do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data): if dataformat==32 and datatype in (b"ATOM", b"ATOM_PAIR") and gdk_atoms: # Convert to strings and send that. Bizarrely, the atoms are # not actual X atoms, but an array of GdkAtom's reinterpreted # as a byte buffer. atoms = gdk_atoms.gdk_atom_objects_from_gdk_atom_array(data) log("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) atoms=%s", target, datatype, dataformat, type(data), len(data), tuple(atoms)) atom_names = [str(atom) for atom in atoms] if target==b"TARGETS": atom_names = _filter_targets(atom_names) return "atoms", atom_names return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data)
def _do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data): if dataformat == 32 and datatype in ("ATOM", "ATOM_PAIR"): log("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s:%s) using gdk atom code", target, datatype, dataformat, type(data), len(data), list(data)) # Convert to strings and send that. Bizarrely, the atoms are # not actual X atoms, but an array of GdkAtom's reinterpreted # as a byte buffer. atoms = gdk_atom_objects_from_gdk_atom_array(data) log("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) atoms=%s", target, datatype, dataformat, type(data), len(data), list(atoms)) atom_names = [str(atom) for atom in atoms] log("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) atom_names=%s", target, datatype, dataformat, type(data), len(data), atom_names) if target=="TARGETS": atom_names = self._filter_targets(atom_names) return "atoms", atom_names return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data)