Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
601400de by wurstsalat at 2024-11-24T17:51:14+01:00
imprv: Group Chats: Add 'Direct Message' menu item to participants menu
Closes #12146
- - - - -
2 changed files:
- gajim/gtk/groupchat_roster.py
- gajim/gtk/menus.py
Changes:
=====================================
gajim/gtk/groupchat_roster.py
=====================================
@@ -31,6 +31,7 @@
from gajim.gtk.builder import get_builder
from gajim.gtk.menus import get_groupchat_participant_menu
+from gajim.gtk.structs import AddChatActionParams
from gajim.gtk.tooltips import GCTooltip
from gajim.gtk.util import GajimPopover
from gajim.gtk.util import SignalManager
@@ -194,17 +195,22 @@ def _on_contact_item_activated(
muc_prefer_direct_msg = app.settings.get("muc_prefer_direct_msg")
if disco.muc_is_nonanonymous and muc_prefer_direct_msg:
assert participant_contact.real_jid is not None
- app.window.add_chat(
- self._contact.account,
- participant_contact.real_jid,
- "contact",
+ dm_params = AddChatActionParams(
+ account=self._contact.account,
+ jid=participant_contact.real_jid,
+ type="chat",
select=True,
)
else:
- app.window.add_private_chat(
- self._contact.account, participant_contact.jid, select=True
+ dm_params = AddChatActionParams(
+ account=self._contact.account,
+ jid=participant_contact.jid,
+ type="pm",
+ select=True,
)
+ app.window.activate_action("win.add-chat", dm_params.to_variant())
+
def _on_search_changed(self, widget: Gtk.SearchEntry) -> None:
self._contact_view.set_search(widget.get_text())
self._scroll_to_top()
=====================================
gajim/gtk/menus.py
=====================================
@@ -688,9 +688,24 @@ def get_groupchat_participant_menu(
contact: types.GroupchatParticipant,
) -> GajimMenu:
+ group_chat = self_contact.room
+ disco = group_chat.get_disco()
+ assert disco is not None
+ muc_prefer_direct_msg = app.settings.get("muc_prefer_direct_msg")
+ if disco.muc_is_nonanonymous and muc_prefer_direct_msg:
+ assert contact.real_jid is not None
+ dm_params = AddChatActionParams(
+ account=account, jid=contact.real_jid, type="chat", select=True
+ )
+ else:
+ dm_params = AddChatActionParams(
+ account=account, jid=contact.jid, type="pm", select=True
+ )
+
value = str(contact.name)
general_items: MenuItemListT = [
+ (_("Direct Message"), "win.add-chat", dm_params),
(_("Details"), "win.muc-contact-info", value),
(_("Execute Command…"), "win.muc-execute-command", value),
]
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/601400dea1bb511f5a90cc39b1bfcd745e409442
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/601400dea1bb511f5a90cc39b1bfcd745e409442
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]