From 38dfa8daef549928463102e12c355ff26eb0652b Mon Sep 17 00:00:00 2001 From: David Freese Date: Tue, 12 Jun 2012 06:50:31 -0500 Subject: [PATCH] Apple file drop * Added registered callback function to handle files dropped on to application icon. --- src/flmsg.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/flmsg.cxx b/src/flmsg.cxx index d8a47ac..d367663 100644 --- a/src/flmsg.cxx +++ b/src/flmsg.cxx @@ -265,7 +265,7 @@ string lineout(string &field, string &data) static string sout; static char sznum[80]; if (data.empty()) return ""; - snprintf(sznum, sizeof(sznum), "%0d", data.length()); + snprintf(sznum, sizeof(sznum), "%0d", (int)data.length()); sout.assign(field); sout.append(sznum).append(" ").append(data).append("\n"); return sout; @@ -1426,6 +1426,21 @@ int default_handler(int event) } #endif +#ifdef __APPLE__ +// registered file drop call back to operating system +void open_callback(const char *param) +{ +LOG_INFO("OS file drop callback %s", param); +string pathname = param; + if (pathname.find(WRAP_EXT) != string::npos) + wrap_import(pathname.c_str()); + else { + read_data_file(pathname); + show_filename(pathname); + } +} +#endif + void after_start(void *) { check_mycall(); @@ -1581,6 +1596,10 @@ void after_start(void *) } else default_form(); +#ifdef __APPLE__ + fl_open_callback(open_callback); +#endif + } int main(int argc, char *argv[])