[tuxdroid-svn] r821 - in software/gadgets/flash_management/trunk: . flash_management flash_manageme
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-01-04 11:30:32
|
Author: Paul_R Date: 2008-01-04 12:30:15 +0100 (Fri, 04 Jan 2008) New Revision: 821 Modified: software/gadgets/flash_management/trunk/flash_management.tgf software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.glade software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.pyp software/gadgets/flash_management/trunk/flash_management/Strings/fr_ALL.xml software/gadgets/flash_management/trunk/flash_management/strings.xml Log: * Added a protection to be sure that the wavs files are in a 8k/8bits format * Added a protection to stop the transfert when the dongle is disconnected, or the RF connection is lost. When the connection is lost, aplay is killed with 'pkill' Modified: software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.glade =================================================================== --- software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.glade 2008-01-04 09:05:29 UTC (rev 820) +++ software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.glade 2008-01-04 11:30:15 UTC (rev 821) @@ -777,32 +777,6 @@ </child> <child> - <widget class="GtkLabel" id="lblSoundState"> - <property name="width_request">216</property> - <property name="height_request">18</property> - <property name="visible">True</property> - <property name="label" translatable="yes">label3</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="x">24</property> - <property name="y">168</property> - </packing> - </child> - - <child> <widget class="GtkButton" id="btnSoundAdd"> <property name="width_request">72</property> <property name="height_request">27</property> @@ -855,6 +829,32 @@ <property name="y">82</property> </packing> </child> + + <child> + <widget class="GtkLabel" id="lblSoundState"> + <property name="width_request">216</property> + <property name="height_request">41</property> + <property name="visible">True</property> + <property name="label" translatable="yes">label3</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="x">24</property> + <property name="y">168</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> Modified: software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.pyp 2008-01-04 09:05:29 UTC (rev 820) +++ software/gadgets/flash_management/trunk/flash_management/Scripts/Python/GUI/widget/other.pyp 2008-01-04 11:30:15 UTC (rev 821) @@ -7,6 +7,7 @@ import commands import time import threading +import wave class Window(SimpleGladeApp): def __init__(self, @@ -19,6 +20,7 @@ self.__sound_mutex = threading.Lock() self.__tree_mutex = threading.Lock() self.my_dict = {} + self.disconnected = False def new(self): self.widget_window = True @@ -121,7 +123,16 @@ wavs.wav_paths=[] wavs.wav_sizes=[] for i in range(17): - wavs.add_wav_path('/opt/tuxdroid/apps/tuxgi/sounds/%d.wav'%(i+1)) + wavfile = wave.open('/opt/tuxdroid/apps/tuxgi/sounds/%d.wav'%(i+1), 'r') + print wavfile.getsampwidth() + print wavfile.getframerate() + if wavfile.getsampwidth() != 1 and wavfile.getframerate() != 8000: + dialog = GdgDialog(_me.string('Warning'), _me.string('FileSample')) + wavfile.close() + return + else: + wavfile.close() + wavs.add_wav_path('/opt/tuxdroid/apps/tuxgi/sounds/%d.wav'%(i+1)) for path in st_wav_paths: wavs.add_wav_path(path) else: @@ -184,7 +195,17 @@ #-------------------------------------------------------------------------- def on_wave_internal_add_bt_clicked(self, widget, *args): if str(self.get_widget("soundInternalChooser").get_filename())=="None": return - wavs.add_wav_path(self.get_widget("soundInternalChooser").get_filename()) + path = str(self.get_widget("soundInternalChooser").get_filename()) + wavfile = wave.open(path, 'r') + print wavfile.getsampwidth() + print wavfile.getframerate() + if wavfile.getsampwidth() != 1 and wavfile.getframerate() != 8000: + dialog = GdgDialog(_me.string('Warning'), _me.string('FileSample')) + wavfile.close() + return + else: + wavfile.close() + wavs.add_wav_path(self.get_widget("soundInternalChooser").get_filename()) self.refresh_flag = True self.refresh_wav_list() @@ -268,6 +289,9 @@ self.get_widget('lblSoundState').show() self.get_widget('lblSoundState').set_text(_me.string('norf')) return + else: + self.disconnected = False + if len(wavs.wav_sizes)==0: self.__sound_mutex.release() self.get_widget('lblSoundState').show() @@ -278,7 +302,8 @@ self.get_widget('lblSoundState').show() self.get_widget('lblSoundState').set_text(_me.string('toobig')) return - + tux.event.on_rf_disconnected = self.on_disconnected + tux.event.on_disconnected = self.on_disconnected try: ver = tux.hw.behavior_get_version() if int(ver[3]) < 733: @@ -343,27 +368,53 @@ self.get_widget('lblSoundState').set_text(_me.string('soundErase')) tux.cmd.sound_storing(len(wavs.wav_sizes)) - tux.sys.wait(10) + + for i in range(10): + if self.disconnected == True: return + tux.sys.wait(1) + current_pos=0x0400 tux.sys.wait(0.1) + + if self.disconnected == True: return + self.get_widget('progressbar1').set_fraction(0.5) self.get_widget('lblSoundState').set_text(_me.string('soundTOC')) + + if self.disconnected == True: return + tux.cmd.sound_store_index(0x00,0x04,0x00) + for size in wavs.wav_sizes: + + if self.disconnected == True: return + current_pos=current_pos+size tux.sys.wait(0.1) tux.cmd.sound_store_index((current_pos & 0xFF0000)>>16, (current_pos & 0x00FF00)>>8,current_pos & 0x0000FF) + self.get_widget('progressbar1').set_fraction(0.75) self.get_widget('lblSoundState').set_text(_me.string('soundProg1')) + + if self.disconnected == True: return + tux.sys.shell("aplay -D %s merged.wav"%soundcard) + if self.disconnected == True: return + self.get_widget('progressbar1').set_fraction(1) - tux.sys.wait(0.3) - self.get_widget('progressbar1').hide() - self.get_widget('lblSoundState').hide() - + self.get_widget('lblSoundState').set_text(_me.string('Succeeded')) + self.__sound_mutex.release() + def on_disconnected(self): + self.disconnected = True + tux.sys.shell('pkill aplay') + self.get_widget('progressbar1').set_fraction(1) + self.get_widget('lblSoundState').set_text(_me.string('norf')) + if self.__sound_mutex.locked(): + self.__sound_mutex.release() + #-------------------------------------------------------------------------- # On "play" flash sound button clicked #-------------------------------------------------------------------------- Modified: software/gadgets/flash_management/trunk/flash_management/Strings/fr_ALL.xml =================================================================== --- software/gadgets/flash_management/trunk/flash_management/Strings/fr_ALL.xml 2008-01-04 09:05:29 UTC (rev 820) +++ software/gadgets/flash_management/trunk/flash_management/Strings/fr_ALL.xml 2008-01-04 11:30:15 UTC (rev 821) @@ -1,6 +1,9 @@ <?xml version='1.0' encoding='UTF-8'?> <strings> + <FileSample type='str'>Le fichier wav doit être au format 8kHz / 8bits</FileSample> <Settingsgadget type='str'>Gestion de la mémoire flash</Settingsgadget> + <Succeeded type='str'>Programation terminée</Succeeded> + <Warning type='str'>Attention</Warning> <btnSoundAdd type='str'>Ajouter</btnSoundAdd> <btnSoundClear type='str'>Purger</btnSoundClear> <btnSoundModify type='str'>Modifier</btnSoundModify> Modified: software/gadgets/flash_management/trunk/flash_management/strings.xml =================================================================== --- software/gadgets/flash_management/trunk/flash_management/strings.xml 2008-01-04 09:05:29 UTC (rev 820) +++ software/gadgets/flash_management/trunk/flash_management/strings.xml 2008-01-04 11:30:15 UTC (rev 821) @@ -1,6 +1,9 @@ <?xml version='1.0' encoding='UTF-8'?> <strings> + <FileSample type='str'>The wav file must have a 8kHz/8bits format.</FileSample> <Settingsgadget type='str'>Sound flash management</Settingsgadget> + <Succeeded type='str'>Programming succeeded</Succeeded> + <Warning type='str'>Warning</Warning> <btnSoundAdd type='str'>Add</btnSoundAdd> <btnSoundClear type='str'>Clear list</btnSoundClear> <btnSoundModify type='str'>Modify</btnSoundModify> @@ -39,7 +42,8 @@ <lblVersions type='str'>Installed versions</lblVersions> <lblWifiAvoidance type='str'>Avoid the wifi channel number :</lblWifiAvoidance> <name_to_read type='str'>Flash memory management</name_to_read> - <norf type='str'>No RF connection detected</norf> + <norf type='str'>Tux cannot be found. +Please connect the dongle and/or switch on Tux</norf> <nowavs type='str'>No wavs to store</nowavs> <official type='str'>Official version</official> <soundErase type='str'>Erasing flash ...</soundErase> Modified: software/gadgets/flash_management/trunk/flash_management.tgf =================================================================== (Binary files differ) |