static GValueArray * image_undo_is_enabled_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args, GError **error) { gboolean success = TRUE; GValueArray *return_vals; GimpImage *image; gboolean enabled = FALSE; image = gimp_value_get_image (&args->values[0], gimp); if (success) { enabled = gimp_image_undo_is_enabled (image); } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) g_value_set_boolean (&return_vals->values[1], enabled); return return_vals; }
static void file_open_sanitize_image (GimpImage *image, gboolean as_new) { if (as_new) gimp_image_set_uri (image, NULL); /* clear all undo steps */ gimp_image_undo_free (image); /* make sure that undo is enabled */ while (! gimp_image_undo_is_enabled (image)) gimp_image_undo_thaw (image); /* Set the image to clean. Note that export dirtiness is not set to * clean here; we can only consider export clean after the first * export */ gimp_image_clean_all (image); /* make sure the entire projection is properly constructed, because * load plug-ins are not required to call gimp_drawable_update() or * anything. */ gimp_image_invalidate (image, 0, 0, gimp_image_get_width (image), gimp_image_get_height (image)); gimp_image_flush (image); /* same for drawable previews */ gimp_image_invalidate_previews (image); }
static void file_open_sanitize_image (GimpImage *image, gboolean as_new) { if (as_new) gimp_image_set_file (image, NULL); /* clear all undo steps */ gimp_image_undo_free (image); /* make sure that undo is enabled */ while (! gimp_image_undo_is_enabled (image)) gimp_image_undo_thaw (image); /* Set the image to clean. Note that export dirtiness is not set to * clean here; we can only consider export clean after the first * export */ gimp_image_clean_all (image); /* Make sure the projection is completely constructed from valid * layers, this is needed in case something triggers projection or * image preview creation before all layers are loaded, see bug #767663. */ gimp_image_invalidate (image, 0, 0, gimp_image_get_width (image), gimp_image_get_height (image)); /* Make sure all image states are up-to-date */ gimp_image_flush (image); }
/* --------------------------------------- * gap_track_detail_on_top_layers_lastvals * --------------------------------------- * processing based on last values used in the same gimp session. * (uses defaults when called the 1.st time) * Intended for use in the player */ gint32 gap_track_detail_on_top_layers_lastvals(gint32 imageId) { gint32 rc; gboolean doProgress; FilterValues fiVals; /* clear undo stack */ if (gimp_image_undo_is_enabled(imageId)) { gimp_image_undo_disable(imageId); } doProgress = FALSE; gap_detail_tracking_get_values(&fiVals); rc = gap_track_detail_on_top_layers(imageId, doProgress, &fiVals); gimp_image_undo_enable(imageId); /* clear undo stack */ return(rc); } /* end gap_track_detail_on_top_layers_lastvals */
void edit_actions_update (GimpActionGroup *group, gpointer data) { GimpImage *image = action_data_get_image (data); GimpDisplay *display = action_data_get_display (data); GimpDrawable *drawable = NULL; gchar *undo_name = NULL; gchar *redo_name = NULL; gchar *fade_name = NULL; gboolean writable = FALSE; gboolean children = FALSE; gboolean undo_enabled = FALSE; gboolean fade_enabled = FALSE; if (image) { drawable = gimp_image_get_active_drawable (image); if (drawable) { writable = ! gimp_item_is_content_locked (GIMP_ITEM (drawable)); if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) children = TRUE; } undo_enabled = gimp_image_undo_is_enabled (image); if (undo_enabled) { GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image); GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image); GimpUndo *undo = gimp_undo_stack_peek (undo_stack); GimpUndo *redo = gimp_undo_stack_peek (redo_stack); const gchar *tool_undo = NULL; const gchar *tool_redo = NULL; if (display) { tool_undo = tool_manager_get_undo_desc_active (image->gimp, display); tool_redo = tool_manager_get_redo_desc_active (image->gimp, display); } if (tool_undo) undo_name = g_strdup_printf (_("_Undo %s"), tool_undo); else if (undo) undo_name = g_strdup_printf (_("_Undo %s"), gimp_object_get_name (undo)); if (tool_redo) redo_name = g_strdup_printf (_("_Redo %s"), tool_redo); else if (redo) redo_name = g_strdup_printf (_("_Redo %s"), gimp_object_get_name (redo)); undo = gimp_image_undo_get_fadeable (image); if (GIMP_IS_DRAWABLE_UNDO (undo) && GIMP_DRAWABLE_UNDO (undo)->applied_buffer) { fade_enabled = TRUE; } if (fade_enabled) { fade_name = g_strdup_printf (_("_Fade %s..."), gimp_object_get_name (undo)); } } } #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) SET_LABEL ("edit-undo", undo_name ? undo_name : _("_Undo")); SET_LABEL ("edit-redo", redo_name ? redo_name : _("_Redo")); SET_LABEL ("edit-fade", fade_name ? fade_name : _("_Fade...")); SET_SENSITIVE ("edit-undo", undo_enabled && undo_name); SET_SENSITIVE ("edit-redo", undo_enabled && redo_name); SET_SENSITIVE ("edit-strong-undo", undo_enabled && undo_name); SET_SENSITIVE ("edit-strong-redo", undo_enabled && redo_name); SET_SENSITIVE ("edit-undo-clear", undo_enabled && (undo_name || redo_name)); SET_SENSITIVE ("edit-fade", fade_enabled && fade_name); g_free (undo_name); g_free (redo_name); g_free (fade_name); SET_SENSITIVE ("edit-cut", writable && !children); SET_SENSITIVE ("edit-copy", drawable); SET_SENSITIVE ("edit-copy-visible", image); SET_SENSITIVE ("edit-paste", !image || (!drawable || (writable && !children))); SET_SENSITIVE ("edit-paste-as-new-layer", image); SET_SENSITIVE ("edit-paste-into", image && (!drawable || (writable && !children))); SET_SENSITIVE ("edit-named-cut", writable && !children); SET_SENSITIVE ("edit-named-copy", drawable); SET_SENSITIVE ("edit-named-copy-visible", drawable); SET_SENSITIVE ("edit-named-paste", TRUE); SET_SENSITIVE ("edit-clear", writable && !children); SET_SENSITIVE ("edit-fill-fg", writable && !children); SET_SENSITIVE ("edit-fill-bg", writable && !children); SET_SENSITIVE ("edit-fill-pattern", writable && !children); #undef SET_LABEL #undef SET_SENSITIVE }
/* ------------------------------------------------------- * gap_image_set_selection_from_selection_or_drawable * ------------------------------------------------------- * create a selection in the specified image_id. * The selection is a scaled copy of the selection in another image, * referred by ref_drawable_id, or a Grayscale copy of the specified ref_drawable_id * (in case the referred image has no selection or the flag force_from_drawable is TRUE) * * - operates on a duplicate of the image referred by ref_drawable_id. * - this duplicate is scaled to same size as specified image_id * * return TRUE in case the selection was successfully created . */ gboolean gap_image_set_selection_from_selection_or_drawable(gint32 image_id, gint32 ref_drawable_id , gboolean force_from_drawable) { gint32 l_aux_channel_id; gint32 ref_image_id; gint32 work_drawable_id; /* the duplicate of the layer that is used as selction mask */ gint32 dup_image_id; gboolean has_selection; gboolean non_empty; gint x1, y1, x2, y2; if ((image_id < 0) || (ref_drawable_id < 0)) { return (FALSE); } ref_image_id = gimp_item_get_image(ref_drawable_id); if (ref_image_id < 0) { printf("ref_drawable_id does not refer to a valid image layer_id:%d\n", (int)ref_drawable_id); return (FALSE); } dup_image_id = gimp_image_duplicate(ref_image_id); if (dup_image_id < 0) { printf("duplicating of image failed, referred souce image_id:%d\n", (int)ref_image_id); return (FALSE); } /* clear undo stack */ if (gimp_image_undo_is_enabled(dup_image_id)) { gimp_image_undo_disable(dup_image_id); } if ((gimp_image_width(image_id) != gimp_image_width(dup_image_id)) || (gimp_image_height(image_id) != gimp_image_height(dup_image_id))) { if(gap_debug) { printf("scaling tmp image_id: %d\n", (int)dup_image_id); } gimp_image_scale(dup_image_id, gimp_image_width(image_id), gimp_image_height(image_id)); } has_selection = gimp_selection_bounds(ref_image_id, &non_empty, &x1, &y1, &x2, &y2); if ((has_selection) && (non_empty) && (force_from_drawable != TRUE)) { /* use scaled copy of the already exisating selection in the referred image */ work_drawable_id = gimp_image_get_selection(dup_image_id); } else { gint32 active_layer_stackposition; /* create selection as gray copy of the alt_selection layer */ active_layer_stackposition = gap_layer_get_stackposition(ref_image_id, ref_drawable_id); if(gimp_image_base_type(dup_image_id) != GIMP_GRAY) { if(gap_debug) { printf("convert to GRAYSCALE tmp image_id: %d\n", (int)dup_image_id); } gimp_image_convert_grayscale(dup_image_id); } work_drawable_id = gap_layer_get_id_by_stackposition(dup_image_id, active_layer_stackposition); gimp_layer_resize_to_image_size (work_drawable_id); } gimp_selection_all(image_id); //l_sel_channel_id = gimp_image_get_selection(image_id); l_aux_channel_id = gimp_selection_save(image_id); /* copy the work drawable (layer or channel) into the selection channel * the work layer is a grayscale copy GRAY or GRAYA of the alt_selection layer * that is already scaled and resized to fit the size of the target image * the work channel is the scaled selection of the image refred by ref_drawable_id * * copying is done into an auxiliary channel from where we regulary load the selection. * this is done because subseqent queries of the selection boudaries will deliver * full channel size rectangle after a direct copy into the selection. */ gap_layer_copy_picked_channel (l_aux_channel_id /* dst_drawable_id*/ , 0 /* dst_channel_pick */ , work_drawable_id /* src_drawable_id */ , 0 /* src_channel_pick */ , FALSE /* gboolean shadow */ ); gimp_image_select_item(image_id, GIMP_CHANNEL_OP_REPLACE, l_aux_channel_id); gimp_image_remove_channel(image_id, l_aux_channel_id); gap_image_delete_immediate(dup_image_id); return (TRUE); } /* end gap_image_set_selection_from_selection_or_drawable */