~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

Viewing changes to app/gui/gui.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The GIMP -- an image manipulation program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <stdlib.h>
 
22
 
 
23
#include <gtk/gtk.h>
 
24
 
 
25
#include "libgimpbase/gimpbase.h"
 
26
#include "libgimpwidgets/gimpwidgets.h"
 
27
#include "libgimpwidgets/gimpwidgets-private.h"
 
28
 
 
29
#include "gui-types.h"
 
30
 
 
31
#include "config/gimpguiconfig.h"
 
32
 
 
33
#include "core/gimp.h"
 
34
#include "core/gimpcontainer.h"
 
35
#include "core/gimpcontext.h"
 
36
#include "core/gimpenvirontable.h"
 
37
#include "core/gimpimage.h"
 
38
#include "core/gimplist.h"
 
39
#include "core/gimptoolinfo.h"
 
40
 
 
41
#include "display/gimpdisplay.h"
 
42
#include "display/gimpdisplay-foreach.h"
 
43
#include "display/gimpdisplayshell.h"
 
44
#include "display/gimpdisplayshell-render.h"
 
45
 
 
46
#include "tools/gimp-tools.h"
 
47
 
 
48
#include "widgets/gimpclipboard.h"
 
49
#include "widgets/gimpcontrollers.h"
 
50
#include "widgets/gimpdevices.h"
 
51
#include "widgets/gimpdevicestatus.h"
 
52
#include "widgets/gimpdialogfactory.h"
 
53
#include "widgets/gimpdnd.h"
 
54
#include "widgets/gimphelp.h"
 
55
#include "widgets/gimphelp-ids.h"
 
56
#include "widgets/gimpmenufactory.h"
 
57
#include "widgets/gimpmessagebox.h"
 
58
#include "widgets/gimpsessioninfo.h"
 
59
#include "widgets/gimpuimanager.h"
 
60
#include "widgets/gimpwidgets-utils.h"
 
61
 
 
62
#include "actions/actions.h"
 
63
#include "actions/dialogs-commands.h"
 
64
 
 
65
#include "menus/menus.h"
 
66
 
 
67
#include "dialogs/dialogs.h"
 
68
 
 
69
#include "color-history.h"
 
70
#include "gui.h"
 
71
#include "gui-vtable.h"
 
72
#include "session.h"
 
73
#include "splash.h"
 
74
#include "themes.h"
 
75
 
 
76
#include "gimp-intl.h"
 
77
 
 
78
 
 
79
/*  local function prototypes  */
 
80
 
 
81
static gchar    * gui_sanity_check              (void);
 
82
static void       gui_help_func                 (const gchar        *help_id,
 
83
                                                 gpointer            help_data);
 
84
static gboolean   gui_get_background_func       (GimpRGB            *color);
 
85
static gboolean   gui_get_foreground_func       (GimpRGB            *color);
 
86
 
 
87
static void       gui_initialize_after_callback (Gimp               *gimp,
 
88
                                                 GimpInitStatusFunc  callback);
 
89
 
 
90
static void       gui_restore_callback          (Gimp               *gimp,
 
91
                                                 GimpInitStatusFunc  callback);
 
92
static void       gui_restore_after_callback    (Gimp               *gimp,
 
93
                                                 GimpInitStatusFunc  callback);
 
94
 
 
95
static gboolean   gui_exit_callback             (Gimp               *gimp,
 
96
                                                 gboolean            force);
 
97
static gboolean   gui_exit_after_callback       (Gimp               *gimp,
 
98
                                                 gboolean            force);
 
99
 
 
100
static void       gui_show_tooltips_notify      (GimpGuiConfig      *gui_config,
 
101
                                                 GParamSpec         *pspec,
 
102
                                                 Gimp               *gimp);
 
103
static void       gui_show_help_button_notify   (GimpGuiConfig      *gui_config,
 
104
                                                 GParamSpec         *pspec,
 
105
                                                 Gimp               *gimp);
 
106
static void       gui_tearoff_menus_notify      (GimpGuiConfig      *gui_config,
 
107
                                                 GParamSpec         *pspec,
 
108
                                                 GtkUIManager       *manager);
 
