def save(self, widget, data=None): """ converts the values from the gui to PersyConfig values and executes the save function on the config object """ self.log.info("saving configuration") #general configuration textGeneralName = self.wTree.get_widget('textGeneralName') self.config['general']['name'] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget('textGeneralMail') self.config['general']['mail'] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget('checkGeneralFortune') self.config['general']['fortune'] = textGeneralName.get_active() textGeneralName = self.wTree.get_widget('checkGeneralAutostart') autostart = textGeneralName.get_active() a = autorun() if autostart and not a.exists('persy'): a.add('persy', self.config.getAttribute('PERSY_BIN') + ' --start') if not autostart and a.exists('persy'): a.remove('persy') textGeneralName = self.wTree.get_widget('comboboxGeneralGitBrowser') self.config['general']['prefgitbrowser'] = textGeneralName.get_active_text() #local configuration textGeneralName = self.wTree.get_widget('spinLocalSleep') self.config['local']['sleep'] = int(textGeneralName.get_value()) root = self.wTree.get_widget('vbox4') tmparray = [] for entry in root: for child in entry: if child.get_name().startswith('text_'): tmparray.append(child.get_text()) self.config['local']['watched'] = tmparray textGeneralName = self.wTree.get_widget('spinLocalFilesize') self.config['local']['maxfilesize'] = int(textGeneralName.get_value()) textGeneralName = self.wTree.get_widget('textLocalExclude') self.config['local']['exclude'] = self.helper.striplist(textGeneralName.get_text().split(',')) #remote configuration textGeneralName = self.wTree.get_widget('checkRemoteUse') self.config['remote']['use_remote'] = textGeneralName.get_active() textGeneralName = self.wTree.get_widget('spinRemoteSleep') self.config['remote']['sleep'] = int(textGeneralName.get_value()) #textGeneralName.set_value(-1) textGeneralName = self.wTree.get_widget('textRemoteHostname') self.config['remote']['hostname'] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget('spinRemotePort') self.config['remote']['port'] = int(textGeneralName.get_value()) textGeneralName = self.wTree.get_widget('textRemotePath') self.config['remote']['path'] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget('textRemoteUsername') self.config['remote']['username'] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget('checkGeneralAutoshare') self.config['general']['autoshare'] = textGeneralName.get_active() #write the configuration self.config.write() #set the sensitivity of the sync now button in the menu self.gtkcore.check_syncnow()
def __init__(self, config, log, gtkcore): """ * builds the settings menu * does the localization of the gui * connects all buttons to the used actions """ #used do distinguish hboxes for watched entries self.hboxcounter = 0; self.config = config self.log = log self.gtkcore = gtkcore self.helper = PersyHelper() self.wTree = gtk.glade.XML(self.config.getAttribute('GLADEFILE'), 'window1') self.wTree.get_widget("window1").set_icon_from_file(self.config.getAttribute('LOGO')) self.wTree.get_widget("window1").set_title(_("persy settings")) self.wTree.get_widget("buttonSave").connect("clicked", self.save) self.wTree.get_widget("buttonSave").set_label(_("save")) textGeneralName = self.wTree.get_widget('labelGeneral') textGeneralName.set_label(_("general")) textGeneralName = self.wTree.get_widget('labelLocal') textGeneralName.set_label(_("backup")) textGeneralName = self.wTree.get_widget('labelRemote') textGeneralName.set_label(_("synchronization")) textGeneralName = self.wTree.get_widget('labelDevel') textGeneralName.set_label(_("administration")) #general configuration textGeneralName = self.wTree.get_widget('labelCategoryPersonal') textGeneralName.set_label('<b>'+_("personal information")+'</b>') textGeneralName = self.wTree.get_widget('labelGeneralName') textGeneralName.set_label(_("name")) textGeneralName = self.wTree.get_widget('textGeneralName') textGeneralName.set_text(config['general']['name']) textGeneralName.set_tooltip_text(_("username to distinguish different users for one share")) textGeneralName = self.wTree.get_widget('labelGeneralMail') textGeneralName.set_label(_("mail")) textGeneralName = self.wTree.get_widget('textGeneralMail') textGeneralName.set_text(config['general']['mail']) textGeneralName.set_tooltip_text(_("email to distinguish different users for one share")) textGeneralName = self.wTree.get_widget('labelCategoryAdvanced') textGeneralName.set_label('<b>'+_("advanced")+'</b>') a = autorun() textGeneralName = self.wTree.get_widget('checkGeneralAutostart') textGeneralName.set_active(a.exists('persy')) textGeneralName.set_label(_("start persy on login")) textGeneralName = self.wTree.get_widget('checkGeneralFortune') textGeneralName.set_active(config['general']['fortune']) textGeneralName.set_label(_("use fortune messages in the git commit")) if self.helper.which(config.getAttribute('FORTUNE')): textGeneralName.set_sensitive(True) else: textGeneralName.set_sensitive(False) textGeneralName = self.wTree.get_widget('checkGeneralAutoshare') textGeneralName.set_active(config['general']['autoshare']) textGeneralName.set_tooltip_text(_("if this is checked, all the computers in a sync will share the configuration file")) textGeneralName.set_label(_("share the configuration file") + _('(experimental)')) textGeneralName.set_sensitive(config['remote']['use_remote']) textGeneralName = self.wTree.get_widget('labelGeneralGitBrowser') textGeneralName.set_label(_("default git browser")) textGeneralName = self.wTree.get_widget('comboboxGeneralGitBrowser') for browser in self.config.getAttribute('GITGUI'): version = self.helper.getSoftwareVersion(browser) if version: textGeneralName.insert_text(0,browser) if self.config['general']['prefgitbrowser'] == browser: textGeneralName.set_active(0) textGeneralName.set_tooltip_text(_("the prefered git browser for browsing the local persy repository")) #local configuration textGeneralName = self.wTree.get_widget('labelLocalWatched') textGeneralName.set_label('<b>'+_("monitored folders in persy")+'</b>') for watched in config['local']['watched']: self.addWatchedEntry(None, watched) button = self.wTree.get_widget('buttonAddWatchedEntry') button.connect("clicked", self.addWatchedEntry, '') textGeneralName = self.wTree.get_widget('labelCategorySyncOptions') textGeneralName.set_label('<b>'+_("backup options")+'</b>') textGeneralName = self.wTree.get_widget('labelLocalSleep') textGeneralName.set_label(_("time to wait for a backup after an file action (in seconds)")) textGeneralName = self.wTree.get_widget('spinLocalSleep') textGeneralName.set_value(int(config['local']['sleep'])) textGeneralName.set_tooltip_text(_("time to wait for a backup after an file action (in seconds)")) textGeneralName = self.wTree.get_widget('labelCategoryExclude') textGeneralName.set_label('<b>'+_("exclude options")+'</b>') textGeneralName = self.wTree.get_widget('labelLocalFilesize') textGeneralName.set_label(_("maximal allowed size of files (in bytes)")) textGeneralName = self.wTree.get_widget('spinLocalFilesize') textGeneralName.set_value(int(config['local']['maxfilesize'])) textGeneralName.set_tooltip_text(_("all files larger than this value will be ignored")) textGeneralName = self.wTree.get_widget('labelLocalExclude') textGeneralName.set_label(_("exclude all files matching these regular expressions")) textGeneralName = self.wTree.get_widget('textLocalExclude') textGeneralName.set_text(", ".join(config['local']['exclude'])) textGeneralName.set_tooltip_text(_("the expressions are seperated by a comma")) textGeneralName = self.wTree.get_widget('labelCategoryExclude1') textGeneralName.set_label('<b>'+_("excluded submodules / directories")+'</b>') textGeneralName = self.wTree.get_widget('label1') textGeneralName.set_text(_("these directories are git submodules and can not be tracked with persy")+':') textGeneralName = self.wTree.get_widget('label2') submodules = self.gtkcore.get_submodules() if submodules: textGeneralName.set_text("\n".join(submodules)) else: textGeneralName.set_text("none!") #remote configuration textGeneralName = self.wTree.get_widget('labelCategoryOptions') textGeneralName.set_label('<b>'+_("options")+'</b>') textGeneralName = self.wTree.get_widget('checkRemoteUse') textGeneralName.set_active(config['remote']['use_remote']) textGeneralName.set_tooltip_text(_("synchronize to the remote server")) textGeneralName.connect("clicked", self.toggle_sensitive, "checkGeneralAutoshare") textGeneralName = self.wTree.get_widget('labelRemoteSleep') textGeneralName.set_label(_("time to wait for a synchronization (in seconds)")) textGeneralName = self.wTree.get_widget('spinRemoteSleep') textGeneralName.set_value(int(config['remote']['sleep'])) textGeneralName.set_tooltip_text(_("interval in seconds in which a synchronization with the remote host occurs")) textGeneralName = self.wTree.get_widget('labelCategoryServerConf') textGeneralName.set_label('<b>'+_("server configuration")+'</b>') textGeneralName = self.wTree.get_widget('labelRemoteHostname') textGeneralName.set_label(_("hostname")) textGeneralName = self.wTree.get_widget('textRemoteHostname') textGeneralName.set_text(config['remote']['hostname']) textGeneralName.set_tooltip_text(_("the hostname of the remote server")) textGeneralName = self.wTree.get_widget('spinRemotePort') textGeneralName.set_value(int(config['remote']['port'])) textGeneralName.set_tooltip_text(_("the port of the remote server")) textGeneralName = self.wTree.get_widget('labelRemoteUsername') textGeneralName.set_label(_("username")) textGeneralName.set_tooltip_text(_("the username for the remote server")) textGeneralName = self.wTree.get_widget('textRemoteUsername') textGeneralName.set_text(config['remote']['username']) textGeneralName.set_tooltip_text(_("the username for the remote server")) textGeneralName = self.wTree.get_widget('labelRemotePath') textGeneralName.set_label(_("repository path on the server")) textGeneralName = self.wTree.get_widget('textRemotePath') textGeneralName.set_text(config['remote']['path']) textGeneralName.set_tooltip_text(_("the path to the git repository on the remote server")) #remote actions textGeneralName = self.wTree.get_widget('labelCategoryActions') textGeneralName.set_label('<b>'+_("environment tests")+'</b>') textGeneralName = self.wTree.get_widget('labelTestsExplanation') textGeneralName.set_label(_("These are some tests to confirm if your settings are correct. If a problem occurs, the problem may be corrected if you run the corresponding action.")) thewidget = self.wTree.get_widget("testLocalSSHKey") thewidget.connect("clicked", self.actionTestLocalSSHKey) thewidget.set_label(_("test")) thewidget.set_tooltip_text(_('show git log')) thewidget = self.wTree.get_widget("testServerConnection") thewidget.connect("clicked", self.actionTestSSHAuth) thewidget.set_label(_("test")) thewidget.set_tooltip_text(_('show git log')) thewidget = self.wTree.get_widget("testRemoteRepository") thewidget.connect("clicked", self.actionTestRemoteServer) thewidget.set_label(_("test")) thewidget.set_tooltip_text(_('show git log')) thewidget = self.wTree.get_widget("buttonIsInSyncWithRemote") thewidget.connect("clicked", self.isInSyncWithRemote) thewidget.set_label(_("test")) thewidget.set_tooltip_text(_('run a new initial synchronization with the remote host')) textGeneralName = self.wTree.get_widget('labelRemoteRepository') textGeneralName.set_label(_("test status of remote repository")) thewidget = self.wTree.get_widget("buttonInitRemote") thewidget.connect("clicked", self.init_remote) thewidget.set_label(_("initialize")) thewidget.set_tooltip_text(_('run a initialization of the remote host')) textGeneralName = self.wTree.get_widget('labelSyncRemote') textGeneralName.set_label(_("is persy in a sync pack with remote host")) thewidget = self.wTree.get_widget("buttonSyncRemote") thewidget.connect("clicked", self.sync_with_remote) thewidget.set_label(_("link")) thewidget.set_tooltip_text(_('run a new initial synchronization with the remote host')) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24) textGeneralName = self.wTree.get_widget('imageLocalSSHKey') textGeneralName.set_from_pixbuf(pixbuf) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24) textGeneralName = self.wTree.get_widget('imageServerConnection') textGeneralName.set_from_pixbuf(pixbuf) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24) textGeneralName = self.wTree.get_widget('imageRemoteRepository') textGeneralName.set_from_pixbuf(pixbuf) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.config.getAttribute('ICON_IDLE'), 24, 24) textGeneralName = self.wTree.get_widget('imageIsInSyncWithRemote') textGeneralName.set_from_pixbuf(pixbuf) #devel textGeneralName = self.wTree.get_widget('labelCategoryMonitoring') textGeneralName.set_label('<b>'+_("monitoring")+'</b>') textGeneralName = self.wTree.get_widget('labelGitBrowser') textGeneralName.set_label(_("start a git browser")) thewidget = self.wTree.get_widget("buttonBrowse") thewidget.connect("clicked", self.gtkcore.browse) thewidget.set_label(_("start")) thewidget.set_tooltip_text(_("starts %s")%config['general']['prefgitbrowser']) textGeneralName = self.wTree.get_widget('labelShowLog') textGeneralName.set_label(_("show log")) thewidget = self.wTree.get_widget("buttonLog") thewidget.connect("clicked", self.gtkcore.showlog) thewidget.set_label(_("show")) thewidget.set_tooltip_text(_('show log')) textGeneralName = self.wTree.get_widget('labelShowGitLog') textGeneralName.set_label(_("show git log")) thewidget = self.wTree.get_widget("buttonGitLog") thewidget.connect("clicked", self.gtkcore.showgitlog) thewidget.set_label(_("show")) thewidget.set_tooltip_text(_('show git log'))
def save(self, widget, data=None): """ converts the values from the gui to PersyConfig values and executes the save function on the config object """ self.log.info("saving configuration") # general configuration textGeneralName = self.wTree.get_widget("textGeneralName") self.config["general"]["name"] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget("textGeneralMail") self.config["general"]["mail"] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget("checkGeneralFortune") self.config["general"]["fortune"] = textGeneralName.get_active() textGeneralName = self.wTree.get_widget("checkGeneralAutostart") autostart = textGeneralName.get_active() a = autorun() if autostart and not a.exists("persy"): a.add("persy", self.config.getAttribute("PERSY_BIN") + " --start") if not autostart and a.exists("persy"): a.remove("persy") textGeneralName = self.wTree.get_widget("comboboxGeneralGitBrowser") self.config["general"]["prefgitbrowser"] = textGeneralName.get_active_text() # local configuration textGeneralName = self.wTree.get_widget("spinLocalSleep") self.config["local"]["sleep"] = int(textGeneralName.get_value()) root = self.wTree.get_widget("vbox4") tmparray = [] for entry in root: for child in entry: if child.get_name().startswith("text_"): tmparray.append(child.get_text()) self.config["local"]["watched"] = tmparray textGeneralName = self.wTree.get_widget("spinLocalFilesize") self.config["local"]["maxfilesize"] = int(textGeneralName.get_value()) textGeneralName = self.wTree.get_widget("textLocalExclude") self.config["local"]["exclude"] = self.helper.striplist(textGeneralName.get_text().split(",")) # remote configuration textGeneralName = self.wTree.get_widget("checkRemoteUse") self.config["remote"]["use_remote"] = textGeneralName.get_active() textGeneralName = self.wTree.get_widget("spinRemoteSleep") self.config["remote"]["sleep"] = int(textGeneralName.get_value()) # textGeneralName.set_value(-1) textGeneralName = self.wTree.get_widget("textRemoteHostname") self.config["remote"]["hostname"] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget("spinRemotePort") self.config["remote"]["port"] = int(textGeneralName.get_value()) textGeneralName = self.wTree.get_widget("textRemotePath") self.config["remote"]["path"] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget("textRemoteUsername") self.config["remote"]["username"] = textGeneralName.get_text() textGeneralName = self.wTree.get_widget("checkGeneralAutoshare") self.config["general"]["autoshare"] = textGeneralName.get_active() # write the configuration self.config.write()