mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Implement help for OSX
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19201 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
12
configure.ac
12
configure.ac
@@ -244,12 +244,16 @@ update to latest darwin])
|
||||
_gdk_tgt=`$PKG_CONFIG --variable=target gdk-2.0`
|
||||
if test "x$_gdk_tgt" = xquartz; then
|
||||
platform=darwin/quartz
|
||||
AC_PROG_OBJC
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(GDK_QUARTZ,,[Using GDK Quartz (not X11)])
|
||||
AC_MSG_CHECKING(For ige-mac-integration)
|
||||
PKG_CHECK_MODULES(IGE_MAC, ige-mac-integration,
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
PKG_CHECK_MODULES([IGE_MAC], ige-mac-integration,
|
||||
[_ige_mac=yes], [_ige_mac=no])
|
||||
if test "x$_ige_mac" = xyes; then
|
||||
IGE_MAC_LIBS="${IGE_MAC_LIBS} -lobjc"
|
||||
IGE_MAC_CFLAGS="${IGE_MAC_CFLAGS} -xobjective-c"
|
||||
fi
|
||||
AC_MSG_RESULT(${_ige_mac})
|
||||
AC_SUBST(IGE_MAC_LIBS)
|
||||
AC_SUBST(IGE_MAC_CFLAGS)
|
||||
GNUCASH_ENVIRONMENT="environment-osx"
|
||||
|
||||
@@ -99,7 +99,7 @@ gnucash-setup-env: gnucash-setup-env-osx.in ${top_builddir}/config.status Makefi
|
||||
rm -f $@.tmp
|
||||
sed < $< > $@.tmp \
|
||||
-e 's#@-BIN_DIR-@#${bindir}#g' \
|
||||
-e 's#@-GNC_DBD_DIR-@#${GNC_DBD_DIR}#g' \
|
||||
-e 's#@-GNC_DBD_DIR-@#${GNC_DBD_DIR}#g' \
|
||||
-e 's#@-GNC_STANDARD_REPORTS_DIR-@#${GNC_SHAREDIR}/guile-modules/gnucash/report/standard-reports#g' \
|
||||
-e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \
|
||||
-e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#ifdef G_OS_WIN32
|
||||
# define HF_GUIDE "gnucash-guide.chm"
|
||||
# define HF_HELP "gnucash-help.chm"
|
||||
#elif defined MAC_INTEGRATION
|
||||
# define HF_GUIDE "Gnucash Guide"
|
||||
# define HF_HELP "Gnucash Help"
|
||||
#else
|
||||
# define HF_GUIDE "gnucash-guide.xml"
|
||||
# define HF_HELP "gnucash-help.xml"
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
#ifdef G_OS_WIN32
|
||||
# include "gnc-help-utils.h"
|
||||
#endif
|
||||
#ifdef MAC_INTEGRATION
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_GUI;
|
||||
static GnomeProgram *gnucash_program = NULL;
|
||||
@@ -271,28 +274,86 @@ gnc_gnome_init (int argc, char **argv, const char * version)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
#ifdef MAC_INTEGRATION
|
||||
|
||||
/* Don't be alarmed if this function looks strange to you: It's
|
||||
* written in Objective-C, the native language of the OSX Cocoa
|
||||
* toolkit.
|
||||
*/
|
||||
void
|
||||
gnc_gnome_help (const char *file_name, const char *anchor)
|
||||
gnc_gnome_help (const char *dir, const char *detail)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *subdir = [NSString stringWithUTF8String: dir];
|
||||
NSString *help_dir = [NSString stringWithUTF8String: HF_HELP];
|
||||
NSString *tag;
|
||||
NSURL *url = NULL;
|
||||
|
||||
DEBUG ("Attempting to opening help file %s", file_name);
|
||||
if (gnome_help_display (file_name, anchor, &error))
|
||||
return;
|
||||
if (detail)
|
||||
tag = [NSString stringWithUTF8String: detail];
|
||||
else if ([subdir compare: help_dir] == NSOrderedSame)
|
||||
tag = @"help";
|
||||
else
|
||||
tag = @"index";
|
||||
|
||||
g_assert(error != NULL);
|
||||
{
|
||||
if (![[NSBundle mainBundle] bundleIdentifier]) {
|
||||
/* If bundleIdentifier is NULL, then we're running from the
|
||||
* commandline and must construct a file path to the resource. We can
|
||||
* still get the resource path, but it will point to the "bin"
|
||||
* directory so we chop that off, break up what's left into pieces,
|
||||
* add some more pieces, and put it all back together again. Then,
|
||||
* because the gettext way of handling localizations is different from
|
||||
* OSX's, we have to figure out which translation to use. */
|
||||
NSArray *components = [NSArray arrayWithObjects: @"share", @"gnome", @"help", @"gnucash", nil ];
|
||||
NSString *prefix = [[[NSBundle mainBundle] resourcePath]
|
||||
stringByDeletingLastPathComponent];
|
||||
NSArray *prefix_comps = [[prefix pathComponents]
|
||||
arrayByAddingObjectsFromArray: components];
|
||||
NSString *docs_dir = [NSString pathWithComponents: prefix_comps];
|
||||
NSString * cur_locale = [[NSLocale currentLocale] localeIdentifier] ;
|
||||
BOOL dir, exists;
|
||||
subdir = [[[subdir lowercaseString] componentsSeparatedByString: @" "]
|
||||
componentsJoinedByString: @"-"];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath: docs_dir]) {
|
||||
const gchar *message =
|
||||
_("GnuCash could not find the files for the help documentation. "
|
||||
"This is likely because the 'gnucash-docs' package is not installed.");
|
||||
gnc_error_dialog(NULL, "%s", message);
|
||||
}
|
||||
PERR ("%s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
[pool release];
|
||||
return;
|
||||
}
|
||||
exists = [[NSFileManager defaultManager]
|
||||
fileExistsAtPath: [docs_dir
|
||||
stringByAppendingPathComponent: cur_locale]
|
||||
isDirectory: &dir];
|
||||
if (exists && dir)
|
||||
url = [NSURL
|
||||
fileURLWithPath: [[[[docs_dir
|
||||
stringByAppendingPathComponent: cur_locale]
|
||||
stringByAppendingPathComponent: subdir]
|
||||
stringByAppendingPathComponent: tag]
|
||||
stringByAppendingPathExtension: @"html"]];
|
||||
if (!url)
|
||||
url = [NSURL
|
||||
fileURLWithPath: [[[[docs_dir
|
||||
stringByAppendingPathComponent: @"C"]
|
||||
stringByAppendingPathComponent: subdir]
|
||||
stringByAppendingPathComponent: tag]
|
||||
stringByAppendingPathExtension: @"html"]];
|
||||
|
||||
#else /* G_OS_WIN32 */
|
||||
}
|
||||
/* It's a lot easier in a bundle! */
|
||||
else
|
||||
url = [NSURL fileURLWithPath: [[NSBundle mainBundle]
|
||||
pathForResource: tag
|
||||
ofType: @"html"
|
||||
inDirectory: subdir ]];
|
||||
|
||||
/* Now just open the URL in the default app for opening URLs */
|
||||
[[NSWorkspace sharedWorkspace] openURL: url];
|
||||
[pool release];
|
||||
}
|
||||
#elif defined G_OS_WIN32 /* G_OS_WIN32 */
|
||||
void
|
||||
gnc_gnome_help (const char *file_name, const char *anchor)
|
||||
{
|
||||
@@ -326,6 +387,28 @@ gnc_gnome_help (const char *file_name, const char *anchor)
|
||||
}
|
||||
g_free (found);
|
||||
}
|
||||
#else
|
||||
void
|
||||
gnc_gnome_help (const char *file_name, const char *anchor)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
DEBUG ("Attempting to opening help file %s", file_name);
|
||||
if (gnome_help_display (file_name, anchor, &error))
|
||||
return;
|
||||
|
||||
g_assert(error != NULL);
|
||||
{
|
||||
const gchar *message =
|
||||
_("GnuCash could not find the files for the help documentation. "
|
||||
"This is likely because the 'gnucash-docs' package is not installed.");
|
||||
gnc_error_dialog(NULL, "%s", message);
|
||||
}
|
||||
PERR ("%s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/********************************************************************\
|
||||
|
||||
Reference in New Issue
Block a user