view-commands.c 19.1 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-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));
Michael Natterer's avatar
Michael Natterer committed
109 110
}

111
void
112 113 114
view_zoom_cmd_callback (GtkAction *action,
                        gint       value,
                        gpointer   data)
115
{
116
  GimpDisplay      *display;
117
  GimpDisplayShell *shell;
118
  return_if_no_display (display, data);
119

120
  shell = GIMP_DISPLAY_SHELL (display->shell);
121

122 123 124
  switch ((GimpActionSelectType) value)
    {
    case GIMP_ACTION_SELECT_FIRST:
125
      gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MAX, 0.0);
126 127 128
      break;

    case GIMP_ACTION_SELECT_LAST:
129
      gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MAX, 0.0);
130 131 132 133 134 135 136 137 138 139 140
      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:
141
      gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MORE, 0.0);
142 143 144
      break;

    case GIMP_ACTION_SELECT_SKIP_NEXT:
145
      gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MORE, 0.0);
146 147 148
      break;

    default:
149 150 151 152 153 154 155 156 157 158 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,
                                     1.0, 16.0,
                                     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;
      }
165
    }
166 167
}

Michael Natterer's avatar
Michael Natterer committed
168
void
169 170 171
view_zoom_explicit_cmd_callback (GtkAction *action,
                                 GtkAction *current,
                                 gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
172
{
173
  GimpDisplay      *display;
174
  GimpDisplayShell *shell;
175
  gint              value;
176
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
177

178
  shell = GIMP_DISPLAY_SHELL (display->shell);
179

180
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
181

182
  if (value != 0 /* not Other... */)
183
    {
184
      if (fabs (value - gimp_zoom_model_get_factor (shell->zoom)) > 0.0001)
185 186
        gimp_display_shell_scale (shell, GIMP_ZOOM_TO, (gdouble) value / 10000);
    }
187 188
}

189 190 191 192
void
view_zoom_other_cmd_callback (GtkAction *action,
                              gpointer   data)
{
193
  GimpDisplay      *display;
194
  GimpDisplayShell *shell;
195
  return_if_no_display (display, data);
196

197
  shell = GIMP_DISPLAY_SHELL (display->shell);
198 199 200 201 202

  /* check if we are activated by the user or from
   * view_actions_set_zoom()
   */
  if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) &&
203
      shell->other_scale != gimp_zoom_model_get_factor (shell->zoom))
204 205 206 207 208
    {
      gimp_display_shell_scale_dialog (shell);
    }
}

Michael Natterer's avatar
Michael Natterer committed
209
void
210
view_dot_for_dot_cmd_callback (GtkAction *action,
211
                               gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
212
{
213
  GimpDisplay      *display;
214
  GimpDisplayShell *shell;
215
  gboolean          active;
216
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
217

218
  shell = GIMP_DISPLAY_SHELL (display->shell);
219

220 221 222
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  if (active != shell->dot_for_dot)
223
    {
224
      gimp_display_shell_scale_set_dot_for_dot (shell, active);
225

226
      SET_ACTIVE (shell->menubar_manager, "view-dot-for-dot",
227
                  shell->dot_for_dot);
228

229
      if (IS_ACTIVE_DISPLAY (display))
230
        SET_ACTIVE (shell->popup_manager, "view-dot-for-dot",
231
                    shell->dot_for_dot);
232
    }
Michael Natterer's avatar
Michael Natterer committed
233 234
}

235 236 237 238 239
void
view_scroll_horizontal_cmd_callback (GtkAction *action,
                                     gint       value,
                                     gpointer   data)
{
240
  GimpDisplay      *display;
241 242
  GimpDisplayShell *shell;
  gdouble           offset;
243
  return_if_no_display (display, data);
244

245
  shell = GIMP_DISPLAY_SHELL (display->shell);
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262

  offset = action_select_value ((GimpActionSelectType) value,
                                shell->hsbdata->value,
                                shell->hsbdata->lower,
                                shell->hsbdata->upper -
                                shell->hsbdata->page_size,
                                shell->hsbdata->step_increment,
                                shell->hsbdata->page_increment,
                                FALSE);
  gtk_adjustment_set_value (shell->hsbdata, offset);
}

void
view_scroll_vertical_cmd_callback (GtkAction *action,
                                   gint       value,
                                   gpointer   data)
{
263
  GimpDisplay      *display;
264 265
  GimpDisplayShell *shell;
  gdouble           offset;
266
  return_if_no_display (display, data);
267

268
  shell = GIMP_DISPLAY_SHELL (display->shell);
269 270 271 272 273 274 275 276 277 278 279 280

  offset = action_select_value ((GimpActionSelectType) value,
                                shell->vsbdata->value,
                                shell->vsbdata->lower,
                                shell->vsbdata->upper -
                                shell->vsbdata->page_size,
                                shell->vsbdata->step_increment,
                                shell->vsbdata->page_increment,
                                FALSE);
  gtk_adjustment_set_value (shell->vsbdata, offset);
}

Michael Natterer's avatar
Michael Natterer committed
281
void
282
view_navigation_window_cmd_callback (GtkAction *action,
283
                                     gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
284
{
285
  GimpDisplay      *display;
Michael Natterer's avatar
Michael Natterer committed
286
  GimpDisplayShell *shell;
287
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
288

289
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
290

Michael Natterer's avatar
Michael Natterer committed
291
  gimp_dialog_factory_dialog_raise (global_dock_factory,
292
                                    gtk_widget_get_screen (display->shell),
Michael Natterer's avatar
Michael Natterer committed
293
                                    "gimp-navigation-view", -1);
Michael Natterer's avatar
Michael Natterer committed
294 295
}

296
void
297
view_display_filters_cmd_callback (GtkAction *action,
298 299
                                   gpointer   data)
{
300
  GimpDisplay      *display;
301
  GimpDisplayShell *shell;
302
  return_if_no_display (display, data);
303

304
  shell = GIMP_DISPLAY_SHELL (display->shell);
305

306 307 308 309 310 311 312 313 314 315
  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));
316 317
}

