[PATCH] fix #931
Gonzalo Odiard
godiard at gmail.com
Thu May 20 00:12:54 EDT 2010
---
Area.py | 5 +++--
toolbox.py | 19 ++++++++++++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Area.py b/Area.py
index 613e66e..611f944 100644
--- a/Area.py
+++ b/Area.py
@@ -155,6 +155,7 @@ class Area(gtk.DrawingArea):
self.line_shape = 'circle'
self.last = []
self.rainbow_counter = 0
+ self.keep_aspect_ratio = False
self.font = pango.FontDescription('Sans 9')
self._set_selection_bounds(0,0,0,0)
@@ -378,7 +379,7 @@ class Area(gtk.DrawingArea):
self.d.square(widget,event,coords,True,self.tool['fill'])
elif self.tool['name'] == 'marquee-rectangular' and not
self.selmove:
- if state & gtk.gdk.CONTROL_MASK:
+ if (state & gtk.gdk.CONTROL_MASK) or
self.keep_aspect_ratio:
coords = self._keep_selection_ratio(coords)
self.d.selection(widget,coords)
# selected
@@ -462,7 +463,7 @@ class Area(gtk.DrawingArea):
elif self.tool['name'] == 'marquee-rectangular':
if self.selmove == False:
- if event.state & gtk.gdk.CONTROL_MASK:
+ if (event.state & gtk.gdk.CONTROL_MASK) or
self.keep_aspect_ratio:
coords = self._keep_selection_ratio(coords)
self.d.selection(widget,coords,False)
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
diff --git a/toolbox.py b/toolbox.py
index 3962b90..6a01a72 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -357,6 +357,11 @@ class ToolsToolbar(gtk.Toolbar):
self._tool_marquee_rectangular =
ToolButton('tool-marquee-rectangular')
self.insert(self._tool_marquee_rectangular, -1)
self._tool_marquee_rectangular.set_tooltip(_('Rectangular
Marquee'))
+ try:
+ self._configure_palette(self._tool_marquee_rectangular,
self._TOOL_MARQUEE_RECTANGULAR)
+ except:
+ logging.debug('Could not create palette for tool Rectangular
Marquee')
+
# New connect method
# Using dictionnaries to control tool's properties
@@ -483,7 +488,7 @@ class ToolsToolbar(gtk.Toolbar):
label.show()
colorbutton = ButtonFillColor(self._activity)
- colorbutton.show()
+ colorbutton.show_all()
hbox.pack_start(label)
hbox.pack_start(colorbutton)
@@ -493,8 +498,20 @@ class ToolsToolbar(gtk.Toolbar):
content_box.pack_start(hbox)
colorbutton.connect_after('color-set', self._on_color_set,
self._TOOL_POLYGON)
+ if tool['name'] is self._TOOL_MARQUEE_RECTANGULAR['name']:
+ # Creating a CheckButton named "Fill".
+ keep_aspect_checkbutton = gtk.CheckButton(_('Keep aspect'))
+ keep_aspect_checkbutton.show()
+
keep_aspect_checkbutton.set_active(self._activity.area.keep_aspect_ratio)
+
+ keep_aspect_checkbutton.connect('toggled',
self._keep_aspect_checkbutton_toggled, widget)
+ palette.action_bar.pack_start(keep_aspect_checkbutton)
+ def _keep_aspect_checkbutton_toggled(self, checkbutton, button=None):
+ logging.debug('Keep aspect is Active: %s',
checkbutton.get_active())
+ self._activity.area.keep_aspect_ratio = checkbutton.get_active()
+
def set_shape(self, widget=None, tool=None, shape=None):
"""
Set a tool shape according to user choice at Tool Palette
--
1.6.6.1
--
Gonzalo Odiard
Responsable de Desarrollo
Sistemas Australes
--000e0cd7619e79d0100486fed96b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello:<br>A new patch to Paint. I don't know who is the mainteiner of t=
his activity.<br>Who can commit these changes and close the bugs?<br>Thanks=
<br><br>Gonzalo<br><br>From f4a375b4861ca084ee03089751de82fc61233997 Mon S=
ep 17 00:00:00 2001<br>
From: Gonzalo Odiard <<a href=3D"mailto:godiard at gmail.com">godiard at gmail=
.com</a>><br>Date: Thu, 20 May 2010 01:12:54 -0300<br>Subject: [PATCH] f=
ix #931<br><br>---<br>=A0Area.py=A0=A0=A0 |=A0=A0=A0 5 +++--<br>=A0toolbox.=
py |=A0=A0 19 ++++++++++++++++++-<br>
=A02 files changed, 21 insertions(+), 3 deletions(-)<br><br>diff --git a/Ar=
ea.py b/Area.py<br>index 613e66e..611f944 100644<br>--- a/Area.py<br>+++ b/=
Area.py<br>@@ -155,6 +155,7 @@ class Area(gtk.DrawingArea):<br>=A0=A0=A0=A0=
=A0=A0=A0=A0 self.line_shape =3D 'circle'<br>
=A0=A0=A0=A0=A0=A0=A0=A0 self.last =3D []<br>=A0=A0=A0=A0=A0=A0=A0=A0 self.=
rainbow_counter =3D 0<br>+=A0=A0=A0=A0=A0=A0=A0 self.keep_aspect_ratio =3D =
False<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 <br>=A0=A0=A0=A0=
=A0=A0=A0=A0 self.font =3D pango.FontDescription('Sans 9')<br>=A0=
=A0=A0=A0=A0=A0=A0=A0 self._set_selection_bounds(0,0,0,0)<br>
@@ -378,7 +379,7 @@ class Area(gtk.DrawingArea):<br>=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 self.d.square(widget,event,coords,T=
rue,self.tool['fill'])<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 <br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =
elif self.tool['name'] =3D=3D 'marquee-rectangular' and not=
self.selmove:<br>
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if state & g=
tk.gdk.CONTROL_MASK:<br>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0 if (state & gtk.gdk.CONTROL_MASK) or self.keep_aspect_ratio:<=
br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
coords =3D self._keep_selection_ratio(coords)<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 self.d.selecti=
on(widget,coords)<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # sel=
ected<br>@@ -462,7 +463,7 @@ class Area(gtk.DrawingArea):<br>=A0<br>=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 elif self.tool['name'] =3D=3D 'm=
arquee-rectangular':<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if self.selmove =3D=3D Fal=
se:<br>-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if event.=
state & gtk.gdk.CONTROL_MASK:<br>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 if (event.state & gtk.gdk.CONTROL_MASK) or self.k=
eep_aspect_ratio:<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 coords =3D self._keep_selection_ratio(coords)<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 self.d.selecti=
on(widget,coords,False)<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))<br>diff =
--git a/toolbox.py b/toolbox.py<br>index 3962b90..6a01a72 100644<br>--- a/t=
oolbox.py<br>
+++ b/toolbox.py<br>@@ -357,6 +357,11 @@ class ToolsToolbar(gtk.Toolbar):<b=
r>=A0=A0=A0=A0=A0=A0=A0=A0 self._tool_marquee_rectangular =3D ToolButton(&#=
39;tool-marquee-rectangular')<br>=A0=A0=A0=A0=A0=A0=A0=A0 self.insert(s=
elf._tool_marquee_rectangular, -1)<br>
=A0=A0=A0=A0=A0=A0=A0=A0 self._tool_marquee_rectangular.set_tooltip(_('=
Rectangular Marquee'))<br>+=A0=A0=A0=A0=A0=A0=A0 try:<br>+=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 self._configure_palette(self._tool_marquee_rectangula=
r, self._TOOL_MARQUEE_RECTANGULAR)<br>+=A0=A0=A0=A0=A0=A0=A0 except:<br>
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 logging.debug('Could not create pale=
tte for tool Rectangular Marquee')<br>+<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 <br>=A0=A0=A0=A0=A0=A0=A0=A0 # New connect method<br>=
=A0=A0=A0=A0=A0=A0=A0=A0 # Using dictionnaries to control tool's proper=
ties<br>
@@ -483,7 +488,7 @@ class ToolsToolbar(gtk.Toolbar):<br>=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 label.show()<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 <br=
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 colorbutton =3D ButtonFillColor(self.=
_activity)<br>-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 colorbutton.show()<br>+=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 colorbutton.show_all()<br>
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 <br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0 hbox.pack_start(label)<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 hbox.pac=
k_start(colorbutton)<br>@@ -493,8 +498,20 @@ class ToolsToolbar(gtk.Toolbar=
):<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 content_box.pack_start(hbox)<br>=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 <br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0 colorbutton.connect_after('color-set', self._on_color_set, self=
._TOOL_POLYGON)<br>
+=A0=A0=A0=A0=A0=A0=A0 if tool['name'] is self._TOOL_MARQUEE_RECTAN=
GULAR['name']:<br>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # Creating a C=
heckButton named "Fill".<br>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ke=
ep_aspect_checkbutton =3D gtk.CheckButton(_('Keep aspect'))<br>
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 keep_aspect_checkbutton.show()<br>+=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 keep_aspect_checkbutton.set_active(self._act=
ivity.area.keep_aspect_ratio)<br>+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 <br>+=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 keep_aspect_checkbutton.connect('togg=
led', self._keep_aspect_checkbutton_toggled, widget)<br>
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 palette.action_bar.pack_start(keep_aspec=
t_checkbutton)<br>=A0=A0=A0=A0 <br>=A0<br>+=A0=A0=A0 def _keep_aspect_check=
button_toggled(self, checkbutton, button=3DNone):<br>+=A0=A0=A0=A0=A0=A0=A0=
logging.debug('Keep aspect is Active: %s', checkbutton.get_active(=
))<br>
+=A0=A0=A0=A0=A0=A0=A0 self._activity.area.keep_aspect_ratio =3D checkbutto=
n.get_active()<br>+<br>=A0=A0=A0=A0 def set_shape(self, widget=3DNone, tool=
=3DNone, shape=3DNone):<br>=A0=A0=A0=A0=A0=A0=A0=A0 """<br>=
=A0=A0=A0=A0=A0=A0=A0=A0 Set a tool shape according to user choice at Tool =
Palette<br>
-- <br>1.6.6.1<br><br clear=3D"all"><br>-- <br>Gonzalo Odiard<br>Responsabl=
e de Desarrollo<br>Sistemas Australes<br><br>
--000e0cd7619e79d0100486fed96b--
More information about the Sugar-devel
mailing list