109
static void       gui_device_change_notify      (Gimp               *gimp);
 
110
 
 
111
static void       gui_display_changed           (GimpContext        *context,
 
112
                                                 GimpDisplay        *display,
 
113
                                                 Gimp               *gimp);
 
114
static void       gui_image_disconnect          (GimpImage          *gimage,
 
115
                                                 Gimp               *gimp);
 
116
 
 
117
 
 
118
/*  private variables  */
 
119
 
 
120
static Gimp          *the_gui_gimp                = NULL;
 
121
static GQuark         image_disconnect_handler_id = 0;
 
122
static GimpUIManager *image_ui_manager            = NULL;
 
123
 
 
124
 
 
125
/*  public functions  */
 
126
 
 
127
gboolean
 
128
gui_libs_init (gint    *argc,
 
129
               gchar ***argv)
 
130
{
 
131
  gchar *abort_message;
 
132
 
 
133
  g_return_val_if_fail (argc != NULL, FALSE);
 
134
  g_return_val_if_fail (argv != NULL, FALSE);
 
135
 
 
136
  if (! gtk_init_check (argc, argv))
 
137
    return FALSE;
 
138
 
 
139
  abort_message = gui_sanity_check ();
 
140
  if (abort_message)
 
141
    gui_abort (abort_message);
 
142
 
 
143
  gimp_widgets_init (gui_help_func,
 
144
                     gui_get_foreground_func,
 
145
                     gui_get_background_func,
 
146
                     NULL);
 
147
 
 
148
  g_type_class_ref (GIMP_TYPE_COLOR_SELECT);
 
149
 
 
150
  return TRUE;
 
151
}
 
152
 
 
153
void
 
154
gui_abort (const gchar *abort_message)
 
155
{
 
156
  GtkWidget *dialog;
 
157
  GtkWidget *box;
 
158
 
 
159
  g_return_if_fail (abort_message != NULL);
 
160
 
 
161
  dialog = gimp_dialog_new (_("GIMP Message"), "gimp-abort",
 
162
                            NULL, GTK_DIALOG_MODAL, NULL, NULL,
 
163
                            GTK_STOCK_OK, GTK_RESPONSE_OK,
 
164
                            NULL);
 
165
 
 
166
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 
167
 
 
168
  box = g_object_new (GIMP_TYPE_MESSAGE_BOX,
 
169
                      "stock_id",     GIMP_STOCK_WILBER_EEK,
 
170
                      "border_width", 12,
 
171
                      NULL);
 
172
 
 
173
  gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), abort_message);
 
174
 
 
175
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
 
176
  gtk_widget_show (box);
 
177
 
 
178
  gimp_dialog_run (GIMP_DIALOG (dialog));
 
179
 
 
180
  exit (EXIT_FAILURE);
 
181
}
 
182
 
 
183
GimpInitStatusFunc
 
184
gui_init (Gimp     *gimp,
 
185
          gboolean  no_splash)
 
186
{
 
187
  GimpInitStatusFunc  status_callback = NULL;
 
188
  GdkScreen          *screen;
 
189
 
 
190
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
 
191
  g_return_val_if_fail (the_gui_gimp == NULL, NULL);
 
192
 
 
193
  the_gui_gimp = gimp;
 
194
 
 
195
  gimp_dnd_init (gimp);
 
196
 
 
197
  themes_init (gimp);
 
198
 
 
199
  gdk_rgb_set_min_colors (CLAMP (gimp->config->min_colors, 27, 256));
 
200
  gdk_rgb_set_install (gimp->config->install_cmap);
 
201
 
 
202
  screen = gdk_screen_get_default ();
 
203
  gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen));
 
204
 
 
205
  if (! no_splash)
 
206
    {
 
207
      splash_create ();
 
208
      status_callback = splash_update;
 
209
    }
 
210
 
 
211
  g_signal_connect_after (gimp, "initialize",
 
212
                          G_CALLBACK (gui_initialize_after_callback),
 
213
                          NULL);
 
