view-commands.c 17.5 KB
Newer Older
Michael Natterer's avatar
Michael Natterer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/* 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"

#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

Michael Natterer's avatar
Michael Natterer committed
25
#include "actions-types.h"
Michael Natterer's avatar
Michael Natterer committed
26

27 28
#include "config/gimpguiconfig.h"

29 30
#include "core/gimp.h"
#include "core/gimpcontext.h"
Michael Natterer's avatar
Michael Natterer committed
31 32
#include "core/gimpimage.h"

33
#include "display/gimpdisplay.h"
34
#include "display/gimpdisplay-foreach.h"
35
#include "display/gimpdisplayoptions.h"
Michael Natterer's avatar
Michael Natterer committed
36
#include "display/gimpdisplayshell.h"
37
#include "display/gimpdisplayshell-appearance.h"
38
#include "display/gimpdisplayshell-filter-dialog.h"
39
#include "display/gimpdisplayshell-scale.h"
40

41
#include "widgets/gimpactiongroup.h"
42
#include "widgets/gimpdock.h"
43
#include "widgets/gimpdialogfactory.h"
44
#include "widgets/gimpuimanager.h"
45

46
#include "gui/color-notebook.h"
Michael Natterer's avatar
Michael Natterer committed
47 48 49 50
#include "gui/dialogs.h"
#include "gui/info-dialog.h"
#include "gui/info-window.h"

51
#include "actions.h"
Michael Natterer's avatar
Michael Natterer committed
52 53
#include "view-commands.h"

54
#include "gimp-intl.h"
Michael Natterer's avatar
Michael Natterer committed
55

56 57

#define SET_ACTIVE(manager,action_name,active) \
58
  { GimpActionGroup *group = \
59
      gimp_ui_manager_get_action_group (manager, "view"); \
60 61
    gimp_action_group_set_action_active (group, action_name, active); }

62 63 64 65
#define IS_ACTIVE_DISPLAY(gdisp) \
  ((gdisp) == \
   gimp_context_get_display (gimp_get_user_context ((gdisp)->gimage->gimp)))

Michael Natterer's avatar
Michael Natterer committed
66

67 68
/*  public functions  */

69 70 71 72
void
view_new_view_cmd_callback (GtkAction *action,
			    gpointer   data)
{
73 74
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
75 76
  return_if_no_display (gdisp, data);

77 78 79 80 81
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

  gimp_create_display (gdisp->gimage->gimp,
                       gdisp->gimage,
                       shell->unit, shell->scale);
82 83 84 85 86 87 88 89 90 91 92 93
}

void
view_close_view_cmd_callback (GtkAction *action,
                              gpointer   data)
{
  GimpDisplay *gdisp;
  return_if_no_display (gdisp, data);

  gimp_display_shell_close (GIMP_DISPLAY_SHELL (gdisp->shell), FALSE);
}

Michael Natterer's avatar
Michael Natterer committed
94
void
95
view_zoom_out_cmd_callback (GtkAction *action,
96
                            gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
97
{
98
  GimpDisplay *gdisp;
Michael Natterer's avatar
Michael Natterer committed
99
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
100

101 102
  gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell),
                            GIMP_ZOOM_OUT, 0.0);
Michael Natterer's avatar
Michael Natterer committed
103 104 105
}

void
106
view_zoom_in_cmd_callback (GtkAction *action,
107
                           gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
108
{
109
  GimpDisplay *gdisp;
Michael Natterer's avatar
Michael Natterer committed
110
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
111

112 113
  gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell),
                            GIMP_ZOOM_IN, 0.0);
Michael Natterer's avatar
Michael Natterer committed
114 115
}

116
void
117 118 119 120 121 122 123 124 125 126 127 128
view_zoom_fit_in_cmd_callback (GtkAction *action,
                               gpointer   data)
{
  GimpDisplay *gdisp;
  return_if_no_display (gdisp, data);

  gimp_display_shell_scale_fit_in (GIMP_DISPLAY_SHELL (gdisp->shell));
}

void
view_zoom_fit_to_cmd_callback (GtkAction *action,
                               gpointer   data)
129 130 131 132
{
  GimpDisplay *gdisp;
  return_if_no_display (gdisp, data);

133
  gimp_display_shell_scale_fit_to (GIMP_DISPLAY_SHELL (gdisp->shell));
134 135
}

Michael Natterer's avatar
Michael Natterer committed
136
void
137 138 139
view_zoom_cmd_callback (GtkAction *action,
                        GtkAction *current,
			gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
140
{
141 142
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
143
  gint              value;
Michael Natterer's avatar
Michael Natterer committed
144
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
145

146 147
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

148
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
149

150
  if (value != 0 /* not Other... */)
151 152 153 154
    {
      if (fabs (value - shell->scale) > 0.0001)
        gimp_display_shell_scale (shell, GIMP_ZOOM_TO, (gdouble) value / 10000);
    }
155 156
}

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
void
view_zoom_other_cmd_callback (GtkAction *action,
                              gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

  /* check if we are activated by the user or from
   * view_actions_set_zoom()
   */
  if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) &&
      shell->scale != shell->other_scale)
    {
      gimp_display_shell_scale_dialog (shell);
    }
}

Michael Natterer's avatar
Michael Natterer committed
177
void
178
view_dot_for_dot_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
179 180
			       gpointer   data)
{
181 182
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
183
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
184
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
185

186 187
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

188 189 190
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  if (active != shell->dot_for_dot)
191
    {
192
      gimp_display_shell_scale_set_dot_for_dot (shell, active);
193

194
      SET_ACTIVE (shell->menubar_manager, "view-dot-for-dot",
195
                  shell->dot_for_dot);
196 197

      if (IS_ACTIVE_DISPLAY (gdisp))
198
        SET_ACTIVE (shell->popup_manager, "view-dot-for-dot",
199
                    shell->dot_for_dot);
200
    }
Michael Natterer's avatar
Michael Natterer committed
201 202 203
}

void
204
view_info_window_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
205 206
			       gpointer   data)
{
Michael Natterer's avatar
Michael Natterer committed
207 208
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
Michael Natterer's avatar
Michael Natterer committed
209
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
210

Michael Natterer's avatar
Michael Natterer committed
211 212
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

213
  if (GIMP_GUI_CONFIG (gdisp->gimage->gimp->config)->info_window_per_display)
Michael Natterer's avatar
Michael Natterer committed
214
    {
Michael Natterer's avatar
Michael Natterer committed
215 216
      if (! shell->info_dialog)
	shell->info_dialog = info_window_create (gdisp);
Michael Natterer's avatar
Michael Natterer committed
217

Sven Neumann's avatar
Sven Neumann committed
218 219 220 221 222
      /* To update the fields of the info window for the first time. *
       * It's no use updating it in info_window_create() because the *
       * pointer of the info window is not present in the shell yet. */
      info_window_update (gdisp);

223
      info_dialog_present (shell->info_dialog);
Michael Natterer's avatar
Michael Natterer committed
224 225 226
    }
  else
    {
Michael Natterer's avatar
Michael Natterer committed
227
      info_window_follow_auto (gdisp->gimage->gimp);
Michael Natterer's avatar
Michael Natterer committed
228 229 230 231
    }
}

void
232
view_navigation_window_cmd_callback (GtkAction *action,
233
                                     gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
234
{
Michael Natterer's avatar
Michael Natterer committed
235 236
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
Michael Natterer's avatar
Michael Natterer committed
237
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
238

Michael Natterer's avatar
Michael Natterer committed
239 240
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

Michael Natterer's avatar
Michael Natterer committed
241
  gimp_dialog_factory_dialog_raise (global_dock_factory,
242
                                    gtk_widget_get_screen (gdisp->shell),
Michael Natterer's avatar
Michael Natterer committed
243
                                    "gimp-navigation-view", -1);
Michael Natterer's avatar
Michael Natterer committed
244 245
}

246
void
247
view_display_filters_cmd_callback (GtkAction *action,
248 249 250 251 252 253 254 255
                                   gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

256 257 258 259 260 261 262 263 264 265
  if (! shell->filters_dialog)
    {
      shell->filters_dialog = gimp_display_shell_filter_dialog_new (shell);

      g_signal_connect (shell->filters_dialog, "destroy",
                        G_CALLBACK (gtk_widget_destroyed),
                        &shell->filters_dialog);
    }

  gtk_window_present (GTK_WINDOW (shell->filters_dialog));
266 267
}

Michael Natterer's avatar
Michael Natterer committed
268
void
269
view_toggle_selection_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
270 271
				    gpointer   data)
{
272 273
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
274
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
275
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
276

277 278
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

279 280 281
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_selection (shell, active);
Michael Natterer's avatar
Michael Natterer committed
282 283 284
}

void
285
view_toggle_layer_boundary_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
286 287 288 289
                                         gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
290
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
291 292 293 294
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

295 296 297
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_layer (shell, active);
Michael Natterer's avatar
Michael Natterer committed
298 299
}

