view-commands.c 19.4 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
Michael Natterer's avatar
Michael Natterer committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * 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-close.h"
39
#include "display/gimpdisplayshell-filter-dialog.h"
40
#include "display/gimpdisplayshell-scale.h"
41

42
#include "widgets/gimpactiongroup.h"
43
#include "widgets/gimpcolordialog.h"
44
#include "widgets/gimpdock.h"
45
#include "widgets/gimpdialogfactory.h"
46
#include "widgets/gimpuimanager.h"
47

48
#include "dialogs/dialogs.h"
Michael Natterer's avatar
Michael Natterer committed
49

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

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

55 56

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

61 62 63
#define IS_ACTIVE_DISPLAY(display) \
  ((display) == \
   gimp_context_get_display (gimp_get_user_context ((display)->image->gimp)))
64

Michael Natterer's avatar
Michael Natterer committed
65

66 67
/*  local function prototypes  */

68 69 70 71
static void   view_padding_color_dialog_update (GimpColorDialog      *dialog,
                                                const GimpRGB        *color,
                                                GimpColorDialogState  state,
                                                GimpDisplayShell     *shell);
72 73


74 75
/*  public functions  */

76
void
77 78
view_new_cmd_callback (GtkAction *action,
                       gpointer   data)
79
{
80
  GimpDisplay      *display;
81
  GimpDisplayShell *shell;
82
  return_if_no_display (display, data);
83

84
  shell = GIMP_DISPLAY_SHELL (display->shell);
85

86 87
  gimp_create_display (display->image->gimp,
                       display->image,
88
                       shell->unit, gimp_zoom_model_get_factor (shell->zoom));
89 90
}

Michael Natterer's avatar
Michael Natterer committed
91
void
92 93
view_zoom_fit_in_cmd_callback (GtkAction *action,
                               gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
94
{
95 96
  GimpDisplay *display;
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
97

98
  gimp_display_shell_scale_fit_in (GIMP_DISPLAY_SHELL (display->shell));
Michael Natterer's avatar
Michael Natterer committed
99 100 101
}

void
102 103
view_zoom_fit_to_cmd_callback (GtkAction *action,
                               gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
104
{
105 106
  GimpDisplay *display;
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
107

108
  gimp_display_shell_scale_fit_to (GIMP_DISPLAY_SHELL (display->shell));
109 110 111 112 113 114 115 116 117 118
}

void
view_zoom_revert_cmd_callback (GtkAction *action,
                               gpointer   data)
{
  GimpDisplay *display;
  return_if_no_display (display, data);

  gimp_display_shell_scale_revert (GIMP_DISPLAY_SHELL (display->shell));
Michael Natterer's avatar
Michael Natterer committed
119 120
}

121
void
122 123 124
view_zoom_cmd_callback (GtkAction *action,
                        gint       value,
                        gpointer   data)
125
{
126
  GimpDisplay      *display;
127
  GimpDisplayShell *shell;
128
  return_if_no_display (display, data);
129

130
  shell = GIMP_DISPLAY_SHELL (display->shell);
131

132 133 134
  switch ((GimpActionSelectType) value)
    {
    case GIMP_ACTION_SELECT_FIRST:
135
      gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MAX, 0.0);
136 137 138
      break;

    case GIMP_ACTION_SELECT_LAST:
139
      gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MAX, 0.0);
140 141 142 143 144 145 146 147 148 149 150
      break;

    case GIMP_ACTION_SELECT_PREVIOUS:
      gimp_display_shell_scale (shell, GIMP_ZOOM_OUT, 0.0);
      break;

    case GIMP_ACTION_SELECT_NEXT:
      gimp_display_shell_scale (shell, GIMP_ZOOM_IN, 0.0);
      break;

    case GIMP_ACTION_SELECT_SKIP_PREVIOUS:
151
      gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MORE, 0.0);
152 153 154
      break;

    case GIMP_ACTION_SELECT_SKIP_NEXT:
155
      gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MORE, 0.0);
156 157 158
      break;

    default:
159 160 161 162 163 164
      {
        gdouble scale = gimp_zoom_model_get_factor (shell->zoom);

        scale = action_select_value ((GimpActionSelectType) value,
                                     scale,
                                     0.0, 512.0,
165
                                     1.0 / 8.0, 1.0, 16.0, 0.0,
166 167 168 169 170 171 172 173 174
                                     FALSE);

        /* min = 1.0 / 256,  max = 256.0                */
        /* scale = min *  (max / min)**(i/n), i = 0..n  */
        scale = pow (65536.0, scale / 512.0) / 256.0;

        gimp_display_shell_scale (shell, GIMP_ZOOM_TO, scale);
        break;
      }
