From b24d0f2f60fc8a7c0bbe2cf4ceac584f9ef24878 Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Tue, 12 Feb 2013 13:03:24 +0100 Subject: Add MacOS support to window geometry save/restore Also make sure the config is flushed to disk. Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- 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 58a4d386f..0e7b6da8a 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -326,6 +326,8 @@ void save_window_geometry(void) gtk_window_get_size(GTK_WINDOW (main_window), &window_width, &window_height); 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 af72a69e3..daa9b00f1 100644 --- a/macos.c +++ b/macos.c @@ -47,7 +47,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) @@ -72,9 +73,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) -- cgit v1.2.3-70-g09d2