gajim is sounds ready even for windows [arnaud plz confirm]

This commit is contained in:
Nikos Kouremenos 2005-04-10 13:33:27 +00:00
parent 9f3a2b0a3a
commit ec34b733c4
2 changed files with 30 additions and 22 deletions

View File

@ -730,17 +730,22 @@ class Preferences_window:
self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\ self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\
set_active(self.plugin.config['ignore_unknown_contacts']) set_active(self.plugin.config['ignore_unknown_contacts'])
if not self.plugin.config['sounds_on']: #sounds
if self.plugin.config['sounds_on']:
self.xml.get_widget('play_sounds_checkbutton').set_active(True)
else:
self.xml.get_widget('sound_player_hbox').set_sensitive(False) self.xml.get_widget('sound_player_hbox').set_sensitive(False)
self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False) self.xml.get_widget('sounds_scrolledwindow').set_sensitive(False)
self.xml.get_widget('browse_sounds_hbox').set_sensitive(False) self.xml.get_widget('browse_sounds_hbox').set_sensitive(False)
#FIXME:
if os.name == 'nt': # if windows, player must not be changeable
self.xml.get_widget('sound_player_hbox').set_visible(False)
#sound player #sound player
self.xml.get_widget('soundplayer_entry').set_text(\ self.xml.get_widget('soundplayer_entry').set_text(\
self.plugin.config['soundplayer']) self.plugin.config['soundplayer'])
#sounds #sounds treeview
self.sound_tree = self.xml.get_widget('sounds_treeview') self.sound_tree = self.xml.get_widget('sounds_treeview')
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \ model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \
gobject.TYPE_STRING) gobject.TYPE_STRING)
@ -767,12 +772,6 @@ class Preferences_window:
col.set_attributes(renderer, text=2) col.set_attributes(renderer, text=2)
self.fill_sound_treeview() self.fill_sound_treeview()
if not os.name == 'posix':
self.xml.get_widget('soundplayer_entry').set_sensitive(False)
self.sound_tree.set_sensitive(False)
self.xml.get_widget('sounds_entry').set_sensitive(False)
self.xml.get_widget('sounds_button').set_sensitive(False)
#Autoaway #Autoaway
st = self.plugin.config['autoaway'] st = self.plugin.config['autoaway']
self.auto_away_checkbutton.set_active(st) self.auto_away_checkbutton.set_active(st)

View File

@ -64,6 +64,11 @@ import Queue
import sre import sre
import common.sleepy import common.sleepy
try:
import winsound # windows-only built-in module for playing wav
except ImportError:
pass
class CellRendererImage(gtk.GenericCellRenderer): class CellRendererImage(gtk.GenericCellRenderer):
__gproperties__ = { __gproperties__ = {
@ -276,17 +281,21 @@ class plugin:
def play_sound(self, event): def play_sound(self, event):
if os.name != 'posix': if not self.config['sounds_on']:
return return
if not self.config[event]: # FIXME: CAN THIS EVER HAPPEN?
return
path_to_soundfile = self.config[event + '_file']
if not os.path.exists(path_to_soundfile):
return
if os.name == 'nt':
winsound.PlaySound(path_to_soundfile, \
winsound.SND_FILENAME|winsound.SND_ASYNC)
elif os.name == 'posix':
if self.config['soundplayer'] == '': if self.config['soundplayer'] == '':
return return
if not self.config[event]:
return
file = self.config[event + '_file']
if not os.path.exists(file):
return
argv = self.config['soundplayer'].split() argv = self.config['soundplayer'].split()
argv.append(file) argv.append(path_to_soundfile)
pid = os.spawnvp(os.P_NOWAIT, argv[0], argv) pid = os.spawnvp(os.P_NOWAIT, argv[0], argv)
pidp, r = os.waitpid(pid, os.WNOHANG) pidp, r = os.waitpid(pid, os.WNOHANG)
if pidp == 0: if pidp == 0: