~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimphelp.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimphelp.c
35
35
 
36
36
#include "core/gimp.h"
37
37
#include "core/gimp-utils.h"
38
 
 
39
 
#include "pdb/procedural_db.h"
40
 
 
41
 
#include "plug-in/plug-ins.h"
42
 
#include "plug-in/plug-in-run.h"
 
38
#include "core/gimpparamspecs.h"
 
39
 
 
40
#include "pdb/gimppdb.h"
 
41
#include "pdb/gimpprocedure.h"
 
42
 
 
43
#include "plug-in/gimppluginmanager-help-domain.h"
43
44
 
44
45
#include "gimphelp.h"
45
46
#include "gimphelp-ids.h"
74
75
                                          const gchar   *text);
75
76
 
76
77
static void      gimp_help_call          (Gimp          *gimp,
77
 
                                          const gchar   *procedure,
 
78
                                          const gchar   *procedure_name,
78
79
                                          const gchar   *help_domain,
79
80
                                          const gchar   *help_locales,
80
81
                                          const gchar   *help_id);
101
102
      idle_help->gimp = gimp;
102
103
 
103
104
      if (help_domain && strlen (help_domain))
104
 
        idle_help->help_domain = g_strdup (help_domain);
 
105
        idle_help->help_domain = g_strdup (help_domain);
105
106
 
106
107
      idle_help->help_locales = gimp_help_get_locales (config);
107
108
 
108
109
      if (help_id && strlen (help_id))
109
 
        idle_help->help_id = g_strdup (help_id);
 
110
        idle_help->help_id = g_strdup (help_id);
110
111
 
111
112
      g_idle_add (gimp_idle_help, idle_help);
112
113
 
