Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-07-12 01:56:43 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-07-12 01:56:43 (GMT)
commit41db218ec9714afaf1edcc7259082db270f36d04 (patch)
tree77c71c4017299d8595e02938e4f11fcc573dd10f
parent150a82ef89cc4e939681af5de5915664cef28953 (diff)
Connecting and disconnecting toolbars with editors (parcially)
-rwxr-xr-xexpose.py4
-rw-r--r--toolbars.py77
-rw-r--r--widgets.py27
3 files changed, 43 insertions, 65 deletions
diff --git a/expose.py b/expose.py
index fd37966..610ca7a 100755
--- a/expose.py
+++ b/expose.py
@@ -51,6 +51,10 @@ class ExposeActivity(activity.Activity):
self.images_galery.image_request)
self.slides.cover.top_image_editor.connect("load-toolbar",
toolbarbox.load_image_toolbar)
+ self.slides.cover.cover_image_editor.connect("load-toolbar",
+ toolbarbox.load_image_toolbar)
+ self.slides.cover.background_image_editor.connect("load-toolbar",
+ toolbarbox.load_image_toolbar)
self.set_canvas(self.slides)
self.slides.show_all()
self.show()
diff --git a/toolbars.py b/toolbars.py
index 3e2343b..009ea36 100644
--- a/toolbars.py
+++ b/toolbars.py
@@ -80,12 +80,16 @@ class ImageToolbar(gtk.Toolbar):
__gsignals__ = {'insert-picture': (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
- tuple())}
-
- _EFFECT_RAINBOW_NAME = 'rainbow'
+ tuple()),
+ 'size-changed': (gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_NONE,
+ tuple())}
def __init__(self):
gtk.Toolbar.__init__(self)
+ # Used to disconnect all the callbacks
+ # when it's changing another image viewer
+ self._connected_methods = []
self.width_percent = 1.
self.height_percent = 1.
@@ -118,7 +122,7 @@ class ImageToolbar(gtk.Toolbar):
lower=0,
upper=50000,
step_incr=1))
- #self.width_entry.connect("value-changed", self.change_width)
+ self.width_entry.connect("value-changed", self.emit_size)
self.width_entry.show()
table.attach(self.width_entry, 3, 4, 0, 2)
self.link_values_button = gtk.ToggleToolButton()
@@ -131,7 +135,7 @@ class ImageToolbar(gtk.Toolbar):
lower=0,
upper=50000,
step_incr=1))
- #self.height_entry.connect("value-changed", self.change_height)
+ self.height_entry.connect("value-changed", self.emit_size)
self.height_entry.show()
table.attach(self.height_entry, 3, 4, 2, 4)
scale_palette.set_content(table)
@@ -204,6 +208,20 @@ class ImageToolbar(gtk.Toolbar):
self.show_all()
+ def get_picture_size(self):
+ return self.width_entry.get_value(), self.height_entry.get_value()
+
+ def emit_size(self, widget):
+ self.emit('size-changed')
+
+ def connect_temporary(self, signal, callback):
+ self.connect(signal, callback)
+ self._connected_methods.append(callback)
+
+ def flash_callbacks(self):
+ [self.disconnect_by_func(i) for i in self._connected_methods]
+ self._connected_methods = []
+
def rotate_left(self, widget, activity):
activity.area.rotate_left(activity.area)
@@ -228,54 +246,6 @@ class ImageToolbar(gtk.Toolbar):
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
- @param widget - the widget which Palette will be set,
- a ToolButton object
- @param tool
- @param activity
- """
- logger.debug('setting a spinButton for %s', tool)
-
- spin = gtk.SpinButton()
- spin.show()
-
- # This is where we set restrictions for Resizing:
- # Initial value, minimum value, maximum value, step
- initial = float(100)
- adj = gtk.Adjustment(initial, 10.0, 500.0, 1.0)
- spin.set_adjustment(adj)
- spin.set_numeric(True)
-
- spin.set_sensitive(self._activity.area.is_selected())
-
- spin.connect('value-changed', self.resize, tool, activity)
-
- return spin
-
-# def insertImage(self, widget, activity):
-# try:
-# chooser = ObjectChooser(_('Choose image'),
-# self._activity, gtk.DIALOG_MODAL |
-# gtk.DIALOG_DESTROY_WITH_PARENT, what_filter='Image')
-# except:
-# chooser = ObjectChooser(_('Choose image'),
-# self._activity, gtk.DIALOG_MODAL |
-# gtk.DIALOG_DESTROY_WITH_PARENT)
-# try:
-# result = chooser.run()
-# if result == gtk.RESPONSE_ACCEPT:
-# logging.debug('ObjectChooser: %r',
-# chooser.get_selected_object())
-# jobject = chooser.get_selected_object()
-# if jobject and jobject.file_path:
-# self._activity.area.loadImage(jobject.file_path)
-# finally:
-# chooser.destroy()
-# del chooser
-
def _on_signal_undo_cb(self, widget, data=None):
self._verify_sensitive_buttons()
@@ -360,4 +330,5 @@ class PresentToolbarBox(ToolbarBox):
self.insert_image_button.hide()
self.image_button.show()
self.image_button.set_expanded(True)
+ self.image_toolbar.flash_callbacks()
return self.image_toolbar
diff --git a/widgets.py b/widgets.py
index 9012245..e03b297 100644
--- a/widgets.py
+++ b/widgets.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# widgets.py
-#
-# Copyright 2012 Santiago Daniel Francis <francis@sugarlabs.org>
+# Copyright 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -91,16 +89,22 @@ class ImageEditor(gtk.Notebook):
time):
self.image = self.emit("get-image-from-galery", selection.data)
self.toolbar = self.emit("load-toolbar")
+ self.toolbar.connect_temporary('size-changed', self.size_changed_cb)
self.main_pixbuf = self.image.render_to_preview()
self.pixbuf = self.image.render_to_preview()
self.image_widget.set_from_pixbuf(self.pixbuf)
self.set_current_page(1)
self.toolbar.set_sensitive(True)
- #self.width_entry.set_value(self.image.width)
- #self.height_entry.set_value(self.image.height)
- #self.link_values_button.set_active(True)
- #self.width = self.image.width
- #self.height = self.image.height
+ self.toolbar.width_entry.set_value(self.image.width)
+ self.toolbar.height_entry.set_value(self.image.height)
+ self.toolbar.link_values_button.set_active(True)
+ self.width = self.image.width
+ self.height = self.image.height
+
+ def size_changed_cb(self, widget):
+ width, height = self.toolbar.get_picture_size()
+ self._resize_timer = gobject.timeout_add(1,
+ self.rescale_image, width, height)
def link_unlink(self, widget):
active = widget.get_active()
@@ -109,9 +113,7 @@ class ImageEditor(gtk.Notebook):
self.width = self.width_entry.get_value()
self.height = self.height_entry.get_value()
- def rescale_image(self):
- width = self.width_entry.get_value()
- height = self.height_entry.get_value()
+ def rescale_image(self, width, height):
self.pixbuf = self.main_pixbuf.scale_simple(int(width
if self.position ==\
0 or self.position == 180
@@ -121,8 +123,9 @@ class ImageEditor(gtk.Notebook):
90 or self.position == 270
else width),
gtk.gdk.INTERP_TILES)
- self.pixbuf = self.pixbuf.rotate_simple(self.position)
+ #self.pixbuf = self.pixbuf.rotate_simple(self.position)
self.image_widget.set_from_pixbuf(self.pixbuf)
+ gobject.source_remove(self._resize_timer)
def rotate_image(self, widget=None):
self.position += 90