diff --git a/src/advanced_configuration_window.py b/src/advanced_configuration_window.py index 5481d2aaa..c76f3afa5 100644 --- a/src/advanced_configuration_window.py +++ b/src/advanced_configuration_window.py @@ -209,7 +209,6 @@ class AdvancedConfigurationWindow(object): else: self.remember_option(option, modelrow[1], newval) gajim.config.set(option, newval) - gajim.interface.save_config() modelrow[1] = self.right_true_dict[newval] self.check_for_restart() @@ -244,7 +243,6 @@ class AdvancedConfigurationWindow(object): else: self.remember_option(option, modelrow[1], text) gajim.config.set(option, text) - gajim.interface.save_config() modelrow[1] = text self.check_for_restart() @@ -279,7 +277,6 @@ class AdvancedConfigurationWindow(object): else: self.remember_option(option, modelrow[C_VALUE], default) gajim.config.set(option, default) - gajim.interface.save_config() modelrow[C_VALUE] = self.right_true_dict[default] self.check_for_restart() else: diff --git a/src/common/config.py b/src/common/config.py index 35078e3af..61c669fd1 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -36,7 +36,9 @@ import sys import re import copy import defs +import gobject +from common import gajim ( OPT_TYPE, @@ -618,6 +620,7 @@ class Config: return self.__options[1][optname] = value + self._timeout_save() def get(self, optname=None): if not optname: @@ -660,6 +663,7 @@ class Config: opt[1][name] = {} for o in opt[0]: opt[1][name][o] = opt[0][o][OPT_VAL] + self._timeout_save() def del_per(self, typename, name, subname = None): # per_group_of_option if typename not in self.__options_per_key: @@ -672,6 +676,7 @@ class Config: # if subname is specified, delete the item in the group. elif subname in opt[1][name]: del opt[1][name][subname] + self._timeout_save() def set_per(self, optname, key, subname, value): # per_group_of_option if optname not in self.__options_per_key: @@ -693,6 +698,7 @@ class Config: # raise RuntimeError, '%s of %s cannot be None' % optname return obj[subname] = value + self._timeout_save() def get_per(self, optname, key=None, subname=None): # per_group_of_option if optname not in self.__options_per_key: @@ -778,9 +784,19 @@ class Config: for opt in self.__options[0]: self.__options[1][opt] = self.__options[0][opt][OPT_VAL] + def _really_save(self): + gajim.interface.save_config() + return False + + def _timeout_save(self): + if self.save_timeout_id: + return + self.save_timeout_id = gobject.timeout_add(1000, self._really_save) + def __init__(self): #init default values self._init_options() + self.save_timeout_id = None for event in self.soundevents_default: default = self.soundevents_default[event] self.add_per('soundevents', event) diff --git a/src/config.py b/src/config.py index 6f95fd215..3a6382a56 100644 --- a/src/config.py +++ b/src/config.py @@ -610,7 +610,6 @@ class PreferencesWindow: if change_sensitivity_widgets: for w in change_sensitivity_widgets: w.set_sensitive(widget.get_active()) - gajim.interface.save_config() def on_per_account_checkbutton_toggled(self, widget, config_name, change_sensitivity_widgets=None): @@ -620,7 +619,6 @@ class PreferencesWindow: if change_sensitivity_widgets: for w in change_sensitivity_widgets: w.set_sensitive(widget.get_active()) - gajim.interface.save_config() def _get_all_controls(self): for ctrl in gajim.interface.msg_win_mgr.get_controls(): @@ -700,21 +698,18 @@ class PreferencesWindow: active = widget.get_active() config_type = common.config.opt_one_window_types[active] gajim.config.set('one_message_window', config_type) - gajim.interface.save_config() gajim.interface.msg_win_mgr.reconfig() def on_show_roster_on_startup_changed(self, widget): active = widget.get_active() config_type = common.config.opt_show_roster_on_startup[active] gajim.config.set('show_roster_on_startup', config_type) - gajim.interface.save_config() def on_compact_view_checkbutton_toggled(self, widget): active = widget.get_active() for ctrl in self._get_all_controls(): ctrl.chat_buttons_set_visible(active) gajim.config.set('compact_view', active) - gajim.interface.save_config() def on_xhtml_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'ignore_incoming_xhtml') @@ -744,7 +739,6 @@ class PreferencesWindow: def on_speller_checkbutton_toggled(self, widget): active = widget.get_active() gajim.config.set('use_speller', active) - gajim.interface.save_config() if active: lang = gajim.config.get('speller_language') if not lang: @@ -776,7 +770,6 @@ class PreferencesWindow: # begin repainting themed widgets throughout gajim.interface.roster.repaint_themed_widgets() gajim.interface.roster.change_roster_style(None) - gajim.interface.save_config() def update_theme_list(self): theme_combobox = self.xml.get_object('theme_combobox') @@ -803,7 +796,6 @@ class PreferencesWindow: icon_string = model[active][1].decode('utf-8') gajim.config.set('iconset', icon_string) gtkgui_helpers.reload_jabber_state_images() - gajim.interface.save_config() def on_transports_iconsets_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'use_transports_iconsets') @@ -898,7 +890,6 @@ class PreferencesWindow: color_string = gtkgui_helpers.make_color_string(color) gajim.config.set(text, color_string) self.update_text_tags() - gajim.interface.save_config() def on_preference_widget_font_set(self, widget, text): if widget: @@ -907,7 +898,6 @@ class PreferencesWindow: font = '' gajim.config.set(text, font) self.update_text_font() - gajim.interface.save_config() def update_text_font(self): """ @@ -988,7 +978,6 @@ class PreferencesWindow: self.draw_color_widgets() self.update_text_tags() - gajim.interface.save_config() def _set_color(self, state, widget_name, option): """ @@ -1000,7 +989,6 @@ class PreferencesWindow: else: color_string = '' gajim.config.set(option, color_string) - gajim.interface.save_config() def on_incoming_msg_checkbutton_toggled(self, widget): state = widget.get_active() @@ -1022,7 +1010,6 @@ class PreferencesWindow: gajim.interface.sleeper = common.sleepy.Sleepy( gajim.config.get('autoawaytime') * 60, gajim.config.get('autoxatime') * 60) - gajim.interface.save_config() def on_auto_away_message_entry_changed(self, widget): gajim.config.set('autoaway_message', widget.get_text().decode('utf-8')) @@ -1037,7 +1024,6 @@ class PreferencesWindow: gajim.interface.sleeper = common.sleepy.Sleepy( gajim.config.get('autoawaytime') * 60, gajim.config.get('autoxatime') * 60) - gajim.interface.save_config() def on_auto_xa_message_entry_changed(self, widget): gajim.config.set('autoxa_message', widget.get_text().decode('utf-8')) @@ -1106,7 +1092,6 @@ class PreferencesWindow: model[iter_][i].decode('utf-8')) i += 1 iter_ = model.iter_next(iter_) - gajim.interface.save_config() def on_msg_treemodel_row_changed(self, model, path, iter_): self.save_status_messages(model) @@ -1152,19 +1137,15 @@ class PreferencesWindow: elif widget.get_active() == 1: gajim.config.set('autodetect_browser_mailer', False) self.xml.get_object('custom_apps_frame').show() - gajim.interface.save_config() def on_custom_browser_entry_changed(self, widget): gajim.config.set('custombrowser', widget.get_text().decode('utf-8')) - gajim.interface.save_config() def on_custom_mail_client_entry_changed(self, widget): gajim.config.set('custommailapp', widget.get_text().decode('utf-8')) - gajim.interface.save_config() def on_custom_file_manager_entry_changed(self, widget): gajim.config.set('custom_file_manager', widget.get_text().decode('utf-8')) - gajim.interface.save_config() def on_log_show_changes_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'log_contact_status_changes') @@ -2472,7 +2453,6 @@ class AccountsWindow: if change_sensitivity_widgets: for w in change_sensitivity_widgets: w.set_sensitive(widget.get_active()) - gajim.interface.save_config() def on_merge_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'mergeaccounts') @@ -2487,7 +2467,6 @@ class AccountsWindow: if account == gajim.ZEROCONF_ACC_NAME: gajim.connections[account].disable_account() del gajim.connections[account] - gajim.interface.save_config() del gajim.interface.instances[account] del gajim.interface.minimized_controls[account] del gajim.nicks[account] @@ -2557,7 +2536,6 @@ class AccountsWindow: gajim.interface.roster.regroup = False gajim.interface.roster.setup_and_draw_roster() gajim.interface.roster.set_actions_menu_needs_rebuild() - gajim.interface.save_config() def on_enable_zeroconf_checkbutton2_toggled(self, widget): # don't do anything if there is an account with the local name but is a @@ -3072,7 +3050,6 @@ class RemoveAccountWindow: del gajim.connections[self.account] gajim.logger.remove_roster(gajim.get_jid_from_account(self.account)) gajim.config.del_per('accounts', self.account) - gajim.interface.save_config() del gajim.interface.instances[self.account] if self.account in gajim.nicks: del gajim.interface.minimized_controls[self.account] @@ -4025,7 +4002,6 @@ class AccountCreationWizardWindow: gajim.interface.roster.regroup = False gajim.interface.roster.setup_and_draw_roster() gajim.interface.roster.set_actions_menu_needs_rebuild() - gajim.interface.save_config() class ManagePEPServicesWindow: def __init__(self, account): @@ -4173,7 +4149,6 @@ class ManageSoundsWindow: bool(model[path][0])) gajim.config.set_per('soundevents', sound_event, 'path', model[iter_][2].decode('utf-8')) - gajim.interface.save_config() def sound_toggled_cb(self, cell, path): model = self.sound_tree.get_model() diff --git a/src/dialogs.py b/src/dialogs.py index d5456d663..2224397a1 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2983,7 +2983,6 @@ class SingleMessageWindow: width, height = self.window.get_size() gajim.config.set('single-msg-width', width) gajim.config.set('single-msg-height', height) - gajim.interface.save_config() def on_single_message_window_delete_event(self, window, ev): self.save_pos() diff --git a/src/disco.py b/src/disco.py index fdf652be5..94643b01b 100644 --- a/src/disco.py +++ b/src/disco.py @@ -828,7 +828,6 @@ _('This type of service does not contain any items to browse.')) self.address_comboboxentry.append_text(j) gajim.config.set('latest_disco_addresses', ' '.join(self.latest_addresses)) - gajim.interface.save_config() self.travel(jid, '') def on_services_treeview_row_activated(self, widget, path, col = 0): diff --git a/src/gajim_themes_window.py b/src/gajim_themes_window.py index 1c925817d..0a8c64213 100644 --- a/src/gajim_themes_window.py +++ b/src/gajim_themes_window.py @@ -291,12 +291,10 @@ class GajimThemesWindow: # use faster functions for this if self.current_option == 'banner': gajim.interface.roster.repaint_themed_widgets() - gajim.interface.save_config() return if self.no_update: return gajim.interface.roster.change_roster_style(self.current_option) - gajim.interface.save_config() def _set_font(self): """ @@ -318,7 +316,6 @@ class GajimThemesWindow: if self.no_update: return gajim.interface.roster.change_roster_style(self.current_option) - gajim.interface.save_config() def _toggle_font_widgets(self, font_props): """ diff --git a/src/history_window.py b/src/history_window.py index 2b3ad5742..3319eee58 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -654,5 +654,3 @@ class HistoryWindow: gajim.config.set('history_window_y-position', y) gajim.config.set('history_window_width', width); gajim.config.set('history_window_height', height); - - gajim.interface.save_config() diff --git a/src/message_window.py b/src/message_window.py index 57d4cc5bd..7537c8f02 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -1198,7 +1198,6 @@ class MessageWindowMgr(gobject.GObject): def reconfig(self): for w in self.windows(): self.save_state(w) - gajim.interface.save_config() mode = gajim.config.get('one_message_window') if self.mode == common.config.opt_one_window_types.index(mode): # No change diff --git a/src/statusicon.py b/src/statusicon.py index a8a396228..f5bc54d77 100644 --- a/src/statusicon.py +++ b/src/statusicon.py @@ -367,7 +367,6 @@ class StatusIcon: def on_sounds_mute_menuitem_activate(self, widget): gajim.config.set('sounds_on', not widget.get_active()) - gajim.interface.save_config() def on_show_roster_menuitem_activate(self, widget): win = gajim.interface.roster.window