Skip to content
Permalink
Browse files

Save settings when options changed

  • Loading branch information...
corenominal committed Aug 5, 2016
1 parent 438164e commit 2c531c9fc23e1aae5ebe49195b2180be0db9c719
Showing with 35 additions and 2 deletions.
  1. +31 −2 src/pwgenGUI
  2. +4 −0 src/pwgenGUI.glade
@@ -59,13 +59,43 @@ class pwgenGUI:
self.option_nums.set_state(settings['nums'])
self.option_specials.set_state(settings['specials'])

def settings_write(self):
def on_chars_value_changed(self, object):
settings = {
'chars': self.chars.get_text(),
'caps': self.option_caps.get_state(),
'nums': self.option_nums.get_state(),
'specials': self.option_specials.get_state()
}
self.settings_write(self, settings)

def on_switch1_state_set(self, object, data=''):
settings = {
'chars': self.chars.get_text(),
'caps': data,
'nums': self.option_nums.get_state(),
'specials': self.option_specials.get_state()
}
self.settings_write(self, settings)

def on_switch2_state_set(self, object, data=''):
settings = {
'chars': self.chars.get_text(),
'caps': self.option_caps.get_state(),
'nums': data,
'specials': self.option_specials.get_state()
}
self.settings_write(self, settings)

def on_switch3_state_set(self, object, data=''):
settings = {
'chars': self.chars.get_text(),
'caps': self.option_caps.get_state(),
'nums': self.option_nums.get_state(),
'specials': data
}
self.settings_write(self, settings)

def settings_write(self, object, settings):
settings = json.dumps(settings)
f = open(self.settings_file, 'w')
f.write(settings)
@@ -97,7 +127,6 @@ class pwgenGUI:
Gtk.main_quit()

def genPassword(self, object):
self.settings_write()
chars = self.chars.get_text()
option_caps = self.option_caps.get_state()
option_nums = self.option_nums.get_state()
@@ -208,6 +208,7 @@
<property name="input_purpose">digits</property>
<property name="adjustment">adjustment1</property>
<property name="value">12</property>
<signal name="value-changed" handler="on_chars_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
@@ -269,6 +270,7 @@
<property name="halign">start</property>
<property name="active">True</property>
<property name="state">True</property>
<signal name="state-set" handler="on_switch1_state_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
@@ -282,6 +284,7 @@
<property name="halign">start</property>
<property name="active">True</property>
<property name="state">True</property>
<signal name="state-set" handler="on_switch2_state_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
@@ -295,6 +298,7 @@
<property name="halign">start</property>
<property name="active">True</property>
<property name="state">True</property>
<signal name="state-set" handler="on_switch3_state_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>

0 comments on commit 2c531c9

Please sign in to comment.
You can’t perform that action at this time.