175
    }
176 177
}

Michael Natterer's avatar
Michael Natterer committed
178
void
179 180 181
view_zoom_explicit_cmd_callback (GtkAction *action,
                                 GtkAction *current,
                                 gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
182
{
183
  GimpDisplay      *display;
184
  GimpDisplayShell *shell;
185
  gint              value;
186
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
187

188
  shell = GIMP_DISPLAY_SHELL (display->shell);
189

190
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
191

192
  if (value != 0 /* not Other... */)
193
    {
194
      if (fabs (value - gimp_zoom_model_get_factor (shell->zoom)) > 0.0001)
195 196
        gimp_display_shell_scale (shell, GIMP_ZOOM_TO, (gdouble) value / 10000);
    }
197 198
}

199 200 201 202
void
view_zoom_other_cmd_callback (GtkAction *action,
                              gpointer   data)
{
203
  GimpDisplay      *display;
204
  GimpDisplayShell *shell;
205
  return_if_no_display (display, data);
206

207
  shell = GIMP_DISPLAY_SHELL (display->shell);
208 209 210 211 212

  /* check if we are activated by the user or from
   * view_actions_set_zoom()
   */
  if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) &&
213
      shell->other_scale != gimp_zoom_model_get_factor (shell->zoom))
214 215 216 217 218
    {
      gimp_display_shell_scale_dialog (shell);
    }
}

Michael Natterer's avatar
Michael Natterer committed
219
void
220
view_dot_for_dot_cmd_callback (GtkAction *action,
221
                               gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
222
{
223
  GimpDisplay      *display;
224
  GimpDisplayShell *shell;
225
  gboolean          active;
226
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
227

228
  shell = GIMP_DISPLAY_SHELL (display->shell);
229

230 231 232
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  if (active != shell->dot_for_dot)
233
    {
234
      gimp_display_shell_scale_set_dot_for_dot (shell, active);
235

236
      SET_ACTIVE (shell->menubar_manager, "view-dot-for-dot",
237
                  shell->dot_for_dot);
238

239
      if (IS_ACTIVE_DISPLAY (display))
240
        SET_ACTIVE (shell->popup_manager, "view-dot-for-dot",
241
                    shell->dot_for_dot);
242
    }
Michael Natterer's avatar
Michael Natterer committed
243 244
}

245 246 247 248 249
void
view_scroll_horizontal_cmd_callback (GtkAction *action,
                                     gint       value,
                                     gpointer   data)
{
250
  GimpDisplay      *display;
251 252
  GimpDisplayShell *shell;
  gdouble           offset;
253
  return_if_no_display (display, data);
254

255
  shell = GIMP_DISPLAY_SHELL (display->shell);
256 257 258 259 260 261

  offset = action_select_value ((GimpActionSelectType) value,
                                shell->hsbdata->value,
                                shell->hsbdata->lower,
                                shell->hsbdata->upper -
                                shell->hsbdata->page_size,
262
                                1,
263 264
                                shell->hsbdata->step_increment,
                                shell->hsbdata->page_increment,
265
                                0,
266 267 268 269 270 271 272 273 274
                                FALSE);
  gtk_adjustment_set_value (shell->hsbdata, offset);
}

void
view_scroll_vertical_cmd_callback (GtkAction *action,
                                   gint       value,
                                   gpointer   data)
{
275
  GimpDisplay      *display;
276 277
  GimpDisplayShell *shell;
  gdouble           offset;
278
  return_if_no_display (display, data);
279

280
  shell = GIMP_DISPLAY_SHELL (display->shell);
281 282 283 284 285 286

  offset = action_select_value ((GimpActionSelectType) value,
                                shell->vsbdata->value,
                                shell->vsbdata->lower,
                                shell->vsbdata->upper -
                                shell->vsbdata->page_size,
287
                                1,
288 289
                                shell->vsbdata->step_increment,
                                shell->vsbdata->page_increment,
290
                                0,
291 292 293 294
                                FALSE);
  gtk_adjustment_set_value (shell->vsbdata, offset);
}

Michael Natterer's avatar
Michael Natterer committed
295
void
296
view_navigation_window_cmd_callback (GtkAction *action,
297
                                     gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
298
{
299
  GimpDisplay      *display;
Michael Natterer's avatar
Michael Natterer committed
300
  GimpDisplayShell *shell;
301
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
302

303
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
304

Michael Natterer's avatar
Michael Natterer committed
305
  gimp_dialog_factory_dialog_raise (global_dock_factory,
306
                                    gtk_widget_get_screen (display->shell),
Michael Natterer's avatar
Michael Natterer committed
307
                                    "gimp-navigation-view", -1);
Michael Natterer's avatar
Michael Natterer committed
308 309
}

310
void
311
view_display_filters_cmd_callback (GtkAction *action,
312 313
                                   gpointer   data)
{
314
  GimpDisplay      *display;
315
  GimpDisplayShell *shell;
316
  return_if_no_display (display, data);
317

318
  shell = GIMP_DISPLAY_SHELL (display->shell);
319

320 321 322 323 324 325 326 327 328 329
  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));
330 331
}

