Add more toolbars and a text area

This commit is contained in:
Marco Pesenti Gritti 2007-04-20 15:38:34 +02:00
parent f6a93fd8e9
commit 76e375749a
3 changed files with 69 additions and 3 deletions

View File

@ -24,6 +24,7 @@ class Toolbox(gtk.VBox):
self._notebook = gtk.Notebook() self._notebook = gtk.Notebook()
self._notebook.set_tab_pos(gtk.POS_BOTTOM) self._notebook.set_tab_pos(gtk.POS_BOTTOM)
self._notebook.set_show_border(False)
self.pack_start(self._notebook) self.pack_start(self._notebook)
self._notebook.show() self._notebook.show()

View File

@ -31,8 +31,19 @@ class Window(gtk.Window):
vbox.pack_start(self.toolbox, False) vbox.pack_start(self.toolbox, False)
self.toolbox.show() self.toolbox.show()
self._canvas_box = gtk.VBox()
vbox.pack_start(self._canvas_box)
self._canvas_box.show()
self.canvas = hippo.Canvas() self.canvas = hippo.Canvas()
vbox.pack_start(self.canvas) self._canvas_box.pack_start(self.canvas)
self.canvas.show() self.canvas.show()
vbox.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

View File

@ -17,10 +17,17 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import gtk import gtk
import hippo
from sugar.graphics2.window import Window 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): class TextToolbar(gtk.Toolbar):
def __init__(self): def __init__(self):
gtk.Toolbar.__init__(self) gtk.Toolbar.__init__(self)
@ -30,14 +37,61 @@ class TextToolbar(gtk.Toolbar):
self.insert(button, -1) self.insert(button, -1)
button.show() 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 = Window()
window.connect("destroy", lambda w: gtk.main_quit()) 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() text_toolbar = TextToolbar()
window.toolbox.add_toolbar('Text', text_toolbar) window.toolbox.add_toolbar('Text', text_toolbar)
text_toolbar.show() 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() window.show()