static void vectors_edit_attributes_callback (GtkWidget *dialog, GimpImage *image, GimpVectors *vectors, GimpContext *context, const gchar *vectors_name, gboolean vectors_visible, gboolean vectors_linked, GimpColorTag vectors_color_tag, gboolean vectors_lock_content, gboolean vectors_lock_position, gpointer user_data) { GimpItem *item = GIMP_ITEM (vectors); if (strcmp (vectors_name, gimp_object_get_name (vectors)) || vectors_visible != gimp_item_get_visible (item) || vectors_linked != gimp_item_get_linked (item) || vectors_color_tag != gimp_item_get_color_tag (item) || vectors_lock_content != gimp_item_get_lock_content (item) || vectors_lock_position != gimp_item_get_lock_position (item)) { gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_PROPERTIES, _("Path Attributes")); if (strcmp (vectors_name, gimp_object_get_name (vectors))) gimp_item_rename (GIMP_ITEM (vectors), vectors_name, NULL); if (vectors_visible != gimp_item_get_visible (item)) gimp_item_set_visible (item, vectors_visible, TRUE); if (vectors_linked != gimp_item_get_linked (item)) gimp_item_set_linked (item, vectors_linked, TRUE); if (vectors_color_tag != gimp_item_get_color_tag (item)) gimp_item_set_color_tag (item, vectors_color_tag, TRUE); if (vectors_lock_content != gimp_item_get_lock_content (item)) gimp_item_set_lock_content (item, vectors_lock_content, TRUE); if (vectors_lock_position != gimp_item_get_lock_position (item)) gimp_item_set_lock_position (item, vectors_lock_position, TRUE); gimp_image_undo_group_end (image); gimp_image_flush (image); } gtk_widget_destroy (dialog); }
static void vectors_edit_vectors_response (GtkWidget *widget, gint response_id, VectorsOptionsDialog *options) { if (response_id == GTK_RESPONSE_OK) { GimpVectors *vectors = options->vectors; const gchar *new_name; new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry)); if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors)))) { gimp_item_rename (GIMP_ITEM (vectors), new_name, NULL); gimp_image_flush (options->image); } } gtk_widget_destroy (options->dialog); }
void gimp_image_set_quick_mask_state (GimpImage *image, gboolean active) { GimpChannel *selection; GimpChannel *mask; gboolean channel_was_active; g_return_if_fail (GIMP_IS_IMAGE (image)); if (active == gimp_image_get_quick_mask_state (image)) return; /* Keep track of the state so that we can make the right drawable * active again when deactiviting quick mask (see bug #134371). */ if (image->quick_mask_state) channel_was_active = (image->quick_mask_state & CHANNEL_WAS_ACTIVE) != 0; else channel_was_active = gimp_image_get_active_channel (image) != NULL; /* Set image->quick_mask_state early so we can return early when * being called recursively. */ image->quick_mask_state = (active ? TRUE | (channel_was_active ? CHANNEL_WAS_ACTIVE : 0) : FALSE); selection = gimp_image_get_mask (image); mask = gimp_image_get_quick_mask (image); if (active) { if (! mask) { gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_QUICK_MASK, _("Enable Quick Mask")); if (gimp_channel_is_empty (selection)) { /* if no selection */ GimpLayer *floating_sel = gimp_image_floating_sel (image); if (floating_sel) floating_sel_to_layer (floating_sel); mask = gimp_channel_new (image, image->width, image->height, GIMP_IMAGE_QUICK_MASK_NAME, &image->quick_mask_color); /* Clear the mask */ gimp_channel_clear (mask, NULL, FALSE); } else { /* if selection */ mask = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection), GIMP_TYPE_CHANNEL, FALSE)); /* Clear the selection */ gimp_channel_clear (selection, NULL, TRUE); gimp_channel_set_color (mask, &image->quick_mask_color, FALSE); gimp_item_rename (GIMP_ITEM (mask), GIMP_IMAGE_QUICK_MASK_NAME); } if (image->quick_mask_inverted) gimp_channel_invert (mask, FALSE); gimp_image_add_channel (image, mask, 0); gimp_image_undo_group_end (image); } } else { if (mask) { GimpLayer *floating_sel = gimp_image_floating_sel (image); gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_QUICK_MASK, _("Disable Quick Mask")); if (image->quick_mask_inverted) gimp_channel_invert (mask, TRUE); if (floating_sel && floating_sel->fs.drawable == GIMP_DRAWABLE (mask)) floating_sel_anchor (floating_sel); gimp_selection_load (gimp_image_get_mask (image), mask); gimp_image_remove_channel (image, mask); if (! channel_was_active) gimp_image_unset_active_channel (image); gimp_image_undo_group_end (image); } } gimp_image_quick_mask_changed (image); }
GimpImage * file_open_with_proc_and_display (Gimp *gimp, GimpContext *context, GimpProgress *progress, GFile *file, GFile *entered_file, gboolean as_new, GimpPlugInProcedure *file_proc, GObject *screen, gint monitor, GimpPDBStatusType *status, GError **error) { GimpImage *image; const gchar *mime_type = NULL; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL); g_return_val_if_fail (G_IS_FILE (file), NULL); g_return_val_if_fail (G_IS_FILE (entered_file), NULL); g_return_val_if_fail (screen == NULL || G_IS_OBJECT (screen), NULL); g_return_val_if_fail (status != NULL, NULL); image = file_open_image (gimp, context, progress, file, entered_file, as_new, file_proc, GIMP_RUN_INTERACTIVE, status, &mime_type, error); if (image) { /* If the file was imported we want to set the layer name to the * file name. For now, assume that multi-layered imported images * have named the layers already, so only rename the layer of * single-layered imported files. Note that this will also * rename already named layers from e.g. single-layered PSD * files. To solve this properly, we would need new file plug-in * API. */ if (! file_proc) file_proc = gimp_image_get_load_proc (image); if (file_open_file_proc_is_import (file_proc) && gimp_image_get_n_layers (image) == 1) { GimpObject *layer = gimp_image_get_layer_iter (image)->data; gchar *basename; basename = g_path_get_basename (gimp_file_get_utf8_name (file)); gimp_item_rename (GIMP_ITEM (layer), basename, NULL); gimp_image_undo_free (image); gimp_image_clean_all (image); g_free (basename); } if (gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0, screen, monitor)) { /* the display owns the image now */ g_object_unref (image); } if (! as_new) { GimpDocumentList *documents = GIMP_DOCUMENT_LIST (gimp->documents); GimpImagefile *imagefile; GFile *any_file; imagefile = gimp_document_list_add_file (documents, file, mime_type); /* can only create a thumbnail if the passed file and the * resulting image's file match. Use any_file() here so we * create thumbnails for both XCF and imported images. */ any_file = gimp_image_get_any_file (image); if (any_file && g_file_equal (file, any_file)) { /* no need to save a thumbnail if there's a good one already */ if (! gimp_imagefile_check_thumbnail (imagefile)) { gimp_imagefile_save_thumbnail (imagefile, mime_type, image, NULL); } } } /* announce that we opened this image */ gimp_image_opened (image->gimp, file); } return image; }