diff options
-rw-r--r-- | AbiWordActivity.py | 11 | ||||
-rw-r--r-- | toolbar.py | 66 | ||||
-rw-r--r-- | widgets.py | 24 |
3 files changed, 50 insertions, 51 deletions
diff --git a/AbiWordActivity.py b/AbiWordActivity.py index e66e9d1..7de5423 100644 --- a/AbiWordActivity.py +++ b/AbiWordActivity.py @@ -46,7 +46,6 @@ from sugar3.graphics.xocolor import XoColor from toolbar import EditToolbar from toolbar import ViewToolbar from toolbar import TextToolbar -from toolbar import ListToolbar from toolbar import InsertToolbar from toolbar import ParagraphToolbar from widgets import ExportButtonFactory @@ -130,21 +129,12 @@ class AbiWordActivity(activity.Activity): para_toolbar.props.label = _('Paragraph') toolbar_box.toolbar.insert(para_toolbar, -1) - list_toolbar = ToolbarButton() - list_toolbar.props.page = ListToolbar(self.abiword_canvas) - list_toolbar.props.icon_name = 'toolbar-bulletlist' - list_toolbar.props.label = _('Bullet List') - toolbar_box.toolbar.insert(list_toolbar, -1) - insert_toolbar = ToolbarButton() insert_toolbar.props.page = InsertToolbar(self.abiword_canvas) insert_toolbar.props.icon_name = 'insert-table' insert_toolbar.props.label = _('Table') toolbar_box.toolbar.insert(insert_toolbar, -1) - separator = Gtk.SeparatorToolItem() - toolbar_box.toolbar.insert(separator, -1) - image = ToolButton('insert-picture') image.set_tooltip(_('Insert Image')) self._image_id = image.connect('clicked', self._image_cb) @@ -162,6 +152,7 @@ class AbiWordActivity(activity.Activity): separator = Gtk.SeparatorToolItem() separator.props.draw = False + separator.set_size_request(0, -1) separator.set_expand(True) separator.show() toolbar_box.toolbar.insert(separator, -1) @@ -574,52 +574,46 @@ class ParagraphToolbar(Gtk.Toolbar): self.insert(Gtk.SeparatorToolItem(), -1) - self.show_all() - - -class ListToolbar(Gtk.Toolbar): - - def __init__(self, abi): - GObject.GObject.__init__(self) - - def append(icon_name, tooltip, do_abi_cb, on_abi_cb): - button = AbiButton(abi, 'style-name', do_abi_cb, on_abi_cb) - button.props.icon_name = icon_name - button.props.group = group - button.props.tooltip = tooltip - self.insert(button, -1) - return button + def append_list(icon_name, tooltip, do_abi_cb, on_abi_cb, button, + button_icon=None): + menu_item = AbiMenuItem(abi, 'style-name', do_abi_cb, + icon_name, tooltip, button, on_abi_cb, button_icon) + button.props.palette.menu.append(menu_item) + menu_item.show() - group = None + list_btn = RadioMenuButton(icon_name='toolbar-bulletlist') + list_btn.props.tooltip = _('Select list') - group = append('list-none', _('Normal'), - lambda: - abi.set_style('Normal'), - lambda abi, style: + append_list('list-none', _('Normal'), + lambda: abi.set_style('Normal'), + lambda abi, style: style not in ['Bullet List', 'Dashed List', 'Numbered List', 'Lower Case List', - 'Upper Case List']) + 'Upper Case List'], + list_btn, 'toolbar-bulletlist') + + append_list('list-bullet', _('Bullet List'), + lambda: abi.set_style('Bullet List'), + lambda abi, style: style == 'Bullet List', list_btn) - append('list-bullet', _('Bullet List'), - lambda: abi.set_style('Bullet List'), - lambda abi, style: style == 'Bullet List') + append_list('list-dashed', _('Dashed List'), + lambda: abi.set_style('Dashed List'), + lambda abi, style: style == 'Dashed List', list_btn) - append('list-dashed', _('Dashed List'), - lambda: abi.set_style('Dashed List'), - lambda abi, style: style == 'Dashed List') + append_list('list-numbered', _('Numbered List'), + lambda: abi.set_style('Numbered List'), + lambda abi, style: style == 'Numbered List', list_btn) - append('list-numbered', _('Numbered List'), - lambda: abi.set_style('Numbered List'), - lambda abi, style: style == 'Numbered List') + append_list('list-lower-case', _('Lower Case List'), + lambda: abi.set_style('Lower Case List'), + lambda abi, style: style == 'Lower Case List', list_btn) - append('list-lower-case', _('Lower Case List'), - lambda: abi.set_style('Lower Case List'), - lambda abi, style: style == 'Lower Case List') + append_list('list-upper-case', _('Upper Case List'), + lambda: abi.set_style('Upper Case List'), + lambda abi, style: style == 'Upper Case List', list_btn) - append('list-upper-case', _('Upper Case List'), - lambda: abi.set_style('Upper Case List'), - lambda abi, style: style == 'Upper Case List') + self.insert(list_btn, -1) self.show_all() @@ -171,8 +171,11 @@ class AbiButton(RadioToolButton): class AbiMenuItem(MenuItem): def __init__(self, abi, abi_signal, do_abi_cb, icon_name, label, - button, on_abi_cb=None): + button, on_abi_cb=None, button_icon_name=None): self._icon_name = icon_name + # _button_icon_name is used only in the first case of + # the list menu + self._button_icon_name = button_icon_name self._button = button MenuItem.__init__(self, icon_name=icon_name, text_label=label) @@ -182,14 +185,22 @@ class AbiMenuItem(MenuItem): abi, do_abi_cb) def __activated_cb(self, button, abi, do_abi_cb): - if self._button.get_icon_name() == self._icon_name: - return + + if self._button_icon_name is not None: + if self._button.get_icon_name() == self._button_icon_name: + return + else: + if self._button.get_icon_name() == self._icon_name: + return abi.handler_block(self._abi_handler) try: logging.debug('Do abi %s' % do_abi_cb) do_abi_cb() - self._button.set_icon_name(self._icon_name) + if self._button_icon_name is not None: + self._button.set_icon_name(self._button_icon_name) + else: + self._button.set_icon_name(self._icon_name) finally: abi.handler_unblock(self._abi_handler) @@ -199,7 +210,10 @@ class AbiMenuItem(MenuItem): return logging.debug('On abi %s prop=%r' % (abi_signal, prop)) - self._button.set_icon_name(self._icon_name) + if self._button_icon_name is not None: + self._button.set_icon_name(self._button_icon_name) + else: + self._button.set_icon_name(self._icon_name) class ExportButtonFactory(): |