Recover the gtk.Image object to store the map for easier redraw
authorjaviplx <javiplx@gmail.com>
Sun, 1 May 2011 20:58:19 +0000 (20:58 +0000)
committerjaviplx <javiplx@gmail.com>
Sun, 1 May 2011 20:58:19 +0000 (20:58 +0000)
git-svn-id: file:///svnroot/wifihood/branches/cleaning@107 c51dfc6a-5949-4919-9c8e-f207a149c383

wifimap/view.py

index cd24ed8..ddaac4b 100755 (executable)
@@ -145,6 +145,10 @@ class simpleMapWidget ( AbstractmapWidget , gtk.DrawingArea ) :
         gtk.DrawingArea.__init__(self)
         self.set_size_request(map_size[0] , map_size[1])
 
+        self.mapimage = gtk.Image()
+        p = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.win_x, self.win_y)
+        self.mapimage.set_from_pixbuf(p)
+
         self.connect("expose-event", self.expose)
 
     def expose(self, area, event):
@@ -160,8 +164,6 @@ class simpleMapWidget ( AbstractmapWidget , gtk.DrawingArea ) :
         center_x -= self.refpix_x
         center_y -= self.refpix_y
 
-        gc = self.style.fg_gc[gtk.STATE_NORMAL]
-
         # Ranges should be long enough as to fill the screen
         # Maybe they should be decided based on self.win_x, self.win_y
         for i in range(-3,4) :
@@ -206,9 +208,12 @@ class simpleMapWidget ( AbstractmapWidget , gtk.DrawingArea ) :
                    size_y = self.win_y - dest_y
 
                 if ( size_x > 0 and size_y > 0 ) and ( init_x < self.tile_size and init_y < self.tile_size ) :
-                    self.window.draw_pixbuf( gc, pixbuf, init_x, init_y, dest_x, dest_y, size_x, size_y )
+                    pixbuf.copy_area( init_x, init_y, size_x, size_y, self.mapimage.get_pixbuf(), dest_x , dest_y )
                 del(pixbuf)
 
+        gc = self.style.fg_gc[gtk.STATE_NORMAL]
+        self.window.draw_pixbuf( gc, self.mapimage.get_pixbuf(), 0, 0, 0, 0, self.win_x, self.win_y )
+
     def draw_paths( self ) :
 
         center_x , center_y = self.win_x / 2 , self.win_y / 2