Added basic support for using the online user manual:

2008-06-12  Sven Neumann  <sven@gimp.org>

	Added basic support for using the online user manual:

	* app/widgets/gimphelp.c
	* plug-ins/help/gimphelp.c: moved some help logic to the core. 
The
	default help domain is now constructed in the core and passed to
	the help plug-ins just like the plug-in help domains.

	* app/config/Makefile.am
	* app/config/gimprc-blurbs.h
	* app/config/gimpguiconfig.[ch]: added gimprc properties to
	specify the location of the online user manual and to decide if 
it
	should be used instead of a locally installed copy.


svn path=/trunk/; revision=25938
This commit is contained in:
Sven Neumann 2008-06-12 20:14:44 +00:00 committed by Sven Neumann
parent fdc55c5cee
commit 92396c2c2d
7 changed files with 127 additions and 40 deletions

View File

@ -1,3 +1,18 @@
2008-06-12 Sven Neumann <sven@gimp.org>
Added basic support for using the online user manual:
* app/widgets/gimphelp.c
* plug-ins/help/gimphelp.c: moved some help logic to the core. The
default help domain is now constructed in the core and passed to
the help plug-ins just like the plug-in help domains.
* app/config/Makefile.am
* app/config/gimprc-blurbs.h
* app/config/gimpguiconfig.[ch]: added gimprc properties to
specify the location of the online user manual and to decide if it
should be used instead of a locally installed copy.
2008-06-12 Sven Neumann <sven@gimp.org>
* app/tools/gimprectangletool.c (gimp_rectangle_tool_motion):

View File

@ -40,7 +40,8 @@ libappconfig_a_SOURCES = \
gimpxmlparser.h
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Config\"
-DG_LOG_DOMAIN=\"Gimp-Config\" \
-DGIMP_APP_VERSION_STRING=\"$(GIMP_APP_VERSION)\"
INCLUDES = \
-I$(top_builddir) \

View File

