Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
c8d19f60
by Daniel Brötzmann at 2020-09-26T10:40:25+02:00
10 changed files:
- gajim/common/events.py
- gajim/common/modules/muc.py
- gajim/data/gui/groupchat_info_scrolled.ui
- − gajim/data/gui/groupchat_invitation_received.ui
- gajim/gtk/const.py
- gajim/gtk/dialogs.py
- gajim/gtk/groupchat_info.py
- + gajim/gtk/groupchat_invitation.py
- gajim/gui_interface.py
- gajim/roster_window.py
Changes:
| ... | ... | @@ -22,6 +22,8 @@ |
| 22 | 22 |
|
| 23 | 23 |
import time
|
| 24 | 24 |
|
| 25 |
+from gajim.common import app
|
|
| 26 |
+ |
|
| 25 | 27 |
|
| 26 | 28 |
class Event:
|
| 27 | 29 |
"""
|
| ... | ... | @@ -130,6 +132,16 @@ class GcInvitationtEvent(Event): |
| 130 | 132 |
for key, value in vars(event).items():
|
| 131 | 133 |
setattr(self, key, value)
|
| 132 | 134 |
|
| 135 |
+ def get_inviter_name(self):
|
|
| 136 |
+ if self.from_.bare_match(self.muc):
|
|
| 137 |
+ return self.from_.resource
|
|
| 138 |
+ |
|
| 139 |
+ contact = app.contacts.get_first_contact_from_jid(
|
|
| 140 |
+ self.account, self.from_.bare)
|
|
| 141 |
+ if contact is None:
|
|
| 142 |
+ return str(self.from_)
|
|
| 143 |
+ return contact.get_shown_name()
|
|
| 144 |
+ |
|
| 133 | 145 |
class FileRequestEvent(Event):
|
| 134 | 146 |
type_ = 'file-request'
|
| 135 | 147 |
def __init__(self, file_props, time_=None, show_in_roster=False, show_in_systray=True):
|
| ... | ... | @@ -771,12 +771,28 @@ class MUC(BaseModule): |
| 771 | 771 |
self._log.info('We are already in this room')
|
| 772 | 772 |
raise nbxmpp.NodeProcessed
|
| 773 | 773 |
|
| 774 |
- app.nec.push_incoming_event(
|
|
| 775 |
- NetworkEvent('muc-invitation',
|
|
| 776 |
- account=self._account,
|
|
| 777 |
- **data._asdict()))
|
|
| 774 |
+ self._con.get_module('Discovery').disco_muc(
|
|
| 775 |
+ data.muc,
|
|
| 776 |
+ request_vcard=True,
|
|
| 777 |
+ callback=self._on_disco_result_after_invite,
|
|
| 778 |
+ user_data=data)
|
|
| 779 |
+ |
|
| 778 | 780 |
raise nbxmpp.NodeProcessed
|
| 779 | 781 |
|
| 782 |
+ def _on_disco_result_after_invite(self, task):
|
|
| 783 |
+ try:
|
|
| 784 |
+ result = task.finish()
|
|
| 785 |
+ except StanzaError as error:
|
|
| 786 |
+ self._log.warning(error)
|
|
| 787 |
+ return
|
|
| 788 |
+ |
|
| 789 |
+ invite_data = task.get_user_data()
|
|
| 790 |
+ app.nec.push_incoming_event(
|
|
| 791 |
+ NetworkEvent('muc-invitation',
|
|
| 792 |
+ account=self._account,
|
|
| 793 |
+ info=result.info,
|
|
| 794 |
+ **invite_data._asdict()))
|
|
| 795 |
+ |
|
| 780 | 796 |
def invite(self, room, to, reason=None, continue_=False):
|
| 781 | 797 |
type_ = InviteType.MEDIATED
|
| 782 | 798 |
contact = app.contacts.get_contact_from_full_jid(self._account, to)
|
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
-<!-- Generated with glade 3.22.2 -->
|
|
| 2 |
+<!-- Generated with glade 3.36.0 -->
|
|
| 3 | 3 |
<interface>
|
| 4 | 4 |
<requires lib="gtk+" version="3.20"/>
|
| 5 | 5 |
<object class="GtkGrid" id="info_grid">
|
| ... | ... | @@ -170,23 +170,6 @@ |
| 170 | 170 |
<property name="top_attach">8</property>
|
| 171 | 171 |
</packing>
|
| 172 | 172 |
</child>
|
| 173 |
- <child>
|
|
| 174 |
- <object class="GtkLabel">
|
|
| 175 |
- <property name="visible">True</property>
|
|
| 176 |
- <property name="can_focus">False</property>
|
|
| 177 |
- <property name="halign">center</property>
|
|
| 178 |
- <property name="valign">start</property>
|
|
| 179 |
- <property name="label" translatable="yes">Configuration</property>
|
|
| 180 |
- <style>
|
|
| 181 |
- <class name="bold16"/>
|
|
| 182 |
- </style>
|
|
| 183 |
- </object>
|
|
| 184 |
- <packing>
|
|
| 185 |
- <property name="left_attach">0</property>
|
|
| 186 |
- <property name="top_attach">10</property>
|
|
| 187 |
- <property name="width">2</property>
|
|
| 188 |
- </packing>
|
|
| 189 |
- </child>
|
|
| 190 | 173 |
<child>
|
| 191 | 174 |
<object class="GtkLinkButton" id="logs">
|
| 192 | 175 |
<property name="label" translatable="yes">button</property>
|
| 1 |
-<?xml version="1.0" encoding="UTF-8"?>
|
|
| 2 |
-<!-- Generated with glade 3.22.1 -->
|
|
| 3 |
-<interface>
|
|
| 4 |
- <requires lib="gtk+" version="3.20"/>
|
|
| 5 |
- <object class="GtkGrid" id="grid">
|
|
| 6 |
- <property name="visible">True</property>
|
|
| 7 |
- <property name="can_focus">False</property>
|
|
| 8 |
- <property name="border_width">18</property>
|
|
| 9 |
- <property name="row_spacing">6</property>
|
|
| 10 |
- <property name="column_spacing">12</property>
|
|
| 11 |
- <child>
|
|
| 12 |
- <object class="GtkLabel" id="invitation_label">
|
|
| 13 |
- <property name="visible">True</property>
|
|
| 14 |
- <property name="can_focus">False</property>
|
|
| 15 |
- <property name="label"><b>contact/jid</b> has invited you to the group chat <b>muc.jid</b></property>
|
|
| 16 |
- <property name="use_markup">True</property>
|
|
| 17 |
- <property name="wrap">True</property>
|
|
| 18 |
- <property name="max_width_chars">50</property>
|
|
| 19 |
- <property name="xalign">0</property>
|
|
| 20 |
- </object>
|
|
| 21 |
- <packing>
|
|
| 22 |
- <property name="left_attach">1</property>
|
|
| 23 |
- <property name="top_attach">1</property>
|
|
| 24 |
- </packing>
|
|
| 25 |
- </child>
|
|
| 26 |
- <child>
|
|
| 27 |
- <object class="GtkImage">
|
|
| 28 |
- <property name="visible">True</property>
|
|
| 29 |
- <property name="can_focus">False</property>
|
|
| 30 |
- <property name="icon_name">system-users-symbolic</property>
|
|
| 31 |
- <property name="icon_size">6</property>
|
|
| 32 |
- </object>
|
|
| 33 |
- <packing>
|
|
| 34 |
- <property name="left_attach">0</property>
|
|
| 35 |
- <property name="top_attach">1</property>
|
|
| 36 |
- </packing>
|
|
| 37 |
- </child>
|
|
| 38 |
- <child>
|
|
| 39 |
- <object class="GtkLabel">
|
|
| 40 |
- <property name="visible">True</property>
|
|
| 41 |
- <property name="can_focus">False</property>
|
|
| 42 |
- <property name="label" translatable="yes">Group Chat Invitation</property>
|
|
| 43 |
- <style>
|
|
| 44 |
- <class name="large-header"/>
|
|
| 45 |
- </style>
|
|
| 46 |
- </object>
|
|
| 47 |
- <packing>
|
|
| 48 |
- <property name="left_attach">0</property>
|
|
| 49 |
- <property name="top_attach">0</property>
|
|
| 50 |
- <property name="width">2</property>
|
|
| 51 |
- </packing>
|
|
| 52 |
- </child>
|
|
| 53 |
- <child>
|
|
| 54 |
- <object class="GtkBox">
|
|
| 55 |
- <property name="visible">True</property>
|
|
| 56 |
- <property name="can_focus">False</property>
|
|
| 57 |
- <property name="margin_top">12</property>
|
|
| 58 |
- <property name="spacing">6</property>
|
|
| 59 |
- <property name="homogeneous">True</property>
|
|
| 60 |
- <child>
|
|
| 61 |
- <object class="GtkButton" id="decline_button">
|
|
| 62 |
- <property name="label" translatable="yes">_Decline</property>
|
|
| 63 |
- <property name="visible">True</property>
|
|
| 64 |
- <property name="can_focus">True</property>
|
|
| 65 |
- <property name="receives_default">True</property>
|
|
| 66 |
- <property name="use_underline">True</property>
|
|
| 67 |
- <signal name="clicked" handler="on_decline_button_clicked" swapped="no"/>
|
|
| 68 |
- </object>
|
|
| 69 |
- <packing>
|
|
| 70 |
- <property name="expand">False</property>
|
|
| 71 |
- <property name="fill">True</property>
|
|
| 72 |
- <property name="position">0</property>
|
|
| 73 |
- </packing>
|
|
| 74 |
- </child>
|
|
| 75 |
- <child>
|
|
| 76 |
- <object class="GtkButton" id="accept_button">
|
|
| 77 |
- <property name="label" translatable="yes">_Accept</property>
|
|
| 78 |
- <property name="visible">True</property>
|
|
| 79 |
- <property name="can_focus">True</property>
|
|
| 80 |
- <property name="receives_default">True</property>
|
|
| 81 |
- <property name="use_underline">True</property>
|
|
| 82 |
- <signal name="clicked" handler="on_accept_button_clicked" swapped="no"/>
|
|
| 83 |
- <style>
|
|
| 84 |
- <class name="suggested-action"/>
|
|
| 85 |
- </style>
|
|
| 86 |
- </object>
|
|
| 87 |
- <packing>
|
|
| 88 |
- <property name="expand">False</property>
|
|
| 89 |
- <property name="fill">True</property>
|
|
| 90 |
- <property name="position">1</property>
|
|
| 91 |
- </packing>
|
|
| 92 |
- </child>
|
|
| 93 |
- </object>
|
|
| 94 |
- <packing>
|
|
| 95 |
- <property name="left_attach">0</property>
|
|
| 96 |
- <property name="top_attach">4</property>
|
|
| 97 |
- <property name="width">2</property>
|
|
| 98 |
- </packing>
|
|
| 99 |
- </child>
|
|
| 100 |
- <child>
|
|
| 101 |
- <object class="GtkExpander" id="message_expander">
|
|
| 102 |
- <property name="visible">True</property>
|
|
| 103 |
- <property name="can_focus">True</property>
|
|
| 104 |
- <property name="margin_top">6</property>
|
|
| 105 |
- <property name="resize_toplevel">True</property>
|
|
| 106 |
- <child>
|
|
| 107 |
- <object class="GtkEntry" id="decline_message">
|
|
| 108 |
- <property name="visible">True</property>
|
|
| 109 |
- <property name="can_focus">True</property>
|
|
| 110 |
- <property name="margin_top">6</property>
|
|
| 111 |
- <property name="placeholder_text" translatable="yes">Message...</property>
|
|
| 112 |
- <property name="show_emoji_icon">True</property>
|
|
| 113 |
- </object>
|
|
| 114 |
- </child>
|
|
| 115 |
- <child type="label">
|
|
| 116 |
- <object class="GtkLabel">
|
|
| 117 |
- <property name="visible">True</property>
|
|
| 118 |
- <property name="can_focus">False</property>
|
|
| 119 |
- <property name="margin_left">6</property>
|
|
| 120 |
- <property name="label" translatable="yes">_Message if you decline (optional)</property>
|
|
| 121 |
- <property name="use_underline">True</property>
|
|
| 122 |
- <property name="mnemonic_widget">decline_message</property>
|
|
| 123 |
- <signal name="mnemonic-activate" handler="on_message_mnemonic_activate" swapped="no"/>
|
|
| 124 |
- <style>
|
|
| 125 |
- <class name="dim-label"/>
|
|
| 126 |
- </style>
|
|
| 127 |
- </object>
|
|
| 128 |
- </child>
|
|
| 129 |
- </object>
|
|
| 130 |
- <packing>
|
|
| 131 |
- <property name="left_attach">1</property>
|
|
| 132 |
- <property name="top_attach">3</property>
|
|
| 133 |
- </packing>
|
|
| 134 |
- </child>
|
|
| 135 |
- <child>
|
|
| 136 |
- <object class="GtkLabel" id="comment_label">
|
|
| 137 |
- <property name="can_focus">False</property>
|
|
| 138 |
- <property name="no_show_all">True</property>
|
|
| 139 |
- <property name="label"><comment></property>
|
|
| 140 |
- <property name="wrap">True</property>
|
|
| 141 |
- <property name="max_width_chars">50</property>
|
|
| 142 |
- <property name="xalign">0</property>
|
|
| 143 |
- </object>
|
|
| 144 |
- <packing>
|
|
| 145 |
- <property name="left_attach">1</property>
|
|
| 146 |
- <property name="top_attach">2</property>
|
|
| 147 |
- </packing>
|
|
| 148 |
- </child>
|
|
| 149 |
- <child>
|
|
| 150 |
- <placeholder/>
|
|
| 151 |
- </child>
|
|
| 152 |
- <child>
|
|
| 153 |
- <placeholder/>
|
|
| 154 |
- </child>
|
|
| 155 |
- </object>
|
|
| 156 |
-</interface>
|
| ... | ... | @@ -129,4 +129,5 @@ WINDOW_MODULES = { |
| 129 | 129 |
'PluginsWindow': 'gajim.plugins.gui',
|
| 130 | 130 |
'Features': 'gajim.gtk.features',
|
| 131 | 131 |
'StatusChange': 'gajim.gtk.status_change',
|
| 132 |
+ 'GroupChatInvitation': 'gajim.gtk.groupchat_invitation',
|
|
| 132 | 133 |
}
|
| ... | ... | @@ -295,64 +295,6 @@ class CertificateDialog(Gtk.ApplicationWindow): |
| 295 | 295 |
self._clipboard.set_text(clipboard_text, -1)
|
| 296 | 296 |
|
| 297 | 297 |
|
| 298 |
-class InvitationReceivedDialog(Gtk.ApplicationWindow):
|
|
| 299 |
- def __init__(self, account, event):
|
|
| 300 |
- Gtk.ApplicationWindow.__init__(self)
|
|
| 301 |
- self.set_name('InvitationReceivedDialog')
|
|
| 302 |
- self.set_application(app.app)
|
|
| 303 |
- self.set_position(Gtk.WindowPosition.CENTER)
|
|
| 304 |
- self.set_resizable(False)
|
|
| 305 |
- self.set_show_menubar(False)
|
|
| 306 |
- self.set_title(_('Group Chat Invitation '))
|
|
| 307 |
- |
|
| 308 |
- self._ui = get_builder('groupchat_invitation_received.ui')
|
|
| 309 |
- self.add(self._ui.grid)
|
|
| 310 |
- self.show_all()
|
|
| 311 |
- self._ui.connect_signals(self)
|
|
| 312 |
- |
|
| 313 |
- self.account = account
|
|
| 314 |
- self.room_jid = str(event.muc)
|
|
| 315 |
- self.from_ = str(event.from_)
|
|
| 316 |
- self.password = event.password
|
|
| 317 |
- |
|
| 318 |
- if event.from_.bare_match(event.muc):
|
|
| 319 |
- contact_text = event.from_.resource
|
|
| 320 |
- else:
|
|
| 321 |
- contact = app.contacts.get_first_contact_from_jid(
|
|
| 322 |
- self.account, event.from_.bare)
|
|
| 323 |
- if contact is None:
|
|
| 324 |
- contact_text = str(event.from_)
|
|
| 325 |
- else:
|
|
| 326 |
- contact_text = contact.get_shown_name()
|
|
| 327 |
- |
|
| 328 |
- invitation_label = _('<b>%(contact)s</b> has invited you to the '
|
|
| 329 |
- 'group chat <b>%(room_jid)s</b>') % \
|
|
| 330 |
- {'contact': contact_text,
|
|
| 331 |
- 'room_jid': self.room_jid}
|
|
| 332 |
- self._ui.invitation_label.set_markup(invitation_label)
|
|
| 333 |
- |
|
| 334 |
- if event.reason:
|
|
| 335 |
- comment = GLib.markup_escape_text(event.reason)
|
|
| 336 |
- comment = _('Comment: %s') % comment
|
|
| 337 |
- self._ui.comment_label.show()
|
|
| 338 |
- self._ui.comment_label.set_text(comment)
|
|
| 339 |
- |
|
| 340 |
- def on_message_mnemonic_activate(self, _widget, _group_cycling=False):
|
|
| 341 |
- self._ui.message_expander.set_expanded(True)
|
|
| 342 |
- |
|
| 343 |
- def on_accept_button_clicked(self, _widget):
|
|
| 344 |
- app.interface.show_or_join_groupchat(self.account,
|
|
| 345 |
- self.room_jid,
|
|
| 346 |
- password=self.password)
|
|
| 347 |
- self.destroy()
|
|
| 348 |
- |
|
| 349 |
- def on_decline_button_clicked(self, _widget):
|
|
| 350 |
- text = self._ui.decline_message.get_text()
|
|
| 351 |
- app.connections[self.account].get_module('MUC').decline(
|
|
| 352 |
- self.room_jid, self.from_, text)
|
|
| 353 |
- self.destroy()
|
|
| 354 |
- |
|
| 355 |
- |
|
| 356 | 298 |
class PassphraseDialog:
|
| 357 | 299 |
"""
|
| 358 | 300 |
Class for Passphrase dialog
|
| ... | ... | @@ -101,14 +101,23 @@ class GroupChatInfoScrolled(Gtk.ScrolledWindow): |
| 101 | 101 |
Gtk.ScrolledWindow.__init__(self)
|
| 102 | 102 |
if options is None:
|
| 103 | 103 |
options = {}
|
| 104 |
+ |
|
| 105 |
+ self._minimal = options.get('minimal', False)
|
|
| 106 |
+ |
|
| 104 | 107 |
self.set_size_request(options.get('width', 400), -1)
|
| 105 | 108 |
self.set_halign(Gtk.Align.CENTER)
|
| 106 |
- self.set_vexpand(True)
|
|
| 107 |
- self.set_min_content_height(400)
|
|
| 108 |
- self.set_policy(Gtk.PolicyType.NEVER,
|
|
| 109 |
- Gtk.PolicyType.AUTOMATIC)
|
|
| 109 |
+ |
|
| 110 |
+ if self._minimal:
|
|
| 111 |
+ self.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
|
|
| 112 |
+ else:
|
|
| 113 |
+ self.set_vexpand(True)
|
|
| 114 |
+ self.set_min_content_height(400)
|
|
| 115 |
+ self.set_policy(Gtk.PolicyType.NEVER,
|
|
| 116 |
+ Gtk.PolicyType.AUTOMATIC)
|
|
| 117 |
+ |
|
| 110 | 118 |
self._account = account
|
| 111 | 119 |
self._info = None
|
| 120 |
+ |
|
| 112 | 121 |
self._ui = get_builder('groupchat_info_scrolled.ui')
|
| 113 | 122 |
self.add(self._ui.info_grid)
|
| 114 | 123 |
self._ui.connect_signals(self)
|
| ... | ... | @@ -165,6 +174,12 @@ class GroupChatInfoScrolled(Gtk.ScrolledWindow): |
| 165 | 174 |
self._ui.description.set_visible(has_desc)
|
| 166 | 175 |
self._ui.description_label.set_visible(has_desc)
|
| 167 | 176 |
|
| 177 |
+ # Set address
|
|
| 178 |
+ self._ui.address.set_text(str(info.jid))
|
|
| 179 |
+ |
|
| 180 |
+ if self._minimal:
|
|
| 181 |
+ return
|
|
| 182 |
+ |
|
| 168 | 183 |
# Set subject
|
| 169 | 184 |
self.set_subject(info.muc_subject)
|
| 170 | 185 |
|
| ... | ... | @@ -174,9 +189,6 @@ class GroupChatInfoScrolled(Gtk.ScrolledWindow): |
| 174 | 189 |
self._ui.users.set_visible(has_users)
|
| 175 | 190 |
self._ui.users_image.set_visible(has_users)
|
| 176 | 191 |
|
| 177 |
- # Set address
|
|
| 178 |
- self._ui.address.set_text(str(info.jid))
|
|
| 179 |
- |
|
| 180 | 192 |
# Set contacts
|
| 181 | 193 |
self._ui.contact_box.foreach(self._ui.contact_box.remove)
|
| 182 | 194 |
has_contacts = bool(info.muc_contacts)
|
| 1 |
+# This file is part of Gajim.
|
|
| 2 |
+#
|
|
| 3 |
+# Gajim is free software; you can redistribute it and/or modify
|
|
| 4 |
+# it under the terms of the GNU General Public License as published
|
|
| 5 |
+# by the Free Software Foundation; version 3 only.
|
|
| 6 |
+#
|
|
| 7 |
+# Gajim is distributed in the hope that it will be useful,
|
|
| 8 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 9 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 10 |
+# GNU General Public License for more details.
|
|
| 11 |
+#
|
|
| 12 |
+# You should have received a copy of the GNU General Public License
|
|
| 13 |
+# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
| 14 |
+ |
|
| 15 |
+from gi.repository import Gdk
|
|
| 16 |
+from gi.repository import Gtk
|
|
| 17 |
+ |
|
| 18 |
+from gajim.common import app
|
|
| 19 |
+from gajim.common.i18n import _
|
|
| 20 |
+from gajim.common.helpers import get_group_chat_nick
|
|
| 21 |
+ |
|
| 22 |
+from gajim.gtk.groupchat_info import GroupChatInfoScrolled
|
|
| 23 |
+from gajim.gtk.groupchat_nick import NickChooser
|
|
| 24 |
+ |
|
| 25 |
+ |
|
| 26 |
+class GroupChatInvitation(Gtk.ApplicationWindow):
|
|
| 27 |
+ def __init__(self, account, event):
|
|
| 28 |
+ Gtk.ApplicationWindow.__init__(self)
|
|
| 29 |
+ self.set_name('GroupChatInvitation')
|
|
| 30 |
+ self.set_application(app.app)
|
|
| 31 |
+ self.set_position(Gtk.WindowPosition.CENTER)
|
|
| 32 |
+ self.set_show_menubar(False)
|
|
| 33 |
+ self.set_title(_('Group Chat Invitation'))
|
|
| 34 |
+ self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
|
| 35 |
+ |
|
| 36 |
+ self.account = account
|
|
| 37 |
+ self._room_jid = str(event.muc)
|
|
| 38 |
+ self._from = str(event.from_)
|
|
| 39 |
+ self._password = event.password
|
|
| 40 |
+ |
|
| 41 |
+ main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
|
| 42 |
+ main_box.set_valign(Gtk.Align.FILL)
|
|
| 43 |
+ main_box.get_style_context().add_class('padding-18')
|
|
| 44 |
+ |
|
| 45 |
+ muc_info_box = GroupChatInfoScrolled(account, {'minimal': True})
|
|
| 46 |
+ muc_info_box.set_from_disco_info(event.info)
|
|
| 47 |
+ |
|
| 48 |
+ main_box.add(muc_info_box)
|
|
| 49 |
+ |
|
| 50 |
+ separator = Gtk.Separator()
|
|
| 51 |
+ contact_label = Gtk.Label(label=event.get_inviter_name())
|
|
| 52 |
+ contact_label.get_style_context().add_class('bold16')
|
|
| 53 |
+ contact_label.set_halign(Gtk.Align.CENTER)
|
|
| 54 |
+ contact_label.set_justify(Gtk.Justification.CENTER)
|
|
| 55 |
+ contact_label.set_line_wrap(True)
|
|
| 56 |
+ invitation_label = Gtk.Label(
|
|
| 57 |
+ label=_('Has invited you to a group chat.\nDo you want to join?'))
|
|
| 58 |
+ invitation_label.set_halign(Gtk.Align.CENTER)
|
|
| 59 |
+ invitation_label.set_justify(Gtk.Justification.CENTER)
|
|
| 60 |
+ invitation_label.set_max_width_chars(50)
|
|
| 61 |
+ invitation_label.set_line_wrap(True)
|
|
| 62 |
+ |
|
| 63 |
+ main_box.add(separator)
|
|
| 64 |
+ main_box.add(contact_label)
|
|
| 65 |
+ main_box.add(invitation_label)
|
|
| 66 |
+ |
|
| 67 |
+ decline_button = Gtk.Button.new_with_mnemonic(_('_Decline'))
|
|
| 68 |
+ decline_button.set_halign(Gtk.Align.START)
|
|
| 69 |
+ decline_button.connect('clicked', self._on_decline)
|
|
| 70 |
+ |
|
| 71 |
+ self._nick_chooser = NickChooser()
|
|
| 72 |
+ self._nick_chooser.set_text(
|
|
| 73 |
+ get_group_chat_nick(self.account, event.info.jid))
|
|
| 74 |
+ |
|
| 75 |
+ join_button = Gtk.Button.new_with_mnemonic(_('_Join'))
|
|
| 76 |
+ join_button.set_halign(Gtk.Align.END)
|
|
| 77 |
+ join_button.get_style_context().add_class('suggested-action')
|
|
| 78 |
+ join_button.connect('clicked', self._on_join)
|
|
| 79 |
+ |
|
| 80 |
+ join_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
|
| 81 |
+ join_box.get_style_context().add_class('linked')
|
|
| 82 |
+ join_box.set_halign(Gtk.Align.END)
|
|
| 83 |
+ join_box.add(self._nick_chooser)
|
|
| 84 |
+ join_box.add(join_button)
|
|
| 85 |
+ |
|
| 86 |
+ button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
|
| 87 |
+ button_box.set_margin_top(6)
|
|
| 88 |
+ button_box.pack_start(decline_button, False, False, 0)
|
|
| 89 |
+ button_box.pack_end(join_box, False, False, 0)
|
|
| 90 |
+ |
|
| 91 |
+ main_box.add(button_box)
|
|
| 92 |
+ |
|
| 93 |
+ self.connect('key-press-event', self._on_key_press_event)
|
|
| 94 |
+ |
|
| 95 |
+ self.add(main_box)
|
|
| 96 |
+ |
|
| 97 |
+ join_button.set_can_default(True)
|
|
| 98 |
+ join_button.grab_focus()
|
|
| 99 |
+ |
|
| 100 |
+ self.show_all()
|
|
| 101 |
+ |
|
| 102 |
+ def _on_key_press_event(self, _widget, event):
|
|
| 103 |
+ if event.keyval == Gdk.KEY_Escape:
|
|
| 104 |
+ self.destroy()
|
|
| 105 |
+ |
|
| 106 |
+ def _on_join(self, _widget):
|
|
| 107 |
+ nickname = self._nick_chooser.get_text()
|
|
| 108 |
+ app.interface.show_or_join_groupchat(self.account,
|
|
| 109 |
+ self._room_jid,
|
|
| 110 |
+ nick=nickname,
|
|
| 111 |
+ password=self._password)
|
|
| 112 |
+ self.destroy()
|
|
| 113 |
+ |
|
| 114 |
+ def _on_decline(self, _widget):
|
|
| 115 |
+ app.connections[self.account].get_module('MUC').decline(
|
|
| 116 |
+ self._room_jid, self._from)
|
|
| 117 |
+ self.destroy()
|
| ... | ... | @@ -98,7 +98,6 @@ from gajim.gtk.dialogs import ConfirmationDialog |
| 98 | 98 |
from gajim.gtk.dialogs import ConfirmationCheckDialog
|
| 99 | 99 |
from gajim.gtk.dialogs import InputDialog
|
| 100 | 100 |
from gajim.gtk.dialogs import PassphraseDialog
|
| 101 |
-from gajim.gtk.dialogs import InvitationReceivedDialog
|
|
| 102 | 101 |
from gajim.gtk.filechoosers import FileChooserDialog
|
| 103 | 102 |
from gajim.gtk.emoji_data import emoji_data
|
| 104 | 103 |
from gajim.gtk.emoji_data import emoji_ascii_data
|
| ... | ... | @@ -376,28 +375,29 @@ class Interface: |
| 376 | 375 |
'jid': event.from_})
|
| 377 | 376 |
|
| 378 | 377 |
def handle_event_gc_invitation(self, event):
|
| 379 |
- if helpers.allow_popup_window(event.account) or not self.systray_enabled:
|
|
| 380 |
- InvitationReceivedDialog(event.account, event)
|
|
| 381 |
- return
|
|
| 378 |
+ event = events.GcInvitationtEvent(event)
|
|
| 382 | 379 |
|
| 383 |
- from_ = str(event.from_)
|
|
| 384 |
- muc = str(event.muc)
|
|
| 380 |
+ if (helpers.allow_popup_window(event.account) or
|
|
| 381 |
+ not self.systray_enabled):
|
|
| 382 |
+ open_window('GroupChatInvitation',
|
|
| 383 |
+ account=event.account,
|
|
| 384 |
+ event=event)
|
|
| 385 |
+ return
|
|
| 385 | 386 |
|
| 386 |
- event_ = events.GcInvitationtEvent(event)
|
|
| 387 |
- self.add_event(event.account, from_, event_)
|
|
| 387 |
+ self.add_event(event.account, str(event.from_), event)
|
|
| 388 | 388 |
|
| 389 | 389 |
if helpers.allow_showing_notification(event.account):
|
| 390 |
+ contact_name = event.get_inviter_name()
|
|
| 390 | 391 |
event_type = _('Group Chat Invitation')
|
| 391 |
- text = _('You are invited to {room} by {user}').format(room=muc,
|
|
| 392 |
- user=from_)
|
|
| 392 |
+ text = _(f'{contact_name} invited you to {event.info.muc_name}')
|
|
| 393 | 393 |
app.notification.popup(event_type,
|
| 394 |
- from_,
|
|
| 394 |
+ str(event.from_),
|
|
| 395 | 395 |
event.account,
|
| 396 | 396 |
'gc-invitation',
|
| 397 | 397 |
'gajim-gc_invitation',
|
| 398 | 398 |
event_type,
|
| 399 | 399 |
text,
|
| 400 |
- room_jid=muc)
|
|
| 400 |
+ room_jid=event.muc)
|
|
| 401 | 401 |
|
| 402 | 402 |
@staticmethod
|
| 403 | 403 |
def handle_event_client_cert_passphrase(obj):
|
| ... | ... | @@ -1165,7 +1165,9 @@ class Interface: |
| 1165 | 1165 |
event = app.events.get_first_event(account, jid, type_)
|
| 1166 | 1166 |
if event is None:
|
| 1167 | 1167 |
return
|
| 1168 |
- InvitationReceivedDialog(account, event)
|
|
| 1168 |
+ open_window('GroupChatInvitation',
|
|
| 1169 |
+ account=account,
|
|
| 1170 |
+ event=event)
|
|
| 1169 | 1171 |
app.events.remove_events(account, jid, event)
|
| 1170 | 1172 |
self.roster.draw_contact(jid, account)
|
| 1171 | 1173 |
elif type_ == 'subscription_request':
|
| ... | ... | @@ -68,7 +68,6 @@ from gajim.gtk.dialogs import ErrorDialog |
| 68 | 68 |
from gajim.gtk.dialogs import InputDialog
|
| 69 | 69 |
from gajim.gtk.dialogs import WarningDialog
|
| 70 | 70 |
from gajim.gtk.dialogs import InformationDialog
|
| 71 |
-from gajim.gtk.dialogs import InvitationReceivedDialog
|
|
| 72 | 71 |
from gajim.gtk.single_message import SingleMessageWindow
|
| 73 | 72 |
from gajim.gtk.add_contact import AddNewContactWindow
|
| 74 | 73 |
from gajim.gtk.service_registration import ServiceRegistration
|
| ... | ... | @@ -1918,7 +1917,9 @@ class RosterWindow: |
| 1918 | 1917 |
return True
|
| 1919 | 1918 |
|
| 1920 | 1919 |
if event.type_ == 'gc-invitation':
|
| 1921 |
- InvitationReceivedDialog(account, event)
|
|
| 1920 |
+ open_window('GroupChatInvitation',
|
|
| 1921 |
+ account=account,
|
|
| 1922 |
+ event=event)
|
|
| 1922 | 1923 |
app.events.remove_events(account, jid, event)
|
| 1923 | 1924 |
return True
|
| 1924 | 1925 |
|