def on_startup_check_toggled(self, widget, data=None): if widget.get_active(): if not os.path.exists(config.get_startup_file_path()): if not os.path.exists(config.get_startup_file_dir()): os.makedirs(config.get_startup_file_dir()) shutil.copyfile(config.add_data_prefix("cloudsn.desktop"), config.get_startup_file_path()) else: os.remove (config.get_startup_file_path())
def preferences_action_activate_cb (self, widget, data=None): self.pref_dialog = self.builder.get_object("preferences_dialog") self.pref_dialog.set_transient_for(self.window) self.pref_dialog.set_destroy_with_parent (True) indicator_combo = self.builder.get_object("indicator_combo") indicators_store = self.builder.get_object("indicators_store"); minutes=self.builder.get_object("minutes_spin") max_not_spin=self.builder.get_object("max_not_spin") startup_check = self.builder.get_object("startup_check") minutes.set_value (float(self.config.get_prefs()["minutes"])) max_not_spin.set_value (float(self.config.get_prefs()["max_notifications"])) if os.path.exists(config.get_startup_file_path()): startup_check.set_active(True) else: startup_check.set_active(False) #Populate indicator combo i=0 indicator_name = self.config.get_prefs()["indicator"] indicators_store.clear() for indi in self.im.get_indicators(): indicators_store.append([indi.get_name()]) if indi.get_name() == indicator_name: indicator_combo.set_active(i) i+=1 response = self.pref_dialog.run() self.pref_dialog.hide() self.config.set_pref ("minutes", minutes.get_value()) self.config.set_pref ("max_notifications", max_not_spin.get_value()) iiter = indicator_combo.get_active_iter() if iiter: self.config.set_pref ("indicator", indicators_store.get_value(iiter,0)) #Check startup checkbox if startup_check.get_active(): if not os.path.exists(config.get_startup_file_path()): if not os.path.exists(config.get_startup_file_dir()): os.makedirs(config.get_startup_file_dir()) shutil.copyfile(config.add_data_prefix("cloudsn.desktop"), config.get_startup_file_path()) else: if os.path.exists(config.get_startup_file_path()): os.remove (config.get_startup_file_path()) self.config.save_prefs()
def load_window(self): from cloudsn.core.controller import Controller builder=gtk.Builder() builder.set_translation_domain("cloudsn") builder.add_from_file(config.add_data_prefix("preferences.ui")) builder.connect_signals(self) self.window=builder.get_object("dialog") self.minutes=builder.get_object("minutes_spin") self.max_not_spin=builder.get_object("max_not_spin") #tests self.store = builder.get_object("account_store"); self.account_tree = builder.get_object("account_treeview"); self.dialog_new = builder.get_object("account_new_dialog"); self.providers_combo = builder.get_object("providers_combo"); self.providers_store = builder.get_object("providers_store"); self.account_name_entry = builder.get_object("account_name_entry"); self.startup_check = builder.get_object("startup_check") self.indicator_combo = builder.get_object("indicator_combo") self.indicators_store = builder.get_object("indicators_store"); for prov in self.pm.get_providers(): self.providers_store.append([prov.get_icon(), prov.get_name()]) for acc in self.am.get_accounts(): self.store.append([acc.get_icon(), acc.get_name(), self.__get_account_date(acc), acc.get_active()]) self.providers_combo.set_active(0) self.minutes.set_value (float(self.config.get_prefs()["minutes"])) self.max_not_spin.set_value (float(self.config.get_prefs()["max_notifications"])) self.window.set_icon(config.get_cloudsn_icon()) self.dialog_new.set_icon(config.get_cloudsn_icon()) if os.path.exists(config.get_startup_file_path()): self.startup_check.set_active(True) else: self.startup_check.set_active(False) #Populate indicator combo i=0 indicator_name = self.config.get_prefs()["indicator"] for indi in self.im.get_indicators(): self.indicators_store.append([indi.get_name()]) if indi.get_name() == indicator_name: self.indicator_combo.set_active(i) i+=1 #Update the last check date Controller.get_instance().connect ("account-checked", self.__on_account_checked_cb) Controller.get_instance().connect ("account-check-error", self.__on_account_check_error_cb)
def preferences_action_activate_cb(self, widget, data=None): self.pref_dialog = self.builder.get_object("preferences_dialog") self.pref_dialog.set_transient_for(self.window) self.pref_dialog.set_destroy_with_parent(True) indicator_combo = self.builder.get_object("indicator_combo") indicators_store = self.builder.get_object("indicators_store") keyring_combo = self.builder.get_object("keyring_combo") keyring_store = self.builder.get_object("keyring_store") minutes = self.builder.get_object("minutes_spin") max_not_spin = self.builder.get_object("max_not_spin") startup_check = self.builder.get_object("startup_check") enable_sounds_check = self.builder.get_object("enable_sounds_check") minutes.set_value(float(self.config.get_prefs()["minutes"])) max_not_spin.set_value( float(self.config.get_prefs()["max_notifications"])) if os.path.exists(config.get_startup_file_path()): startup_check.set_active(True) else: startup_check.set_active(False) enable_sounds_check.set_active( coreutils.get_boolean(self.config.get_prefs()["enable_sounds"])) #Populate indicator combo i = 0 indicator_name = self.config.get_prefs()["indicator"] indicators_store.clear() for indi in self.im.get_indicators(): indicators_store.append([indi.get_name()]) if indi.get_name() == indicator_name: indicator_combo.set_active(i) i += 1 i = 0 keyring_id = self.config.get_prefs()["keyring"] keyring_store.clear() for k in self.km.get_managers(): keyring_store.append([k.get_name(), k.get_id()]) if k.get_id() == keyring_id: keyring_combo.set_active(i) i += 1 response = self.pref_dialog.run() self.pref_dialog.hide() self.config.set_pref("minutes", minutes.get_value()) self.config.set_pref("max_notifications", max_not_spin.get_value()) self.config.set_pref("enable_sounds", enable_sounds_check.get_active()) iiter = indicator_combo.get_active_iter() if iiter: self.config.set_pref("indicator", indicators_store.get_value(iiter, 0)) iiter = keyring_combo.get_active_iter() selected = keyring_store.get_value(iiter, 1) for m in self.km.get_managers(): logger.debug("selected %s, current %s" % (selected, m.get_id())) if m.get_id() == selected: self.km.set_manager(m) break self.config.set_pref("keyring", selected) #Check startup checkbox if startup_check.get_active(): if not os.path.exists(config.get_startup_file_path()): if not os.path.exists(config.get_startup_file_dir()): os.makedirs(config.get_startup_file_dir()) shutil.copyfile(config.add_data_prefix("cloudsn.desktop"), config.get_startup_file_path()) else: if os.path.exists(config.get_startup_file_path()): os.remove(config.get_startup_file_path()) self.config.save_prefs()
def preferences_action_activate_cb (self, widget, data=None): self.pref_dialog = self.builder.get_object("preferences_dialog") self.pref_dialog.set_transient_for(self.window) self.pref_dialog.set_destroy_with_parent (True) indicator_combo = self.builder.get_object("indicator_combo") indicators_store = self.builder.get_object("indicators_store"); keyring_combo = self.builder.get_object("keyring_combo") keyring_store = self.builder.get_object("keyring_store"); minutes=self.builder.get_object("minutes_spin") max_not_spin=self.builder.get_object("max_not_spin") startup_check = self.builder.get_object("startup_check") enable_sounds_check = self.builder.get_object("enable_sounds_check") minutes.set_value (float(self.config.get_prefs()["minutes"])) max_not_spin.set_value (float(self.config.get_prefs()["max_notifications"])) if os.path.exists(config.get_startup_file_path()): startup_check.set_active(True) else: startup_check.set_active(False) enable_sounds_check.set_active(coreutils.get_boolean(self.config.get_prefs()["enable_sounds"])) #Populate indicator combo i=0 indicator_name = self.config.get_prefs()["indicator"] indicators_store.clear() for indi in self.im.get_indicators(): indicators_store.append([indi.get_name()]) if indi.get_name() == indicator_name: indicator_combo.set_active(i) i+=1 i=0 keyring_id = self.config.get_prefs()["keyring"] keyring_store.clear() for k in self.km.get_managers(): keyring_store.append([k.get_name(), k.get_id()]) if k.get_id() == keyring_id: keyring_combo.set_active(i) i+=1 response = self.pref_dialog.run() self.pref_dialog.hide() self.config.set_pref ("minutes", minutes.get_value()) self.config.set_pref ("max_notifications", max_not_spin.get_value()) self.config.set_pref ("enable_sounds", enable_sounds_check.get_active()) iiter = indicator_combo.get_active_iter() if iiter: self.config.set_pref ("indicator", indicators_store.get_value(iiter,0)) iiter = keyring_combo.get_active_iter() selected = keyring_store.get_value(iiter,1) for m in self.km.get_managers(): logger.debug("selected %s, current %s" % (selected, m.get_id())) if m.get_id() == selected: self.km.set_manager(m) break self.config.set_pref ("keyring", selected) #Check startup checkbox if startup_check.get_active(): if not os.path.exists(config.get_startup_file_path()): if not os.path.exists(config.get_startup_file_dir()): os.makedirs(config.get_startup_file_dir()) shutil.copyfile(config.add_data_prefix("cloudsn.desktop"), config.get_startup_file_path()) else: if os.path.exists(config.get_startup_file_path()): os.remove (config.get_startup_file_path()) self.config.save_prefs()