Beispiel #1
0
 def _munge_raw_selection_to_wire(self, type, format, data):
     # Some types just cannot be marshalled:
     if type in ("WINDOW", "PIXMAP", "BITMAP", "DRAWABLE",
                 "PIXEL", "COLORMAP"):
         return (None, None)
     # Other types need special handling, and all types need to be
     # converting into an endian-neutral format:
     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)
     elif format == 16:
         sizeof_short = struct.calcsize("@H")
         assert sizeof_short == 16
         format = "@" + "H" * (len(data) // sizeof_short)
         return ("integers", struct.unpack(format, data))
     else:
         assert format == 8
         return ("bytes", data)
Beispiel #2
0
 def _munge_raw_selection_to_wire(self, type, format, data):
     # Some types just cannot be marshalled:
     if type in ("WINDOW", "PIXMAP", "BITMAP", "DRAWABLE",
                 "PIXEL", "COLORMAP"):
         return (None, None)
     # Other types need special handling, and all types need to be
     # converting into an endian-neutral format:
     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)
     elif format == 16:
         sizeof_short = struct.calcsize("@H")
         assert sizeof_short == 16
         format = "@" + "H" * (len(data) // sizeof_short)
         return ("integers", struct.unpack(format, data))
     else:
         assert format == 8
         return ("bytes", data)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
 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)