Commit 000e168c authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Migrate app.config.set()

parent 3da2859b
......@@ -124,7 +124,7 @@ def on_single_message(_action, param):
def on_merge_accounts(action, param):
action.set_state(param)
value = param.get_boolean()
app.config.set('mergeaccounts', value)
app.settings.set('mergeaccounts', value)
# Do not merge accounts if only one active
if len(app.connections) >= 2:
app.interface.roster.regroup = value
......
......@@ -797,12 +797,12 @@ def on_num_button_released(self, _released):
def on_mic_hscale_value_changed(self, _widget, value):
self._get_audio_content().set_mic_volume(value / 100)
# Save volume to config
app.config.set('audio_input_volume', value)
app.settings.set('audio_input_volume', value)
def on_sound_hscale_value_changed(self, _widget, value):
self._get_audio_content().set_out_volume(value / 100)
# Save volume to config
app.config.set('audio_output_volume', value)
app.settings.set('audio_output_volume', value)
def on_location_eventbox_button_release_event(self, _widget, _event):
if 'geoloc' in self.contact.pep:
......
......@@ -754,7 +754,7 @@ def _on_message_textview_paste_event(self, _texview):
def _paste_event_confirmed(self, is_checked, image):
if is_checked:
app.config.set('confirm_paste_image', False)
app.settings.set('confirm_paste_image', False)
dir_ = tempfile.gettempdir()
path = os.path.join(dir_, '%s.png' % str(uuid.uuid4()))
......
......@@ -989,8 +989,8 @@ def save_roster_position(window):
return
x_pos, y_pos = window.get_position()
log.debug('Save roster position: %s %s', x_pos, y_pos)
app.config.set('roster_x-position', x_pos)
app.config.set('roster_y-position', y_pos)
app.settings.set('roster_x-position', x_pos)
app.settings.set('roster_y-position', y_pos)
class Singleton(type):
......
......@@ -1724,13 +1724,13 @@ def allow_shutdown(self, method, on_yes, on_no, on_minimize):
def on_ok(is_checked):
if is_checked:
# User does not want to be asked again
app.config.set('confirm_close_muc', False)
app.settings.set('confirm_close_muc', False)
on_yes(self)
def on_cancel(is_checked):
if is_checked:
# User does not want to be asked again
app.config.set('confirm_close_muc', False)
app.settings.set('confirm_close_muc', False)
on_no(self)
NewConfirmationCheckDialog(
......
......@@ -221,7 +221,7 @@ def _on_treeview_row_activated(self, _treeview, path, _column):
app.config.set_per(optname, key, option, newval)
else:
self._remember_option(option, modelrow[1], newval)
app.config.set(option, newval)
app.settings.set(option, newval)
modelrow[1] = self.right_true_dict[newval]
self._check_for_restart()
......@@ -262,7 +262,7 @@ def _on_config_edited(self, _cell, path, text):
app.config.set_per(optname, key, option, text)
else:
self._remember_option(option, modelrow[1], text)
app.config.set(option, text)
app.settings.set(option, text)
modelrow[1] = text
self._check_for_restart()
......@@ -298,7 +298,7 @@ def _on_reset_button_clicked(self, _widget):
option,
modelrow[Column.VALUE],
default)
app.config.set(option, default)
app.settings.set(option, default)
modelrow[Column.VALUE] = self.right_true_dict[default]
self._check_for_restart()
else:
......
......@@ -127,7 +127,7 @@ def set_dark_theme(value=None):
if value is None:
value = app.settings.get('dark_theme')
else:
app.config.set('dark_theme', value)
app.settings.set('dark_theme', value)
if settings is None:
return
......@@ -204,7 +204,7 @@ def _determine_theme_path(self):
theme_path = self.get_theme_path(theme)
if not theme or not theme_path.exists():
log.warning('Theme %s not found, fallback to default', theme)
app.config.set('roster_theme', 'default')
app.settings.set('roster_theme', 'default')
log.info('Use Theme: default')
return self.get_theme_path('default', user=False)
log.info('Use Theme: %s', theme)
......@@ -467,7 +467,7 @@ def change_theme(self, theme):
return False
self._load_selected(theme_path)
self._activate_theme()
app.config.set('roster_theme', theme)
app.settings.set('roster_theme', theme)
log.info('Change Theme: Successful switched to %s', theme)
return True
......
......@@ -758,7 +758,7 @@ def _on_go_button_clicked(self, widget):
self.address_comboboxtext.get_model().clear()
for j in self.latest_addresses:
self.address_comboboxtext.append_text(j)
app.config.set('latest_disco_addresses',
app.settings.set('latest_disco_addresses',
' '.join(self.latest_addresses))
self.travel(jid, None)
......
......@@ -305,11 +305,11 @@ def _get_current_theme():
themes = helpers.get_available_emoticon_themes()
if theme not in themes:
if sys.platform not in ('win32', 'darwin'):
app.config.set('emoticons_theme', 'font')
app.settings.set('emoticons_theme', 'font')
theme = 'font'
else:
# Win/Mac fallback to noto
app.config.set('emoticons_theme', 'noto')
app.settings.set('emoticons_theme', 'noto')
theme = 'noto'
return theme
......
......@@ -379,7 +379,7 @@ def send_file(self, account, contact, file_path, file_desc=''):
def _start_receive(self, file_path, account, contact, file_props):
file_dir = os.path.dirname(file_path)
if file_dir:
app.config.set('last_save_dir', file_dir)
app.settings.set('last_save_dir', file_dir)
file_props.file_name = file_path
file_props.type_ = 'r'
self.add_transfer(account, contact, file_props)
......@@ -389,7 +389,7 @@ def _start_receive(self, file_path, account, contact, file_props):
def on_file_request_accepted(self, account, contact, file_props):
def _on_accepted(account, contact, file_props, file_path):
if os.path.exists(file_path):
app.config.set('last_save_dir', os.path.dirname(file_path))
app.settings.set('last_save_dir', os.path.dirname(file_path))
# Check if we have write permissions
if not os.access(file_path, os.W_OK):
......@@ -924,7 +924,7 @@ def _on_cancel_button_clicked(self, widget):
self.set_status(file_props, 'stop')
def _on_notify_ft_complete_toggled(self, widget, *args):
app.config.set('notify_on_file_complete', widget.get_active())
app.settings.set('notify_on_file_complete', widget.get_active())
def _on_file_transfers_dialog_delete_event(self, widget, event):
self.window.hide()
......@@ -1075,7 +1075,7 @@ def _set_files(self, filenames):
last_dir = row.path.parent
self._ui.listbox.add(row)
self._ui.listbox.show_all()
app.config.set('last_send_dir', str(last_dir))
app.settings.set('last_send_dir', str(last_dir))
def _get_description(self):
buffer_ = self._ui.description.get_buffer()
......
......@@ -809,7 +809,7 @@ def save_state(self):
x, y = self.get_window().get_root_origin()
width, height = self.get_size()
app.config.set('history_window_x-position', x)
app.config.set('history_window_y-position', y)
app.config.set('history_window_width', width)
app.config.set('history_window_height', height)
app.settings.set('history_window_x-position', x)
app.settings.set('history_window_y-position', y)
app.settings.set('history_window_width', width)
app.settings.set('history_window_height', height)
......@@ -422,7 +422,7 @@ def _on_key_press(self, widget, event):
def on_checkbutton_toggled(self, widget, config_name,
change_sensitivity_widgets=None):
app.config.set(config_name, widget.get_active())
app.settings.set(config_name, widget.get_active())
if change_sensitivity_widgets:
for w in change_sensitivity_widgets:
w.set_sensitive(widget.get_active())
......@@ -444,11 +444,11 @@ def _get_all_muc_controls(self):
### General tab ###
def on_one_window_type_combo_changed(self, combobox):
app.config.set('one_message_window', combobox.get_active_id())
app.settings.set('one_message_window', combobox.get_active_id())
app.interface.msg_win_mgr.reconfig()
def on_show_roster_on_startup_changed(self, combobox):
app.config.set('show_roster_on_startup', combobox.get_active_id())
app.settings.set('show_roster_on_startup', combobox.get_active_id())
def on_quit_on_roster_x_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'quit_on_roster_x_button')
......@@ -456,13 +456,13 @@ def on_quit_on_roster_x_checkbutton_toggled(self, widget):
def on_tab_placement_changed(self, widget):
active = widget.get_active()
if active == 0: # top
app.config.set('tabs_position', 'top')
app.settings.set('tabs_position', 'top')
elif active == 1: # bottom
app.config.set('tabs_position', 'bottom')
app.settings.set('tabs_position', 'bottom')
elif active == 2: # left
app.config.set('tabs_position', 'left')
app.settings.set('tabs_position', 'left')
else: # right
app.config.set('tabs_position', 'right')
app.settings.set('tabs_position', 'right')
def on_merge_accounts_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'mergeaccounts')
......@@ -501,14 +501,14 @@ def on_auto_copy_toggled(self, widget):
def on_speller_checkbutton_toggled(self, widget):
active = widget.get_active()
app.config.set('use_speller', active)
app.settings.set('use_speller', active)
if not active:
return
lang = app.settings.get('speller_language')
gspell_lang = Gspell.language_lookup(lang)
if gspell_lang is None:
gspell_lang = Gspell.language_get_default()
app.config.set('speller_language', gspell_lang.get_code())
app.settings.set('speller_language', gspell_lang.get_code())
self.apply_speller()
def apply_speller(self):
......@@ -530,7 +530,7 @@ def on_subject_on_join_checkbutton_toggled(self, widget):
def _on_sync_threshold_changed(self, widget):
active = widget.get_active_id()
app.config.set('public_room_sync_threshold', int(active))
app.settings.set('public_room_sync_threshold', int(active))
def _on_join_leave_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'gc_print_join_left_default')
......@@ -555,26 +555,26 @@ def on_show_chatstate_in_banner_toggled(self, widget):
def on_systray_combobox_changed(self, widget):
active = widget.get_active()
if active == 0:
app.config.set('trayicon', 'never')
app.settings.set('trayicon', 'never')
app.interface.hide_systray()
elif active == 1:
app.config.set('trayicon', 'on_event')
app.settings.set('trayicon', 'on_event')
app.interface.show_systray()
else:
app.config.set('trayicon', 'always')
app.settings.set('trayicon', 'always')
app.interface.show_systray()
def on_event_received_combobox_changed(self, widget):
active = widget.get_active()
if active == 0:
app.config.set('autopopup', True)
app.config.set('notify_on_new_message', False)
app.settings.set('autopopup', True)
app.settings.set('notify_on_new_message', False)
elif active == 1:
app.config.set('autopopup', False)
app.config.set('notify_on_new_message', True)
app.settings.set('autopopup', False)
app.settings.set('notify_on_new_message', True)
else:
app.config.set('autopopup', False)
app.config.set('notify_on_new_message', False)
app.settings.set('autopopup', False)
app.settings.set('notify_on_new_message', False)
def on_notify_on_signin_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_signin')
......@@ -609,12 +609,12 @@ def on_auto_away_checkbutton_toggled(self, widget):
def on_auto_away_time_spinbutton_value_changed(self, widget):
aat = widget.get_value_as_int()
app.config.set('autoawaytime', aat)
app.settings.set('autoawaytime', aat)
idle.Monitor.set_interval(app.settings.get('autoawaytime') * 60,
app.settings.get('autoxatime') * 60)
def on_auto_away_message_entry_changed(self, widget):
app.config.set('autoaway_message', widget.get_text())
app.settings.set('autoaway_message', widget.get_text())
def on_auto_xa_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autoxa',
......@@ -623,12 +623,12 @@ def on_auto_xa_checkbutton_toggled(self, widget):
def on_auto_xa_time_spinbutton_value_changed(self, widget):
axt = widget.get_value_as_int()
app.config.set('autoxatime', axt)
app.settings.set('autoxatime', axt)
idle.Monitor.set_interval(app.settings.get('autoawaytime') * 60,
app.settings.get('autoxatime') * 60)
def on_auto_xa_message_entry_changed(self, widget):
app.config.set('autoxa_message', widget.get_text())
app.settings.set('autoxa_message', widget.get_text())
def on_sign_in_status_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'ask_online_status')
......@@ -643,7 +643,7 @@ def on_status_change_checkbutton_toggled(self, widget):
@staticmethod
def on_theme_combobox_changed(combobox):
theme = combobox.get_active_id()
app.config.set('roster_theme', theme)
app.settings.set('roster_theme', theme)
app.css_config.change_theme(theme)
app.nec.push_incoming_event(NetworkEvent('theme-update'))
......@@ -670,13 +670,13 @@ def on_emoticons_combobox_changed(self, widget):
active = widget.get_active()
model = widget.get_model()
emot_theme = model[active][0]
app.config.set('emoticons_theme', emot_theme)
app.settings.set('emoticons_theme', emot_theme)
from gajim.gtk.emoji_chooser import emoji_chooser
emoji_chooser.load()
self.toggle_emoticons()
def on_convert_ascii_toggle(self, widget):
app.config.set('ascii_emoticons', widget.get_active())
app.settings.set('ascii_emoticons', widget.get_active())
app.interface.make_regexps()
def toggle_emoticons(self):
......@@ -690,7 +690,7 @@ def on_iconset_combobox_changed(self, widget):
model = widget.get_model()
active = widget.get_active()
icon_string = model[active][1]
app.config.set('iconset', icon_string)
app.settings.set('iconset', icon_string)
app.interface.roster.update_icons()
def on_transports_iconsets_checkbutton_toggled(self, widget):
......@@ -704,7 +704,7 @@ def on_av_combobox_changed(self, combobox, config_name):
model = combobox.get_model()
active = combobox.get_active()
device = model[active][1]
app.config.set(config_name, device)
app.settings.set(config_name, device)
return device
def on_audio_input_combobox_changed(self, widget):
......@@ -735,7 +735,7 @@ def on_video_input_combobox_changed(self, widget):
src.link(self.av_sink)
self.av_src = src
self.av_pipeline.set_state(Gst.State.PLAYING)
app.config.set('video_input_device', device)
app.settings.set('video_input_device', device)
def _on_live_preview_toggled(self, widget):
if widget.get_active():
......@@ -824,7 +824,7 @@ def on_stun_checkbutton_toggled(self, widget):
self._ui.stun_server_entry])
def stun_server_entry_changed(self, widget):
app.config.set('stun_server', widget.get_text())
app.settings.set('stun_server', widget.get_text())
### Advanced tab ###
# Proxies
......@@ -835,7 +835,7 @@ def on_proxies_combobox_changed(self, widget):
proxy = widget.get_model()[active][0]
if proxy == _('No Proxy'):
proxy = ''
app.config.set('global_proxy', proxy)
app.settings.set('global_proxy', proxy)
def on_manage_proxies_button_clicked(self, _widget):
app.app.activate_action('manage-proxies')
......@@ -879,7 +879,7 @@ def _on_reset_help_clicked(self, widget):
'start_chat',
]
for hint in helping_hints:
app.config.set('show_help_%s' % hint, True)
app.settings.set('show_help_%s' % hint, True)
def on_open_advanced_editor_button_clicked(self, _widget):
open_window('AdvancedConfig')
......@@ -232,7 +232,7 @@ def __get_value(type_, value, account):
def set_value(self, state):
if self.type_ == SettingType.CONFIG:
app.config.set(self.value, state)
app.settings.set(self.value, state)
if self.type_ == SettingType.ACCOUNT_CONFIG:
if self.value == 'password':
passwords.save_password(self.account, state)
......
......@@ -140,11 +140,11 @@ def _set_cursor_to_end(self):
def _save_position(self):
# save the window size and position
x_pos, y_pos = self.get_position()
app.config.set('single-msg-x-position', x_pos)
app.config.set('single-msg-y-position', y_pos)
app.settings.set('single-msg-x-position', x_pos)
app.settings.set('single-msg-y-position', y_pos)
width, height = self.get_size()
app.config.set('single-msg-width', width)
app.config.set('single-msg-height', height)
app.settings.set('single-msg-width', width)
app.settings.set('single-msg-height', height)
def _on_to_entry_changed(self, _widget):
entry = self._ui.to_entry.get_text()
......
......@@ -100,7 +100,7 @@ def _on_file_set(self, button):
filename = button.get_filename()
directory = os.path.dirname(filename)
app.config.set('last_sounds_dir', directory)
app.settings.set('last_sounds_dir', directory)
path_to_snd_file = helpers.strip_soundfile_path(filename)
# set new path to sounds_model
......
......@@ -264,7 +264,7 @@ def _on_key_press(self, _widget, event):
def _on_infobar_response(self, _widget, response):
if response == Gtk.ResponseType.CLOSE:
self._ui.infobar.set_revealed(False)
app.config.set('show_help_start_chat', False)
app.settings.set('show_help_start_chat', False)
def _start_new_chat(self, row):
if row.new:
......
......@@ -290,7 +290,7 @@ def _on_show_all_events(_widget):
@staticmethod
def _on_sounds_mute(widget):
app.config.set('sounds_on', not widget.get_active())
app.settings.set('sounds_on', not widget.get_active())
@staticmethod
def _on_show_roster(_widget):
......
......@@ -304,7 +304,7 @@ def _on_add_new_theme(self, *args):
@staticmethod
def _apply_theme(theme):
app.config.set('roster_theme', theme)
app.settings.set('roster_theme', theme)
app.css_config.change_theme(theme)
app.nec.push_incoming_event(NetworkEvent('theme-update'))
......
......@@ -1877,7 +1877,7 @@ def check_for_updates(self):
last_check = app.settings.get('last_update_check')
if not last_check:
def _on_cancel():
app.config.set('check_for_update', False)
app.settings.set('check_for_update', False)
def _on_check():
self._get_latest_release()
......@@ -1909,7 +1909,7 @@ def _get_latest_release(self):
def _on_update_checked(self, _session, message):
now = datetime.now()
app.config.set('last_update_check', now.strftime('%Y-%m-%d %H:%M'))
app.settings.set('last_update_check', now.strftime('%Y-%m-%d %H:%M'))
body = message.props.response_body.data
if not body:
......@@ -1922,11 +1922,11 @@ def _on_update_checked(self, _session, message):
if V(latest_version) > V(app.version):
def _on_cancel(is_checked):
if is_checked:
app.config.set('check_for_update', False)
app.settings.set('check_for_update', False)
def _on_update(is_checked):
if is_checked:
app.config.set('check_for_update', False)
app.settings.set('check_for_update', False)
helpers.open_uri('https://gajim.org/download')
NewConfirmationCheckDialog(
......
......@@ -348,7 +348,7 @@ def _on_window_delete(self, win, event):
if number_of_closed_control > 1:
def _on_yes1(checked):
if checked:
app.config.set('confirm_close_multiple_tabs', False)
app.settings.set('confirm_close_multiple_tabs', False)
self.dont_warn_on_delete = True
for ctrl in self.controls():
if ctrl.minimizable():
......@@ -1191,14 +1191,14 @@ def save_state(self, msg_win, width_adjust=0):
else:
win_maximized = msg_win.window.get_window().get_state() == \
Gdk.WindowState.MAXIMIZED
app.config.set(max_win_key, win_maximized)
app.settings.set(max_win_key, win_maximized)
width += width_adjust
app.config.set(size_width_key, width)
app.config.set(size_height_key, height)
app.settings.set(size_width_key, width)
app.settings.set(size_height_key, height)
if self.mode != self.ONE_MSG_WINDOW_NEVER:
app.config.set(pos_x_key, x)
app.config.set(pos_y_key, y)
app.settings.set(pos_x_key, x)
app.settings.set(pos_y_key, y)
def reconfig(self):
for w in self.windows():
......@@ -1220,7 +1220,7 @@ def reconfig(self):
# Stash current size so it can be restored if the MessageWindow
# is not longer embedded
roster_width = w.parent_paned.get_position()
app.config.set('roster_width', roster_width)
app.settings.set('roster_width', roster_width)
while w.notebook.get_n_pages():
page = w.notebook.get_nth_page(0)
......
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