view-actions.c 20.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* 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>

23
#include "libgimpcolor/gimpcolor.h"
24 25 26 27 28 29 30 31 32 33 34
#include "libgimpwidgets/gimpwidgets.h"

#include "actions-types.h"

#include "config/gimpguiconfig.h"

#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"

#include "widgets/gimpactiongroup.h"
35
#include "widgets/gimprender.h"
36
#include "widgets/gimphelp-ids.h"
37
#include "widgets/gimpwidgets-utils.h"
38 39 40 41 42 43 44

#include "display/gimpdisplay.h"
#include "display/gimpdisplayoptions.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-selection.h"

45
#include "actions.h"
46
#include "view-actions.h"
Michael Natterer's avatar
Michael Natterer committed
47
#include "view-commands.h"
48
#include "window-actions.h"
49 50 51 52 53 54

#include "gimp-intl.h"


/*  local function prototypes  */

55 56 57 58 59
static void   view_actions_set_zoom          (GimpActionGroup   *group,
                                              GimpDisplayShell  *shell);
static void   view_actions_check_type_notify (GimpDisplayConfig *config,
                                              GParamSpec        *pspec,
                                              GimpActionGroup   *group);
60 61 62 63


static GimpActionEntry view_actions[] =
{
64 65 66 67 68 69
  { "view-menu",                NULL, N_("_View")          },
  { "view-zoom-menu",           NULL, N_("_Zoom")          },
  { "view-padding-color-menu",  NULL, N_("_Padding Color") },
  { "view-move-to-screen-menu", GIMP_STOCK_MOVE_TO_SCREEN,
    N_("Move to Screen"), NULL, NULL, NULL,
    GIMP_HELP_VIEW_CHANGE_SCREEN },
70 71 72

  { "view-new", GTK_STOCK_NEW,
    N_("_New View"), "", NULL,
73
    G_CALLBACK (view_new_cmd_callback),
74 75
    GIMP_HELP_VIEW_NEW },

76 77
  { "view-close", GTK_STOCK_CLOSE,
    N_( "_Close"), "<control>W", NULL,
78
    G_CALLBACK (view_close_cmd_callback),
79 80
    GIMP_HELP_FILE_CLOSE },

81
  { "view-zoom-fit-in", GTK_STOCK_ZOOM_FIT,
82 83
    N_("_Fit Image in Window"), "<control><shift>E",
    N_("Fit image in window"),
84 85 86 87
    G_CALLBACK (view_zoom_fit_in_cmd_callback),
    GIMP_HELP_VIEW_ZOOM_FIT_IN },

  { "view-zoom-fit-to", GTK_STOCK_ZOOM_FIT,
88
    N_("Fit Image _to Window"), NULL,
89
    N_("Fit image to window"),
90 91
    G_CALLBACK (view_zoom_fit_to_cmd_callback),
    GIMP_HELP_VIEW_ZOOM_FIT_TO },
92 93

  { "view-navigation-window", GIMP_STOCK_NAVIGATION,
94
    N_("Na_vigation Window"), NULL, NULL,
95 96 97 98 99 100 101 102
    G_CALLBACK (view_navigation_window_cmd_callback),
    GIMP_HELP_NAVIGATION_DIALOG },

  { "view-display-filters", GIMP_STOCK_DISPLAY_FILTER,
    N_("Display _Filters..."), NULL, NULL,
    G_CALLBACK (view_display_filters_cmd_callback),
    GIMP_HELP_DISPLAY_FILTER_DIALOG },

103 104 105
  { "view-shrink-wrap", GTK_STOCK_ZOOM_FIT,
    N_("Shrink _Wrap"), "<control>E",
    N_("Shrink wrap"),
106
    G_CALLBACK (view_shrink_wrap_cmd_callback),
107
    GIMP_HELP_VIEW_SHRINK_WRAP }
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
};