214
 
 
215
  g_signal_connect (gimp, "restore",
 
216
                    G_CALLBACK (gui_restore_callback),
 
217
                    NULL);
 
218
  g_signal_connect_after (gimp, "restore",
 
219
                          G_CALLBACK (gui_restore_after_callback),
 
220
                          NULL);
 
221
 
 
222
  g_signal_connect (gimp, "exit",
 
223
                    G_CALLBACK (gui_exit_callback),
 
224
                    NULL);
 
225
  g_signal_connect_after (gimp, "exit",
 
226
                          G_CALLBACK (gui_exit_after_callback),
 
227
                          NULL);
 
228
 
 
229
  return status_callback;
 
230
}
 
231
 
 
232
void
 
233
gui_post_init (Gimp *gimp)
 
234
{
 
235
  g_return_if_fail (GIMP_IS_GIMP (gimp));
 
236
 
 
237
  if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
 
238
    gimp_dialog_factory_dialog_new (global_dialog_factory,
 
239
                                    gdk_screen_get_default (),
 
240
                                    "gimp-tips-dialog", -1, TRUE);
 
241
}
 
242
 
 
243
 
 
244
/*  private functions  */
 
245
 
 
246
static gchar *
 
247
gui_sanity_check (void)
 
248
{
 
249
  const gchar *mismatch;
 
250
 
 
251
#define GTK_REQUIRED_MAJOR 2
 
252
#define GTK_REQUIRED_MINOR 4
 
253
#define GTK_REQUIRED_MICRO 4
 
254
 
 
255
  mismatch = gtk_check_version (GTK_REQUIRED_MAJOR,
 
256
                                GTK_REQUIRED_MINOR,
 
257
                                GTK_REQUIRED_MICRO);
 
258
 
 
259
  if (mismatch)
 
260
    return g_strdup_printf
 
261
      ("%s\n\n"
 
262
       "The GIMP requires Gtk+ version %d.%d.%d or later.\n"
 
263
       "Installed Gtk+ version is %d.%d.%d.\n\n"
 
264
       "Somehow you or your software packager managed\n"
 
265
       "to install The GIMP with an older Gtk+ version.\n\n"
 
266
       "Please upgrade to Gtk+ version %d.%d.%d or later.",
 
267
       mismatch,
 
268
       GTK_REQUIRED_MAJOR, GTK_REQUIRED_MINOR, GTK_REQUIRED_MICRO,
 
269
       gtk_major_version, gtk_minor_version, gtk_micro_version,
 
270
       GTK_REQUIRED_MAJOR, GTK_REQUIRED_MINOR, GTK_REQUIRED_MICRO);
 
271
 
 
272
#undef GTK_REQUIRED_MAJOR
 
273
#undef GTK_REQUIRED_MINOR
 
274
#undef GTK_REQUIRED_MICRO
 
275
 
 
276
  return NULL;
 
277
}
 
278
 
 
279
 
 
280
static void
 
281
gui_help_func (const gchar *help_id,
 
282
               gpointer     help_data)
 
283
{
 
284
  g_return_if_fail (GIMP_IS_GIMP (the_gui_gimp));
 
285
 
 
286
  gimp_help (the_gui_gimp, NULL, help_id);
 
287
}
 
288
 
 
289
static gboolean
 
290
gui_get_foreground_func (GimpRGB *color)
 
291
{
 
292
  g_return_val_if_fail (color != NULL, FALSE);
 
293
  g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
 
294
 
 
295
  gimp_context_get_foreground (gimp_get_user_context (the_gui_gimp), color);
 
296
 
 
297
  return TRUE;
 
298
}
 
299
 
 
300
static gboolean
 
301
gui_get_background_func (GimpRGB *color)
 
302
{
 
303
  g_return_val_if_fail (color != NULL, FALSE);
 
304
  g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
 
305
 
 
306
  gimp_context_get_background (gimp_get_user_context (the_gui_gimp), color);
 
307
 
 
308
  return TRUE;
 
309
}
 
310
 
 
311
static void
 
