Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/viewtoolbar.py
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-09-28 00:34:12 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-09-28 00:34:12 (GMT)
commit49495aa4584035a97754c75b124a3c326d9f8db9 (patch)
tree45fb2fc882271deb88048648aa584fe8abf05c4b /viewtoolbar.py
parent5d0188398a92d6f28fbe5a7aa22f43b3e2edfe21 (diff)
Restore the Bookmarks tray handling using a toggle button - SL #3868
Instead of changing the tooltip and icon of the tool button based on the visibility of the tray, with the map and unmap callbacks that this patch removes, do the inverse: when a bookmark is made, the toggle button is activated, and it shows the tray in the toggled callback. Also when the only pending bookmark is removed, the toggle button is deactivated, and it hides the tray in the toggled callback. The switch to a toggle button allows us to do the tray and button interaction in a more standard way, and the bugs that the unconventional interaction raised are now fixed. Signed-off-by: Manuel Quiñones <manuq@laptop.org> Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Diffstat (limited to 'viewtoolbar.py')
-rw-r--r--viewtoolbar.py32
1 files changed, 10 insertions, 22 deletions
diff --git a/viewtoolbar.py b/viewtoolbar.py
index e7ad13e..7ea4487 100644
--- a/viewtoolbar.py
+++ b/viewtoolbar.py
@@ -21,6 +21,7 @@ from gi.repository import Gtk
from gi.repository import GObject
from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.toggletoolbutton import ToggleToolButton
from browser import Browser
from browser import ZOOM_ORIGINAL
@@ -33,8 +34,6 @@ class ViewToolbar(Gtk.Toolbar):
self._browser = None
self._activity = activity
- self._activity.tray.connect('unmap', self.__unmap_cb)
- self._activity.tray.connect('map', self.__map_cb)
self.zoomout = ToolButton('zoom-out')
self.zoomout.set_tooltip(_('Zoom out'))
@@ -65,9 +64,10 @@ class ViewToolbar(Gtk.Toolbar):
self.insert(self.fullscreen, -1)
self.fullscreen.show()
- self.traybutton = ToolButton('tray-hide')
- self.traybutton.connect('clicked', self.__tray_clicked_cb)
+ self.traybutton = ToggleToolButton('tray-show')
+ self.traybutton.connect('toggled', self.__tray_toggled_cb)
self.traybutton.props.sensitive = False
+ self.traybutton.props.active = False
self.insert(self.traybutton, -1)
self.traybutton.show()
@@ -105,24 +105,12 @@ class ViewToolbar(Gtk.Toolbar):
def __fullscreen_clicked_cb(self, button):
self._activity.fullscreen()
- def __tray_clicked_cb(self, button):
- if self._activity.tray.props.visible is False:
+ def __tray_toggled_cb(self, button):
+ if button.props.active:
self._activity.tray.show()
+ self.traybutton.set_icon_name('tray-show')
+ self.traybutton.set_tooltip(_('Show Tray'))
else:
self._activity.tray.hide()
-
- def __map_cb(self, tray):
- if len(self._activity.tray.get_children()) > 0:
- self.tray_set_hide()
-
- def __unmap_cb(self, tray):
- if len(self._activity.tray.get_children()) > 0:
- self.tray_set_show()
-
- def tray_set_show(self):
- self.traybutton.set_icon('tray-show')
- self.traybutton.set_tooltip(_('Show Tray'))
-
- def tray_set_hide(self):
- self.traybutton.set_icon('tray-hide')
- self.traybutton.set_tooltip(_('Hide Tray'))
+ self.traybutton.set_icon_name('tray-hide')
+ self.traybutton.set_tooltip(_('Hide Tray'))