static GimpToggleActionEntry view_toggle_actions[] =
{
  { "view-dot-for-dot", NULL,
    N_("_Dot for Dot"), NULL, NULL,
    G_CALLBACK (view_dot_for_dot_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_DOT_FOR_DOT },

  { "view-show-selection", NULL,
    N_("Show _Selection"), "<control>T", NULL,
    G_CALLBACK (view_toggle_selection_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_SELECTION },

  { "view-show-layer-boundary", NULL,
    N_("Show _Layer Boundary"), NULL, NULL,
    G_CALLBACK (view_toggle_layer_boundary_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_LAYER_BOUNDARY },

  { "view-show-guides", NULL,
    N_("Show _Guides"), "<control><shift>T", NULL,
    G_CALLBACK (view_toggle_guides_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_GUIDES },

  { "view-show-grid", NULL,
    N_("S_how Grid"), NULL, NULL,
    G_CALLBACK (view_toggle_grid_cmd_callback),
    FALSE,
    GIMP_HELP_VIEW_SHOW_GRID },

142 143 144 145 146 147
  { "view-show-sample-points", NULL,
    N_("Show Sample Points"), NULL, NULL,
    G_CALLBACK (view_toggle_sample_points_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_SAMPLE_POINTS },

148 149 150 151 152 153
  { "view-snap-to-guides", NULL,
    N_("Sn_ap to Guides"), NULL, NULL,
    G_CALLBACK (view_snap_to_guides_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SNAP_TO_GUIDES },

154 155 156 157 158 159
  { "view-snap-to-grid", NULL,
    N_("Sna_p to Grid"), NULL, NULL,
    G_CALLBACK (view_snap_to_grid_cmd_callback),
    FALSE,
    GIMP_HELP_VIEW_SNAP_TO_GRID },

160
  { "view-snap-to-canvas", NULL,
161
    N_("Snap to _Canvas Edges"), NULL, NULL,
162 163 164 165 166
    G_CALLBACK (view_snap_to_canvas_cmd_callback),
    FALSE,
    GIMP_HELP_VIEW_SNAP_TO_CANVAS },

  { "view-snap-to-vectors", NULL,
167
    N_("Snap t_o Active Path"), NULL, NULL,
168 169 170 171
    G_CALLBACK (view_snap_to_vectors_cmd_callback),
    FALSE,
    GIMP_HELP_VIEW_SNAP_TO_VECTORS },

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
  { "view-show-menubar", NULL,
    N_("Show _Menubar"), NULL, NULL,
    G_CALLBACK (view_toggle_menubar_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_MENUBAR },

  { "view-show-rulers", NULL,
    N_("Show R_ulers"), "<control><shift>R", NULL,
    G_CALLBACK (view_toggle_rulers_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_RULERS },

  { "view-show-scrollbars", NULL,
    N_("Show Scroll_bars"), NULL, NULL,
    G_CALLBACK (view_toggle_scrollbars_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_SCROLLBARS },

  { "view-show-statusbar", NULL,
    N_("Show S_tatusbar"), NULL, NULL,
    G_CALLBACK (view_toggle_statusbar_cmd_callback),
    TRUE,
    GIMP_HELP_VIEW_SHOW_STATUSBAR },

  { "view-fullscreen", NULL,
    N_("Fullscr_een"), "F11", NULL,
    G_CALLBACK (view_fullscreen_cmd_callback),
    FALSE,
    GIMP_HELP_VIEW_FULLSCREEN }
};

203 204 205 206
static GimpEnumActionEntry view_zoom_actions[] =
{
  { "view-zoom", NULL,
    "Set zoom factor", NULL, NULL,
207
    GIMP_ACTION_SELECT_SET, TRUE,
208
    NULL },
209 210

  { "view-zoom-minimum", GTK_STOCK_ZOOM_OUT,
211
    "Zoom out as far as possible", NULL, NULL,
212
    GIMP_ACTION_SELECT_FIRST, FALSE,
213 214 215
    GIMP_HELP_VIEW_ZOOM_OUT },

  { "view-zoom-maximum", GTK_STOCK_ZOOM_IN,
216
    "Zoom in as far as possible", NULL, NULL,
217
    GIMP_ACTION_SELECT_LAST, FALSE,
218 219
    GIMP_HELP_VIEW_ZOOM_IN },

220 221 222
  { "view-zoom-out", GTK_STOCK_ZOOM_OUT,
    N_("Zoom _Out"), "minus",
    N_("Zoom out"),
223
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
224
    GIMP_HELP_VIEW_ZOOM_OUT },
225

226 227 228
  { "view-zoom-in", GTK_STOCK_ZOOM_IN,
    N_("Zoom _In"), "plus",
    N_("Zoom in"),
229
    GIMP_ACTION_SELECT_NEXT, FALSE,
230
    GIMP_HELP_VIEW_ZOOM_IN },
231

232
  { "view-zoom-out-accel", GTK_STOCK_ZOOM_OUT,
233 234 235
    N_("Zoom Out"), "KP_Subtract",
    N_("Zoom out"),
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
236
    GIMP_HELP_VIEW_ZOOM_OUT },
237

238
  { "view-zoom-in-accel", GTK_STOCK_ZOOM_IN,
239 240 241
    N_("Zoom in"), "KP_Add",
    N_("Zoom in"),
    GIMP_ACTION_SELECT_NEXT, FALSE,
242
    GIMP_HELP_VIEW_ZOOM_IN },
243

244
  { "view-zoom-out-skip", GTK_STOCK_ZOOM_OUT,
245
    "Zoom out a lot", NULL, NULL,
246
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
247 248 249 250
    GIMP_HELP_VIEW_ZOOM_OUT },

  { "view-zoom-in-skip", GTK_STOCK_ZOOM_IN,
    "Zoom in a lot", NULL, NULL,
251
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
252
    GIMP_HELP_VIEW_ZOOM_IN }
253 254 255
};

static GimpRadioActionEntry view_zoom_explicit_actions[] =
256 257
{
  { "view-zoom-16-1", NULL,
258
    N_("1_6:1  (1600%)"), NULL, NULL,
259 260 261 262
    160000,
    GIMP_HELP_VIEW_ZOOM_IN },

  { "view-zoom-8-1", NULL,
263
    N_("_8:1  (800%)"), NULL, NULL,
264 265 266 267
    80000,
    GIMP_HELP_VIEW_ZOOM_IN },

  { "view-zoom-4-1", NULL,
268
    N_("_4:1  (400%)"), NULL, NULL,
269 270 271 272
    40000,
    GIMP_HELP_VIEW_ZOOM_IN },

  { "view-zoom-2-1", NULL,
273
    N_("_2:1  (200%)"), NULL, NULL,
274 275 276
    20000,
    GIMP_HELP_VIEW_ZOOM_IN },

277
  { "view-zoom-1-1", GTK_STOCK_ZOOM_100,
278
    N_("_1:1  (100%)"), "1",
279
    N_("Zoom 1:1"),
280 281 282 283
    10000,
    GIMP_HELP_VIEW_ZOOM_100 },

  { "view-zoom-1-2", NULL,
284
    N_("1:_2  (50%)"), NULL, NULL,
285 286 287 288
    5000,
    GIMP_HELP_VIEW_ZOOM_OUT },

  { "view-zoom-1-4", NULL,
289
    N_("1:_4  (25%)"), NULL, NULL,
290 291 292 293
    2500,
    GIMP_HELP_VIEW_ZOOM_OUT },

  { "view-zoom-1-8", NULL,
294
    N_("1:_8  (12.5%)"), NULL, NULL,
295 296 297 298
    1250,
    GIMP_HELP_VIEW_ZOOM_OUT },

  { "view-zoom-1-16", NULL,
299
    N_("1:1_6  (6.25%)"), NULL, NULL,
300 301 302 303
    625,
    GIMP_HELP_VIEW_ZOOM_OUT },

  { "view-zoom-other", NULL,
304
    N_("Othe_r..."), NULL, NULL,
305 306 307 308
    0,
    GIMP_HELP_VIEW_ZOOM_OTHER }
};

309 310 311 312
static GimpEnumActionEntry view_padding_color_actions[] =
{
  { "view-padding-color-theme", NULL,
    N_("From _Theme"), NULL, NULL,
313
    GIMP_CANVAS_PADDING_MODE_DEFAULT, FALSE,
314 315 316 317
    GIMP_HELP_VIEW_PADDING_COLOR },

  { "view-padding-color-light-check", NULL,
    N_("_Light Check Color"), NULL, NULL,
318
    GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK, FALSE,
319 320 321 322
    GIMP_HELP_VIEW_PADDING_COLOR },

  { "view-padding-color-dark-check", NULL,
    N_("_Dark Check Color"), NULL, NULL,
323
    GIMP_CANVAS_PADDING_MODE_DARK_CHECK, FALSE,
324 325 326 327
    GIMP_HELP_VIEW_PADDING_COLOR },

  { "view-padding-color-custom", GTK_STOCK_SELECT_COLOR,
    N_("Select _Custom Color..."), NULL, NULL,
328
    GIMP_CANVAS_PADDING_MODE_CUSTOM, FALSE,
329 330 331 332
    GIMP_HELP_VIEW_PADDING_COLOR },

  { "view-padding-color-prefs", GIMP_STOCK_RESET,
    N_("As in _Preferences"), NULL, NULL,
333
    GIMP_CANVAS_PADDING_MODE_RESET, FALSE,
334 335 336
    GIMP_HELP_VIEW_PADDING_COLOR }
};

337 338 339 340
static GimpEnumActionEntry view_scroll_horizontal_actions[] =
{
  { "view-scroll-horizontal", NULL,
    "Set horizontal scroll offset", NULL, NULL,
341
    GIMP_ACTION_SELECT_SET, TRUE,
342
    NULL },
343

344 345
  { "view-scroll-left-border", NULL,
    "Scroll to left border", NULL, NULL,
346
    GIMP_ACTION_SELECT_FIRST, FALSE,
347
    NULL },
348

349 350
  { "view-scroll-right-border", NULL,
    "Scroll to right border", NULL, NULL,
351
    GIMP_ACTION_SELECT_LAST, FALSE,
352
    NULL },
353

354 355
  { "view-scroll-left", NULL,
    "Scroll left", NULL, NULL,
356
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
357
    NULL },
358

359 360
  { "view-scroll-right", NULL,
    "Scroll right", NULL, NULL,
361
    GIMP_ACTION_SELECT_NEXT, FALSE,
362
    NULL },
363

364 365
  { "view-scroll-page-left", NULL,
    "Scroll page left", NULL, NULL,
366
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
367
    NULL },
368

369 370
  { "view-scroll-page-right", NULL,
    "Scroll page right", NULL, NULL,
371
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
372 373 374 375 376 377 378
    NULL }
};

static GimpEnumActionEntry view_scroll_vertical_actions[] =
{
  { "view-scroll-vertical", NULL,
    "Set vertical scroll offset", NULL, NULL,
379
    GIMP_ACTION_SELECT_SET, TRUE,
380
    NULL },
381

382 383
  { "view-scroll-top-border", NULL,
    "Scroll to top border", NULL, NULL,
384
    GIMP_ACTION_SELECT_FIRST, FALSE,
385
    NULL },
386

387 388
  { "view-scroll-bottom-border", NULL,
    "Scroll to bottom border", NULL, NULL,
389
    GIMP_ACTION_SELECT_LAST, FALSE,
390
    NULL },
391

392 393
  { "view-scroll-up", NULL,
    "Scroll up", NULL, NULL,
394
    GIMP_ACTION_SELECT_PREVIOUS, FALSE,
395
    NULL },
396

397 398
  { "view-scroll-down", NULL,
    "Scroll down", NULL, NULL,
399
    GIMP_ACTION_SELECT_NEXT, FALSE,
400
    NULL },
401

402 403
  { "view-scroll-page-up", NULL,
    "Scroll page up", NULL, NULL,
404
    GIMP_ACTION_SELECT_SKIP_PREVIOUS, FALSE,
405
    NULL },
406

407 408
  { "view-scroll-page-down", NULL,
    "Scroll page down", NULL, NULL,
409
    GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
410 411 412
    NULL }
};

413 414

void
415
view_actions_setup (GimpActionGroup *group)
416
{
417 418
  GtkAction *action;

419 420
  gimp_action_group_add_actions (group,
                                 view_actions,
421
                                 G_N_ELEMENTS (view_actions));
422 423 424

  gimp_action_group_add_toggle_actions (group,
                                        view_toggle_actions,
425
                                        G_N_ELEMENTS (view_toggle_actions));
426

427 428 429 430 431
  gimp_action_group_add_enum_actions (group,
                                      view_zoom_actions,
                                      G_N_ELEMENTS (view_zoom_actions),
                                      G_CALLBACK (view_zoom_cmd_callback));

432
  gimp_action_group_add_radio_actions (group,
433 434
                                       view_zoom_explicit_actions,
                                       G_N_ELEMENTS (view_zoom_explicit_actions),
435
                                       10000,
436
                                       G_CALLBACK (view_zoom_explicit_cmd_callback));
437

438 439 440 441 442
  gimp_action_group_add_enum_actions (group,
                                      view_padding_color_actions,
                                      G_N_ELEMENTS (view_padding_color_actions),
                                      G_CALLBACK (view_padding_color_cmd_callback));

443 444 445 446 447 448 449 450 451 452
  gimp_action_group_add_enum_actions (group,
                                      view_scroll_horizontal_actions,
                                      G_N_ELEMENTS (view_scroll_horizontal_actions),
                                      G_CALLBACK (view_scroll_horizontal_cmd_callback));

  gimp_action_group_add_enum_actions (group,
                                      view_scroll_vertical_actions,
                                      G_N_ELEMENTS (view_scroll_vertical_actions),
                                      G_CALLBACK (view_scroll_vertical_cmd_callback));

453 454 455 456
  window_actions_setup (group,
                        GIMP_HELP_VIEW_CHANGE_SCREEN,
                        G_CALLBACK (view_move_to_screen_cmd_callback));

457 458 459 460 461 462 463 464
  /*  connect "activate" of view-zoom-other manually so it can be
   *  selected even if it's the active item of the radio group
   */
  action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                        "view-zoom-other");
  g_signal_connect (action, "activate",
                    G_CALLBACK (view_zoom_other_cmd_callback),
                    group->user_data);
465 466 467 468 469 470

  g_signal_connect_object (group->gimp->config, "notify::check-type",
                           G_CALLBACK (view_actions_check_type_notify),
                           group, 0);
  view_actions_check_type_notify (GIMP_DISPLAY_CONFIG (group->gimp->config),
                                  NULL, group);
471 472 473 474 475 476
}

void
view_actions_update (GimpActionGroup *group,
                     gpointer         data)
{
477
  GimpDisplay        *gdisp      = action_data_get_display (data);
478 479 480 481 482 483 484
  GimpDisplayShell   *shell      = NULL;
  GimpDisplayOptions *options    = NULL;
  GimpImage          *gimage     = NULL;
  gboolean            fullscreen = FALSE;

  if (gdisp)
    {
485
      shell  = GIMP_DISPLAY_SHELL (gdisp->shell);
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
      gimage = gdisp->gimage;

      fullscreen = gimp_display_shell_get_fullscreen (shell);

      options = fullscreen ? shell->fullscreen_options : shell->options;
    }

#define SET_ACTIVE(action,condition) \
        gimp_action_group_set_action_active (group, action, (condition) != 0)
#define SET_VISIBLE(action,condition) \
        gimp_action_group_set_action_visible (group, action, (condition) != 0)
#define SET_LABEL(action,label) \
        gimp_action_group_set_action_label (group, action, (label))
#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
501 502
#define SET_COLOR(action,color) \
        gimp_action_group_set_action_color (group, action, color, FALSE)
503

504 505
  SET_SENSITIVE ("view-new",   gdisp);
  SET_SENSITIVE ("view-close", gdisp);
506 507 508 509

  SET_SENSITIVE ("view-dot-for-dot", gdisp);
  SET_ACTIVE    ("view-dot-for-dot", gdisp && shell->dot_for_dot);

510 511 512 513
  SET_SENSITIVE ("view-zoom-out",    gdisp);
  SET_SENSITIVE ("view-zoom-in",     gdisp);
  SET_SENSITIVE ("view-zoom-fit-in", gdisp);
  SET_SENSITIVE ("view-zoom-fit-to", gdisp);
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537

  SET_SENSITIVE ("view-zoom-16-1",  gdisp);
  SET_SENSITIVE ("view-zoom-8-1",   gdisp);
  SET_SENSITIVE ("view-zoom-4-1",   gdisp);
  SET_SENSITIVE ("view-zoom-2-1",   gdisp);
  SET_SENSITIVE ("view-zoom-1-1",   gdisp);
  SET_SENSITIVE ("view-zoom-1-2",   gdisp);
  SET_SENSITIVE ("view-zoom-1-4",   gdisp);
  SET_SENSITIVE ("view-zoom-1-8",   gdisp);
  SET_SENSITIVE ("view-zoom-1-16",  gdisp);
  SET_SENSITIVE ("view-zoom-other", gdisp);

  if (gdisp)
    view_actions_set_zoom (group, shell);

  SET_SENSITIVE ("view-navigation-window", gdisp);
  SET_SENSITIVE ("view-display-filters",   gdisp);

  SET_SENSITIVE ("view-show-selection",      gdisp);
  SET_ACTIVE    ("view-show-selection",      gdisp && options->show_selection);
  SET_SENSITIVE ("view-show-layer-boundary", gdisp);
  SET_ACTIVE    ("view-show-layer-boundary", gdisp && options->show_layer_boundary);
  SET_ACTIVE    ("view-show-guides",         gdisp && options->show_guides);
  SET_ACTIVE    ("view-show-grid",           gdisp && options->show_grid);
538
  SET_ACTIVE    ("view-show-sample-points",  gdisp && options->show_sample_points);
539
  SET_ACTIVE    ("view-snap-to-guides",      gdisp && shell->snap_to_guides);
540
  SET_ACTIVE    ("view-snap-to-grid",        gdisp && shell->snap_to_grid);
541 542
  SET_ACTIVE    ("view-snap-to-canvas",      gdisp && shell->snap_to_canvas);
  SET_ACTIVE    ("view-snap-to-vectors",     gdisp && shell->snap_to_vectors);
543

544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
  if (gdisp)
    {
      SET_COLOR ("view-padding-color-menu", &options->padding_color);

      if (shell->canvas)
        {
          GimpRGB color;

          gtk_widget_ensure_style (shell->canvas);
          gimp_rgb_set_gdk_color (&color,
                                  shell->canvas->style->bg + GTK_STATE_NORMAL);
          gimp_rgb_set_alpha (&color, GIMP_OPACITY_OPAQUE);

          SET_COLOR ("view-padding-color-theme",  &color);
        }
    }

561 562 563 564 565 566 567 568 569
  SET_SENSITIVE ("view-show-menubar",    gdisp);
  SET_ACTIVE    ("view-show-menubar",    gdisp && options->show_menubar);
  SET_SENSITIVE ("view-show-rulers",     gdisp);
  SET_ACTIVE    ("view-show-rulers",     gdisp && options->show_rulers);
  SET_SENSITIVE ("view-show-scrollbars", gdisp);
  SET_ACTIVE    ("view-show-scrollbars", gdisp && options->show_scrollbars);
  SET_SENSITIVE ("view-show-statusbar",  gdisp);
  SET_ACTIVE    ("view-show-statusbar",  gdisp && options->show_statusbar);

570 571 572 573 574
  SET_SENSITIVE ("view-shrink-wrap", gdisp);
  SET_SENSITIVE ("view-fullscreen",  gdisp);
  SET_ACTIVE    ("view-fullscreen",  gdisp && fullscreen);

  window_actions_update (group, gdisp ? gdisp->shell : NULL);
575 576 577 578 579

#undef SET_ACTIVE
#undef SET_VISIBLE
#undef SET_LABEL
#undef SET_SENSITIVE
580
#undef SET_COLOR
581 582 583 584 585 586 587 588 589 590
}


/*  private functions  */

static void
view_actions_set_zoom (GimpActionGroup  *group,
                       GimpDisplayShell *shell)
{
  const gchar *action = NULL;
591
  gchar       *str;
592
  gchar       *label;
593 594 595 596 597
  guint        scale;

  g_object_get (shell->zoom,
                "percentage", &str,
                NULL);
598

599
  scale = ROUND (gimp_zoom_model_get_factor (shell->zoom) * 1000);
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614

  switch (scale)
    {
    case 16000:  action = "view-zoom-16-1";  break;
    case  8000:  action = "view-zoom-8-1";   break;
    case  4000:  action = "view-zoom-4-1";   break;
    case  2000:  action = "view-zoom-2-1";   break;
    case  1000:  action = "view-zoom-1-1";   break;
    case   500:  action = "view-zoom-1-2";   break;
    case   250:  action = "view-zoom-1-4";   break;
    case   125:  action = "view-zoom-1-8";   break;
    case    63:
    case    62:  action = "view-zoom-1-16";  break;
    }

615
  if (! action)
616
    {
617
      action = "view-zoom-other";
618

619
      label = g_strdup_printf (_("Othe_r (%s) ..."), str);
620 621 622
      gimp_action_group_set_action_label (group, action, label);
      g_free (label);

623
      shell->other_scale = gimp_zoom_model_get_factor (shell->zoom);
624 625 626 627
    }

  gimp_action_group_set_action_active (group, action, TRUE);

628
  label = g_strdup_printf (_("_Zoom (%s)"), str);
629 630 631 632 633
  gimp_action_group_set_action_label (group, "view-zoom-menu", label);
  g_free (label);

  /* flag as dirty */
  shell->other_scale = - fabs (shell->other_scale);
634 635

  g_free (str);
636
}
637 638 639 640 641 642 643 644 645

static void
view_actions_check_type_notify (GimpDisplayConfig *config,
                                GParamSpec        *pspec,
                                GimpActionGroup   *group)
{
  GimpRGB color;

  gimp_rgba_set_uchar (&color,
646 647 648
                       gimp_render_blend_light_check[0],
                       gimp_render_blend_light_check[1],
                       gimp_render_blend_light_check[2],
649 650 651 652 653
                       255);
  gimp_action_group_set_action_color (group, "view-padding-color-light-check",
                                      &color, FALSE);

  gimp_rgba_set_uchar (&color,
654 655 656
                       gimp_render_blend_dark_check[0],
                       gimp_render_blend_dark_check[1],
                       gimp_render_blend_dark_check[2],
657 658 659 660
                       255);
  gimp_action_group_set_action_color (group, "view-padding-color-dark-check",
                                      &color, FALSE);
}