/** * gimp_display_shell_scale_resize: * @shell: the #GimpDisplayShell * @resize_window: whether the display window should be resized * @grow_only: whether shrinking of the window is allowed or not * * Function commonly called after a change in display scale to make the changes * visible to the user. If @resize_window is %TRUE then the display window is * resized to accommodate the display image as per * gimp_display_shell_shrink_wrap(). **/ void gimp_display_shell_scale_resize (GimpDisplayShell *shell, gboolean resize_window, gboolean grow_only) { g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); /* freeze the active tool */ gimp_display_shell_pause (shell); if (resize_window) { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window && gimp_image_window_get_active_shell (window) == shell) { gimp_image_window_shrink_wrap (window, grow_only); } } gimp_display_shell_scroll_clamp_and_update (shell); gimp_display_shell_scaled (shell); gimp_display_shell_expose_full (shell); /* re-enable the active tool */ gimp_display_shell_resume (shell); }
static void gimp_display_shell_close_response (GtkWidget *widget, gint response_id, GimpDisplayShell *shell) { gtk_widget_destroy (widget); switch (response_id) { case GTK_RESPONSE_CLOSE: gimp_display_close (shell->display); break; case RESPONSE_SAVE: { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window) { GimpUIManager *manager = gimp_image_window_get_ui_manager (window); /* FIXME image window: set this display active */ gimp_ui_manager_activate_action (manager, "file", "file-save-and-close"); } } break; default: break; } }
gboolean gimp_display_shell_quick_mask_button_press (GtkWidget *widget, GdkEventButton *bevent, GimpDisplayShell *shell) { if (! gimp_display_get_image (shell->display)) return TRUE; if (gdk_event_triggers_context_menu ((GdkEvent *) bevent)) { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window) { GimpUIManager *manager = gimp_image_window_get_ui_manager (window); gimp_ui_manager_ui_popup (manager, "/quick-mask-popup", GTK_WIDGET (shell), NULL, NULL, NULL, NULL); } return TRUE; } return FALSE; }
void view_dot_for_dot_cmd_callback (GtkAction *action, gpointer data) { GimpDisplay *display; GimpDisplayShell *shell; gboolean active; return_if_no_display (display, data); shell = gimp_display_get_shell (display); active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); if (active != shell->dot_for_dot) { GimpImageWindow *window = gimp_display_shell_get_window (shell); gimp_display_shell_scale_set_dot_for_dot (shell, active); if (window) SET_ACTIVE (gimp_image_window_get_ui_manager (window), "view-dot-for-dot", shell->dot_for_dot); if (IS_ACTIVE_DISPLAY (display)) SET_ACTIVE (shell->popup_manager, "view-dot-for-dot", shell->dot_for_dot); } }
void gimp_display_shell_close (GimpDisplayShell *shell, gboolean kill_it) { GimpImage *image; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); image = gimp_display_get_image (shell->display); /* FIXME: gimp_busy HACK not really appropriate here because we only * want to prevent the busy image and display to be closed. --Mitch */ if (shell->display->gimp->busy) return; /* If the image has been modified, give the user a chance to save * it before nuking it--this only applies if its the last view * to an image canvas. (a image with disp_count = 1) */ if (! kill_it && image && gimp_image_get_display_count (image) == 1 && gimp_image_is_dirty (image) && shell->display->config->confirm_on_close) { /* If there's a save dialog active for this image, then raise it. * (see bug #511965) */ GtkWidget *dialog = g_object_get_data (G_OBJECT (image), "gimp-file-save-dialog"); if (dialog) { gtk_window_present (GTK_WINDOW (dialog)); } else { gimp_display_shell_close_dialog (shell, image); } } else if (image) { gimp_display_close (shell->display); } else { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window) { GimpUIManager *manager = gimp_image_window_get_ui_manager (window); /* Activate the action instead of simply calling gimp_exit(), so * the quit action's sensitivity is taken into account. */ gimp_ui_manager_activate_action (manager, "file", "file-quit"); } } }
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 gimp_display_shell_size_changed_detailed_handler (GimpImage *image, gint previous_origin_x, gint previous_origin_y, gint previous_width, gint previous_height, GimpDisplayShell *shell) { if (shell->display->config->resize_windows_on_resize) { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window && gimp_image_window_get_active_shell (window) == shell) { /* If the window is resized just center the image in it when it * has change size */ gimp_image_window_shrink_wrap (window, FALSE); } } else { GimpImage *image = gimp_display_get_image (shell->display); gint new_width = gimp_image_get_width (image); gint new_height = gimp_image_get_height (image); gint scaled_previous_origin_x = SCALEX (shell, previous_origin_x); gint scaled_previous_origin_y = SCALEY (shell, previous_origin_y); gboolean horizontally; gboolean vertically; horizontally = (SCALEX (shell, previous_width) > shell->disp_width && SCALEX (shell, new_width) <= shell->disp_width); vertically = (SCALEY (shell, previous_height) > shell->disp_height && SCALEY (shell, new_height) <= shell->disp_height); gimp_display_shell_scroll_set_offset (shell, shell->offset_x + scaled_previous_origin_x, shell->offset_y + scaled_previous_origin_y); gimp_display_shell_scroll_center_image (shell, horizontally, vertically); /* The above calls might not lead to a call to * gimp_display_shell_scroll_clamp_and_update() in all cases we * need it to be called, so simply call it explicitly here at * the end */ gimp_display_shell_scroll_clamp_and_update (shell); gimp_display_shell_expose_full (shell); } }
/** * dialogs_restore_window: * @factory: * @screen: * @monitor: * @info: * * "restores" the image window. We don't really restore anything since * the image window is created earlier, so we just look for and return * the already-created image window. * * Returns: **/ static GtkWidget * dialogs_restore_window (GimpDialogFactory *factory, GdkScreen *screen, gint monitor, GimpSessionInfo *info) { Gimp *gimp = gimp_dialog_factory_get_context (factory)->gimp; GimpDisplay *display = GIMP_DISPLAY (gimp_get_empty_display (gimp)); GimpDisplayShell *shell = gimp_display_get_shell (display); GtkWidget *dialog; dialog = GTK_WIDGET (gimp_display_shell_get_window (shell)); return dialog; }
void view_fullscreen_cmd_callback (GtkAction *action, gpointer data) { GimpDisplay *display; GimpDisplayShell *shell; GimpImageWindow *window; return_if_no_display (display, data); shell = gimp_display_get_shell (display); window = gimp_display_shell_get_window (shell); if (window) { gboolean active; active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); gimp_image_window_set_fullscreen (window, active); } }
void gimp_display_shell_quick_mask_toggled (GtkWidget *widget, GimpDisplayShell *shell) { GimpImage *image = gimp_display_get_image (shell->display); gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); if (active != gimp_image_get_quick_mask_state (image)) { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window) { GimpUIManager *manager = gimp_image_window_get_ui_manager (window); gimp_ui_manager_toggle_action (manager, "quick-mask", "quick-mask-toggle", active); } } }
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 gimp_display_shell_set_action_active (GimpDisplayShell *shell, const gchar *action, gboolean active) { GimpImageWindow *window; GimpContext *context; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (action != NULL); window = gimp_display_shell_get_window (shell); if (window && gimp_image_window_get_active_shell (window) == shell) { GimpUIManager *manager = gimp_image_window_get_ui_manager (window); GimpActionGroup *action_group; action_group = gimp_ui_manager_get_action_group (manager, "view"); if (action_group) gimp_action_group_set_action_active (action_group, action, active); } context = gimp_get_user_context (shell->display->gimp); if (shell->display == gimp_context_get_display (context)) { GimpActionGroup *action_group; action_group = gimp_ui_manager_get_action_group (shell->popup_manager, "view"); if (action_group) gimp_action_group_set_action_active (action_group, action, active); } }
static void gimp_color_tool_real_picked (GimpColorTool *color_tool, GimpColorPickState pick_state, gdouble x, gdouble y, const Babl *sample_format, gpointer pixel, const GimpRGB *color) { GimpTool *tool = GIMP_TOOL (color_tool); GimpDisplayShell *shell = gimp_display_get_shell (tool->display); GimpImageWindow *image_window; GimpDialogFactory *dialog_factory; GimpContext *context; image_window = gimp_display_shell_get_window (shell); dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window)); /* use this tool's own options here (NOT color_tool->options) */ context = GIMP_CONTEXT (gimp_tool_get_options (tool)); if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND || color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND) { GtkWidget *widget; if (babl_format_is_palette (sample_format)) { widget = gimp_dialog_factory_find_widget (dialog_factory, "gimp-indexed-palette"); if (widget) { GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget)); guchar *index = pixel; gimp_colormap_editor_set_index (GIMP_COLORMAP_EDITOR (editor), *index, NULL); } } widget = gimp_dialog_factory_find_widget (dialog_factory, "gimp-palette-editor"); if (widget) { GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget)); gint index; index = gimp_palette_editor_get_index (GIMP_PALETTE_EDITOR (editor), color); if (index != -1) gimp_palette_editor_set_index (GIMP_PALETTE_EDITOR (editor), index, NULL); } } switch (color_tool->pick_mode) { case GIMP_COLOR_PICK_MODE_NONE: break; case GIMP_COLOR_PICK_MODE_FOREGROUND: gimp_context_set_foreground (context, color); break; case GIMP_COLOR_PICK_MODE_BACKGROUND: gimp_context_set_background (context, color); break; case GIMP_COLOR_PICK_MODE_PALETTE: { GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell)); gint monitor = gimp_widget_get_monitor (GTK_WIDGET (shell)); GtkWidget *dockable; dockable = gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (tool->display->gimp)), tool->display->gimp, dialog_factory, screen, monitor, "gimp-palette-editor"); if (dockable) { GtkWidget *palette_editor; GimpData *data; /* don't blink like mad when updating */ if (pick_state != GIMP_COLOR_PICK_STATE_START) gimp_dockable_blink_cancel (GIMP_DOCKABLE (dockable)); palette_editor = gtk_bin_get_child (GTK_BIN (dockable)); data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (palette_editor)); if (! data) { data = GIMP_DATA (gimp_context_get_palette (context)); gimp_data_editor_set_data (GIMP_DATA_EDITOR (palette_editor), data); } gimp_palette_editor_pick_color (GIMP_PALETTE_EDITOR (palette_editor), color, pick_state); } } break; } }
/** * gimp_display_shell_scale: * @shell: the #GimpDisplayShell * @zoom_type: whether to zoom in, our or to a specific scale * @scale: ignored unless @zoom_type == %GIMP_ZOOM_TO * * This function figures out the context of the zoom and behaves * appropriatley thereafter. * **/ void gimp_display_shell_scale (GimpDisplayShell *shell, GimpZoomType zoom_type, gdouble new_scale, GimpZoomFocus zoom_focus) { gint x, y; gdouble current_scale; gdouble real_new_scale; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (shell->canvas != NULL); current_scale = gimp_zoom_model_get_factor (shell->zoom); if (zoom_type != GIMP_ZOOM_TO) { real_new_scale = gimp_zoom_model_zoom_step (zoom_type, current_scale); } else { real_new_scale = new_scale; } if (! SCALE_EQUALS (real_new_scale, current_scale)) { if (shell->display->config->resize_windows_on_zoom) { GimpImageWindow *window = gimp_display_shell_get_window (shell); /* If the window is resized on zoom, simply do the zoom and * get things rolling */ gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, real_new_scale); gimp_display_shell_scaled (shell); if (window && gimp_image_window_get_active_shell (window) == shell) { gimp_image_window_shrink_wrap (window, FALSE); } } else { gboolean starts_fitting_horiz; gboolean starts_fitting_vert; gboolean zoom_focus_almost_centered_horiz; gboolean zoom_focus_almost_centered_vert; gboolean image_center_almost_centered_horiz; gboolean image_center_almost_centered_vert; gint image_center_x; gint image_center_y; gimp_display_shell_scale_get_zoom_focus (shell, real_new_scale, current_scale, &x, &y, zoom_focus); gimp_display_shell_scale_get_image_center_viewport (shell, &image_center_x, &image_center_y); gimp_display_shell_scale_to (shell, real_new_scale, x, y); /* If an image axis started to fit due to zooming out or if * the focus point is as good as in the center, center on * that axis */ gimp_display_shell_scale_image_starts_to_fit (shell, real_new_scale, current_scale, &starts_fitting_horiz, &starts_fitting_vert); gimp_display_shell_scale_viewport_coord_almost_centered (shell, x, y, &zoom_focus_almost_centered_horiz, &zoom_focus_almost_centered_vert); gimp_display_shell_scale_viewport_coord_almost_centered (shell, image_center_x, image_center_y, &image_center_almost_centered_horiz, &image_center_almost_centered_vert); gimp_display_shell_scroll_center_image (shell, starts_fitting_horiz || (zoom_focus_almost_centered_horiz && image_center_almost_centered_horiz), starts_fitting_vert || (zoom_focus_almost_centered_vert && image_center_almost_centered_vert)); } } }
/** * gimp_display_shell_scale_get_zoom_focus: * @shell: * @new_scale: * @x: * @y: * * Calculates the viewport coordinate to focus on when zooming * independently for each axis. **/ static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell, gdouble new_scale, gdouble current_scale, gdouble *x, gdouble *y, GimpZoomFocus zoom_focus) { GtkWidget *window = GTK_WIDGET (gimp_display_shell_get_window (shell)); GdkEvent *event; gint image_center_x; gint image_center_y; gint other_x; gint other_y; /* Calculate stops-to-fit focus point */ gimp_display_shell_scale_get_image_center_viewport (shell, &image_center_x, &image_center_y); /* Calculate other focus point, default is the canvas center */ other_x = shell->disp_width / 2; other_y = shell->disp_height / 2; /* Center on the mouse position instead of the display center if * one of the following conditions are fulfilled and pointer is * within the canvas: * * (1) there's no current event (the action was triggered by an * input controller) * (2) the event originates from the canvas (a scroll event) * (3) the event originates from the window (a key press event) * * Basically the only situation where we don't want to center on * mouse position is if the action is being called from a menu. */ event = gtk_get_current_event (); if (! event || gtk_get_event_widget (event) == shell->canvas || gtk_get_event_widget (event) == window) { GdkPoint *point = g_queue_pop_head (shell->zoom_focus_pointer_queue); gint canvas_pointer_x; gint canvas_pointer_y; if (point) { canvas_pointer_x = point->x; canvas_pointer_y = point->y; g_slice_free (GdkPoint, point); } else { gtk_widget_get_pointer (shell->canvas, &canvas_pointer_x, &canvas_pointer_y); } if (canvas_pointer_x >= 0 && canvas_pointer_y >= 0 && canvas_pointer_x < shell->disp_width && canvas_pointer_y < shell->disp_height) { other_x = canvas_pointer_x; other_y = canvas_pointer_y; } } /* Decide which one to use for each axis */ if (zoom_focus == GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS) { if (gimp_display_shell_scale_viewport_coord_almost_centered (shell, image_center_x, image_center_y, NULL, NULL)) { zoom_focus = GIMP_ZOOM_FOCUS_IMAGE_CENTER; } else { zoom_focus = GIMP_ZOOM_FOCUS_BEST_GUESS; } } switch (zoom_focus) { case GIMP_ZOOM_FOCUS_POINTER: *x = other_x; *y = other_y; break; case GIMP_ZOOM_FOCUS_IMAGE_CENTER: *x = image_center_x; *y = image_center_y; break; case GIMP_ZOOM_FOCUS_BEST_GUESS: default: { gboolean within_horizontally, within_vertically; gboolean stops_horizontally, stops_vertically; gimp_display_shell_scale_image_is_within_viewport (shell, &within_horizontally, &within_vertically); gimp_display_shell_scale_image_stops_to_fit (shell, new_scale, current_scale, &stops_horizontally, &stops_vertically); *x = within_horizontally && ! stops_horizontally ? image_center_x : other_x; *y = within_vertically && ! stops_vertically ? image_center_y : other_y; } 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 }
static void gimp_display_shell_size_changed_detailed_handler (GimpImage *image, gint previous_origin_x, gint previous_origin_y, gint previous_width, gint previous_height, GimpDisplayShell *shell) { GimpDisplayConfig *config = shell->display->config; gboolean resize_window; /* Resize windows only in multi-window mode */ resize_window = (config->resize_windows_on_resize && ! GIMP_GUI_CONFIG (config)->single_window_mode); if (resize_window) { GimpImageWindow *window = gimp_display_shell_get_window (shell); if (window && gimp_image_window_get_active_shell (window) == shell) { /* If the window is resized just center the image in it when it * has change size */ gimp_image_window_shrink_wrap (window, FALSE); } } else { GimpImage *image = gimp_display_get_image (shell->display); gint new_width = gimp_image_get_width (image); gint new_height = gimp_image_get_height (image); gint scaled_previous_origin_x; gint scaled_previous_origin_y; gboolean horizontally; gboolean vertically; scaled_previous_origin_x = SCALEX (shell, previous_origin_x); scaled_previous_origin_y = SCALEY (shell, previous_origin_y); horizontally = (SCALEX (shell, previous_width) > shell->disp_width && SCALEX (shell, new_width) <= shell->disp_width); vertically = (SCALEY (shell, previous_height) > shell->disp_height && SCALEY (shell, new_height) <= shell->disp_height); gimp_display_shell_scroll_set_offset (shell, shell->offset_x + scaled_previous_origin_x, shell->offset_y + scaled_previous_origin_y); gimp_display_shell_scroll_center_image (shell, horizontally, vertically); /* The above calls might not lead to a call to * gimp_display_shell_scroll_clamp_and_update() and * gimp_display_shell_expose_full() in all cases because when * scaling the old and new scroll offset might be the same. * * We need them to be called in all cases, so simply call them * explicitly here at the end */ gimp_display_shell_scroll_clamp_and_update (shell); gimp_display_shell_expose_full (shell); } }
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 debug_dump_keyboard_shortcuts_cmd_callback (GtkAction *action, gpointer data) { GimpDisplay *display; GimpImageWindow *window; GtkUIManager *manager; GtkAccelGroup *accel_group; GList *group_it; GList *strings = NULL; return_if_no_display (display, data); window = gimp_display_shell_get_window (gimp_display_get_shell (display)); manager = GTK_UI_MANAGER (gimp_image_window_get_ui_manager (window)); accel_group = gtk_ui_manager_get_accel_group (manager); /* Gather formated strings of keyboard shortcuts */ for (group_it = gtk_ui_manager_get_action_groups (manager); group_it; group_it = g_list_next (group_it)) { GimpActionGroup *group = group_it->data; GList *actions = NULL; GList *action_it = NULL; actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group)); actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare); for (action_it = actions; action_it; action_it = g_list_next (action_it)) { GtkAction *action = action_it->data; const gchar *name = gtk_action_get_name (action); GClosure *accel_closure = NULL; if (strstr (name, "-menu") || strstr (name, "-popup") || name[0] == '<') continue; accel_closure = gtk_action_get_accel_closure (action); if (accel_closure) { GtkAccelKey *key = gtk_accel_group_find (accel_group, debug_accel_find_func, accel_closure); if (key && key->accel_key && key->accel_flags & GTK_ACCEL_VISIBLE) { const gchar *label_tmp; gchar *label; gchar *key_string; label_tmp = gtk_action_get_label (action); label = gimp_strip_uline (label_tmp); key_string = gtk_accelerator_get_label (key->accel_key, key->accel_mods); strings = g_list_prepend (strings, g_strdup_printf ("%-20s %s", key_string, label)); g_free (key_string); g_free (label); } } } g_list_free (actions); } /* Sort and prints the strings */ { GList *string_it = NULL; strings = g_list_sort (strings, (GCompareFunc) strcmp); for (string_it = strings; string_it; string_it = g_list_next (string_it)) { g_print ("%s\n", (gchar *) string_it->data); g_free (string_it->data); } g_list_free (strings); } }
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 }