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)
@ -766,12 +771,6 @@ class Preferences_window:
col.pack_start(renderer) col.pack_start(renderer)
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']

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,21 +281,25 @@ 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 self.config['soundplayer'] == '': if not self.config[event]: # FIXME: CAN THIS EVER HAPPEN?
return return
if not self.config[event]: path_to_soundfile = self.config[event + '_file']
if not os.path.exists(path_to_soundfile):
return return
file = self.config[event + '_file'] if os.name == 'nt':
if not os.path.exists(file): winsound.PlaySound(path_to_soundfile, \
return winsound.SND_FILENAME|winsound.SND_ASYNC)
argv = self.config['soundplayer'].split() elif os.name == 'posix':
argv.append(file) if self.config['soundplayer'] == '':
pid = os.spawnvp(os.P_NOWAIT, argv[0], argv) return
pidp, r = os.waitpid(pid, os.WNOHANG) argv = self.config['soundplayer'].split()
if pidp == 0: argv.append(path_to_soundfile)
gobject.timeout_add(10000, self.play_timeout, pid) pid = os.spawnvp(os.P_NOWAIT, argv[0], argv)
pidp, r = os.waitpid(pid, os.WNOHANG)
if pidp == 0:
gobject.timeout_add(10000, self.play_timeout, pid)
def send(self, event, account, data): def send(self, event, account, data):
self.queueOUT.put((event, account, data)) self.queueOUT.put((event, account, data))