Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/classroomkit.py
blob: e8c7e0d14b2d9f6a2348928df0d88e55e24b6845 (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
# 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,

# 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import logging
import gtk

from sugar.activity import activity
from sugar.activity.activity import ActivityToolbox
from sugar.presence import presenceservice

from broadcast import Broadcast
from viewer import Viewer
from utilities import Utilities

# Telepathy service setup
SERVICE = 'org.sugarlabs.ClassroomKit'
IFACE = SERVICE
PATH = '/org/sugarlabs/ClassroomKit'

class ClassroomKitActivity(activity.Activity):
    """Classroom Kit Activity
    """

    # Broadcast Component
    _broadcast = None

    # Viewer Component
    _viewer = None

    # UI
    _toolbar = None

    # Utilities
    _utilities = None

    def __init__(self, handle):
        """Constructor
        """
        # initialize activity
        activity.Activity.__init__(self, handle)

        # debug msg
        logging.debug("Starting Classroom Kit Activity")

        # UI
        self.loadUI()

        # Utilities
        self._utilities = Utilities()

        # Broadcast
        if not self._shared_activity:
            self._broadcast = Broadcast(self)
            self._broadcast.loadUI();
        # Viewer
        else:
            self._viewer = Viewer(self)
            self._viewer.loadUI();

        # Show UI
        self.showUI()

        # Show status
        if not self._shared_activity:
            self._broadcast.startBroadcast()
            self._broadcast.showStatus()
        else:
            self._viewer.startViewer(self._utilities.getNetworkDict())
            #self._viewer.showStatus()


    def loadUI(self):
        """Create and show UI
        """
        # Toolbar

        # Broadcast
        if not self._shared_activity:
            toolbox = ActivityToolbox(self)
            self._toolbar = toolbox.get_activity_toolbar()
            self.set_toolbox(toolbox)
        # Viewer
        else:
            # we do not have collaboration features
            # make the share option insensitive
            self.max_participants = 1

            toolbox = ActivityToolbox(self)
            self._toolbar = toolbox.get_activity_toolbar()

            self._toolbar.remove(self._toolbar.share)
            self._toolbar.share = None
            self._toolbar.remove(self._toolbar.keep)
            self._toolbar.keep = None
            self.set_toolbox(toolbox)


    def showUI(self):
        """Show UI elements
        """
        self.show_all()