diff --git a/sugar/graphics2/toolbox.py b/sugar/graphics2/toolbox.py index c3148b76..be7e5e09 100644 --- a/sugar/graphics2/toolbox.py +++ b/sugar/graphics2/toolbox.py @@ -24,6 +24,7 @@ class Toolbox(gtk.VBox): self._notebook = gtk.Notebook() self._notebook.set_tab_pos(gtk.POS_BOTTOM) + self._notebook.set_show_border(False) self.pack_start(self._notebook) self._notebook.show() diff --git a/sugar/graphics2/window.py b/sugar/graphics2/window.py index 068d1770..d03788b0 100644 --- a/sugar/graphics2/window.py +++ b/sugar/graphics2/window.py @@ -31,8 +31,19 @@ class Window(gtk.Window): vbox.pack_start(self.toolbox, False) self.toolbox.show() + self._canvas_box = gtk.VBox() + vbox.pack_start(self._canvas_box) + self._canvas_box.show() + self.canvas = hippo.Canvas() - vbox.pack_start(self.canvas) + self._canvas_box.pack_start(self.canvas) self.canvas.show() vbox.show() + + def set_canvas(self, canvas): + if self.canvas: + self._canvas_box.remove(self.canvas) + + self._canvas_box.add(canvas) + self.canvas = canvas diff --git a/tests/test-ui.py b/tests/test-ui.py index e44828cd..26f3d127 100755 --- a/tests/test-ui.py +++ b/tests/test-ui.py @@ -17,10 +17,17 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gtk -import hippo from sugar.graphics2.window import Window +class ActivityToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class EditToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + class TextToolbar(gtk.Toolbar): def __init__(self): gtk.Toolbar.__init__(self) @@ -30,14 +37,61 @@ class TextToolbar(gtk.Toolbar): self.insert(button, -1) button.show() +class ImageToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class TableToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class FormatToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class ViewToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + window = Window() window.connect("destroy", lambda w: gtk.main_quit()) +activity_toolbar = ActivityToolbar() +window.toolbox.add_toolbar('Activity', activity_toolbar) +activity_toolbar.show() + +edit_toolbar = EditToolbar() +window.toolbox.add_toolbar('Edit', edit_toolbar) +edit_toolbar.show() + text_toolbar = TextToolbar() window.toolbox.add_toolbar('Text', text_toolbar) text_toolbar.show() -window.canvas.set_root(hippo.CanvasBox(background_color=0)) +image_toolbar = ImageToolbar() +window.toolbox.add_toolbar('Image', image_toolbar) +image_toolbar.show() + +table_toolbar = TableToolbar() +window.toolbox.add_toolbar('Table', table_toolbar) +table_toolbar.show() + +format_toolbar = FormatToolbar() +window.toolbox.add_toolbar('Format', format_toolbar) +format_toolbar.show() + +view_toolbar = ViewToolbar() +window.toolbox.add_toolbar('View', view_toolbar) +view_toolbar.show() + +scrolled_window = gtk.ScrolledWindow() +scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) +window.set_canvas(scrolled_window) +scrolled_window.show() + +text_view = gtk.TextView() +scrolled_window.add(text_view) +text_view.show() window.show()