Example #1
0
    def _copy_pointed(self, mode=""):
        """Copy an item into the clipboard.
           Can copy as all upper or all lower, depending on mode chosen."""
        pointed = self.model.filtered_items[self.view.pointer].encode("utf-8")

        write_text = pointed.upper() if mode == "upper" else \
                     pointed.lower() if mode == "lower" else \
                     pointed

        ClipboardFactory.create().put_text(write_text)
Example #2
0
    def run(self):
        """ Listen to the clipboard. """
        storage = Pickle(expanduser('~/clipp_daemon.pkl'))
        ipc = UDSServer()
        history = storage.get()
        clipboard = ClipboardFactory.create()

        last = lambda x: x[-1] if len(x) > 0 else None

        try:
            while True:
                new_text = clipboard.get_text()

                if new_text and (new_text != last(history)):
                    ipc.broadcast(Protocol.create_new_entry(new_text))
                    history.insert(0, new_text)

                new_clients = ipc.handle_clients()
                for client in new_clients:
                    ipc.send(client, Protocol.create_full_history(history))

                time.sleep(0.01)
        except Exception, exception:
            print ":: ", exception