1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#!/usr/bin/python
# Copyright (C) 2006, Martin Sevior <msevior@physics.unimelb.edu.au>.
#
# 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 sys
import pygtk
pygtk.require('2.0')
import gtk
import abiword
import gettext
from abiword import Canvas
from toolbar import Toolbar
class SugarAbiWord:
"""Main class for SugarAbiWord"""
def __init__(self):
gtk.gdk.threads_init()
mainWindow = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
mainWindow.resize(640,480)
mainWindow.show()
hbox = gtk.HBox(False, 0)
mainWindow.add(hbox)
hbox.show()
print 'Pullin in Canvas \n '
self.abiword_canvas = Canvas()
print 'Canvas obtained \n'
toolbar = Toolbar(self.abiword_canvas)
hbox.pack_start(toolbar, False)
toolbar.show()
hbox.add(self.abiword_canvas)
self.abiword_canvas.show()
mainWindow.connect("delete_event",self._delete_cb)
#
# test out signals
#
self.styleName_id = self.abiword_canvas.connect("style-name",self.styleName_cb)
self.fontFamily_id = self.abiword_canvas.connect("font-family",self.fontFamily_cb)
self.fontSize_id = self.abiword_canvas.connect("font-size",self.fontSize_cb)
self.textSelected_id = self.abiword_canvas.connect("text-selected",self.textSelected_cb)
self.imageSelected_id = self.abiword_canvas.connect("image-selected",self.imageSelected_cb)
self.selectionCleared_id = self.abiword_canvas.connect("selection-cleared",self.selectionCleared_cb)
self.enterSelection_id = self.abiword_canvas.connect("enter-selection",self.enterSelection_cb)
self.leaveSelection_id = self.abiword_canvas.connect("leave-selection",self.leaveSelection_cb)
def _delete_cb(self,me,p):
print "Doing delete \n"
self.abiword_canvas.save_immediate()
gtk.main_quit()
def main(self):
gtk.main()
def styleName_cb(self,abi,sz):
print 'Style is ',sz
def fontFamily_cb(self,abi,sz):
print 'Font Family is ',sz
def fontSize_cb(self,abi,iSize):
print 'Font Size is ',iSize
def textSelected_cb(self,abi,b):
if b:
print 'Text selected \n'
else:
print 'Text unselected \n'
def imageSelected_cb(self,abi,b):
if b:
print 'Image selected \n'
else:
print 'Image unselected \n'
def selectionCleared_cb(self,abi,b):
if b:
print 'Selected cleared\n'
else:
print 'Selection cleared -error wrong bool \n'
def enterSelection_cb(self,abi,b):
if b:
print 'Enter Selection \n'
else:
print 'enter selection -error wrong bool \n'
def leaveSelection_cb(self,abi,b):
if b:
print 'Leave Selection \n'
else:
print 'Leave selection -error wrong bool \n'
MySugarAbiWord = SugarAbiWord()
MySugarAbiWord.main()
|