Rework InvitationReceivedDialog
This commit is contained in:
parent
239ab1455b
commit
318ae4e9d4
|
@ -0,0 +1,156 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">18</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="invitation_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label"><b>contact/jid</b> has invited you to the group chat <b>muc.jid</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="max_width_chars">70</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">system-users-symbolic</property>
|
||||
<property name="icon_size">6</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Group Chat Invitation</property>
|
||||
<style>
|
||||
<class name="large-header"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">12</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="decline_button">
|
||||
<property name="label" translatable="yes">_Decline</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="clicked" handler="on_decline_button_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="accept_button">
|
||||
<property name="label" translatable="yes">_Accept</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="clicked" handler="on_accept_button_clicked" swapped="no"/>
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="message_expander">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="resize_toplevel">True</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="decline_message">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="placeholder_text" translatable="yes">Message...</property>
|
||||
<property name="show_emoji_icon">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">6</property>
|
||||
<property name="label" translatable="yes">_Message if you decline (optional)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">decline_message</property>
|
||||
<signal name="mnemonic-activate" handler="on_message_mnemonic_activate" swapped="no"/>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="comment_label">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="no_show_all">True</property>
|
||||
<property name="label"><comment></property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="max_width_chars">70</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -910,6 +910,7 @@ class SynchroniseSelectAccountDialog:
|
|||
def on_destroy(widget):
|
||||
del app.interface.instances['import_contacts']
|
||||
|
||||
|
||||
class SynchroniseSelectContactsDialog:
|
||||
def __init__(self, account, remote_account):
|
||||
self.local_account = account
|
||||
|
@ -1208,63 +1209,6 @@ class RosterItemExchangeWindow:
|
|||
self.window.destroy()
|
||||
|
||||
|
||||
class InvitationReceivedDialog:
|
||||
def __init__(self, account, event):
|
||||
self.account = account
|
||||
self.room_jid = str(event.muc)
|
||||
self.from_ = str(event.from_)
|
||||
self.password = event.password
|
||||
self.is_continued = event.continued
|
||||
|
||||
if event.from_.bareMatch(event.muc):
|
||||
contact_text = event.from_.getResource()
|
||||
else:
|
||||
contact = app.contacts.get_first_contact_from_jid(
|
||||
account, event.from_.getBare())
|
||||
if contact is None:
|
||||
contact_text = str(event.from_)
|
||||
else:
|
||||
contact_text = contact.get_shown_name()
|
||||
|
||||
pritext = _('''You are invited to a groupchat''')
|
||||
#Don't translate $Contact
|
||||
if self.is_continued:
|
||||
sectext = _('$Contact has invited you to join a discussion')
|
||||
else:
|
||||
sectext = _('$Contact has invited you to group chat %(room_jid)s')\
|
||||
% {'room_jid': self.room_jid}
|
||||
|
||||
sectext = sectext.replace('$Contact', contact_text)
|
||||
|
||||
if event.reason:
|
||||
comment = GLib.markup_escape_text(event.reason)
|
||||
comment = _('Comment: %s') % comment
|
||||
sectext += '\n\n%s' % comment
|
||||
sectext += '\n\n' + _('Do you want to accept the invitation?')
|
||||
|
||||
def on_yes(_checked, _text):
|
||||
if self.is_continued:
|
||||
app.interface.join_gc_room(self.account,
|
||||
self.room_jid,
|
||||
app.nicks[self.account],
|
||||
self.password,
|
||||
is_continued=True)
|
||||
else:
|
||||
app.interface.join_gc_minimal(self.account,
|
||||
self.room_jid,
|
||||
password=self.password)
|
||||
|
||||
def on_no(text):
|
||||
app.connections[account].get_module('MUC').decline(
|
||||
self.room_jid, self.from_, text)
|
||||
|
||||
dlg = YesNoDialog(pritext,
|
||||
sectext,
|
||||
text_label=_('Reason (if you decline):'),
|
||||
on_response_yes=on_yes,
|
||||
on_response_no=on_no)
|
||||
dlg.set_title(_('Groupchat Invitation'))
|
||||
|
||||
class ProgressDialog:
|
||||
def __init__(self, title_text, during_text, messages_queue):
|
||||
"""
|
||||
|
|
|
@ -16,6 +16,7 @@ from datetime import datetime
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
|
||||
|
@ -998,6 +999,76 @@ class ChangePasswordDialog(Gtk.Dialog):
|
|||
self._password2_entry.set_sensitive(True)
|
||||
|
||||
|
||||
class InvitationReceivedDialog(Gtk.ApplicationWindow):
|
||||
def __init__(self, account, event):
|
||||
Gtk.ApplicationWindow.__init__(self)
|
||||
self.set_name('InvitationReceivedDialog')
|
||||
self.set_application(app.app)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.set_show_menubar(False)
|
||||
self.set_title(_('Group Chat Invitation '))
|
||||
|
||||
self._ui = get_builder('groupchat_invitation_received.ui')
|
||||
self.add(self._ui.grid)
|
||||
self.show_all()
|
||||
self._ui.connect_signals(self)
|
||||
|
||||
self.account = account
|
||||
self.room_jid = str(event.muc)
|
||||
self.from_ = str(event.from_)
|
||||
self.password = event.password
|
||||
self.is_continued = event.continued
|
||||
|
||||
if event.from_.bareMatch(event.muc):
|
||||
contact_text = event.from_.getResource()
|
||||
else:
|
||||
contact = app.contacts.get_first_contact_from_jid(
|
||||
self.account, event.from_.getBare())
|
||||
if contact is None:
|
||||
contact_text = str(event.from_)
|
||||
else:
|
||||
contact_text = contact.get_shown_name()
|
||||
|
||||
# is_continued when invited from 1:1 chat
|
||||
if self.is_continued:
|
||||
invitation_label = _('<b>%s</b> has invited you to join '
|
||||
'a discussion') % contact_text
|
||||
else:
|
||||
invitation_label = _('<b>%(contact)s</b> has invited you to the '
|
||||
'group chat <b>%(room_jid)s</b>') % \
|
||||
{'contact': contact_text,
|
||||
'room_jid': self.room_jid}
|
||||
self._ui.invitation_label.set_markup(invitation_label)
|
||||
|
||||
if event.reason:
|
||||
comment = GLib.markup_escape_text(event.reason)
|
||||
comment = _('Comment: %s') % comment
|
||||
self._ui.comment_label.show()
|
||||
self._ui.comment_label.set_text(comment)
|
||||
|
||||
def on_message_mnemonic_activate(self, widget, group_cycling=False):
|
||||
self._ui.message_expander.set_expanded(True)
|
||||
|
||||
def on_accept_button_clicked(self, widget):
|
||||
if self.is_continued:
|
||||
app.interface.join_gc_room(self.account,
|
||||
self.room_jid,
|
||||
app.nicks[self.account],
|
||||
self.password,
|
||||
is_continued=True)
|
||||
else:
|
||||
app.interface.join_gc_minimal(self.account,
|
||||
self.room_jid,
|
||||
password=self.password)
|
||||
self.destroy()
|
||||
|
||||
def on_decline_button_clicked(self, widget):
|
||||
text = self._ui.decline_message.get_text()
|
||||
app.connections[self.account].get_module('MUC').decline(
|
||||
self.room_jid, self.from_, text)
|
||||
self.destroy()
|
||||
|
||||
|
||||
class NewConfirmationDialog(Gtk.MessageDialog):
|
||||
def __init__(self, title, text, sec_text, buttons,
|
||||
modal=True, transient_for=None):
|
||||
|
|
|
@ -112,6 +112,7 @@ from gajim.gtk.dialogs import YesNoDialog
|
|||
from gajim.gtk.dialogs import PlainConnectionDialog
|
||||
from gajim.gtk.dialogs import SSLErrorDialog
|
||||
from gajim.gtk.dialogs import ChangeNickDialog
|
||||
from gajim.gtk.dialogs import InvitationReceivedDialog
|
||||
from gajim.gtk.profile import ProfileWindow
|
||||
from gajim.gtk.join_groupchat import JoinGroupchatWindow
|
||||
from gajim.gtk.filechoosers import FileChooserDialog
|
||||
|
@ -548,7 +549,7 @@ class Interface:
|
|||
|
||||
def handle_event_gc_invitation(self, event):
|
||||
if helpers.allow_popup_window(event.account) or not self.systray_enabled:
|
||||
dialogs.InvitationReceivedDialog(event.account, event)
|
||||
InvitationReceivedDialog(event.account, event)
|
||||
return
|
||||
|
||||
from_ = str(event.from_)
|
||||
|
@ -1467,7 +1468,7 @@ class Interface:
|
|||
event = app.events.get_first_event(account, jid, type_)
|
||||
if event is None:
|
||||
return
|
||||
dialogs.InvitationReceivedDialog(account, event)
|
||||
InvitationReceivedDialog(account, event)
|
||||
app.events.remove_events(account, jid, event)
|
||||
self.roster.draw_contact(jid, account)
|
||||
elif type_ == 'subscription_request':
|
||||
|
|
|
@ -73,6 +73,7 @@ from gajim.gtk.dialogs import InformationDialog
|
|||
from gajim.gtk.dialogs import NonModalConfirmationDialog
|
||||
from gajim.gtk.dialogs import NewConfirmationCheckDialog
|
||||
from gajim.gtk.dialogs import DialogButton
|
||||
from gajim.gtk.dialogs import InvitationReceivedDialog
|
||||
from gajim.gtk.join_groupchat import JoinGroupchatWindow
|
||||
from gajim.gtk.single_message import SingleMessageWindow
|
||||
from gajim.gtk.add_contact import AddNewContactWindow
|
||||
|
@ -1977,7 +1978,7 @@ class RosterWindow:
|
|||
return True
|
||||
|
||||
if event.type_ == 'gc-invitation':
|
||||
dialogs.InvitationReceivedDialog(account, event)
|
||||
InvitationReceivedDialog(account, event)
|
||||
app.events.remove_events(account, jid, event)
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue