[Sugar-devel] [PATCH Read] Alert the user when he removes a bookmark SL #1274

Manuel Kaufmann humitos at gmail.com
Tue May 29 12:03:26 EDT 2012


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 at gmail.com>
---
 readactivity.py |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/readactivity.py b/readactivity.py
index c0092d5..5e23b86 100644
--- a/readactivity.py
+++ b/readactivity.py
@@ -39,6 +39,7 @@ from sugar3.graphics.toolbarbox import ToolbarBox
 from sugar3.graphics.toolbarbox import ToolbarButton
 from sugar3.graphics.toolcombobox import ToolComboBox
 from sugar3.graphics.toggletoolbutton import ToggleToolButton
+from sugar3.graphics.alert import ConfirmationAlert
 from sugar3.activity.widgets import ActivityToolbarButton
 from sugar3.activity.widgets import StopButton
 from sugar3 import network
@@ -477,7 +478,24 @@ class ReadActivity(activity.Activity):
         if self._bookmarker.props.active:
             self._sidebar.add_bookmark(page)
         else:
+            alert = ConfirmationAlert()
+            alert.props.title = _('Delete bookmark')
+            alert.props.msg = _('All the information related '
+                                'with this bookmark will be lost')
+            self.add_alert(alert)
+            alert.connect('response', self.__alert_response_cb, page)
+            alert.show()
+
+    def __alert_response_cb(self, alert, response_id, page):
+        self.remove_alert(alert)
+
+        if response_id is Gtk.ResponseType.OK:
             self._sidebar.del_bookmark(page)
+        elif response_id is Gtk.ResponseType.CANCEL:
+            self._bookmarker.handler_block(self._bookmarker_toggle_handler_id)
+            self._bookmarker.props.active = True
+            self._bookmarker.handler_unblock(\
+                self._bookmarker_toggle_handler_id)
 
     def __page_changed_cb(self, model, page_from, page_to):
         self._update_nav_buttons(page_to)
-- 
1.7.10



More information about the Sugar-devel mailing list