Пример #1
0
GimpDisplay *
action_data_get_display (gpointer data)
{
  GimpDisplay     *result    = NULL;
  static gboolean  recursion = FALSE;

  if (! data || recursion)
    return NULL;

  recursion = TRUE;

  if (GIMP_IS_DISPLAY (data))
    result = data;
  else if (GIMP_IS_IMAGE_WINDOW (data))
    {
      GimpDisplayShell *shell = gimp_image_window_get_active_shell (data);
      result = shell ? shell->display : NULL;
    }

  if (! result)
    {
      GimpContext *context = action_data_get_context (data);

      if (context)
        result = gimp_context_get_display (context);
    }

  recursion = FALSE;

  return result;
}
Пример #2
0
void
dock_actions_update (GimpActionGroup *group,
                     gpointer         data)
{
  GtkWidget *widget   = action_data_get_widget (data);
  GtkWidget *toplevel = NULL;

  if (widget)
    toplevel = gtk_widget_get_toplevel (widget);

#define SET_ACTIVE(action,active) \
        gimp_action_group_set_action_active (group, action, (active) != 0)
#define SET_VISIBLE(action,active) \
        gimp_action_group_set_action_visible (group, action, (active) != 0)

  if (GIMP_IS_DOCK_WINDOW (toplevel))
    {
      GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (toplevel);
      gboolean show_image_menu = ! gimp_dock_window_has_toolbox (dock_window);

      if (show_image_menu)
        {
          SET_VISIBLE ("dock-show-image-menu",    TRUE);
          SET_VISIBLE ("dock-auto-follow-active", TRUE);

          SET_ACTIVE ("dock-show-image-menu",    gimp_dock_window_get_show_image_menu (dock_window));
          SET_ACTIVE ("dock-auto-follow-active", gimp_dock_window_get_auto_follow_active (dock_window));
        }
      else
        {
          SET_VISIBLE ("dock-show-image-menu",    FALSE);
          SET_VISIBLE ("dock-auto-follow-active", FALSE);
        }

      /*  update the window actions only in the context of their
       *  own window (not in the context of some display or NULL)
       *  (see view-actions.c)
       */
      window_actions_update (group, toplevel);
    }
  else if (GIMP_IS_IMAGE_WINDOW (toplevel))
    {
      SET_VISIBLE ("dock-show-image-menu",    FALSE);
      SET_VISIBLE ("dock-auto-follow-active", FALSE);
    }

#undef SET_ACTIVE
#undef SET_VISIBLE
}
Пример #3
0
void
view_actions_update (GimpActionGroup *group,
                     gpointer         data)
{
  GimpDisplay        *display        = action_data_get_display (data);
  GimpImage          *image          = NULL;
  GimpDisplayShell   *shell          = NULL;
  GimpDisplayOptions *options        = NULL;
  gchar              *label          = NULL;
  gboolean            fullscreen     = FALSE;
  gboolean            revert_enabled = FALSE;   /* able to revert zoom? */
  gboolean            use_gegl       = FALSE;

  if (display)
    {
      GimpImageWindow *window;

      image  = gimp_display_get_image (display);
      shell  = gimp_display_get_shell (display);
      window = gimp_display_shell_get_window (shell);

      if (window)
        fullscreen = gimp_image_window_get_fullscreen (window);

      options = (image ?
                 (fullscreen ? shell->fullscreen_options : shell->options) :
                 shell->no_image_options);

      revert_enabled = gimp_display_shell_scale_can_revert (shell);

      if (image)
        use_gegl = gimp_image_get_projection (image)->use_gegl;
    }

#define SET_ACTIVE(action,condition) \
        gimp_action_group_set_action_active (group, action, (condition) != 0)
#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_COLOR(action,color) \
        gimp_action_group_set_action_color (group, action, color, FALSE)

  SET_SENSITIVE ("view-new",   image);
  SET_SENSITIVE ("view-close", image);

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

  SET_SENSITIVE ("view-zoom-revert", revert_enabled);
  if (revert_enabled)
    {
      label = g_strdup_printf (_("Re_vert Zoom (%d%%)"),
                               ROUND (shell->last_scale * 100));
      gimp_action_group_set_action_label (group, "view-zoom-revert", label);
      g_free (label);
    }
  else
    {
      gimp_action_group_set_action_label (group, "view-zoom-revert",
                                          _("Re_vert Zoom"));
    }

  SET_SENSITIVE ("view-zoom-out",    image);
  SET_SENSITIVE ("view-zoom-in",     image);
  SET_SENSITIVE ("view-zoom-fit-in", image);
  SET_SENSITIVE ("view-zoom-fill",   image);

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

  if (image)
    view_actions_set_zoom (group, shell);

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

  SET_SENSITIVE ("view-show-selection",      image);
  SET_ACTIVE    ("view-show-selection",      display && options->show_selection);
  SET_SENSITIVE ("view-show-layer-boundary", image);
  SET_ACTIVE    ("view-show-layer-boundary", display && options->show_layer_boundary);
  SET_SENSITIVE ("view-show-guides",         image);
  SET_ACTIVE    ("view-show-guides",         display && options->show_guides);
  SET_SENSITIVE ("view-show-grid",           image);
  SET_ACTIVE    ("view-show-grid",           display && options->show_grid);
  SET_SENSITIVE ("view-show-sample-points",  image);
  SET_ACTIVE    ("view-show-sample-points",  display && options->show_sample_points);

  SET_SENSITIVE ("view-snap-to-guides",      image);
  SET_ACTIVE    ("view-snap-to-guides",      display && shell->snap_to_guides);
  SET_SENSITIVE ("view-snap-to-grid",        image);
  SET_ACTIVE    ("view-snap-to-grid",        display && shell->snap_to_grid);
  SET_SENSITIVE ("view-snap-to-canvas",      image);
  SET_ACTIVE    ("view-snap-to-canvas",      display && shell->snap_to_canvas);
  SET_SENSITIVE ("view-snap-to-vectors",     image);
  SET_ACTIVE    ("view-snap-to-vectors",     display && shell->snap_to_vectors);

  SET_SENSITIVE ("view-padding-color-theme",       image);
  SET_SENSITIVE ("view-padding-color-light-check", image);
  SET_SENSITIVE ("view-padding-color-dark-check",  image);
  SET_SENSITIVE ("view-padding-color-custom",      image);
  SET_SENSITIVE ("view-padding-color-prefs",       image);

  if (display)
    {
      SET_COLOR ("view-padding-color-menu", &options->padding_color);

      if (shell->canvas)
        {
          GtkStyle *style = gtk_widget_get_style (shell->canvas);
          GimpRGB   color;

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

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

  SET_SENSITIVE ("view-show-menubar",    image);
  SET_ACTIVE    ("view-show-menubar",    display && options->show_menubar);
  SET_SENSITIVE ("view-show-rulers",     image);
  SET_ACTIVE    ("view-show-rulers",     display && options->show_rulers);
  SET_SENSITIVE ("view-show-scrollbars", image);
  SET_ACTIVE    ("view-show-scrollbars", display && options->show_scrollbars);
  SET_SENSITIVE ("view-show-statusbar",  image);
  SET_ACTIVE    ("view-show-statusbar",  display && options->show_statusbar);

  SET_SENSITIVE ("view-shrink-wrap", image);
  SET_SENSITIVE ("view-fullscreen",  image);
  SET_ACTIVE    ("view-fullscreen",  display && fullscreen);
  SET_ACTIVE    ("view-use-gegl",    use_gegl);

  if (GIMP_IS_IMAGE_WINDOW (group->user_data) ||
      GIMP_IS_GIMP (group->user_data))
    {
      GtkWidget *window = NULL;

      if (shell)
        window = gtk_widget_get_toplevel (GTK_WIDGET (shell));

      /*  see view_actions_setup()  */
      if (GTK_IS_WINDOW (window))
        window_actions_update (group, window);
    }

#undef SET_ACTIVE
#undef SET_SENSITIVE
#undef SET_COLOR
}
Пример #4
0
void
view_actions_setup (GimpActionGroup *group)
{
  GtkAction *action;

  gimp_action_group_add_actions (group, "view-action",
                                 view_actions,
                                 G_N_ELEMENTS (view_actions));

  gimp_action_group_add_toggle_actions (group, "view-action",
                                        view_toggle_actions,
                                        G_N_ELEMENTS (view_toggle_actions));

  gimp_action_group_add_enum_actions (group, "view-zoom-action",
                                      view_zoom_actions,
                                      G_N_ELEMENTS (view_zoom_actions),
                                      G_CALLBACK (view_zoom_cmd_callback));

  gimp_action_group_add_radio_actions (group, "view-zoom-action",
                                       view_zoom_explicit_actions,
                                       G_N_ELEMENTS (view_zoom_explicit_actions),
                                       NULL,
                                       10000,
                                       G_CALLBACK (view_zoom_explicit_cmd_callback));

  gimp_action_group_add_enum_actions (group, "view-padding-color",
                                      view_padding_color_actions,
                                      G_N_ELEMENTS (view_padding_color_actions),
                                      G_CALLBACK (view_padding_color_cmd_callback));

  gimp_action_group_add_enum_actions (group, NULL,
                                      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, NULL,
                                      view_scroll_vertical_actions,
                                      G_N_ELEMENTS (view_scroll_vertical_actions),
                                      G_CALLBACK (view_scroll_vertical_cmd_callback));

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

  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);

  if (GIMP_IS_IMAGE_WINDOW (group->user_data) ||
      GIMP_IS_GIMP (group->user_data))
    {
      /*  add window actions only if the context of the group is
       *  the display itself or the global popup (not if the context
       *  is a dock)
       *  (see dock-actions.c)
       */
      window_actions_setup (group, GIMP_HELP_VIEW_CHANGE_SCREEN);
    }
}
Пример #5
0
void
view_actions_update (GimpActionGroup *group,
                     gpointer         data)
{
  GimpDisplay        *display           = action_data_get_display (data);
  GimpImage          *image             = NULL;
  GimpDisplayShell   *shell             = NULL;
  GimpDisplayOptions *options           = NULL;
  GimpColorConfig    *color_config      = NULL;
  gchar              *label             = NULL;
  gboolean            fullscreen        = FALSE;
  gboolean            revert_enabled    = FALSE;   /* able to revert zoom? */
  gboolean            flip_horizontally = FALSE;
  gboolean            flip_vertically   = FALSE;
  gboolean            cm                = FALSE;
  gboolean            sp                = FALSE;

  if (display)
    {
      GimpImageWindow          *window;
      GimpColorRenderingIntent  intent = GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL;
      gboolean                  bpc    = TRUE;
      const gchar              *action = NULL;

      image  = gimp_display_get_image (display);
      shell  = gimp_display_get_shell (display);
      window = gimp_display_shell_get_window (shell);

      if (window)
        fullscreen = gimp_image_window_get_fullscreen (window);

      options = (image ?
                 (fullscreen ? shell->fullscreen_options : shell->options) :
                 shell->no_image_options);

      revert_enabled = gimp_display_shell_scale_can_revert (shell);

      flip_horizontally = shell->flip_horizontally;
      flip_vertically   = shell->flip_vertically;

      color_config = gimp_display_shell_get_color_config (shell);

      switch (color_config->mode)
        {
        case GIMP_COLOR_MANAGEMENT_OFF:
          action = "view-color-management-mode-off";
          break;

        case GIMP_COLOR_MANAGEMENT_DISPLAY:
          action = "view-color-management-mode-display";
          intent = color_config->display_intent;
          bpc    = color_config->display_use_black_point_compensation;

          cm = TRUE;
          break;

        case GIMP_COLOR_MANAGEMENT_SOFTPROOF:
          action = "view-color-management-mode-softproof";
          intent = color_config->simulation_intent;
          bpc    = color_config->simulation_use_black_point_compensation;

          cm = TRUE;
          sp = TRUE;
          break;
        }

      gimp_action_group_set_action_active (group, action, TRUE);

      switch (intent)
        {
        case GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL:
          action = "view-color-management-intent-perceptual";
          break;

        case GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
          action = "view-color-management-intent-relative-colorimetric";
          break;

        case GIMP_COLOR_RENDERING_INTENT_SATURATION:
          action = "view-color-management-intent-saturation";
          break;

        case GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
          action = "view-color-management-intent-absolute-colorimetric";
          break;
        }

      gimp_action_group_set_action_active (group, action, TRUE);

      gimp_action_group_set_action_active (group,
                                           "view-color-management-black-point-compensation",
                                           bpc);
      gimp_action_group_set_action_active (group,
                                           "view-color-management-gamut-check",
                                           color_config->simulation_gamut_check);
    }

#define SET_ACTIVE(action,condition) \
        gimp_action_group_set_action_active (group, action, (condition) != 0)
#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_COLOR(action,color) \
        gimp_action_group_set_action_color (group, action, color, FALSE)

  SET_SENSITIVE ("view-new",   image);
  SET_SENSITIVE ("view-close", image);

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

  SET_SENSITIVE ("view-zoom-revert", revert_enabled);
  if (revert_enabled)
    {
      label = g_strdup_printf (_("Re_vert Zoom (%d%%)"),
                               ROUND (shell->last_scale * 100));
      gimp_action_group_set_action_label (group, "view-zoom-revert", label);
      g_free (label);
    }
  else
    {
      gimp_action_group_set_action_label (group, "view-zoom-revert",
                                          _("Re_vert Zoom"));
    }

  SET_SENSITIVE ("view-zoom",              image);
  SET_SENSITIVE ("view-zoom-minimum",      image);
  SET_SENSITIVE ("view-zoom-maximum",      image);
  SET_SENSITIVE ("view-zoom-in",           image);
  SET_SENSITIVE ("view-zoom-in-accel",     image);
  SET_SENSITIVE ("view-zoom-in-skip",      image);
  SET_SENSITIVE ("view-zoom-out",          image);
  SET_SENSITIVE ("view-zoom-out-accel",    image);
  SET_SENSITIVE ("view-zoom-out-skip",     image);

  SET_SENSITIVE ("view-zoom-fit-in",       image);
  SET_SENSITIVE ("view-zoom-fill",         image);
  SET_SENSITIVE ("view-zoom-selection",    image);
  SET_SENSITIVE ("view-zoom-revert",       image);

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

  SET_SENSITIVE ("view-flip-horizontally", image);
  SET_ACTIVE    ("view-flip-horizontally", flip_horizontally);

  SET_SENSITIVE ("view-flip-vertically",   image);
  SET_ACTIVE    ("view-flip-vertically",   flip_vertically);

  SET_SENSITIVE ("view-rotate-reset",      image);
  SET_SENSITIVE ("view-rotate-15",         image);
  SET_SENSITIVE ("view-rotate-345",        image);
  SET_SENSITIVE ("view-rotate-90",         image);
  SET_SENSITIVE ("view-rotate-180",        image);
  SET_SENSITIVE ("view-rotate-270",        image);
  SET_SENSITIVE ("view-rotate-other",      image);

  if (image)
    {
      view_actions_set_zoom (group, shell);
      view_actions_set_rotate (group, shell);
    }

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

  SET_SENSITIVE ("view-color-management-mode-off",                     image);
  SET_SENSITIVE ("view-color-management-mode-display",                 image);
  SET_SENSITIVE ("view-color-management-mode-softproof",               image);
  SET_SENSITIVE ("view-color-management-intent-perceptual",            cm);
  SET_SENSITIVE ("view-color-management-intent-relative-colorimetric", cm);
  SET_SENSITIVE ("view-color-management-intent-saturation",            cm);
  SET_SENSITIVE ("view-color-management-intent-absolute-colorimetric", cm);
  SET_SENSITIVE ("view-color-management-black-point-compensation",     cm);
  SET_SENSITIVE ("view-color-management-gamut-check",                  sp);
  SET_SENSITIVE ("view-color-management-reset",                        image);

  SET_SENSITIVE ("view-show-selection",      image);
  SET_ACTIVE    ("view-show-selection",      display && options->show_selection);
  SET_SENSITIVE ("view-show-layer-boundary", image);
  SET_ACTIVE    ("view-show-layer-boundary", display && options->show_layer_boundary);
  SET_SENSITIVE ("view-show-guides",         image);
  SET_ACTIVE    ("view-show-guides",         display && options->show_guides);
  SET_SENSITIVE ("view-show-grid",           image);
  SET_ACTIVE    ("view-show-grid",           display && options->show_grid);
  SET_SENSITIVE ("view-show-sample-points",  image);
  SET_ACTIVE    ("view-show-sample-points",  display && options->show_sample_points);

  SET_SENSITIVE ("view-snap-to-guides",      image);
  SET_ACTIVE    ("view-snap-to-guides",      display && options->snap_to_guides);
  SET_SENSITIVE ("view-snap-to-grid",        image);
  SET_ACTIVE    ("view-snap-to-grid",        display && options->snap_to_grid);
  SET_SENSITIVE ("view-snap-to-canvas",      image);
  SET_ACTIVE    ("view-snap-to-canvas",      display && options->snap_to_canvas);
  SET_SENSITIVE ("view-snap-to-vectors",     image);
  SET_ACTIVE    ("view-snap-to-vectors",     display && options->snap_to_path);

  SET_SENSITIVE ("view-padding-color-theme",       image);
  SET_SENSITIVE ("view-padding-color-light-check", image);
  SET_SENSITIVE ("view-padding-color-dark-check",  image);
  SET_SENSITIVE ("view-padding-color-custom",      image);
  SET_SENSITIVE ("view-padding-color-prefs",       image);

  if (display)
    {
      SET_COLOR ("view-padding-color-menu", &options->padding_color);

      if (shell->canvas)
        {
          GtkStyle *style = gtk_widget_get_style (shell->canvas);
          GimpRGB   color;

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

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

  SET_SENSITIVE ("view-show-menubar",    image);
  SET_ACTIVE    ("view-show-menubar",    display && options->show_menubar);
  SET_SENSITIVE ("view-show-rulers",     image);
  SET_ACTIVE    ("view-show-rulers",     display && options->show_rulers);
  SET_SENSITIVE ("view-show-scrollbars", image);
  SET_ACTIVE    ("view-show-scrollbars", display && options->show_scrollbars);
  SET_SENSITIVE ("view-show-statusbar",  image);
  SET_ACTIVE    ("view-show-statusbar",  display && options->show_statusbar);

  SET_SENSITIVE ("view-shrink-wrap", image);
  SET_ACTIVE    ("view-fullscreen",  display && fullscreen);

  if (GIMP_IS_IMAGE_WINDOW (group->user_data) ||
      GIMP_IS_GIMP (group->user_data))
    {
      GtkWidget *window = NULL;

      if (shell)
        window = gtk_widget_get_toplevel (GTK_WIDGET (shell));

      /*  see view_actions_setup()  */
      if (GTK_IS_WINDOW (window))
        window_actions_update (group, window);
    }

#undef SET_ACTIVE
#undef SET_SENSITIVE
#undef SET_COLOR
}