From d0ec8d6d3a092da8890e5f97f9655cd015b5b577 Mon Sep 17 00:00:00 2001 From: Pootle daemon Date: Mon, 16 May 2011 17:03:55 +0000 Subject: Merge branch 'master' of git.sugarlabs.org:paint/mainline --- diff --git a/Area.py b/Area.py index 90bec38..b5ab8e6 100644 --- a/Area.py +++ b/Area.py @@ -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): diff --git a/OficinaActivity.py b/OficinaActivity.py index 4096a83..86175c2 100644 --- a/OficinaActivity.py +++ b/OficinaActivity.py @@ -125,9 +125,11 @@ class OficinaActivity(activity.Activity): self._setup_handle = self.connect('map', map_cp) def key_press(self, widget, event): - sliders = {65474: -5, 65475: -1, 65476: 1, 65477: 5} - if event.keyval in sliders: - self.area.change_line_size(sliders[event.keyval]) + print event.keyval + if event.keyval == 45: + self.area.change_line_size(-1) + if event.keyval == 43: + self.area.change_line_size(1) def read_file(self, file_path): '''Read file from Sugar Journal.''' diff --git a/activity/activity.info b/activity/activity.info index 20195b4..0e7bcd5 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Paint -activity_version = 32 +activity_version = 33 service_name = org.laptop.Oficina exec = sugar-activity OficinaActivity.OficinaActivity icon = activity-paint diff --git a/fill/linux64_27/_fill.so b/fill/linux64_27/_fill.so index f0e1fa9..2b2975f 100755 --- a/fill/linux64_27/_fill.so +++ b/fill/linux64_27/_fill.so Binary files differ diff --git a/toolbox.py b/toolbox.py index 00d98b1..5783bd5 100644 --- a/toolbox.py +++ b/toolbox.py @@ -162,6 +162,7 @@ class DrawEditToolbar(EditToolbar): self._clear_all = ToolButton('edit-clear') self.insert(self._clear_all, -1) self._clear_all.set_tooltip(_('Clear')) + self._clear_all.show() self.undo.connect('clicked', self._undo_cb) self.redo.connect('clicked', self._redo_cb) diff --git a/widgets.py b/widgets.py index 7c23683..c1833fa 100644 --- a/widgets.py +++ b/widgets.py @@ -56,7 +56,7 @@ class BrushButton(_ColorButton): self._preview.show() self.pixmap = gtk.gdk.Pixmap(self.get_window(), style.STANDARD_ICON_SIZE, - style.STANDARD_ICON_SIZE, 24) + style.STANDARD_ICON_SIZE, -1) self._gc = self.get_window().new_gc() self.show_all() -- cgit v0.9.1