[Pkg-privacy-commits] [onionshare] 47/256: Clicking Save in the settings dialog saves settings

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit 9462b7d05f3f0a2f1e1da9b5d7ba6f626fad0c26
Author: Micah Lee <micah at micahflee.com>
Date:   Wed Dec 28 20:03:32 2016 -0800

    Clicking Save in the settings dialog saves settings
---
 onionshare/settings.py            |  8 ++++++--
 onionshare_gui/settings_dialog.py | 26 ++++++++++++++++++++++++--
 resources/locale/en.json          |  3 ++-
 3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/onionshare/settings.py b/onionshare/settings.py
index d36bb18..6ba2779 100644
--- a/onionshare/settings.py
+++ b/onionshare/settings.py
@@ -20,7 +20,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import platform, os, json
 
-from . import helpers
+from . import strings, helpers
 
 class Settings(object):
     """
@@ -77,8 +77,12 @@ class Settings(object):
         """
         Save settings to file.
         """
-        os.mkdirs(os.path.dirname(self.filename))
+        try:
+            os.makedirs(os.path.dirname(self.filename))
+        except:
+            pass
         open(self.filename, 'w').write(json.dumps(self._settings))
+        print(strings._('settings_saved').format(self.filename))
 
     def get(self, key):
         return self._settings[key]
diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py
index 55a76d0..1f1120e 100644
--- a/onionshare_gui/settings_dialog.py
+++ b/onionshare_gui/settings_dialog.py
@@ -151,7 +151,7 @@ class SettingsDialog(QtWidgets.QDialog):
         if connection_type == 'automatic':
             self.connection_type_automatic_radio.setChecked(True)
         elif connection_type == 'control_port':
-            self.connect_type_control_port_radio.setChecked(True)
+            self.connection_type_control_port_radio.setChecked(True)
         elif connection_type == 'socket_file':
             self.connection_type_socket_file_radio.setChecked(True)
         self.connection_type_control_port_extras_address.setText(self.settings.get('control_port_address'))
@@ -238,7 +238,29 @@ class SettingsDialog(QtWidgets.QDialog):
         """
         Save button clicked. Save current settings to disk.
         """
-        pass
+        if self.connection_type_automatic_radio.isChecked():
+            self.settings.set('connection_type', 'automatic')
+        if self.connection_type_control_port_radio.isChecked():
+            self.settings.set('connection_type', 'control_port')
+        if self.connection_type_socket_file_radio.isChecked():
+            self.settings.set('connection_type', 'socket_file')
+
+        self.settings.set('control_port_address', self.connection_type_control_port_extras_address.text())
+        self.settings.set('control_port_port', self.connection_type_control_port_extras_port.text())
+        self.settings.set('socket_file_path', self.connection_type_socket_file_extras_path.text())
+
+        if self.authenticate_no_auth_radio.isChecked():
+            self.settings.set('auth_type', 'no_auth')
+        if self.authenticate_password_radio.isChecked():
+            self.settings.set('auth_type', 'password')
+        if self.authenticate_cookie_radio.isChecked():
+            self.settings.set('auth_type', 'cookie')
+
+        self.settings.set('auth_password', self.authenticate_password_extras_password.text())
+        self.settings.set('auth_cookie_path', self.authenticate_cookie_extras_cookie_path.text())
+
+        self.settings.save()
+        self.close()
 
     def cancel_clicked(self):
         """
diff --git a/resources/locale/en.json b/resources/locale/en.json
index 66494a5..90e7d3c 100644
--- a/resources/locale/en.json
+++ b/resources/locale/en.json
@@ -77,5 +77,6 @@
     "gui_settings_cookie_label": "Cookie path",
     "gui_settings_button_test": "Test Settings",
     "gui_settings_button_save": "Save",
-    "gui_settings_button_cancel": "Cancel"
+    "gui_settings_button_cancel": "Cancel",
+    "settings_saved": "Settings saved to {}"
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list