[PATCH 2/2] Add MacOS support to window geometry save/restore
subsurface at henrik.synth.no
subsurface at henrik.synth.no
Tue Feb 12 04:03:24 PST 2013
From: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
Also make sure the config is flushed to disk.
Signed-off-by: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
---
gtk-gui.c | 2 ++
macos.c | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/gtk-gui.c b/gtk-gui.c
index f759b8f..3fcb362 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -326,6 +326,8 @@ void save_window_geometry(void)
subsurface_set_conf_int("window_origin_y", window_origin_y);
subsurface_set_conf_int("window_width", window_width);
subsurface_set_conf_int("window_height", window_height);
+
+ subsurface_flush_conf();
}
void restore_window_geometry(void)
diff --git a/macos.c b/macos.c
index 792b165..14069dd 100644
--- a/macos.c
+++ b/macos.c
@@ -46,7 +46,8 @@ void subsurface_set_conf_bool(char *name, int value)
void subsurface_set_conf_int(char *name, int value)
{
- /* CF pref stuff here? */
+ CFNumberRef numRef = CFNumberCreate(NULL, kCFNumberIntType, &value);
+ CFPreferencesSetAppValue(CFSTR_VAR(name), numRef, SUBSURFACE_PREFERENCES);
}
const void *subsurface_get_conf(char *name)
@@ -71,9 +72,13 @@ int subsurface_get_conf_bool(char *name)
int subsurface_get_conf_int(char *name)
{
+ Boolean exists;
+ CFIndex value;
- return -1; /* CF pref stuff here? */
-
+ value = CFPreferencesGetAppIntegerValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES, &exists);
+ if (!exists)
+ return -1;
+ return value;
}
void subsurface_flush_conf(void)
--
1.8.1.3
More information about the subsurface
mailing list