Exemple #1
0
 def claim(self):
     log("claim() selection=%s, enabled=%s", self._selection, self._enabled)
     if self._enabled and not selection_owner_set(self, self._selection):
         # I don't know how this can actually fail, given that we pass
         # CurrentTime, but just in case:
         log.warn("Failed to acquire local clipboard %s; "
                  % (self._selection,)
                  + "will not be able to pass local apps "
                  + "contents of remote clipboard")
Exemple #2
0
 def got_token(self,
               targets,
               target_data,
               claim=True,
               synchronous_client=False):
     # We got the anti-token.
     self.cancel_emit_token()
     if not self._enabled:
         return
     self._got_token_events += 1
     log(
         "got token, selection=%s, targets=%s, target data=%s, claim=%s, can-receive=%s",
         self._selection, targets, target_data, claim, self._can_receive)
     if self._greedy_client or CLIPBOARD_GREEDY:
         self._block_owner_change = True
         #re-enable the flag via idle_add so events like do_owner_changed
         #get a chance to run first.
         glib.idle_add(self.remove_block)
     if (CLIPBOARD_GREEDY or synchronous_client) and self._can_receive:
         if targets:
             for target in targets:
                 selection_add_target(self, self._selection, target, 0)
             selection_owner_set(self, self._selection)
         if target_data:
             for text_target in TEXT_TARGETS:
                 if text_target in target_data:
                     text_data = target_data.get(text_target)
                     log("clipboard %s set to '%s'", self._selection,
                         repr_ellipsized(text_data))
                     set_clipboard_data(self._clipboard, text_data,
                                        text_target)
     if not claim:
         log("token packet without claim, not setting the token flag")
         #the other end is just telling us to send the token again next time something changes,
         #not that they want to own the clipboard selection
         return
     self._have_token = True
     if self._can_receive:
         if not self._block_owner_change:
             #if we don't claim the selection (can-receive=False),
             #we will have to send the token back on owner-change!
             self._block_owner_change = True
             glib.idle_add(self.remove_block)
         self.claim()