Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/memosonoactivity.py
blob: 1998cdf2db9e177a784f0d145bd224562b07c69b (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#! /usr/bin/env python
#
#    Copyright (C) 2006 Simon Schampijer
#
#    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.
#

from gettext import gettext as _

import gobject
import gtk, pygtk
import os
import socket
import logging
import random
import copy
import time
import errno
import gc

from sugar.activity.activity import Activity
from sugar.activity.activity import ActivityToolbox

from toolbar import ImageToolbar

from osc.oscapi import OscApi
from csound.csoundserver import CsoundServer
from gameselectview import GameSelectView

class MemosonoActivity(Activity):
    def __init__(self, handle):
        Activity.__init__(self, handle)
        self.set_title ("Memosono")

        toolbox = ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()
        #toolbox._notebook.connect('select-page', self._select_page)
        toolbox._notebook.connect('switch-page', self._switch_page)
        
        self.image_toolbar = ImageToolbar(toolbox)        
        toolbox.add_toolbar(_('Play'), self.image_toolbar)
        self.image_toolbar.show()

        self.gs = GameSelectView(['drumgit','summer'])
        self.gs.connect('entry-selected', self._entry_selected_cb)
        self.set_canvas(self.gs)
        self.gs.show()

        self.play = GameSelectView(['play', 'play'])
        
        '''
        # create our main abiword canvas
        self.abiword_canvas = Canvas()
        self.abiword_canvas.connect("can-undo", self._can_undo_cb)
        self.abiword_canvas.connect("can-redo", self._can_redo_cb)
        self.abiword_canvas.connect('text-selected', self._selection_cb)
        self.abiword_canvas.connect('image-selected', self._selection_cb)
        self.abiword_canvas.connect('selection-cleared', self._selection_cleared_cb)

        self._edit_toolbar = EditToolbar()

        self._edit_toolbar.undo.set_sensitive(False)
        self._edit_toolbar.undo.connect('clicked', self._undo_cb)

        self._edit_toolbar.redo.set_sensitive(False)
        self._edit_toolbar.redo.connect('clicked', self._redo_cb)

        self._edit_toolbar.copy.connect('clicked', self._copy_cb)
        self._edit_toolbar.paste.connect('clicked', self._paste_cb)

        toolbox.add_toolbar(_('Edit'), self._edit_toolbar)
        self._edit_toolbar.show()

        text_toolbar = TextToolbar(toolbox, self.abiword_canvas)
        toolbox.add_toolbar(_('Text'), text_toolbar)
        text_toolbar.show()

        image_toolbar = ImageToolbar(toolbox, self.abiword_canvas)
        toolbox.add_toolbar(_('Image'), image_toolbar)
        image_toolbar.show()

        table_toolbar = TableToolbar(toolbox, self.abiword_canvas)
        toolbox.add_toolbar(_('Table'), table_toolbar)
        table_toolbar.show()

        view_toolbar = ViewToolbar(self.abiword_canvas)
        toolbox.add_toolbar(_('View'), view_toolbar)
        view_toolbar.show()

        self.set_canvas(self.abiword_canvas)
        self.abiword_canvas.show()

        self.abiword_canvas.connect_after('map', self._map_cb)
        '''

    def _entry_selected_cb(self, list_view, entry):
        self.set_canvas(self.play)
        self.play.show()

        #def _select_page(self, notebook, move_focus, user_param1 ):
        #print '+++++ select page'
        
    def _switch_page(self, notebook, page, page_num, user_param1=None):
        
        print '+++++ switch page %s'%str(page_num)
        
     # def get_nth_page(page_num)
     # page_num :	the index of a page in the notebook
     # Returns :	the child widget, or None if page_num is out of bounds.
     
    def _cleanup_cb(self, data=None):
        pass
        #self.controler.oscapi.send(('127.0.0.1', 6783), "/CSOUND/quit", [])
        #self.controler.oscapi.iosock.close()
        #self.server.oscapi.iosock.close()
        #logging.debug(" Closed OSC sockets ")
        
    def _focus_in(self, event, data=None):
        pass
        #logging.debug(" Memosono is visible: Connect to the Csound-Server. ")
        #self.controler.oscapi.send(('127.0.0.1', 6783), "/CSOUND/connect", [])
        
    def _focus_out(self, event, data=None):
        pass
        #logging.debug(" Memosono is invisible: Close the connection to the Csound-Server. ")
        #self.controler.oscapi.send(('127.0.0.1', 6783), "/CSOUND/disconnect", [])