Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/toolbar_top.py
blob: 2a653646b2c2e8a274a49151c13b455c8df0a2be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /usr/bin/python
#
#    Author:  Arjun Sarwal   arjun@laptop.org
#    Copyright (C) 2007, Arjun Sarwal
#    Copyright (C) 2009, Walter Bender
#    
#    	
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import pygtk
import gtk
import time

import config

from sugar.activity.activity import ActivityToolbox

from sound_toolbar import SoundToolbar
from sensor_toolbar import SensorToolbar
# from logging_ui import LogToolbar
from gettext import gettext as _

class Toolbar(ActivityToolbox):

    def __init__(self, activity, wave, audiograb, journal, textbox):

        ActivityToolbox.__init__(self, activity)

        self._SOUND_TOOLBAR = 1
        self._SENSOR_TOOLBAR = 2

        self._sound_toolbar = SoundToolbar(wave, audiograb, textbox, journal)
        self.add_toolbar(_('Sound'), self._sound_toolbar)
        self._sound_toolbar.show()

        self._sensors_toolbar = SensorToolbar(wave, audiograb, textbox, journal)
        self.add_toolbar(_('Sensors'), self._sensors_toolbar)
        self._sensors_toolbar.show()

        """
        self._camera_toolbar = CameraToolbar(activity, camera_ui)
        self.add_toolbar('Camera', self._camera_toolbar)
        self._camera_toolbar.show()

        self._wifi_toolbar = MeasureToolbar(wave, audiograb)
        self.add_toolbar('Wireless', self._wifi_toolbar)
        self._wifi_toolbar.show()

        self._log_toolbar = LogToolbar(audiograb, journal, activity)
        self.add_toolbar('Log View', self._log_toolbar)
        self._log_toolbar.show()
        """

        self.connect("current-toolbar-changed", self._toolbar_changed_cb)
        self.wave = wave
        self.activity = activity
        self.toolbar_active_id = 1
        self.set_current_toolbar(self._SOUND_TOOLBAR)


    def _toolbar_changed_cb(self, tbox, num):
        if num==0:                              #Activity
	        pass

        elif num==self._SOUND_TOOLBAR:                           #Sound
            self.activity.set_show_hide_windows(self._SOUND_TOOLBAR)
            self._sensors_toolbar.context_off()
            time.sleep(0.5)
            self._sound_toolbar.context_on()
            config.CONTEXT = self._SOUND_TOOLBAR

        elif num==self._SENSOR_TOOLBAR:                            #Sensor
            self._sound_toolbar.context_off()
            time.sleep(0.5)
            self._sensors_toolbar.context_on()
            self.activity.set_show_hide_windows(self._SENSOR_TOOLBAR)
            config.CONTEXT = self._SENSOR_TOOLBAR

        self.toolbar_active_id = num
        """
        elif num==3:                            #Camera
	        self.activity.set_show_hide_windows(1)
	        self._sound_toolbar.context_off()
	        self.wave.set_context_off()
	        time.sleep(0.5)
	        self._camera_toolbar.set_context_on()
        elif num==4:        
	        self.wave.set_context_off()
	        self._sound_toolbar.context_off()
	        self._camera_toolbar.set_context_off()
	        time.sleep(0.5)
        elif num==5:
	        self.wave.set_context_off() 
	        self._sound_toolbar.context_off()
	        self._camera_toolbar.set_context_off()
	        time.sleep(0.5)
        """
        return True


    def get_which_toolbar_active(self):
        """Returns which toolbar is active
        Activity toolbar - 1
        Sound toolbar 	 - 2
        Sensors toolbar  - 3
        """
        return self.toolbar_active_id