Use staticmethod decorator where it makes sense.
This commit is contained in:
parent
51eb62bb73
commit
07716daec2
2 changed files with 58 additions and 30 deletions
|
@ -150,7 +150,8 @@ class AdvancedConfigurationWindow(object):
|
||||||
else:
|
else:
|
||||||
cell.set_property('editable', True)
|
cell.set_property('editable', True)
|
||||||
|
|
||||||
def get_option_path(self, model, iter_):
|
@staticmethod
|
||||||
|
def get_option_path(model, iter_):
|
||||||
# It looks like path made from reversed array
|
# It looks like path made from reversed array
|
||||||
# path[0] is the true one optname
|
# path[0] is the true one optname
|
||||||
# path[1] is the key name
|
# path[1] is the key name
|
||||||
|
@ -255,7 +256,8 @@ class AdvancedConfigurationWindow(object):
|
||||||
modelrow[1] = text
|
modelrow[1] = text
|
||||||
self.check_for_restart()
|
self.check_for_restart()
|
||||||
|
|
||||||
def on_advanced_configuration_window_destroy(self, widget):
|
@staticmethod
|
||||||
|
def on_advanced_configuration_window_destroy(widget):
|
||||||
del gajim.interface.instances['advanced_config']
|
del gajim.interface.instances['advanced_config']
|
||||||
|
|
||||||
def on_reset_button_clicked(self, widget):
|
def on_reset_button_clicked(self, widget):
|
||||||
|
|
|
@ -120,7 +120,8 @@ class Interface:
|
||||||
self.db_error_dialog = None
|
self.db_error_dialog = None
|
||||||
self.db_error_dialog.connect('destroy', destroyed)
|
self.db_error_dialog.connect('destroy', destroyed)
|
||||||
|
|
||||||
def handle_event_information(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_information(obj):
|
||||||
if obj.popup:
|
if obj.popup:
|
||||||
if obj.level == 'error':
|
if obj.level == 'error':
|
||||||
cls = dialogs.ErrorDialog
|
cls = dialogs.ErrorDialog
|
||||||
|
@ -147,7 +148,8 @@ class Interface:
|
||||||
self.instances['change_nick_dialog'] = dialogs.ChangeNickDialog(
|
self.instances['change_nick_dialog'] = dialogs.ChangeNickDialog(
|
||||||
account, room_jid, title, prompt, transient_for=parent_win)
|
account, room_jid, title, prompt, transient_for=parent_win)
|
||||||
|
|
||||||
def handle_event_http_auth(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_http_auth(obj):
|
||||||
#('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg))
|
#('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg))
|
||||||
def response(account, answer):
|
def response(account, answer):
|
||||||
obj.conn.build_http_auth_answer(obj.stanza, answer)
|
obj.conn.build_http_auth_answer(obj.stanza, answer)
|
||||||
|
@ -200,14 +202,16 @@ class Interface:
|
||||||
if ctrl and ctrl.type_id == message_control.TYPE_GC:
|
if ctrl and ctrl.type_id == message_control.TYPE_GC:
|
||||||
ctrl.print_conversation('Error %s: %s' % (obj.errcode, obj.errmsg))
|
ctrl.print_conversation('Error %s: %s' % (obj.errcode, obj.errmsg))
|
||||||
|
|
||||||
def handle_event_connection_lost(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_connection_lost(obj):
|
||||||
# ('CONNECTION_LOST', account, [title, text])
|
# ('CONNECTION_LOST', account, [title, text])
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-connection_lost', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-connection_lost', 48)
|
||||||
account = obj.conn.name
|
account = obj.conn.name
|
||||||
notify.popup(_('Connection Failed'), account, account,
|
notify.popup(_('Connection Failed'), account, account,
|
||||||
'', path, obj.title, obj.msg)
|
'', path, obj.title, obj.msg)
|
||||||
|
|
||||||
def unblock_signed_in_notifications(self, account):
|
@staticmethod
|
||||||
|
def unblock_signed_in_notifications(account):
|
||||||
gajim.block_signed_in_notifications[account] = False
|
gajim.block_signed_in_notifications[account] = False
|
||||||
|
|
||||||
def handle_event_status(self, obj): # OUR status
|
def handle_event_status(self, obj): # OUR status
|
||||||
|
@ -247,7 +251,8 @@ class Interface:
|
||||||
profile_window.ProfileWindow(account, gajim.interface.roster.window)
|
profile_window.ProfileWindow(account, gajim.interface.roster.window)
|
||||||
gajim.connections[account].request_vcard(jid)
|
gajim.connections[account].request_vcard(jid)
|
||||||
|
|
||||||
def handle_gc_error(self, gc_control, pritext, sectext):
|
@staticmethod
|
||||||
|
def handle_gc_error(gc_control, pritext, sectext):
|
||||||
if gc_control and gc_control.autorejoin is not None:
|
if gc_control and gc_control.autorejoin is not None:
|
||||||
if gc_control.error_dialog:
|
if gc_control.error_dialog:
|
||||||
gc_control.error_dialog.destroy()
|
gc_control.error_dialog.destroy()
|
||||||
|
@ -339,7 +344,8 @@ class Interface:
|
||||||
if gc_control and gc_control.autorejoin:
|
if gc_control and gc_control.autorejoin:
|
||||||
gc_control.autorejoin = False
|
gc_control.autorejoin = False
|
||||||
|
|
||||||
def handle_event_gc_message(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_gc_message(obj):
|
||||||
if not obj.stanza.getTag('body'): # no <body>
|
if not obj.stanza.getTag('body'): # no <body>
|
||||||
# It could be a voice request. See
|
# It could be a voice request. See
|
||||||
# http://www.xmpp.org/extensions/xep-0045.html#voiceapprove
|
# http://www.xmpp.org/extensions/xep-0045.html#voiceapprove
|
||||||
|
@ -443,14 +449,16 @@ class Interface:
|
||||||
if session:
|
if session:
|
||||||
session.roster_message(jid, msg, obj.time_, msg_type='error')
|
session.roster_message(jid, msg, obj.time_, msg_type='error')
|
||||||
|
|
||||||
def handle_event_msgsent(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_msgsent(obj):
|
||||||
#('MSGSENT', account, (jid, msg, keyID))
|
#('MSGSENT', account, (jid, msg, keyID))
|
||||||
# do not play sound when standalone chatstate message (eg no msg)
|
# do not play sound when standalone chatstate message (eg no msg)
|
||||||
if obj.message and gajim.config.get_per('soundevents', 'message_sent',
|
if obj.message and gajim.config.get_per('soundevents', 'message_sent',
|
||||||
'enabled'):
|
'enabled'):
|
||||||
helpers.play_sound('message_sent')
|
helpers.play_sound('message_sent')
|
||||||
|
|
||||||
def handle_event_msgnotsent(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_msgnotsent(obj):
|
||||||
#('MSGNOTSENT', account, (jid, ierror_msg, msg, time, session))
|
#('MSGNOTSENT', account, (jid, ierror_msg, msg, time, session))
|
||||||
msg = _('error while sending %(message)s ( %(error)s )') % {
|
msg = _('error while sending %(message)s ( %(error)s )') % {
|
||||||
'message': obj.message, 'error': obj.error}
|
'message': obj.message, 'error': obj.error}
|
||||||
|
@ -540,7 +548,8 @@ class Interface:
|
||||||
notify.popup(event_type, obj.jid, account, 'unsubscribed', path,
|
notify.popup(event_type, obj.jid, account, 'unsubscribed', path,
|
||||||
event_type, obj.jid)
|
event_type, obj.jid)
|
||||||
|
|
||||||
def handle_event_register_agent_info(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_register_agent_info(obj):
|
||||||
# ('REGISTER_AGENT_INFO', account, (agent, infos, is_form))
|
# ('REGISTER_AGENT_INFO', account, (agent, infos, is_form))
|
||||||
# info in a dataform if is_form is True
|
# info in a dataform if is_form is True
|
||||||
if obj.is_form or 'instructions' in obj.config:
|
if obj.is_form or 'instructions' in obj.config:
|
||||||
|
@ -688,7 +697,8 @@ class Interface:
|
||||||
_('You are currently connected without your OpenPGP key.'))
|
_('You are currently connected without your OpenPGP key.'))
|
||||||
self.forget_gpg_passphrase(obj.keyID)
|
self.forget_gpg_passphrase(obj.keyID)
|
||||||
|
|
||||||
def handle_event_client_cert_passphrase(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_client_cert_passphrase(obj):
|
||||||
def on_ok(passphrase, checked):
|
def on_ok(passphrase, checked):
|
||||||
obj.conn.on_client_cert_passphrase(passphrase, obj.con, obj.port,
|
obj.conn.on_client_cert_passphrase(passphrase, obj.con, obj.port,
|
||||||
obj.secure_tuple)
|
obj.secure_tuple)
|
||||||
|
@ -710,7 +720,8 @@ class Interface:
|
||||||
self.gpg_passphrase[obj.keyid] = request
|
self.gpg_passphrase[obj.keyid] = request
|
||||||
request.add_callback(obj.conn.name, obj.callback)
|
request.add_callback(obj.conn.name, obj.callback)
|
||||||
|
|
||||||
def handle_event_gpg_trust_key(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_gpg_trust_key(obj):
|
||||||
#('GPG_ALWAYS_TRUST', account, callback)
|
#('GPG_ALWAYS_TRUST', account, callback)
|
||||||
def on_yes(checked):
|
def on_yes(checked):
|
||||||
if checked:
|
if checked:
|
||||||
|
@ -861,7 +872,8 @@ class Interface:
|
||||||
notify.popup(event_type, jid, account, 'file-send-error', path,
|
notify.popup(event_type, jid, account, 'file-send-error', path,
|
||||||
event_type, file_props.name)
|
event_type, file_props.name)
|
||||||
|
|
||||||
def handle_event_gmail_notify(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_gmail_notify(obj):
|
||||||
jid = obj.jid
|
jid = obj.jid
|
||||||
gmail_new_messages = int(obj.newmsgs)
|
gmail_new_messages = int(obj.newmsgs)
|
||||||
gmail_messages_list = obj.gmail_messages_list
|
gmail_messages_list = obj.gmail_messages_list
|
||||||
|
@ -963,7 +975,8 @@ class Interface:
|
||||||
notify.popup(event_type, obj.jid, account, 'file-request',
|
notify.popup(event_type, obj.jid, account, 'file-request',
|
||||||
path_to_image=path, title=event_type, text=txt)
|
path_to_image=path, title=event_type, text=txt)
|
||||||
|
|
||||||
def handle_event_file_error(self, title, message):
|
@staticmethod
|
||||||
|
def handle_event_file_error(title, message):
|
||||||
dialogs.ErrorDialog(title, message)
|
dialogs.ErrorDialog(title, message)
|
||||||
|
|
||||||
def handle_event_file_progress(self, account, file_props):
|
def handle_event_file_progress(self, account, file_props):
|
||||||
|
@ -1129,7 +1142,8 @@ class Interface:
|
||||||
notify.popup(event_type, jid, account, msg_type, path_to_image=path,
|
notify.popup(event_type, jid, account, msg_type, path_to_image=path,
|
||||||
title=event_type, text=txt)
|
title=event_type, text=txt)
|
||||||
|
|
||||||
def ask_offline_status(self, account):
|
@staticmethod
|
||||||
|
def ask_offline_status(account):
|
||||||
for contact in gajim.contacts.iter_contacts(account):
|
for contact in gajim.contacts.iter_contacts(account):
|
||||||
gajim.connections[account].request_last_status_time(contact.jid,
|
gajim.connections[account].request_last_status_time(contact.jid,
|
||||||
contact.resource)
|
contact.resource)
|
||||||
|
@ -1187,13 +1201,16 @@ class Interface:
|
||||||
location_listener.enable()
|
location_listener.enable()
|
||||||
|
|
||||||
|
|
||||||
def handle_event_metacontacts(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_metacontacts(obj):
|
||||||
gajim.contacts.define_metacontacts(obj.conn.name, obj.meta_list)
|
gajim.contacts.define_metacontacts(obj.conn.name, obj.meta_list)
|
||||||
|
|
||||||
def handle_atom_entry(self, obj):
|
@staticmethod
|
||||||
|
def handle_atom_entry(obj):
|
||||||
AtomWindow.newAtomEntry(obj.atom_entry)
|
AtomWindow.newAtomEntry(obj.atom_entry)
|
||||||
|
|
||||||
def handle_event_failed_decrypt(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_failed_decrypt(obj):
|
||||||
details = _('Unable to decrypt message from %s\nIt may have been '
|
details = _('Unable to decrypt message from %s\nIt may have been '
|
||||||
'tampered with.') % obj.fjid
|
'tampered with.') % obj.fjid
|
||||||
dialogs.WarningDialog(_('Unable to decrypt message'), details)
|
dialogs.WarningDialog(_('Unable to decrypt message'), details)
|
||||||
|
@ -1328,7 +1345,8 @@ class Interface:
|
||||||
if ctrl:
|
if ctrl:
|
||||||
ctrl.set_audio_state('error', reason=obj.reason)
|
ctrl.set_audio_state('error', reason=obj.reason)
|
||||||
|
|
||||||
def handle_event_roster_item_exchange(self, obj):
|
@staticmethod
|
||||||
|
def handle_event_roster_item_exchange(obj):
|
||||||
# data = (action in [add, delete, modify], exchange_list, jid_from)
|
# data = (action in [add, delete, modify], exchange_list, jid_from)
|
||||||
dialogs.RosterItemExchangeWindow(obj.conn.name, obj.action,
|
dialogs.RosterItemExchangeWindow(obj.conn.name, obj.action,
|
||||||
obj.exchange_items_list, obj.fjid)
|
obj.exchange_items_list, obj.fjid)
|
||||||
|
@ -1821,7 +1839,8 @@ class Interface:
|
||||||
### Methods dealing with emoticons
|
### Methods dealing with emoticons
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def image_is_ok(self, image):
|
@staticmethod
|
||||||
|
def image_is_ok(image):
|
||||||
if not os.path.exists(image):
|
if not os.path.exists(image):
|
||||||
return False
|
return False
|
||||||
img = Gtk.Image()
|
img = Gtk.Image()
|
||||||
|
@ -2317,7 +2336,8 @@ class Interface:
|
||||||
### Other Methods
|
### Other Methods
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def change_awn_icon_status(self, status):
|
@staticmethod
|
||||||
|
def change_awn_icon_status(status):
|
||||||
if not dbus_support.supported:
|
if not dbus_support.supported:
|
||||||
# do nothing if user doesn't have D-Bus bindings
|
# do nothing if user doesn't have D-Bus bindings
|
||||||
return
|
return
|
||||||
|
@ -2356,8 +2376,8 @@ class Interface:
|
||||||
listener.disconnect(self.music_track_changed_signal)
|
listener.disconnect(self.music_track_changed_signal)
|
||||||
self.music_track_changed_signal = None
|
self.music_track_changed_signal = None
|
||||||
|
|
||||||
def music_track_changed(self, unused_listener, music_track_info,
|
@staticmethod
|
||||||
account=None):
|
def music_track_changed(unused_listener, music_track_info, account=None):
|
||||||
if not account:
|
if not account:
|
||||||
accounts = gajim.connections.keys()
|
accounts = gajim.connections.keys()
|
||||||
else:
|
else:
|
||||||
|
@ -2478,7 +2498,8 @@ class Interface:
|
||||||
self.systray_enabled = False
|
self.systray_enabled = False
|
||||||
self.systray.hide_icon()
|
self.systray.hide_icon()
|
||||||
|
|
||||||
def on_launch_browser_mailer(self, widget, url, kind):
|
@staticmethod
|
||||||
|
def on_launch_browser_mailer(widget, url, kind):
|
||||||
helpers.launch_browser_mailer(kind, url)
|
helpers.launch_browser_mailer(kind, url)
|
||||||
|
|
||||||
def process_connections(self):
|
def process_connections(self):
|
||||||
|
@ -2497,7 +2518,8 @@ class Interface:
|
||||||
raise
|
raise
|
||||||
return True # renew timeout (loop for ever)
|
return True # renew timeout (loop for ever)
|
||||||
|
|
||||||
def save_config(self):
|
@staticmethod
|
||||||
|
def save_config():
|
||||||
err_str = parser.write()
|
err_str = parser.write()
|
||||||
if err_str is not None:
|
if err_str is not None:
|
||||||
print(err_str, file=sys.stderr)
|
print(err_str, file=sys.stderr)
|
||||||
|
@ -2507,7 +2529,8 @@ class Interface:
|
||||||
'preferences'), err_str)
|
'preferences'), err_str)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def save_avatar_files(self, jid, photo, puny_nick = None, local = False):
|
@staticmethod
|
||||||
|
def save_avatar_files(jid, photo, puny_nick = None, local = False):
|
||||||
"""
|
"""
|
||||||
Save an avatar to a separate file, and generate files for dbus
|
Save an avatar to a separate file, and generate files for dbus
|
||||||
notifications. An avatar can be given as a pixmap directly or as an
|
notifications. An avatar can be given as a pixmap directly or as an
|
||||||
|
@ -2567,7 +2590,8 @@ class Interface:
|
||||||
log.error('Error writing avatar file %s: %s' % \
|
log.error('Error writing avatar file %s: %s' % \
|
||||||
(path_to_original_file, str(e)))
|
(path_to_original_file, str(e)))
|
||||||
|
|
||||||
def remove_avatar_files(self, jid, puny_nick = None, local = False):
|
@staticmethod
|
||||||
|
def remove_avatar_files(jid, puny_nick = None, local = False):
|
||||||
"""
|
"""
|
||||||
Remove avatar files of a jid
|
Remove avatar files of a jid
|
||||||
"""
|
"""
|
||||||
|
@ -2657,7 +2681,8 @@ class Interface:
|
||||||
|
|
||||||
return gc_ctrl and gc_ctrl.type_id == message_control.TYPE_GC
|
return gc_ctrl and gc_ctrl.type_id == message_control.TYPE_GC
|
||||||
|
|
||||||
def get_pep_icon(self, pep_obj):
|
@staticmethod
|
||||||
|
def get_pep_icon(pep_obj):
|
||||||
if isinstance(pep_obj, pep.UserMoodPEP):
|
if isinstance(pep_obj, pep.UserMoodPEP):
|
||||||
received_mood = pep_obj._pep_specific_data['mood']
|
received_mood = pep_obj._pep_specific_data['mood']
|
||||||
mood = received_mood if received_mood in pep.MOODS else 'unknown'
|
mood = received_mood if received_mood in pep.MOODS else 'unknown'
|
||||||
|
@ -2688,7 +2713,8 @@ class Interface:
|
||||||
quiet=True)
|
quiet=True)
|
||||||
return icon
|
return icon
|
||||||
|
|
||||||
def create_ipython_window(self):
|
@staticmethod
|
||||||
|
def create_ipython_window():
|
||||||
try:
|
try:
|
||||||
from ipython_view import IPythonView
|
from ipython_view import IPythonView
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue