430
430
loader = gtk.gdk.PixbufLoader()
431
431
loader.write(mem); loader.close()
433
433
anchor = self.textbuf.create_child_anchor(self.iter)
434
434
img = AnimatedResizableImage(100, 100, self.canResize)
435
435
img.set_tooltip(attrs['alt'])
666
667
self._changed_cursor = False
667
668
self.linkColor = "#0000FF"
670
self.connect('copy-clipboard', self._on_copy_clipboard)
671
self.clipboard = gtk.Clipboard(selection=gtk.gdk.atom_intern("CLIPBOARD"))
672
self.get_buffer().add_selection_clipboard(self.clipboard)
669
675
self.connect("motion-notify-event", self.__motion_notify_event)
670
676
self.connect("leave-notify-event", self.__leave_event)
671
677
self.connect("enter-notify-event", self.__motion_notify_event)
845
851
if not self.isScrollLocked():
846
852
# very ugly but quite effective.
847
853
gobject.timeout_add(200, self.scrollToBottom, True)
855
def _on_copy_clipboard(self, textview):
856
''' replaces the copied text with a new text with the
857
alt text of the images selected at copying '''
858
buffer = textview.get_buffer()
859
if buffer.get_has_selection():
860
iterStart, iterEnd = buffer.get_selection_bounds()
861
if iterStart.get_offset() > iterEnd.get_offset():
863
iterStart = iterEnd.copy()
864
iterEnd = temp.copy() #set the right begining
866
text = buffer.get_slice(iterStart, iterEnd)
868
#TODO: magic string '\xef\xbf\xbc', object replacement special char
869
while iterStart.forward_search('\xef\xbf\xbc', \
870
gtk.TEXT_SEARCH_VISIBLE_ONLY):
872
iterPos, iterEnd = iterStart.forward_search('\xef\xbf\xbc', \
873
gtk.TEXT_SEARCH_VISIBLE_ONLY)
874
anchor = iterPos.get_child_anchor()
875
if anchor and anchor.get_widgets():
876
widget = anchor.get_widgets()[0]
877
if isinstance(widget, gtk.EventBox):
878
alt = anchor.get_widgets()[0].child.get_tooltip_text()
880
alt = anchor.get_widgets()[0].get_tooltip_text()
884
text = text.replace('\xef\xbf\xbc', alt, 1)
888
self.clipboard.set_text(text)
889
self.clipboard.store()
892
self.get_buffer().set_text('')
849
895
if __name__ == '__main__':
850
896
sw = gtk.ScrolledWindow()