2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1999-09-27 17:58:10 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimphelp.c
|
2004-03-09 01:37:56 +00:00
|
|
|
* Copyright (C) 1999-2004 Michael Natterer <mitch@gimp.org>
|
|
|
|
* Henrik Brix Andersen <brix@gimp.org>
|
1999-09-27 17:58:10 +00:00
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1999-09-27 17:58:10 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1999-09-27 17:58:10 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1999-09-27 17:58:10 +00:00
|
|
|
*/
|
2000-12-29 15:22:01 +00:00
|
|
|
|
1999-12-19 17:15:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-06-23 00:14:07 +00:00
|
|
|
#include <string.h>
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2012-03-21 21:58:40 +01:00
|
|
|
#include <gegl.h>
|
1999-09-27 17:58:10 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-21 20:30:16 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-05 19:17:41 +00:00
|
|
|
#include "widgets-types.h"
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2002-11-18 20:50:31 +00:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2002-04-12 18:14:13 +00:00
|
|
|
#include "core/gimp.h"
|
2006-04-29 17:55:42 +00:00
|
|
|
#include "core/gimpparamspecs.h"
|
2008-06-10 09:54:54 +00:00
|
|
|
#include "core/gimpprogress.h"
|
|
|
|
#include "core/gimp-utils.h"
|
2002-04-12 18:14:13 +00:00
|
|
|
|
2006-04-26 09:13:47 +00:00
|
|
|
#include "pdb/gimppdb.h"
|
2006-03-31 09:15:08 +00:00
|
|
|
#include "pdb/gimpprocedure.h"
|
2002-03-20 17:46:13 +00:00
|
|
|
|
2009-02-26 22:58:19 +00:00
|
|
|
#include "plug-in/gimpplugin.h"
|
2006-04-28 22:26:51 +00:00
|
|
|
#include "plug-in/gimppluginmanager-help-domain.h"
|
2009-02-26 22:58:19 +00:00
|
|
|
#include "plug-in/gimptemporaryprocedure.h"
|
2001-12-01 00:14:14 +00:00
|
|
|
|
1999-09-27 17:58:10 +00:00
|
|
|
#include "gimphelp.h"
|
2003-08-23 19:35:05 +00:00
|
|
|
#include "gimphelp-ids.h"
|
2017-10-03 01:52:35 +02:00
|
|
|
#include "gimplanguagecombobox.h"
|
2004-10-13 11:57:07 +00:00
|
|
|
#include "gimpmessagebox.h"
|
2004-10-13 14:35:28 +00:00
|
|
|
#include "gimpmessagedialog.h"
|
2008-07-06 17:47:24 +00:00
|
|
|
#include "gimpmessagedialog.h"
|
2008-08-29 09:05:49 +00:00
|
|
|
#include "gimpwidgets-utils.h"
|
2002-05-05 19:17:41 +00:00
|
|
|
|
2007-11-16 18:56:10 +00:00
|
|
|
#include "gimp-log.h"
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
1999-09-27 17:58:10 +00:00
|
|
|
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-21 17:41:02 +00:00
|
|
|
|
|
|
|
typedef struct _GimpIdleHelp GimpIdleHelp;
|
|
|
|
|
|
|
|
struct _GimpIdleHelp
|
|
|
|
{
|
2008-06-10 09:54:54 +00:00
|
|
|
Gimp *gimp;
|
|
|
|
GimpProgress *progress;
|
|
|
|
gchar *help_domain;
|
|
|
|
gchar *help_locales;
|
|
|
|
gchar *help_id;
|
2017-09-25 22:59:50 +02:00
|
|
|
|
|
|
|
GtkDialog *query_dialog;
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-21 17:41:02 +00:00
|
|
|
};
|
|
|
|
|
2001-12-01 00:14:14 +00:00
|
|
|
|
1999-11-20 12:12:41 +00:00
|
|
|
/* local function prototypes */
|
2001-12-01 00:14:14 +00:00
|
|
|
|
2008-07-06 17:47:24 +00:00
|
|
|
static gboolean gimp_idle_help (GimpIdleHelp *idle_help);
|
|
|
|
static void gimp_idle_help_free (GimpIdleHelp *idle_help);
|
2008-06-10 09:16:48 +00:00
|
|
|
|
2008-07-10 10:12:34 +00:00
|
|
|
static gboolean gimp_help_browser (Gimp *gimp,
|
2015-11-08 23:26:48 +01:00
|
|
|
GimpProgress *progress);
|
2008-06-10 09:16:48 +00:00
|
|
|
static void gimp_help_browser_error (Gimp *gimp,
|
2015-11-08 23:26:48 +01:00
|
|
|
GimpProgress *progress,
|
2008-06-10 09:16:48 +00:00
|
|
|
const gchar *title,
|
|
|
|
const gchar *primary,
|
|
|
|
const gchar *text);
|
|
|
|
|
|
|
|
static void gimp_help_call (Gimp *gimp,
|
2008-06-10 09:54:54 +00:00
|
|
|
GimpProgress *progress,
|
2008-06-10 09:16:48 +00:00
|
|
|
const gchar *procedure_name,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_locales,
|
|
|
|
const gchar *help_id);
|
2008-06-12 20:14:44 +00:00
|
|
|
|
2020-12-23 21:15:43 +01:00
|
|
|
static void gimp_help_get_help_domains (Gimp *gimp,
|
2008-07-06 17:47:24 +00:00
|
|
|
gchar ***domain_names,
|
|
|
|
gchar ***domain_uris);
|
|
|
|
static gchar * gimp_help_get_default_domain_uri (Gimp *gimp);
|
|
|
|
static gchar * gimp_help_get_locales (Gimp *gimp);
|
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
static GFile * gimp_help_get_user_manual_basedir (void);
|
2008-07-05 12:01:00 +00:00
|
|
|
|
2017-09-25 22:59:50 +02:00
|
|
|
static void gimp_help_query_alt_user_manual (GimpIdleHelp *idle_help);
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2017-09-25 22:59:50 +02:00
|
|
|
static void gimp_help_language_combo_changed (GtkComboBox *combo,
|
|
|
|
GimpIdleHelp *idle_help);
|
2001-12-01 00:14:14 +00:00
|
|
|
|
1999-11-20 12:12:41 +00:00
|
|
|
/* public functions */
|
1999-11-03 09:58:46 +00:00
|
|
|
|
1999-11-20 12:12:41 +00:00
|
|
|
void
|
2008-06-10 09:54:54 +00:00
|
|
|
gimp_help_show (Gimp *gimp,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_id)
|
1999-11-20 12:12:41 +00:00
|
|
|
{
|
2004-03-17 13:59:42 +00:00
|
|
|
GimpGuiConfig *config;
|
|
|
|
|
2002-04-12 18:14:13 +00:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2008-06-10 09:54:54 +00:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
2002-04-12 18:14:13 +00:00
|
|
|
|
2004-03-17 13:59:42 +00:00
|
|
|
config = GIMP_GUI_CONFIG (gimp->config);
|
|
|
|
|
|
|
|
if (config->use_help)
|
1999-11-20 12:12:41 +00:00
|
|
|
{
|
2007-05-22 15:14:41 +00:00
|
|
|
GimpIdleHelp *idle_help = g_slice_new0 (GimpIdleHelp);
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2008-06-10 09:54:54 +00:00
|
|
|
idle_help->gimp = gimp;
|
|
|
|
idle_help->progress = progress;
|
2002-04-12 18:14:13 +00:00
|
|
|
|
2003-08-28 18:49:11 +00:00
|
|
|
if (help_domain && strlen (help_domain))
|
2006-04-12 12:49:29 +00:00
|
|
|
idle_help->help_domain = g_strdup (help_domain);
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-21 17:41:02 +00:00
|
|
|
|
2008-06-12 20:14:44 +00:00
|
|
|
idle_help->help_locales = gimp_help_get_locales (gimp);
|
2003-07-24 17:30:14 +00:00
|
|
|
|
2003-08-23 19:35:05 +00:00
|
|
|
if (help_id && strlen (help_id))
|
2006-04-12 12:49:29 +00:00
|
|
|
idle_help->help_id = g_strdup (help_id);
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-21 17:41:02 +00:00
|
|
|
|
2008-07-07 06:51:20 +00:00
|
|
|
GIMP_LOG (HELP, "request for help-id '%s' from help-domain '%s'",
|
|
|
|
help_id ? help_id : "(null)",
|
|
|
|
help_domain ? help_domain : "(null)");
|
2004-07-27 11:19:33 +00:00
|
|
|
|
2008-07-07 06:51:20 +00:00
|
|
|
g_idle_add ((GSourceFunc) gimp_idle_help, idle_help);
|
2000-01-05 15:47:06 +00:00
|
|
|
}
|
1999-11-20 12:12:41 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:51:47 +02:00
|
|
|
gboolean
|
|
|
|
gimp_help_browser_is_installed (Gimp *gimp)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
|
|
|
if (gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-browser"))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-07-05 12:01:00 +00:00
|
|
|
gboolean
|
|
|
|
gimp_help_user_manual_is_installed (Gimp *gimp)
|
2008-07-04 18:41:58 +00:00
|
|
|
{
|
2014-07-29 13:04:16 +02:00
|
|
|
GFile *basedir;
|
2008-07-05 12:01:00 +00:00
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
2008-07-05 12:11:35 +00:00
|
|
|
/* if GIMP2_HELP_URI is set, assume that the manual can be found there */
|
|
|
|
if (g_getenv ("GIMP2_HELP_URI"))
|
|
|
|
return TRUE;
|
|
|
|
|
2008-07-05 12:01:00 +00:00
|
|
|
basedir = gimp_help_get_user_manual_basedir ();
|
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
if (g_file_query_file_type (basedir, G_FILE_QUERY_INFO_NONE, NULL) ==
|
|
|
|
G_FILE_TYPE_DIRECTORY)
|
2008-07-05 12:01:00 +00:00
|
|
|
{
|
|
|
|
gchar *locales = gimp_help_get_locales (gimp);
|
|
|
|
const gchar *s = locales;
|
|
|
|
const gchar *p;
|
|
|
|
|
|
|
|
for (p = strchr (s, ':'); p && !found; p = strchr (s, ':'))
|
|
|
|
{
|
|
|
|
gchar *locale = g_strndup (s, p - s);
|
2014-07-29 13:04:16 +02:00
|
|
|
GFile *file1 = g_file_get_child (basedir, locale);
|
|
|
|
GFile *file2 = g_file_get_child (file1, "gimp-help.xml");
|
2008-07-05 12:01:00 +00:00
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
found = (g_file_query_file_type (file2, G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL) == G_FILE_TYPE_REGULAR);
|
2008-07-05 12:01:00 +00:00
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
g_object_unref (file1);
|
|
|
|
g_object_unref (file2);
|
2008-07-05 12:01:00 +00:00
|
|
|
g_free (locale);
|
|
|
|
|
|
|
|
s = p + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (locales);
|
2008-10-31 20:00:19 +00:00
|
|
|
|
|
|
|
if (! found)
|
|
|
|
{
|
2014-07-29 13:04:16 +02:00
|
|
|
GFile *file1 = g_file_get_child (basedir, "en");
|
|
|
|
GFile *file2 = g_file_get_child (file1, "gimp-help.xml");
|
2008-10-31 20:00:19 +00:00
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
found = (g_file_query_file_type (file2, G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL) == G_FILE_TYPE_REGULAR);
|
2008-10-31 20:00:19 +00:00
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
g_object_unref (file1);
|
|
|
|
g_object_unref (file2);
|
2008-10-31 20:00:19 +00:00
|
|
|
}
|
2008-07-05 12:01:00 +00:00
|
|
|
}
|
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
g_object_unref (basedir);
|
2008-07-05 12:01:00 +00:00
|
|
|
|
|
|
|
return found;
|
2008-07-04 18:41:58 +00:00
|
|
|
}
|
|
|
|
|
2009-02-26 22:58:19 +00:00
|
|
|
void
|
|
|
|
gimp_help_user_manual_changed (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
/* Check if a help parser is running */
|
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp");
|
|
|
|
|
|
|
|
if (GIMP_IS_TEMPORARY_PROCEDURE (procedure))
|
|
|
|
{
|
|
|
|
gimp_plug_in_close (GIMP_TEMPORARY_PROCEDURE (procedure)->plug_in, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:52:35 +02:00
|
|
|
GList *
|
|
|
|
gimp_help_get_installed_languages (void)
|
|
|
|
{
|
|
|
|
GList *manuals = NULL;
|
|
|
|
GFile *basedir;
|
|
|
|
|
|
|
|
/* if GIMP2_HELP_URI is set, assume that the manual can be found there */
|
|
|
|
if (g_getenv ("GIMP2_HELP_URI"))
|
|
|
|
basedir = g_file_new_for_uri (g_getenv ("GIMP2_HELP_URI"));
|
|
|
|
else
|
|
|
|
basedir = gimp_help_get_user_manual_basedir ();
|
|
|
|
|
|
|
|
if (g_file_query_file_type (basedir, G_FILE_QUERY_INFO_NONE, NULL) ==
|
|
|
|
G_FILE_TYPE_DIRECTORY)
|
|
|
|
{
|
|
|
|
GFileEnumerator *enumerator;
|
|
|
|
|
|
|
|
enumerator = g_file_enumerate_children (basedir,
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_TYPE,
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
if (enumerator)
|
|
|
|
{
|
|
|
|
GFileInfo *info;
|
|
|
|
|
|
|
|
while ((info = g_file_enumerator_next_file (enumerator,
|
|
|
|
NULL, NULL)))
|
|
|
|
{
|
2023-09-19 14:38:42 +02:00
|
|
|
if (g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
|
2017-10-03 01:52:35 +02:00
|
|
|
{
|
|
|
|
GFile *locale_dir;
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
locale_dir = g_file_enumerator_get_child (enumerator, info);
|
|
|
|
file = g_file_get_child (locale_dir, "gimp-help.xml");
|
|
|
|
if (g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE,
|
|
|
|
NULL) == G_FILE_TYPE_REGULAR)
|
|
|
|
{
|
|
|
|
manuals = g_list_prepend (manuals,
|
|
|
|
g_strdup (g_file_info_get_name (info)));
|
|
|
|
}
|
|
|
|
g_object_unref (locale_dir);
|
|
|
|
g_object_unref (file);
|
|
|
|
}
|
|
|
|
g_object_unref (info);
|
|
|
|
}
|
|
|
|
g_object_unref (enumerator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_object_unref (basedir);
|
|
|
|
|
|
|
|
return manuals;
|
|
|
|
}
|
2001-12-01 00:14:14 +00:00
|
|
|
|
|
|
|
/* private functions */
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2001-08-17 14:27:31 +00:00
|
|
|
static gboolean
|
2007-05-22 15:14:41 +00:00
|
|
|
gimp_idle_help (GimpIdleHelp *idle_help)
|
1999-11-20 12:12:41 +00:00
|
|
|
{
|
2006-03-31 17:42:13 +00:00
|
|
|
GimpGuiConfig *config = GIMP_GUI_CONFIG (idle_help->gimp->config);
|
|
|
|
const gchar *procedure_name = NULL;
|
2002-11-18 20:50:31 +00:00
|
|
|
|
2008-07-06 17:47:24 +00:00
|
|
|
if (! idle_help->help_domain &&
|
|
|
|
! config->user_manual_online &&
|
|
|
|
! gimp_help_user_manual_is_installed (idle_help->gimp))
|
|
|
|
{
|
2017-09-25 22:59:50 +02:00
|
|
|
/* The user manual is not installed locally, propose alternative
|
|
|
|
* manuals (other installed languages or online version).
|
2008-07-06 17:47:24 +00:00
|
|
|
*/
|
2017-09-25 22:59:50 +02:00
|
|
|
gimp_help_query_alt_user_manual (idle_help);
|
2008-07-06 17:47:24 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-10-13 10:34:02 +00:00
|
|
|
if (config->help_browser == GIMP_HELP_BROWSER_GIMP)
|
1999-12-19 17:15:11 +00:00
|
|
|
{
|
2008-07-10 10:12:34 +00:00
|
|
|
if (gimp_help_browser (idle_help->gimp, idle_help->progress))
|
2006-03-31 17:42:13 +00:00
|
|
|
procedure_name = "extension-gimp-help-browser-temp";
|
2004-10-13 10:34:02 +00:00
|
|
|
}
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2004-10-13 10:34:02 +00:00
|
|
|
if (config->help_browser == GIMP_HELP_BROWSER_WEB_BROWSER)
|
|
|
|
{
|
2004-03-09 01:37:56 +00:00
|
|
|
/* FIXME: should check for procedure availability */
|
2006-03-31 17:42:13 +00:00
|
|
|
procedure_name = "plug-in-web-browser";
|
1999-12-19 17:15:11 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (procedure_name)
|
2004-10-13 10:34:02 +00:00
|
|
|
gimp_help_call (idle_help->gimp,
|
2008-06-10 09:54:54 +00:00
|
|
|
idle_help->progress,
|
2006-03-31 17:42:13 +00:00
|
|
|
procedure_name,
|
2004-10-13 10:34:02 +00:00
|
|
|
idle_help->help_domain,
|
|
|
|
idle_help->help_locales,
|
|
|
|
idle_help->help_id);
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2008-07-06 17:47:24 +00:00
|
|
|
gimp_idle_help_free (idle_help);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_idle_help_free (GimpIdleHelp *idle_help)
|
|
|
|
{
|
2003-08-28 18:49:11 +00:00
|
|
|
g_free (idle_help->help_domain);
|
2004-03-17 13:59:42 +00:00
|
|
|
g_free (idle_help->help_locales);
|
2003-08-23 19:35:05 +00:00
|
|
|
g_free (idle_help->help_id);
|
2007-05-22 15:14:41 +00:00
|
|
|
|
|
|
|
g_slice_free (GimpIdleHelp, idle_help);
|
2000-01-05 15:47:06 +00:00
|
|
|
}
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2000-08-25 17:41:38 +00:00
|
|
|
static gboolean
|
2008-07-10 10:12:34 +00:00
|
|
|
gimp_help_browser (Gimp *gimp,
|
2015-11-08 23:26:48 +01:00
|
|
|
GimpProgress *progress)
|
1999-12-19 17:15:11 +00:00
|
|
|
{
|
2004-10-13 10:34:02 +00:00
|
|
|
static gboolean busy = FALSE;
|
2006-03-31 17:42:13 +00:00
|
|
|
GimpProcedure *procedure;
|
2003-07-24 17:30:14 +00:00
|
|
|
|
|
|
|
if (busy)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
busy = TRUE;
|
|
|
|
|
1999-11-20 12:12:41 +00:00
|
|
|
/* Check if a help browser is already running */
|
2006-04-26 09:13:47 +00:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb,
|
|
|
|
"extension-gimp-help-browser-temp");
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (! procedure)
|
1999-11-20 12:12:41 +00:00
|
|
|
{
|
2012-05-04 00:50:23 +02:00
|
|
|
GimpValueArray *args = NULL;
|
|
|
|
gchar **help_domains = NULL;
|
|
|
|
gchar **help_uris = NULL;
|
|
|
|
GError *error = NULL;
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2006-04-26 09:13:47 +00:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb,
|
|
|
|
"extension-gimp-help-browser");
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (! procedure)
|
2006-04-12 12:49:29 +00:00
|
|
|
{
|
2008-07-10 10:12:34 +00:00
|
|
|
gimp_help_browser_error (gimp, progress,
|
|
|
|
_("Help browser is missing"),
|
|
|
|
_("The GIMP help browser is not available."),
|
2004-10-13 11:57:07 +00:00
|
|
|
_("The GIMP help browser plug-in appears "
|
2008-07-10 10:12:34 +00:00
|
|
|
"to be missing from your installation. "
|
2015-11-08 23:26:48 +01:00
|
|
|
"You may instead use the web browser "
|
|
|
|
"for reading the help pages."));
|
2003-07-24 17:30:14 +00:00
|
|
|
busy = FALSE;
|
|
|
|
|
2006-04-12 12:49:29 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2020-12-23 21:15:43 +01:00
|
|
|
gimp_help_get_help_domains (gimp, &help_domains, &help_uris);
|
2006-11-23 21:04:41 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
2020-12-23 21:15:43 +01:00
|
|
|
gimp_value_array_truncate (args, 3);
|
|
|
|
|
|
|
|
g_value_set_enum (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE);
|
|
|
|
g_value_take_boxed (gimp_value_array_index (args, 1), help_domains);
|
|
|
|
g_value_take_boxed (gimp_value_array_index (args, 2), help_uris);
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2006-04-07 18:23:20 +00:00
|
|
|
gimp_procedure_execute_async (procedure, gimp,
|
|
|
|
gimp_get_user_context (gimp),
|
2007-12-02 18:05:54 +00:00
|
|
|
NULL, args, NULL, &error);
|
2003-08-28 18:49:11 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
gimp_value_array_unref (args);
|
2007-12-02 18:05:54 +00:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
|
2013-09-15 04:59:20 +12:00
|
|
|
error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2003-08-28 18:49:11 +00:00
|
|
|
/* Check if the help browser started properly */
|
2006-04-26 09:13:47 +00:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb,
|
|
|
|
"extension-gimp-help-browser-temp");
|
1999-11-20 12:12:41 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (! procedure)
|
2003-08-28 18:49:11 +00:00
|
|
|
{
|
2008-07-10 10:12:34 +00:00
|
|
|
gimp_help_browser_error (gimp, progress,
|
2004-10-13 11:57:07 +00:00
|
|
|
_("Help browser doesn't start"),
|
2008-07-04 21:49:17 +00:00
|
|
|
_("Could not start the GIMP help browser "
|
|
|
|
"plug-in."),
|
2016-09-06 20:51:47 +02:00
|
|
|
_("You may instead use the web browser "
|
|
|
|
"for reading the help pages."));
|
2003-08-28 18:49:11 +00:00
|
|
|
busy = FALSE;
|
|
|
|
|
2004-10-13 10:34:02 +00:00
|
|
|
return FALSE;
|
1999-11-20 12:12:41 +00:00
|
|
|
}
|
2000-08-25 17:41:38 +00:00
|
|
|
|
2003-07-24 17:30:14 +00:00
|
|
|
busy = FALSE;
|
|
|
|
|
2000-08-25 17:41:38 +00:00
|
|
|
return TRUE;
|
1999-11-20 12:12:41 +00:00
|
|
|
}
|
|
|
|
|
2004-10-13 11:57:07 +00:00
|
|
|
static void
|
2008-07-10 10:12:34 +00:00
|
|
|
gimp_help_browser_error (Gimp *gimp,
|
2015-11-08 23:26:48 +01:00
|
|
|
GimpProgress *progress,
|
2008-07-10 10:12:34 +00:00
|
|
|
const gchar *title,
|
|
|
|
const gchar *primary,
|
|
|
|
const gchar *text)
|
2004-10-13 11:57:07 +00:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
2017-03-05 16:01:59 +01:00
|
|
|
dialog = gimp_message_dialog_new (title, GIMP_ICON_HELP_USER_MANUAL,
|
2015-11-08 23:26:48 +01:00
|
|
|
NULL, 0,
|
|
|
|
NULL, NULL,
|
2004-10-13 11:57:07 +00:00
|
|
|
|
2017-02-12 16:06:34 +01:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
2015-11-08 23:26:48 +01:00
|
|
|
_("Use _Web Browser"), GTK_RESPONSE_OK,
|
2004-10-13 11:57:07 +00:00
|
|
|
|
2015-11-08 23:26:48 +01:00
|
|
|
NULL);
|
2004-10-13 11:57:07 +00:00
|
|
|
|
2018-05-10 17:04:37 +02:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2007-10-09 08:04:31 +00:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2008-07-10 10:12:34 +00:00
|
|
|
if (progress)
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 14:23:06 +02:00
|
|
|
gimp_window_set_transient_for (GTK_WINDOW (dialog), progress);
|
2008-07-10 10:12:34 +00:00
|
|
|
|
2007-10-09 08:04:31 +00:00
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
2008-11-04 12:33:09 +00:00
|
|
|
"%s", primary);
|
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, "%s", text);
|
2004-10-13 11:57:07 +00:00
|
|
|
|
|
|
|
if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
2007-10-09 08:04:31 +00:00
|
|
|
{
|
|
|
|
g_object_set (gimp->config,
|
|
|
|
"help-browser", GIMP_HELP_BROWSER_WEB_BROWSER,
|
|
|
|
NULL);
|
|
|
|
}
|
2004-10-13 11:57:07 +00:00
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
2000-01-06 16:40:17 +00:00
|
|
|
static void
|
2008-06-10 09:54:54 +00:00
|
|
|
gimp_help_call (Gimp *gimp,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const gchar *procedure_name,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_locales,
|
|
|
|
const gchar *help_id)
|
1999-11-20 12:12:41 +00:00
|
|
|
{
|
2006-03-31 17:42:13 +00:00
|
|
|
GimpProcedure *procedure;
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2006-11-23 21:04:41 +00:00
|
|
|
/* Special case the help browser */
|
|
|
|
if (! strcmp (procedure_name, "extension-gimp-help-browser-temp"))
|
|
|
|
{
|
2012-05-04 00:50:23 +02:00
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GError *error = NULL;
|
2006-11-23 21:04:41 +00:00
|
|
|
|
2007-11-16 18:56:10 +00:00
|
|
|
GIMP_LOG (HELP, "Calling help via %s: %s %s %s",
|
|
|
|
procedure_name,
|
|
|
|
help_domain ? help_domain : "(null)",
|
|
|
|
help_locales ? help_locales : "(null)",
|
|
|
|
help_id ? help_id : "(null)");
|
|
|
|
|
2007-10-09 08:04:31 +00:00
|
|
|
return_vals =
|
|
|
|
gimp_pdb_execute_procedure_by_name (gimp->pdb,
|
|
|
|
gimp_get_user_context (gimp),
|
2008-06-10 09:54:54 +00:00
|
|
|
progress, &error,
|
2007-10-09 08:04:31 +00:00
|
|
|
procedure_name,
|
|
|
|
G_TYPE_STRING, help_domain,
|
|
|
|
G_TYPE_STRING, help_locales,
|
|
|
|
G_TYPE_STRING, help_id,
|
|
|
|
G_TYPE_NONE);
|
2006-11-23 21:04:41 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
gimp_value_array_unref (return_vals);
|
2006-11-23 21:04:41 +00:00
|
|
|
|
2007-12-02 18:05:54 +00:00
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
2006-11-23 21:04:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-09 01:37:56 +00:00
|
|
|
/* Check if a help parser is already running */
|
2006-04-26 09:13:47 +00:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp");
|
2003-01-09 12:45:25 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (! procedure)
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-21 17:41:02 +00:00
|
|
|
{
|
2012-05-04 00:50:23 +02:00
|
|
|
GimpValueArray *args = NULL;
|
|
|
|
gchar **help_domains = NULL;
|
|
|
|
gchar **help_uris = NULL;
|
|
|
|
GError *error = NULL;
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2006-04-26 09:13:47 +00:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help");
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (! procedure)
|
2004-10-13 10:34:02 +00:00
|
|
|
/* FIXME: error msg */
|
|
|
|
return;
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2020-12-23 21:15:43 +01:00
|
|
|
gimp_help_get_help_domains (gimp, &help_domains, &help_uris);
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
2020-12-23 21:15:43 +01:00
|
|
|
gimp_value_array_truncate (args, 2);
|
2004-03-09 10:58:06 +00:00
|
|
|
|
2020-12-23 21:15:43 +01:00
|
|
|
g_value_take_boxed (gimp_value_array_index (args, 0), help_domains);
|
|
|
|
g_value_take_boxed (gimp_value_array_index (args, 1), help_uris);
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2006-04-07 18:23:20 +00:00
|
|
|
gimp_procedure_execute_async (procedure, gimp,
|
2008-06-10 09:54:54 +00:00
|
|
|
gimp_get_user_context (gimp), progress,
|
|
|
|
args, NULL, &error);
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
gimp_value_array_unref (args);
|
2007-12-02 18:05:54 +00:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-21 17:41:02 +00:00
|
|
|
}
|
2004-03-09 01:37:56 +00:00
|
|
|
|
|
|
|
/* Check if the help parser started properly */
|
2006-04-26 09:13:47 +00:00
|
|
|
procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp");
|
2004-03-09 01:37:56 +00:00
|
|
|
|
2006-03-31 17:42:13 +00:00
|
|
|
if (procedure)
|
2004-03-09 01:37:56 +00:00
|
|
|
{
|
2012-05-04 00:50:23 +02:00
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GError *error = NULL;
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2007-11-16 18:56:10 +00:00
|
|
|
GIMP_LOG (HELP, "Calling help via %s: %s %s %s",
|
|
|
|
procedure_name,
|
|
|
|
help_domain ? help_domain : "(null)",
|
|
|
|
help_locales ? help_locales : "(null)",
|
|
|
|
help_id ? help_id : "(null)");
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2007-10-09 08:04:31 +00:00
|
|
|
return_vals =
|
|
|
|
gimp_pdb_execute_procedure_by_name (gimp->pdb,
|
|
|
|
gimp_get_user_context (gimp),
|
2008-06-10 09:54:54 +00:00
|
|
|
progress, &error,
|
2007-10-09 08:04:31 +00:00
|
|
|
"extension-gimp-help-temp",
|
|
|
|
G_TYPE_STRING, procedure_name,
|
|
|
|
G_TYPE_STRING, help_domain,
|
|
|
|
G_TYPE_STRING, help_locales,
|
|
|
|
G_TYPE_STRING, help_id,
|
|
|
|
G_TYPE_NONE);
|
1999-12-19 17:15:11 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
gimp_value_array_unref (return_vals);
|
2007-12-02 18:05:54 +00:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
2004-03-09 01:37:56 +00:00
|
|
|
}
|
1999-11-20 12:12:41 +00:00
|
|
|
}
|
2004-09-13 12:19:34 +00:00
|
|
|
|
2020-12-23 21:15:43 +01:00
|
|
|
static void
|
2008-06-12 20:14:44 +00:00
|
|
|
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);
|
|
|
|
|
2020-12-23 21:15:43 +01:00
|
|
|
*domain_names = g_new0 (gchar *, n_domains + 2);
|
|
|
|
*domain_uris = g_new0 (gchar *, n_domains + 2);
|
2008-06-12 20:14:44 +00:00
|
|
|
|
2018-07-14 14:13:22 +02:00
|
|
|
(*domain_names)[0] = g_strdup ("https://www.gimp.org/help");
|
2008-10-02 17:16:14 +00:00
|
|
|
(*domain_uris)[0] = gimp_help_get_default_domain_uri (gimp);
|
2008-06-12 20:14:44 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n_domains; i++)
|
|
|
|
{
|
2008-10-02 17:16:14 +00:00
|
|
|
(*domain_names)[i + 1] = plug_in_domains[i];
|
|
|
|
(*domain_uris)[i + 1] = plug_in_uris[i];
|
2008-06-12 20:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (plug_in_domains);
|
|
|
|
g_free (plug_in_uris);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gimp_help_get_default_domain_uri (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
|
2014-07-29 13:04:16 +02:00
|
|
|
GFile *dir;
|
2008-06-12 20:14:44 +00:00
|
|
|
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);
|
|
|
|
|
2008-07-05 12:01:00 +00:00
|
|
|
dir = gimp_help_get_user_manual_basedir ();
|
2014-07-29 13:04:16 +02:00
|
|
|
uri = g_file_get_uri (dir);
|
|
|
|
g_object_unref (dir);
|
2008-06-12 20:14:44 +00:00
|
|
|
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
2004-09-13 12:19:34 +00:00
|
|
|
static gchar *
|
2008-06-12 20:14:44 +00:00
|
|
|
gimp_help_get_locales (Gimp *gimp)
|
2004-09-13 12:19:34 +00:00
|
|
|
{
|
2017-02-01 03:10:13 +01:00
|
|
|
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
|
|
|
|
gchar **names;
|
|
|
|
gchar *locales = NULL;
|
|
|
|
GList *locales_list = NULL;
|
|
|
|
GList *iter;
|
|
|
|
gint i;
|
2008-06-12 20:14:44 +00:00
|
|
|
|
2004-09-13 12:19:34 +00:00
|
|
|
if (config->help_locales && strlen (config->help_locales))
|
|
|
|
return g_strdup (config->help_locales);
|
|
|
|
|
2017-02-01 03:10:13 +01:00
|
|
|
/* Process locales. */
|
|
|
|
names = (gchar **) g_get_language_names ();
|
|
|
|
for (i = 0; names[i]; i++)
|
|
|
|
{
|
|
|
|
gchar *locale = g_strdup (names[i]);
|
|
|
|
gchar *c;
|
|
|
|
|
|
|
|
/* We don't care about encoding in context of our help system. */
|
|
|
|
c = strchr (locale, '.');
|
|
|
|
if (c)
|
|
|
|
*c = '\0';
|
2017-04-21 19:59:35 -03:00
|
|
|
|
|
|
|
/* We don't care about variants either. */
|
2017-02-01 03:10:13 +01:00
|
|
|
c = strchr (locale, '@');
|
|
|
|
if (c)
|
|
|
|
*c = '\0';
|
2017-04-21 19:59:35 -03:00
|
|
|
|
2017-02-01 03:10:13 +01:00
|
|
|
/* Apparently some systems (i.e. Windows) would return a value as
|
|
|
|
* IETF language tag, which is a different format from POSIX
|
|
|
|
* locale; especially it would separate the lang and the region
|
|
|
|
* with an hyphen instead of an underscore.
|
|
|
|
* Actually the difference is much deeper, and IETF language tags
|
|
|
|
* can have extended language subtags, a script subtag, variants,
|
|
|
|
* moreover using different codes.
|
|
|
|
* We'd actually need to look into this in details (TODO).
|
|
|
|
* this dirty hack should do for easy translation at least (like
|
|
|
|
* "en-GB" -> "en_GB).
|
|
|
|
* Cf. bug 777754.
|
|
|
|
*/
|
|
|
|
c = strchr (locale, '-');
|
|
|
|
if (c)
|
|
|
|
*c = '_';
|
2017-04-21 19:59:35 -03:00
|
|
|
|
2017-02-01 03:10:13 +01:00
|
|
|
if (locale && *locale &&
|
|
|
|
! g_list_find_custom (locales_list, locale,
|
|
|
|
(GCompareFunc) g_strcmp0))
|
|
|
|
{
|
|
|
|
gchar *base;
|
|
|
|
|
|
|
|
/* Adding this locale. */
|
|
|
|
locales_list = g_list_prepend (locales_list, locale);
|
|
|
|
|
|
|
|
/* Adding the base language as well. */
|
|
|
|
base = strdup (locale);
|
|
|
|
c = strchr (base, '_');
|
|
|
|
if (c)
|
|
|
|
*c = '\0';
|
2017-04-21 19:59:35 -03:00
|
|
|
|
2017-02-01 03:10:13 +01:00
|
|
|
if (base && *base &&
|
|
|
|
! g_list_find_custom (locales_list, base,
|
|
|
|
(GCompareFunc) g_strcmp0))
|
|
|
|
{
|
|
|
|
locales_list = g_list_prepend (locales_list, base);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_free (base);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_free (locale);
|
|
|
|
}
|
|
|
|
}
|
2017-04-21 19:59:35 -03:00
|
|
|
|
2017-02-01 03:10:13 +01:00
|
|
|
locales_list = g_list_reverse (locales_list);
|
|
|
|
|
|
|
|
/* Finally generate the colon-separated value. */
|
|
|
|
if (locales_list)
|
|
|
|
{
|
|
|
|
locales = g_strdup (locales_list->data);
|
|
|
|
for (iter = locales_list->next; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
gchar *temp = locales;
|
|
|
|
locales = g_strconcat (temp, ":", iter->data, NULL);
|
|
|
|
g_free (temp);
|
|
|
|
}
|
|
|
|
}
|
2017-04-21 19:59:35 -03:00
|
|
|
|
2017-02-01 03:10:13 +01:00
|
|
|
g_list_free_full (locales_list, g_free);
|
|
|
|
|
|
|
|
return locales;
|
2004-09-13 12:19:34 +00:00
|
|
|
}
|
2008-07-05 12:01:00 +00:00
|
|
|
|
2014-07-29 13:04:16 +02:00
|
|
|
static GFile *
|
2008-07-05 12:01:00 +00:00
|
|
|
gimp_help_get_user_manual_basedir (void)
|
|
|
|
{
|
2014-07-29 13:04:16 +02:00
|
|
|
return gimp_data_directory_file ("help", NULL);
|
2008-07-05 12:01:00 +00:00
|
|
|
}
|
2008-07-06 17:47:24 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_help_query_online_response (GtkWidget *dialog,
|
|
|
|
gint response,
|
|
|
|
GimpIdleHelp *idle_help)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
|
|
|
g_object_set (idle_help->gimp->config,
|
|
|
|
"user-manual-online", TRUE,
|
|
|
|
NULL);
|
2017-09-25 22:59:50 +02:00
|
|
|
}
|
|
|
|
if (response != GTK_RESPONSE_YES)
|
|
|
|
{
|
|
|
|
g_object_set (idle_help->gimp->config,
|
|
|
|
"help-locales", "",
|
|
|
|
NULL);
|
|
|
|
}
|
2008-07-06 17:47:24 +00:00
|
|
|
|
2017-09-25 22:59:50 +02:00
|
|
|
if (response == GTK_RESPONSE_ACCEPT ||
|
|
|
|
response == GTK_RESPONSE_YES)
|
|
|
|
{
|
2008-07-06 17:47:24 +00:00
|
|
|
gimp_help_show (idle_help->gimp,
|
|
|
|
idle_help->progress,
|
|
|
|
idle_help->help_domain,
|
|
|
|
idle_help->help_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_idle_help_free (idle_help);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-25 22:59:50 +02:00
|
|
|
gimp_help_query_alt_user_manual (GimpIdleHelp *idle_help)
|
2008-07-06 17:47:24 +00:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2017-09-25 22:59:50 +02:00
|
|
|
GList *manuals;
|
2008-07-06 17:47:24 +00:00
|
|
|
|
|
|
|
dialog = gimp_message_dialog_new (_("GIMP user manual is missing"),
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_HELP_USER_MANUAL,
|
2008-07-06 17:47:24 +00:00
|
|
|
NULL, 0, NULL, NULL,
|
2017-09-25 22:59:50 +02:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
2017-02-12 16:06:34 +01:00
|
|
|
NULL);
|
2017-09-25 22:59:50 +02:00
|
|
|
idle_help->query_dialog = GTK_DIALOG (dialog);
|
2008-07-06 17:47:24 +00:00
|
|
|
|
|
|
|
if (idle_help->progress)
|
app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:
In core:
- get_window_id() virtual function in core GimpProgress is changed to
return a GBytes, as a generic "data" to represent a window differently
on different systems.
- All implementations of get_window_id() in various classes implementing
this interface are updated accordingly:
* GimpSubProgress
* GimpDisplay returns the handle of its shell.
* GimpDisplayShell now creates its window handle at construction with
libgimpwidget's gimp_widget_set_native_handle() and simply return
this handle every time it's requested.
* GimpFileDialog also creates its window handle at construction with
gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
GimpProgress as argument (instead of a guint32 ID), requests and
process the ID itself, according to the running platform. In
particular, the following were improved:
* Unlike old code, it will work even if the window is not visible yet.
In such a case, the function simply adds a signal handler to set
transient at mapping. It makes it easier to use it at construction
in a reliable way.
* It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.
PDB/libgimp:
- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
now return a GBytes to represent a window handle in an opaque way
(depending on the running platform).
In libgimp:
- GimpProgress's get_window() virtual function changed to return a
GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
get_window_handle(). It creates its handle at object construction with
libgimpwidget's gimp_widget_set_native_handle() and the virtual
method's implementation simply returns the GBytes.
In libgimpUi:
- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
removed. We should not assume anymore that it is possible to create a
GdkWindow to be used. For instance this is not possible with Wayland
which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
gimp_window_set_transient() now use an internal implementation similar
to core gimp_window_set_transient_for(), with the same improvements
(works even at construction when the window is not visible yet + works
for Wayland too).
In libgimpwidgets:
- New gimp_widget_set_native_handle() is a helper function used both in
core and libgimp* libraries for widgets which we want to be usable as
possible parents. It takes care of getting the relevant window handle
(depending on the running platform) and stores it in a given pointer,
either immediately or after a callback once the widget is mapped. So
it can be used at construction. Also it sets a handle for X11 or
Wayland.
In plug-ins:
- Screenshot uses the new gimp_progress_get_window_handle() directly now
in its X11 code path and creates out of it a GdkWindows itself with
gdk_x11_window_foreign_new_for_display().
Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.
There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(
Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-08-14 14:23:06 +02:00
|
|
|
gimp_window_set_transient_for (GTK_WINDOW (dialog), idle_help->progress);
|
2008-07-06 17:47:24 +00:00
|
|
|
|
2017-09-25 22:59:50 +02:00
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("The GIMP user manual is not installed "
|
|
|
|
"in your language."));
|
|
|
|
|
|
|
|
/* Add a list of available manuals instead, if any. */
|
2017-10-03 01:52:35 +02:00
|
|
|
manuals = gimp_help_get_installed_languages ();
|
2017-09-25 22:59:50 +02:00
|
|
|
if (manuals != NULL)
|
|
|
|
{
|
2017-10-03 01:52:35 +02:00
|
|
|
GtkWidget *lang_combo;
|
|
|
|
|
2017-09-25 22:59:50 +02:00
|
|
|
/* Add an additional button. */
|
|
|
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
|
|
|
_("Read Selected _Language"),
|
|
|
|
GTK_RESPONSE_YES);
|
|
|
|
/* And a dropdown list of available manuals. */
|
2017-10-03 20:47:06 +02:00
|
|
|
lang_combo = gimp_language_combo_box_new (TRUE,
|
|
|
|
_("Available manuals..."));
|
2017-09-25 22:59:50 +02:00
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (lang_combo), 0);
|
|
|
|
gtk_dialog_set_response_sensitive (idle_help->query_dialog,
|
|
|
|
GTK_RESPONSE_YES, FALSE);
|
|
|
|
g_signal_connect (lang_combo, "changed",
|
|
|
|
G_CALLBACK (gimp_help_language_combo_changed),
|
|
|
|
idle_help);
|
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
lang_combo, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (lang_combo);
|
|
|
|
|
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("You may either select a manual in another "
|
|
|
|
"language or read the online version."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("You may either install the additional help "
|
|
|
|
"package or change your preferences to use "
|
|
|
|
"the online version."));
|
|
|
|
}
|
|
|
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
|
|
|
_("Read _Online"), GTK_RESPONSE_ACCEPT);
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
|
|
|
if (manuals != NULL)
|
|
|
|
{
|
2018-05-10 17:04:37 +02:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2017-09-25 22:59:50 +02:00
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
GTK_RESPONSE_YES,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
g_list_free_full (manuals, g_free);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-10 17:04:37 +02:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2017-09-25 22:59:50 +02:00
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
}
|
2008-07-06 17:47:24 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (gimp_help_query_online_response),
|
|
|
|
idle_help);
|
2017-09-25 22:59:50 +02:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
2008-07-06 17:47:24 +00:00
|
|
|
|
2017-09-25 22:59:50 +02:00
|
|
|
static void
|
|
|
|
gimp_help_language_combo_changed (GtkComboBox *combo,
|
|
|
|
GimpIdleHelp *idle_help)
|
|
|
|
{
|
2017-10-03 01:52:35 +02:00
|
|
|
gchar *help_locales = NULL;
|
|
|
|
gchar *code;
|
2017-09-25 22:59:50 +02:00
|
|
|
|
2017-10-03 01:52:35 +02:00
|
|
|
code = gimp_language_combo_box_get_code (GIMP_LANGUAGE_COMBO_BOX (combo));
|
|
|
|
if (code && g_strcmp0 ("", code) != 0)
|
2017-09-25 22:59:50 +02:00
|
|
|
{
|
2017-10-03 01:52:35 +02:00
|
|
|
help_locales = g_strdup_printf ("%s:", code);
|
2017-09-25 22:59:50 +02:00
|
|
|
gtk_dialog_set_response_sensitive (idle_help->query_dialog,
|
|
|
|
GTK_RESPONSE_YES, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_dialog_set_response_sensitive (idle_help->query_dialog,
|
|
|
|
GTK_RESPONSE_YES, FALSE);
|
|
|
|
}
|
2017-10-03 01:52:35 +02:00
|
|
|
g_object_set (idle_help->gimp->config,
|
|
|
|
"help-locales", help_locales? help_locales : "",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_free (code);
|
|
|
|
if (help_locales)
|
|
|
|
g_free (help_locales);
|
2008-07-06 17:47:24 +00:00
|
|
|
}
|