312
gui_initialize_after_callback (Gimp               *gimp,
 
313
                               GimpInitStatusFunc  status_callback)
 
314
{
 
315
  const gchar *name = NULL;
 
316
 
 
317
  g_return_if_fail (GIMP_IS_GIMP (gimp));
 
318
 
 
319
  if (gimp->be_verbose)
 
320
    g_print ("INIT: gui_initialize_after_callback\n");
 
321
 
 
322
#if defined (GDK_WINDOWING_X11)
 
323
  name = "DISPLAY";
 
324
#elif defined (GDK_WINDOWING_DIRECTFB) || defined (GDK_WINDOWING_FB)
 
325
  name = "GDK_DISPLAY";
 
326
#endif
 
327
 
 
328
  /* TODO: Need to care about display migration with GTK+ 2.2 at some point */
 
329
 
 
330
  if (name)
 
331
    {
 
332
      gchar *display;
 
333
 
 
334
      display = gdk_get_display ();
 
335
      gimp_environ_table_add (gimp->environ_table, name, display, NULL);
 
336
      g_free (display);
 
337
    }
 
338
 
 
339
  gimp_tools_init (gimp);
 
340
 
 
341
  gimp_context_set_tool (gimp_get_user_context (gimp),
 
342
                         gimp_tool_info_get_standard (gimp));
 
343
}
 
344
 
 
345
static void
 
346
gui_restore_callback (Gimp               *gimp,
 
347
                      GimpInitStatusFunc  status_callback)
 
348
{
 
349
  GimpDisplayConfig *display_config = GIMP_DISPLAY_CONFIG (gimp->config);
 
350
  GimpGuiConfig     *gui_config     = GIMP_GUI_CONFIG (gimp->config);
 
351
 
 
352
  if (gimp->be_verbose)
 
353
    g_print ("INIT: gui_restore_callback\n");
 
354
 
 
355
  gui_vtable_init (gimp);
 
356
 
 
357
  image_disconnect_handler_id =
 
358
    gimp_container_add_handler (gimp->images, "disconnect",
 
359
                                G_CALLBACK (gui_image_disconnect),
 
360
                                gimp);
 
361
 
 
362
  if (! gui_config->show_tool_tips)
 
363
    gimp_help_disable_tooltips ();
 
364
 
 
365
  g_signal_connect (gui_config, "notify::show-tool-tips",
 
366
                    G_CALLBACK (gui_show_tooltips_notify),
 
367
                    gimp);
 
368
 
 
369
  gimp_dialogs_show_help_button (gui_config->use_help &&
 
370
                                 gui_config->show_help_button);
 
371
 
 
372
  g_signal_connect (gui_config, "notify::use-help",
 
373
                    G_CALLBACK (gui_show_help_button_notify),
 
374
                    gimp);
 
375
  g_signal_connect (gui_config, "notify::show-help-button",
 
376
                    G_CALLBACK (gui_show_help_button_notify),
 
377
                    gimp);
 
378
 
 
379
  g_signal_connect (gimp_get_user_context (gimp), "display_changed",
 
380
                    G_CALLBACK (gui_display_changed),
 
381
                    gimp);
 
382
 
 
383
  /* make sure the monitor resolution is valid */
 
384
  if (display_config->monitor_res_from_gdk               ||
 
385
      display_config->monitor_xres < GIMP_MIN_RESOLUTION ||
 
386
      display_config->monitor_yres < GIMP_MIN_RESOLUTION)
 
387
    {
 
388
      gdouble xres, yres;
 
389
 
 
390
      gimp_get_screen_resolution (NULL, &xres, &yres);
 
391
 
 
392
      g_object_set (gimp->config,
 
393
                    "monitor-xresolution",                      xres,
 
394
                    "monitor-yresolution",                      yres,
 
395
                    "monitor-resolution-from-windowing-system", TRUE,
 
396
                    NULL);
 
397
    }
 
398
 
 
399
  actions_init (gimp);
 
400
  menus_init (gimp, global_action_factory);
 
401
  render_init (gimp);
 
402
 
 
403
  dialogs_init (gimp, global_menu_factory);
 
404
 
 
405
  gimp_clipboard_init (gimp);
 
406
  gimp_devices_init (gimp, gui_device_change_notify);
 
407
  gimp_controllers_init (gimp);
 
408
  session_init (gimp);
 
409
 
 
410
  (* status_callback) (NULL, _("Tool Options"), 1.0);
 
411
  gimp_tools_restore (gimp);
 
412
}
 
