[PATCH] Add MacOS support to window geometry save/restore
subsurface at henrik.synth.no
subsurface at henrik.synth.no
Sun Feb 3 10:46:43 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>
---
This requires Amit's "Add window save/restore" patch.
Henrik
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 4d6f211..e78eb2b 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -322,6 +322,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 0248214..f0b4166 100644
--- a/macos.c
+++ b/macos.c
@@ -45,7 +45,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)
@@ -70,9 +71,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.1
More information about the subsurface
mailing list