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, format, data): if encoding == "atoms": gdkatoms = gdk_atom_array_from_gdk_atoms(data) log.debug("gdkatoms(%s)=%s", data, gdkatoms) return struct.pack("=" + "L" * len(gdkatoms), *gdkatoms) return ClipboardProtocolHelperBase._munge_wire_selection_to_raw( self, encoding, datatype, format, data)
def _munge_wire_selection_to_raw(self, encoding, datatype, format, data): 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) return struct.pack("=" + "I" * len(atom_array), *atom_array) return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, datatype, format, data)
def _do_munge_raw_selection_to_wire(self, type, format, data): if format == 32 and type in ("ATOM", "ATOM_PAIR"): # 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) return ("atoms", [str(atom) for atom in atoms]) return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, type, format, data)
def _munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data): debug("_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) debug("_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, dtype, dformat, data): debug("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s:%s)", encoding, dtype, dformat, 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) debug("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s)=%s=%s=%s", encoding, dtype, dformat, type(data), len(data or ""), gdk_atoms, atom_array, list(bdata)) return bdata return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, dtype, dformat, data)
def _do_munge_raw_selection_to_wire(self, target, ype, format, data): if format == 32 and type in ("ATOM", "ATOM_PAIR"): # 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) atom_names = [str(atom) for atom in atoms] if target=="TARGET": atom_names.remove("SAVE_TARGETS") atom_names.remove("COMPOUND_TEXT") return ("atoms", atom_names) return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, target, type, format, data)
def _do_munge_raw_selection_to_wire(self, type, format, data): if format == 32: if type in ("ATOM", "ATOM_PAIR"): # 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) return ("atoms", [str(atom) for atom in atoms]) else: sizeof_long = struct.calcsize("@L") format = "@" + "L" * (len(data) // sizeof_long) ints = struct.unpack(format, data) return ("integers", ints) return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, type, format, data)
def _do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data): if dataformat == 32 and datatype in ("ATOM", "ATOM_PAIR"): debug("_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) debug("_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] debug("_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)
def _do_munge_raw_selection_to_wire(self, target, dtype, dformat, data): if dformat == 32 and dtype in ("ATOM", "ATOM_PAIR"): # 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) atom_names = [str(atom) for atom in atoms] if target=="TARGETS": otargets = list(atom_names) discard_targets = ("SAVE_TARGETS", "COMPOUND_TEXT") for x in discard_targets: if x in atom_names: atom_names.remove(x) debug("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) filtered targets(%s)=%s", target, dtype, dformat, type(data), len(data), otargets, atom_names) return ("atoms", atom_names) return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, target, dtype, dformat, data)
def _do_munge_raw_selection_to_wire(self, target, dtype, dformat, data): if dformat == 32 and dtype in ("ATOM", "ATOM_PAIR"): # 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) atom_names = [str(atom) for atom in atoms] if target == "TARGETS": otargets = list(atom_names) discard_targets = ("SAVE_TARGETS", "COMPOUND_TEXT") for x in discard_targets: if x in atom_names: atom_names.remove(x) debug( "_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) filtered targets(%s)=%s", target, dtype, dformat, type(data), len(data), otargets, atom_names) return ("atoms", atom_names) return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire( self, target, dtype, dformat, data)
def __init__(self, send_packet_cb): ClipboardProtocolHelperBase.__init__(self, send_packet_cb, ["CLIPBOARD", "PRIMARY", "SECONDARY"])
def __init__(self, send_packet_cb, local_clipboard="CLIPBOARD", remote_clipboard="PRIMARY"): self.local_clipboard = local_clipboard self.remote_clipboard = remote_clipboard ClipboardProtocolHelperBase.__init__(self, send_packet_cb, [local_clipboard])
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): ClipboardProtocolHelperBase.__init__(self, send_packet_cb, progress_cb, ["CLIPBOARD"])
def _munge_wire_selection_to_raw(self, encoding, type, format, data): if encoding == "atoms": d = gtk.gdk.display_get_default() ints = [get_xatom(d, a) for a in data] return struct.pack("@" + "L" * len(ints), *ints) return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, type, format, data)
def _munge_wire_selection_to_raw(self, encoding, datatype, format, data): if encoding == "atoms": ints = [get_xatom(a) for a in data] log.debug("wire to raw: atoms(%s)=%s", data, ints) return struct.pack("=" + "L" * len(ints), *ints) return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, datatype, format, data)