def on_text_paste(e): if e.EventObject is not textctrl: return e.Skip() if onfilename is not None: files = clipboard.get_files() or [] for file in files: if file.isfile(): if onfilename(file) is False: e.Skip() return if maybe_callable(shorten_urls): text = clipboard.get_text() if text is not None: import util.net if util.isurl(text) and not util.net.is_short_url(text): cancellable = insert_shortened_url(textctrl, text, ondone=onshorten_done) if onshorten is not None: onshorten(cancellable) else: e.Skip() return if onbitmap is not None: bitmap = clipboard.get_bitmap() if bitmap is not None: import stdpaths, time filename = stdpaths.temp / 'digsby.clipboard.%s.png' % time.time() bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG) if onbitmap(filename, bitmap) is False: e.Skip() return e.Skip()
def OnPaste(self, event): text = clipboard.get_text() if text is None: return # our rich text control adds a newline to the end of copied text-- # strip one out if it's there if text.endswith('\n'): text = text[:-1] self.tc.WriteText(text)
def _on_text_ctrl_paste(self, e): e.Skip() if not pref('conversation_window.paste.images', default=True): return # if we have a convo object... convo = self.convo if convo is None: return # and if the protocol supports sending files... from common import caps if caps.FILES not in convo.protocol.caps: return text = clipboard.get_text() # Some forms of text (like excel data) can be sent as images. we'd rather send it as text though. if text is not None: return # and there's a bitmap in the clipboard... bitmap = clipboard.get_bitmap() if bitmap is None: return # show a "send image" dialog buddy = convo.buddy self_name = convo.protocol.self_buddy.name from gui.imagedialog import show_image_dialog message = _(u'Would you like to send this image to %s?') % buddy.name if show_image_dialog(self, message, bitmap): import time, stdpaths filename = '%s.clipboard.%s.png' % (self_name, time.time()) filename = stdpaths.temp / filename bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG) buddy.send_file(filename)