From 5e1f45d74b76b5716cac328ef23cb88ec391612f Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Tue, 30 Aug 2011 17:35:32 +0000 Subject: Replace the export combo by a group of buttons This change do more discoverable the functionality and improve consistencywith other activities. Signed-off-by: Gonzalo Odiard --- diff --git a/AbiWordActivity.py b/AbiWordActivity.py index 09543dd..9b105fe 100644 --- a/AbiWordActivity.py +++ b/AbiWordActivity.py @@ -48,7 +48,7 @@ from toolbar import TextToolbar from toolbar import ListToolbar from toolbar import InsertToolbar from toolbar import ParagraphToolbar -from widgets import ExportButton +from widgets import ExportButtonFactory logger = logging.getLogger('write-activity') @@ -66,15 +66,14 @@ class AbiWordActivity(activity.Activity): toolbar_box = ToolbarBox() - activity_button = ActivityToolbarButton(self) + self.activity_button = ActivityToolbarButton(self) + toolbar_box.toolbar.insert(self.activity_button, -1) separator = gtk.SeparatorToolItem() separator.show() - activity_button.props.page.insert(separator, 2) - export_button = ExportButton(self, self.abiword_canvas) - export_button.show() - activity_button.props.page.insert(export_button, 2) - toolbar_box.toolbar.insert(activity_button, 0) + self.activity_button.props.page.insert(separator, 2) + ExportButtonFactory(self, self.abiword_canvas) + self.activity_button.show() edit_toolbar = ToolbarButton() edit_toolbar.props.page = EditToolbar(self, toolbar_box) diff --git a/icons/save-as-html.svg b/icons/save-as-html.svg new file mode 100644 index 0000000..92f1fd2 --- /dev/null +++ b/icons/save-as-html.svg @@ -0,0 +1,128 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/icons/save-as-pdf.svg b/icons/save-as-pdf.svg new file mode 100644 index 0000000..a1c6af8 --- /dev/null +++ b/icons/save-as-pdf.svg @@ -0,0 +1,155 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PDF + \ No newline at end of file diff --git a/icons/save-as-rtf.svg b/icons/save-as-rtf.svg new file mode 100644 index 0000000..0e8d81c --- /dev/null +++ b/icons/save-as-rtf.svg @@ -0,0 +1,155 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RTF + \ No newline at end of file diff --git a/icons/save-as-txt.svg b/icons/save-as-txt.svg new file mode 100644 index 0000000..e60c753 --- /dev/null +++ b/icons/save-as-txt.svg @@ -0,0 +1,182 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TXT + \ No newline at end of file diff --git a/widgets.py b/widgets.py index 0a525bf..728963d 100644 --- a/widgets.py +++ b/widgets.py @@ -159,47 +159,44 @@ class AbiButton(RadioToolButton): self.handler_unblock(self._toggled_handler) -class ExportButton(ToolButton): +class ExportButtonFactory(): _EXPORT_FORMATS = [{'mime_type': 'application/rtf', 'title': _('Rich Text (RTF)'), + 'icon':'save-as-rtf', 'jpostfix': _('RTF'), 'exp_props': ''}, {'mime_type': 'text/html', 'title': _('Hypertext (HTML)'), + 'icon':'save-as-html', 'jpostfix': _('HTML'), 'exp_props': 'html4:yes; declare-xml:no; ' \ 'embed-css:yes; embed-images:yes;'}, {'mime_type': 'text/plain', 'title': _('Plain Text (TXT)'), + 'icon':'save-as-txt', 'jpostfix': _('TXT'), 'exp_props': ''}, {'mime_type': 'application/pdf', 'title': _('Portable Document Format (PDF)'), + 'icon':'save-as-pdf', 'jpostfix': _('PDF'), 'exp_props': ''}] def __init__(self, activity, abi): - ToolButton.__init__(self, 'document-save') - self.props.tooltip = _('Export') - self.props.label = _('Export') + toolbar = activity.activity_button.props.page for i in self._EXPORT_FORMATS: - menu_item = MenuItem(i['title']) - menu_item.connect('activate', self.__activate_cb, activity, abi, i) - self.props.palette.menu.append(menu_item) - menu_item.show() - - def do_clicked(self): - if self.props.palette.is_up(): - self.props.palette.popdown(immediate=True) - else: - self.props.palette.popup(immediate=True, state=Palette.SECONDARY) - - def __activate_cb(self, menu_item, activity, abi, format): + button = ToolButton(i['icon']) + button.set_tooltip(i['title']) + button.connect('clicked', self.__clicked_cb, activity, abi, i) + toolbar.insert(button, -1) + button.show() + + def __clicked_cb(self, menu_item, activity, abi, format): logger.debug('exporting file: %r' % format) exp_props = format['exp_props'] -- cgit v0.9.1