300
void
301
view_toggle_menubar_cmd_callback (GtkAction *action,
302 303 304 305
                                  gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
306
  gboolean          active;
307 308 309 310
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

311 312 313
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_menubar (shell, active);
314 315
}

Michael Natterer's avatar
Michael Natterer committed
316
void
317
view_toggle_rulers_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
318 319
				 gpointer   data)
{
320 321
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
322
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
323
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
324

Michael Natterer's avatar
Michael Natterer committed
325 326
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

327 328 329
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_rulers (shell, active);
330
}
331

332
void
333
view_toggle_scrollbars_cmd_callback (GtkAction *action,
334 335 336 337
                                     gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
338
  gboolean          active;
339
  return_if_no_display (gdisp, data);
340

341 342
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

343 344 345
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_scrollbars (shell, active);
Michael Natterer's avatar
Michael Natterer committed
346 347 348
}

void
349
view_toggle_statusbar_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
350 351
				    gpointer   data)
{
Michael Natterer's avatar
Michael Natterer committed
352 353
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
354
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
355
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
356

Michael Natterer's avatar
Michael Natterer committed
357 358
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

359 360 361
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_statusbar (shell, active);
Michael Natterer's avatar
Michael Natterer committed
362 363 364
}

void
365
view_toggle_guides_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
366 367
				 gpointer   data)
{
368 369
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
370
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
371
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
372

373 374
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

375 376 377
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_guides (shell, active);
Michael Natterer's avatar
Michael Natterer committed
378 379 380
}

void
381
view_snap_to_guides_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
382 383
				  gpointer   data)
{
384 385
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
386
  gboolean          active;
Michael Natterer's avatar
Michael Natterer committed
387
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
388

389
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
390

391
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
392

393
  gimp_display_shell_set_snap_to_guides (shell, active);
Michael Natterer's avatar
Michael Natterer committed
394 395
}

396 397

void
398
view_toggle_grid_cmd_callback (GtkAction *action,
399 400 401 402
                               gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
403
  gboolean          active;
404 405 406 407
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

408
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
409

410
  gimp_display_shell_set_show_grid (shell, active);
411 412 413
}

void
414
view_snap_to_grid_cmd_callback (GtkAction *action,
415 416 417 418
                                gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
419
  gboolean          active;
420 421 422 423
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

424
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
425

426
  gimp_display_shell_set_snap_to_grid (shell, active);
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 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
static void
view_padding_color_callback (ColorNotebook      *cnb,
                             const GimpRGB      *color,
                             ColorNotebookState  state,
                             gpointer            data)
{
  GimpDisplayShell   *shell = GIMP_DISPLAY_SHELL (data);
  GimpDisplayOptions *options;
  gboolean            fullscreen;

  fullscreen = gimp_display_shell_get_fullscreen (shell);

  if (fullscreen)
    options = shell->fullscreen_options;
  else
    options = shell->options;

  switch (state)
    {
    case COLOR_NOTEBOOK_OK:
      options->padding_mode_set = TRUE;

      gimp_display_shell_set_padding (shell, GIMP_CANVAS_PADDING_MODE_CUSTOM,
                                      color);
      /* fallthru */

    case COLOR_NOTEBOOK_CANCEL:
      g_object_set_data (G_OBJECT (shell), "padding-color-notebook", NULL);
      break;

    default:
      break;
    }
}

void
view_padding_color_cmd_callback (GtkAction *action,
                                 gint       value,
                                 gpointer   data)
{
  GimpDisplay        *gdisp;
  GimpDisplayShell   *shell;
  GimpDisplayOptions *options;
  gboolean            fullscreen;
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

  fullscreen = gimp_display_shell_get_fullscreen (shell);

  if (fullscreen)
    options = shell->fullscreen_options;
  else
    options = shell->options;

  switch ((GimpCanvasPaddingMode) value)
    {
    case GIMP_CANVAS_PADDING_MODE_DEFAULT:
    case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
    case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
      g_object_set_data (G_OBJECT (shell), "padding-color-notebook", NULL);

      options->padding_mode_set = TRUE;

      gimp_display_shell_set_padding (shell, (GimpCanvasPaddingMode) value,
                                      &options->padding_color);
      break;

    case GIMP_CANVAS_PADDING_MODE_CUSTOM:
      {
        ColorNotebook *color_notebook;

        color_notebook = g_object_get_data (G_OBJECT (shell),
                                            "padding-color-notebook");

        if (! color_notebook)
          {
            color_notebook = color_notebook_new (GIMP_VIEWABLE (gdisp->gimage),
                                                 _("Set Canvas Padding Color"),
                                                 GTK_STOCK_SELECT_COLOR,
                                                 NULL,
                                                 gdisp->shell,
                                                 NULL, NULL,
                                                 &options->padding_color,
                                                 view_padding_color_callback,
                                                 shell,
                                                 FALSE, FALSE);
            g_object_set_data_full (G_OBJECT (shell), "padding-color-notebook",
                                    color_notebook,
                                    (GDestroyNotify) color_notebook_free);
          }

        color_notebook_show (color_notebook);
      }
      break;

    case GIMP_CANVAS_PADDING_MODE_RESET:
      g_object_set_data (G_OBJECT (shell), "padding-color-notebook", NULL);

      {
        GimpDisplayConfig  *config;
        GimpDisplayOptions *default_options;

        config = GIMP_DISPLAY_CONFIG (gdisp->gimage->gimp->config);

        options->padding_mode_set = FALSE;

        if (fullscreen)
          default_options = config->default_fullscreen_view;
        else
          default_options = config->default_view;

        gimp_display_shell_set_padding (shell,
                                        default_options->padding_mode,
                                        &default_options->padding_color);
      }
      break;
    }
}

Michael Natterer's avatar
Michael Natterer committed
549
void
550
view_shrink_wrap_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
551 552
			       gpointer   data)
{
553
  GimpDisplay *gdisp;
Michael Natterer's avatar
Michael Natterer committed
554
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
555

Michael Natterer's avatar
Michael Natterer committed
556
  gimp_display_shell_scale_shrink_wrap (GIMP_DISPLAY_SHELL (gdisp->shell));
Michael Natterer's avatar
Michael Natterer committed
557
}
558 559

