dialogs.c 20.3 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
4 5 6
 * dialogs.c
 * Copyright (C) 2010 Martin Nordholts <martinn@src.gnome.org>
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 3 of the License, or
10 11 12 13 14 15 16 17
 * (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
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 20 21 22 23 24
 */

#include "config.h"

#include <gtk/gtk.h>

25 26
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
27 28
#include "libgimpwidgets/gimpwidgets.h"

29
#include "dialogs-types.h"
30

Michael Natterer's avatar
Michael Natterer committed
31
#include "core/gimp.h"
32
#include "core/gimpcontext.h"
33
#include "core/gimplist.h"
34

35
#include "widgets/gimpdialogfactory.h"
36
#include "widgets/gimpdockwindow.h"
37
#include "widgets/gimphelp-ids.h"
38
#include "widgets/gimpmenufactory.h"
39
#include "widgets/gimpsessioninfo.h"
40
#include "widgets/gimptoolbox.h"
41

42 43 44
#include "dialogs.h"
#include "dialogs-constructors.h"

45 46
#include "gimp-intl.h"

47

48
GimpContainer *global_recent_docks = NULL;
49

50

51
#define FOREIGN(id, singleton, remember_size) \
52 53 54 55 56 57 58 59 60 61 62
  { id             /* identifier       */, \
    NULL           /* name             */, \
    NULL           /* blurb            */, \
    NULL           /* stock_id         */, \
    NULL           /* help_id          */, \
    NULL           /* new_func         */, \
    0              /* view_size        */, \
    singleton      /* singleton        */, \
    TRUE           /* session_managed  */, \
    remember_size  /* remember_size    */, \
    FALSE          /* remember_if_open */, \
63
    TRUE           /* hideable         */, \
64
    FALSE          /* dockable         */}
65

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#define FOREIGN_NOT_HIDEABLE(id, singleton, remember_size) \
  { id             /* identifier       */, \
    NULL           /* name             */, \
    NULL           /* blurb            */, \
    NULL           /* stock_id         */, \
    NULL           /* help_id          */, \
    NULL           /* new_func         */, \
    0              /* view_size        */, \
    singleton      /* singleton        */, \
    TRUE           /* session_managed  */, \
    remember_size  /* remember_size    */, \
    FALSE          /* remember_if_open */, \
    FALSE          /* hideable         */, \
    FALSE          /* dockable         */}

81
#define TOPLEVEL(id, new_func, singleton, session_managed, remember_size) \
82 83 84 85 86 87 88 89 90 91 92
  { id               /* identifier       */, \
    NULL             /* name             */, \
    NULL             /* blurb            */, \
    NULL             /* stock_id         */, \
    NULL             /* help_id          */, \
    new_func         /* new_func         */, \
    0                /* view_size        */, \
    singleton        /* singleton        */, \
    session_managed  /* session_managed  */, \
    remember_size    /* remember_size    */, \
    FALSE            /* remember_if_open */, \
93
    TRUE             /* hideable         */, \
94 95 96 97 98 99 100 101 102 103 104 105 106 107
    FALSE            /* dockable         */}

#define DOCKABLE(id, name, blurb, stock_id, help_id, new_func, view_size, singleton) \
  { id         /* identifier       */, \
    name       /* name             */, \
    blurb      /* blurb            */, \
    stock_id   /* stock_id         */, \
    help_id    /* help_id          */, \
    new_func   /* new_func         */, \
    view_size  /* view_size        */, \
    singleton  /* singleton        */, \
    FALSE      /* session_managed  */, \
    FALSE      /* remember_size    */, \
    TRUE       /* remember_if_open */, \
108
    TRUE       /* hideable         */, \
109 110
    TRUE       /* dockable         */}

111 112 113 114 115 116 117 118 119 120 121 122
#define DOCK(id, new_func) \
  { id         /* identifier       */, \
    NULL       /* name             */, \
    NULL       /* blurb            */, \
    NULL       /* stock_id         */, \
    NULL       /* help_id          */, \
    new_func   /* new_func         */, \
    0          /* view_size        */, \
    FALSE      /* singleton        */, \
    FALSE      /* session_managed  */, \
    FALSE      /* remember_size    */, \
    FALSE      /* remember_if_open */, \
123
    TRUE       /* hideable         */, \
124 125
    FALSE      /* dockable         */}

126 127 128 129 130 131 132 133 134 135 136 137
#define DOCK_WINDOW(id, new_func) \
  { id         /* identifier       */, \
    NULL       /* name             */, \
    NULL       /* blurb            */, \
    NULL       /* stock_id         */, \
    NULL       /* help_id          */, \
    new_func   /* new_func         */, \
    0          /* view_size        */, \
    FALSE      /* singleton        */, \
    TRUE       /* session_managed  */, \
    TRUE       /* remember_size    */, \
    TRUE       /* remember_if_open */, \
138
    TRUE       /* hideable         */, \
139 140
    FALSE      /* dockable         */}

141 142 143 144 145 146 147 148 149 150 151 152
#define LISTGRID(id, name, blurb, stock_id, help_id, view_size) \
  { "gimp-"#id"-list"             /* identifier       */,  \
    name                          /* name             */,  \
    blurb                         /* blurb            */,  \
    stock_id                      /* stock_id         */,  \
    help_id                       /* help_id          */,  \
    dialogs_##id##_list_view_new  /* new_func         */,  \
    view_size                     /* view_size        */,  \
    FALSE                         /* singleton        */,  \
    FALSE                         /* session_managed  */,  \
    FALSE                         /* remember_size    */,  \
    TRUE                          /* remember_if_open */,  \
153
    TRUE                          /* hideable         */,  \
154 155 156 157 158 159 160 161 162 163 164 165
    TRUE                          /* dockable         */}, \
  { "gimp-"#id"-grid"             /* identifier       */,  \
    name                          /* name             */,  \
    blurb                         /* blurb            */,  \
    stock_id                      /* stock_id         */,  \
    help_id                       /* help_id          */,  \
    dialogs_##id##_grid_view_new  /* new_func         */,  \
    view_size                     /* view_size        */,  \
    FALSE                         /* singleton        */,  \
    FALSE                         /* session_managed  */,  \
    FALSE                         /* remember_size    */,  \
    TRUE                          /* remember_if_open */,  \
166
    TRUE                          /* hideable         */,  \
167 168 169 170 171 172 173 174 175 176 177 178 179 180
    TRUE                          /* dockable         */}

#define LIST(id, name, blurb, stock_id, help_id, view_size) \
  { "gimp-"#id"-list"             /* identifier       */, \
    name                          /* name             */, \
    blurb                         /* blurb            */, \
    stock_id                      /* stock_id         */, \
    help_id                       /* help_id          */, \
    dialogs_##id##_list_view_new  /* new_func         */, \
    view_size                     /* view_size        */, \
    FALSE                         /* singleton        */, \
    FALSE                         /* session_managed  */, \
    FALSE                         /* remember_size    */, \
    TRUE                          /* remember_if_open */, \
181
    TRUE                          /* hideable         */, \
182
    TRUE                          /* dockable         */}
183 184


185
static const GimpDialogFactoryEntry entries[] =
186
{
187
  /*  foreign toplevels without constructor  */
188
  FOREIGN ("gimp-brightness-contrast-tool-dialog", TRUE,  FALSE),
189
  FOREIGN ("gimp-color-balance-tool-dialog",       TRUE,  FALSE),
190 191 192 193
  FOREIGN ("gimp-color-picker-tool-dialog",        TRUE,  TRUE),
  FOREIGN ("gimp-colorize-tool-dialog",            TRUE,  FALSE),
  FOREIGN ("gimp-crop-tool-dialog",                TRUE,  FALSE),
  FOREIGN ("gimp-curves-tool-dialog",              TRUE,  TRUE),
194
  FOREIGN ("gimp-desaturate-tool-dialog",          TRUE,  FALSE),
195
  FOREIGN ("gimp-gegl-tool-dialog",                TRUE,  FALSE),
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
  FOREIGN ("gimp-hue-saturation-tool-dialog",      TRUE,  FALSE),
  FOREIGN ("gimp-levels-tool-dialog",              TRUE,  TRUE),
  FOREIGN ("gimp-measure-tool-dialog",             TRUE,  FALSE),
  FOREIGN ("gimp-posterize-tool-dialog",           TRUE,  FALSE),
  FOREIGN ("gimp-rotate-tool-dialog",              TRUE,  FALSE),
  FOREIGN ("gimp-scale-tool-dialog",               TRUE,  FALSE),
  FOREIGN ("gimp-shear-tool-dialog",               TRUE,  FALSE),
  FOREIGN ("gimp-text-tool-dialog",                TRUE,  TRUE),
  FOREIGN ("gimp-threshold-tool-dialog",           TRUE,  FALSE),
  FOREIGN ("gimp-perspective-tool-dialog",         TRUE,  FALSE),

  FOREIGN ("gimp-toolbox-color-dialog",            TRUE,  FALSE),
  FOREIGN ("gimp-gradient-editor-color-dialog",    TRUE,  FALSE),
  FOREIGN ("gimp-palette-editor-color-dialog",     TRUE,  FALSE),
  FOREIGN ("gimp-colormap-editor-color-dialog",    TRUE,  FALSE),

  FOREIGN ("gimp-controller-editor-dialog",        FALSE, TRUE),
  FOREIGN ("gimp-controller-action-dialog",        FALSE, TRUE),
214

215
  /*  ordinary toplevels  */
216 217 218 219 220 221 222 223
  TOPLEVEL ("gimp-image-new-dialog",
            dialogs_image_new_new,          FALSE, TRUE, FALSE),
  TOPLEVEL ("gimp-file-open-dialog",
            dialogs_file_open_new,          TRUE,  TRUE, TRUE),
  TOPLEVEL ("gimp-file-open-location-dialog",
            dialogs_file_open_location_new, FALSE, TRUE, FALSE),
  TOPLEVEL ("gimp-file-save-dialog",
            dialogs_file_save_new,          FALSE, TRUE, TRUE),
224 225
  TOPLEVEL ("gimp-file-export-dialog",
            dialogs_file_export_new,        FALSE, TRUE, TRUE),
226 227

  /*  singleton toplevels  */
228
  TOPLEVEL ("gimp-preferences-dialog",
229
            dialogs_preferences_get,        TRUE, TRUE,  FALSE),
230 231
  TOPLEVEL ("gimp-input-devices-dialog",
            dialogs_input_devices_get,      TRUE, TRUE,  FALSE),
232 233
  TOPLEVEL ("gimp-keyboard-shortcuts-dialog",
            dialogs_keyboard_shortcuts_get, TRUE, TRUE,  TRUE),
234
  TOPLEVEL ("gimp-module-dialog",
235
            dialogs_module_get,             TRUE, TRUE,  TRUE),
236 237
  TOPLEVEL ("gimp-palette-import-dialog",
            dialogs_palette_import_get,     TRUE, TRUE,  TRUE),
238
  TOPLEVEL ("gimp-tips-dialog",
239
            dialogs_tips_get,               TRUE, FALSE, FALSE),
240
  TOPLEVEL ("gimp-about-dialog",
241
            dialogs_about_get,              TRUE, FALSE, FALSE),
242
  TOPLEVEL ("gimp-error-dialog",
243
            dialogs_error_get,              TRUE, FALSE, FALSE),
244
  TOPLEVEL ("gimp-close-all-dialog",
245
            dialogs_close_all_get,          TRUE, FALSE, FALSE),
246
  TOPLEVEL ("gimp-quit-dialog",
247
            dialogs_quit_get,               TRUE, FALSE, FALSE),
248

249
  /*  docks  */
250 251 252 253 254
  DOCK ("gimp-dock",
        dialogs_dock_new),
  DOCK ("gimp-toolbox",
        dialogs_toolbox_new),

255 256 257 258 259 260
  /*  dock windows  */
  DOCK_WINDOW ("gimp-dock-window",
               dialogs_dock_window_new),
  DOCK_WINDOW ("gimp-toolbox-window",
               dialogs_toolbox_dock_window_new),

261
  /*  singleton dockables  */
262 263 264
  DOCKABLE ("gimp-tool-options",
            N_("Tool Options"), NULL, GIMP_STOCK_TOOL_OPTIONS,
            GIMP_HELP_TOOL_OPTIONS_DIALOG,
265
            dialogs_tool_options_new, 0, TRUE),
266 267 268
  DOCKABLE ("gimp-device-status",
            N_("Devices"), N_("Device Status"), GIMP_STOCK_DEVICE_STATUS,
            GIMP_HELP_DEVICE_STATUS_DIALOG,
269
            dialogs_device_status_new, 0, TRUE),
270 271 272
  DOCKABLE ("gimp-error-console",
            N_("Errors"), N_("Error Console"), GIMP_STOCK_WARNING,
            GIMP_HELP_ERRORS_DIALOG,
273 274
            dialogs_error_console_new, 0, TRUE),
  DOCKABLE ("gimp-cursor-view",
275 276
            N_("Pointer"), N_("Pointer Information"), GIMP_STOCK_CURSOR,
            GIMP_HELP_POINTER_INFO_DIALOG,
277
            dialogs_cursor_view_new, 0, TRUE),
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293

  /*  list & grid views  */
  LISTGRID (image, N_("Images"), NULL, GIMP_STOCK_IMAGES,
            GIMP_HELP_IMAGE_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
  LISTGRID (brush, N_("Brushes"), NULL, GIMP_STOCK_BRUSH,
            GIMP_HELP_BRUSH_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
  LISTGRID (pattern, N_("Patterns"), NULL, GIMP_STOCK_PATTERN,
            GIMP_HELP_PATTERN_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
  LISTGRID (gradient, N_("Gradients"), NULL, GIMP_STOCK_GRADIENT,
            GIMP_HELP_GRADIENT_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
  LISTGRID (palette, N_("Palettes"), NULL, GIMP_STOCK_PALETTE,
            GIMP_HELP_PALETTE_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
  LISTGRID (font, N_("Fonts"), NULL, GIMP_STOCK_FONT,
            GIMP_HELP_FONT_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
  LISTGRID (buffer, N_("Buffers"), NULL, GIMP_STOCK_BUFFER,
            GIMP_HELP_BUFFER_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
294
  LISTGRID (document, N_("History"), N_("Document History"), "document-open-recent",
295 296 297
            GIMP_HELP_DOCUMENT_DIALOG, GIMP_VIEW_SIZE_LARGE),
  LISTGRID (template, N_("Templates"), N_("Image Templates"), GIMP_STOCK_TEMPLATE,
            GIMP_HELP_TEMPLATE_DIALOG, GIMP_VIEW_SIZE_SMALL),
298

299
  /* Some things do not have grids, so just list */
300
  LIST (dynamics, N_("Paint Dynamics"), NULL, GIMP_STOCK_DYNAMICS,
301 302
        GIMP_HELP_DYNAMICS_DIALOG, GIMP_VIEW_SIZE_MEDIUM),

303
  /*  image related  */
304 305 306 307 308 309 310 311 312 313 314 315 316
  DOCKABLE ("gimp-layer-list",
            N_("Layers"), NULL, GIMP_STOCK_LAYERS,
            GIMP_HELP_LAYER_DIALOG,
            dialogs_layer_list_view_new, 0, FALSE),
  DOCKABLE ("gimp-channel-list",
            N_("Channels"), NULL, GIMP_STOCK_CHANNELS,
            GIMP_HELP_CHANNEL_DIALOG,
            dialogs_channel_list_view_new, 0, FALSE),
  DOCKABLE ("gimp-vectors-list",
            N_("Paths"), NULL, GIMP_STOCK_PATHS,
            GIMP_HELP_PATH_DIALOG,
            dialogs_vectors_list_view_new, 0, FALSE),
  DOCKABLE ("gimp-indexed-palette",
317
            N_("Colormap"), NULL, GIMP_STOCK_COLORMAP,
318 319 320 321 322 323 324 325 326 327 328 329 330 331
            GIMP_HELP_INDEXED_PALETTE_DIALOG,
            dialogs_colormap_editor_new, 0, FALSE),
  DOCKABLE ("gimp-histogram-editor",
            N_("Histogram"), NULL, GIMP_STOCK_HISTOGRAM,
            GIMP_HELP_HISTOGRAM_DIALOG,
            dialogs_histogram_editor_new, 0, FALSE),
  DOCKABLE ("gimp-selection-editor",
            N_("Selection"), N_("Selection Editor"), GIMP_STOCK_SELECTION,
            GIMP_HELP_SELECTION_DIALOG,
            dialogs_selection_editor_new, 0, FALSE),
  DOCKABLE ("gimp-undo-history",
            N_("Undo"), N_("Undo History"), GIMP_STOCK_UNDO_HISTORY,
            GIMP_HELP_UNDO_DIALOG,
            dialogs_undo_editor_new, 0, FALSE),
332 333 334 335
  DOCKABLE ("gimp-sample-point-editor",
            N_("Sample Points"), N_("Sample Points"), GIMP_STOCK_SAMPLE_POINT,
            GIMP_HELP_SAMPLE_POINT_DIALOG,
            dialogs_sample_point_editor_new, 0, FALSE),
336

337
  /*  display related  */
338 339 340 341
  DOCKABLE ("gimp-navigation-view",
            N_("Navigation"), N_("Display Navigation"), GIMP_STOCK_NAVIGATION,
            GIMP_HELP_NAVIGATION_DIALOG,
            dialogs_navigation_editor_new, 0, FALSE),
342

343
  /*  editors  */
344 345 346 347
  DOCKABLE ("gimp-color-editor",
            N_("FG/BG"), N_("FG/BG Color"), GIMP_STOCK_DEFAULT_COLORS,
            GIMP_HELP_COLOR_DIALOG,
            dialogs_color_editor_new, 0, FALSE),
348

349
  /*  singleton editors  */
350 351 352 353
  DOCKABLE ("gimp-brush-editor",
            N_("Brush Editor"), NULL, GIMP_STOCK_BRUSH,
            GIMP_HELP_BRUSH_EDITOR_DIALOG,
            dialogs_brush_editor_get, 0, TRUE),
354
  DOCKABLE ("gimp-dynamics-editor",
355
            N_("Paint Dynamics Editor"), NULL, GIMP_STOCK_DYNAMICS,
356 357
            GIMP_HELP_DYNAMICS_EDITOR_DIALOG,
            dialogs_dynamics_editor_get, 0, TRUE),
358 359 360 361 362 363 364
  DOCKABLE ("gimp-gradient-editor",
            N_("Gradient Editor"), NULL, GIMP_STOCK_GRADIENT,
            GIMP_HELP_GRADIENT_EDITOR_DIALOG,
            dialogs_gradient_editor_get, 0, TRUE),
  DOCKABLE ("gimp-palette-editor",
            N_("Palette Editor"), NULL, GIMP_STOCK_PALETTE,
            GIMP_HELP_PALETTE_EDITOR_DIALOG,
365 366 367 368 369
            dialogs_palette_editor_get, 0, TRUE),

  /*  emtpy image window  */
  FOREIGN_NOT_HIDEABLE ("gimp-empty-image-window",
                        TRUE, TRUE)
370 371 372 373 374
};


/*  public functions  */

375
void
376 377
dialogs_init (Gimp            *gimp,
              GimpMenuFactory *menu_factory)
378
{
379 380
  GimpDialogFactory *factory = NULL;
  gint               i       = 0;
381

382
  g_return_if_fail (GIMP_IS_GIMP (gimp));
383
  g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
384

385 386 387 388
  factory = gimp_dialog_factory_new ("toplevel",
                                     gimp_get_user_context (gimp),
                                     menu_factory);
  gimp_dialog_factory_set_singleton (factory);
389

390
  for (i = 0; i < G_N_ELEMENTS (entries); i++)
391
    gimp_dialog_factory_register_entry (gimp_dialog_factory_get_singleton (),
392 393 394 395 396 397 398 399 400 401 402
                                        entries[i].identifier,
                                        gettext (entries[i].name),
                                        gettext (entries[i].blurb),
                                        entries[i].stock_id,
                                        entries[i].help_id,
                                        entries[i].new_func,
                                        entries[i].view_size,
                                        entries[i].singleton,
                                        entries[i].session_managed,
                                        entries[i].remember_size,
                                        entries[i].remember_if_open,
403
                                        entries[i].hideable,
404
                                        entries[i].dockable);
405

406
  global_recent_docks = gimp_list_new (GIMP_TYPE_SESSION_INFO, FALSE);
407
}
408 409

void
Michael Natterer's avatar
Michael Natterer committed
410
dialogs_exit (Gimp *gimp)
411
{
412 413
  g_return_if_fail (GIMP_IS_GIMP (gimp));

414
  if (gimp_dialog_factory_get_singleton ())
415
    {
416 417
      g_object_unref (gimp_dialog_factory_get_singleton ());
      gimp_dialog_factory_set_singleton (NULL);
418 419
    }

420 421 422 423 424 425 426
  if (global_recent_docks)
    {
      g_object_unref (global_recent_docks);
      global_recent_docks = NULL;
    }
}

427 428 429 430 431 432 433 434 435 436
static void
dialogs_ensure_factory_entry_on_recent_dock (GimpSessionInfo *info)
{
  if (! gimp_session_info_get_factory_entry (info))
    {
      GimpDialogFactoryEntry *entry = NULL;

      /* The recent docks container only contains session infos for
       * dock windows
       */
437
      entry = gimp_dialog_factory_find_entry (gimp_dialog_factory_get_singleton (),
438 439 440 441 442 443
                                              "gimp-dock-window");

      gimp_session_info_set_factory_entry (info, entry);
    }
}

444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
void
dialogs_load_recent_docks (Gimp *gimp)
{
  gchar  *filename;
  GError *error = NULL;

  g_return_if_fail (GIMP_IS_GIMP (gimp));

  filename = gimp_personal_rc_file ("dockrc");

  if (gimp->be_verbose)
    g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));

  if (! gimp_config_deserialize_file (GIMP_CONFIG (global_recent_docks),
                                      filename,
                                      NULL, &error))
    {
      if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
462
        gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
463 464 465 466

      g_clear_error (&error);
    }

467 468 469 470 471 472 473
  /* In GIMP 2.6 dockrc did not contain the factory entries for the
   * session infos, so set that up manually if needed
   */
  gimp_container_foreach (global_recent_docks,
                          (GFunc) dialogs_ensure_factory_entry_on_recent_dock,
                          NULL);

474 475
  gimp_list_reverse (GIMP_LIST (global_recent_docks));

476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
  g_free (filename);
}

void
dialogs_save_recent_docks (Gimp *gimp)
{
  gchar  *filename;
  GError *error = NULL;

  g_return_if_fail (GIMP_IS_GIMP (gimp));

  filename = gimp_personal_rc_file ("dockrc");

  if (gimp->be_verbose)
    g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));

  if (! gimp_config_serialize_to_file (GIMP_CONFIG (global_recent_docks),
                                       filename,
                                       "recently closed docks",
                                       "end of recently closed docks",
                                       NULL, &error))
    {
498
      gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
499 500 501 502
      g_clear_error (&error);
    }

  g_free (filename);
503
}
504 505 506 507 508 509

GtkWidget *
dialogs_get_toolbox (void)
{
  GList *list;

510
  g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (gimp_dialog_factory_get_singleton ()), NULL);
511

512
  for (list = gimp_dialog_factory_get_open_dialogs (gimp_dialog_factory_get_singleton ());
513 514 515
       list;
       list = g_list_next (list))
    {
516 517
      if (GIMP_IS_DOCK_WINDOW (list->data) &&
          gimp_dock_window_has_toolbox (list->data))
518 519 520 521 522
        return list->data;
    }

  return NULL;
}