Ticket #1274: 0001-Alert-the-user-when-he-removes-a-bookmark-SL-1274.patch

File 0001-Alert-the-user-when-he-removes-a-bookmark-SL-1274.patch, 2.2 KB (added by humitos, 12 years ago)
  • readactivity.py

    From 2b5ec0886d5290f4d3a0a347ff164b9eaef83fd1 Mon Sep 17 00:00:00 2001
    Message-Id: <2b5ec0886d5290f4d3a0a347ff164b9eaef83fd1.1338307395.git.humitos@gmail.com>
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Tue, 29 May 2012 13:01:18 -0300
    Subject: [PATCH Read] Alert the user when he removes a bookmark SL #1274
    
    Alert the user with a Confirmation Alert when he / she removes a bookmark
    informing that the bookmark information will be lost.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     readactivity.py |   18 ++++++++++++++++++
     1 file changed, 18 insertions(+)
    
    diff --git a/readactivity.py b/readactivity.py
    index c0092d5..5e23b86 100644
    a b from sugar3.graphics.toolbarbox import ToolbarBox 
    3939from sugar3.graphics.toolbarbox import ToolbarButton
    4040from sugar3.graphics.toolcombobox import ToolComboBox
    4141from sugar3.graphics.toggletoolbutton import ToggleToolButton
     42from sugar3.graphics.alert import ConfirmationAlert
    4243from sugar3.activity.widgets import ActivityToolbarButton
    4344from sugar3.activity.widgets import StopButton
    4445from sugar3 import network
    class ReadActivity(activity.Activity): 
    477478        if self._bookmarker.props.active:
    478479            self._sidebar.add_bookmark(page)
    479480        else:
     481            alert = ConfirmationAlert()
     482            alert.props.title = _('Delete bookmark')
     483            alert.props.msg = _('All the information related '
     484                                'with this bookmark will be lost')
     485            self.add_alert(alert)
     486            alert.connect('response', self.__alert_response_cb, page)
     487            alert.show()
     488
     489    def __alert_response_cb(self, alert, response_id, page):
     490        self.remove_alert(alert)
     491
     492        if response_id is Gtk.ResponseType.OK:
    480493            self._sidebar.del_bookmark(page)
     494        elif response_id is Gtk.ResponseType.CANCEL:
     495            self._bookmarker.handler_block(self._bookmarker_toggle_handler_id)
     496            self._bookmarker.props.active = True
     497            self._bookmarker.handler_unblock(\
     498                self._bookmarker_toggle_handler_id)
    481499
    482500    def __page_changed_cb(self, model, page_from, page_to):
    483501        self._update_nav_buttons(page_to)