def __init__(self, handle): # !!!!!! initialize threading in gtk !!!!! # ! this is important for the networking ! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! gtk.gdk.threads_init() activity.Activity.__init__(self, handle) for snd in ['mic1', 'mic2', 'mic3', 'mic4']: if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): shutil.copyfile(Config.SOUNDS_DIR + '/' + snd, Config.DATA_DIR + '/' + snd) os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Jam') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.trackpad.setContext('jam') self.jam = JamMain(self) self.connect('key-press-event', self.jam.onKeyPress) self.connect('key-release-event', self.jam.onKeyRelease) #self.modeList[mode].regenerate() self.set_canvas(self.jam) self.jam.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) # for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']: # if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): # shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd) # os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') #color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) #self.modify_bg(gtk.STATE_NORMAL, color) self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.activity_toolbar = self.toolbox.get_activity_toolbar() self.toolbox.show() self.trackpad.setContext('edit') self.edit = MainWindow(self) self.connect('key-press-event', self.edit.onKeyPress) self.connect('key-release-event', self.edit.onKeyRelease) #self.modeList[mode].regenerate() self.set_canvas(self.edit) self.edit.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.set_toolbar_box(self.toolbox) else: self.activity_toolbar.share.hide() self.show()
def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Mini') self.set_resizable(False) self.trackpad = Trackpad(self) self.trackpad.setContext('mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityButton(self), -1) self.toolbox.toolbar.insert(widgets.TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: logging.debug('DescriptionItem button is not available,' + 'toolkit version < 0.96') else: description_item = DescriptionItem(self) self.toolbox.toolbar.insert(description_item, -1) description_item.show() self.toolbox.toolbar.insert(widgets.ShareButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() #self.modeList[mode].regenerate() self.set_canvas(self.mini) self.mini.instrumentPanel.grab_focus() if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam SynthLab') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) # no sharing self.activity_toolbar = self.toolbox.get_activity_toolbar() self.activity_toolbar.share.hide() self.activity_toolbar.keep.hide() self.toolbox.show() self.trackpad.setContext('synthLab') self.synthLab = SynthLabMain(self) self.connect('key-press-event', self.synthLab.onKeyPress) self.connect('key-release-event', self.synthLab.onKeyRelease) self.connect("key-press-event", self.synthLab.onKeyPress) self.connect("key-release-event", self.synthLab.onKeyRelease) self.set_canvas(self.synthLab) self.synthLab.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show()
def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) #color = Gdk.color_parse(Config.WS_BCK_COLOR) #self.modify_bg(Gtk.StateType.NORMAL, color) self.set_title('TamTam Mini') self.set_resizable(False) self.trackpad = Trackpad(self) self.trackpad.setContext('mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar toolbox = ToolbarBox() toolbox.toolbar.insert(widgets.ActivityButton(self), -1) toolbox.toolbar.insert(widgets.TitleEntry(self), -1) description_item = DescriptionItem(self) toolbox.toolbar.insert(description_item, -1) description_item.show() toolbox.toolbar.insert(widgets.ShareButton(self), -1) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) toolbox.toolbar.insert(widgets.StopButton(self), -1) toolbox.toolbar.show_all() toolbox.show() self.set_toolbar_box(toolbox) self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() #self.modeList[mode].regenerate() self.set_canvas(self.mini) self.mini.instrumentPanel.grab_focus() self.set_size_request(Gdk.Screen.width(), Gdk.Screen.height()) self.show() logging.error('Activity startup end')
def __init__(self, handle): activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam SynthLab') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) # no sharing self.activity_toolbar = self.toolbox.get_activity_toolbar() self.activity_toolbar.share.hide() self.activity_toolbar.keep.hide() self.toolbox.show() self.trackpad.setContext('synthLab') self.synthLab = SynthLabMain(self) self.connect('key-press-event', self.synthLab .onKeyPress) self.connect('key-release-event', self.synthLab .onKeyRelease) self.connect("key-press-event", self.synthLab.onKeyPress) self.connect("key-release-event", self.synthLab.onKeyRelease) self.set_canvas(self.synthLab) self.synthLab.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show()
def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Mini') self.trackpad = Trackpad(self) self.trackpad.setContext('mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityButton(self), -1) self.toolbox.toolbar.insert(widgets.TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: logging.debug('DescriptionItem button is not available,' + 'toolkit version < 0.96') else: description_item = DescriptionItem(self) self.toolbox.toolbar.insert(description_item, -1) description_item.show() self.toolbox.toolbar.insert(widgets.ShareButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() #self.modeList[mode].regenerate() self.set_canvas(self.mini) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show()
def __init__(self, handle): # !!!!!! initialize threading in gtk !!!!! # ! this is important for the networking ! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Gdk.threads_init() activity.Activity.__init__(self, handle) for snd in ["mic1", "mic2", "mic3", "mic4"]: if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): shutil.copyfile(Config.SOUNDS_DIR + "/" + snd, Config.DATA_DIR + "/" + snd) os.system("chmod 0777 " + Config.DATA_DIR + "/" + snd + " &") color = Gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(Gtk.StateType.NORMAL, color) self.set_title("TamTam Jam") self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect("notify::active", self.onActive) self.connect("destroy", self.onDestroy) toolbox = ToolbarBox() toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) toolbox.toolbar.insert(Gtk.SeparatorToolItem(), -1) self.trackpad.setContext("jam") self.set_toolbar_box(toolbox) self.jam = JamMain(self) self.connect("key-press-event", self.jam.onKeyPress) self.connect("key-release-event", self.jam.onKeyRelease) # self.modeList[mode].regenerate() self.jam.onActivate(arg=None) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) toolbox.toolbar.insert(widgets.StopButton(self), -1) toolbox.toolbar.show_all() self.set_canvas(self.jam) self.show_all()
class TamTamEdit(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) # for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']: # if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): # shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd) # os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') #color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) #self.modify_bg(gtk.STATE_NORMAL, color) self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.activity_toolbar = self.toolbox.get_activity_toolbar() self.toolbox.show() self.trackpad.setContext('edit') self.edit = MainWindow(self) self.connect('key-press-event', self.edit.onKeyPress) self.connect('key-release-event', self.edit.onKeyRelease) #self.modeList[mode].regenerate() self.set_canvas(self.edit) self.edit.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.set_toolbar_box(self.toolbox) else: self.activity_toolbar.share.hide() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.edit.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() Gtk.main_quit() # No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamSynthLab(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam SynthLab') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) # no sharing self.activity_toolbar = self.toolbox.get_activity_toolbar() self.activity_toolbar.share.hide() self.activity_toolbar.keep.hide() self.toolbox.show() self.trackpad.setContext('synthLab') self.synthLab = SynthLabMain(self) self.connect('key-press-event', self.synthLab .onKeyPress) self.connect('key-release-event', self.synthLab .onKeyRelease) self.connect("key-press-event", self.synthLab.onKeyPress) self.connect("key-release-event", self.synthLab.onKeyRelease) self.set_canvas(self.synthLab) self.synthLab.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: logging.debug('TamTamSynthLab.onActivate disconnecting csound') csnd = new_csound_client() csnd.connect(False) else: logging.debug('TamTamSynthLab.onActivate connecting csound') csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.synthLab.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamJam(activity.Activity): def __init__(self, handle): # !!!!!! initialize threading in gtk !!!!! # ! this is important for the networking ! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! gtk.gdk.threads_init() activity.Activity.__init__(self, handle) for snd in ['mic1', 'mic2', 'mic3', 'mic4']: if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): shutil.copyfile(Config.SOUNDS_DIR + '/' + snd, Config.DATA_DIR + '/' + snd) os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Jam') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.trackpad.setContext('jam') self.jam = JamMain(self) self.connect('key-press-event', self.jam.onKeyPress) self.connect('key-release-event', self.jam.onKeyRelease) #self.modeList[mode].regenerate() self.set_canvas(self.jam) self.jam.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: logging.debug('Jam.onActivate disconnecting csound') csnd = new_csound_client() csnd.connect(False) else: logging.debug('Jam.onActivate connecting csound') csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.jam.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamSynthLab(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam SynthLab') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) # no sharing self.activity_toolbar = self.toolbox.get_activity_toolbar() self.activity_toolbar.share.hide() self.activity_toolbar.keep.hide() self.toolbox.show() self.trackpad.setContext('synthLab') self.synthLab = SynthLabMain(self) self.connect('key-press-event', self.synthLab.onKeyPress) self.connect('key-release-event', self.synthLab.onKeyRelease) self.connect("key-press-event", self.synthLab.onKeyPress) self.connect("key-release-event", self.synthLab.onKeyRelease) self.set_canvas(self.synthLab) self.synthLab.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: logging.debug('TamTamSynthLab.onActivate disconnecting csound') csnd = new_csound_client() csnd.connect(False) else: logging.debug('TamTamSynthLab.onActivate connecting csound') csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.synthLab.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamMini(activity.Activity): __gtype_name__ = 'TamTamMiniWindow' def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) #color = Gdk.color_parse(Config.WS_BCK_COLOR) #self.modify_bg(Gtk.StateType.NORMAL, color) self.set_title('TamTam Mini') self.set_resizable(False) self.trackpad = Trackpad(self) self.trackpad.setContext('mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar toolbox = ToolbarBox() toolbox.toolbar.insert(widgets.ActivityButton(self), -1) toolbox.toolbar.insert(widgets.TitleEntry(self), -1) description_item = DescriptionItem(self) toolbox.toolbar.insert(description_item, -1) description_item.show() toolbox.toolbar.insert(widgets.ShareButton(self), -1) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) toolbox.toolbar.insert(widgets.StopButton(self), -1) toolbox.toolbar.show_all() toolbox.show() self.set_toolbar_box(toolbox) self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() #self.modeList[mode].regenerate() self.set_canvas(self.mini) self.mini.instrumentPanel.grab_focus() self.set_size_request(Gdk.Screen.width(), Gdk.Screen.height()) self.show() logging.error('Activity startup end') def do_size_allocate(self, allocation): activity.Activity.do_size_allocate(self, allocation) if self.mini is not None: logging.error('TamTamMini size alloc %s', (allocation.x, allocation.y, allocation.width, allocation.height)) self.mini.updateInstrumentPanel() def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.mini.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() Gtk.main_quit() # no more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
def __init__(self, activity): gtk.EventBox.__init__(self) self.instrumentPanel = None self.activity = activity #self.set_border_width(Config.MAIN_WINDOW_PADDING) #self.set_border_width(0) self.instrumentDB = InstrumentDB.getRef() self.firstTime = False self.playing = False self.csnd = new_csound_client() self.timeout_ms = 50 self.instVolume = 50 self.drumVolume = 0.5 self.instrument = 'sarangi' self.regularity = 0.75 self.beat = 4 self.reverb = 0.1 self.tempo = Config.PLAYER_TEMPO self.beatDuration = 60.0 / self.tempo self.ticksPerSecond = Config.TICKS_PER_BEAT * self.tempo / 60.0 self.rythmInstrument = 'drum1kit' self.csnd.load_drumkit(self.rythmInstrument) self.muteInst = False self.drumFillin = Fillin(self.beat, self.tempo, self.rythmInstrument, self.reverb, self.drumVolume) self.sequencer = MiniSequencer(self.recordStateButton, self.recordOverSensitivity) self.loop = Loop(self.beat, sqrt(self.instVolume * 0.01)) self.csnd.setTempo(self.tempo) self.noteList = [] time.sleep(0.001) # why? self.trackpad = Trackpad(self) for i in range(21): self.csnd.setTrackVolume(100, i) for i in range(10): r = str(i + 1) self.csnd.load_instrument('guidice' + r) self.volume = 100 self.csnd.setMasterVolume(self.volume) self.sequencer.beat = self.beat self.loop.beat = self.beat self.tooltips = gtk.Tooltips() self.mainWindowBox = gtk.HBox() self.leftBox = gtk.VBox() self.rightBox = gtk.VBox() self.mainWindowBox.pack_start(self.rightBox, False, True) self.mainWindowBox.pack_start(self.leftBox, True, True) self.add(self.mainWindowBox) self.enableKeyboard() self.setInstrument(self.instrument) self.connect('key-press-event', self.onKeyPress) self.connect('key-release-event', self.onKeyRelease) self.drawGeneration() self.show_all() if 'a good idea' == True: self.playStartupSound() self.beatPickup = True #self.regenerate() self.heartbeatStart = time.time() self.syncQueryStart = {} self.syncTimeout = None self.network = Net.Network() self.network.addWatcher(self.networkStatusWatcher) self.network.connectMessage(Net.HT_SYNC_REPLY, self.processHT_SYNC_REPLY) self.network.connectMessage(Net.HT_TEMPO_UPDATE, self.processHT_TEMPO_UPDATE) self.network.connectMessage(Net.PR_SYNC_QUERY, self.processPR_SYNC_QUERY) self.network.connectMessage(Net.PR_TEMPO_QUERY, self.processPR_TEMPO_QUERY) self.network.connectMessage(Net.PR_REQUEST_TEMPO_CHANGE, self.processPR_REQUEST_TEMPO_CHANGE) # data packing classes self.packer = xdrlib.Packer() self.unpacker = xdrlib.Unpacker("") #-- handle forced networking --------------------------------------- if self.network.isHost(): self.updateSync() self.syncTimeout = gobject.timeout_add(1000, self.updateSync) elif self.network.isPeer(): self.sendTempoQuery() self.syncTimeout = gobject.timeout_add(1000, self.updateSync) #------------------------------------------------------------------- # Toolbar if Config.HAVE_TOOLBOX: from sugar.graphics.toolbarbox import ToolbarButton # no sharing # self.max_participants = 1 self._playToolbar = playToolbar(self) ## Uncomment to show play and record tabs ## ''' play_toolbar_button = ToolbarButton(label=_('Play'), page=self._playToolbar, # Fixme: need an icon icon_name='activity-start') self._playToolbar.show() play_toolbar_button.show() self.activity.toolbox.toolbar.insert(play_toolbar_button, -1) self._recordToolbar = recordToolbar(self) record_toolbar_button = ToolbarButton(label=_('Record'), page=self._recordToolbar, # Fixme: need an icon icon_name='media-record') self._recordToolbar.show() record_toolbar_button.show() self.activity.toolbox.toolbar.insert(record_toolbar_button, -1) ''' else: self._playToolbar = playToolbar(self) ## set to 1 to show play and record tabs ## if 0: self._recordToolbar = recordToolbar(self) self.activity.toolbox.add_toolbar(_('Play'), self._playToolbar) self.activity.toolbox.add_toolbar(_('Record'), self._recordToolbar) self.activity.toolbox.set_current_toolbar(1) self._playToolbar.show() self._recordToolbar.show() if not Config.HAVE_TOOLBOX: self.activity.connect("shared", self.shared) if os.path.isfile("FORCE_SHARE"): # HOST r = random.random() #print "::::: Sharing as TTDBG%f :::::" % r #self.activity.set_title(_("TTDBG%f" % r)) print "::::: Sharing as TamTam :::::" self.activity.set_title(_("TamTam")) self.activity.share() elif self.activity._shared_activity: # PEER self.activity._shared_activity.connect("buddy-joined", self.buddy_joined) self.activity._shared_activity.connect("buddy-left", self.buddy_left) self.activity.connect("joined", self.joined) self.network.setMode(Net.MD_WAIT)
class TamTamJam(activity.Activity): def __init__(self, handle): # !!!!!! initialize threading in gtk !!!!! # ! this is important for the networking ! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Gdk.threads_init() activity.Activity.__init__(self, handle) for snd in ["mic1", "mic2", "mic3", "mic4"]: if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): shutil.copyfile(Config.SOUNDS_DIR + "/" + snd, Config.DATA_DIR + "/" + snd) os.system("chmod 0777 " + Config.DATA_DIR + "/" + snd + " &") color = Gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(Gtk.StateType.NORMAL, color) self.set_title("TamTam Jam") self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect("notify::active", self.onActive) self.connect("destroy", self.onDestroy) toolbox = ToolbarBox() toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) toolbox.toolbar.insert(Gtk.SeparatorToolItem(), -1) self.trackpad.setContext("jam") self.set_toolbar_box(toolbox) self.jam = JamMain(self) self.connect("key-press-event", self.jam.onKeyPress) self.connect("key-release-event", self.jam.onKeyRelease) # self.modeList[mode].regenerate() self.jam.onActivate(arg=None) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) toolbox.toolbar.insert(widgets.StopButton(self), -1) toolbox.toolbar.show_all() self.set_canvas(self.jam) self.show_all() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: logging.debug("Jam.onActivate disconnecting csound") csnd = new_csound_client() csnd.connect(False) else: logging.debug("Jam.onActivate connecting csound") csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print "DEBUG: TamTam::onDestroy()" self.jam.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() Gtk.main_quit() def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamMini(activity.Activity): __gtype_name__ = 'TamTamMiniWindow' def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Mini') self.set_resizable(False) self.trackpad = Trackpad(self) self.trackpad.setContext('mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityButton(self), -1) self.toolbox.toolbar.insert(widgets.TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: logging.debug('DescriptionItem button is not available,' + 'toolkit version < 0.96') else: description_item = DescriptionItem(self) self.toolbox.toolbar.insert(description_item, -1) description_item.show() self.toolbox.toolbar.insert(widgets.ShareButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() #self.modeList[mode].regenerate() self.set_canvas(self.mini) self.mini.instrumentPanel.grab_focus() if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def do_size_allocate(self, allocation): activity.Activity.do_size_allocate(self, allocation) if self.mini is not None: self.mini.updateInstrumentPanel() def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.mini.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # no more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamMini(activity.Activity): __gtype_name__ = 'TamTamMiniWindow' def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Mini') self.trackpad = Trackpad(self) self.trackpad.setContext('mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityButton(self), -1) self.toolbox.toolbar.insert(widgets.TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: logging.debug('DescriptionItem button is not available,' + 'toolkit version < 0.96') else: description_item = DescriptionItem(self) self.toolbox.toolbar.insert(description_item, -1) description_item.show() self.toolbox.toolbar.insert(widgets.ShareButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() #self.modeList[mode].regenerate() self.set_canvas(self.mini) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def do_size_allocate(self, allocation): activity.Activity.do_size_allocate(self, allocation) if self.mini is not None: self.mini.updateInstrumentPanel() def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.mini.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # no more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamEdit(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) # for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']: # if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): # shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd) # os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.activity_toolbar = self.toolbox.get_activity_toolbar() self.toolbox.show() self.trackpad.setContext('edit') self.edit = MainWindow(self) self.connect('key-press-event', self.edit.onKeyPress) self.connect('key-release-event', self.edit.onKeyRelease) #self.modeList[mode].regenerate() self.set_canvas(self.edit) self.edit.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() else: self.activity_toolbar.share.hide() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.edit.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):