void
560
view_fullscreen_cmd_callback (GtkAction *action,
561 562 563 564
			      gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
565
  gboolean          active;
566 567 568 569 570
  gboolean          fullscreen;
  return_if_no_display (gdisp, data);

  shell = GIMP_DISPLAY_SHELL (gdisp->shell);

571 572 573
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_fullscreen (shell, active);
574 575 576

  fullscreen = (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;

577
  if (active != fullscreen)
578
    {
579
      SET_ACTIVE (shell->menubar_manager, "view-fullscreen",
580
                  fullscreen);
581 582

      if (IS_ACTIVE_DISPLAY (gdisp))
583
        SET_ACTIVE (shell->popup_manager, "view-fullscreen",
584
                    fullscreen);
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
    }
}

static void
view_change_screen_confirm_callback (GtkWidget *query_box,
                                     gint       value,
                                     gpointer   data)
{
  GdkScreen *screen;

  screen = gdk_display_get_screen (gtk_widget_get_display (GTK_WIDGET (data)),
                                   value);

  if (screen)
    gtk_window_set_screen (GTK_WINDOW (data), screen);
}

static void
view_change_screen_destroy_callback (GtkWidget *query_box,
                                     GtkWidget *shell)
{
  g_object_set_data (G_OBJECT (shell), "gimp-change-screen-dialog", NULL);
}

void
610
view_change_screen_cmd_callback (GtkAction *action,
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
                                 gpointer   data)
{
  GimpDisplay *gdisp;
  GdkScreen   *screen;
  GdkDisplay  *display;
  gint         cur_screen;
  gint         num_screens;
  GtkWidget   *qbox;
  return_if_no_display (gdisp, data);

  qbox = g_object_get_data (G_OBJECT (gdisp->shell),
                            "gimp-change-screen-dialog");

  if (qbox)
    {
      gtk_window_present (GTK_WINDOW (qbox));
      return;
    }

  screen  = gtk_widget_get_screen (gdisp->shell);
  display = gtk_widget_get_display (gdisp->shell);

  cur_screen  = gdk_screen_get_number (screen);
  num_screens = gdk_display_get_n_screens (display);

  qbox = gimp_query_int_box ("Move Display to Screen",
                             gdisp->shell,
                             NULL, 0,
639
                             "Enter destination screen",
640 641 642 643 644 645 646 647 648 649 650 651 652
                             cur_screen, 0, num_screens - 1,
                             G_OBJECT (gdisp->shell), "destroy",
                             view_change_screen_confirm_callback,
                             gdisp->shell);

  g_object_set_data (G_OBJECT (gdisp->shell), "gimp-change-screen-dialog", qbox);

  g_signal_connect (qbox, "destroy",
                    G_CALLBACK (view_change_screen_destroy_callback),
                    gdisp->shell);

  gtk_widget_show (qbox);
}