From 616e479f7dbeaeeb74e943ea72b94ee382a37c7a Mon Sep 17 00:00:00 2001 From: Marc Maurer Date: Tue, 28 Aug 2007 10:47:20 +0000 Subject: Add a Format toolbar & implement basic style support --- diff --git a/AbiWordActivity.py b/AbiWordActivity.py index 3789f6f..5645767 100644 --- a/AbiWordActivity.py +++ b/AbiWordActivity.py @@ -31,7 +31,7 @@ from sugar.activity.activity import Activity, ActivityToolbox, EditToolbar from sugar.presence import presenceservice from abiword import Canvas -from toolbar import TextToolbar, ImageToolbar, TableToolbar, ViewToolbar +from toolbar import TextToolbar, ImageToolbar, TableToolbar, FormatToolbar, ViewToolbar logger = logging.getLogger('write-activity') @@ -84,6 +84,10 @@ class AbiWordActivity (Activity): toolbox.add_toolbar(_('Table'), table_toolbar) table_toolbar.show() + format_toolbar = FormatToolbar(toolbox, self.abiword_canvas) + toolbox.add_toolbar(_('Format'), format_toolbar) + format_toolbar.show() + view_toolbar = ViewToolbar(self.abiword_canvas) toolbox.add_toolbar(_('View'), view_toolbar) view_toolbar.show() diff --git a/NEWS b/NEWS index 0e665e3..e6722fc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +* Add a format toolbar +* Implement basic style support + 35 * Update zoom icon names diff --git a/toolbar.py b/toolbar.py index cd5aa60..0ab143a 100644 --- a/toolbar.py +++ b/toolbar.py @@ -304,6 +304,40 @@ class TableToolbar(gtk.Toolbar): self._toolbox.set_current_toolbar(TOOLBAR_TABLE) self._abiword_canvas.grab_focus() # hack: bad toolbox, bad! +class FormatToolbar(gtk.Toolbar): + def __init__(self, toolbox, abiword_canvas): + gtk.Toolbar.__init__(self) + + self._toolbox = toolbox + self._abiword_canvas = abiword_canvas + + self._style_combo = ComboBox() + self._styles = ['Heading 1', + 'Heading 2', + 'Heading 3', + 'Heading 4', + 'Bullet List', + 'Dashed List', + 'Numbered List', + 'Lower Case List', + 'Upper Case List', + 'Block Text', + 'Normal', + 'Plain Text'] + self._style_changed_id = self._style_combo.connect('changed', self._style_changed_cb) + for i, s in enumerate(self._styles): + self._style_combo.append_item(i, s, None) + if s == 'Normal': + self._style_combo.set_active(i) + tool_item = ToolComboBox(self._style_combo) + self.insert(tool_item, -1); + tool_item.show() + + def _style_changed_cb(self, combobox): + if self._style_combo.get_active() != -1: + logger.debug('Setting style name: %s', self._styles[self._style_combo.get_active()]) + self._abiword_canvas.set_style(self._styles[self._style_combo.get_active()]) + class ViewToolbar(gtk.Toolbar): def __init__(self, abiword_canvas): gtk.Toolbar.__init__(self) -- cgit v0.9.1