diff --git a/src/gnome-utils/gnc-gnome-utils.c b/src/gnome-utils/gnc-gnome-utils.c index 044aa559af..cc91921324 100644 --- a/src/gnome-utils/gnc-gnome-utils.c +++ b/src/gnome-utils/gnc-gnome-utils.c @@ -42,10 +42,6 @@ static QofLogModule log_module = GNC_MOD_GUI; static GnomeProgram *gnucash_program = NULL; -static const struct poptOption nullPoptTable[] = { - { NULL, 0, 0, NULL, 0 } -}; - char * gnc_gnome_locate_pixmap (const char *name) { @@ -64,6 +60,19 @@ gnc_gnome_locate_pixmap (const char *name) return fullname; } +char * +gnc_gnome_locate_file (GnomeFileDomain domain, const char *name) +{ + char *fullname; + + g_return_val_if_fail(name, NULL); + fullname = gnome_program_locate_file(gnucash_program, + domain, name, TRUE, NULL); + if (!fullname) + PERR ("Could not locate file %s", name); + return fullname; +} + char * gnc_gnome_locate_data_file (const char *name) { @@ -121,7 +130,7 @@ gnc_gnome_init (int argc, char **argv, const char * version) gnc_gtk_add_rc_file(); gnucash_program = gnome_program_init( "gnucash", version, LIBGNOMEUI_MODULE, - argc, argv, GNOME_PARAM_POPT_TABLE, nullPoptTable, + argc, argv, GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_NONE); /* initialization required for gtkhtml */ diff --git a/src/gnome-utils/gnc-gnome-utils.h b/src/gnome-utils/gnc-gnome-utils.h index dd40f029c0..2c9c76b68c 100644 --- a/src/gnome-utils/gnc-gnome-utils.h +++ b/src/gnome-utils/gnc-gnome-utils.h @@ -35,6 +35,8 @@ #ifndef GNC_GNOME_UTILS_H #define GNC_GNOME_UTILS_H +#include + /** Initialize the Gnome libraries. */ void gnc_gnome_init (int argc, char **argv, const char * version); @@ -83,6 +85,20 @@ char *gnc_gnome_locate_data_file (const char *name); */ char *gnc_gnome_locate_ui_file (const char *name); +/** Given a file name, find the file in the directories associated + * with the given file domain. This routine will display an error + * message if it can't find the file. + * + * @param doamin The GnomeFileDomain, e.g. GNOME_FILE_DOMAIN_APP_HELP + * + * @param name The name of the file to be found. + * + * @return the full path name of the file, or NULL of the file can't + * be found. + * + * @note It is the caller's responsibility to free the returned string. + */ +char *gnc_gnome_locate_file (GnomeFileDomain domain, const char *name); /** Launch the default gnome help browser and open to a given link * within a given file. This routine will display an error message diff --git a/src/gnome-utils/gw-gnome-utils-spec.scm b/src/gnome-utils/gw-gnome-utils-spec.scm index 7af2707262..5bb9102209 100644 --- a/src/gnome-utils/gw-gnome-utils-spec.scm +++ b/src/gnome-utils/gw-gnome-utils-spec.scm @@ -493,4 +493,12 @@ if they say 'Yes'. The return is false if the user says 'Cancel'.") '((( caller-owned const) message) ( percentage)) "Set the progressbar window from the given GncWindow.") + + (gw:wrap-function + ws + 'gnc:gnome-locate-data-file + '( caller-owned) + "gnc_gnome_locate_data_file" + '((( caller-owned const) name)) + "Find the file in the application data directory.") )