dialogs.c 21.1 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
    TRUE                          /* dockable         */}

Alexia Death's avatar
Alexia Death committed
169
#define LIST(id, new_func, name, blurb, stock_id, help_id, view_size) \
170 171 172 173 174
  { "gimp-"#id"-list"                   /* identifier       */, \
    name                                /* name             */, \
    blurb                               /* blurb            */, \
    stock_id                            /* stock_id         */, \
    help_id                             /* help_id          */, \
Alexia Death's avatar
Alexia Death committed
175
    dialogs_##new_func##_list_view_new  /* new_func         */, \
176 177 178 179 180 181 182
    view_size                           /* view_size        */, \
    FALSE                               /* singleton        */, \
    FALSE                               /* session_managed  */, \
    FALSE                               /* remember_size    */, \
    TRUE                                /* remember_if_open */, \
    TRUE                                /* hideable         */, \
    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 */
Alexia Death's avatar
Alexia Death committed
300
  LIST (dynamics, dynamics, N_("Paint Dynamics"), NULL, GIMP_STOCK_DYNAMICS,
301
        GIMP_HELP_DYNAMICS_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
Alexia Death's avatar
Alexia Death committed
302 303
  LIST (tool-preset, tool_preset, N_("Tool Presets"), NULL, GIMP_STOCK_TOOL_PRESET,
        GIMP_HELP_TOOL_PRESET_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
304

305
  /*  image related  */
306 307 308 309 310 311 312 313 314 315 316 317 318
  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",
319
            N_("Colormap"), NULL, GIMP_STOCK_COLORMAP,
320 321 322 323 324 325 326 327 328 329 330 331 332 333
            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),
334 335 336 337
  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),
338

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

345
  /*  editors  */
346 347 348 349
  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),
350

351
  /*  singleton editors  */
352 353 354 355
  DOCKABLE ("gimp-brush-editor",
            N_("Brush Editor"), NULL, GIMP_STOCK_BRUSH,
            GIMP_HELP_BRUSH_EDITOR_DIALOG,
            dialogs_brush_editor_get, 0, TRUE),
356
  DOCKABLE ("gimp-dynamics-editor",
357
            N_("Paint Dynamics Editor"), NULL, GIMP_STOCK_DYNAMICS,
358 359
            GIMP_HELP_DYNAMICS_EDITOR_DIALOG,
            dialogs_dynamics_editor_get, 0, TRUE),
360 361 362 363 364 365 366
  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,
367
            dialogs_palette_editor_get, 0, TRUE),
Alexia Death's avatar
Alexia Death committed
368 369 370 371
  DOCKABLE ("gimp-tool-preset-editor",
            N_("Tool Preset Editor"), NULL, GIMP_STOCK_TOOL_PRESET,
            GIMP_HELP_TOOL_PRESET_EDITOR_DIALOG,
            dialogs_tool_preset_editor_get, 0, TRUE),
372

373
  /*  image windows  */
374
  FOREIGN_NOT_HIDEABLE ("gimp-empty-image-window",
375 376
                        TRUE, TRUE),
  FOREIGN_NOT_HIDEABLE ("gimp-single-image-window",
377
                        TRUE, TRUE)
378 379 380 381 382
};


/*  public functions  */

383
void
384 385
dialogs_init (Gimp            *gimp,
              GimpMenuFactory *menu_factory)
386
{
387 388
  GimpDialogFactory *factory = NULL;
  gint               i       = 0;
389

390
  g_return_if_fail (GIMP_IS_GIMP (gimp));
391
  g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
392

393 394 395 396
  factory = gimp_dialog_factory_new ("toplevel",
                                     gimp_get_user_context (gimp),
                                     menu_factory);
  gimp_dialog_factory_set_singleton (factory);
397

398
  for (i = 0; i < G_N_ELEMENTS (entries); i++)
399
    gimp_dialog_factory_register_entry (gimp_dialog_factory_get_singleton (),
400 401 402 403 404 405 406 407 408 409 410
                                        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,
411
                                        entries[i].hideable,
412
                                        entries[i].dockable);
413

414
  global_recent_docks = gimp_list_new (GIMP_TYPE_SESSION_INFO, FALSE);
415
}
416 417

void
Michael Natterer's avatar
Michael Natterer committed
418
dialogs_exit (Gimp *gimp)
419
{
420 421
  g_return_if_fail (GIMP_IS_GIMP (gimp));

422
  if (gimp_dialog_factory_get_singleton ())
423
    {
424 425 426 427 428
      /* run dispose manually so the factory destroys its dialogs, which
       * might in turn directly or indirectly ref the factory
       */
      g_object_run_dispose (G_OBJECT (gimp_dialog_factory_get_singleton ()));

429 430
      g_object_unref (gimp_dialog_factory_get_singleton ());
      gimp_dialog_factory_set_singleton (NULL);
431 432
    }

433 434 435 436 437 438 439
  if (global_recent_docks)
    {
      g_object_unref (global_recent_docks);
      global_recent_docks = NULL;
    }
}

440 441 442 443 444 445 446 447 448 449
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
       */
450
      entry = gimp_dialog_factory_find_entry (gimp_dialog_factory_get_singleton (),
451 452 453 454 455 456
                                              "gimp-dock-window");

      gimp_session_info_set_factory_entry (info, entry);
    }
}

457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
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)
475
        gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
476 477 478 479

      g_clear_error (&error);
    }

480 481 482 483 484 485 486
  /* 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);

487 488
  gimp_list_reverse (GIMP_LIST (global_recent_docks));

489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
  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))
    {
511
      gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
512 513 514 515
      g_clear_error (&error);
    }

  g_free (filename);
516
}
517 518 519 520 521 522

GtkWidget *
dialogs_get_toolbox (void)
{
  GList *list;

523
  g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (gimp_dialog_factory_get_singleton ()), NULL);
524

525
  for (list = gimp_dialog_factory_get_open_dialogs (gimp_dialog_factory_get_singleton ());
526 527 528
       list;
       list = g_list_next (list))
    {
529 530
      if (GIMP_IS_DOCK_WINDOW (list->data) &&
          gimp_dock_window_has_toolbox (list->data))
531 532 533 534 535
        return list->data;
    }

  return NULL;
}