From c285036f5674ee54c16b46c3088ed86503d63d83 Mon Sep 17 00:00:00 2001
From: Sebastian Koslowski <koslowski@kit.edu>
Date: Wed, 16 Mar 2016 16:25:09 +0100
Subject: grc-refactor: remove (hopefully) all deps to GR in core/ and gui/

---
 grc/gui/Config.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 grc/gui/Config.py

(limited to 'grc/gui/Config.py')

diff --git a/grc/gui/Config.py b/grc/gui/Config.py
new file mode 100644
index 0000000000..9b0c5d4afe
--- /dev/null
+++ b/grc/gui/Config.py
@@ -0,0 +1,74 @@
+"""
+Copyright 2016 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+"""
+
+import sys
+import os
+from ..core.Config import Config as _Config
+from . import Constants
+
+
+class Config(_Config):
+
+    name = 'GNU Radio Companion'
+
+    gui_prefs_file = os.environ.get(
+        'GRC_PREFS_PATH', os.path.expanduser('~/.gnuradio/grc.conf'))
+
+    def __init__(self, install_prefix, *args, **kwargs):
+        _Config.__init__(self, *args, **kwargs)
+        self.install_prefix = install_prefix
+        Constants.update_font_size(self.font_size)
+
+    @property
+    def editor(self):
+        return self.prefs.get_string('grc', 'editor', '')
+
+    @editor.setter
+    def editor(self, value):
+        self.prefs.get_string('grc', 'editor', value)
+        self.prefs.save()
+
+    @property
+    def xterm_executable(self):
+        return self.prefs.get_string('grc', 'xterm_executable', 'xterm')
+
+    @property
+    def default_canvas_size(self):
+        try:  # ugly, but matches current code style
+            raw = self.prefs.get_string('grc', 'canvas_default_size', '1280, 1024')
+            value = tuple(int(x.strip('() ')) for x in raw.split(','))
+            if len(value) != 2 or not all(300 < x < 4096 for x in value):
+                raise Exception()
+            return value
+        except:
+            print >> sys.stderr, "Error: invalid 'canvas_default_size' setting."
+            return Constants.DEFAULT_CANVAS_SIZE_DEFAULT
+
+    @property
+    def font_size(self):
+        try:  # ugly, but matches current code style
+            font_size = self.prefs.get_long('grc', 'canvas_font_size',
+                                            Constants.DEFAULT_FONT_SIZE)
+            if font_size <= 0:
+                raise Exception()
+        except:
+            font_size = Constants.DEFAULT_FONT_SIZE
+            print >> sys.stderr, "Error: invalid 'canvas_font_size' setting."
+
+        return font_size
-- 
cgit v1.2.3