static void gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view, gint x, gint y, const GimpRGB *color, GimpPattern *pattern) { GimpItem *item; gimp_image_undo_group_start (gimp_item_tree_view_get_image (view), GIMP_UNDO_GROUP_EDIT_PASTE, _("New Layer")); item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->new_item (gimp_item_tree_view_get_image (view)); if (item) { gimp_edit_fill_full (gimp_item_get_image (item), GIMP_DRAWABLE (item), color, pattern, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, pattern ? C_("undo-type", "Drop pattern to layer") : C_("undo-type", "Drop color to layer")); } gimp_image_undo_group_end (gimp_item_tree_view_get_image (view)); gimp_image_flush (gimp_item_tree_view_get_image (view)); }
gboolean gimp_edit_clear (GimpImage *image, GimpDrawable *drawable, GimpContext *context) { GimpRGB background; GimpLayerModeEffects paint_mode; g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE); gimp_context_get_background (context, &background); if (gimp_drawable_has_alpha (drawable)) paint_mode = GIMP_ERASE_MODE; else paint_mode = GIMP_NORMAL_MODE; return gimp_edit_fill_full (image, drawable, &background, NULL, GIMP_OPACITY_OPAQUE, paint_mode, C_("undo-type", "Clear")); }
static void gimp_display_shell_dnd_bucket_fill (GimpDisplayShell *shell, GimpBucketFillMode fill_mode, const GimpRGB *color, GimpPattern *pattern) { GimpImage *image = gimp_display_get_image (shell->display); GimpDrawable *drawable; if (shell->display->gimp->busy) return; if (! image) return; drawable = gimp_image_get_active_drawable (image); if (! drawable) return; if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("Cannot modify the pixels of layer groups.")); return; } if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("The active layer's pixels are locked.")); return; } /* FIXME: there should be a virtual method for this that the * GimpTextLayer can override. */ if (color && gimp_item_is_text_layer (GIMP_ITEM (drawable))) { gimp_text_layer_set (GIMP_TEXT_LAYER (drawable), NULL, "color", color, NULL); } else { gimp_edit_fill_full (image, drawable, color, pattern, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, pattern ? C_("undo-type", "Drop pattern to layer") : C_("undo-type", "Drop color to layer")); } gimp_display_shell_dnd_flush (shell, image); }
gboolean gimp_edit_fill (GimpImage *image, GimpDrawable *drawable, GimpContext *context, GimpFillType fill_type, gdouble opacity, GimpLayerModeEffects paint_mode, GError **error) { GimpRGB color; GimpPattern *pattern; const gchar *undo_desc = NULL; g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if (! gimp_get_fill_params (context, fill_type, &color, &pattern, error)) return FALSE; switch (fill_type) { case GIMP_FILL_FOREGROUND: undo_desc = C_("undo-type", "Fill with Foreground Color"); break; case GIMP_FILL_BACKGROUND: undo_desc = C_("undo-type", "Fill with Background Color"); break; case GIMP_FILL_WHITE: undo_desc = C_("undo-type", "Fill with White"); break; case GIMP_FILL_TRANSPARENT: undo_desc = C_("undo-type", "Fill with Transparency"); break; case GIMP_FILL_PATTERN: undo_desc = C_("undo-type", "Fill with Pattern"); break; } return gimp_edit_fill_full (image, drawable, &color, pattern, opacity, paint_mode, undo_desc); }
static void gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view, const GimpRGB *color, GimpViewable *dest_viewable, GtkTreeViewDropPosition drop_pos) { if (dest_viewable) { gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)), GIMP_DRAWABLE (dest_viewable), color, NULL, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, C_("undo-type", "Drop color to layer")); gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable))); } }
static void gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view, GimpViewable *src_viewable, GimpViewable *dest_viewable, GtkTreeViewDropPosition drop_pos) { if (dest_viewable && GIMP_IS_PATTERN (src_viewable)) { gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)), GIMP_DRAWABLE (dest_viewable), NULL, GIMP_PATTERN (src_viewable), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, C_("undo-type", "Drop pattern to layer")); gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable))); return; } GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (view, src_viewable, dest_viewable, drop_pos); }