Michael Natterer's avatar
Michael Natterer committed
318
void
319
view_toggle_selection_cmd_callback (GtkAction *action,
320
                                    gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
321
{
322
  GimpDisplay      *display;
323
  GimpDisplayShell *shell;
324
  gboolean          active;
325
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
326

327
  shell = GIMP_DISPLAY_SHELL (display->shell);
328

329 330 331
  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
332 333 334
}

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

343
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
344

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

350
void
351
view_toggle_menubar_cmd_callback (GtkAction *action,
352 353
                                  gpointer   data)
{
354
  GimpDisplay      *display;
355
  GimpDisplayShell *shell;
356
  gboolean          active;
357
  return_if_no_display (display, data);
358

359
  shell = GIMP_DISPLAY_SHELL (display->shell);
360

361 362 363
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_menubar (shell, active);
364 365
}

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

375
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
376

377 378 379
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_show_rulers (shell, active);
380
}
381

382
void
383
view_toggle_scrollbars_cmd_callback (GtkAction *action,
384 385
                                     gpointer   data)
{
386
  GimpDisplay      *display;
387
  GimpDisplayShell *shell;
388
  gboolean          active;
389
  return_if_no_display (display, data);
390

391
  shell = GIMP_DISPLAY_SHELL (display->shell);
392

393 394 395
  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
396 397 398
}