123
124
static gboolean
124
125
gimp_idle_help (gpointer data)
125
126
{
126
 
  GimpIdleHelp  *idle_help = data;
127
 
  GimpGuiConfig *config    = GIMP_GUI_CONFIG (idle_help->gimp->config);
128
 
  const gchar   *procedure = NULL;
 
127
  GimpIdleHelp  *idle_help      = data;
 
128
  GimpGuiConfig *config         = GIMP_GUI_CONFIG (idle_help->gimp->config);
 
129
  const gchar   *procedure_name = NULL;
129
130
 
130
131
#ifdef GIMP_HELP_DEBUG
131
132
  g_printerr ("Help Domain: %s\n",
137
138
  if (config->help_browser == GIMP_HELP_BROWSER_GIMP)
138
139
    {
139
140
      if (gimp_help_browser (idle_help->gimp))
140
 
        procedure = "extension_gimp_help_browser_temp";
 
141
        procedure_name = "extension-gimp-help-browser-temp";
141
142
    }
142
143
 
143
144
  if (config->help_browser == GIMP_HELP_BROWSER_WEB_BROWSER)
144
145
    {
145
146
      /*  FIXME: should check for procedure availability  */
146
 
      procedure = "plug_in_web_browser";
 
147
      procedure_name = "plug-in-web-browser";
147
148
    }
148
149
 
149
 
  if (procedure)
 
150
  if (procedure_name)
150
151
    gimp_help_call (idle_help->gimp,
151
 
                    procedure,
 
152
                    procedure_name,
152
153
                    idle_help->help_domain,
153
154
                    idle_help->help_locales,
154
155
                    idle_help->help_id);
165
166
gimp_help_browser (Gimp *gimp)
166
167
{
167
168
  static gboolean  busy = FALSE;
168
 
  ProcRecord      *proc_rec;
 
169
  GimpProcedure   *procedure;
169
170
 
170
171
  if (busy)
171
172
    return TRUE;
173
174
  busy = TRUE;
174
175
 
175
176
  /*  Check if a help browser is already running  */
176
 
  proc_rec = procedural_db_lookup (gimp, "extension_gimp_help_browser_temp");
 
177
  procedure = gimp_pdb_lookup_procedure (gimp->pdb,
 
178
                                         "extension-gimp-help-browser-temp");
177
179
 
178
 
  if (! proc_rec)
 
180
  if (! procedure)
179
181
    {
180
 
      Argument *args = NULL;
181
 
 
182
 
      proc_rec = procedural_db_lookup (gimp, "extension_gimp_help_browser");
183
 
 
184
 
      if (! proc_rec)
185
 
        {
 
182
      GValueArray *args          = NULL;
 
183
      gint          n_domains    = 0;
 
184
      gchar       **help_domains = NULL;
 
185
      gchar       **help_uris    = NULL;
 
186
 
 
187
      procedure = gimp_pdb_lookup_procedure (gimp->pdb,
 
188
                                             "extension-gimp-help-browser");
 
189
 
 
190
      if (! procedure)
 
191
        {
186
192
          gimp_help_browser_error (gimp,
187
193
                                   _("Help browser not found"),
188
194
                                   _("Could not find GIMP help browser."),
190
196
                                     "to be missing from your installation."));
191
197
          busy = FALSE;
192
198
 
193
 
          return FALSE;
194
 
        }
195
 
 
196
 
      args = g_new (Argument, 1);
197
 
 
198
 
      args[0].arg_type      = GIMP_PDB_INT32;
199
 
      args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
200
 
 
201
 
      plug_in_run (gimp, gimp_get_user_context (gimp), NULL,
202
 
                   proc_rec, args, 1, FALSE, TRUE, -1);
203
 
 
204
 
      procedural_db_destroy_args (args, 1);
 
199
          return FALSE;
 
200
        }
 
201
 
 
202
      n_domains = gimp_plug_in_manager_get_help_domains (gimp->plug_in_manager,
 
203
                                                         &help_domains,
 
204
                                                         &help_uris);
 
205
 
 
206
      args = gimp_procedure_get_arguments (procedure);
 
207
      gimp_value_array_truncate (args, 5);
 
208
 
 
209
      g_value_set_int             (&args->values[0], GIMP_RUN_INTERACTIVE);
 
210
      g_value_set_int             (&args->values[1], n_domains);
 
211
      gimp_value_take_stringarray (&args->values[2], help_domains, n_domains);
 
212
      g_value_set_int             (&args->values[3], n_domains);
 
213
      gimp_value_take_stringarray (&args->values[4], help_uris, n_domains);
 
214
 
 
215
      gimp_procedure_execute_async (procedure, gimp,
 
216
                                    gimp_get_user_context (gimp),
 
217
                                    NULL, args, NULL);
 
218
 
 
219
      g_value_array_free (args);
205
220
    }
206
221
 
207
222
  /*  Check if the help browser started properly  */
208
 
  proc_rec = procedural_db_lookup (gimp, "extension_gimp_help_browser_temp");
 
223
  procedure = gimp_pdb_lookup_procedure (gimp->pdb,
 
224
                                         "extension-gimp-help-browser-temp");
209
225
 
210
 
  if (! proc_rec)
 
226
  if (! procedure)
211
227
    {
212
228
      gimp_help_browser_error (gimp,
213
229
                               _("Help browser doesn't start"),
246
262
 
247
263
  if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK)
248
264
    g_object_set (gimp->config,
249
 
                  "help-browser", GIMP_HELP_BROWSER_WEB_BROWSER,
250
 
                  NULL);
 
265
                  "help-browser", GIMP_HELP_BROWSER_WEB_BROWSER,
 
266
                  NULL);
251
267
 
252
268
  gtk_widget_destroy (dialog);
253
269
}
254
270
 
255
271
static void
256
272
gimp_help_call (Gimp        *gimp,
257
 
                const gchar *procedure,
 
273
                const gchar *procedure_name,
258
274
                const gchar *help_domain,
259
275
                const gchar *help_locales,
260
276
                const gchar *help_id)
261
277
{
262
 
  ProcRecord *proc_rec;
 
278
  GimpProcedure *procedure;
 
279
 
 
280
  /*  Special case the help browser  */
 
281
  if (! strcmp (procedure_name, "extension-gimp-help-browser-temp"))
 
282
    {
 
283
      GValueArray *return_vals;
 
284
 
 
285
      return_vals = gimp_pdb_execute_procedure_by_name (gimp->pdb,
 
286
                                                        gimp_get_user_context (gimp),
 
287
                                                        NULL,
 
288
                                                        procedure_name,
 
289
                                                        G_TYPE_STRING, help_domain,
 
290
                                                        G_TYPE_STRING, help_locales,
 
291
                                                        G_TYPE_STRING, help_id,
 
292
                                                        G_TYPE_NONE);
 
293
 
 
294
      g_value_array_free (return_vals);
 
295
 
 
296
      return;
 
297
    }
263
298
 
264
299
  /*  Check if a help parser is already running  */
265
 
  proc_rec = procedural_db_lookup (gimp, "extension_gimp_help_temp");
 
300
  procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp");
266
301
 
267
 
  if (! proc_rec)
 
302
  if (! procedure)
268
303
    {
269
 
      Argument  *args         = NULL;
270
 
      gint       n_domains    = 0;
271
 
      gchar    **help_domains = NULL;
272
 
      gchar    **help_uris    = NULL;
273
 
 
274
 
      proc_rec = procedural_db_lookup (gimp, "extension_gimp_help");
275
 
 
276
 
      if (! proc_rec)
 
304
      GValueArray  *args         = NULL;
 
305
      gint          n_domains    = 0;
 
306
      gchar       **help_domains = NULL;
 
307
      gchar       **help_uris    = NULL;
 
308
 
 
309
      procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help");
 
310
 
 
311
      if (! procedure)
277
312
        /*  FIXME: error msg  */
278
313
        return;
279
314
 
280
 
      n_domains = plug_ins_help_domains (gimp, &help_domains, &help_uris);
281
 
 
282
 
      args = g_new (Argument, 4);
283
 
 
284
 
      args[0].arg_type          = GIMP_PDB_INT32;
285
 
      args[0].value.pdb_int     = n_domains;
286
 
      args[1].arg_type          = GIMP_PDB_STRINGARRAY;
287
 
      args[1].value.pdb_pointer = help_domains;
288
 
      args[2].arg_type          = GIMP_PDB_INT32;
289
 
      args[2].value.pdb_int     = n_domains;
290
 
      args[3].arg_type          = GIMP_PDB_STRINGARRAY;
291
 
      args[3].value.pdb_pointer = help_uris;
292
 
 
293
 
      plug_in_run (gimp, gimp_get_user_context (gimp), NULL,
294
 
                   proc_rec, args, 4, FALSE, TRUE, -1);
295
 
 
296
 
      procedural_db_destroy_args (args, 4);
 
315
      n_domains = gimp_plug_in_manager_get_help_domains (gimp->plug_in_manager,
 
316
                                                         &help_domains,
 
317
                                                         &help_uris);
 
318
 
 
319
      args = gimp_procedure_get_arguments (procedure);
 
320
      gimp_value_array_truncate (args, 4);
 
321
 
 
322
      g_value_set_int             (&args->values[0], n_domains);
 
323
      gimp_value_take_stringarray (&args->values[1], help_domains, n_domains);
 
324
      g_value_set_int             (&args->values[2], n_domains);
 
325
      gimp_value_take_stringarray (&args->values[3], help_uris, n_domains);
 
326
 
 
327
      gimp_procedure_execute_async (procedure, gimp,
 
328
                                    gimp_get_user_context (gimp),
 
329
                                    NULL, args, NULL);
 
330
 
 
331
      g_value_array_free (args);
297
332
    }
298
333
 
299
334
  /*  Check if the help parser started properly  */
300
 
  proc_rec = procedural_db_lookup (gimp, "extension_gimp_help_temp");
 
335
  procedure = gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-temp");
301
336
 
302
 
  if (proc_rec)
 
337
  if (procedure)
303
338
    {
304
 
      Argument *return_vals;
305
 
      gint      n_return_vals;
 
339
      GValueArray *return_vals;
306
340
 
307
341
#ifdef GIMP_HELP_DEBUG
308
342
      g_printerr ("Calling help via %s: %s %s %s\n",
309
 
                  procedure,
 
343
                  procedure_name,
310
344
                  help_domain  ? help_domain  : "(null)",
311
345
                  help_locales ? help_locales : "(null)",
312
346
                  help_id      ? help_id      : "(null)");
313
347
#endif
314
348
 
315
 
      return_vals =
316
 
        procedural_db_run_proc (gimp,
317
 
                                gimp_get_user_context (gimp),
318
 
                                NULL,
319
 
                                "extension_gimp_help_temp",
320
 
                                &n_return_vals,
321
 
                                GIMP_PDB_STRING, procedure,
322
 
                                GIMP_PDB_STRING, help_domain,
323
 
                                GIMP_PDB_STRING, help_locales,
324
 
                                GIMP_PDB_STRING, help_id,
325
 
                                GIMP_PDB_END);
 
349
      return_vals = gimp_pdb_execute_procedure_by_name (gimp->pdb,
 
350
                                                        gimp_get_user_context (gimp),
 
351
                                                        NULL,
 
352
                                                        "extension-gimp-help-temp",
 
353
                                                        G_TYPE_STRING, procedure_name,
 
354
                                                        G_TYPE_STRING, help_domain,
 
355
                                                        G_TYPE_STRING, help_locales,
 
356
                                                        G_TYPE_STRING, help_id,
 
357
                                                        G_TYPE_NONE);
326
358
 
327
 
      procedural_db_destroy_args (return_vals, n_return_vals);
 
359
      g_value_array_free (return_vals);
328
360
    }
329
361
}
330
362
 
331
363
static gchar *
332
364
gimp_help_get_locales (GimpGuiConfig *config)
333
365
{
334
 
  const gchar *language;
335
 
  gchar       *locale;
336
 
 
337
366
  if (config->help_locales && strlen (config->help_locales))
338
367
    return g_strdup (config->help_locales);
339
368
 
340
 
  locale = gimp_get_default_language ("LC_MESSAGES");
341
 
 
342
 
  /*  Simulate the behaviour of GNU gettext() and look
343
 
   *  at LANGUAGE if the locale is not the "C" locale.
344
 
   */
345
 
  language = g_getenv ("LANGUAGE");
346
 
  if (language && (locale == NULL || strcmp (locale, "C")))
347
 
    {
348
 
      g_free (locale);
349
 
      locale = g_strdup (language);
350
 
    }
351
 
 
352
 
  return locale;
 
369
  return g_strjoinv (":", (gchar **) g_get_language_names ());
353
370
}
354
371