Commit f35c67eb authored by Philipp Hörist's avatar Philipp Hörist

Increase usage of EventHelper

parent 0e893197
......@@ -24,15 +24,17 @@ import nbxmpp
from nbxmpp.structs import StanzaHandler
from gajim.common import app
from gajim.common.nec import EventHelper
from gajim.common.modules.util import LogAdapter
class BaseModule:
class BaseModule(EventHelper):
_nbxmpp_extends = ''
_nbxmpp_methods = [] # type: List[str]
def __init__(self, con, *args, plugin=False, **kwargs):
EventHelper.__init__(self)
self._con = con
self._account = con.name
self._log = self._set_logger(plugin)
......@@ -90,3 +92,6 @@ class BaseModule:
return
self._log.info('Send stored publish')
self._stored_publish() # pylint: disable=not-callable
def cleanup(self):
self.unregister_events()
......@@ -53,23 +53,14 @@ class HTTPUpload(BaseModule):
self.httpupload_namespace = None
self._allowed_headers = ['Authorization', 'Cookie', 'Expires']
self.max_file_size = None # maximum file size in bytes
app.ged.register_event_handler('stanza-message-outgoing',
ged.OUT_PREGUI,
self.handle_outgoing_stanza)
app.ged.register_event_handler('gc-stanza-message-outgoing',
ged.OUT_PREGUI,
self.handle_outgoing_stanza)
self.messages = []
def cleanup(self):
app.ged.remove_event_handler('stanza-message-outgoing',
ged.OUT_PREGUI,
self.handle_outgoing_stanza)
app.ged.remove_event_handler('gc-stanza-message-outgoing',
ged.OUT_PREGUI,
self.handle_outgoing_stanza)
# pylint: disable=line-too-long
self.register_events([
('stanza-message-outgoing', ged.OUT_PREGUI, self.handle_outgoing_stanza),
('gc-stanza-message-outgoing', ged.OUT_PREGUI, self.handle_outgoing_stanza),
])
# pylint: enable=line-too-long
def pass_disco(self, info):
if NS_HTTPUPLOAD_0 in info.features:
......
......@@ -109,12 +109,9 @@ class MUC(BaseModule):
priority=49)
]
self._event_handlers = [
self.register_events([
('account-disconnected', ged.CORE, self._on_account_disconnected),
]
for handler in self._event_handlers:
app.ged.register_event_handler(*handler)
])
self._manager = MUCManager(self._log)
self._rejoin_muc = set()
......@@ -837,10 +834,6 @@ class MUC(BaseModule):
for room_jid in list(self._join_timeouts.keys()):
self._remove_join_timeout(room_jid)
def cleanup(self):
for handler in self._event_handlers:
app.ged.remove_event_handler(*handler)
class MUCManager:
def __init__(self, logger):
......
......@@ -26,6 +26,7 @@ from gajim.common import configpaths
from gajim.common import helpers
from gajim.common import connection
from gajim.common.i18n import _
from gajim.common.nec import EventHelper
from gajim import dataforms_widget
from gajim import gui_menu_builder
......@@ -36,8 +37,9 @@ from gajim.gtk.proxies import ManageProxies
from gajim.gtk.dataform import FakeDataFormWidget
class AccountCreationWizard:
class AccountCreationWizard(EventHelper):
def __init__(self):
EventHelper.__init__(self)
self.xml = get_builder('account_creation_wizard_window.ui')
self.window = self.xml.get_object('account_creation_wizard_window')
active_window = app.app.get_active_window()
......@@ -85,18 +87,13 @@ class AccountCreationWizard:
self.notebook.set_current_page(0)
self.xml.connect_signals(self)
self.window.show_all()
app.ged.register_event_handler(
'new-account-connected', ged.GUI1,
self._nec_new_acc_connected)
app.ged.register_event_handler(
'new-account-not-connected', ged.GUI1,
self._nec_new_acc_not_connected)
app.ged.register_event_handler(
'account-created', ged.GUI1,
self._nec_acc_is_ok)
app.ged.register_event_handler(
'account-not-created', ged.GUI1,
self._nec_acc_is_not_ok)
self.register_events([
('new-account-connected', ged.GUI1, self._nec_new_acc_connected),
('new-account-not-connected', ged.GUI1, self._nec_new_acc_not_connected),
('account-created', ged.GUI1, self._nec_acc_is_ok),
('account-not-created', ged.GUI1, self._nec_acc_is_not_ok),
])
def on_wizard_window_destroy(self, widget):
page = self.notebook.get_current_page()
......@@ -106,18 +103,7 @@ class AccountCreationWizard:
del app.connections[self.account]
if self.account in app.config.get_per('accounts'):
app.config.del_per('accounts', self.account)
app.ged.remove_event_handler(
'new-account-connected', ged.GUI1,
self._nec_new_acc_connected)
app.ged.remove_event_handler(
'new-account-not-connected', ged.GUI1,
self._nec_new_acc_not_connected)
app.ged.remove_event_handler(
'account-created', ged.GUI1,
self._nec_acc_is_ok)
app.ged.remove_event_handler(
'account-not-created', ged.GUI1,
self._nec_acc_is_not_ok)
self.unregister_events()
del app.interface.instances['account_creation_wizard']
def on_save_password_checkbutton_toggled(self, widget):
......
......@@ -23,9 +23,10 @@ from gajim.common.i18n import _
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
class AddNewContactWindow(Gtk.ApplicationWindow):
class AddNewContactWindow(Gtk.ApplicationWindow, EventHelper):
uid_labels = {'jabber': _('XMPP Address'),
'gadu-gadu': _('GG Number'),
......@@ -33,13 +34,13 @@ class AddNewContactWindow(Gtk.ApplicationWindow):
def __init__(self, account=None, jid=None, user_nick=None, group=None):
Gtk.ApplicationWindow.__init__(self)
EventHelper.__init__(self)
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_show_menubar(False)
self.set_resizable(False)
self.set_title(_('Add Contact'))
self.connect('destroy', self._on_destroy)
self.connect('key-press-event', self._on_key_press)
self.account = account
......@@ -203,16 +204,10 @@ class AddNewContactWindow(Gtk.ApplicationWindow):
self.uid_entry.connect('changed', self.on_uid_entry_changed)
self.show_all()
app.ged.register_event_handler('gateway-prompt-received', ged.GUI1,
self._nec_gateway_prompt_received)
app.ged.register_event_handler('presence-received', ged.GUI1,
self._nec_presence_received)
def _on_destroy(self, widget):
app.ged.remove_event_handler('presence-received', ged.GUI1,
self._nec_presence_received)
app.ged.remove_event_handler('gateway-prompt-received', ged.GUI1,
self._nec_gateway_prompt_received)
self.register_events([
('gateway-prompt-received', ged.GUI1, self._nec_gateway_prompt_received),
('presence-received', ged.GUI1, self._nec_presence_received),
])
def on_uid_entry_changed(self, widget):
is_empty = bool(not self.uid_entry.get_text() == '')
......
......@@ -35,6 +35,7 @@ from gajim.common.const import StyleAttr
from gajim.gui_menu_builder import get_groupchat_roster_menu
from gajim.gtk.tooltips import GCTooltip
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
AffiliationRoleSortOrder = {
......@@ -54,7 +55,7 @@ class Column(IntEnum):
NICK_OR_GROUP = 4
class GroupchatRoster(Gtk.ScrolledWindow):
class GroupchatRoster(Gtk.ScrolledWindow, EventHelper):
__gsignals__ = {
'row-activated': (
......@@ -65,6 +66,7 @@ class GroupchatRoster(Gtk.ScrolledWindow):
def __init__(self, account, room_jid, control):
Gtk.ScrolledWindow.__init__(self)
EventHelper.__init__(self)
self.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.get_style_context().add_class('groupchat-roster')
self._account = account
......@@ -98,13 +100,10 @@ class GroupchatRoster(Gtk.ScrolledWindow):
self.connect('destroy', self._on_destroy)
self._ui.connect_signals(self)
self._event_handlers = [
self.register_events([
('theme-update', ged.GUI2, self._on_theme_update),
('update-gc-avatar', ged.GUI1, self._on_avatar_update),
]
for handler in self._event_handlers:
app.ged.register_event_handler(*handler)
])
@staticmethod
def _on_focus_out(treeview, _param):
......@@ -473,9 +472,6 @@ class GroupchatRoster(Gtk.ScrolledWindow):
self._store.clear()
def _on_destroy(self, _roster):
for handler in self._event_handlers:
app.ged.remove_event_handler(*handler)
for id_ in list(self._handler_ids.keys()):
if self._handler_ids[id_].handler_is_connected(id_):
self._handler_ids[id_].disconnect(id_)
......
......@@ -26,6 +26,7 @@ from gajim.common.const import ArchiveState
from gajim.common.helpers import event_filter
from gajim.gtk.util import load_icon
from gajim.gtk.util import EventHelper
log = logging.getLogger('gajim.gtk.history_sync')
......@@ -36,9 +37,10 @@ class Pages(IntEnum):
SUMMARY = 2
class HistorySyncAssistant(Gtk.Assistant):
class HistorySyncAssistant(Gtk.Assistant, EventHelper):
def __init__(self, account, parent):
Gtk.Assistant.__init__(self)
EventHelper.__init__(self)
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_name('HistorySyncAssistant')
......@@ -86,18 +88,15 @@ class HistorySyncAssistant(Gtk.Assistant):
self.set_page_type(self.summary, Gtk.AssistantPageType.SUMMARY)
self.set_page_complete(self.summary, True)
app.ged.register_event_handler('archiving-count-received',
ged.GUI1,
self._received_count)
app.ged.register_event_handler('archiving-interval-finished',
ged.GUI1,
self._received_finished)
app.ged.register_event_handler('mam-message-received',
ged.PRECORE,
self._nec_mam_message_received)
# pylint: disable=line-too-long
self.register_events([
('archiving-count-received', ged.GUI1, self._received_count),
('archiving-interval-finished', ged.GUI1, self._received_finished),
('mam-message-received', ged.PRECORE, self._nec_mam_message_received),
])
# pylint: enable=line-too-long
self.connect('prepare', self._on_page_change)
self.connect('destroy', self._on_destroy)
self.connect('cancel', self._on_close_clicked)
self.connect('close', self._on_close_clicked)
......@@ -182,17 +181,6 @@ class HistorySyncAssistant(Gtk.Assistant):
self._prepare_query()
self.set_title(_('Synchronise History'))
def _on_destroy(self, *args):
app.ged.remove_event_handler('archiving-count-received',
ged.GUI1,
self._received_count)
app.ged.remove_event_handler('archiving-interval-finished',
ged.GUI1,
self._received_finished)
app.ged.remove_event_handler('mam-message-received',
ged.PRECORE,
self._nec_mam_message_received)
def _on_close_clicked(self, *args):
self.destroy()
......
......@@ -23,11 +23,13 @@ from gajim.common import ged
from gajim.common.i18n import _
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
class HTTPUploadProgressWindow(Gtk.ApplicationWindow):
class HTTPUploadProgressWindow(Gtk.ApplicationWindow, EventHelper):
def __init__(self, file):
Gtk.ApplicationWindow.__init__(self)
EventHelper.__init__(self)
self.set_name('HTTPUploadProgressWindow')
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
......@@ -55,8 +57,9 @@ class HTTPUploadProgressWindow(Gtk.ApplicationWindow):
self.connect('destroy', self._on_destroy)
self._ui.connect_signals(self)
app.ged.register_event_handler('httpupload-progress', ged.CORE,
self._on_httpupload_progress)
self.register_events([
('httpupload-progress', ged.CORE, self._on_httpupload_progress),
])
def _on_httpupload_progress(self, obj):
if self.file != obj.file:
......@@ -84,8 +87,6 @@ class HTTPUploadProgressWindow(Gtk.ApplicationWindow):
self.event.set()
if self.pulse:
GLib.source_remove(self.pulse)
app.ged.remove_event_handler('httpupload-progress', ged.CORE,
self._on_httpupload_progress)
def _update_progress(self, seen, total):
if self.event.isSet():
......
......@@ -22,6 +22,7 @@ from gajim.common import ged
from gajim.common.i18n import _
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import InformationDialog
......@@ -29,15 +30,15 @@ from gajim.gtk.dialogs import InformationDialog
log = logging.getLogger('gajim.gtk.mam_preferences')
class MamPreferences(Gtk.ApplicationWindow):
class MamPreferences(Gtk.ApplicationWindow, EventHelper):
def __init__(self, account):
Gtk.ApplicationWindow.__init__(self)
EventHelper.__init__(self)
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_show_menubar(False)
self.set_title(_('Archiving Preferences for %s') % account)
self.connect('destroy', self._on_destroy)
self.connect('key-press-event', self._on_key_press)
self.account = account
......@@ -49,12 +50,11 @@ class MamPreferences(Gtk.ApplicationWindow):
self._spinner = Gtk.Spinner()
self._ui.overlay.add_overlay(self._spinner)
app.ged.register_event_handler('mam-prefs-received', ged.GUI1,
self._mam_prefs_received)
app.ged.register_event_handler('mam-prefs-saved', ged.GUI1,
self._mam_prefs_saved)
app.ged.register_event_handler('mam-prefs-error', ged.GUI1,
self._mam_prefs_error)
self.register_events([
('mam-prefs-received', ged.GUI1, self._mam_prefs_received),
('mam-prefs-saved', ged.GUI1, self._mam_prefs_saved),
('mam-prefs-error', ged.GUI1, self._mam_prefs_error),
])
self._set_mam_box_state(False)
self._ui.connect_signals(self)
......@@ -147,11 +147,3 @@ class MamPreferences(Gtk.ApplicationWindow):
def _on_key_press(self, widget, event):
if event.keyval == Gdk.KEY_Escape:
self.destroy()
def _on_destroy(self, widget):
app.ged.remove_event_handler('mam-prefs-received', ged.GUI1,
self._mam_prefs_received)
app.ged.remove_event_handler('mam-prefs-saved', ged.GUI1,
self._mam_prefs_saved)
app.ged.remove_event_handler('mam-prefs-error', ged.GUI1,
self._mam_prefs_error)
......@@ -37,6 +37,7 @@ from gajim.common import app
from gajim.common import helpers
from gajim.common import ged
from gajim.common.i18n import _
from gajim.common.nec import EventHelper
from gajim.gtk.util import get_builder
from gajim.gtk.util import get_icon_name
......@@ -46,21 +47,23 @@ from gajim.gtk.util import get_total_screen_geometry
log = logging.getLogger('gajim.gtk.notification')
class Notification:
class Notification(EventHelper):
"""
Handle notifications
"""
def __init__(self):
EventHelper.__init__(self)
self._dbus_available = False
self._daemon_capabilities = ['actions']
self._win32_active_popup = None
self._detect_dbus_caps()
app.ged.register_event_handler(
'notification', ged.GUI2, self._nec_notification)
app.ged.register_event_handler(
'our-show', ged.GUI2, self._nec_our_status)
self.register_events([
('notification', ged.GUI2, self._nec_notification),
('our-show', ged.GUI2, self._nec_our_status),
])
app.events.event_removed_subscribe(self._on_event_removed)
def _detect_dbus_caps(self):
......
......@@ -25,11 +25,13 @@ from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import WarningDialog
from gajim.gtk.dataform import DataFormDialog
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
class ManagePEPServicesWindow(Gtk.ApplicationWindow):
class ManagePEPServicesWindow(Gtk.ApplicationWindow, EventHelper):
def __init__(self, account):
Gtk.ApplicationWindow.__init__(self)
EventHelper.__init__(self)
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_show_menubar(False)
......@@ -49,22 +51,18 @@ class ManagePEPServicesWindow(Gtk.ApplicationWindow):
self._ui.services_treeview.get_selection().connect(
'changed', self._on_services_selection_changed)
app.ged.register_event_handler(
'pubsub-config-received', ged.GUI1, self._nec_pep_config_received)
self.register_events([
('pubsub-config-received', ged.GUI1, self._nec_pep_config_received),
])
self.show_all()
self.connect('key-press-event', self._on_key_press_event)
self.connect('destroy', self._on_destroy)
self._ui.connect_signals(self)
def _on_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_Escape:
self.destroy()
def _on_destroy(self, *args):
app.ged.remove_event_handler(
'pubsub-config-received', ged.GUI1, self._nec_pep_config_received)
def _on_services_selection_changed(self, sel):
self._ui.configure_button.set_sensitive(True)
self._ui.delete_button.set_sensitive(True)
......
......@@ -20,15 +20,17 @@ from gi.repository import GObject
from gajim.common import app
from gajim.common import ged
from gajim.common.i18n import _
from gajim.common.nec import EventHelper
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.util import get_builder
class PrivacyListWindow:
class PrivacyListWindow(EventHelper):
def __init__(self, account, privacy_list_name, action):
'''action is 'EDIT' or 'NEW' depending on if we create a new priv list
or edit an already existing one'''
# action is 'EDIT' or 'NEW' depending on if we create a new priv list
# or edit an already existing one
EventHelper.__init__(self)
self.account = account
self.privacy_list_name = privacy_list_name
......@@ -103,10 +105,12 @@ class PrivacyListWindow:
self.window.set_title(title)
app.ged.register_event_handler('privacy-list-received', ged.GUI1,
self._nec_privacy_list_received)
app.ged.register_event_handler('privacy-lists-received', ged.GUI1,
self._nec_privacy_lists_received)
# pylint: disable=line-too-long
self.register_events([
('privacy-list-received', ged.GUI1, self._nec_privacy_list_received),
('privacy-lists-received', ged.GUI1, self._nec_privacy_lists_received)
])
# pylint: enable=line-too-long
self.window.show_all()
self.add_edit_vbox.hide()
......@@ -121,10 +125,7 @@ class PrivacyListWindow:
key_name = 'privacy_list_%s' % self.privacy_list_name
if key_name in app.interface.instances[self.account]:
del app.interface.instances[self.account][key_name]
app.ged.remove_event_handler('privacy-list-received', ged.GUI1,
self._nec_privacy_list_received)
app.ged.remove_event_handler('privacy-lists-received', ged.GUI1,
self._nec_privacy_lists_received)
self.unregister_events()
def _nec_privacy_lists_received(self, obj):
if obj.conn.name != self.account:
......@@ -397,12 +398,13 @@ class PrivacyListWindow:
self.window.destroy()
class PrivacyListsWindow:
class PrivacyListsWindow(EventHelper):
"""
Window that is the main window for Privacy Lists; we can list there the
privacy lists and ask to create a new one or edit an already there one
"""
def __init__(self, account):
EventHelper.__init__(self)
self.account = account
self.privacy_lists_save = []
......@@ -428,10 +430,12 @@ class PrivacyListsWindow:
self.window.set_title(title)
app.ged.register_event_handler('privacy-lists-received', ged.GUI1,
self._nec_privacy_lists_received)
app.ged.register_event_handler('privacy-list-removed', ged.GUI1,
self._nec_privacy_lists_removed)
# pylint: disable=line-too-long
self.register_events([
('privacy-lists-received', ged.GUI1, self._nec_privacy_lists_received),
('privacy-list-removed', ged.GUI1, self._nec_privacy_lists_removed),
])
# pylint: enable=line-too-long
self.window.show_all()
......@@ -444,10 +448,7 @@ class PrivacyListsWindow:
def on_privacy_lists_first_window_destroy(self, widget):
if 'privacy_lists' in app.interface.instances[self.account]:
del app.interface.instances[self.account]['privacy_lists']
app.ged.remove_event_handler('privacy-lists-received', ged.GUI1,
self._nec_privacy_lists_received)
app.ged.remove_event_handler('privacy-list-removed', ged.GUI1,
self._nec_privacy_lists_removed)
self.unregister_events()
def remove_privacy_list_from_combobox(self, privacy_list):
if privacy_list not in self.privacy_lists_save:
......
......@@ -36,15 +36,17 @@ from gajim import gtkgui_helpers
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import InformationDialog
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
from gajim.gtk.filechoosers import AvatarChooserDialog
log = logging.getLogger('gajim.profile')
class ProfileWindow(Gtk.ApplicationWindow):
class ProfileWindow(Gtk.ApplicationWindow, EventHelper):
def __init__(self, account):
Gtk.ApplicationWindow.__init__(self)
EventHelper.__init__(self)
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_show_menubar(False)
......@@ -76,10 +78,10 @@ class ProfileWindow(Gtk.ApplicationWindow):
self.remove_statusbar_timeout_id = None
self.xml.connect_signals(self)
app.ged.register_event_handler('vcard-published', ged.GUI1,
self._nec_vcard_published)
app.ged.register_event_handler('vcard-not-published', ged.GUI1,
self._nec_vcard_not_published)
self.register_events([
('vcard-published', ged.GUI1, self._nec_vcard_published),
('vcard-not-published', ged.GUI1, self._nec_vcard_not_published),
])
self.show_all()
self.xml.get_object('ok_button').grab_focus()
......@@ -102,10 +104,6 @@ class ProfileWindow(Gtk.ApplicationWindow):
GLib.source_remove(self.update_progressbar_timeout_id)
if self.remove_statusbar_timeout_id is not None:
GLib.source_remove(self.remove_statusbar_timeout_id)
app.ged.remove_event_handler(
'vcard-published', ged.GUI1, self._nec_vcard_published)
app.ged.remove_event_handler(
'vcard-not-published', ged.GUI1, self._nec_vcard_not_published)
if self.dialog: # Image chooser dialog
self.dialog.destroy()
......
......@@ -31,6 +31,7 @@ from gajim.gui_menu_builder import SearchMenu
from gajim.gtk.dataform import DataFormWidget
from gajim.gtk.util import ensure_not_destroyed
from gajim.gtk.util import find_widget
from gajim.gtk.util import EventHelper
log = logging.getLogger('gajim.gtk.search')
......@@ -43,9 +44,10 @@ class Page(IntEnum):
ERROR = 4
class Search(Gtk.Assistant):
class Search(Gtk.Assistant, EventHelper):
def __init__(self, account, jid, transient_for=None):
Gtk.Assistant.__init__(self)
EventHelper.__init__(self)
self._con = app.connections[account]
self._account = account
......@@ -78,12 +80,10 @@ class Search(Gtk.Assistant):
self._add_custom_buttons()
self.show()
app.ged.register_event_handler('search-form-received',
ged.GUI1,
self._search_form_received)
app.ged.register_event_handler('search-result-received',
ged.GUI1,
self._search_result_received)
self.register_events([
('search-form-received', ged.GUI1, self._search_form_received),
('search-result-received', ged.GUI1, self._search_result_received),
])
self._request_search_fields()
......@@ -164,12 +164,6 @@ class Search(Gtk.Assistant):
self.set_current_page(Page.ERROR)
def _on_cancel(self, _widget):
app.ged.remove_event_handler('search-form-received',
ged.GUI1,
self._search_form_received)
app.ged.remove_event_handler('search-result-received',
ged.GUI1,
self._search_result_received)
self.destroy()
def _on_destroy(self, *args):
......
......@@ -28,13 +28,15 @@ from gajim.common.i18n import _
from gajim.gtk.dialogs import CertificateDialog
from gajim.gtk.util import ensure_not_destroyed
from gajim.gtk.util import get_builder
from gajim.gtk.util import EventHelper
log = logging.getLogger('gajim.gtk.server_info')
class ServerInfo(Gtk.ApplicationWindow):
class ServerInfo(Gtk.ApplicationWindow, EventHelper):
def __init__(self, account):
Gtk.ApplicationWindow.__init__(self)
EventHelper.__init__(self)
self.set_name('ServerInfo')
self.set_application(app.app)
self.set_position(Gtk.WindowPosition.CENTER)
......@@ -52,9 +54,9 @@ class ServerInfo(Gtk.ApplicationWindow):
self.connect('key-press-event', self._on_key_press)
self._ui.connect_signals(self)
app.ged.register_event_handler('server-disco-received',
ged.GUI1,
self._server_disco_received)
self.register_events([
('server-disco-received', ged.GUI1, self._server_disco_received),
])
self.version = ''
self.hostname = app.get_hostname_from_account(account)
......@@ -256,9 +258,6 @@ class ServerInfo(Gtk.ApplicationWindow):
def on_destroy(self, *args):
self._destroyed = True
app.ged.remove_event_handler('server-disco-received',
ged.GUI1,
self._server_disco_received)
class FeatureItem(Gtk.Grid):
......
......@@ -27,6 +27,7 @@ from gajim.common.const import StyleAttr
from gajim.gtk import util
from gajim.gtk.util import get_builder
from gajim.gtk.util import MaxWidthComboBoxText
from gajim.gtk.util import EventHelper
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.settings import SettingsDialog
from gajim.gtk.const import Setting
......@@ -34,9 +35,10 @@ from gajim.gtk.const import SettingKind