void
399
view_toggle_statusbar_cmd_callback (GtkAction *action,
400
                                    gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
401
{
402
  GimpDisplay      *display;
Michael Natterer's avatar
Michael Natterer committed
403
  GimpDisplayShell *shell;
404
  gboolean          active;
405
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
406

407
  shell = GIMP_DISPLAY_SHELL (display->shell);
Michael Natterer's avatar
Michael Natterer committed
408

409 410 411
  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
412 413 414
}

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

423
  shell = GIMP_DISPLAY_SHELL (display->shell);
424

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

430
void
431 432
view_toggle_grid_cmd_callback (GtkAction *action,
                               gpointer   data)
433
{
434
  GimpDisplay      *display;
435 436
  GimpDisplayShell *shell;
  gboolean          active;
437
  return_if_no_display (display, data);
438

439
  shell = GIMP_DISPLAY_SHELL (display->shell);
440 441 442

  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

443
  gimp_display_shell_set_show_grid (shell, active);
444 445
}

Michael Natterer's avatar
Michael Natterer committed
446
void
447 448
view_toggle_sample_points_cmd_callback (GtkAction *action,
                                        gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
449
{
450
  GimpDisplay      *display;
451
  GimpDisplayShell *shell;
452
  gboolean          active;
453
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
454

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

457
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
458

459
  gimp_display_shell_set_show_sample_points (shell, active);
Michael Natterer's avatar
Michael Natterer committed
460 461
}

462
void
463 464
view_snap_to_guides_cmd_callback (GtkAction *action,
                                  gpointer   data)
465
{
466
  GimpDisplay      *display;
467
  GimpDisplayShell *shell;
468
  gboolean          active;
469
  return_if_no_display (display, data);
470

471
  shell = GIMP_DISPLAY_SHELL (display->shell);
472

473
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
474

475
  gimp_display_shell_set_snap_to_guides (shell, active);
476 477 478
}

void
479
view_snap_to_grid_cmd_callback (GtkAction *action,
480 481
                                gpointer   data)
{
482
  GimpDisplay      *display;
483
  GimpDisplayShell *shell;
484
  gboolean          active;
485
  return_if_no_display (display, data);
486

487
  shell = GIMP_DISPLAY_SHELL (display->shell);
488

489
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
490

491
  gimp_display_shell_set_snap_to_grid (shell, active);
492 493
}

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

503
  shell = GIMP_DISPLAY_SHELL (display->shell);
504 505 506 507 508 509 510 511 512 513

  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)
{
514
  GimpDisplay      *display;
515 516
  GimpDisplayShell *shell;
  gboolean          active;
517
  return_if_no_display (display, data);
518

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

  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  gimp_display_shell_set_snap_to_vectors (shell, active);
}

526 527 528 529 530
void
view_padding_color_cmd_callback (GtkAction *action,
                                 gint       value,
                                 gpointer   data)
{
531
  GimpDisplay        *display;
532 533 534
  GimpDisplayShell   *shell;
  GimpDisplayOptions *options;
  gboolean            fullscreen;
535
  return_if_no_display (display, data);
536

537
  shell = GIMP_DISPLAY_SHELL (display->shell);
538 539 540 541 542 543 544 545 546 547 548 549 550

  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:
551
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
552 553 554 555 556 557 558 559 560

      options->padding_mode_set = TRUE;

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

    case GIMP_CANVAS_PADDING_MODE_CUSTOM:
      {
561
        GtkWidget *color_dialog;
562

563
        color_dialog = g_object_get_data (G_OBJECT (shell),
564
                                          "padding-color-dialog");
565

566
        if (! color_dialog)
567
          {
568
            color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (display->image),
569 570 571
                                                  _("Set Canvas Padding Color"),
                                                  GTK_STOCK_SELECT_COLOR,
                                                  _("Set Custom Canvas Padding Color"),
572
                                                  display->shell,
573 574 575 576 577 578
                                                  NULL, NULL,
                                                  &options->padding_color,
                                                  FALSE, FALSE);

            g_signal_connect (color_dialog, "update",
                              G_CALLBACK (view_padding_color_dialog_update),
579
                              display->shell);
580

581 582
            g_object_set_data_full (G_OBJECT (shell), "padding-color-dialog",
                                    color_dialog,
583
                                    (GDestroyNotify) gtk_widget_destroy);
584 585
          }

586
        gtk_window_present (GTK_WINDOW (color_dialog));
587 588 589 590
      }
      break;

    case GIMP_CANVAS_PADDING_MODE_RESET:
591
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
592 593 594 595 596

      {
        GimpDisplayConfig  *config;
        GimpDisplayOptions *default_options;

597
        config = GIMP_DISPLAY_CONFIG (display->image->gimp->config);
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613

        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
614
void
615
view_shrink_wrap_cmd_callback (GtkAction *action,
616
                               gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
617
{
618 619
  GimpDisplay *display;
  return_if_no_display (display, data);
Michael Natterer's avatar
Michael Natterer committed
620

621
  gimp_display_shell_scale_shrink_wrap (GIMP_DISPLAY_SHELL (display->shell));
Michael Natterer's avatar
Michael Natterer committed
622
}
623 624

void
625
view_fullscreen_cmd_callback (GtkAction *action,
626
                              gpointer   data)
627
{
628
  GimpDisplay      *display;
629
  GimpDisplayShell *shell;
630
  gboolean          active;
631
  return_if_no_display (display, data);
632

633
  shell = GIMP_DISPLAY_SHELL (display->shell);
634

635 636 637
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

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

/*  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;
    }
}