# Copyright (C) 2006 by Martin Sevior # Copyright (C) 2006-2007 Marc Maurer # # 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 from sugar.graphics.toolbar import Toolbar from sugar.graphics.iconbutton import IconButton class AbiToolbar(): def __init__(self, hippoCanvasBox, abiword_canvas): toolbar = Toolbar() hippoCanvasBox.append(toolbar) self._abiword_canvas = abiword_canvas self._open = IconButton(icon_name='theme:stock-open') self._open.connect("activated", self._open_cb) toolbar.append(self._open) self._save = IconButton(icon_name='theme:stock-save') self._save.connect("activated", self._save_cb) self._abiword_canvas.connect("is-dirty", self._isDirty_cb) toolbar.append(self._save) # self._insert_separator() self._undo = IconButton(icon_name='theme:stock-undo') self._undo.connect("activated", self._undo_cb) self._abiword_canvas.connect("can_undo", self._canUndo_cb) toolbar.append(self._undo) self._redo = IconButton(icon_name='theme:stock-redo') self._redo.connect("activated", self._redo_cb) self._abiword_canvas.connect("can_redo", self._canRedo_cb) toolbar.append(self._redo) # self._insert_separator() self._underline = IconButton(icon_name='theme:stock-underline') self._underline_id = self._underline.connect("activated", self._underline_cb) self._abiword_canvas.connect("underline", self._isUnderline_cb) toolbar.append(self._underline) self._bold = IconButton(icon_name='theme:stock-bold') self._bold_id = self._bold.connect("activated", self._bold_cb) self._abiword_canvas.connect("bold", self._isBold_cb) toolbar.append(self._bold) # self._insert_separator() self._align_left = IconButton(icon_name='theme:stock-justify-left') self._align_left_id = self._align_left.connect("activated", self._align_left_cb) self._abiword_canvas.connect("left-align", self._isLeftAlign_cb) toolbar.append(self._align_left) self._align_center = IconButton(icon_name='theme:stock-justify-center') self._align_center_id = self._align_center.connect("activated", self._align_center_cb) self._abiword_canvas.connect("center-align", self._isCenterAlign_cb) toolbar.append(self._align_center) self._align_right = IconButton(icon_name='theme:stock-justify-right') self._align_right_id = self._align_right.connect("activated", self._align_right_cb) self._abiword_canvas.connect("right-align", self._isRightAlign_cb) toolbar.append(self._align_right) # def _insert_separator(self): # separator = gtk.SeparatorToolItem() # separator.set_draw(True) # self.insert(separator, -1) # separator.show() # # def setToggleButtonState(self, button, b, id): # button.handler_block(id) # button.set_active(b) # button.handler_unblock(id) def _open_cb(self, button): self._abiword_canvas.file_open() def _save_cb(self, button): self._abiword_canvas.file_save() def _isDirty_cb(self, abi, b): print "isDirty",b # self._save.set_sensitive(b) def _undo_cb(self, button): self._abiword_canvas.undo() def _canUndo_cb(self, abi, b): print "canUndo",b # self._undo.set_sensitive(b) def _redo_cb(self, button): self._abiword_canvas.redo() def _canRedo_cb(self, abi ,b): print "canRedo",b # self._redo.set_sensitive(b) def _underline_cb(self, button): self._abiword_canvas.toggle_underline() def _isUnderline_cb(self, abi, b): print "isUnderline",b # self.setToggleButtonState(self._underline, b, self._underline_id) def _bold_cb(self, button): self._abiword_canvas.toggle_bold() def _isBold_cb(self, abi, b): print "isBold",b # self.setToggleButtonState(self._bold,b,self._bold_id) def _align_left_cb(self, button): self._abiword_canvas.align_left() def _isLeftAlign_cb(self, abi, b): print "isLeftAlign",b # self.setToggleButtonState(self._align_left,b,self._align_left_id) def _align_center_cb(self, button): self._abiword_canvas.align_center() def _isCenterAlign_cb(self, abi, b): print "isCenterAlign",b # self.setToggleButtonState(self._align_center,b,self._align_center_id) def _align_right_cb(self, button): self._abiword_canvas.align_right() def _isRightAlign_cb(self, abi, b): print "isRightAlign",b # self.setToggleButtonState(self._align_right,b,self._align_right_id)