Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
0d68b968
by wurstsalat at 2021-12-09T20:47:12+01:00
-
4d83f3f0
by wurstsalat at 2021-12-09T20:47:12+01:00
3 changed files:
Changes:
| ... | ... | @@ -46,9 +46,10 @@ |
| 46 | 46 |
from nbxmpp.modules.security_labels import Displaymarking
|
| 47 | 47 |
|
| 48 | 48 |
from gajim.common import app
|
| 49 |
-from gajim.common import helpers
|
|
| 50 | 49 |
from gajim.common import ged
|
| 51 | 50 |
from gajim.common import i18n
|
| 51 |
+from gajim.common.helpers import message_needs_highlight
|
|
| 52 |
+from gajim.common.helpers import get_file_path_from_dnd_dropped_uri
|
|
| 52 | 53 |
from gajim.common.i18n import _
|
| 53 | 54 |
from gajim.common.nec import EventHelper
|
| 54 | 55 |
from gajim.common.nec import NetworkEvent
|
| ... | ... | @@ -68,6 +69,7 @@ |
| 68 | 69 |
from gajim.gui.message_input import MessageInputTextView
|
| 69 | 70 |
from gajim.gui.util import get_hardware_key_codes
|
| 70 | 71 |
from gajim.gui.util import get_builder
|
| 72 |
+from gajim.gui.util import set_urgency_hint
|
|
| 71 | 73 |
from gajim.gui.util import AccountBadge
|
| 72 | 74 |
from gajim.gui.const import ControlType # pylint: disable=unused-import
|
| 73 | 75 |
from gajim.gui.const import TARGET_TYPE_URI_LIST
|
| ... | ... | @@ -798,7 +800,7 @@ def _get_pref_ft_method(self) -> Optional[str]: |
| 798 | 800 |
jingle = app.window.lookup_action(
|
| 799 | 801 |
f'send-file-jingle-{self.control_id}')
|
| 800 | 802 |
|
| 801 |
- if self._type.is_groupchat:
|
|
| 803 |
+ if self.is_groupchat:
|
|
| 802 | 804 |
if httpupload.get_enabled():
|
| 803 | 805 |
return 'httpupload'
|
| 804 | 806 |
return None
|
| ... | ... | @@ -866,7 +868,7 @@ def _on_message_textview_key_press_event(self, textview, event): |
| 866 | 868 |
self.space_pressed = False
|
| 867 | 869 |
|
| 868 | 870 |
# Ctrl [+ Shift] + Tab are not forwarded to notebook. We handle it here
|
| 869 |
- if self._type.is_groupchat:
|
|
| 871 |
+ if self.is_groupchat:
|
|
| 870 | 872 |
if event.keyval not in (Gdk.KEY_ISO_Left_Tab, Gdk.KEY_Tab):
|
| 871 | 873 |
self.last_key_tabs = False
|
| 872 | 874 |
|
| ... | ... | @@ -920,7 +922,7 @@ def _on_message_textview_key_press_event(self, textview, event): |
| 920 | 922 |
self.COMMAND_PREFIX + self.command_hits[0] + ' ')
|
| 921 | 923 |
self.last_key_tabs = True
|
| 922 | 924 |
return True
|
| 923 |
- if not self._type.is_groupchat:
|
|
| 925 |
+ if not self.is_groupchat:
|
|
| 924 | 926 |
self.last_key_tabs = False
|
| 925 | 927 |
if event.keyval == Gdk.KEY_Up:
|
| 926 | 928 |
if event_state & Gdk.ModifierType.CONTROL_MASK:
|
| ... | ... | @@ -995,7 +997,7 @@ def drag_data_file_transfer(self, selection: Gtk.SelectionData) -> None: |
| 995 | 997 |
# we may have more than one file dropped
|
| 996 | 998 |
uri_splitted = selection.get_uris()
|
| 997 | 999 |
for uri in uri_splitted:
|
| 998 |
- path = helpers.get_file_path_from_dnd_dropped_uri(uri)
|
|
| 1000 |
+ path = get_file_path_from_dnd_dropped_uri(uri)
|
|
| 999 | 1001 |
if not os.path.isfile(path): # is it a file?
|
| 1000 | 1002 |
self.add_info_message(_("The following file could not be accessed and was not uploaded: ") + path)
|
| 1001 | 1003 |
continue
|
| ... | ... | @@ -1173,7 +1175,7 @@ def add_message(self, |
| 1173 | 1175 |
self._jump_to_end_button.add_unread_count()
|
| 1174 | 1176 |
|
| 1175 | 1177 |
if message_id:
|
| 1176 |
- if self._type.is_groupchat:
|
|
| 1178 |
+ if self.is_groupchat:
|
|
| 1177 | 1179 |
self.last_msg_id = stanza_id or message_id
|
| 1178 | 1180 |
else:
|
| 1179 | 1181 |
self.last_msg_id = message_id
|
| ... | ... | @@ -1186,10 +1188,22 @@ def add_message(self, |
| 1186 | 1188 |
if notify:
|
| 1187 | 1189 |
self._notify(name, text, tim, additional_data)
|
| 1188 | 1190 |
|
| 1189 |
- # Send chat marker if we’re actively following the chat
|
|
| 1190 | 1191 |
chat_active = app.window.is_chat_active(
|
| 1191 | 1192 |
self.account, self.contact.jid)
|
| 1193 |
+ |
|
| 1194 |
+ if not chat_active:
|
|
| 1195 |
+ if self.is_groupchat:
|
|
| 1196 |
+ needs_highlight = message_needs_highlight(
|
|
| 1197 |
+ text,
|
|
| 1198 |
+ self.contact.nickname,
|
|
| 1199 |
+ self._client.get_own_jid().bare)
|
|
| 1200 |
+ if needs_highlight or self.contact.can_notify():
|
|
| 1201 |
+ set_urgency_hint(app.window, True)
|
|
| 1202 |
+ else:
|
|
| 1203 |
+ set_urgency_hint(app.window, True)
|
|
| 1204 |
+ |
|
| 1192 | 1205 |
if chat_active and self._scrolled_view.get_autoscroll():
|
| 1206 |
+ # Send chat marker if we’re actively following the chat
|
|
| 1193 | 1207 |
app.window.mark_as_read(self.account, self.contact.jid)
|
| 1194 | 1208 |
|
| 1195 | 1209 |
def _notify(self,
|
| ... | ... | @@ -1222,7 +1236,7 @@ def _notify(self, |
| 1222 | 1236 |
if self.is_groupchat:
|
| 1223 | 1237 |
msg_type = 'group-chat-message'
|
| 1224 | 1238 |
title += f' ({self.contact.name})'
|
| 1225 |
- needs_highlight = helpers.message_needs_highlight(
|
|
| 1239 |
+ needs_highlight = message_needs_highlight(
|
|
| 1226 | 1240 |
text, self.contact.nickname, self._client.get_own_jid().bare)
|
| 1227 | 1241 |
if needs_highlight:
|
| 1228 | 1242 |
sound = 'muc_message_highlight'
|
| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 |
# You should have received a copy of the GNU General Public License
|
| 13 | 13 |
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
| 14 | 14 |
|
| 15 |
+from __future__ import annotations
|
|
| 16 |
+ |
|
| 15 | 17 |
from typing import Optional
|
| 16 | 18 |
from typing import Union
|
| 17 | 19 |
|
| ... | ... | @@ -28,6 +30,7 @@ |
| 28 | 30 |
from nbxmpp.modules.security_labels import Displaymarking
|
| 29 | 31 |
|
| 30 | 32 |
from gajim.common import app
|
| 33 |
+from gajim.common import types
|
|
| 31 | 34 |
from gajim.common.const import AvatarSize
|
| 32 | 35 |
from gajim.common.const import TRUST_SYMBOL_DATA
|
| 33 | 36 |
from gajim.common.helpers import AdditionalDataDict
|
| ... | ... | @@ -36,9 +39,6 @@ |
| 36 | 39 |
from gajim.common.helpers import message_needs_highlight
|
| 37 | 40 |
from gajim.common.helpers import reduce_chars_newlines
|
| 38 | 41 |
from gajim.common.helpers import to_user_string
|
| 39 |
-from gajim.common.modules.contacts import BareContact
|
|
| 40 |
-from gajim.common.modules.contacts import GroupchatContact
|
|
| 41 |
-from gajim.common.modules.contacts import GroupchatParticipant
|
|
| 42 | 42 |
from gajim.common.styling import process
|
| 43 | 43 |
from gajim.common.styling import ParsingResult
|
| 44 | 44 |
from gajim.common.i18n import _
|
| ... | ... | @@ -56,14 +56,13 @@ |
| 56 | 56 |
|
| 57 | 57 |
MERGE_TIMEFRAME = timedelta(seconds=120)
|
| 58 | 58 |
|
| 59 |
-# TODO:
|
|
| 60 |
-ContactType = Union[BareContact, GroupchatContact, GroupchatParticipant]
|
|
| 61 |
- |
|
| 62 | 59 |
|
| 63 | 60 |
class MessageRow(BaseRow):
|
| 64 | 61 |
def __init__(self,
|
| 65 | 62 |
account: str,
|
| 66 |
- contact: ContactType,
|
|
| 63 |
+ contact: Union[types.BareContact,
|
|
| 64 |
+ types.GroupchatContact,
|
|
| 65 |
+ types.GroupchatParticipant],
|
|
| 67 | 66 |
message_id: Optional[str],
|
| 68 | 67 |
stanza_id: Optional[str],
|
| 69 | 68 |
timestamp: float,
|
| ... | ... | @@ -52,6 +52,7 @@ |
| 52 | 52 |
from .util import restore_main_window_position
|
| 53 | 53 |
from .util import save_main_window_position
|
| 54 | 54 |
from .util import open_window
|
| 55 |
+from .util import set_urgency_hint
|
|
| 55 | 56 |
|
| 56 | 57 |
log = logging.getLogger('gajim.gui.main')
|
| 57 | 58 |
|
| ... | ... | @@ -521,7 +522,7 @@ def get_chat_unread_count(self, |
| 521 | 522 |
|
| 522 | 523 |
def mark_as_read(self, account: str, jid: JID,
|
| 523 | 524 |
send_marker: bool = True) -> None:
|
| 524 |
- # TODO set window urgency hint, etc.
|
|
| 525 |
+ set_urgency_hint(self, False)
|
|
| 525 | 526 |
control = self.get_control(account, jid)
|
| 526 | 527 |
if control is not None:
|
| 527 | 528 |
# Send displayed marker and
|
| ... | ... | @@ -536,6 +537,7 @@ def _on_window_active(self, window, _param): |
| 536 | 537 |
if not is_active:
|
| 537 | 538 |
return
|
| 538 | 539 |
|
| 540 |
+ set_urgency_hint(self, False)
|
|
| 539 | 541 |
control = self.get_active_control()
|
| 540 | 542 |
if control is None:
|
| 541 | 543 |
return
|