gajim is sounds ready even for windows [arnaud plz confirm]
This commit is contained in:
parent
9f3a2b0a3a
commit
ec34b733c4
|
@ -730,17 +730,22 @@ class Preferences_window:
|
|||
self.xml.get_widget('ignore_events_from_unknown_contacts_checkbutton').\
|
||||
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('sounds_scrolledwindow').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
|
||||
self.xml.get_widget('soundplayer_entry').set_text(\
|
||||
self.plugin.config['soundplayer'])
|
||||
|
||||
#sounds
|
||||
#sounds treeview
|
||||
self.sound_tree = self.xml.get_widget('sounds_treeview')
|
||||
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \
|
||||
gobject.TYPE_STRING)
|
||||
|
@ -766,12 +771,6 @@ class Preferences_window:
|
|||
col.pack_start(renderer)
|
||||
col.set_attributes(renderer, text=2)
|
||||
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
|
||||
st = self.plugin.config['autoaway']
|
||||
|
|
|
@ -64,6 +64,11 @@ import Queue
|
|||
import sre
|
||||
import common.sleepy
|
||||
|
||||
try:
|
||||
import winsound # windows-only built-in module for playing wav
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
class CellRendererImage(gtk.GenericCellRenderer):
|
||||
|
||||
__gproperties__ = {
|
||||
|
@ -276,21 +281,25 @@ class plugin:
|
|||
|
||||
|
||||
def play_sound(self, event):
|
||||
if os.name != 'posix':
|
||||
if not self.config['sounds_on']:
|
||||
return
|
||||
if self.config['soundplayer'] == '':
|
||||
if not self.config[event]: # FIXME: CAN THIS EVER HAPPEN?
|
||||
return
|
||||
if not self.config[event]:
|
||||
path_to_soundfile = self.config[event + '_file']
|
||||
if not os.path.exists(path_to_soundfile):
|
||||
return
|
||||
file = self.config[event + '_file']
|
||||
if not os.path.exists(file):
|
||||
return
|
||||
argv = self.config['soundplayer'].split()
|
||||
argv.append(file)
|
||||
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)
|
||||
if os.name == 'nt':
|
||||
winsound.PlaySound(path_to_soundfile, \
|
||||
winsound.SND_FILENAME|winsound.SND_ASYNC)
|
||||
elif os.name == 'posix':
|
||||
if self.config['soundplayer'] == '':
|
||||
return
|
||||
argv = self.config['soundplayer'].split()
|
||||
argv.append(path_to_soundfile)
|
||||
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):
|
||||
self.queueOUT.put((event, account, data))
|
||||
|
|
Loading…
Reference in New Issue