gnome-help

Name

gnome-help -- Display application and GNOME system help.

Synopsis


#include <libgnome/libgnome.h>


enum        GnomeHelpError;
#define     GNOME_HELP_ERROR
gboolean    gnome_help_display              (const char *file_name,
                                             const char *link_id,
                                             GError **error);
gboolean    gnome_help_display_with_doc_id  (GnomeProgram *program,
                                             const char *doc_id,
                                             const char *file_name,
                                             const char *link_id,
                                             GError **error);
gboolean    gnome_help_display_desktop      (GnomeProgram *program,
                                             const char *doc_id,
                                             const char *file_name,
                                             const char *link_id,
                                             GError **error);
gboolean    gnome_help_display_uri          (const char *help_uri,
                                             GError **error);
GQuark      gnome_help_error_quark          (void);

Description

These functions provide a way to display help files that are either installed as part of the main GNOME installation or that are specific to the current application.

Details

enum GnomeHelpError

typedef enum {
  GNOME_HELP_ERROR_INTERNAL, 
  GNOME_HELP_ERROR_NOT_FOUND
} GnomeHelpError;


GNOME_HELP_ERROR

#define GNOME_HELP_ERROR (gnome_help_error_quark ())

The class (or domain) of errors raised directly by the gnome-help module. This is used as a value in the domain field of the GError structure.


gnome_help_display ()

gboolean    gnome_help_display              (const char *file_name,
                                             const char *link_id,
                                             GError **error);

Displays the help file specified by file_name at location link_id in the preferred help browser of the user.


gnome_help_display_with_doc_id ()

gboolean    gnome_help_display_with_doc_id  (GnomeProgram *program,
                                             const char *doc_id,
                                             const char *file_name,
                                             const char *link_id,
                                             GError **error);

Displays the help file specified by file_name at location link_id within the doc_id domain in the preferred help browser of the user. Most of the time, you want to call @gnome_help_display() instead.

This function will display the help through creating a "ghelp" URI, by looking for file_name in the applications installed help location (found by GNOME_FILE_DOMAIN_APP_HELP) and its app_id. The resulting URI is roughly in the form "ghelp:appid/file_name?link_id". If a matching file cannot be found, FALSE is returned and error is set.

Please note that this only displays application help. To display help files from the global GNOME domain, you will want to use #gnome_help_display_desktop().

program : The current application object, or NULL for the default one.
doc_id : The document identifier, or NULL to default to the application ID (app_id) of the specified program.
file_name : The name of the help document to display.
link_id : Can be NULL. If set, refers to an anchor or section id within the requested document.
error : A GError instance that will hold the specifics of any error which occurs during processing, or NULL
Returns : TRUE on success, FALSE otherwise (in which case error will contain the actual error). */ gboolean gnome_help_display_with_doc_id (GnomeProgram *program, const char *doc_id, const char *file_name, const char *link_id, GError **error) { gchar *local_help_path; gchar *global_help_path; gchar *file; struct stat local_help_st; struct stat global_help_st; gchar *uri; gboolean retval; g_return_val_if_fail (file_name != NULL, FALSE); retval = FALSE; local_help_path = NULL; global_help_path = NULL; file = NULL; uri = NULL; if (program == NULL) program = gnome_program_get(); if (doc_id == NULL) doc_id = gnome_program_get_app_id (program); /* Compute the local and global help paths */ local_help_path = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_HELP, "", FALSE /* only_if_exists */, NULL /* ret_locations */); if (local_help_path == NULL) { g_set_error (error, GNOME_HELP_ERROR, GNOME_HELP_ERROR_INTERNAL, _("Unable to find the GNOME_FILE_DOMAIN_APP_HELP domain")); goto out; } global_help_path = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_HELP, "", FALSE /* only_if_exists */, NULL /* ret_locations */); if (global_help_path == NULL) { g_set_error (error, GNOME_HELP_ERROR, GNOME_HELP_ERROR_INTERNAL, _("Unable to find the GNOME_FILE_DOMAIN_HELP domain.")); goto out; } /* Try to access the help paths, first the app-specific help path and then falling back to the global help path if the first one fails.


gnome_help_display_desktop ()

gboolean    gnome_help_display_desktop      (GnomeProgram *program,
                                             const char *doc_id,
                                             const char *file_name,
                                             const char *link_id,
                                             GError **error);

Displays the GNOME system help file specified by file_name at location link_id in the preferred help browser of the user. This is done by creating a "ghelp" URI, by looking for file_name in the system help domain (GNOME_FILE_DOMAIN_HELP) and it's app_id. This domain is determined when the library is compiled. If a matching file cannot be found, FALSE is returned and error is set.

Please note that this only displays system help. To display help files for an application, you will want to use #gnome_help_display().


gnome_help_display_uri ()

gboolean    gnome_help_display_uri          (const char *help_uri,
                                             GError **error);

Displays help_uri in the user's preferred viewer. You should never need to call this function directly in code, since it is just a wrapper for gnome_url_show() and consequently the viewer used to display the results depends upon the scheme of the URI (so it is not strictly a help-only function).


gnome_help_error_quark ()

GQuark      gnome_help_error_quark          (void);