[Sugar-devel] [PATCH sugar] Journal: add alert to confirm before erasing an entry

Manuel Quiñones manuq at laptop.org
Wed Aug 22 10:36:54 EDT 2012


Yes, this v2 has the discussed wording.  Please commit.

2012/8/22 Simon Schampijer <simon at schampijer.de>:
> Erasing an entry in the Journal does not ask for confirmation
> before doing the erase. This patch adds an alert to the ListView
> and the DetailView that asks for confirmation before doing the
> erase. This is part of the touch interaction work [1].
>
> The wording of the alert has been finallized with Gary
> yesterday.
>
> Signed-off-by: Simon Schampijer <simon at laptop.org>

Acked-by: Manuel Quiñones <manuq at laptop.org>

>
> [1] http://wiki.sugarlabs.org/go/Features/Touch/Development#Journal
> ---
>  src/jarabe/journal/journaltoolbox.py | 31 +++++++++++++++++++++++++------
>  src/jarabe/journal/palettes.py       | 22 +++++++++++++++++++++-
>  2 files changed, 46 insertions(+), 7 deletions(-)
>
> diff --git a/src/jarabe/journal/journaltoolbox.py b/src/jarabe/journal/journaltoolbox.py
> index 2aa4153..9a5f5a2 100644
> --- a/src/jarabe/journal/journaltoolbox.py
> +++ b/src/jarabe/journal/journaltoolbox.py
> @@ -36,6 +36,7 @@ from sugar.graphics.combobox import ComboBox
>  from sugar.graphics.menuitem import MenuItem
>  from sugar.graphics.icon import Icon
>  from sugar.graphics.xocolor import XoColor
> +from sugar.graphics.alert import Alert
>  from sugar.graphics import iconentry
>  from sugar.graphics import style
>  from sugar import mime
> @@ -45,6 +46,7 @@ from jarabe.journal import misc
>  from jarabe.journal import model
>  from jarabe.journal.palettes import ClipboardMenu
>  from jarabe.journal.palettes import VolumeMenu
> +from jarabe.journal import journalwindow
>
>
>  _AUTOSEARCH_TIMEOUT = 1000
> @@ -438,12 +440,29 @@ class EntryToolbar(gtk.Toolbar):
>                        _('Error'))
>
>      def _erase_button_clicked_cb(self, button):
> -        registry = bundleregistry.get_registry()
> -
> -        bundle = misc.get_bundle(self._metadata)
> -        if bundle is not None and registry.is_installed(bundle):
> -            registry.uninstall(bundle)
> -        model.delete(self._metadata['uid'])
> +        alert = Alert()
> +        erase_string = _('Erase')
> +        alert.props.title = erase_string
> +        alert.props.msg = _('Do you want to permanently erase \"%s\"?') \
> +            % self._metadata['title']
> +        icon = Icon(icon_name='dialog-cancel')
> +        alert.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
> +        icon.show()
> +        ok_icon = Icon(icon_name='dialog-ok')
> +        alert.add_button(gtk.RESPONSE_OK, erase_string, ok_icon)
> +        ok_icon.show()
> +        alert.connect('response', self.__erase_alert_response_cb)
> +        journalwindow.get_journal_window().add_alert(alert)
> +        alert.show()
> +
> +    def __erase_alert_response_cb(self, alert, response_id):
> +        journalwindow.get_journal_window().remove_alert(alert)
> +        if response_id is gtk.RESPONSE_OK:
> +            registry = bundleregistry.get_registry()
> +            bundle = misc.get_bundle(self._metadata)
> +            if bundle is not None and registry.is_installed(bundle):
> +                registry.uninstall(bundle)
> +            model.delete(self._metadata['uid'])
>
>      def _resume_menu_item_activate_cb(self, menu_item, service_name):
>          misc.resume(self._metadata, service_name)
> diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
> index 8fc1e5d..f0d686f 100644
> --- a/src/jarabe/journal/palettes.py
> +++ b/src/jarabe/journal/palettes.py
> @@ -29,6 +29,7 @@ from sugar.graphics.palette import Palette
>  from sugar.graphics.menuitem import MenuItem
>  from sugar.graphics.icon import Icon
>  from sugar.graphics.xocolor import XoColor
> +from sugar.graphics.alert import Alert
>  from sugar import mime
>
>  from jarabe.model import friends
> @@ -36,6 +37,7 @@ from jarabe.model import filetransfer
>  from jarabe.model import mimeregistry
>  from jarabe.journal import misc
>  from jarabe.journal import model
> +from jarabe.journal import journalwindow
>
>
>  class ObjectPalette(Palette):
> @@ -142,7 +144,25 @@ class ObjectPalette(Palette):
>                        _('Error'))
>
>      def __erase_activate_cb(self, menu_item):
> -        model.delete(self._metadata['uid'])
> +        alert = Alert()
> +        erase_string = _('Erase')
> +        alert.props.title = erase_string
> +        alert.props.msg = _('Do you want to permanently erase \"%s\"?') \
> +            % self._metadata['title']
> +        icon = Icon(icon_name='dialog-cancel')
> +        alert.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
> +        icon.show()
> +        ok_icon = Icon(icon_name='dialog-ok')
> +        alert.add_button(gtk.RESPONSE_OK, erase_string, ok_icon)
> +        ok_icon.show()
> +        alert.connect('response', self.__erase_alert_response_cb)
> +        journalwindow.get_journal_window().add_alert(alert)
> +        alert.show()
> +
> +    def __erase_alert_response_cb(self, alert, response_id):
> +        journalwindow.get_journal_window().remove_alert(alert)
> +        if response_id is gtk.RESPONSE_OK:
> +            model.delete(self._metadata['uid'])
>
>      def __detail_activate_cb(self, menu_item):
>          self.emit('detail-clicked', self._metadata['uid'])
> --
> 1.7.11.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..


More information about the Sugar-devel mailing list