Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-09-05 19:35:28 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-09-05 19:35:28 (GMT)
commit9eb9395e254c333f145bec52976c209b55db41f2 (patch)
tree36c09a1d7765f370ef38b1b6e1821d2d1c1959ab
parent8b57b1731373337a2901806d9a47348b30a75d44 (diff)
chased down spacing bug
-rw-r--r--sensor_toolbar.py44
-rw-r--r--sound_toolbar.py91
-rwxr-xr-xtoolbar_top.py7
3 files changed, 66 insertions, 76 deletions
diff --git a/sensor_toolbar.py b/sensor_toolbar.py
index 1be451c..3718e4d 100644
--- a/sensor_toolbar.py
+++ b/sensor_toolbar.py
@@ -26,7 +26,6 @@ from gettext import gettext as _
import config #This has all the globals
from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.combobox import ComboBox
from sugar.graphics.toolcombobox import ToolComboBox
from sugar import profile
@@ -49,7 +48,7 @@ class SensorToolbar(gtk.Toolbar):
self.string_for_textbox = ""
- self._LOG_SEPARATOR_DIST = 20
+ self._LOG_SEPARATOR_DIST = 5
self.wave = wave
self.ag = audiograb
@@ -76,14 +75,14 @@ class SensorToolbar(gtk.Toolbar):
'voltage')
######################################################
- ####################### invert #####################
+ ####################### invert #######################
self._invert = ToolButton('invert')
self.insert(self._invert, -1)
self._invert.show()
self._invert.set_tooltip(_('Invert'))
self._invert.connect('clicked', self._invert_control_cb)
self.wave.set_invert_state(False)
- ####################################################
+ ######################################################
for seperator_count_temp in range( 1, self._LOG_SEPARATOR_DIST):
separator = gtk.SeparatorToolItem()
@@ -91,19 +90,21 @@ class SensorToolbar(gtk.Toolbar):
self.insert(separator, -1)
self.loginterval_img = gtk.Image()
- self.loginterval_img.set_from_file(config.ICONS_DIR + '/sample_rate.svg')
+ self.loginterval_img.set_from_file(config.ICONS_DIR + \
+ '/sample_rate.svg')
self.loginterval_img_tool = gtk.ToolItem()
self.loginterval_img_tool.add(self.loginterval_img)
self.insert(self.loginterval_img_tool,-1)
self.loginterval_img.show()
self.loginterval_img_tool.show()
-
- #######################Logging Interval#####################
+ ################### Logging Interval ##################
self._loginterval_combo = ComboBox()
- self.interval = [_('1 second') , _('30 seconds'), _('5 minutes'), _('30 minutes')]
+ self.interval = [_('1 second') , _('30 seconds'), _('5 minutes'),\
+ _('30 minutes')]
- self._interval_changed_id = self._loginterval_combo.connect("changed", self.loginterval_control)
+ self._interval_changed_id = self._loginterval_combo.connect("changed",\
+ self.loginterval_control)
for i, s in enumerate(self.interval):
self._loginterval_combo.append_item(i, s, None)
@@ -114,16 +115,15 @@ class SensorToolbar(gtk.Toolbar):
self.insert(self._loginterval_tool,-1)
self._loginterval_tool.show()
self.logginginterval_status = '1second'
- ############################################################
+ ########################################################
- #######################Start Logging/Stop Logging#####################
+ ########### Start Logging/Stop Logging #################
self._record = ToolButton('media-record')
self.insert(self._record, -1)
self._record.show()
self._record.set_tooltip(_('Start Recording'))
self._record.connect('clicked', self.record_control)
- ######################################################################
-
+ ########################################################
def record_control(self, data=None):
"""Depending upon the selected interval, does either
@@ -137,11 +137,11 @@ class SensorToolbar(gtk.Toolbar):
Yscale = 0.0
interval = self.interval_convert()
username = profile.get_nick_name()
- self.ji.start_new_session(username, Xscale, Yscale, self.logginginterval_status)
+ self.ji.start_new_session(username, Xscale, Yscale,\
+ self.logginginterval_status)
self.ag.set_logging_params(True, interval, False)
config.LOGGING_IN_SESSION = True
self.logging_status = True
-
self._record.set_icon('media-playback-stop')
self._record.show()
self._record.set_tooltip(_('Stop Recording'))
@@ -152,15 +152,14 @@ class SensorToolbar(gtk.Toolbar):
self.ji.stop_session()
config.LOGGING_IN_SESSION = False
self.logging_status = False
-
self._record.set_icon('media-record')
self._record.show()
self._record.set_tooltip(_('Start Recording'))
-
def interval_convert(self):
"""Converts picture/1second/5seconds/1minute/5minutes to an integer
- which denotes the number of times the audiograb buffer must be called before a value is written.
+ which denotes the number of times the audiograb buffer must be called
+ before a value is written.
When set to 0, the whole of current buffer will be written"""
if self.logginginterval_status == '1second':
return 89
@@ -171,10 +170,7 @@ class SensorToolbar(gtk.Toolbar):
elif self.logginginterval_status == '30minute':
return 160000
-
-
def loginterval_control(self, combobox):
-
if (self._loginterval_combo.get_active() != -1):
if (self._loginterval_combo.get_active() == 0):
self.logginginterval_status = '1second'
@@ -185,8 +181,6 @@ class SensorToolbar(gtk.Toolbar):
if (self._loginterval_combo.get_active() == 3):
self.logginginterval_status = '30minute'
-
-
def set_resistance_voltage_mode(self, data=None, mode_to_set='resistance'):
if mode_to_set == 'resistance' and self.get_mode()=='voltage' :
self.set_mode('resistance')
@@ -196,7 +190,6 @@ class SensorToolbar(gtk.Toolbar):
self._voltage.show()
self._update_string_for_textbox()
return False
-
if mode_to_set == 'voltage' and self.get_mode()=='resistance' :
self.set_mode('voltage')
self._resistance.set_icon('bias-on')
@@ -231,7 +224,6 @@ class SensorToolbar(gtk.Toolbar):
else:
return 'error'
-
def set_mode(self, mode='resistance'):
if mode=='resistance':
self.ag.set_bias(True)
@@ -239,7 +231,6 @@ class SensorToolbar(gtk.Toolbar):
self.ag.set_bias(False)
return
-
def context_off(self):
self.ag.pause_grabbing()
@@ -253,7 +244,6 @@ class SensorToolbar(gtk.Toolbar):
self.ag.set_capture_gain(0)
self.ag.set_mic_boost(False)
-
def _update_string_for_textbox(self):
self.string_for_textbox = ""
self.string_for_textbox += (self._STR_BASIC + "\n")
diff --git a/sound_toolbar.py b/sound_toolbar.py
index 9ef94cf..6f82bc9 100644
--- a/sound_toolbar.py
+++ b/sound_toolbar.py
@@ -18,36 +18,30 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-import pygst
-pygst.require("0.10")
import pygtk
import gtk
-import os
-import gobject
from time import *
from gettext import gettext as _
import config #This has all the globals
-import audioop
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.combobox import ComboBox
from sugar.graphics.toolcombobox import ToolComboBox
-
+from sugar import profile
class SoundToolbar(gtk.Toolbar):
- def __init__(self, wave, audiograb, textbox, journal, activity):
+ def __init__(self, wave, audiograb, textbox, journal):
gtk.Toolbar.__init__(self)
- self.wave_copy = wave
- self.audiograb_copy = audiograb
+ self.wave = wave
+ self.ag = audiograb
self.textbox_copy = textbox
self.ji = journal
- self.activity = activity
- self._LOG_SEPARATOR_DIST = 10
+ self._LOG_SEPARATOR_DIST = 5
self._STR_BASIC = _("Sound ")
self._STR1 = _("Time Base ")
@@ -83,7 +77,7 @@ class SoundToolbar(gtk.Toolbar):
self._freq.connect('clicked', self._timefreq_control_cb, False)
####################################################
- #self.time_freq_state = self.wave_copy.get_fft_mode()
+ #self.time_freq_state = self.wave.get_fft_mode()
#self._time.set_active(not(self.time_freq_state))
#self._freq.set_active(self.time_freq_state)
@@ -175,8 +169,13 @@ class SoundToolbar(gtk.Toolbar):
"""Depending upon the selected interval, does either
a logging session, or just logs the current buffer"""
if config.LOGGING_IN_SESSION == False:
+ Xscale = (1.00/self.ag.get_sampling_rate())
+ Yscale = 0.0
interval = self.interval_convert()
- self.audiograb_copy.set_logging_params(True, interval, True)
+ username = profile.get_nick_name()
+ self.ji.start_new_session(username, Xscale, Yscale,\
+ self.logginginterval_status)
+ self.ag.set_logging_params(True, interval, True)
config.LOGGING_IN_SESSION = True
self.logging_status = True
self._record.set_icon('media-playback-stop')
@@ -191,7 +190,7 @@ class SoundToolbar(gtk.Toolbar):
self.logging_status = False
else:
if self.logging_status == True:
- self.audiograb_copy.set_logging_params(False)
+ self.ag.set_logging_params(False)
config.LOGGING_IN_SESSION = False
self.logging_status = False
self._record.set_icon('media-record')
@@ -228,29 +227,29 @@ class SoundToolbar(gtk.Toolbar):
self.logginginterval_status = '30minute'
def _pauseplay_control_cb(self, data=None):
- if self.audiograb_copy.get_freeze_the_display()==True:
- self.audiograb_copy.set_freeze_the_display(False)
+ if self.ag.get_freeze_the_display()==True:
+ self.ag.set_freeze_the_display(False)
self._pause.set_icon('media-playback-pause-insensitive')
self._pause.set_tooltip(_('Unfreeze the display'))
self._pause.show()
else:
- self.audiograb_copy.set_freeze_the_display(True)
+ self.ag.set_freeze_the_display(True)
self._pause.set_icon('media-playback-pause')
self._pause.set_tooltip(_('Freeze the display'))
self._pause.show()
return False
def _timefreq_control_cb(self, data=None, time_state=True):
- if time_state==True and self.wave_copy.get_fft_mode()==True:
- self.wave_copy.set_fft_mode(False)
+ if time_state==True and self.wave.get_fft_mode()==True:
+ self.wave.set_fft_mode(False)
self._time.set_icon('domain-time2')
self._freq.set_icon('domain-freq')
self._time.show()
self._freq.show()
self._update_string_for_textbox()
return False
- if time_state==False and self.wave_copy.get_fft_mode()==False:
- self.wave_copy.set_fft_mode(True)
+ if time_state==False and self.wave.get_fft_mode()==False:
+ self.wave.set_fft_mode(True)
self._time.set_icon('domain-time')
self._freq.set_icon('domain-freq2')
self._time.show()
@@ -261,27 +260,27 @@ class SoundToolbar(gtk.Toolbar):
def cb_page_sizef(self, get, data=None):
if(get.value>=10 and get.value<20):
self._freq_range.set_value(10)
- self.audiograb_copy.set_sampling_rate(4000)
- self.wave_copy.set_freq_range(1)
+ self.ag.set_sampling_rate(4000)
+ self.wave.set_freq_range(1)
if(get.value>=20 and get.value<46):
self._freq_range.set_value(30)
- self.audiograb_copy.set_sampling_rate(4000)
- self.wave_copy.set_freq_range(2)
+ self.ag.set_sampling_rate(4000)
+ self.wave.set_freq_range(2)
if(get.value>=46 and get.value<62):
self._freq_range.set_value(50)
- self.audiograb_copy.set_sampling_rate(16000)
- self.wave_copy.set_freq_range(3)
+ self.ag.set_sampling_rate(16000)
+ self.wave.set_freq_range(3)
if(get.value>=62 and get.value<=70):
self._freq_range.set_value(70)
- self.audiograb_copy.set_sampling_rate(48000)
- self.wave_copy.set_freq_range(4)
+ self.ag.set_sampling_rate(48000)
+ self.wave.set_freq_range(4)
self._update_string_for_textbox()
return True
def calculate_x_axis_scale(self):
- sampling_rate = self.audiograb_copy.get_sampling_rate()
- draw_interval = self.wave_copy.get_drawing_interval()
- if self.wave_copy.get_fft_mode() == False:
+ sampling_rate = self.ag.get_sampling_rate()
+ draw_interval = self.wave.get_drawing_interval()
+ if self.wave.get_fft_mode() == False:
scale = (50000.0/sampling_rate)/draw_interval
#TODO: fix this [:4] bad bad hack!
self._STR_SCALEX = self._STR_XAXIS1 + str(scale)[:4] + \
@@ -297,32 +296,32 @@ class SoundToolbar(gtk.Toolbar):
def context_off(self):
"""When some other context is switched to and the sound context
is switched off"""
- self.g, self.y_mag = self.wave_copy.get_mag_params()
- self.capture_gain = self.audiograb_copy.get_capture_gain()
- self.mic_boost = self.audiograb_copy.get_mic_boost()
- self.audiograb_copy.stop_sound_device()
- self.wave_copy.set_fft_mode(False)
+ self.g, self.y_mag = self.wave.get_mag_params()
+ self.capture_gain = self.ag.get_capture_gain()
+ self.mic_boost = self.ag.get_mic_boost()
+ self.ag.stop_sound_device()
+ self.wave.set_fft_mode(False)
def context_on(self):
"""When the sound context is switched on"""
- self.audiograb_copy.start_sound_device()
- self.audiograb_copy.set_dc_mode(False)
- self.audiograb_copy.set_bias(True)
- self.audiograb_copy.set_capture_gain(self.capture_gain)
- self.audiograb_copy.set_mic_boost(self.mic_boost)
- self.wave_copy.set_fft_mode(False)
- self.wave_copy.set_mag_params(self.g, self.y_mag)
+ self.ag.start_sound_device()
+ self.ag.set_dc_mode(False)
+ self.ag.set_bias(True)
+ self.ag.set_capture_gain(self.capture_gain)
+ self.ag.set_mic_boost(self.mic_boost)
+ self.wave.set_fft_mode(False)
+ self.wave.set_mag_params(self.g, self.y_mag)
self._update_string_for_textbox()
def _update_string_for_textbox(self):
self.calculate_x_axis_scale()
self.string_for_textbox = ""
self.string_for_textbox += (self._STR_BASIC + "\t")
- if self.wave_copy.get_fft_mode() == False:
+ if self.wave.get_fft_mode() == False:
self.string_for_textbox += self._STR1
else:
self.string_for_textbox += self._STR2
- if self.wave_copy.get_invert_state()==True:
+ if self.wave.get_invert_state()==True:
self.string_for_textbox += self._STR3
self.string_for_textbox += ("\n" + self._STR_SCALEX)
self.textbox_copy.set_data_params(0, self.string_for_textbox)
diff --git a/toolbar_top.py b/toolbar_top.py
index fa17fdc..2a65364 100755
--- a/toolbar_top.py
+++ b/toolbar_top.py
@@ -1,7 +1,8 @@
#! /usr/bin/python
#
# Author: Arjun Sarwal arjun@laptop.org
-# Copyright (C) 2007, OLPC
+# Copyright (C) 2007, Arjun Sarwal
+# Copyright (C) 2009, Walter Bender
#
#
# This program is free software; you can redistribute it and/or modify
@@ -28,7 +29,7 @@ from sugar.activity.activity import ActivityToolbox
from sound_toolbar import SoundToolbar
from sensor_toolbar import SensorToolbar
-from logging_ui import LogToolbar
+# from logging_ui import LogToolbar
from gettext import gettext as _
class Toolbar(ActivityToolbox):
@@ -40,7 +41,7 @@ class Toolbar(ActivityToolbox):
self._SOUND_TOOLBAR = 1
self._SENSOR_TOOLBAR = 2
- self._sound_toolbar = SoundToolbar(wave, audiograb, textbox, journal, activity)
+ self._sound_toolbar = SoundToolbar(wave, audiograb, textbox, journal)
self.add_toolbar(_('Sound'), self._sound_toolbar)
self._sound_toolbar.show()