Example #1
0
 def unpack(clipboard, selection_data, _user_data=None):
     log("unpack %s: %s", clipboard, type(selection_data))
     global sanitize_gtkselectiondata
     if selection_data and sanitize_gtkselectiondata(selection_data):
         self._clipboard.set_text("", len=-1)
         selection_data = None
     if selection_data is None:
         cb(None, None, None)
         return
     log("unpack: %s", selection_data)
     data = selectiondata_get_data(selection_data)
     dtype = selectiondata_get_data_type(selection_data)
     dformat = selectiondata_get_format(selection_data)
     log("unpack(..) type=%s, format=%s, data=%s:%s", dtype, dformat, type(data), len(data or ""))
     isstring = dtype in (b"UTF8_STRING", b"STRING") and dformat==8
     if isstring:
         if self._strip_nullbyte:
             #we may have to strip the nullbyte:
             if data and data[-1]=='\0':
                 log("stripping end of string null byte")
                 data = data[:-1]
         if data and data==self._loop_uuid:
             log("not sending loop uuid value '%s', returning an empty string instead", data)
             data= ""
     cb(str(dtype), dformat, data)
Example #2
0
 def unpack(clipboard, selection_data, _user_data=None):
     log("unpack %s: %s", clipboard, type(selection_data))
     global sanitize_gtkselectiondata
     if selection_data and sanitize_gtkselectiondata(selection_data):
         self._clipboard.set_text("")
     if selection_data is None:
         cb(None, None, None)
         return
     log("unpack: %s", selection_data)
     data = selectiondata_get_data(selection_data)
     dtype = selectiondata_get_data_type(selection_data)
     dformat = selectiondata_get_format(selection_data)
     log("unpack(..) type=%s, format=%s, data=%s:%s", dtype, dformat,
         type(data), len(data or ""))
     if self._strip_nullbyte and dtype in (b"UTF8_STRING",
                                           b"STRING") and dformat == 8:
         #we may have to strip the nullbyte:
         if data and data[-1] == '\0':
             log("stripping end of string null byte")
             data = data[:-1]
     cb(str(dtype), dformat, data)