diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2012-06-28 14:39:08 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2012-08-10 13:49:29 (GMT) |
commit | 16c5b2406cac683eb7009ae84f0c6a4db36cf7c7 (patch) | |
tree | 5ec963b75f2d865e9a9a33fcffee5b475898bef5 /OficinaActivity.py | |
parent | 6d884b54e61a4b9eaa0429fac0695bfee7d3b811 (diff) |
First stage of port of Paint to cairo
Brushes and shapes are working.
NOTES:
* The pixmaps used as canvas has been replaced by ImageSurface and cairo context.
* All the gc with tool properties were removed.
* The variables needed by the freeform and rainbow were moved from Area to Desenha
* The freeform code was simplified.
* The heart is draw using cairo curves and is a little different than before.
* I am using cairo_stroke_color and cairo_fill_color values in the tool dict
to enable compatibility while the port is done, later will be unified.
I am setting this color with a fixed alpha of 0.3 to display artifacts
if we want enable alpha in the future. It's only for test at this stage.
* The code used to display the polygons (triangle, trapezoid, arrow,
paralellogram, star, polygon_regular) was simplified calling a method
_draw_polygon witha array of points.
PENDING:
* All the clipboard operations.
* All the efects.
* Text
* Bucket
* Stamps
Diffstat (limited to 'OficinaActivity.py')
-rw-r--r-- | OficinaActivity.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/OficinaActivity.py b/OficinaActivity.py index 64dace4..16484b6 100644 --- a/OficinaActivity.py +++ b/OficinaActivity.py @@ -140,21 +140,23 @@ class OficinaActivity(activity.Activity): logging.debug('reading file %s, mimetype: %s, title: %s', file_path, self.metadata['mime_type'], self.metadata['title']) - pixbuf = gtk.gdk.pixbuf_new_from_file(file_path) + self.area.load_from_file(file_path) def size_allocate_cb(widget, allocation): + logging.error('read file size allocate') self.fixed.disconnect(self._setup_handle) - self.area.setup(pixbuf.get_width(), pixbuf.get_height()) + width = self.area.drawing_canvas.get_width() + height = self.area.drawing_canvas.get_height() + self.area.setup(width, height) # The scrolled window is confused with a image of the same size # of the canvas when the toolbars popup and the scrolls # keep visible. - if pixbuf.get_height() > allocation.height or \ - pixbuf.get_width() > allocation.width: - self.canvas.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + if height > allocation.height or width > allocation.width: + self.canvas.set_policy(gtk.POLICY_AUTOMATIC, + gtk.POLICY_AUTOMATIC) else: self.canvas.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) - self.area.loadImageFromJournal(pixbuf) self.center_area() self.canvas.add_with_viewport(self.fixed) @@ -186,12 +188,8 @@ class OficinaActivity(activity.Activity): self.area.d.text(self.area, event=None) self.area.getout() - pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, - width, height) - pixbuf.get_from_drawable(self.area.pixmap, - gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1) + self.area.drawing_canvas.write_to_png(file_path) self.metadata['mime_type'] = 'image/png' - pixbuf.save(file_path, 'png', {}) def _get_area_displacement(self): """Return the point to use as top left corner in order to move |