1
# Copyright (C) 2007, One Laptop Per Child
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
from gettext import gettext as _
21
from sugar.graphics.toolbutton import ToolButton
23
class ViewToolbar(gtk.Toolbar):
24
def __init__(self, activity):
25
gtk.Toolbar.__init__(self)
27
self._activity = activity
28
self._activity.tray.connect('unmap', self.__unmap_cb)
29
self._activity.tray.connect('map', self.__map_cb)
31
self._browser = self._activity._browser
33
self.zoomout = ToolButton('zoom-out')
34
self.zoomout.set_tooltip(_('Zoom out'))
35
self.zoomout.connect('clicked', self.__zoomout_clicked_cb)
36
self.insert(self.zoomout, -1)
39
self.zoomin = ToolButton('zoom-in')
40
self.zoomin.set_tooltip(_('Zoom in'))
41
self.zoomin.connect('clicked', self.__zoomin_clicked_cb)
42
self.insert(self.zoomin, -1)
45
self.separator = gtk.SeparatorToolItem()
46
self.separator.set_draw(True)
47
self.insert(self.separator, -1)
50
self.fullscreen = ToolButton('view-fullscreen')
51
self.fullscreen.set_tooltip(_('Fullscreen'))
52
self.fullscreen.connect('clicked', self.__fullscreen_clicked_cb)
53
self.insert(self.fullscreen, -1)
54
self.fullscreen.show()
56
self.traybutton = ToolButton('tray-hide')
57
self.traybutton.connect('clicked', self.__tray_clicked_cb)
58
self.traybutton.props.sensitive = False
59
self.insert(self.traybutton, -1)
60
self.traybutton.show()
62
def __zoomin_clicked_cb(self, button):
63
self._browser.zoom_in()
65
def __zoomout_clicked_cb(self, button):
66
self._browser.zoom_out()
68
def __fullscreen_clicked_cb(self, button):
69
self._activity.fullscreen()
71
def __tray_clicked_cb(self, button):
72
if self._activity.tray.props.visible is False:
73
self._activity.tray.show()
75
self._activity.tray.hide()
77
def __map_cb(self, tray):
78
if len(self._activity.tray.get_children()) > 0:
81
def __unmap_cb(self, tray):
82
if len(self._activity.tray.get_children()) > 0:
85
def tray_set_show(self):
86
self.traybutton.set_icon('tray-show')
87
self.traybutton.set_tooltip(_('Show Tray'))
89
def tray_set_hide(self):
90
self.traybutton.set_icon('tray-hide')
91
self.traybutton.set_tooltip(_('Hide Tray'))