summaryrefslogtreecommitdiffstats
path: root/macos.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-17 21:27:43 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-17 21:44:28 -0400
commit3835faa8fb02df8edb299278f4258389d3e99bda (patch)
tree6ac1697a5f7343157f73ad5063b2cefa23395e20 /macos.c
parentfebae4d165866ca4a4e28347aebe446d65ed44e5 (diff)
parentd7465129bb7fc912ec89671051192983b80711c4 (diff)
downloadsubsurface-3835faa8fb02df8edb299278f4258389d3e99bda.tar.gz
Merge branch 'defaultfile'
By now the default file code seems quite matured, so in preparation for 2.0 we'll bring it back into master. I made a few small clean-ups during the merge, but the merge itself is very much straight forward. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'macos.c')
-rw-r--r--macos.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/macos.c b/macos.c
index 20445c808..d76225472 100644
--- a/macos.c
+++ b/macos.c
@@ -1,5 +1,6 @@
/* macos.c */
/* implements Mac OS X specific functions */
+#include "dive.h"
#include "display-gtk.h"
#include <CoreFoundation/CoreFoundation.h>
#include <mach-o/dyld.h>
@@ -53,7 +54,7 @@ const void *subsurface_get_conf(char *name, pref_type_t type)
strpref = CFPreferencesCopyAppValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES);
if (!strpref)
return NULL;
- return CFStringGetCStringPtr(strpref, kCFStringEncodingMacRoman);
+ return strdup(CFStringGetCStringPtr(strpref, kCFStringEncodingMacRoman));
}
/* we shouldn't get here, but having this line makes the compiler happy */
return NULL;
@@ -85,6 +86,30 @@ const char *subsurface_icon_name()
return path;
}
+const char *subsurface_default_filename()
+{
+ if (default_filename) {
+ return strdup(default_filename);
+ } else {
+ const char *home, *user;
+ char *buffer;
+ int len;
+
+ home = g_get_home_dir();
+ user = g_get_user_name();
+ len = strlen(home) + strlen(user) + 45;
+ buffer = malloc(len);
+ snprintf(buffer, len, "%s/Library/Application Support/Subsurface/%s.xml", home, user);
+ return buffer;
+ }
+}
+
+static void show_main_window(GtkWidget *w, gpointer data)
+{
+ gtk_widget_show(main_window);
+ gtk_window_present(GTK_WINDOW(main_window));
+}
+
void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
GtkWidget *vbox, GtkUIManager *ui_manager)
{
@@ -122,5 +147,8 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
gtk_osxapplication_insert_app_menu_item (osx_app, sep, 3);
gtk_osxapplication_set_use_quartz_accelerators(osx_app, TRUE);
+ g_signal_connect(osx_app,"NSApplicationDidBecomeActive",G_CALLBACK(show_main_window),NULL);
+ g_signal_connect(osx_app,"NSApplicationWillTerminate",G_CALLBACK(quit),NULL);
+
gtk_osxapplication_ready(osx_app);
}