coding standards

This commit is contained in:
Denis Fomin 2010-11-06 16:01:28 +03:00
parent 69578659a2
commit f1b9e29fe3
1 changed files with 240 additions and 230 deletions

View File

@ -711,8 +711,8 @@ class ChangeStatusMessageDialog(TimeoutDialog):
message = helpers.remove_invalid_xml_chars(message) message = helpers.remove_invalid_xml_chars(message)
msg = helpers.to_one_line(message) msg = helpers.to_one_line(message)
if self.show: if self.show:
gajim.config.set_per('statusmsg', '_last_' + self.show, 'message', gajim.config.set_per('statusmsg', '_last_' + self.show,
msg) 'message', msg)
if self.show_pep: if self.show_pep:
gajim.config.set_per('statusmsg', '_last_' + self.show, gajim.config.set_per('statusmsg', '_last_' + self.show,
'activity', self.pep_dict['activity']) 'activity', self.pep_dict['activity'])
@ -720,8 +720,8 @@ class ChangeStatusMessageDialog(TimeoutDialog):
'subactivity', self.pep_dict['subactivity']) 'subactivity', self.pep_dict['subactivity'])
gajim.config.set_per('statusmsg', '_last_' + self.show, gajim.config.set_per('statusmsg', '_last_' + self.show,
'activity_text', self.pep_dict['activity_text']) 'activity_text', self.pep_dict['activity_text'])
gajim.config.set_per('statusmsg', '_last_' + self.show, 'mood', gajim.config.set_per('statusmsg', '_last_' + self.show,
self.pep_dict['mood']) 'mood', self.pep_dict['mood'])
gajim.config.set_per('statusmsg', '_last_' + self.show, gajim.config.set_per('statusmsg', '_last_' + self.show,
'mood_text', self.pep_dict['mood_text']) 'mood_text', self.pep_dict['mood_text'])
else: else:
@ -777,11 +777,13 @@ class ChangeStatusMessageDialog(TimeoutDialog):
msg_name = msg_text_1l.decode('utf-8') msg_name = msg_text_1l.decode('utf-8')
def on_ok2(): def on_ok2():
self.preset_messages_dict[msg_name] = [msg_text, self.pep_dict.get( self.preset_messages_dict[msg_name] = [
'activity'), self.pep_dict.get('subactivity'), self.pep_dict.get( msg_text, self.pep_dict.get('activity'),
'activity_text'), self.pep_dict.get('mood'), self.pep_dict.get( self.pep_dict.get('subactivity'),
'mood_text')] self.pep_dict.get('activity_text'),
gajim.config.set_per('statusmsg', msg_name, 'message', msg_text_1l) self.pep_dict.get('mood'), self.pep_dict.get('mood_text')]
gajim.config.set_per('statusmsg', msg_name, 'message',
msg_text_1l)
gajim.config.set_per('statusmsg', msg_name, 'activity', gajim.config.set_per('statusmsg', msg_name, 'activity',
self.pep_dict.get('activity')) self.pep_dict.get('activity'))
gajim.config.set_per('statusmsg', msg_name, 'subactivity', gajim.config.set_per('statusmsg', msg_name, 'subactivity',
@ -1187,8 +1189,7 @@ class AboutDialog:
text = open(copying_file_path).read() text = open(copying_file_path).read()
dlg.set_license(text) dlg.set_license(text)
dlg.set_comments('%s\n%s %s\n%s %s' dlg.set_comments('%s\n%s %s\n%s %s' % (_('A GTK+ jabber client'),
% (_('A GTK+ jabber client'), \
_('GTK+ Version:'), self.tuple2str(gtk.gtk_version), \ _('GTK+ Version:'), self.tuple2str(gtk.gtk_version), \
_('PyGTK Version:'), self.tuple2str(gtk.pygtk_version))) _('PyGTK Version:'), self.tuple2str(gtk.pygtk_version)))
dlg.set_website('http://www.gajim.org/') dlg.set_website('http://www.gajim.org/')
@ -2132,7 +2133,8 @@ class SubscriptionRequestWindow:
""" """
menu = self.prepare_popup_menu() menu = self.prepare_popup_menu()
menu.show_all() menu.show_all()
gtkgui_helpers.popup_emoticons_under_button(menu, widget, self.window.window) gtkgui_helpers.popup_emoticons_under_button(menu, widget,
self.window.window)
class JoinGroupchatWindow: class JoinGroupchatWindow:
@ -2396,11 +2398,11 @@ class SynchroniseSelectAccountDialog:
self.accounts_treeview.set_model(model) self.accounts_treeview.set_model(model)
# columns # columns
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
self.accounts_treeview.insert_column_with_attributes(-1, self.accounts_treeview.insert_column_with_attributes(-1, _('Name'),
_('Name'), renderer, text=0) renderer, text=0)
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
self.accounts_treeview.insert_column_with_attributes(-1, self.accounts_treeview.insert_column_with_attributes(-1, _('Server'),
_('Server'), renderer, text=1) renderer, text=1)
self.xml.connect_signals(self) self.xml.connect_signals(self)
self.init_accounts() self.init_accounts()
@ -2421,8 +2423,8 @@ class SynchroniseSelectAccountDialog:
# Do not show the account we're sync'ing # Do not show the account we're sync'ing
continue continue
iter_ = model.append() iter_ = model.append()
model.set(iter_, 0, remote_account, 1, gajim.get_hostname_from_account( model.set(iter_, 0, remote_account, 1,
remote_account)) gajim.get_hostname_from_account(remote_account))
def on_cancel_button_clicked(self, widget): def on_cancel_button_clicked(self, widget):
self.dialog.destroy() self.dialog.destroy()
@ -2450,7 +2452,8 @@ class SynchroniseSelectContactsDialog:
def __init__(self, account, remote_account): def __init__(self, account, remote_account):
self.local_account = account self.local_account = account
self.remote_account = remote_account self.remote_account = remote_account
self.xml = gtkgui_helpers.get_gtk_builder('synchronise_select_contacts_dialog.ui') self.xml = gtkgui_helpers.get_gtk_builder(
'synchronise_select_contacts_dialog.ui')
self.dialog = self.xml.get_object('synchronise_select_contacts_dialog') self.dialog = self.xml.get_object('synchronise_select_contacts_dialog')
self.contacts_treeview = self.xml.get_object('contacts_treeview') self.contacts_treeview = self.xml.get_object('contacts_treeview')
model = gtk.ListStore(bool, str) model = gtk.ListStore(bool, str)
@ -2462,8 +2465,8 @@ class SynchroniseSelectContactsDialog:
self.contacts_treeview.insert_column_with_attributes(-1, self.contacts_treeview.insert_column_with_attributes(-1,
_('Synchronise'), renderer1, active=0) _('Synchronise'), renderer1, active=0)
renderer2 = gtk.CellRendererText() renderer2 = gtk.CellRendererText()
self.contacts_treeview.insert_column_with_attributes(-1, self.contacts_treeview.insert_column_with_attributes(-1, _('Name'),
_('Name'), renderer2, text=1) renderer2, text=1)
self.xml.connect_signals(self) self.xml.connect_signals(self)
self.init_contacts() self.init_contacts()
@ -3191,7 +3194,8 @@ class RosterItemExchangeWindow:
show_dialog = False show_dialog = False
# Connect to gtk builder # Connect to gtk builder
self.xml = gtkgui_helpers.get_gtk_builder('roster_item_exchange_window.ui') self.xml = gtkgui_helpers.get_gtk_builder(
'roster_item_exchange_window.ui')
self.window = self.xml.get_object('roster_item_exchange_window') self.window = self.xml.get_object('roster_item_exchange_window')
# Add Widgets. # Add Widgets.
@ -4118,8 +4122,7 @@ class PrivacyListsWindow:
'delete_privacy_list_button', 'open_privacy_list_button', 'delete_privacy_list_button', 'open_privacy_list_button',
'new_privacy_list_button', 'new_privacy_list_entry', 'new_privacy_list_button', 'new_privacy_list_entry',
'privacy_lists_refresh_button', 'close_privacy_lists_window_button'): 'privacy_lists_refresh_button', 'close_privacy_lists_window_button'):
self.__dict__[widget_to_add] = self.xml.get_object( self.__dict__[widget_to_add] = self.xml.get_object(widget_to_add)
widget_to_add)
self.draw_privacy_lists_in_combobox([]) self.draw_privacy_lists_in_combobox([])
self.privacy_lists_refresh() self.privacy_lists_refresh()
@ -4351,8 +4354,7 @@ class SoundChooserDialog(FileChooserDialog):
if os.path.exists(path_to_snd_file): if os.path.exists(path_to_snd_file):
callback(widget, path_to_snd_file) callback(widget, path_to_snd_file)
FileChooserDialog.__init__(self, FileChooserDialog.__init__(self, title_text = _('Choose Sound'),
title_text = _('Choose Sound'),
action = gtk.FILE_CHOOSER_ACTION_OPEN, action = gtk.FILE_CHOOSER_ACTION_OPEN,
buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK), gtk.STOCK_OPEN, gtk.RESPONSE_OK),
@ -4524,7 +4526,8 @@ class AddSpecialNotificationDialog:
jid is the jid for which we want to add special notification (sound and jid is the jid for which we want to add special notification (sound and
notification popups) notification popups)
""" """
self.xml = gtkgui_helpers.get_gtk_builder('add_special_notification_window.ui') self.xml = gtkgui_helpers.get_gtk_builder(
'add_special_notification_window.ui')
self.window = self.xml.get_object('add_special_notification_window') self.window = self.xml.get_object('add_special_notification_window')
self.condition_combobox = self.xml.get_object('condition_combobox') self.condition_combobox = self.xml.get_object('condition_combobox')
self.condition_combobox.set_active(0) self.condition_combobox.set_active(0)
@ -4578,7 +4581,8 @@ class AdvancedNotificationsWindow:
'tab_opened', 'sound', 'sound_file', 'popup', 'auto_open', 'tab_opened', 'sound', 'sound_file', 'popup', 'auto_open',
'run_command', 'command', 'systray', 'roster', 'urgency_hint'] 'run_command', 'command', 'systray', 'roster', 'urgency_hint']
def __init__(self): def __init__(self):
self.xml = gtkgui_helpers.get_gtk_builder('advanced_notifications_window.ui') self.xml = gtkgui_helpers.get_gtk_builder(
'advanced_notifications_window.ui')
self.window = self.xml.get_object('advanced_notifications_window') self.window = self.xml.get_object('advanced_notifications_window')
for w in ('conditions_treeview', 'config_vbox', 'event_combobox', for w in ('conditions_treeview', 'config_vbox', 'event_combobox',
'recipient_type_combobox', 'recipient_list_entry', 'delete_button', 'recipient_type_combobox', 'recipient_list_entry', 'delete_button',
@ -4798,10 +4802,12 @@ class AdvancedNotificationsWindow:
if not iter_: if not iter_:
return return
for opt in self.config_options: for opt in self.config_options:
val = gajim.config.get_per('notifications', str(self.active_num), opt) val = gajim.config.get_per('notifications', str(self.active_num),
val2 = gajim.config.get_per('notifications', str(self.active_num - 1),
opt) opt)
gajim.config.set_per('notifications', str(self.active_num), opt, val2) val2 = gajim.config.get_per('notifications',
str(self.active_num - 1), opt)
gajim.config.set_per('notifications', str(self.active_num), opt,
val2)
gajim.config.set_per('notifications', str(self.active_num - 1), opt, gajim.config.set_per('notifications', str(self.active_num - 1), opt,
val) val)
@ -4817,10 +4823,12 @@ class AdvancedNotificationsWindow:
if not iter_: if not iter_:
return return
for opt in self.config_options: for opt in self.config_options:
val = gajim.config.get_per('notifications', str(self.active_num), opt) val = gajim.config.get_per('notifications', str(self.active_num),
val2 = gajim.config.get_per('notifications', str(self.active_num + 1),
opt) opt)
gajim.config.set_per('notifications', str(self.active_num), opt, val2) val2 = gajim.config.get_per('notifications',
str(self.active_num + 1), opt)
gajim.config.set_per('notifications', str(self.active_num), opt,
val2)
gajim.config.set_per('notifications', str(self.active_num + 1), opt, gajim.config.set_per('notifications', str(self.active_num + 1), opt,
val) val)
@ -4942,7 +4950,8 @@ class AdvancedNotificationsWindow:
gajim.config.set_per('notifications', str(self.active_num), option, gajim.config.set_per('notifications', str(self.active_num), option,
'no') 'no')
else: else:
gajim.config.set_per('notifications', str(self.active_num), option, '') gajim.config.set_per('notifications', str(self.active_num),
option, '')
def on_disable_it_toggled(self, widget, oposite_widget, option): def on_disable_it_toggled(self, widget, oposite_widget, option):
if widget.get_active(): if widget.get_active():
@ -4954,7 +4963,8 @@ class AdvancedNotificationsWindow:
gajim.config.set_per('notifications', str(self.active_num), option, gajim.config.set_per('notifications', str(self.active_num), option,
'yes') 'yes')
else: else:
gajim.config.set_per('notifications', str(self.active_num), option, '') gajim.config.set_per('notifications', str(self.active_num), option,
'')
def on_use_sound_cb_toggled(self, widget): def on_use_sound_cb_toggled(self, widget):
self.on_use_it_toggled(widget, self.disable_sound_cb, 'sound') self.on_use_it_toggled(widget, self.disable_sound_cb, 'sound')
@ -5002,8 +5012,8 @@ class AdvancedNotificationsWindow:
self.on_disable_it_toggled(widget, self.use_auto_open_cb, 'auto_open') self.on_disable_it_toggled(widget, self.use_auto_open_cb, 'auto_open')
def on_run_command_cb_toggled(self, widget): def on_run_command_cb_toggled(self, widget):
gajim.config.set_per('notifications', str(self.active_num), 'run_command', gajim.config.set_per('notifications', str(self.active_num),
widget.get_active()) 'run_command', widget.get_active())
if widget.get_active(): if widget.get_active():
self.command_entry.set_sensitive(True) self.command_entry.set_sensitive(True)
else: else:
@ -5107,8 +5117,8 @@ class TransformChatToMUC:
if gajim.connections[account].is_zeroconf: if gajim.connections[account].is_zeroconf:
continue continue
for jid in gajim.contacts.get_jid_list(account): for jid in gajim.contacts.get_jid_list(account):
contact = \ contact = gajim.contacts.get_contact_with_highest_priority(
gajim.contacts.get_contact_with_highest_priority(account, jid) account, jid)
contact_transport = gajim.get_transport_name_from_jid(jid) contact_transport = gajim.get_transport_name_from_jid(jid)
# Add contact if it can be invited # Add contact if it can be invited
if invitable(contact, contact_transport) and \ if invitable(contact, contact_transport) and \
@ -5121,8 +5131,7 @@ class TransformChatToMUC:
# preselect treeview rows # preselect treeview rows
if self.preselected_jids and jid in self.preselected_jids: if self.preselected_jids and jid in self.preselected_jids:
path = self.store.get_path(iter_) path = self.store.get_path(iter_)
self.guests_treeview.get_selection().\ self.guests_treeview.get_selection().select_path(path)
select_path(path)
# show all # show all
self.window.show_all() self.window.show_all()
@ -5377,7 +5386,8 @@ class VoIPCallReceivedDialog(object):
# do the substitution # do the substitution
self.dialog.set_property('secondary-text', self.dialog.set_property('secondary-text',
_('%(contact)s wants to start %(type)s session with you. Do you want ' _('%(contact)s wants to start %(type)s session with you. Do you want '
'to answer the call?') % {'contact': self.contact_text, 'type': types_text}) 'to answer the call?') % {'contact': self.contact_text,
'type': types_text})
def add_contents(self, content_types): def add_contents(self, content_types):
for type_ in content_types: for type_ in content_types: