Philipp Hörist pushed to branch master at gajim / gajim

Commits:

5 changed files:

Changes:

  • gajim/data/gui/groupchat_invitation_received.ui
    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">&lt;b&gt;contact/jid&lt;/b&gt; has invited you to the group chat &lt;b&gt;muc.jid&lt;/b&gt;</property>
    
    16
    +        <property name="use_markup">True</property>
    
    17
    +        <property name="wrap">True</property>
    
    18
    +        <property name="max_width_chars">70</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">&lt;comment&gt;</property>
    
    140
    +        <property name="wrap">True</property>
    
    141
    +        <property name="max_width_chars">70</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>

  • gajim/dialogs.py
    ... ... @@ -910,6 +910,7 @@ class SynchroniseSelectAccountDialog:
    910 910
         def on_destroy(widget):
    
    911 911
             del app.interface.instances['import_contacts']
    
    912 912
     
    
    913
    +
    
    913 914
     class SynchroniseSelectContactsDialog:
    
    914 915
         def __init__(self, account, remote_account):
    
    915 916
             self.local_account = account
    
    ... ... @@ -1208,63 +1209,6 @@ class RosterItemExchangeWindow:
    1208 1209
             self.window.destroy()
    
    1209 1210
     
    
    1210 1211
     
    
    1211
    -class InvitationReceivedDialog:
    
    1212
    -    def __init__(self, account, event):
    
    1213
    -        self.account = account
    
    1214
    -        self.room_jid = str(event.muc)
    
    1215
    -        self.from_ = str(event.from_)
    
    1216
    -        self.password = event.password
    
    1217
    -        self.is_continued = event.continued
    
    1218
    -
    
    1219
    -        if event.from_.bareMatch(event.muc):
    
    1220
    -            contact_text = event.from_.getResource()
    
    1221
    -        else:
    
    1222
    -            contact = app.contacts.get_first_contact_from_jid(
    
    1223
    -                account, event.from_.getBare())
    
    1224
    -            if contact is None:
    
    1225
    -                contact_text = str(event.from_)
    
    1226
    -            else:
    
    1227
    -                contact_text = contact.get_shown_name()
    
    1228
    -
    
    1229
    -        pritext = _('''You are invited to a groupchat''')
    
    1230
    -        #Don't translate $Contact
    
    1231
    -        if self.is_continued:
    
    1232
    -            sectext = _('$Contact has invited you to join a discussion')
    
    1233
    -        else:
    
    1234
    -            sectext = _('$Contact has invited you to group chat %(room_jid)s')\
    
    1235
    -                % {'room_jid': self.room_jid}
    
    1236
    -
    
    1237
    -        sectext = sectext.replace('$Contact', contact_text)
    
    1238
    -
    
    1239
    -        if event.reason:
    
    1240
    -            comment = GLib.markup_escape_text(event.reason)
    
    1241
    -            comment = _('Comment: %s') % comment
    
    1242
    -            sectext += '\n\n%s' % comment
    
    1243
    -        sectext += '\n\n' + _('Do you want to accept the invitation?')
    
    1244
    -
    
    1245
    -        def on_yes(_checked, _text):
    
    1246
    -            if self.is_continued:
    
    1247
    -                app.interface.join_gc_room(self.account,
    
    1248
    -                                           self.room_jid,
    
    1249
    -                                           app.nicks[self.account],
    
    1250
    -                                           self.password,
    
    1251
    -                                           is_continued=True)
    
    1252
    -            else:
    
    1253
    -                app.interface.join_gc_minimal(self.account,
    
    1254
    -                                              self.room_jid,
    
    1255
    -                                              password=self.password)
    
    1256
    -
    
    1257
    -        def on_no(text):
    
    1258
    -            app.connections[account].get_module('MUC').decline(
    
    1259
    -                self.room_jid, self.from_, text)
    
    1260
    -
    
    1261
    -        dlg = YesNoDialog(pritext,
    
    1262
    -                          sectext,
    
    1263
    -                          text_label=_('Reason (if you decline):'),
    
    1264
    -                          on_response_yes=on_yes,
    
    1265
    -                          on_response_no=on_no)
    
    1266
    -        dlg.set_title(_('Groupchat Invitation'))
    
    1267
    -
    
    1268 1212
     class ProgressDialog:
    
    1269 1213
         def __init__(self, title_text, during_text, messages_queue):
    
    1270 1214
             """
    

  • gajim/gtk/dialogs.py
    ... ... @@ -16,6 +16,7 @@ from datetime import datetime
    16 16
     
    
    17 17
     from collections import namedtuple
    
    18 18
     
    
    19
    +from gi.repository import GLib
    
    19 20
     from gi.repository import Gtk
    
    20 21
     from gi.repository import Pango
    
    21 22
     
    
    ... ... @@ -998,6 +999,76 @@ class ChangePasswordDialog(Gtk.Dialog):
    998 999
             self._password2_entry.set_sensitive(True)
    
    999 1000
     
    
    1000 1001
     
    
    1002
    +class InvitationReceivedDialog(Gtk.ApplicationWindow):
    
    1003
    +    def __init__(self, account, event):
    
    1004
    +        Gtk.ApplicationWindow.__init__(self)
    
    1005
    +        self.set_name('InvitationReceivedDialog')
    
    1006
    +        self.set_application(app.app)
    
    1007
    +        self.set_position(Gtk.WindowPosition.CENTER)
    
    1008
    +        self.set_show_menubar(False)
    
    1009
    +        self.set_title(_('Group Chat Invitation '))
    
    1010
    +
    
    1011
    +        self._ui = get_builder('groupchat_invitation_received.ui')
    
    1012
    +        self.add(self._ui.grid)
    
    1013
    +        self.show_all()
    
    1014
    +        self._ui.connect_signals(self)
    
    1015
    +
    
    1016
    +        self.account = account
    
    1017
    +        self.room_jid = str(event.muc)
    
    1018
    +        self.from_ = str(event.from_)
    
    1019
    +        self.password = event.password
    
    1020
    +        self.is_continued = event.continued
    
    1021
    +
    
    1022
    +        if event.from_.bareMatch(event.muc):
    
    1023
    +            contact_text = event.from_.getResource()
    
    1024
    +        else:
    
    1025
    +            contact = app.contacts.get_first_contact_from_jid(
    
    1026
    +                self.account, event.from_.getBare())
    
    1027
    +            if contact is None:
    
    1028
    +                contact_text = str(event.from_)
    
    1029
    +            else:
    
    1030
    +                contact_text = contact.get_shown_name()
    
    1031
    +
    
    1032
    +        # is_continued when invited from 1:1 chat
    
    1033
    +        if self.is_continued:
    
    1034
    +            invitation_label = _('<b>%s</b> has invited you to join '
    
    1035
    +                                 'a discussion') % contact_text
    
    1036
    +        else:
    
    1037
    +            invitation_label = _('<b>%(contact)s</b> has invited you to the '
    
    1038
    +                                 'group chat <b>%(room_jid)s</b>') % \
    
    1039
    +                                {'contact': contact_text,
    
    1040
    +                                 'room_jid': self.room_jid}
    
    1041
    +        self._ui.invitation_label.set_markup(invitation_label)
    
    1042
    +
    
    1043
    +        if event.reason:
    
    1044
    +            comment = GLib.markup_escape_text(event.reason)
    
    1045
    +            comment = _('Comment: %s') % comment
    
    1046
    +            self._ui.comment_label.show()
    
    1047
    +            self._ui.comment_label.set_text(comment)
    
    1048
    +
    
    1049
    +    def on_message_mnemonic_activate(self, widget, group_cycling=False):
    
    1050
    +        self._ui.message_expander.set_expanded(True)
    
    1051
    +
    
    1052
    +    def on_accept_button_clicked(self, widget):
    
    1053
    +        if self.is_continued:
    
    1054
    +            app.interface.join_gc_room(self.account,
    
    1055
    +                                       self.room_jid,
    
    1056
    +                                       app.nicks[self.account],
    
    1057
    +                                       self.password,
    
    1058
    +                                       is_continued=True)
    
    1059
    +        else:
    
    1060
    +            app.interface.join_gc_minimal(self.account,
    
    1061
    +                                          self.room_jid,
    
    1062
    +                                          password=self.password)
    
    1063
    +        self.destroy()
    
    1064
    +
    
    1065
    +    def on_decline_button_clicked(self, widget):
    
    1066
    +        text = self._ui.decline_message.get_text()
    
    1067
    +        app.connections[self.account].get_module('MUC').decline(
    
    1068
    +            self.room_jid, self.from_, text)
    
    1069
    +        self.destroy()
    
    1070
    +
    
    1071
    +
    
    1001 1072
     class NewConfirmationDialog(Gtk.MessageDialog):
    
    1002 1073
         def __init__(self, title, text, sec_text, buttons,
    
    1003 1074
                      modal=True, transient_for=None):
    

  • gajim/gui_interface.py
    ... ... @@ -112,6 +112,7 @@ from gajim.gtk.dialogs import YesNoDialog
    112 112
     from gajim.gtk.dialogs import PlainConnectionDialog
    
    113 113
     from gajim.gtk.dialogs import SSLErrorDialog
    
    114 114
     from gajim.gtk.dialogs import ChangeNickDialog
    
    115
    +from gajim.gtk.dialogs import InvitationReceivedDialog
    
    115 116
     from gajim.gtk.profile import ProfileWindow
    
    116 117
     from gajim.gtk.join_groupchat import JoinGroupchatWindow
    
    117 118
     from gajim.gtk.filechoosers import FileChooserDialog
    
    ... ... @@ -548,7 +549,7 @@ class Interface:
    548 549
     
    
    549 550
         def handle_event_gc_invitation(self, event):
    
    550 551
             if helpers.allow_popup_window(event.account) or not self.systray_enabled:
    
    551
    -            dialogs.InvitationReceivedDialog(event.account, event)
    
    552
    +            InvitationReceivedDialog(event.account, event)
    
    552 553
                 return
    
    553 554
     
    
    554 555
             from_ = str(event.from_)
    
    ... ... @@ -1467,7 +1468,7 @@ class Interface:
    1467 1468
                 event = app.events.get_first_event(account, jid, type_)
    
    1468 1469
                 if event is None:
    
    1469 1470
                     return
    
    1470
    -            dialogs.InvitationReceivedDialog(account, event)
    
    1471
    +            InvitationReceivedDialog(account, event)
    
    1471 1472
                 app.events.remove_events(account, jid, event)
    
    1472 1473
                 self.roster.draw_contact(jid, account)
    
    1473 1474
             elif type_ == 'subscription_request':
    

  • gajim/roster_window.py
    ... ... @@ -73,6 +73,7 @@ from gajim.gtk.dialogs import InformationDialog
    73 73
     from gajim.gtk.dialogs import NonModalConfirmationDialog
    
    74 74
     from gajim.gtk.dialogs import NewConfirmationCheckDialog
    
    75 75
     from gajim.gtk.dialogs import DialogButton
    
    76
    +from gajim.gtk.dialogs import InvitationReceivedDialog
    
    76 77
     from gajim.gtk.join_groupchat import JoinGroupchatWindow
    
    77 78
     from gajim.gtk.single_message import SingleMessageWindow
    
    78 79
     from gajim.gtk.add_contact import AddNewContactWindow
    
    ... ... @@ -1977,7 +1978,7 @@ class RosterWindow:
    1977 1978
                 return True
    
    1978 1979
     
    
    1979 1980
             if event.type_ == 'gc-invitation':
    
    1980
    -            dialogs.InvitationReceivedDialog(account, event)
    
    1981
    +            InvitationReceivedDialog(account, event)
    
    1981 1982
                 app.events.remove_events(account, jid, event)
    
    1982 1983
                 return True
    
    1983 1984