diff options
Diffstat (limited to 'Area.py')
-rw-r--r-- | Area.py | 57 |
1 files changed, 22 insertions, 35 deletions
@@ -73,7 +73,6 @@ from fill import fill from Desenho import Desenho from urlparse import urlparse - ##Tools and events manipulation are handle with this class. TARGET_URI = 0 @@ -96,8 +95,6 @@ class Area(gtk.DrawingArea): @param janela -- the parent window """ - logging.debug('Area.__init__(self, janela)') - gtk.DrawingArea.__init__(self) self.set_events(gtk.gdk.POINTER_MOTION_MASK | @@ -202,7 +199,7 @@ class Area(gtk.DrawingArea): if self.pixmap: return - logging.debug('Area.configure_event: w=%s h=%s' % (width, height)) + logging.debug('Area.setup: w=%s h=%s' % (width, height)) win = self.window self.set_size_request(width, height) @@ -669,8 +666,6 @@ class Area(gtk.DrawingArea): @param self -- the Area object (GtkDrawingArea) """ - logging.debug('Area.setup_stamp(self)') - if self.is_selected(): # Change stamp, get it from selection: width, height = self.pixmap_sel.get_size() @@ -910,7 +905,7 @@ class Area(gtk.DrawingArea): else: self.loadImage(tempPath, self) logging.debug('Area.past(self): Load from clipboard fails') - logging.debug('loading from tempPatch') + logging.debug('loading from tempPath') self.queue_draw() @@ -921,8 +916,6 @@ class Area(gtk.DrawingArea): @param color -- a gdk.Color object """ - logging.debug('Area._set_fill_color(self, color)') - self.gc.set_foreground(color) def set_stroke_color(self, color): @@ -932,8 +925,6 @@ class Area(gtk.DrawingArea): @param color -- a gdk.Color object """ - logging.debug('Area._set_stroke_color(self, color)') - self.gc_line.set_foreground(color) self.gc_line.set_line_attributes(1, gtk.gdk.LINE_ON_OFF_DASH, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_ROUND) @@ -1007,6 +998,9 @@ class Area(gtk.DrawingArea): def _do_process(self, widget, apply_process): width, height = self.window.get_size() + self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + self.drain_events() + if self.selmove: size = self.pixmap_sel.get_size() temp_pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, @@ -1045,6 +1039,11 @@ class Area(gtk.DrawingArea): self.queue_draw() if not self.selmove: self.enableUndo(widget) + self.set_tool_cursor() + + def drain_events(self, block=gtk.FALSE): + while gtk.events_pending(): + gtk.mainiteration(block) def _pixbuf2Image(self, pb): """change a pixbuf to RGB image @@ -1099,7 +1098,6 @@ class Area(gtk.DrawingArea): @param self -- the Area object (GtkDrawingArea) @param widget -- the Area object (GtkDrawingArea) """ - logging.debug('Area._rotate_left(self)') if self.selmove: width, height = self.window.get_size() size = self.pixmap_sel.get_size() @@ -1140,12 +1138,8 @@ class Area(gtk.DrawingArea): def can_undo(self): """ Indicate if is there some action to undo - @param self -- the Area object (GtkDrawingArea) - """ -# logging.debug('Area.can_undo(self)') - undo_times = self.undo_times if self.first_undo: @@ -1159,12 +1153,8 @@ class Area(gtk.DrawingArea): def can_redo(self): """ Indicate if is there some action to redo - @param self -- the Area object (GtkDrawingArea) - """ - #logging.debug('Area.can_redo(self)') - if self.redo_times < 1: return False else: @@ -1175,11 +1165,7 @@ class Area(gtk.DrawingArea): Return True if there is some thing selected @param self -- the Area object (GtkDrawingArea) - """ - - #logging.debug('Area.is_selected(self)') - if self.selmove: return True else: @@ -1225,8 +1211,7 @@ class Area(gtk.DrawingArea): @param widget -- GtkDrawingArea """ - logging.debug('Area.loadImage') - logging.debug('Loading file %s', name) + logging.debug('Area.loadImage Loading file %s', name) pixbuf = gtk.gdk.pixbuf_new_from_file(name) size = (int)(pixbuf.get_width()), (int)(pixbuf.get_height()) @@ -1285,10 +1270,8 @@ class Area(gtk.DrawingArea): 'fill': a Boolean value 'vertices': a integer ''' - logging.debug('Area.set_tool %s', tool) - + # logging.debug('Area.set_tool %s', tool) self.tool = tool - try: if self.tool['line size'] is not None: self.configure_line(self.tool['line size']) @@ -1308,6 +1291,9 @@ class Area(gtk.DrawingArea): except AttributeError: pass + self.set_tool_cursor() + + def set_tool_cursor(self): # Setting the cursor try: cursors = {'pencil': 'pencil', @@ -1320,15 +1306,14 @@ class Area(gtk.DrawingArea): if self.tool['name'] in cursors: name = cursors[self.tool['name']] cursor = gtk.gdk.cursor_new_from_name(display, name) - elif tool['name'] == 'marquee-rectangular': + elif self.tool['name'] == 'marquee-rectangular': cursor = gtk.gdk.Cursor(gtk.gdk.CROSS) else: - filename = os.path.join('images', tool['name'] + '.png') + filename = os.path.join('images', self.tool['name'] + '.png') pixbuf = gtk.gdk.pixbuf_new_from_file(filename) cursor = gtk.gdk.Cursor(display, pixbuf, 0, 0) except gobject.GError: cursor = None - self.window.set_cursor(cursor) def getout(self, undo=False, widget=None): @@ -1401,16 +1386,18 @@ class Area(gtk.DrawingArea): self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSS)) widget.queue_draw() - # TODO: unused method? def change_line_size(self, delta): - if self.tool['name'] in ['pencil', 'eraser', 'brush', 'rainbow', - 'stamp']: + # Used from OficinaActivity + if self.tool['name'] in ['pencil', 'eraser', 'brush', 'rainbow']: size = self.tool['line size'] + delta if size < 1: size = 1 self.tool['line size'] = size self.configure_line(size) self.queue_draw() + if self.tool['name'] == 'stamp': + self.resize_stamp(self.stamp_size + delta) + self.queue_draw() def _keep_selection_ratio(self, coords): |