Philipp Hörist pushed to branch master at gajim / gajim
Commits: a287b218 by lovetox at 2020-07-29T13:20:53+02:00 Move notify_for_muc() into helpers module
- - - - -
9 changed files:
- gajim/chat_control_base.py - gajim/common/config.py - gajim/common/connection_handlers_events.py - gajim/common/helpers.py - gajim/groupchat_control.py - gajim/gtk/util.py - gajim/message_window.py - gajim/remote_control.py - gajim/roster_window.py
Changes:
===================================== gajim/chat_control_base.py ===================================== @@ -1138,7 +1138,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
if kind == 'incoming': if (not self._type.is_groupchat or - app.config.notify_for_muc(jid) or + helpers.notify_for_muc(jid) or 'marked' in other_tags_for_text): # it's a normal message, or a muc message with want to be # notified about if quitting just after
===================================== gajim/common/config.py ===================================== @@ -628,11 +628,6 @@ class Config: return obj[subname][Option.RESTART] return False
- def notify_for_muc(self, room): - all_ = self.get('notify_on_all_muc_messages') - room = self.get_per('rooms', room, 'notify_on_all_messages') - return all_ or room - def get_options(self, optname, return_type=str): options = self.get(optname).split(',') options = [return_type(option.strip()) for option in options]
===================================== gajim/common/connection_handlers_events.py ===================================== @@ -305,7 +305,7 @@ class NotificationEvent(nec.NetworkIncomingEvent): self.control_focused = self.control.has_focus()
if app.config.get('notify_on_new_message'): - notify_for_muc = (app.config.notify_for_muc(self.jid) or + notify_for_muc = (helpers.notify_for_muc(self.jid) or sound == 'highlight') if not notify_for_muc: self.do_popup = False
===================================== gajim/common/helpers.py ===================================== @@ -1570,3 +1570,9 @@ def should_log(account, jid): no_log_for = no_log_for.split()
return (account not in no_log_for) and (jid not in no_log_for) + + +def notify_for_muc(room): + all_ = app.config.get('notify_on_all_muc_messages') + room = app.config.get_per('rooms', room, 'notify_on_all_messages') + return all_ or room
===================================== gajim/groupchat_control.py ===================================== @@ -962,7 +962,7 @@ class GroupchatControl(ChatControlBase):
def get_nb_unread(self): type_events = ['printed_marked_gc_msg'] - if app.config.notify_for_muc(self.room_jid): + if helpers.notify_for_muc(self.room_jid): type_events.append('printed_gc_msg') nb = len(app.events.get_events(self.account, self.room_jid, @@ -984,7 +984,7 @@ class GroupchatControl(ChatControlBase): """ highlight, sound = None, None
- notify = app.config.notify_for_muc(self.room_jid) + notify = helpers.notify_for_muc(self.room_jid) message_sound_enabled = app.config.get_per('soundevents', 'muc_message_received', 'enabled')
===================================== gajim/gtk/util.py ===================================== @@ -48,6 +48,7 @@ from gajim.common import configpaths from gajim.common import i18n from gajim.common.i18n import _ from gajim.common.helpers import URL_REGEX +from gajim.common.helpers import notify_for_muc from gajim.common.const import MOODS from gajim.common.const import ACTIVITIES from gajim.common.const import LOCATION_DATA @@ -500,7 +501,7 @@ def get_show_in_systray(type_, jid): """ Return True if this event must be shown in systray, else False """ - notify = app.config.notify_for_muc(jid) + notify = notify_for_muc(jid) if type_ == 'printed_gc_msg' and not notify: # it's not an highlighted message, don't show in systray return False
===================================== gajim/message_window.py ===================================== @@ -36,6 +36,7 @@ from gajim.common import app from gajim.common import ged from gajim.common.i18n import Q_ from gajim.common.i18n import _ +from gajim.common.helpers import notify_for_muc from gajim.common.nec import EventHelper
from gajim import gtkgui_helpers @@ -491,7 +492,7 @@ class MessageWindow(EventHelper): unread = 0 for ctrl in self.controls(): if (ctrl.is_groupchat and - not app.config.notify_for_muc(ctrl.room_jid) and + not notify_for_muc(ctrl.room_jid) and not ctrl.attention_flag): # count only pm messages unread += ctrl.get_nb_unread_pm() @@ -509,7 +510,7 @@ class MessageWindow(EventHelper): if control.is_groupchat: name = control.contact.get_shown_name() urgent = (control.attention_flag or - app.config.notify_for_muc(control.room_jid)) + notify_for_muc(control.room_jid)) else: name = control.contact.get_shown_name() if control.resource:
===================================== gajim/remote_control.py ===================================== @@ -884,7 +884,7 @@ class GajimRemote(Server): def get_unread_msgs_number(self): unread = app.events.get_nb_events() for event in app.events.get_all_events(['printed_gc_msg']): - if not app.config.notify_for_muc(event.jid): + if not helpers.notify_for_muc(event.jid): unread -= 1 return str(unread)
===================================== gajim/roster_window.py ===================================== @@ -2368,7 +2368,7 @@ class RosterWindow: unread = app.events.get_nb_events()
for event in app.events.get_all_events(['printed_gc_msg']): - if not app.config.notify_for_muc(event.jid): + if not helpers.notify_for_muc(event.jid): unread -= 1
# check if we have recent messages
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/a287b218a58d8715bb3167c18af7572af...