~ubuntu-branches/ubuntu/karmic/sugar-web-activity/karmic

« back to all changes in this revision

Viewing changes to Web.activity/viewtoolbar.py

  • Committer: Bazaar Package Importer
  • Author(s): Jani Monoses
  • Date: 2008-01-31 15:17:08 UTC
  • Revision ID: james.westby@ubuntu.com-20080131151708-4tegqfae3vdhiylk
Tags: upstream-85
ImportĀ upstreamĀ versionĀ 85

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007, One Laptop Per Child
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
 
 
17
from gettext import gettext as _
 
18
 
 
19
import gtk
 
20
 
 
21
from sugar.graphics.toolbutton import ToolButton
 
22
 
 
23
class ViewToolbar(gtk.Toolbar):
 
24
    def __init__(self, activity):
 
25
        gtk.Toolbar.__init__(self)
 
26
 
 
27
        self._activity = activity        
 
28
        self._activity.tray.connect('unmap', self.__unmap_cb)
 
29
        self._activity.tray.connect('map', self.__map_cb)
 
30
 
 
31
        self._browser = self._activity._browser
 
32
                
 
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)
 
37
        self.zoomout.show()
 
38
 
 
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)
 
43
        self.zoomin.show()
 
44
 
 
45
        self.separator = gtk.SeparatorToolItem()
 
46
        self.separator.set_draw(True)
 
47
        self.insert(self.separator, -1)
 
48
        self.separator.show()
 
49
 
 
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()
 
55
 
 
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()
 
61
                
 
62
    def __zoomin_clicked_cb(self, button):
 
63
        self._browser.zoom_in()
 
64
        
 
65
    def __zoomout_clicked_cb(self, button):
 
66
        self._browser.zoom_out()
 
67
                
 
68
    def __fullscreen_clicked_cb(self, button):
 
69
        self._activity.fullscreen()
 
70
 
 
71
    def __tray_clicked_cb(self, button):        
 
72
        if self._activity.tray.props.visible is False:
 
73
            self._activity.tray.show()
 
74
        else:
 
75
            self._activity.tray.hide()
 
76
 
 
77
    def __map_cb(self, tray):
 
78
        if len(self._activity.tray.get_children()) > 0:
 
79
            self.tray_set_hide()
 
80
            
 
81
    def __unmap_cb(self, tray):
 
82
        if len(self._activity.tray.get_children()) > 0:
 
83
            self.tray_set_show()
 
84
        
 
85
    def tray_set_show(self):     
 
86
        self.traybutton.set_icon('tray-show')
 
87
        self.traybutton.set_tooltip(_('Show Tray'))
 
88
        
 
89
    def tray_set_hide(self):
 
90
        self.traybutton.set_icon('tray-hide')
 
91
        self.traybutton.set_tooltip(_('Hide Tray'))
 
92