413
 
 
414
static void
 
415
gui_restore_after_callback (Gimp               *gimp,
 
416
                            GimpInitStatusFunc  status_callback)
 
417
{
 
418
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
 
419
 
 
420
  if (gimp->be_verbose)
 
421
    g_print ("INIT: gui_restore_after_callback\n");
 
422
 
 
423
  gimp->message_handler = GIMP_MESSAGE_BOX;
 
424
 
 
425
  if (gui_config->restore_accels)
 
426
    menus_restore (gimp);
 
427
 
 
428
  image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory,
 
429
                                                    "<Image>",
 
430
                                                    gimp,
 
431
                                                    gui_config->tearoff_menus);
 
432
 
 
433
  g_signal_connect_object (gui_config, "notify::tearoff-menus",
 
434
                           G_CALLBACK (gui_tearoff_menus_notify),
 
435
                           image_ui_manager, 0);
 
436
 
 
437
  gimp_devices_restore (gimp);
 
438
  gimp_controllers_restore (gimp, image_ui_manager);
 
439
 
 
440
  if (status_callback == splash_update)
 
441
    splash_destroy ();
 
442
 
 
443
  color_history_restore ();
 
444
 
 
445
  if (gui_config->restore_session)
 
446
    session_restore (gimp);
 
447
 
 
448
  dialogs_show_toolbox ();
 
449
}
 
450
 
 
451
static gboolean
 
452
gui_exit_callback (Gimp     *gimp,
 
453
                   gboolean  force)
 
454
{
 
455
  GimpGuiConfig  *gui_config = GIMP_GUI_CONFIG (gimp->config);
 
456
 
 
457
  if (gimp->be_verbose)
 
458
    g_print ("EXIT: gui_exit_callback\n");
 
459
 
 
460
  if (! force && gimp_displays_dirty (gimp))
 
461
    {
 
462
      gimp_dialog_factory_dialog_raise (global_dialog_factory,
 
463
                                        gdk_screen_get_default (),
 
464
                                        "gimp-quit-dialog", -1);
 
465
 
 
466
      return TRUE; /* stop exit for now */
 
467
    }
 
468
 
 
469
  gimp->message_handler = GIMP_CONSOLE;
 
470
 
 
471
  if (gui_config->save_session_info)
 
472
    session_save (gimp, FALSE);
 
473
 
 
474
  color_history_save ();
 
475
 
 
476
  if (gui_config->save_accels)
 
477
    menus_save (gimp, FALSE);
 
478
 
 
479
  if (gui_config->save_device_status)
 
480
    gimp_devices_save (gimp, FALSE);
 
481
 
 
482
  if (TRUE /* gui_config->save_controllers */)
 
483
    gimp_controllers_save (gimp);
 
484
 
 
485
  gimp_displays_delete (gimp);
 
486
 
 
487
  gimp_tools_save (gimp);
 
488
  gimp_tools_exit (gimp);
 
489
 
 
490
  return FALSE; /* continue exiting */
 
491
}
 
492
 
 
493
static gboolean
 
494
gui_exit_after_callback (Gimp     *gimp,
 
495
                         gboolean  force)
 
