def got_token(self, targets): # We got the anti-token. debug("got token, selection=%s, targets=%s", self._selection, targets) self._have_token = True for target in targets: self.selection_add_target(self._selection, target, 0) self.selection_owner_set(self._selection)
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, 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 _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 remote_to_local(self, selection): debug("remote_to_local(%s) local_clipboard=%s, remote_clipboard=%s", selection, self.local_clipboard, self.remote_clipboard) if selection==self.remote_clipboard: return self.local_clipboard return selection