Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
-
02cb001b
by wurstsalat at 2021-03-21T15:46:35+01:00
-
19a89a09
by wurstsalat at 2021-03-21T15:57:57+01:00
4 changed files:
- gajim/gtk/account_page.py
- gajim/gtk/groupchat_invitation.py
- gajim/gtk/notification_manager.py
- gajim/gui_interface.py
Changes:
| ... | ... | @@ -70,6 +70,8 @@ def __init__(self, account): |
| 70 | 70 |
self.register_events([
|
| 71 | 71 |
('subscribe-presence-received', ged.GUI1, self._subscribe_received),
|
| 72 | 72 |
('unsubscribed-presence-received', ged.GUI1, self._unsubscribed_received),
|
| 73 |
+ ('muc-invitation', ged.GUI1, self._muc_invitation_received),
|
|
| 74 |
+ ('muc-decline', ged.GUI1, self._muc_invitation_declined),
|
|
| 73 | 75 |
])
|
| 74 | 76 |
# pylint: enable=line-too-long
|
| 75 | 77 |
|
| ... | ... | @@ -109,11 +111,16 @@ def update(self): |
| 109 | 111 |
self._status_selector.update()
|
| 110 | 112 |
|
| 111 | 113 |
def _subscribe_received(self, event):
|
| 112 |
- self._notification_manager.add_subscription_request(
|
|
| 113 |
- event.jid, event.status, user_nick=event.user_nick)
|
|
| 114 |
+ self._notification_manager.add_subscription_request(event)
|
|
| 114 | 115 |
|
| 115 | 116 |
def _unsubscribed_received(self, event):
|
| 116 |
- self._notification_manager.add_unsubscribed(event.jid)
|
|
| 117 |
+ self._notification_manager.add_unsubscribed(event)
|
|
| 118 |
+ |
|
| 119 |
+ def _muc_invitation_received(self, event):
|
|
| 120 |
+ self._notification_manager.add_invitation_received(event)
|
|
| 121 |
+ |
|
| 122 |
+ def _muc_invitation_declined(self, event):
|
|
| 123 |
+ self._notification_manager.add_invitation_declined(event)
|
|
| 117 | 124 |
|
| 118 | 125 |
def process_event(self, event):
|
| 119 | 126 |
self._roster.process_event(event)
|
| ... | ... | @@ -35,6 +35,7 @@ def __init__(self, account, event): |
| 35 | 35 |
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
| 36 | 36 |
|
| 37 | 37 |
self.account = account
|
| 38 |
+ self._client = app.get_client(account)
|
|
| 38 | 39 |
self._room_jid = str(event.muc)
|
| 39 | 40 |
self._from = str(event.from_)
|
| 40 | 41 |
self._password = event.password
|
| ... | ... | @@ -45,16 +46,20 @@ def __init__(self, account, event): |
| 45 | 46 |
|
| 46 | 47 |
muc_info_box = GroupChatInfoScrolled(account, {'minimal': True})
|
| 47 | 48 |
muc_info_box.set_from_disco_info(event.info)
|
| 48 |
- |
|
| 49 | 49 |
main_box.add(muc_info_box)
|
| 50 | 50 |
|
| 51 | 51 |
separator = Gtk.Separator()
|
| 52 |
- contact_label = Gtk.Label(label=event.get_inviter_name())
|
|
| 52 |
+ main_box.add(separator)
|
|
| 53 |
+ |
|
| 54 |
+ contact = self._client.get_module('Contacts').get_contact(
|
|
| 55 |
+ event.from_.bare)
|
|
| 56 |
+ contact_label = Gtk.Label(label=contact.name)
|
|
| 53 | 57 |
contact_label.get_style_context().add_class('bold16')
|
| 54 | 58 |
contact_label.set_line_wrap(True)
|
| 55 | 59 |
contact_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
|
| 56 | 60 |
contact_box.set_halign(Gtk.Align.CENTER)
|
| 57 | 61 |
contact_box.add(contact_label)
|
| 62 |
+ main_box.add(contact_box)
|
|
| 58 | 63 |
|
| 59 | 64 |
enabled_accounts = app.get_enabled_accounts_with_labels()
|
| 60 | 65 |
if len(enabled_accounts) > 1:
|
| ... | ... | @@ -69,9 +74,6 @@ def __init__(self, account, event): |
| 69 | 74 |
invitation_label.set_justify(Gtk.Justification.CENTER)
|
| 70 | 75 |
invitation_label.set_max_width_chars(50)
|
| 71 | 76 |
invitation_label.set_line_wrap(True)
|
| 72 |
- |
|
| 73 |
- main_box.add(separator)
|
|
| 74 |
- main_box.add(contact_box)
|
|
| 75 | 77 |
main_box.add(invitation_label)
|
| 76 | 78 |
|
| 77 | 79 |
decline_button = Gtk.Button.new_with_mnemonic(_('_Decline'))
|
| ... | ... | @@ -115,13 +117,10 @@ def _on_key_press_event(self, _widget, event): |
| 115 | 117 |
|
| 116 | 118 |
def _on_join(self, _widget):
|
| 117 | 119 |
nickname = self._nick_chooser.get_text()
|
| 118 |
- app.interface.show_or_join_groupchat(self.account,
|
|
| 119 |
- self._room_jid,
|
|
| 120 |
- nick=nickname,
|
|
| 121 |
- password=self._password)
|
|
| 120 |
+ app.interface.show_add_join_groupchat(
|
|
| 121 |
+ self.account, self._room_jid, nickname=nickname)
|
|
| 122 | 122 |
self.destroy()
|
| 123 | 123 |
|
| 124 | 124 |
def _on_decline(self, _widget):
|
| 125 |
- app.connections[self.account].get_module('MUC').decline(
|
|
| 126 |
- self._room_jid, self._from)
|
|
| 125 |
+ self._client.get_module('MUC').decline(self._room_jid, self._from)
|
|
| 127 | 126 |
self.destroy()
|
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 |
from gajim.gui_menu_builder import get_subscription_menu
|
| 24 | 24 |
|
| 25 | 25 |
from .add_contact import AddNewContactWindow
|
| 26 |
+from .util import open_window
|
|
| 26 | 27 |
|
| 27 | 28 |
|
| 28 | 29 |
class NotificationManager(Gtk.ScrolledWindow):
|
| ... | ... | @@ -132,21 +133,31 @@ def _get_notification_row(self, jid): |
| 132 | 133 |
return child
|
| 133 | 134 |
return None
|
| 134 | 135 |
|
| 135 |
- def add_subscription_request(self, jid, text, user_nick=None):
|
|
| 136 |
- row = self._get_notification_row(jid)
|
|
| 136 |
+ def add_subscription_request(self, event):
|
|
| 137 |
+ row = self._get_notification_row(event.jid)
|
|
| 137 | 138 |
if row is None:
|
| 138 | 139 |
self._listbox.add(SubscriptionRequestRow(
|
| 139 |
- self._account, jid, text, user_nick))
|
|
| 140 |
+ self._account, event.jid, event.status, event.user_nick))
|
|
| 140 | 141 |
elif row.type == 'unsubscribed':
|
| 141 | 142 |
self._listbox.remove(row)
|
| 142 | 143 |
|
| 143 |
- def add_unsubscribed(self, jid):
|
|
| 144 |
- row = self._get_notification_row(jid)
|
|
| 144 |
+ def add_unsubscribed(self, event):
|
|
| 145 |
+ row = self._get_notification_row(event.jid)
|
|
| 145 | 146 |
if row is None:
|
| 146 |
- self._listbox.add(UnsubscribedRow(self._account, jid))
|
|
| 147 |
+ self._listbox.add(UnsubscribedRow(self._account, event.jid))
|
|
| 147 | 148 |
elif row.type == 'subscribe':
|
| 148 | 149 |
self._listbox.remove(row)
|
| 149 | 150 |
|
| 151 |
+ def add_invitation_received(self, event):
|
|
| 152 |
+ row = self._get_notification_row(event.muc)
|
|
| 153 |
+ if row is None:
|
|
| 154 |
+ self._listbox.add(InvitationReceivedRow(self._account, event))
|
|
| 155 |
+ |
|
| 156 |
+ def add_invitation_declined(self, event):
|
|
| 157 |
+ row = self._get_notification_row(event.muc)
|
|
| 158 |
+ if row is None:
|
|
| 159 |
+ self._listbox.add(InvitationDeclinedRow(self._account, event))
|
|
| 160 |
+ |
|
| 150 | 161 |
|
| 151 | 162 |
class NotificationRow(Gtk.ListBoxRow):
|
| 152 | 163 |
def __init__(self, account, jid):
|
| ... | ... | @@ -170,7 +181,7 @@ def _generate_label(): |
| 170 | 181 |
|
| 171 | 182 |
|
| 172 | 183 |
class SubscriptionRequestRow(NotificationRow):
|
| 173 |
- def __init__(self, account, jid, text, user_nick):
|
|
| 184 |
+ def __init__(self, account, jid, text, user_nick=None):
|
|
| 174 | 185 |
NotificationRow.__init__(self, account, jid)
|
| 175 | 186 |
self.type = 'subscribe'
|
| 176 | 187 |
|
| ... | ... | @@ -259,3 +270,97 @@ def __init__(self, account, jid): |
| 259 | 270 |
|
| 260 | 271 |
def _on_dismiss(self, _button):
|
| 261 | 272 |
self.get_parent().remove(self)
|
| 273 |
+ |
|
| 274 |
+ |
|
| 275 |
+class InvitationReceivedRow(NotificationRow):
|
|
| 276 |
+ def __init__(self, account, event):
|
|
| 277 |
+ NotificationRow.__init__(self, account, event.muc)
|
|
| 278 |
+ self.type = 'invitation-received'
|
|
| 279 |
+ |
|
| 280 |
+ self._event = event
|
|
| 281 |
+ |
|
| 282 |
+ image = Gtk.Image.new_from_icon_name(
|
|
| 283 |
+ 'system-users-symbolic', Gtk.IconSize.DND)
|
|
| 284 |
+ image.set_valign(Gtk.Align.CENTER)
|
|
| 285 |
+ self.grid.attach(image, 1, 1, 1, 2)
|
|
| 286 |
+ |
|
| 287 |
+ title_label = self._generate_label()
|
|
| 288 |
+ title_label.set_text(_('Group Chat Invitation Received'))
|
|
| 289 |
+ title_label.get_style_context().add_class('bold')
|
|
| 290 |
+ self.grid.attach(title_label, 2, 1, 1, 1)
|
|
| 291 |
+ |
|
| 292 |
+ contact = self._client.get_module('Contacts').get_contact(
|
|
| 293 |
+ event.from_.bare)
|
|
| 294 |
+ invitation_text = _('%(contact)s invited you to %(chat)s') % {
|
|
| 295 |
+ 'contact': contact.name,
|
|
| 296 |
+ 'chat': event.info.muc_name}
|
|
| 297 |
+ text_label = self._generate_label()
|
|
| 298 |
+ text_label.set_text(invitation_text)
|
|
| 299 |
+ text_label.set_tooltip_text(invitation_text)
|
|
| 300 |
+ text_label.get_style_context().add_class('dim-label')
|
|
| 301 |
+ self.grid.attach(text_label, 2, 2, 1, 1)
|
|
| 302 |
+ |
|
| 303 |
+ show_button = Gtk.Button.new_with_label(label=_('Show'))
|
|
| 304 |
+ show_button.set_valign(Gtk.Align.CENTER)
|
|
| 305 |
+ show_button.set_tooltip_text('Show Invitation')
|
|
| 306 |
+ show_button.connect('clicked', self._on_show_invitation)
|
|
| 307 |
+ self.grid.attach(show_button, 3, 1, 1, 2)
|
|
| 308 |
+ |
|
| 309 |
+ decline_button = Gtk.Button.new_with_label(label=_('Decline'))
|
|
| 310 |
+ decline_button.set_valign(Gtk.Align.CENTER)
|
|
| 311 |
+ decline_button.set_tooltip_text('Decline Invitation')
|
|
| 312 |
+ decline_button.connect('clicked', self._on_decline_invitation)
|
|
| 313 |
+ self.grid.attach(decline_button, 4, 1, 1, 2)
|
|
| 314 |
+ |
|
| 315 |
+ self.show_all()
|
|
| 316 |
+ |
|
| 317 |
+ def _on_show_invitation(self, _button):
|
|
| 318 |
+ open_window('GroupChatInvitation',
|
|
| 319 |
+ account=self._account,
|
|
| 320 |
+ event=self._event)
|
|
| 321 |
+ self.get_parent().remove(self)
|
|
| 322 |
+ |
|
| 323 |
+ def _on_decline_invitation(self, _button):
|
|
| 324 |
+ self._client.get_module('MUC').decline(
|
|
| 325 |
+ self.jid, self._event.from_.bare)
|
|
| 326 |
+ self.get_parent().remove(self)
|
|
| 327 |
+ |
|
| 328 |
+ |
|
| 329 |
+class InvitationDeclinedRow(NotificationRow):
|
|
| 330 |
+ def __init__(self, account, event):
|
|
| 331 |
+ NotificationRow.__init__(self, account, event.muc)
|
|
| 332 |
+ self.type = 'invitation-declined'
|
|
| 333 |
+ |
|
| 334 |
+ image = Gtk.Image.new_from_icon_name(
|
|
| 335 |
+ 'system-users-symbolic', Gtk.IconSize.DND)
|
|
| 336 |
+ image.set_valign(Gtk.Align.CENTER)
|
|
| 337 |
+ self.grid.attach(image, 1, 1, 1, 2)
|
|
| 338 |
+ |
|
| 339 |
+ title_label = self._generate_label()
|
|
| 340 |
+ title_label.set_text(_('Group Chat Invitation Declined'))
|
|
| 341 |
+ title_label.get_style_context().add_class('bold')
|
|
| 342 |
+ self.grid.attach(title_label, 2, 1, 1, 1)
|
|
| 343 |
+ |
|
| 344 |
+ contact = self._client.get_module('Contacts').get_contact(
|
|
| 345 |
+ event.from_.bare)
|
|
| 346 |
+ invitation_text = _('%(contact)s declined your invitation '
|
|
| 347 |
+ 'to %(chat)s') % {
|
|
| 348 |
+ 'contact': contact.name,
|
|
| 349 |
+ 'chat': event.info.muc_name}
|
|
| 350 |
+ text_label = self._generate_label()
|
|
| 351 |
+ text_label.set_text(invitation_text)
|
|
| 352 |
+ text_label.set_tooltip_text(invitation_text)
|
|
| 353 |
+ text_label.get_style_context().add_class('dim-label')
|
|
| 354 |
+ self.grid.attach(text_label, 2, 2, 1, 1)
|
|
| 355 |
+ |
|
| 356 |
+ dismiss_button = Gtk.Button.new_from_icon_name(
|
|
| 357 |
+ 'window-close-symbolic', Gtk.IconSize.BUTTON)
|
|
| 358 |
+ dismiss_button.set_valign(Gtk.Align.CENTER)
|
|
| 359 |
+ dismiss_button.set_tooltip_text(_('Remove Notification'))
|
|
| 360 |
+ dismiss_button.connect('clicked', self._on_dismiss)
|
|
| 361 |
+ self.grid.attach(dismiss_button, 3, 1, 1, 2)
|
|
| 362 |
+ |
|
| 363 |
+ self.show_all()
|
|
| 364 |
+ |
|
| 365 |
+ def _on_dismiss(self, _button):
|
|
| 366 |
+ self.get_parent().remove(self)
|
| ... | ... | @@ -302,6 +302,7 @@ def handle_event_msgnotsent(obj): |
| 302 | 302 |
msg_type='error')
|
| 303 | 303 |
|
| 304 | 304 |
def handle_event_gc_decline(self, event):
|
| 305 |
+ # TODO: Adapt to new mainwindow
|
|
| 305 | 306 |
gc_control = self.msg_win_mgr.get_gc_control(str(event.muc),
|
| 306 | 307 |
event.account)
|
| 307 | 308 |
if gc_control:
|
| ... | ... | @@ -317,20 +318,24 @@ def handle_event_gc_decline(self, event): |
| 317 | 318 |
def handle_event_gc_invitation(self, event):
|
| 318 | 319 |
event = events.GcInvitationtEvent(event)
|
| 319 | 320 |
|
| 320 |
- if (helpers.allow_popup_window(event.account) or
|
|
| 321 |
- not self.systray_enabled):
|
|
| 322 |
- open_window('GroupChatInvitation',
|
|
| 323 |
- account=event.account,
|
|
| 324 |
- event=event)
|
|
| 325 |
- return
|
|
| 321 |
+ # TODO: show account page
|
|
| 322 |
+ # if (helpers.allow_popup_window(event.account) or
|
|
| 323 |
+ # not self.systray_enabled):
|
|
| 324 |
+ # open_window('GroupChatInvitation',
|
|
| 325 |
+ # account=event.account,
|
|
| 326 |
+ # event=event)
|
|
| 327 |
+ # return
|
|
| 326 | 328 |
|
| 327 |
- self.add_event(event.account, str(event.from_), event)
|
|
| 329 |
+ #self.add_event(event.account, str(event.from_), event)
|
|
| 328 | 330 |
|
| 329 | 331 |
if helpers.allow_showing_notification(event.account):
|
| 330 |
- contact_name = event.get_inviter_name()
|
|
| 332 |
+ client = app.get_client(event.account)
|
|
| 333 |
+ contact = client.get_module('Contacts').get_contact(
|
|
| 334 |
+ event.from_.bare)
|
|
| 331 | 335 |
event_type = _('Group Chat Invitation')
|
| 332 | 336 |
text = _('%(contact)s invited you to %(chat)s') % {
|
| 333 |
- 'contact': contact_name, 'chat': event.info.muc_name}
|
|
| 337 |
+ 'contact': contact.name,
|
|
| 338 |
+ 'chat': event.info.muc_name}
|
|
| 334 | 339 |
app.notification.popup(event_type,
|
| 335 | 340 |
str(event.from_),
|
| 336 | 341 |
event.account,
|
| ... | ... | @@ -1160,11 +1165,12 @@ def handle_event(self, account, fjid, type_): |
| 1160 | 1165 |
event = app.events.get_first_event(account, jid, type_)
|
| 1161 | 1166 |
if event is None:
|
| 1162 | 1167 |
return
|
| 1163 |
- open_window('GroupChatInvitation',
|
|
| 1164 |
- account=account,
|
|
| 1165 |
- event=event)
|
|
| 1168 |
+ # TODO: Show account page
|
|
| 1169 |
+ # open_window('GroupChatInvitation',
|
|
| 1170 |
+ # account=account,
|
|
| 1171 |
+ # event=event)
|
|
| 1166 | 1172 |
app.events.remove_events(account, jid, event)
|
| 1167 |
- self.roster.draw_contact(jid, account)
|
|
| 1173 |
+ # self.roster.draw_contact(jid, account)
|
|
| 1168 | 1174 |
elif type_ == 'subscription_request':
|
| 1169 | 1175 |
event = app.events.get_first_event(account, jid, type_)
|
| 1170 | 1176 |
if event is None:
|