From 9d3229e8e5d927807c1cb5d5cfc9438c8d7b9503 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 30 Oct 2009 20:28:58 +0000 Subject: updated bubble message with image --- diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py index 6a2c421..2c6bd41 100644 --- a/tutorius/overlayer.py +++ b/tutorius/overlayer.py @@ -488,7 +488,12 @@ class TextBubbleWImg(gtk.Widget): self.speaker = speaker self.tailpos = tailpos self.line_width = 5 - self.padding = 50 + self.padding = 20 + + # image painting + self.filename = "/home/dave/Pictures/Favicon_01.png" + self.pixbuf = gtk.gdk.pixbuf_new_from_file(self.filename) + self.imgsize = (self.pixbuf.get_width(), self.pixbuf.get_height()) self._no_expose = False self.__exposer = None @@ -553,23 +558,19 @@ class TextBubbleWImg(gtk.Widget): text_size = self._text_layout.get_pixel_size() pangoctx.move_to( int((self.allocation.width-text_size[0])/2), - int(self.line_width)) + int(self.line_width+self.imgsize[1]+self.padding/2)) pangoctx.show_layout(self._text_layout) - # image painting - filename = "/home/dave/Pictures/Favicon_01.png" - pixbuf = gtk.gdk.pixbuf_new_from_file(filename) - x = pixbuf.get_width() - y = pixbuf.get_height() # create a new cairo surface to place the image on #surface = cairo.ImageSurface(0,x,y) # create a context to the new surface #ct = cairo.Context(surface) + # paint image context.set_source_pixbuf( - pixbuf, + self.pixbuf, int((self.allocation.width-text_size[0])/2), - int(self.line_width+text_size[1])) + int(self.line_width+self.padding/2)) context.paint() @@ -611,8 +612,8 @@ class TextBubbleWImg(gtk.Widget): self._text_layout.set_markup(self.__label) width, height = self._text_layout.get_pixel_size() - requisition.width = int(width+2*self.padding) - requisition.height = int(height+2*self.padding) + requisition.width = int(width+2*self.padding+self.imgsize[0]) + requisition.height = int(height+2*self.padding+self.imgsize[1]) def do_size_allocate(self, allocation): """Save zone allocated to the widget.""" -- cgit v0.9.1