496
{
 
497
  if (gimp->be_verbose)
 
498
    g_print ("EXIT: gui_exit_after_callback\n");
 
499
 
 
500
  g_signal_handlers_disconnect_by_func (gimp->config,
 
501
                                        gui_show_help_button_notify,
 
502
                                        gimp);
 
503
 
 
504
  g_signal_handlers_disconnect_by_func (gimp->config,
 
505
                                        gui_show_tooltips_notify,
 
506
                                        gimp);
 
507
 
 
508
  gimp_container_remove_handler (gimp->images, image_disconnect_handler_id);
 
509
  image_disconnect_handler_id = 0;
 
510
 
 
511
  g_object_unref (image_ui_manager);
 
512
  image_ui_manager = NULL;
 
513
 
 
514
  session_exit (gimp);
 
515
  menus_exit (gimp);
 
516
  actions_exit (gimp);
 
517
  render_exit (gimp);
 
518
 
 
519
  dialogs_exit (gimp);
 
520
  gimp_controllers_exit (gimp);
 
521
  gimp_devices_exit (gimp);
 
522
  gimp_clipboard_exit (gimp);
 
523
 
 
524
  themes_exit (gimp);
 
525
 
 
526
  g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
 
527
 
 
528
  return FALSE; /* continue exiting */
 
529
}
 
530
 
 
531
static void
 
532
gui_show_tooltips_notify (GimpGuiConfig *gui_config,
 
533
                          GParamSpec    *param_spec,
 
534
                          Gimp          *gimp)
 
535
{
 
536
  if (gui_config->show_tool_tips)
 
537
    gimp_help_enable_tooltips ();
 
538
  else
 
539
    gimp_help_disable_tooltips ();
 
540
}
 
541
 
 
542
static void
 
543
gui_show_help_button_notify (GimpGuiConfig *gui_config,
 
544
                             GParamSpec    *param_spec,
 
545
                             Gimp          *gimp)
 
546
{
 
547
  gimp_dialogs_show_help_button (gui_config->use_help &&
 
548
                                 gui_config->show_help_button);
 
549
}
 
550
 
 
551
static void
 
552
gui_tearoff_menus_notify (GimpGuiConfig *gui_config,
 
553
                          GParamSpec    *pspec,
 
554
                          GtkUIManager  *manager)
 
555
{
 
556
  gtk_ui_manager_set_add_tearoffs (manager, gui_config->tearoff_menus);
 
557
}
 
558
 
 
559
static void
 
560
gui_device_change_notify (Gimp *gimp)
 
561
{
 
562
  GimpSessionInfo *session_info;
 
563
 
 
564
  session_info = gimp_dialog_factory_find_session_info (global_dock_factory,
 
565
                                                        "gimp-device-status");
 
566
 
 
567
  if (session_info && session_info->widget)
 
568
    {
 
569
      GtkWidget *device_status;
 
570
 
 
571
      device_status = GTK_BIN (session_info->widget)->child;
 
572
 
 
573
      gimp_device_status_update (GIMP_DEVICE_STATUS (device_status));
 
574
    }
 
575
}
 
576
 
 
577
static void
 
578
gui_display_changed (GimpContext *context,
 
579
                     GimpDisplay *display,
 
580
                     Gimp        *gimp)
 
581
{
 
582
  if (! display)
 
583
    {
 
584
      GimpImage *image = gimp_context_get_image (context);
 
585
 
 
586
      if (image)
 
587
        {
 
588
          GList *list;
 
589
 
 
590
          for (list = GIMP_LIST (gimp->displays)->list;
 
591
               list;
 
592
               list = g_list_next (list))
 
593
            {
 
594
              GimpDisplay *display2 = list->data;
 
595
 
 
596
              if (display2->gimage == image)
 
597
                {
 
598
                  gimp_context_set_display (context, display2);
 
599
                  return;
 
600
                }
 
601
            }
 
602
 
 
603
          gimp_context_set_image (context, NULL);
 
604
        }
 
605
    }
 
606
 
 
607
  gimp_ui_manager_update (image_ui_manager, display);
 
608
}
 
609
 
 
610
static void
 
611
gui_image_disconnect (GimpImage *gimage,
 
612
                      Gimp      *gimp)
 
613
{
 
614
  /*  check if this is the last image and if it had a display  */
 
615
  if (gimp_container_num_children (gimp->images) == 1 &&
 
616
      gimage->instance_count                      > 0)
 
617
    {
 
618
      dialogs_show_toolbox ();
 
619
    }
 
620
}