Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Maurer <uwog@uwog.net>2006-12-01 00:37:56 (GMT)
committer Marc Maurer <uwog@uwog.net>2006-12-01 00:37:56 (GMT)
commit65971425cca59a0f246f6c6d1338c9ae6218f455 (patch)
treea723f62e8f828901cbfec1ea7ac3169e885ead15
parent88149a34f5d5328ab26505b98651b07fff9786db (diff)
The start of the new abiword activity, using the python
bindings to build the interface (patch from Tomeu Vizoso, tweaked by me)
-rwxr-xr-xAbiWordActivity.py37
-rw-r--r--toolbar.py131
2 files changed, 146 insertions, 22 deletions
diff --git a/AbiWordActivity.py b/AbiWordActivity.py
index 24fb415..ebb63aa 100755
--- a/AbiWordActivity.py
+++ b/AbiWordActivity.py
@@ -1,29 +1,12 @@
-
import logging
import os
import time
import gtk
+from abiword import Canvas
from sugar.activity.Activity import Activity
-
-class AbiWord (gtk.Socket):
-
- def __init__ (self):
- gtk.Socket.__init__ (self)
-
- self.connect ('realize', self.realize_cb)
-
-
- def realize_cb (self, event):
-
- params = [
- 'abiword',
- '--nosplash',
- '--gtk-socket-id=' + str (self.get_id ())
- ]
- os.spawnvp (os.P_NOWAIT, 'abiword', params)
-
+from toolbar import Toolbar
class AbiWordActivity (Activity):
@@ -32,6 +15,16 @@ class AbiWordActivity (Activity):
self.set_title ("AbiWord")
- abiword = AbiWord ()
- self.add (abiword)
- abiword.show_all ()
+ hbox = gtk.HBox(False, 0)
+ self.add(hbox)
+ hbox.show()
+
+ abiword_canvas = Canvas()
+
+ toolbar = Toolbar(abiword_canvas)
+ hbox.pack_start(toolbar, False)
+ toolbar.show()
+
+ hbox.add(abiword_canvas)
+ abiword_canvas.set_property("load-file", "")
+ abiword_canvas.show()
diff --git a/toolbar.py b/toolbar.py
new file mode 100644
index 0000000..8b79892
--- /dev/null
+++ b/toolbar.py
@@ -0,0 +1,131 @@
+# Copyright (C) 2006, Red Hat, Inc.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import logging
+import gtk
+import pango
+
+class Toolbar(gtk.Toolbar):
+ def __init__(self, abiword_canvas):
+ gtk.Toolbar.__init__(self)
+
+ self.set_orientation(gtk.ORIENTATION_VERTICAL)
+ self.set_style(gtk.TOOLBAR_ICONS)
+
+ self._abiword_canvas = abiword_canvas
+
+ self._open = gtk.ToolButton()
+ self._open.set_icon_name('gtk-open')
+ self._open.connect("clicked", self._open_cb)
+ self.insert(self._open, -1)
+ self._open.show()
+
+ self._save = gtk.ToolButton()
+ self._save.set_icon_name('gtk-save')
+ self._save.connect("clicked", self._save_cb)
+ self.insert(self._save, -1)
+ self._save.show()
+
+ self._insert_separator()
+
+ self._undo = gtk.ToolButton()
+ self._undo.set_icon_name('gtk-undo')
+ self._undo.connect("clicked", self._undo_cb)
+ self.insert(self._undo, -1)
+ self._undo.show()
+
+ self._redo = gtk.ToolButton()
+ self._redo.set_icon_name('gtk-redo')
+ self._redo.connect("clicked", self._redo_cb)
+ self.insert(self._redo, -1)
+ self._redo.show()
+
+ self._insert_separator()
+
+ self._underline = gtk.ToolButton()
+ self._underline.set_icon_name('gtk-underline')
+ self._underline.connect("clicked", self._underline_cb)
+ self.insert(self._underline, -1)
+ self._underline.show()
+
+ self._bold = gtk.ToolButton()
+ self._bold.set_icon_name('gtk-bold')
+ self._bold.connect("clicked", self._bold_cb)
+ self.insert(self._bold, -1)
+ self._bold.show()
+
+ self._insert_separator()
+
+ self._align_left = gtk.ToolButton()
+ self._align_left.set_icon_name('gtk-justify-left')
+ self._align_left.connect("clicked", self._align_left_cb)
+ self.insert(self._align_left, -1)
+ self._align_left.show()
+
+ self._align_center = gtk.ToolButton()
+ self._align_center.set_icon_name('gtk-justify-center')
+ self._align_center.connect("clicked", self._align_center_cb)
+ self.insert(self._align_center, -1)
+ self._align_center.show()
+
+ self._align_right = gtk.ToolButton()
+ self._align_right.set_icon_name('gtk-justify-right')
+ self._align_right.connect("clicked", self._align_right_cb)
+ self.insert(self._align_right, -1)
+ self._align_right.show()
+
+ self._align_fill = gtk.ToolButton()
+ self._align_fill.set_icon_name('gtk-justify-fill')
+ self._align_fill.connect("clicked", self._align_fill_cb)
+ self.insert(self._align_fill, -1)
+ self._align_fill.show()
+
+ def _insert_separator(self):
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(True)
+ self.insert(separator, -1)
+ separator.show()
+
+ def _open_cb(self, button):
+ self._abiword_canvas.set_property("file-open","")
+
+ def _save_cb(self, button):
+ self._abiword_canvas.set_property("file-save","")
+
+ def _undo_cb(self, button):
+ self._abiword_canvas.set_property("undo","")
+
+ def _redo_cb(self, button):
+ self._abiword_canvas.set_property("redo","")
+
+ def _underline_cb(self, button):
+ self._abiword_canvas.set_property("toggle-uline","")
+
+ def _bold_cb(self, button):
+ self._abiword_canvas.set_property("toggle-bold","")
+
+ def _align_left_cb(self, button):
+ self._abiword_canvas.set_property("align-left","")
+
+ def _align_center_cb(self, button):
+ self._abiword_canvas.set_property("align-center","")
+
+ def _align_right_cb(self, button):
+ self._abiword_canvas.set_property("align-right","")
+
+ def _align_fill_cb(self, button):
+ self._abiword_canvas.set_property("align-fill","")
+