use better varname; put a comment or two; try to make it better understandable; rm two unneeded lines
This commit is contained in:
parent
320698e497
commit
b19b73d4cc
|
@ -747,20 +747,20 @@ def sanitize_filename(filename):
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def allow_showing_notification(account, type = None, advanced_notif_num = None,
|
def allow_showing_notification(account, type = None,
|
||||||
first = True):
|
advanced_notif_num = None, is_first_message = True):
|
||||||
'''is it allowed to show nofication?
|
'''is it allowed to show nofication?
|
||||||
check OUR status and if we allow notifications for that status
|
check OUR status and if we allow notifications for that status
|
||||||
type is the option that need to be True ex: notify_on_signing
|
type is the option that need to be True e.g.: notify_on_signing
|
||||||
first: set it to false when it's not the first message'''
|
is_first_message: set it to false when it's not the first message'''
|
||||||
if advanced_notif_num != None:
|
if advanced_notif_num is not None:
|
||||||
popup = gajim.config.get_per('notifications', str(advanced_notif_num),
|
popup = gajim.config.get_per('notifications', str(advanced_notif_num),
|
||||||
'popup')
|
'popup')
|
||||||
if popup == 'yes':
|
if popup == 'yes':
|
||||||
return True
|
return True
|
||||||
if popup == 'no':
|
if popup == 'no':
|
||||||
return False
|
return False
|
||||||
if type and (not gajim.config.get(type) or not first):
|
if type and (not gajim.config.get(type) or not is_first_message):
|
||||||
return False
|
return False
|
||||||
if gajim.config.get('autopopupaway'): # always show notification
|
if gajim.config.get('autopopupaway'): # always show notification
|
||||||
return True
|
return True
|
||||||
|
@ -785,7 +785,7 @@ def allow_popup_window(account, advanced_notif_num = None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def allow_sound_notification(sound_event, advanced_notif_num = None):
|
def allow_sound_notification(sound_event, advanced_notif_num = None):
|
||||||
if advanced_notif_num != None:
|
if advanced_notif_num is not None:
|
||||||
sound = gajim.config.get_per('notifications', str(advanced_notif_num),
|
sound = gajim.config.get_per('notifications', str(advanced_notif_num),
|
||||||
'sound')
|
'sound')
|
||||||
if sound == 'yes':
|
if sound == 'yes':
|
||||||
|
|
|
@ -64,7 +64,8 @@ def get_show_in_systray(event, account, contact):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_advanced_notification(event, account, contact):
|
def get_advanced_notification(event, account, contact):
|
||||||
'''Returns the number of the first advanced notification or None'''
|
'''Returns the number of the first (top most)
|
||||||
|
advanced notification else None'''
|
||||||
num = 0
|
num = 0
|
||||||
notif = gajim.config.get_per('notifications', str(num))
|
notif = gajim.config.get_per('notifications', str(num))
|
||||||
while notif:
|
while notif:
|
||||||
|
@ -112,7 +113,8 @@ def get_advanced_notification(event, account, contact):
|
||||||
|
|
||||||
def notify(event, jid, account, parameters, advanced_notif_num = None):
|
def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
'''Check what type of notifications we want, depending on basic
|
'''Check what type of notifications we want, depending on basic
|
||||||
and the advanced configuration of notifications and do these notifications'''
|
and the advanced configuration of notifications and do these notifications;
|
||||||
|
advanced_notif_num'''
|
||||||
# First, find what notifications we want
|
# First, find what notifications we want
|
||||||
do_popup = False
|
do_popup = False
|
||||||
do_sound = False
|
do_sound = False
|
||||||
|
@ -146,17 +148,17 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
do_sound = True
|
do_sound = True
|
||||||
elif event == 'new_message':
|
elif event == 'new_message':
|
||||||
message_type = parameters[0]
|
message_type = parameters[0]
|
||||||
first = parameters[1]
|
is_first_message = parameters[1]
|
||||||
nickname = parameters[2]
|
nickname = parameters[2]
|
||||||
message = parameters[3]
|
message = parameters[3]
|
||||||
if helpers.allow_showing_notification(account, 'notify_on_new_message',
|
if helpers.allow_showing_notification(account, 'notify_on_new_message',
|
||||||
advanced_notif_num, first):
|
advanced_notif_num, is_first_message):
|
||||||
do_popup = True
|
do_popup = True
|
||||||
if first and helpers.allow_sound_notification('first_message_received',
|
if is_first_message and helpers.allow_sound_notification(
|
||||||
advanced_notif_num):
|
'first_message_received', advanced_notif_num):
|
||||||
do_sound = True
|
do_sound = True
|
||||||
elif not first and helpers.allow_sound_notification(
|
elif not is_first_message and helpers.allow_sound_notification(
|
||||||
'next_message_received', advanced_notif_num):
|
'next_message_received', advanced_notif_num):
|
||||||
do_sound = True
|
do_sound = True
|
||||||
else:
|
else:
|
||||||
print '*Event not implemeted yet*'
|
print '*Event not implemeted yet*'
|
||||||
|
@ -253,7 +255,7 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
|
||||||
elif advanced_notif_num is not None and gajim.config.get_per(
|
elif advanced_notif_num is not None and gajim.config.get_per(
|
||||||
'notifications', str(advanced_notif_num), 'sound') == 'no':
|
'notifications', str(advanced_notif_num), 'sound') == 'no':
|
||||||
pass # do not set snd_event
|
pass # do not set snd_event
|
||||||
elif first:
|
elif is_first_message:
|
||||||
snd_event = 'first_message_received'
|
snd_event = 'first_message_received'
|
||||||
else:
|
else:
|
||||||
snd_event = 'next_message_received'
|
snd_event = 'next_message_received'
|
||||||
|
|
Loading…
Reference in New Issue