Michael Natterer's avatar
Michael Natterer committed
332
void
333
view_toggle_selection_cmd_callback (GtkAction *action,
334
                                    gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
335
{
336
  GimpDisplay      *display;
337
  GimpDisplayShell *shell;
338
  gboolean          active;
339
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
340

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

343 344 345
  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
346 347 348
}

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

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

359 360 361
  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
362 363
}

364
void
365
view_toggle_menubar_cmd_callback (GtkAction *action,
366 367
                                  gpointer   data)
{
368
  GimpDisplay      *display;
369
  GimpDisplayShell *shell;
370
  gboolean          active;
371
  return_if_no_display (display, data);
372

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

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

  gimp_display_shell_set_show_menubar (shell, active);
378 379
}

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

389
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
390

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

  gimp_display_shell_set_show_rulers (shell, active);
394
}
395

396
void
397
view_toggle_scrollbars_cmd_callback (GtkAction *action,
398 399
                                     gpointer   data)
{
400
  GimpDisplay      *display;
401
  GimpDisplayShell *shell;
402
  gboolean          active;
403
  return_if_no_display (display, data);
404

405
  shell = GIMP_DISPLAY_SHELL (display->shell);
406

407 408 409
  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
410 411 412
}

void
413
view_toggle_statusbar_cmd_callback (GtkAction *action,
414
                                    gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
415
{
416
  GimpDisplay      *display;
Michael Natterer's avatar
Michael Natterer committed
417
  GimpDisplayShell *shell;
418
  gboolean          active;
419
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
420

421
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
422

423 424 425
  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
426 427 428
}

void
429
view_toggle_guides_cmd_callback (GtkAction *action,
430
                                 gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
431
{
432
  GimpDisplay      *display;
433
  GimpDisplayShell *shell;
434
  gboolean          active;
435
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
436

437
  shell = GIMP_DISPLAY_SHELL (display->shell);
438

439 440 441
  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
442 443
}

444
void
445 446
view_toggle_grid_cmd_callback (GtkAction *action,
                               gpointer   data)
447
{
448
  GimpDisplay      *display;
449 450
  GimpDisplayShell *shell;
  gboolean          active;
451
  return_if_no_display (display, data);
452

453
  shell = GIMP_DISPLAY_SHELL (display->shell);
454 455 456

  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

457
  gimp_display_shell_set_show_grid (shell, active);
458 459
}

Michael Natterer's avatar
Michael Natterer committed
460
void
461 462
view_toggle_sample_points_cmd_callback (GtkAction *action,
                                        gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
463
{
464
  GimpDisplay      *display;
465
  GimpDisplayShell *shell;
466
  gboolean          active;
467
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
468

469
  shell = GIMP_DISPLAY_SHELL (display->shell);
470

471
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
472

473
  gimp_display_shell_set_show_sample_points (shell, active);
Michael Natterer's avatar
Michael Natterer committed
474 475
}

476
void
477 478
view_snap_to_guides_cmd_callback (GtkAction *action,
                                  gpointer   data)
479
{
480
  GimpDisplay      *display;
481
  GimpDisplayShell *shell;
482
  gboolean          active;
483
  return_if_no_display (display, data);
484

485
  shell = GIMP_DISPLAY_SHELL (display->shell);
486

487
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
488

489
  gimp_display_shell_set_snap_to_guides (shell, active);
490 491 492
}

void
493
view_snap_to_grid_cmd_callback (GtkAction *action,
494 495
                                gpointer   data)
{
496
  GimpDisplay      *display;
497
  GimpDisplayShell *shell;
498
  gboolean          active;
499
  return_if_no_display (display, data);
500

501
  shell = GIMP_DISPLAY_SHELL (display->shell);
502

503
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
504

505
  gimp_display_shell_set_snap_to_grid (shell, active);
506 507
}

508 509 510 511
void
view_snap_to_canvas_cmd_callback (GtkAction *action,
                                  gpointer   data)
{
512
  GimpDisplay      *display;
513 514
  GimpDisplayShell *shell;
  gboolean          active;
515
  return_if_no_display (display, data);
516

517
  shell = GIMP_DISPLAY_SHELL (display->shell);
518 519 520 521 522 523 524 525 526 527

  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_snap_to_canvas (shell, active);
}

void
view_snap_to_vectors_cmd_callback (GtkAction *action,
                                   gpointer   data)
{
528
  GimpDisplay      *display;
529 530
  GimpDisplayShell *shell;
  gboolean          active;
531
  return_if_no_display (display, data);
532

533
  shell = GIMP_DISPLAY_SHELL (display->shell);
534 535 536 537 538 539

  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_snap_to_vectors (shell, active);
}

540 541 542 543 544
void
view_padding_color_cmd_callback (GtkAction *action,
                                 gint       value,
                                 gpointer   data)
{
545
  GimpDisplay        *display;
546 547 548
  GimpDisplayShell   *shell;
  GimpDisplayOptions *options;
  gboolean            fullscreen;
549
  return_if_no_display (display, data);
550

551
  shell = GIMP_DISPLAY_SHELL (display->shell);
552 553 554 555 556 557 558 559 560 561 562 563 564

  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:
565
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
566 567 568 569 570 571 572 573 574

      options->padding_mode_set = TRUE;

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

    case GIMP_CANVAS_PADDING_MODE_CUSTOM:
      {
575
        GtkWidget *color_dialog;
576

577
        color_dialog = g_object_get_data (G_OBJECT (shell),
578
                                          "padding-color-dialog");
579

580
        if (! color_dialog)
581
          {
582 583 584 585 586 587 588 589 590 591
            color_dialog =
              gimp_color_dialog_new (GIMP_VIEWABLE (display->image),
                                     action_data_get_context (data),
                                     _("Set Canvas Padding Color"),
                                     GTK_STOCK_SELECT_COLOR,
                                     _("Set Custom Canvas Padding Color"),
                                     display->shell,
                                     NULL, NULL,
                                     &options->padding_color,
                                     FALSE, FALSE);
592 593 594

            g_signal_connect (color_dialog, "update",
                              G_CALLBACK (view_padding_color_dialog_update),
595
                              display->shell);
596

597 598
            g_object_set_data_full (G_OBJECT (shell), "padding-color-dialog",
                                    color_dialog,
599
                                    (GDestroyNotify) gtk_widget_destroy);
600 601
          }

602
        gtk_window_present (GTK_WINDOW (color_dialog));
603 604 605 606
      }
      break;

    case GIMP_CANVAS_PADDING_MODE_RESET:
607
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
608 609 610 611 612

      {
        GimpDisplayConfig  *config;
        GimpDisplayOptions *default_options;

613
        config = GIMP_DISPLAY_CONFIG (display->image->gimp->config);
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629

        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
630
void
631
view_shrink_wrap_cmd_callback (GtkAction *action,
632
                               gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
633
{
634 635
  GimpDisplay *display;
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
636

637
  gimp_display_shell_scale_shrink_wrap (GIMP_DISPLAY_SHELL (display->shell));
Michael Natterer's avatar
Michael Natterer committed
638
}
639 640

void
641
view_fullscreen_cmd_callback (GtkAction *action,
642
                              gpointer   data)
643
{
644
  GimpDisplay      *display;
645
  GimpDisplayShell *shell;
646
  gboolean          active;
647
  return_if_no_display (display, data);
648

649
  shell = GIMP_DISPLAY_SHELL (display->shell);
650

651 652 653
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_fullscreen (shell, active);
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

/*  private functions  */

static void
view_padding_color_dialog_update (GimpColorDialog      *dialog,
                                  const GimpRGB        *color,
                                  GimpColorDialogState  state,
                                  GimpDisplayShell     *shell)
{
  GimpDisplayOptions *options;
  gboolean            fullscreen;

  fullscreen = gimp_display_shell_get_fullscreen (shell);

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

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

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

    case GIMP_COLOR_DIALOG_CANCEL:
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
      break;

    default:
      break;
    }
}