Commit 084daf64 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Remove unnecessary dict lookups

parent e2919927
......@@ -97,10 +97,10 @@ def update_proxy_list(self):
self._settings.update_proxy_list(account)
def _check_relogin(self):
for account in self._need_relogin:
for account, r_settings in self._need_relogin.items():
settings = self._get_relogin_settings(account)
active = app.settings.get_account_setting(account, 'active')
if settings != self._need_relogin[account]:
if settings != r_settings:
self._need_relogin[account] = settings
if active:
self._relog(account)
......
......@@ -112,7 +112,7 @@ def __init__(self, account=None, contact_jid=None, user_nick=None, group=None):
# Jabber as first
liststore = self.protocol_combobox.get_model()
liststore.append(['XMPP', 'xmpp', 'jabber'])
for type_ in self.agents:
for type_, services in self.agents.items():
if type_ == 'jabber':
continue
if type_ in uf_type:
......@@ -121,7 +121,7 @@ def __init__(self, account=None, contact_jid=None, user_nick=None, group=None):
liststore.append([type_, type_ + '-online', type_])
if account:
for service in self.agents[type_]:
for service in services:
con = app.connections[account]
con.get_module('Gateway').request_gateway_prompt(service)
self.protocol_combobox.set_active(0)
......
......@@ -181,7 +181,7 @@ def _fill_model(self, node=None, parent=None):
if category != 'app':
continue
for setting, description in settings.items():
for setting in settings:
value = app.settings.get(setting)
if isinstance(value, bool):
value = BOOL_DICT[value]
......
......@@ -775,7 +775,7 @@ def _on_services_treeview_selection_changed(self, widget):
self.browser.update_actions()
def _on_entry_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_Return or event.keyval == Gdk.KEY_KP_Enter:
if event.keyval in (Gdk.KEY_Return, Gdk.KEY_KP_Enter):
self._on_go_button_clicked(widget)
......
......@@ -188,14 +188,13 @@ def _add_new_jid_row(self):
def _remove_new_jid_row(self):
if not self._new_contact_row_visible:
return
for account in self.new_contact_rows:
self._ui.contacts_listbox.remove(
self.new_contact_rows[account])
for row in self.new_contact_rows.values():
self._ui.contacts_listbox.remove(row)
self._new_contact_row_visible = False
def _update_new_jid_rows(self, search_text):
for account in self.new_contact_rows:
self.new_contact_rows[account].update_jid(search_text)
for row in self.new_contact_rows.values():
row.update_jid(search_text)
def _select_new_match(self, _entry, direction):
selected_row = self._ui.contacts_listbox.get_selected_row()
......
......@@ -434,16 +434,15 @@ def _add_new_jid_row(self):
def _remove_new_jid_row(self):
if not self.new_contact_row_visible:
return
for account in self.new_contact_rows:
self._ui.listbox.remove(
self.new_contact_rows[account])
for account, row in self.new_contact_rows.items():
self._ui.listbox.remove(row)
self._ui.listbox.remove(
self.new_groupchat_rows[account])
self.new_contact_row_visible = False
def _update_new_jid_rows(self, search_text):
for account in self.new_contact_rows:
self.new_contact_rows[account].update_jid(search_text)
for account, row in self.new_contact_rows.items():
row.update_jid(search_text)
self.new_groupchat_rows[account].update_jid(search_text)
def _select_new_match(self, _entry, direction):
......
......@@ -227,11 +227,11 @@ def _build_preset_popover(self):
def _init_activities(self):
group = None
for category in ACTIVITIES:
for category, activity_dict in ACTIVITIES.items():
icon_name = get_activity_icon_name(category)
item = self._ui.get_object(category + '_image')
item.set_from_icon_name(icon_name, Gtk.IconSize.MENU)
item.set_tooltip_text(ACTIVITIES[category]['category'])
item.set_tooltip_text(activity_dict['category'])
category_box = self._ui.get_object(category + '_box')
......@@ -248,7 +248,7 @@ def _init_activities(self):
spacing=6)
icon_box.pack_start(icon, False, False, 0)
label = Gtk.Label(
label='<b>%s</b>' % ACTIVITIES[category]['category'])
label='<b>%s</b>' % activity_dict['category'])
label.set_use_markup(True)
icon_box.pack_start(label, False, False, 0)
self._activity_btns[act].add(icon_box)
......@@ -257,7 +257,7 @@ def _init_activities(self):
'toggled', self._on_activity_toggled, [category, 'other'])
category_box.pack_start(self._activity_btns[act], False, False, 0)
activities = list(ACTIVITIES[category].keys())
activities = list(activity_dict.keys())
activities.sort()
for activity in activities:
if activity == 'category':
......@@ -274,7 +274,7 @@ def _init_activities(self):
icon_name = get_activity_icon_name(category, activity)
icon = Gtk.Image.new_from_icon_name(
icon_name, Gtk.IconSize.MENU)
label = Gtk.Label(label=ACTIVITIES[category][activity])
label = Gtk.Label(label=activity_dict[activity])
icon_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
spacing=6)
icon_box.pack_start(icon, False, False, 0)
......
......@@ -283,9 +283,9 @@ def _make_menu(self, _event_button, event_time):
@staticmethod
def _on_show_all_events(_widget):
events = app.events.get_systray_events()
for account in events:
for jid in events[account]:
for event in events[account][jid]:
for account, acc_events in events.items():
for jid in acc_events:
for event in acc_events[jid]:
app.interface.handle_event(account, jid, event.type_)
@staticmethod
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment