gui-vtable.c 22.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (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
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

21 22
#include <string.h>

23 24 25 26 27 28
#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "gui-types.h"

29 30
#include "config/gimpguiconfig.h"

31
#include "core/gimp.h"
32
#include "core/gimp-utils.h"
33 34
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
35
#include "core/gimpcontext.h"
36
#include "core/gimpgradient.h"
37
#include "core/gimpimage.h"
38 39
#include "core/gimppalette.h"
#include "core/gimppattern.h"
40
#include "core/gimpprogress.h"
41 42

#include "text/gimpfont.h"
43

44
#include "plug-in/plug-ins.h"
45
#include "plug-in/plug-in-proc-def.h"
46 47

#include "widgets/gimpactiongroup.h"
48
#include "widgets/gimpbrushselect.h"
49 50
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
51
#include "widgets/gimperrordialog.h"
52 53
#include "widgets/gimpfontselect.h"
#include "widgets/gimpgradientselect.h"
54
#include "widgets/gimphelp.h"
55 56 57 58
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimppaletteselect.h"
#include "widgets/gimppatternselect.h"
59
#include "widgets/gimpprogressdialog.h"
60
#include "widgets/gimpuimanager.h"
61 62 63 64 65

#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"

66 67
#include "actions/plug-in-actions.h"

68 69 70
#include "menus/menus.h"
#include "menus/plug-in-menus.h"

71 72
#include "dialogs/dialogs.h"

Michael Natterer's avatar
Michael Natterer committed
73
#include "themes.h"
74 75 76 77 78 79 80 81 82 83 84


/*  local function prototypes  */

static void           gui_threads_enter        (Gimp          *gimp);
static void           gui_threads_leave        (Gimp          *gimp);
static void           gui_set_busy             (Gimp          *gimp);
static void           gui_unset_busy           (Gimp          *gimp);
static void           gui_message              (Gimp          *gimp,
                                                const gchar   *domain,
                                                const gchar   *message);
85 86 87
static void           gui_help                 (Gimp          *gimp,
                                                const gchar   *help_domain,
                                                const gchar   *help_id);
88 89 90 91 92 93 94 95
static const gchar  * gui_get_program_class    (Gimp          *gimp);
static gchar        * gui_get_display_name     (Gimp          *gimp,
                                                gint           gdisp_ID,
                                                gint          *monitor_number);
static const gchar  * gui_get_theme_dir        (Gimp          *gimp);
static GimpObject   * gui_display_get_by_ID    (Gimp          *gimp,
                                                gint           ID);
static gint           gui_display_get_ID       (GimpObject    *display);
Sven Neumann's avatar
Sven Neumann committed
96
static guint32        gui_display_get_window   (GimpObject    *display);
97 98 99 100 101 102 103
static GimpObject   * gui_display_create       (GimpImage     *gimage,
                                                GimpUnit       unit,
                                                gdouble        scale);
static void           gui_display_delete       (GimpObject    *display);
static void           gui_displays_reconnect   (Gimp          *gimp,
                                                GimpImage     *old_image,
                                                GimpImage     *new_image);
104 105 106
static void           gui_menus_init           (Gimp          *gimp,
                                                GSList        *plug_in_defs,
                                                const gchar   *plugins_domain);
107
static void           gui_menus_create_item    (Gimp          *gimp,
108 109
                                                PlugInProcDef *proc_def,
                                                const gchar   *menu_path);
110
static void           gui_menus_delete_item    (Gimp          *gimp,
111
                                                PlugInProcDef *proc_def);
112 113 114 115
static void           gui_menus_create_branch  (Gimp          *gimp,
                                                const gchar   *progname,
                                                const gchar   *menu_path,
                                                const gchar   *menu_label);
116 117
static GimpProgress * gui_new_progress         (Gimp          *gimp,
                                                gint           display_ID);
118
static void           gui_free_progress        (Gimp          *gimp,
119
                                                GimpProgress  *progress);
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
static gboolean       gui_pdb_dialog_new       (Gimp          *gimp,
                                                GimpContext   *context,
                                                GimpContainer *container,
                                                const gchar   *title,
                                                const gchar   *callback_name,
                                                const gchar   *object_name,
                                                va_list        args);
static gboolean       gui_pdb_dialog_set       (Gimp          *gimp,
                                                GimpContainer *container,
                                                const gchar   *callback_name,
                                                const gchar   *object_name,
                                                va_list        args);
static gboolean       gui_pdb_dialog_close     (Gimp          *gimp,
                                                GimpContainer *container,
                                                const gchar   *callback_name);
static void           gui_pdb_dialogs_check    (Gimp          *gimp);
136 137 138 139 140 141 142 143 144


/*  public functions  */

void
gui_vtable_init (Gimp *gimp)
{
  g_return_if_fail (GIMP_IS_GIMP (gimp));

145 146 147 148 149 150 151 152 153 154 155
  gimp->gui.threads_enter       = gui_threads_enter;
  gimp->gui.threads_leave       = gui_threads_leave;
  gimp->gui.set_busy            = gui_set_busy;
  gimp->gui.unset_busy          = gui_unset_busy;
  gimp->gui.message             = gui_message;
  gimp->gui.help                = gui_help;
  gimp->gui.get_program_class   = gui_get_program_class;
  gimp->gui.get_display_name    = gui_get_display_name;
  gimp->gui.get_theme_dir       = gui_get_theme_dir;
  gimp->gui.display_get_by_id   = gui_display_get_by_ID;
  gimp->gui.display_get_id      = gui_display_get_ID;
Sven Neumann's avatar
Sven Neumann committed
156
  gimp->gui.display_get_window  = gui_display_get_window;
157 158 159 160 161 162 163 164 165 166 167 168 169
  gimp->gui.display_create      = gui_display_create;
  gimp->gui.display_delete      = gui_display_delete;
  gimp->gui.displays_reconnect  = gui_displays_reconnect;
  gimp->gui.menus_init          = gui_menus_init;
  gimp->gui.menus_create_item   = gui_menus_create_item;
  gimp->gui.menus_delete_item   = gui_menus_delete_item;
  gimp->gui.menus_create_branch = gui_menus_create_branch;
  gimp->gui.progress_new        = gui_new_progress;
  gimp->gui.progress_free       = gui_free_progress;
  gimp->gui.pdb_dialog_new      = gui_pdb_dialog_new;
  gimp->gui.pdb_dialog_set      = gui_pdb_dialog_set;
  gimp->gui.pdb_dialog_close    = gui_pdb_dialog_close;
  gimp->gui.pdb_dialogs_check   = gui_pdb_dialogs_check;
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
}


/*  private functions  */

static void
gui_threads_enter (Gimp *gimp)
{
  GDK_THREADS_ENTER ();
}

static void
gui_threads_leave (Gimp *gimp)
{
  GDK_THREADS_LEAVE ();
}

static void
gui_set_busy (Gimp *gimp)
{
  gimp_displays_set_busy (gimp);
191
  gimp_dialog_factories_set_busy ();
192 193 194 195 196 197 198 199

  gdk_flush ();
}

static void
gui_unset_busy (Gimp *gimp)
{
  gimp_displays_unset_busy (gimp);
200
  gimp_dialog_factories_unset_busy ();
201 202 203 204 205 206 207 208 209

  gdk_flush ();
}

static void
gui_message (Gimp        *gimp,
             const gchar *domain,
             const gchar *message)
{
210
  switch (gimp->message_handler)
211
    {
212 213 214
    case GIMP_ERROR_CONSOLE:
      {
        GtkWidget *dockable;
215

216 217 218
        dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
                                                     gdk_screen_get_default (),
                                                     "gimp-error-console", -1);
219

220 221 222
        if (dockable)
          {
            GimpErrorConsole *console;
223

224
            console = GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child);
225

226 227
            gimp_error_console_add (console,
                                    GIMP_STOCK_WARNING, domain, message);
228

229 230
            return;
          }
231

232 233 234 235 236 237 238
        gimp->message_handler = GIMP_MESSAGE_BOX;
      }
      /*  fallthru  */

    case GIMP_MESSAGE_BOX:
      {
        GtkWidget *dialog;
239

240 241 242 243 244
        dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
                                                 gdk_screen_get_default (),
                                                 "gimp-error-dialog", -1,
                                                 FALSE);

245 246 247 248 249
        if (dialog)
          {
            gimp_error_dialog_add (GIMP_ERROR_DIALOG (dialog),
                                   GIMP_STOCK_WARNING, domain, message);

250 251
            gtk_window_present (GTK_WINDOW (dialog));

252 253 254 255 256 257 258 259 260 261 262
            return;
          }

        gimp->message_handler = GIMP_CONSOLE;
      }
      /*  fallthru  */

    case GIMP_CONSOLE:
      g_printerr ("%s: %s\n\n", domain, message);
      break;
    }
263 264
}

265 266 267 268
void
gui_help (Gimp        *gimp,
          const gchar *help_domain,
          const gchar *help_id)
269
{
270
  gimp_help_show (gimp, help_domain, help_id);
271 272
}

273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
static const gchar *
gui_get_program_class (Gimp *gimp)
{
  return gdk_get_program_class ();
}

static gchar *
gui_get_display_name (Gimp *gimp,
                      gint  gdisp_ID,
                      gint *monitor_number)
{
  GimpDisplay *gdisp = NULL;
  GdkScreen   *screen;
  gint         monitor;

  if (gdisp_ID > 0)
    gdisp = gimp_display_get_by_ID (gimp, gdisp_ID);

  if (gdisp)
    {
      screen  = gtk_widget_get_screen (gdisp->shell);
      monitor = gdk_screen_get_monitor_at_window (screen,
                                                  gdisp->shell->window);
    }
  else
    {
      gint x, y;

      gdk_display_get_pointer (gdk_display_get_default (),
                               &screen, &x, &y, NULL);
      monitor = gdk_screen_get_monitor_at_point (screen, x, y);
    }

  *monitor_number = monitor;

  if (screen)
    return gdk_screen_make_display_name (screen);

  return NULL;
}

static const gchar *
gui_get_theme_dir (Gimp *gimp)
{
  return themes_get_theme_dir (gimp, GIMP_GUI_CONFIG (gimp->config)->theme);
}

static GimpObject *
gui_display_get_by_ID (Gimp *gimp,
                       gint  ID)
{
  return (GimpObject *) gimp_display_get_by_ID (gimp, ID);
}

static gint
gui_display_get_ID (GimpObject *display)
{
  return gimp_display_get_ID (GIMP_DISPLAY (display));
}

Sven Neumann's avatar
Sven Neumann committed
333 334 335 336 337 338 339 340 341 342 343 344 345
static guint32
gui_display_get_window (GimpObject *display)
{
#ifdef GDK_NATIVE_WINDOW_POINTER
#ifdef __GNUC__
#warning gui_display_get_window() unimplementable for the target windowing system
#endif
  return 0;
#else
  return (guint32) gimp_display_get_window (GIMP_DISPLAY (display));
#endif
}

346 347 348 349 350
static GimpObject *
gui_display_create (GimpImage *gimage,
                    GimpUnit   unit,
                    gdouble    scale)
{
351 352
  GimpDisplay *gdisp;
  GList       *image_managers;
353 354 355 356 357 358 359 360 361

  image_managers = gimp_ui_managers_from_name ("<Image>");

  gdisp = gimp_display_new (gimage, unit, scale,
                            global_menu_factory,
                            image_managers->data);

  gimp_context_set_display (gimp_get_user_context (gimage->gimp), gdisp);

362 363
  gimp_ui_manager_update (GIMP_DISPLAY_SHELL (gdisp->shell)->menubar_manager,
                          gdisp);
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381

  return GIMP_OBJECT (gdisp);
}

static void
gui_display_delete (GimpObject *display)
{
  gimp_display_delete (GIMP_DISPLAY (display));
}

static void
gui_displays_reconnect (Gimp      *gimp,
                        GimpImage *old_image,
                        GimpImage *new_image)
{
  gimp_displays_reconnect (gimp, old_image, new_image);
}

382 383 384 385 386 387 388 389
static void
gui_menus_init (Gimp        *gimp,
                GSList      *plug_in_defs,
                const gchar *std_plugins_domain)
{
  plug_in_menus_init (gimp, plug_in_defs, std_plugins_domain);
}

390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
static void
gui_menus_add_proc (Gimp          *gimp,
                    PlugInProcDef *proc_def,
                    const gchar   *menu_path)
{
  gchar *name;
  gchar *p;
  GList *list;

  name = g_strdup (menu_path);

  p = strchr (name, '>');

  if (p)
    {
      p[1] = '\0';

      for (list = gimp_ui_managers_from_name (name);
           list;
           list = g_list_next (list))
        {
          if (! strncmp (menu_path, "<Image>", 7))
            {
              plug_in_menus_add_proc (list->data, "/image-menubar",
                                      proc_def, menu_path);
              plug_in_menus_add_proc (list->data, "/dummy-menubar/image-popup",
                                      proc_def, menu_path);
            }
          else if (! strncmp (menu_path, "<Toolbox>", 9))
            {
              plug_in_menus_add_proc (list->data, "/toolbox-menubar",
                                      proc_def, menu_path);
            }
        }
    }

  g_free (name);
}

static void
gui_menus_delete_proc (Gimp          *gimp,
                       PlugInProcDef *proc_def,
                       const gchar   *menu_path)
{
  gchar *name;
  gchar *p;
  GList *list;

  name = g_strdup (menu_path);

  p = strchr (name, '>');

  if (p)
    {
      p[1] = '\0';

      for (list = gimp_ui_managers_from_name (name);
           list;
           list = g_list_next (list))
        {
          plug_in_menus_remove_proc (list->data, proc_def);
        }
    }

  g_free (name);
}

457
static void
458 459 460
gui_menus_create_item (Gimp          *gimp,
                       PlugInProcDef *proc_def,
                       const gchar   *menu_path)
461
{
462
  GList *list;
463

464 465 466
  for (list = gimp_action_groups_from_name ("plug-in");
       list;
       list = g_list_next (list))
467
    {
468
      if (menu_path == NULL)
469 470 471
        {
          plug_in_actions_add_proc (list->data, proc_def);
        }
472 473 474 475
      else
        {
          plug_in_actions_add_path (list->data, proc_def, menu_path);
        }
476 477
    }

478
  if (menu_path == NULL)
479
    {
480 481 482 483 484 485
      for (list = proc_def->menu_paths; list; list = g_list_next (list))
        gui_menus_add_proc (gimp, proc_def, list->data);
    }
  else
    {
      gui_menus_add_proc (gimp, proc_def, menu_path);
486
    }
487 488 489
}

static void
490 491
gui_menus_delete_item (Gimp          *gimp,
                       PlugInProcDef *proc_def)
492
{
493 494
  GList *list;

495 496
  for (list = proc_def->menu_paths; list; list = g_list_next (list))
    gui_menus_delete_proc (gimp, proc_def, list->data);
497

498 499 500 501 502 503
  for (list = gimp_action_groups_from_name ("plug-in");
       list;
       list = g_list_next (list))
    {
      plug_in_actions_remove_proc (list->data, proc_def);
    }
504 505
}

506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
static void
gui_menus_create_branch (Gimp        *gimp,
                         const gchar *progname,
                         const gchar *menu_path,
                         const gchar *menu_label)
{
  GList *list;

  for (list = gimp_action_groups_from_name ("plug-in");
       list;
       list = g_list_next (list))
    {
      plug_in_actions_add_branch (list->data, progname, menu_path, menu_label);
    }
}

522
static GimpProgress *
523 524
gui_new_progress (Gimp *gimp,
                  gint  display_ID)
525
{
526 527 528 529 530 531 532 533
  GimpDisplay *display = NULL;

  if (display_ID > 0)
    display = gimp_display_get_by_ID (gimp, display_ID);

  if (display)
    return GIMP_PROGRESS (display);

534
  return GIMP_PROGRESS (gimp_progress_dialog_new ());
535 536 537
}

static void
538 539
gui_free_progress (Gimp          *gimp,
                   GimpProgress  *progress)
540
{
541
  g_return_if_fail (GIMP_IS_PROGRESS_DIALOG (progress));
542

543 544
  if (GIMP_IS_PROGRESS_DIALOG (progress))
    gtk_widget_destroy (GTK_WIDGET (progress));
545 546
}

547 548 549 550 551 552 553 554 555
static gboolean
gui_pdb_dialog_new (Gimp          *gimp,
                    GimpContext   *context,
                    GimpContainer *container,
                    const gchar   *title,
                    const gchar   *callback_name,
                    const gchar   *object_name,
                    va_list        args)
{
556 557 558
  GType        dialog_type = G_TYPE_NONE;
  const gchar *dialog_role = NULL;
  const gchar *help_id     = NULL;
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602

  if (container->children_type == GIMP_TYPE_BRUSH)
    {
      dialog_type = GIMP_TYPE_BRUSH_SELECT;
      dialog_role = "gimp-brush-selection";
      help_id     = GIMP_HELP_BRUSH_DIALOG;
    }
  else if (container->children_type == GIMP_TYPE_FONT)
    {
      dialog_type = GIMP_TYPE_FONT_SELECT;
      dialog_role = "gimp-font-selection";
      help_id     = GIMP_HELP_FONT_DIALOG;
    }
  else if (container->children_type == GIMP_TYPE_GRADIENT)
    {
      dialog_type = GIMP_TYPE_GRADIENT_SELECT;
      dialog_role = "gimp-gradient-selection";
      help_id     = GIMP_HELP_GRADIENT_DIALOG;
    }
  else if (container->children_type == GIMP_TYPE_PALETTE)
    {
      dialog_type = GIMP_TYPE_PALETTE_SELECT;
      dialog_role = "gimp-palette-selection";
      help_id     = GIMP_HELP_PALETTE_DIALOG;
    }
  else if (container->children_type == GIMP_TYPE_PATTERN)
    {
      dialog_type = GIMP_TYPE_PATTERN_SELECT;
      dialog_role = "gimp-pattern-selection";
      help_id     = GIMP_HELP_PATTERN_DIALOG;
    }

  if (dialog_type != G_TYPE_NONE)
    {
      GimpObject *object = NULL;

      if (object_name && strlen (object_name))
        object = gimp_container_get_child_by_name (container, object_name);

      if (! object)
        object = gimp_context_get_by_type (context, container->children_type);

      if (object)
        {
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
          GParameter *params   = NULL;
          gint        n_params = 0;
          GtkWidget  *dialog;

          params = gimp_parameters_append (dialog_type, params, &n_params,
                                           "title",          title,
                                           "role",           dialog_role,
                                           "help-func",      gimp_standard_help_func,
                                           "help-id",        help_id,
                                           "context",        context,
                                           "select-type",    container->children_type,
                                           "initial-object", object,
                                           "callback-name",  callback_name,
                                           "menu-factory",   global_menu_factory,
                                           NULL);
618

619 620 621
          params = gimp_parameters_append_valist (dialog_type,
                                                  params, &n_params,
                                                  args);
622 623 624

          dialog = g_object_newv (dialog_type, n_params, params);

625
          gimp_parameters_free (params, n_params);
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742

          gtk_widget_show (dialog);

          return TRUE;
        }
    }

  return FALSE;
}

static gboolean
gui_pdb_dialog_set (Gimp          *gimp,
                    GimpContainer *container,
                    const gchar   *callback_name,
                    const gchar   *object_name,
                    va_list        args)
{
  GimpPdbDialogClass *klass = NULL;

  if (container->children_type == GIMP_TYPE_BRUSH)
    klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
  else if (container->children_type == GIMP_TYPE_FONT)
    klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
  else if (container->children_type == GIMP_TYPE_GRADIENT)
    klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
  else if (container->children_type == GIMP_TYPE_PALETTE)
    klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
  else if (container->children_type == GIMP_TYPE_PATTERN)
    klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);

  if (klass)
    {
      GimpPdbDialog *dialog;

      dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);

      if (dialog && dialog->select_type == container->children_type)
        {
          GimpObject *object;

          object = gimp_container_get_child_by_name (container, object_name);

          if (object)
            {
              const gchar *prop_name;

              gimp_context_set_by_type (dialog->context, dialog->select_type,
                                        object);

              prop_name = va_arg (args, const gchar *);

              if (prop_name)
                g_object_set_valist (G_OBJECT (dialog), prop_name, args);

              gtk_window_present (GTK_WINDOW (dialog));
              return TRUE;
            }
        }
    }

  return FALSE;
}

static gboolean
gui_pdb_dialog_close (Gimp          *gimp,
                      GimpContainer *container,
                      const gchar   *callback_name)
{
  GimpPdbDialogClass *klass = NULL;

  if (container->children_type == GIMP_TYPE_BRUSH)
    klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
  else if (container->children_type == GIMP_TYPE_FONT)
    klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
  else if (container->children_type == GIMP_TYPE_GRADIENT)
    klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
  else if (container->children_type == GIMP_TYPE_PALETTE)
    klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
  else if (container->children_type == GIMP_TYPE_PATTERN)
    klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);

  if (klass)
    {
      GimpPdbDialog *dialog;

      dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);

      if (dialog && dialog->select_type == container->children_type)
        {
          gtk_widget_destroy (GTK_WIDGET (dialog));
          return TRUE;
        }
    }

  return FALSE;
}

static void
gui_pdb_dialogs_check (Gimp *gimp)
{
  GimpPdbDialogClass *klass;

  if ((klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT)))
    gimp_pdb_dialogs_check_callback (klass);

  if ((klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT)))
    gimp_pdb_dialogs_check_callback (klass);

  if ((klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT)))
    gimp_pdb_dialogs_check_callback (klass);

  if ((klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT)))
    gimp_pdb_dialogs_check_callback (klass);

  if ((klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT)))
    gimp_pdb_dialogs_check_callback (klass);
}