[Sugar-devel] Write: changing the default insert image mode

Gonzalo Odiard gonzalo at laptop.org
Thu Oct 28 12:20:06 EDT 2010


I was testing changing the default mode inserting a image in Write
from floating to in-place.
It enable insert a image inside a table, and I think is more usable.
Is the default mode in Abiword too.
If the user want insert a floating image, i added a checkbox to the
palette of the insert image button.
Can anybody check with users and provide feedback?

Gonzalo

To test it, you can apply the following patch:

>From 7a5a40818e0fdc73dc7ac5b89ade1b278f300f46 Mon Sep 17 00:00:00 2001
From: Gonzalo Odiard <godiard at sugarlabs.org>
Date: Thu, 28 Oct 2010 12:27:21 -0300
Subject: [PATCH] Write: Change the default method of insert images to
in place instead of floating
 and add a checkbox to enable the user to select the method

---
 toolbar.py |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/toolbar.py b/toolbar.py
index 701d8be..d84abf7 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -253,15 +253,29 @@ class InsertToolbar(gtk.Toolbar):
         self._image_id = image.connect('clicked', self._image_cb)
         self.insert(image, -1)

+        palette = image.get_palette()
+        content_box = gtk.VBox()
+        palette.set_content(content_box)
+        image_floating_checkbutton = gtk.CheckButton(_('Floating'))
+        image_floating_checkbutton.connect('toggled',
+                self._image_floating_checkbutton_toggled_cb)
+        content_box.pack_start(image_floating_checkbutton)
+        content_box.show_all()
+        self.floating_image = False
+
         self.show_all()

         self._abiword_canvas.connect('table-state', self._isTable_cb)
         #self._abiword_canvas.connect('image-selected',
self._image_selected_cb)

+    def _image_floating_checkbutton_toggled_cb(self, checkbutton):
+        logging.error('Floating image is Active: %s', checkbutton.get_active())
+        self.floating_image = checkbutton.get_active()
+
     def _image_cb(self, button):
         def cb(object):
             logging.debug('ObjectChooser: %r' % object)
-            self._abiword_canvas.insert_image(object.file_path, True)
+            self._abiword_canvas.insert_image(object.file_path,
self.floating_image)
         chooser.pick(parent=self._abiword_canvas.get_toplevel(),
what=chooser.IMAGE, cb=cb)

     def _table_cb(self, abi, rows, cols):
-- 
1.7.2.3


More information about the Sugar-devel mailing list