static void gimp_display_shell_padding_notify_handler (GObject *config, GParamSpec *param_spec, GimpDisplayShell *shell) { GimpDisplayConfig *display_config; GimpImageWindow *window; gboolean fullscreen; GimpCanvasPaddingMode padding_mode; GimpRGB padding_color; display_config = shell->display->config; window = gimp_display_shell_get_window (shell); if (window) fullscreen = gimp_image_window_get_fullscreen (window); else fullscreen = FALSE; /* if the user did not set the padding mode for this display explicitly */ if (! shell->fullscreen_options->padding_mode_set) { padding_mode = display_config->default_fullscreen_view->padding_mode; padding_color = display_config->default_fullscreen_view->padding_color; if (fullscreen) { gimp_display_shell_set_padding (shell, padding_mode, &padding_color); } else { shell->fullscreen_options->padding_mode = padding_mode; shell->fullscreen_options->padding_color = padding_color; } } /* if the user did not set the padding mode for this display explicitly */ if (! shell->options->padding_mode_set) { padding_mode = display_config->default_view->padding_mode; padding_color = display_config->default_view->padding_color; if (fullscreen) { shell->options->padding_mode = padding_mode; shell->options->padding_color = padding_color; } else { gimp_display_shell_set_padding (shell, padding_mode, &padding_color); } } }
static void view_padding_color_dialog_update (GimpColorDialog *dialog, const GimpRGB *color, GimpColorDialogState state, GimpDisplayShell *shell) { GimpImageWindow *window; GimpDisplayOptions *options; gboolean fullscreen; window = gimp_display_shell_get_window (shell); if (window) fullscreen = gimp_image_window_get_fullscreen (window); else fullscreen = FALSE; 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; } }
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 }
void view_padding_color_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpDisplay *display; GimpImageWindow *window; GimpDisplayShell *shell; GimpDisplayOptions *options; gboolean fullscreen; return_if_no_display (display, data); shell = gimp_display_get_shell (display); window = gimp_display_shell_get_window (shell); if (window) fullscreen = gimp_image_window_get_fullscreen (window); else fullscreen = FALSE; if (fullscreen) options = shell->fullscreen_options; else options = shell->options; switch ((GimpCanvasPaddingMode) value) { case GIMP_CANVAS_PADDING_MODE_DEFAULT: case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK: case GIMP_CANVAS_PADDING_MODE_DARK_CHECK: g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL); options->padding_mode_set = TRUE; gimp_display_shell_set_padding (shell, (GimpCanvasPaddingMode) value, &options->padding_color); break; case GIMP_CANVAS_PADDING_MODE_CUSTOM: { GtkWidget *color_dialog; color_dialog = g_object_get_data (G_OBJECT (shell), "padding-color-dialog"); if (! color_dialog) { GimpImage *image = gimp_display_get_image (display); GimpDisplayShell *shell = gimp_display_get_shell (display); color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (image), action_data_get_context (data), _("Set Canvas Padding Color"), GTK_STOCK_SELECT_COLOR, _("Set Custom Canvas Padding Color"), GTK_WIDGET (shell), NULL, NULL, &options->padding_color, FALSE, FALSE); g_signal_connect (color_dialog, "update", G_CALLBACK (view_padding_color_dialog_update), shell); g_object_set_data_full (G_OBJECT (shell), "padding-color-dialog", color_dialog, (GDestroyNotify) gtk_widget_destroy); } gtk_window_present (GTK_WINDOW (color_dialog)); } break; case GIMP_CANVAS_PADDING_MODE_RESET: g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL); { GimpDisplayOptions *default_options; options->padding_mode_set = FALSE; if (fullscreen) default_options = display->config->default_fullscreen_view; else default_options = display->config->default_view; gimp_display_shell_set_padding (shell, default_options->padding_mode, &default_options->padding_color); } break; } }
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 }