Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: 0d68b968 by wurstsalat at 2021-12-09T20:47:12+01:00 MessageRow: Fix contact typing
- - - - - 4d83f3f0 by wurstsalat at 2021-12-09T20:47:12+01:00 Bring back urgency hint
- - - - -
3 changed files:
- gajim/gtk/controls/base.py - gajim/gtk/conversation/rows/message.py - gajim/gtk/main.py
Changes:
===================================== gajim/gtk/controls/base.py ===================================== @@ -46,9 +46,10 @@ from nbxmpp.modules.security_labels import Displaymarking
from gajim.common import app -from gajim.common import helpers from gajim.common import ged from gajim.common import i18n +from gajim.common.helpers import message_needs_highlight +from gajim.common.helpers import get_file_path_from_dnd_dropped_uri from gajim.common.i18n import _ from gajim.common.nec import EventHelper from gajim.common.nec import NetworkEvent @@ -68,6 +69,7 @@ from gajim.gui.message_input import MessageInputTextView from gajim.gui.util import get_hardware_key_codes from gajim.gui.util import get_builder +from gajim.gui.util import set_urgency_hint from gajim.gui.util import AccountBadge from gajim.gui.const import ControlType # pylint: disable=unused-import from gajim.gui.const import TARGET_TYPE_URI_LIST @@ -798,7 +800,7 @@ def _get_pref_ft_method(self) -> Optional[str]: jingle = app.window.lookup_action( f'send-file-jingle-{self.control_id}')
- if self._type.is_groupchat: + if self.is_groupchat: if httpupload.get_enabled(): return 'httpupload' return None @@ -866,7 +868,7 @@ def _on_message_textview_key_press_event(self, textview, event): self.space_pressed = False
# Ctrl [+ Shift] + Tab are not forwarded to notebook. We handle it here - if self._type.is_groupchat: + if self.is_groupchat: if event.keyval not in (Gdk.KEY_ISO_Left_Tab, Gdk.KEY_Tab): self.last_key_tabs = False
@@ -920,7 +922,7 @@ def _on_message_textview_key_press_event(self, textview, event): self.COMMAND_PREFIX + self.command_hits[0] + ' ') self.last_key_tabs = True return True - if not self._type.is_groupchat: + if not self.is_groupchat: self.last_key_tabs = False if event.keyval == Gdk.KEY_Up: if event_state & Gdk.ModifierType.CONTROL_MASK: @@ -995,7 +997,7 @@ def drag_data_file_transfer(self, selection: Gtk.SelectionData) -> None: # we may have more than one file dropped uri_splitted = selection.get_uris() for uri in uri_splitted: - path = helpers.get_file_path_from_dnd_dropped_uri(uri) + path = get_file_path_from_dnd_dropped_uri(uri) if not os.path.isfile(path): # is it a file? self.add_info_message(_("The following file could not be accessed and was not uploaded: ") + path) continue @@ -1173,7 +1175,7 @@ def add_message(self, self._jump_to_end_button.add_unread_count()
if message_id: - if self._type.is_groupchat: + if self.is_groupchat: self.last_msg_id = stanza_id or message_id else: self.last_msg_id = message_id @@ -1186,10 +1188,22 @@ def add_message(self, if notify: self._notify(name, text, tim, additional_data)
- # Send chat marker if we’re actively following the chat chat_active = app.window.is_chat_active( self.account, self.contact.jid) + + if not chat_active: + if self.is_groupchat: + needs_highlight = message_needs_highlight( + text, + self.contact.nickname, + self._client.get_own_jid().bare) + if needs_highlight or self.contact.can_notify(): + set_urgency_hint(app.window, True) + else: + set_urgency_hint(app.window, True) + if chat_active and self._scrolled_view.get_autoscroll(): + # Send chat marker if we’re actively following the chat app.window.mark_as_read(self.account, self.contact.jid)
def _notify(self, @@ -1222,7 +1236,7 @@ def _notify(self, if self.is_groupchat: msg_type = 'group-chat-message' title += f' ({self.contact.name})' - needs_highlight = helpers.message_needs_highlight( + needs_highlight = message_needs_highlight( text, self.contact.nickname, self._client.get_own_jid().bare) if needs_highlight: sound = 'muc_message_highlight'
===================================== gajim/gtk/conversation/rows/message.py ===================================== @@ -12,6 +12,8 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from __future__ import annotations + from typing import Optional from typing import Union
@@ -28,6 +30,7 @@ from nbxmpp.modules.security_labels import Displaymarking
from gajim.common import app +from gajim.common import types from gajim.common.const import AvatarSize from gajim.common.const import TRUST_SYMBOL_DATA from gajim.common.helpers import AdditionalDataDict @@ -36,9 +39,6 @@ from gajim.common.helpers import message_needs_highlight from gajim.common.helpers import reduce_chars_newlines from gajim.common.helpers import to_user_string -from gajim.common.modules.contacts import BareContact -from gajim.common.modules.contacts import GroupchatContact -from gajim.common.modules.contacts import GroupchatParticipant from gajim.common.styling import process from gajim.common.styling import ParsingResult from gajim.common.i18n import _ @@ -56,14 +56,13 @@
MERGE_TIMEFRAME = timedelta(seconds=120)
-# TODO: -ContactType = Union[BareContact, GroupchatContact, GroupchatParticipant] -
class MessageRow(BaseRow): def __init__(self, account: str, - contact: ContactType, + contact: Union[types.BareContact, + types.GroupchatContact, + types.GroupchatParticipant], message_id: Optional[str], stanza_id: Optional[str], timestamp: float,
===================================== gajim/gtk/main.py ===================================== @@ -52,6 +52,7 @@ from .util import restore_main_window_position from .util import save_main_window_position from .util import open_window +from .util import set_urgency_hint
log = logging.getLogger('gajim.gui.main')
@@ -521,7 +522,7 @@ def get_chat_unread_count(self,
def mark_as_read(self, account: str, jid: JID, send_marker: bool = True) -> None: - # TODO set window urgency hint, etc. + set_urgency_hint(self, False) control = self.get_control(account, jid) if control is not None: # Send displayed marker and @@ -536,6 +537,7 @@ def _on_window_active(self, window, _param): if not is_active: return
+ set_urgency_hint(self, False) control = self.get_active_control() if control is None: return
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/ad86867ab7e6fe531e9e24d2823cdac1...