@ -34,15 +34,18 @@
#include "gimp-intl.h"
#define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_GIMP
#define DEFAULT_THEME "Default"
#define DEFAULT_HELP_BROWSER GIMP_HELP_BROWSER_GIMP
#define DEFAULT_THEME "Default"
#define DEFAULT_USER_MANUAL_ONLINE_URI \
"http://docs.gimp.org/" GIMP_APP_VERSION_STRING
#ifdef G_OS_WIN32
# define DEFAULT_WEB_BROWSER "not used on Windows"
# define DEFAULT_WEB_BROWSER "not used on Windows"
#elif HAVE_CARBON
# define DEFAULT_WEB_BROWSER "open %s"
# define DEFAULT_WEB_BROWSER "open %s"
#else
# define DEFAULT_WEB_BROWSER "firefox %s"
# define DEFAULT_WEB_BROWSER "firefox %s"
#endif
@ -74,6 +77,8 @@ enum
PROP_HELP_LOCALES,
PROP_HELP_BROWSER,
PROP_WEB_BROWSER,
PROP_USER_MANUAL_ONLINE,
PROP_USER_MANUAL_ONLINE_URI,
PROP_TOOLBOX_WINDOW_HINT,
PROP_DOCK_WINDOW_HINT,
PROP_TRANSIENT_DOCKS,
@ -217,13 +222,23 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_HELP_BROWSER,
"help-browser", HELP_BROWSER_BLURB,
GIMP_TYPE_HELP_BROWSER_TYPE,
DEFAULT_GIMP_HELP_BROWSER,
DEFAULT_HELP_BROWSER,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_WEB_BROWSER,
"web-browser", WEB_BROWSER_BLURB,
GIMP_CONFIG_PATH_FILE,
DEFAULT_WEB_BROWSER,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USER_MANUAL_ONLINE,
"user-manual-online",
USER_MANUAL_ONLINE_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_USER_MANUAL_ONLINE_URI,
"user-manual-online-uri",
USER_MANUAL_ONLINE_URI_BLURB,
DEFAULT_USER_MANUAL_ONLINE_URI,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TOOLBOX_WINDOW_HINT,
"toolbox-window-hint",
TOOLBOX_WINDOW_HINT_BLURB,
@ -263,6 +278,7 @@ gimp_gui_config_finalize (GObject *object)
g_free (gui_config->theme);
g_free (gui_config->help_locales);
g_free (gui_config->web_browser);
g_free (gui_config->user_manual_online_uri);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -356,6 +372,13 @@ gimp_gui_config_set_property (GObject *object,
g_free (gui_config->web_browser);
gui_config->web_browser = g_value_dup_string (value);
break;
case PROP_USER_MANUAL_ONLINE:
gui_config->user_manual_online = g_value_get_boolean (value);
break;
case PROP_USER_MANUAL_ONLINE_URI:
g_free (gui_config->user_manual_online_uri);
gui_config->user_manual_online_uri = g_value_dup_string (value);
break;
case PROP_TOOLBOX_WINDOW_HINT:
gui_config->toolbox_window_hint = g_value_get_enum (value);
break;
@ -460,6 +483,12 @@ gimp_gui_config_get_property (GObject *object,
case PROP_WEB_BROWSER:
g_value_set_string (value, gui_config->web_browser);
break;
case PROP_USER_MANUAL_ONLINE:
g_value_set_boolean (value, gui_config->user_manual_online);
break;
case PROP_USER_MANUAL_ONLINE_URI:
g_value_set_string (value, gui_config->user_manual_online_uri);
break;
case PROP_TOOLBOX_WINDOW_HINT:
g_value_set_enum (value, gui_config->toolbox_window_hint);
break;

View File

@ -65,6 +65,8 @@ struct _GimpGuiConfig
gchar *help_locales;
GimpHelpBrowserType help_browser;
gchar *web_browser;
gboolean user_manual_online;
gchar *user_manual_online_uri;
GimpWindowHint toolbox_window_hint;
GimpWindowHint dock_window_hint;
gboolean transient_docks;

View File

@ -419,6 +419,14 @@ N_("Sets the size of the previews in the Undo History.")
#define USE_HELP_BLURB \
N_("When enabled, pressing F1 will open the help browser.")
#define USER_MANUAL_ONLINE_BLURB \
N_("When enabled, the online user manual will be used by the help system. " \
"Otherwise the locally installed copy is used.")
#define USER_MANUAL_ONLINE_URI_BLURB \
"The location of the online user manual. This is used if " \
"'user-manual-online' is enabled."
#define WEB_BROWSER_BLURB \
N_("Sets the external web browser to be used. This can be an absolute " \
"path or the name of an executable to search for in the user's PATH. " \

View File

@ -80,7 +80,12 @@ static void gimp_help_call (Gimp *gimp,
const gchar *help_domain,
const gchar *help_locales,
const gchar *help_id);
static gchar * gimp_help_get_locales (GimpGuiConfig *config);
static gint gimp_help_get_help_domains (Gimp *gimp,
gchar ***domain_names,
gchar ***domain_uris);
static gchar * gimp_help_get_default_domain_uri (Gimp *gimp);
static gchar * gimp_help_get_locales (Gimp *gimp);
/* public functions */
@ -108,7 +113,7 @@ gimp_help_show (Gimp *gimp,
if (help_domain && strlen (help_domain))
idle_help->help_domain = g_strdup (help_domain);
idle_help->help_locales = gimp_help_get_locales (config);
idle_help->help_locales = gimp_help_get_locales (gimp);
if (help_id && strlen (help_id))
idle_help->help_id = g_strdup (help_id);
@ -202,9 +207,7 @@ gimp_help_browser (Gimp *gimp)
return FALSE;
}
n_domains = gimp_plug_in_manager_get_help_domains (gimp->plug_in_manager,
&help_domains,
&help_uris);
n_domains = gimp_help_get_help_domains (gimp, &help_domains, &help_uris);
args = gimp_procedure_get_arguments (procedure);
gimp_value_array_truncate (args, 5);
@ -409,9 +412,62 @@ gimp_help_call (Gimp *gimp,
}
}
static gchar *
gimp_help_get_locales (GimpGuiConfig *config)
static gint
gimp_help_get_help_domains (Gimp *gimp,
gchar ***domain_names,
gchar ***domain_uris)
{
gchar **plug_in_domains = NULL;
gchar **plug_in_uris = NULL;
gint i, n_domains;
n_domains = gimp_plug_in_manager_get_help_domains (gimp->plug_in_manager,
&plug_in_domains,
&plug_in_uris);
*domain_names = g_new0 (gchar *, n_domains + 1);
*domain_uris = g_new0 (gchar *, n_domains + 1);
*domain_names[0] = g_strdup ("http://www.gimp.org/help");
*domain_uris[0] = gimp_help_get_default_domain_uri (gimp);
for (i = 0; i < n_domains; i++)
{
*domain_names[i + 1] = plug_in_domains[i];
*domain_uris[i + 1] = plug_in_uris[i];
}
g_free (plug_in_domains);
g_free (plug_in_uris);
return n_domains + 1;
}
static gchar *
gimp_help_get_default_domain_uri (Gimp *gimp)
{
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
gchar *dir;
gchar *uri;
if (g_getenv ("GIMP2_HELP_URI"))
return g_strdup (g_getenv ("GIMP2_HELP_URI"));
if (config->user_manual_online)
return g_strdup (config->user_manual_online_uri);
dir = g_build_filename (gimp_data_directory (), "help", NULL);
uri = g_filename_to_uri (dir, NULL, NULL);
g_free (dir);
return uri;
}
static gchar *
gimp_help_get_locales (Gimp *gimp)
{
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
if (config->help_locales && strlen (config->help_locales))
return g_strdup (config->help_locales);

View File

@ -55,9 +55,7 @@ gimp_help_init (gint num_domain_names,
gint num_domain_uris,
gchar **domain_uris)
{
const gchar *default_env_domain_uri;
gchar *default_domain_uri;
gint i;
gint i;
if (num_domain_names != num_domain_uris)
{
@ -66,31 +64,9 @@ gimp_help_init (gint num_domain_names,
return FALSE;
}
/* set default values */
default_env_domain_uri = g_getenv (GIMP_HELP_ENV_URI);
if (default_env_domain_uri)
{
default_domain_uri = g_strdup (default_env_domain_uri);
}
else
{
gchar *help_root = g_build_filename (gimp_data_directory (),
GIMP_HELP_PREFIX,
NULL);
default_domain_uri = g_filename_to_uri (help_root, NULL, NULL);
g_free (help_root);
}
gimp_help_register_domain (GIMP_HELP_DEFAULT_DOMAIN, default_domain_uri);
for (i = 0; i < num_domain_names; i++)
gimp_help_register_domain (domain_names[i], domain_uris[i]);
g_free (default_domain_uri);
return TRUE;
}
@ -160,7 +136,7 @@ gimp_help_parse_locales (const gchar *help_locales)
if (*s)
locales = g_list_append (locales, g_strdup (s));
/* if the list doesn't contain the default domain yet, append it */
/* if the list doesn't contain the default locale yet, append it */
for (list = locales; list; list = list->next)
if (strcmp ((const gchar *) list->data, GIMP_HELP_DEFAULT_LOCALE) == 0)
break;