Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/readtoolbar.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-08-29 14:12:53 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-09-10 14:19:32 (GMT)
commit759188370815f490a6f85343c679e2d3372e9b66 (patch)
tree817365922d64824da808881fc2069ad093f83402 /readtoolbar.py
parent9d18b220d83f274328806bcb5a56727c963c5be2 (diff)
Show the table of contents in a panel
The table of contents, actually implemented in epub backend, is displayed in a later panel, instead of in a combo, to do easier the interaction with touch, and provide context. The code is now more general to allow the implementation in the pdf backend too. The button used to display the table of contents, was moved from the main toolbar to the view subtoolbar. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'readtoolbar.py')
-rw-r--r--readtoolbar.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/readtoolbar.py b/readtoolbar.py
index 58baebc..737c55d 100644
--- a/readtoolbar.py
+++ b/readtoolbar.py
@@ -22,6 +22,7 @@ from gi.repository import Gtk
from gi.repository import Gdk
from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.toggletoolbutton import ToggleToolButton
from sugar3.graphics import iconentry
from sugar3.activity.widgets import EditToolbar as BaseEditToolbar
@@ -164,6 +165,8 @@ class ViewToolbar(Gtk.Toolbar):
__gsignals__ = {
'go-fullscreen': (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,
([])),
+ 'toggle-index-show': (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,
+ ([bool])),
}
def __init__(self):
@@ -171,6 +174,15 @@ class ViewToolbar(Gtk.Toolbar):
self._view = None
+ self._navigator_button = ToggleToolButton('view-list')
+ self._navigator_button.set_tooltip(_('Table of contents'))
+ self._navigator_button.connect('toggled', self.__navigator_toggled_cb)
+ self.insert(self._navigator_button, -1)
+
+ self._spacer_navigator = Gtk.SeparatorToolItem()
+ self._spacer_navigator.props.draw = False
+ self.insert(self._spacer_navigator, -1)
+
self._zoom_out = ToolButton('zoom-out')
self._zoom_out.set_tooltip(_('Zoom out'))
self._zoom_out.connect('clicked', self._zoom_out_cb)
@@ -218,6 +230,10 @@ class ViewToolbar(Gtk.Toolbar):
self._view = view
self._update_zoom_buttons()
+ def show_nav_button(self):
+ self._navigator_button.show()
+ self._spacer_navigator.show()
+
def zoom_in(self):
self._view.zoom_in()
self._update_zoom_buttons()
@@ -239,6 +255,9 @@ class ViewToolbar(Gtk.Toolbar):
def _zoom_to_width_cb(self, button):
self.zoom_to_width()
+ def __navigator_toggled_cb(self, button):
+ self.emit('toggle-index-show', button.get_active())
+
def _update_zoom_buttons(self):
self._zoom_in.props.sensitive = self._view.can_zoom_in()
self._zoom_out.props.sensitive = self._view.can_zoom_out()