Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-03-26 06:24:10 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-03-26 06:24:10 (GMT)
commit06a21a37ee1591329039631398923b171d5bef6a (patch)
tree7dc56b44626106fbb905207327bc74029d8e3fdc
parentf922702c98e25127e2a7637b03da0f1cdae5cff7 (diff)
Change stroke width
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
-rw-r--r--drawing.py6
-rw-r--r--toolbar.py39
2 files changed, 40 insertions, 5 deletions
diff --git a/drawing.py b/drawing.py
index 729fadd..3e73f6f 100644
--- a/drawing.py
+++ b/drawing.py
@@ -91,6 +91,12 @@ class Drawing(gtk.DrawingArea):
self._paint_stroke(context, stroke_points)
self.queue_draw()
+ def set_stroke_width(self, width):
+ self._settings['stroke width'] = width
+
+ def get_stroke_width(self):
+ return self._settings['stroke width']
+
def clear_drawing_canvas(self):
width, height = self.get_size()
self.setup(width, height)
diff --git a/toolbar.py b/toolbar.py
index 70d27c5..dfb3a82 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -42,11 +42,31 @@ class PaintToolbar(ToolbarBox):
self.toolbar.insert(separator, -1)
separator.show()
- button = ToolButton('edit-clear')
- button.set_tooltip(_("Clear canvas"))
- button.connect("clicked", self._clear_drawing_canvas_cb)
- self.toolbar.insert(button, -1)
- button.show()
+ tool_item_width = gtk.ToolItem()
+ self.toolbar.insert(tool_item_width, -1)
+ tool_item_width.show()
+
+ hbox_width = gtk.HBox()
+ tool_item_width.add(hbox_width)
+ hbox_width.show()
+
+ width_label = gtk.Label(_('Width: '))
+ hbox_width.pack_start(width_label)
+ width_label.show()
+
+ self._width_spin = gtk.SpinButton()
+ adj = gtk.Adjustment(1, 1.0, 100.0, 1.0)
+ self._width_spin.set_adjustment(adj)
+ self._width_spin.set_numeric(True)
+ self._width_spin.connect('value-changed', self._width_spin_cb)
+ hbox_width.pack_start(self._width_spin)
+ self._width_spin.show()
+
+ clear_button = ToolButton('edit-clear')
+ clear_button.set_tooltip(_("Clear canvas"))
+ clear_button.connect("clicked", self._clear_drawing_canvas_cb)
+ self.toolbar.insert(clear_button, -1)
+ clear_button.show()
separator = gtk.SeparatorToolItem()
separator.props.draw = False
@@ -60,6 +80,15 @@ class PaintToolbar(ToolbarBox):
def set_drawing(self, drawing):
self._drawing = drawing
+ self._update_buttons()
+
+ def _update_buttons(self):
+ width = self._drawing.get_stroke_width()
+ self._width_spin.props.value = width
+
+ def _width_spin_cb(self, width_spin):
+ width = width_spin.get_value_as_int()
+ self._drawing.set_stroke_width(width)
def _clear_drawing_canvas_cb(self, button):
logging.debug("clear canvas")