diff --git a/gajim/data/gui/subscription_request_window.ui b/gajim/data/gui/subscription_request_window.ui index 8fc15f436..689a4bdc5 100644 --- a/gajim/data/gui/subscription_request_window.ui +++ b/gajim/data/gui/subscription_request_window.ui @@ -1,95 +1,143 @@ - + - - + + True False - - - True - False - _Start Chat - True - - - - - - True - False - _Information - True - - - + user-available-symbolic + + + True + False + user-info-symbolic True False - 18 - 18 - 18 - 18 + start + 18 vertical - 5 + 6 - + True False + 6 + 12 + + + True + False + start + <XMPP address> + 0 + + + + 1 + 0 + + + + + True + False + start + <subscription request> + True + 0 + + + + 1 + 1 + + + + + True + False + start + 6 + <subscription text> + + True + 0 + 0 + + + + + + 1 + 2 + + + + + True + True + True + Contact Information + center + image2 + + + + 0 + 0 + + + + + True + True + True + Start Chat + center + image1 + + + + 0 + 2 + + + + + False - False + True 0 - - 100 + True - True - 5 - in - - - True - True - False - word - False - - + False + 12 - True + False True - 1 + 2 - + True False - 5 + baseline + 12 12 - end - - - _Close - True - True - True - False - True - - - - False - False - 0 - - + True _Deny @@ -97,59 +145,45 @@ True True False - Deny authorization from contact so he or she cannot know when you're connected + Deny authorization from contact so the contact cannot know if you are connected True + False - False - 1 - - - - - True - True - True - subscription_request_popup_menu - False - - - True - False - applications-system-symbolic - - - - - True True - 2 + 0 - Au_thorize + Ac_cept True True True + True False - Authorize contact so he or she can know when you're connected + Authorize contact so the contact can know if you are connected True + False - False - 3 + True + 1 False - False - 2 + True + 3 diff --git a/gajim/dialogs.py b/gajim/dialogs.py index ab2460d49..9471717b9 100644 --- a/gajim/dialogs.py +++ b/gajim/dialogs.py @@ -37,7 +37,6 @@ from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GLib -from gajim import vcard from gajim import dataforms_widget from gajim.common import ged @@ -53,7 +52,6 @@ from gajim.common.exceptions import GajimGeneralException # Compat with Gajim 1.0.3 for plugins from gajim.gtk.dialogs import * -from gajim.gtk.add_contact import AddNewContactWindow from gajim.gtk.util import get_icon_name from gajim.gtk.util import resize_window from gajim.gtk.util import get_builder @@ -842,89 +840,6 @@ class ChangeStatusMessageDialog(TimeoutDialog): self.pep_dict['mood_text']) -class SubscriptionRequestWindow(Gtk.ApplicationWindow): - def __init__(self, jid, text, account, user_nick=None): - Gtk.ApplicationWindow.__init__(self) - self.set_name('SubscriptionRequest') - self.set_application(app.app) - self.set_show_menubar(False) - self.set_resizable(False) - self.set_position(Gtk.WindowPosition.CENTER) - self.set_title(_('Subscription Request')) - - xml = get_builder('subscription_request_window.ui') - self.add(xml.get_object('subscription_box')) - self.jid = jid - self.account = account - self.user_nick = user_nick - if len(app.connections) >= 2: - prompt_text = \ - _('Subscription request for account %(account)s from %(jid)s')\ - % {'account': account, 'jid': self.jid} - else: - prompt_text = _('Subscription request from %s') % self.jid - - from_label = xml.get_object('from_label') - from_label.set_text(prompt_text) - - textview = xml.get_object('message_textview') - textview.get_buffer().set_text(text) - - self.set_default(xml.get_object('authorize_button')) - xml.connect_signals(self) - self.show_all() - - def on_subscription_request_window_destroy(self, widget): - """ - Close window - """ - if self.jid in app.interface.instances[self.account]['sub_request']: - # remove us from open windows - del app.interface.instances[self.account]['sub_request'][self.jid] - - def on_close_button_clicked(self, widget): - self.destroy() - - def on_authorize_button_clicked(self, widget): - """ - Accept the request - """ - app.connections[self.account].get_module('Presence').subscribed(self.jid) - self.destroy() - contact = app.contacts.get_contact(self.account, self.jid) - if not contact or _('Not in Roster') in contact.groups: - AddNewContactWindow(self.account, self.jid, self.user_nick) - - def on_contact_info_activate(self, widget): - """ - Ask vcard - """ - if self.jid in app.interface.instances[self.account]['infos']: - app.interface.instances[self.account]['infos'][self.jid].window.present() - else: - contact = app.contacts.create_contact(jid=self.jid, account=self.account) - app.interface.instances[self.account]['infos'][self.jid] = \ - vcard.VcardWindow(contact, self.account) - # Remove jabber page - app.interface.instances[self.account]['infos'][self.jid].xml.\ - get_object('information_notebook').remove_page(0) - - def on_start_chat_activate(self, widget): - """ - Open chat - """ - app.interface.new_chat_from_jid(self.account, self.jid) - - def on_deny_button_clicked(self, widget): - """ - Refuse the request - """ - app.connections[self.account].get_module('Presence').unsubscribed(self.jid) - contact = app.contacts.get_contact(self.account, self.jid) - if contact and _('Not in Roster') in contact.get_shown_groups(): - app.interface.roster.remove_contact(self.jid, self.account) - self.destroy() - class SynchroniseSelectAccountDialog: def __init__(self, account): # 'account' can be None if we are about to create our first one diff --git a/gajim/gtk/subscription_request.py b/gajim/gtk/subscription_request.py new file mode 100644 index 000000000..37f058413 --- /dev/null +++ b/gajim/gtk/subscription_request.py @@ -0,0 +1,101 @@ +# This file is part of Gajim. +# +# Gajim is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 3 only. +# +# Gajim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Gajim. If not, see . + +from gi.repository import Gtk + +from gajim import vcard + +from gajim.common import app +from gajim.common.i18n import _ + +from gajim.gtk.add_contact import AddNewContactWindow +from gajim.gtk.util import get_builder + + +class SubscriptionRequestWindow(Gtk.ApplicationWindow): + def __init__(self, jid, text, account, user_nick=None): + Gtk.ApplicationWindow.__init__(self) + self.set_name('SubscriptionRequest') + self.set_application(app.app) + self.set_show_menubar(False) + self.set_resizable(False) + self.set_position(Gtk.WindowPosition.CENTER) + self.set_title(_('Subscription Request')) + + self._ui = get_builder('subscription_request_window.ui') + self.add(self._ui.subscription_box) + self.jid = jid + self.account = account + self.user_nick = user_nick + self._ui.jid_label.set_text(self.jid) + if len(app.connections) >= 2: + prompt_text = \ + _('Subscription request for account %(account)s from %(jid)s')\ + % {'account': account, 'jid': self.jid} + else: + prompt_text = _('Subscription request from %s') % self.jid + + self._ui.request_label.set_text(prompt_text) + self._ui.subscription_text.set_text(text) + + self._ui.connect_signals(self) + self.show_all() + + def on_subscription_request_window_destroy(self, widget): + """ + Close window + """ + if self.jid in app.interface.instances[self.account]['sub_request']: + # Remove us from open windows + del app.interface.instances[self.account]['sub_request'][self.jid] + + def on_authorize_button_clicked(self, widget): + """ + Accept the request + """ + app.connections[self.account].get_module('Presence').subscribed(self.jid) + self.destroy() + contact = app.contacts.get_contact(self.account, self.jid) + if not contact or _('Not in Roster') in contact.groups: + AddNewContactWindow(self.account, self.jid, self.user_nick) + + def on_contact_info_button_clicked(self, widget): + """ + Ask for vCard + """ + if self.jid in app.interface.instances[self.account]['infos']: + app.interface.instances[self.account]['infos'][self.jid].window.present() + else: + contact = app.contacts.create_contact(jid=self.jid, account=self.account) + app.interface.instances[self.account]['infos'][self.jid] = \ + vcard.VcardWindow(contact, self.account) + # Remove xmpp page + app.interface.instances[self.account]['infos'][self.jid].xml.\ + get_object('information_notebook').remove_page(0) + + def on_start_chat_button_clicked(self, widget): + """ + Open chat + """ + app.interface.new_chat_from_jid(self.account, self.jid) + + def on_deny_button_clicked(self, widget): + """ + Refuse the request + """ + app.connections[self.account].get_module('Presence').unsubscribed(self.jid) + contact = app.contacts.get_contact(self.account, self.jid) + if contact and _('Not in Roster') in contact.get_shown_groups(): + app.interface.roster.remove_contact(self.jid, self.account) + self.destroy() diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py index d1f3b90ec..a10ae1f26 100644 --- a/gajim/gui_interface.py +++ b/gajim/gui_interface.py @@ -119,6 +119,7 @@ from gajim.gtk.emoji_data import emoji_data from gajim.gtk.emoji_data import emoji_ascii_data from gajim.gtk.groupchat_config import GroupchatConfig from gajim.gtk.filetransfer import FileTransfersWindow +from gajim.gtk.subscription_request import SubscriptionRequestWindow from gajim.gtk.util import get_show_in_roster from gajim.gtk.util import get_show_in_systray @@ -414,8 +415,8 @@ class Interface: if obj.jid in self.instances[account]['sub_request']: self.instances[account]['sub_request'][obj.jid].destroy() self.instances[account]['sub_request'][obj.jid] = \ - dialogs.SubscriptionRequestWindow(obj.jid, obj.status, account, - obj.user_nick) + SubscriptionRequestWindow(obj.jid, obj.status, account, + obj.user_nick) return event = events.SubscriptionRequestEvent(obj.status, obj.user_nick) @@ -1473,8 +1474,7 @@ class Interface: event = app.events.get_first_event(account, jid, type_) if event is None: return - dialogs.SubscriptionRequestWindow(jid, event.text, account, - event.nick) + SubscriptionRequestWindow(jid, event.text, account, event.nick) app.events.remove_events(account, jid, event) self.roster.draw_contact(jid, account) elif type_ == 'unsubscribed': diff --git a/gajim/roster_window.py b/gajim/roster_window.py index 81e59e849..7393ac23a 100644 --- a/gajim/roster_window.py +++ b/gajim/roster_window.py @@ -84,6 +84,7 @@ from gajim.gtk.discovery import ServiceDiscoveryWindow from gajim.gtk.accounts import AccountsWindow from gajim.gtk.tooltips import RosterTooltip from gajim.gtk.adhoc_commands import CommandWindow +from gajim.gtk.subscription_request import SubscriptionRequestWindow from gajim.gtk.util import get_icon_name from gajim.gtk.util import resize_window from gajim.gtk.util import restore_roster_position @@ -1981,8 +1982,7 @@ class RosterWindow: return True if event.type_ == 'subscription_request': - dialogs.SubscriptionRequestWindow(jid, event.text, account, - event.nick) + SubscriptionRequestWindow(jid, event.text, account, event.nick) app.events.remove_events(account, jid, event) return True