Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Desenho.py76
-rw-r--r--MANIFEST7
-rw-r--r--OficinaActivity.py10
-rw-r--r--toolbox.py90
4 files changed, 109 insertions, 74 deletions
diff --git a/Desenho.py b/Desenho.py
index 72ec259..c2f2018 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -60,6 +60,7 @@ import sys, gobject, socket
from gtk import gdk
import math
import pango
+import gc
WIDTH = 1195
@@ -548,6 +549,7 @@ class Desenho:
widget.pixmap.draw_layout(widget.gc, widget.oldx, widget.oldy, layout)
widget.pixmap_temp.draw_layout(widget.gc, widget.oldx, widget.oldy, layout)
widget.janela.textview.hide()
+
try:
widget.janela.textview.set_text('')
except AttributeError:
@@ -587,6 +589,8 @@ class Desenho:
y = int(coords[1])
else:
y = widget.oldy
+
+ self.coords = (x,y)
pixmap.draw_drawable(widget.gc,widget.pixmap,0,0,0,0,width,height)
if fill:
@@ -595,11 +599,10 @@ class Desenho:
pixmap.draw_rectangle(widget.gc_selection,False,x,y,dx,dy)
pixmap.draw_rectangle(widget.gc_selection1,False,x-1,y-1,dx+2,dy+2)
widget.queue_draw()
-
+
return x,y,x+dx,y+dy
def moveSelection(self, widget, coords, mvcopy=False, pixbuf_copy=None):
- self.draw_widget = widget
"""Move the selection.
@param self -- Desenho.Desenho instance
@@ -609,6 +612,7 @@ class Desenho:
@param pixbuf_copy -- For import image
"""
+
width, height = widget.window.get_size()
widget.pixmap_sel.draw_drawable(widget.gc,widget.pixmap,0,0,0,0, width, height)
@@ -625,18 +629,26 @@ class Desenho:
w = int(math.fabs(widget.sx - widget.oldx))
h = int(math.fabs(widget.sy - widget.oldy))
-
+
+ self.coords = (coords[0] -w/2,coords[1]-h/2)
+
widget._set_selection_bounds(coords[0]-w/2, coords[1]-h/2, coords[0]+w/2, coords[1]+h/2)
if not mvcopy:
widget.pixmap_sel.draw_rectangle(widget.get_style().white_gc, True, x0, y0, w, h)
-
- if pixbuf_copy!=None: #to import or paste image
- widget.pixmap_sel.draw_pixbuf(widget.gc, pixbuf_copy, 0, 0, coords[0] - w/2, coords[1]- h/2, w, h, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
- widget.pixmap_temp.draw_pixbuf(widget.gc, pixbuf_copy, 0, 0, coords[0] - w/2, coords[1]- h/2, w, h, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
- else:
- widget.pixmap_sel.draw_drawable(widget.gc, widget.pixmap, x0, y0, coords[0] - w/2, coords[1]- h/2, w, h)
- widget.pixmap_temp.draw_drawable(widget.gc, widget.pixmap_sel,0,0,0,0, width, height)
+ try: # test if resizing has been done
+ w, h = self.resized.get_width(), self.resized.get_height()
+ widget.pixmap_sel.draw_pixbuf(widget.gc,self.resized,0,0,coords[0] - w/2, coords[1] - h/2, w, h)
+ widget.pixmap_temp.draw_pixbuf(widget.gc,self.resized,0,0,coords[0] - w/2, coords[1] - h/2, w, h)
+ except:
+ if pixbuf_copy!=None: #to import or paste image
+ widget.pixmap_sel.draw_pixbuf(widget.gc, pixbuf_copy, 0, 0, coords[0] - w/2, coords[1]- h/2, w, h, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
+ widget.pixmap_temp.draw_pixbuf(widget.gc, pixbuf_copy, 0, 0, coords[0] - w/2, coords[1]- h/2, w, h, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
+ else:
+ widget.pixmap_sel.draw_drawable(widget.gc, widget.pixmap, x0, y0, coords[0] - w/2, coords[1]- h/2, w, h)
+
+ widget.pixmap_temp.draw_drawable(widget.gc, widget.pixmap_sel,0,0,0,0, width, height)
+
#to draw the selection black and white line rectangle
widget.pixmap_sel.draw_rectangle(widget.gc_selection, False ,coords[0] - w/2, coords[1]- h/2, w, h)
widget.pixmap_sel.draw_rectangle(widget.gc_selection1, False ,coords[0] - w/2-1, coords[1]- h/2-1, w+2, h+2)
@@ -650,12 +662,12 @@ class Desenho:
@param height_percent -- Percent of y scale
"""
- #widget = self.draw_widget
+ widget.desenha = True
+ widget.selmove = True
+
width, height = widget.window.get_size()
+ widget.pixmap_sel.draw_drawable(widget.gc,widget.pixmap_temp,0,0,0,0, width, height)
-
- widget.pixmap.draw_drawable(widget.gc,widget.pixmap_temp,0,0,0,0, width, height)
-
if widget.sx > widget.oldx:
x0 = int(widget.oldx)
else:
@@ -668,28 +680,34 @@ class Desenho:
w = int(math.fabs(widget.sx - widget.oldx))
h = int(math.fabs(widget.sy - widget.oldy))
+ delta_x = int( w*(width_percent-1)/2 )
+ delta_y = int( h*(height_percent-1)/2 )
+ gc.collect()
+
+ try: self.resize_pixbuf
+ except:
+ self.resize_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h)
+ self.resize_pixbuf.get_from_drawable(widget.pixmap, gtk.gdk.colormap_get_system(), x0, y0, 0, 0, int(w), int(h))
- #delta_x = int( w*(width_percent-1)/2 )
- #delta_y = int( h*(height_percent-1)/2 )
+ x0,y0 = self.coords
+
+ try:
+ del(self.resized)
+ except: pass
- pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h)
- pixbuf.get_from_drawable(widget.pixmap_temp, gtk.gdk.colormap_get_system(), x0, y0, 0, 0, w, h)
- pixbuf = pixbuf.scale_simple(int(w*width_percent), int(h*height_percent), gtk.gdk.INTERP_BILINEAR)
+ self.resized = self.resize_pixbuf.scale_simple(int(w*width_percent), int(h*height_percent), gtk.gdk.INTERP_HYPER)
- widget.pixmap.draw_rectangle(widget.get_style().white_gc, True, x0 , y0 , int(w*width_percent), int(h*height_percent))
- widget.pixmap.draw_pixbuf(widget.get_style().white_gc,pixbuf,0,0,x0 , y0 ,int(w*width_percent), int(h*height_percent))
-
- #widget.pixmap_temp.draw_drawable(widget.gc, widget.pixmap_sel,0,0,0,0, width, height)
-
- #to draw the selection black and white line rectangle
- #widget.pixmap_sel.draw_rectangle(widget.gc_selection, False ,x0, y0-2,int(width_percent*w+1), int(height_percent*h+1))
- #widget.pixmap_sel.draw_rectangle(widget.gc_selection1, False ,x0, y0-3,int(width_percent*w +2), int(height_percent*h +2))
+ widget.pixmap_sel.draw_rectangle(widget.get_style().white_gc, True, x0 - delta_x, y0 - delta_y, int(w*width_percent), int(h*height_percent))
+ widget.pixmap_sel.draw_pixbuf(widget.get_style().white_gc,self.resized,0,0,x0 - delta_x, y0 - delta_y,int(w*width_percent), int(h*height_percent))
+ widget.pixmap_temp.draw_drawable(widget.gc, widget.pixmap_sel,0,0,0,0, width, height)
- #widget.pixmap.draw_drawable(widget.gc, widget.pixmap_temp, 0,0,0,0, width, height)
+ #to draw the selection black and white line rectangle
+ widget.pixmap_sel.draw_rectangle(widget.gc_selection, False ,x0- delta_x -1, y0- delta_y-1,int(width_percent*w+1), int(height_percent*h+1))
+ widget.pixmap_sel.draw_rectangle(widget.gc_selection1, False ,x0- delta_x -2, y0- delta_y-2,int(width_percent*w +1), int(height_percent*h +1))
widget.queue_draw()
- widget.enableUndo(widget)
+ gc.collect()
def polygon(self, widget, coords, temp, fill):
"""Draw polygon.
diff --git a/MANIFEST b/MANIFEST
index a227dd1..cb8ca94 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -6,6 +6,13 @@ OficinaActivity.py
activity/activity-paint.svg
activity/activity.info
fill.so
+fill_src/Makefile
+fill_src/eggfill.c
+fill_src/eggfill.h
+fill_src/fill.c
+fill_src/fill.defs
+fill_src/fill.override
+fill_src/fillmodule.c
icons/bg.svg
icons/edit-copy.svg
icons/edit-paste.svg
diff --git a/OficinaActivity.py b/OficinaActivity.py
index 08355c2..d823b16 100644
--- a/OficinaActivity.py
+++ b/OficinaActivity.py
@@ -98,12 +98,12 @@ class OficinaActivity(activity.Activity):
color = gtk.gdk.color_parse("white")
self.fixed.modify_bg(gtk.STATE_NORMAL, color)
-
+
self._bg = gtk.Image()
self._bg.set_from_file('./icons/bg.svg')
self.fixed.put(self._bg, 200, 100)
- self._bg.show()
-
+ self._bg.show
+
self.textview = gtk.TextView()
# If we use this, text viewer will have constant size, we don't want that
#self.textview.set_size_request(100,100)
@@ -115,15 +115,12 @@ class OficinaActivity(activity.Activity):
sw.add_with_viewport(self.fixed)
self.area.show()
self.fixed.show()
-
-
self.fixed.put(self.textview, 0, 0)
self.textview.hide()
sw.show()
# setting scrolledwindow as activity canvas...
self.set_canvas(sw)
-
def read_file(self, file_path):
'''Read file from Sugar Journal.
@@ -136,7 +133,6 @@ class OficinaActivity(activity.Activity):
# logging.debug(file_path)
self.area.loadImage(file_path, self.area, False)
-
def write_file(self, file_path):
diff --git a/toolbox.py b/toolbox.py
index f7b21c2..cbe3daf 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -134,7 +134,6 @@ class DrawEditToolbar(EditToolbar):
self._clear_all.connect('clicked', self._clear_all_cb)
-
self._activity.area.connect('undo', self._on_signal_undo_cb)
self._activity.area.connect('redo', self._on_signal_redo_cb)
self._activity.area.connect('selected', self._on_signal_copy_cb)
@@ -289,7 +288,6 @@ class ToolsToolbar(gtk.Toolbar):
self.insert(item, -1)
item.show()
-
separator = gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
@@ -537,15 +535,15 @@ class ToolsToolbar(gtk.Toolbar):
tool['fill'] = checkbutton.get_active()
self.set_tool(tool=tool)
- def _on_fill_checkbutton_map(self, checkbutton, data=None):
- """
- Update checkbutton condition to agree with Area.Area object; this prevents tools to have fill checked but be drawed not filled.
-
- @param self -- gtk.Toolbar
- @param checkbutton
- @param data
- """
- self._activity.area.fill = checkbutton.get_active()
+# def _on_fill_checkbutton_map(self, checkbutton, data=None):
+# """
+# Update checkbutton condition to agree with Area.Area object; this prevents tools to have fill checked but be drawed not filled.
+#
+# @param self -- gtk.Toolbar
+# @param checkbutton
+# @param data
+# """
+# self._activity.area.fill = checkbutton.get_active()
def _on_color_set(self, colorbutton, tool):
logging.debug('toolbox.ToolsToolbar._on_color_set')
@@ -749,7 +747,7 @@ class ShapesToolbar(gtk.Toolbar):
item.add(self._stroke_color)
self.insert(item, -1)
item.show()
-
+
separator = gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
@@ -1163,6 +1161,10 @@ class ImageToolbar(gtk.Toolbar):
separator.set_draw(True)
self.insert(separator, -1)
separator.show()
+
+ self.width_percent = 1.
+ self.height_percent = 1.
+
"""
self._object_rotate_left = ToolButton('object-rotate-left')
self.insert(self._object_rotate_left, -1)
@@ -1181,14 +1183,24 @@ class ImageToolbar(gtk.Toolbar):
self._object_height.show()
self._object_height.set_tooltip(_('Height'))
+ height_spinButton = self._create_spinButton(self._object_height, 'object-height', activity)
+
+ item = gtk.ToolItem()
+ item.add(height_spinButton)
+ self.insert(item, -1)
+ item.show()
+
self._object_width = ToolButton('object-width')
self.insert(self._object_width, -1)
self._object_width.show()
self._object_width.set_tooltip(_('Width'))
-
- self._configure_palette_resize(self._object_height, 'object-height', activity)
- self._configure_palette_resize(self._object_width, 'object-width', activity)
+ width_spinButton = self._create_spinButton(self._object_width, 'object-width', activity)
+
+ item = gtk.ToolItem()
+ item.add(width_spinButton)
+ self.insert(item, -1)
+ item.show()
# self._object_height.connect('clicked', self.resize, activity, 'object-height', self._OBJECT_HEIGHT)
@@ -1196,20 +1208,31 @@ class ImageToolbar(gtk.Toolbar):
#self._object_rotate_left.connect('clicked', self.rotate_left, activity)
#self._object_rotate_right.connect('clicked', set_tool, activity, 'object-rotate-right', self._OBJECT_ROTATE_RIGHT)
# self._object_width.connect('clicked', self.resize, activity, 'object-width', self._OBJECT_WIDTH)
-
- def rotate_left(self, widget, activity):
+
+ def _selected(self, widget, spin, activity):
+ if not activity.area.is_selected():
+ spin.set_value(100)
+ self.width_percent = 1.
+ self.height_percent = 1.
+ try:
+ del(activity.area.d.resize_pixbuf)
+ del(activity.area.d.resized)
+ except: pass
+
+ def rotate_left(self, widget, activity):
#activity.area._rotate_left(widget)
pass
- def _resize(self, spinButton, tool, activity):
- size = spinButton.get_value_as_int()
- if activity.area.tool == 'marquee-rectangular' and activity.area.selmove:
+ def resize(self, spinButton, tool, activity):
+ if activity.area.tool['name'] == 'marquee-rectangular' and activity.area.selmove:
if tool == "object-height":
- activity.area.d.resizeSelection(activity.area,1., float(size)/100)
+ self.height_percent = spinButton.get_value_as_int()/100.
+ activity.area.d.resizeSelection(activity.area, self.width_percent, self.height_percent)
elif tool == "object-width":
- activity.area.d.resizeSelection(activity.area,float(size)/100, 1.)
-
- def _configure_palette_resize(self, widget, tool, activity):
+ self.width_percent = spinButton.get_value_as_int()/100.
+ activity.area.d.resizeSelection(activity.area, self.width_percent, self.height_percent)
+
+ def _create_spinButton(self, widget, tool, activity):
"""Set palette for a tool - width or height
@param self -- gtk.Toolbar
@@ -1217,17 +1240,11 @@ class ImageToolbar(gtk.Toolbar):
@param tool
@param activity
"""
- logging.debug('setting a palette for %s', tool)
-
- palette = widget.get_palette()
+ logging.debug('setting a spinButton for %s', tool)
spin = gtk.SpinButton()
spin.show()
- # When inserted in a Palette, a spinbutton does not display text in black
- black = gtk.gdk.Color(0,0,0)
- spin.modify_text(gtk.STATE_NORMAL, black)
-
# This is where we set restrictions for Resizing:
# Initial value, minimum value, maximum value, step
initial = float(100)
@@ -1235,13 +1252,11 @@ class ImageToolbar(gtk.Toolbar):
spin.set_adjustment(adj)
spin.set_numeric(True)
- label = gtk.Label(_('Resize (%): '))
- label.show()
- palette.action_bar.pack_start(label)
- palette.action_bar.pack_start(spin)
+ spin.connect('value-changed', self.resize, tool, activity)
+ activity.area.connect('selected', self._selected, spin, activity)
+
+ return spin
- spin.connect('value-changed', self._resize, tool, activity)
-
def insertImage(self, widget, activity):
# TODO: add a filter to display images only.
dialog = gtk.FileChooserDialog(title=(_('Open File...')),
@@ -1371,7 +1386,6 @@ class EffectsToolbar(gtk.Toolbar):
size_spinbutton.connect('value-changed', self._on_size_value_changed, tool)
# Line Shape
-
item1 = gtk.RadioButton(None, _('Circle'))
item1.show()
item1.set_active(True)