Hi once more time, 2 patches again - this time I will take a break
from making them as other tasks will absorb me for a while, unless
they need some work.

I will start from patches. First one is easy, fixes 2 typos in
comments. Second changes way settings.conf is loaded and saved -
detailed description in patch. I ended up doing this, because I wanted
to add other simple thing I thought might be useful (checkbox for
"start fullscreen") - at least for me - so I needed to add entry to
settings.conf with it. When I added it, I noticed, that adding new
entry made it fail when I used dummyobj[name], because file
settings.conf was present but without field with name I needed, so I
either had to remove settings.conf, or change dummyobj[name] into
dummyobj.get(name, default). Second solution sounded better - but it
would work in different way (default values) than 3 already present
options, so I though - why not use get(name, default) for all options?
I also moved all settings into global list - and made load/save
iterate over it, it makes whole thing shorter and I think cleaner -
that way, adding new option can be done in single place with single
line - and no special changes to user-side .conf file should be
needed. Other change I added there, is saving only what isn't default
- but this might as well be not so good :)

Oh, btw - It's late already here and I don't have time to open bug
report or look/ask if it is or isn't a bug - so I'll ask here to raise
it and not forget about it - if I'm in fullscreen mode and menubar is
hidden, when I access menubar using menu key (and it shows), Quit
works only when accessed using keyboard (arrows+enter,
highlight+enter, shortcur), but if I click on it (using any pointing
device), nothing happens (well, menubar disappears again) - I haven't
checked other menu commands, but is it intended or known behaviour?
It's like that in current git and also in released 0.8.x, don't know
about others.

Cheers,
Andrzej.
From ca074b663da7da768961a7ffd73b715b55e63fc9 Mon Sep 17 00:00:00 2001
From: Andrzej Giniewicz <[email protected]>
Date: Sun, 16 May 2010 00:37:09 +0200
Subject: [PATCH 1/2] gui/application: small comment typos

---
 gui/application.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gui/application.py b/gui/application.py
index 74bb7ad..9d354b7 100644
--- a/gui/application.py
+++ b/gui/application.py
@@ -70,7 +70,7 @@ class Application: # singleton
 
         self.ui_manager = gtk.UIManager()
 
-        # if we are not installed, use the the icons from the source
+        # if we are not installed, use the icons from the source
         theme = gtk.icon_theme_get_default()
         themedir_src = join(self.datapath, 'desktop/icons')
         theme.prepend_search_path(themedir_src)
@@ -143,7 +143,7 @@ class Application: # singleton
         save_config()
 
     def load_settings(self):
-        '''Loads the settings from peristent storage. Uses defaults if
+        '''Loads the settings from persistent storage. Uses defaults if
         not explicitly configured'''
         def get_config():
             dummyobj = {}
-- 
1.7.1

From 752289437ee3b7bbbdbc361768c7eca49aa28fa2 Mon Sep 17 00:00:00 2001
From: Andrzej Giniewicz <[email protected]>
Date: Sun, 16 May 2010 00:37:33 +0200
Subject: [PATCH 2/2] Tweaked settings.conf saving and loading.

Made small rearrangements to settings.conf file handling. Added list of all
settings with their corresponding names in settings.conf and default values
(global variable SETTINGS, list of triples (name, name in file, default value).
Adjusted loading to use default value for missing entries even if file exists
and other entries are present, save only entries that are not default.
This simple patch should make extensions in future a lot easier, especially,
that if new entry in settings.conf is found, this solution handles by itself
cases in which user upgrades and have older settings.conf file, without new
entries (as I tested, current loading hangs there with KeyError - the problem
was with using dummyobj[...] instead of method get, with old implementation, all
keys to load had to be present - so new keys would have to be loaded with method
get, this modification unifies it and loads all options using method get with
default value).
---
 gui/application.py |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/gui/application.py b/gui/application.py
index 9d354b7..5c92337 100644
--- a/gui/application.py
+++ b/gui/application.py
@@ -53,6 +53,13 @@ CENTRE_STAGE_CONSTRAINTS = (\
     ## >     -- http://designinginterfaces.com/Center_Stage
 )
 
+# Centralized settings data, list of triples:
+#  (setting name, name in settings.cfg file, default value)
+SETTINGS = [
+    ('saving.scrap_prefix','save_scrap_prefix','scrap'),
+    ('input.device_mode', 'input_device_mode', 'screen'),
+    ('input.global_pressure_mapping', 'global_pressure_mapping', [(0.0,1.0),(1.0,0.0)])
+]
 
 class Application: # singleton
     """
@@ -132,13 +139,13 @@ class Application: # singleton
         gobject.idle_add(at_application_start)
 
     def save_settings(self):
-        """Saves the current settings to persistent storage."""
+        """Saves the current, non default settings to persistent storage."""
         def save_config():
             f = open(join(self.confpath, 'settings.conf'), 'w')
-            p = self.preferences
-            print >>f, 'global_pressure_mapping =', p['input.global_pressure_mapping']
-            print >>f, 'save_scrap_prefix =', repr(p['saving.scrap_prefix'])
-            print >>f, 'input_devices_mode =', repr(p['input.device_mode'])
+            for setting in SETTINGS:
+                data = self.preferences[setting[0]]
+                if data != setting[2]:
+                    print >>f, setting[1],'=',repr(self.preferences[setting[0]])
             f.close()
         save_config()
 
@@ -151,18 +158,10 @@ class Application: # singleton
             settingspath = join(self.confpath, 'settings.conf')
             if os.path.exists(settingspath):
                 exec open(settingspath) in dummyobj
-                tmpdict['saving.scrap_prefix'] = dummyobj['save_scrap_prefix']
-                tmpdict['input.device_mode'] = dummyobj['input_devices_mode']
-                tmpdict['input.global_pressure_mapping'] = dummyobj['global_pressure_mapping']
+            for setting in SETTINGS:
+                tmpdict[setting[0]] = dummyobj.get(setting[1], setting[2])
             return tmpdict
-
-        DEFAULT_CONFIG = {
-            'saving.scrap_prefix': 'scrap',
-            'input.device_mode': 'screen',
-            'input.global_pressure_mapping': [(0.0, 1.0), (1.0, 0.0)],
-        }
-        self.preferences = DEFAULT_CONFIG
-        self.preferences.update(get_config())
+        self.preferences = get_config()
 
     def brush_selected_cb(self, b):
         assert b is not self.brush
-- 
1.7.1

_______________________________________________
Mypaint-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-discuss

Reply via email to