static gboolean gimp_bucket_fill_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { return FALSE; } if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("Cannot modify the pixels of layer groups.")); return FALSE; } if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("The active layer's pixels are locked.")); return FALSE; } if (! gimp_item_is_visible (GIMP_ITEM (drawable))) { g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("The active layer is not visible.")); return FALSE; } return TRUE; }
void gimp_image_resize_to_selection (GimpImage *image, GimpContext *context, GimpProgress *progress) { GimpChannel *selection = gimp_image_get_mask (image); gint x, y, w, h; if (gimp_item_bounds (GIMP_ITEM (selection), &x, &y, &w, &h)) { gimp_image_resize (image, context, w, h, -x, -y, progress); } }
static void gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool) { GimpTool *tool = GIMP_TOOL (blend_tool); gint off_x, off_y; gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y); gegl_node_set (blend_tool->render_node, "start_x", blend_tool->start_x - off_x, "start_y", blend_tool->start_y - off_y, "end_x", blend_tool->end_x - off_x, "end_y", blend_tool->end_y - off_y, NULL); }
static void gimp_viewable_dialog_name_changed (GimpObject *object, GimpViewableDialog *dialog) { gchar *name; name = gimp_viewable_get_description (GIMP_VIEWABLE (object), NULL); if (GIMP_IS_ITEM (object)) { GimpImage *image = gimp_item_get_image (GIMP_ITEM (object)); gchar *tmp; tmp = name; name = g_strdup_printf ("%s-%d (%s)", tmp, gimp_item_get_ID (GIMP_ITEM (object)), gimp_image_get_display_name (image)); g_free (tmp); } gtk_label_set_text (GTK_LABEL (dialog->viewable_label), name); g_free (name); }
static void gimp_blend_tool_update_graph (GimpBlendTool *blend_tool) { GimpTool *tool = GIMP_TOOL (blend_tool); gint off_x, off_y; gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y); #if 0 if (gimp_blend_tool_is_shapeburst (blend_tool)) { gfloat start, end; gegl_buffer_get (blend_tool->dist_buffer, GEGL_RECTANGLE (blend_tool->start_x - off_x, blend_tool->start_y - off_y, 1, 1), 1.0, babl_format("Y float"), &start, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); gegl_buffer_get (blend_tool->dist_buffer, GEGL_RECTANGLE (blend_tool->end_x - off_x, blend_tool->end_y - off_y, 1, 1), 1.0, babl_format("Y float"), &end, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); if (start != end) { gegl_node_set (blend_tool->subtract_node, "value", (gdouble) start, NULL); gegl_node_set (blend_tool->divide_node, "value", (gdouble) (end - start), NULL); } } else #endif { gegl_node_set (blend_tool->render_node, "start_x", blend_tool->start_x - off_x, "start_y", blend_tool->start_y - off_y, "end_x", blend_tool->end_x - off_x, "end_y", blend_tool->end_y - off_y, NULL); } }
gboolean gimp_paint_core_stroke (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, GimpCoords *strokes, gint n_strokes, gboolean push_undo, GError **error) { g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), 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_PAINT_OPTIONS (paint_options), FALSE); g_return_val_if_fail (strokes != NULL, FALSE); g_return_val_if_fail (n_strokes > 0, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if (gimp_paint_core_start (core, drawable, paint_options, &strokes[0], error)) { gint i; core->last_coords = strokes[0]; gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_INIT, 0); gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_MOTION, 0); for (i = 1; i < n_strokes; i++) { gimp_paint_core_interpolate (core, drawable, paint_options, &strokes[i], 0); } gimp_paint_core_paint (core, drawable, paint_options, GIMP_PAINT_STATE_FINISH, 0); gimp_paint_core_finish (core, drawable, push_undo); gimp_paint_core_cleanup (core); return TRUE; } return FALSE; }
void gimp_item_get_preview_size (GimpViewable *viewable, gint size, gboolean is_popup, gboolean dot_for_dot, gint *width, gint *height) { GimpItem *item = GIMP_ITEM (viewable); GimpImage *image = gimp_item_get_image (item); if (image && ! image->gimp->config->layer_previews && ! is_popup) { *width = size; *height = size; return; } if (image && ! is_popup) { gdouble xres; gdouble yres; gimp_image_get_resolution (image, &xres, &yres); gimp_viewable_calc_preview_size (gimp_image_get_width (image), gimp_image_get_height (image), size, size, dot_for_dot, xres, yres, width, height, NULL); } else { gimp_viewable_calc_preview_size (gimp_item_get_width (item), gimp_item_get_height (item), size, size, dot_for_dot, 1.0, 1.0, width, height, NULL); } }
void select_actions_update (GimpActionGroup *group, gpointer data) { GimpImage *image = action_data_get_image (data); GimpDrawable *drawable = NULL; gboolean fs = FALSE; gboolean sel = FALSE; gboolean writable = FALSE; gboolean children = 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; } fs = (gimp_image_get_floating_selection (image) != NULL); sel = ! gimp_channel_is_empty (gimp_image_get_mask (image)); } #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) SET_SENSITIVE ("select-all", drawable); SET_SENSITIVE ("select-none", drawable && sel); SET_SENSITIVE ("select-invert", drawable); SET_SENSITIVE ("select-float", writable && !children && sel); SET_SENSITIVE ("select-feather", drawable && sel); SET_SENSITIVE ("select-sharpen", drawable && sel); SET_SENSITIVE ("select-shrink", drawable && sel); SET_SENSITIVE ("select-grow", drawable && sel); SET_SENSITIVE ("select-border", drawable && sel); SET_SENSITIVE ("select-flood", drawable && sel); SET_SENSITIVE ("select-save", drawable && !fs); SET_SENSITIVE ("select-stroke", writable && !children && sel); SET_SENSITIVE ("select-stroke-last-values", writable && !children && sel); #undef SET_SENSITIVE }
static void gimp_warp_tool_button_press (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpButtonPressType press_type, GimpDisplay *display) { GimpWarpTool *wt = GIMP_WARP_TOOL (tool); GimpWarpOptions *options = GIMP_WARP_TOOL_GET_OPTIONS (wt); GeglNode *new_op; gint off_x, off_y; if (tool->display && display != tool->display) gimp_warp_tool_halt (wt); if (! tool->display) gimp_warp_tool_start (wt, display); wt->current_stroke = gegl_path_new (); new_op = gegl_node_new_child (NULL, "operation", "gegl:warp", "behavior", options->behavior, "strength", options->effect_strength, "size", options->effect_size, "hardness", options->effect_hardness, "stroke", wt->current_stroke, NULL); gimp_warp_tool_add_op (wt, new_op); g_object_unref (new_op); g_signal_connect (wt->current_stroke, "changed", G_CALLBACK (gimp_warp_tool_stroke_changed), wt); gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y); gegl_path_append (wt->current_stroke, 'M', coords->x - off_x, coords->y - off_y); wt->stroke_timer = g_timeout_add (STROKE_PERIOD, (GSourceFunc) gimp_warp_tool_stroke_timer, wt); gimp_tool_control_activate (tool->control); }
TempBuf * gimp_paint_core_get_paint_area (GimpPaintCore *core, GimpDrawable *drawable, GimpPaintOptions *paint_options, const GimpCoords *coords) { g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), NULL); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL); g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), NULL); g_return_val_if_fail (coords != NULL, NULL); return GIMP_PAINT_CORE_GET_CLASS (core)->get_paint_area (core, drawable, paint_options, coords); }
void vectors_duplicate_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpVectors *vectors; GimpVectors *new_vectors; return_if_no_vectors (image, vectors, data); new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors), G_TYPE_FROM_INSTANCE (vectors), TRUE)); gimp_image_add_vectors (image, new_vectors, -1); gimp_image_flush (image); }
void vectors_stroke_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpVectors *vectors; return_if_no_vectors (image, vectors, data); items_stroke_cmd_callback (action, image, GIMP_ITEM (vectors), "gimp-vectors-stroke-dialog", _("Stroke Path"), GIMP_ICON_PATH_STROKE, GIMP_HELP_PATH_STROKE, data); }
void gimp_channel_combine_rect (GimpChannel *mask, GimpChannelOps op, gint x, gint y, gint w, gint h) { GeglBuffer *buffer; g_return_if_fail (GIMP_IS_CHANNEL (mask)); buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)); if (! gimp_gegl_mask_combine_rect (buffer, op, x, y, w, h)) return; gimp_rectangle_intersect (x, y, w, h, 0, 0, gimp_item_get_width (GIMP_ITEM (mask)), gimp_item_get_height (GIMP_ITEM (mask)), &x, &y, &w, &h); /* Determine new boundary */ if (mask->bounds_known && (op == GIMP_CHANNEL_OP_ADD) && ! mask->empty) { if (x < mask->x1) mask->x1 = x; if (y < mask->y1) mask->y1 = y; if ((x + w) > mask->x2) mask->x2 = (x + w); if ((y + h) > mask->y2) mask->y2 = (y + h); } else if (op == GIMP_CHANNEL_OP_REPLACE || mask->empty) { mask->empty = FALSE; mask->x1 = x; mask->y1 = y; mask->x2 = x + w; mask->y2 = y + h; } else { mask->bounds_known = FALSE; } mask->x1 = CLAMP (mask->x1, 0, gimp_item_get_width (GIMP_ITEM (mask))); mask->y1 = CLAMP (mask->y1, 0, gimp_item_get_height (GIMP_ITEM (mask))); mask->x2 = CLAMP (mask->x2, 0, gimp_item_get_width (GIMP_ITEM (mask))); mask->y2 = CLAMP (mask->y2, 0, gimp_item_get_height (GIMP_ITEM (mask))); gimp_drawable_update (GIMP_DRAWABLE (mask), x, y, w, h); }
void vectors_fill_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpVectors *vectors; return_if_no_vectors (image, vectors, data); items_fill_cmd_callback (action, image, GIMP_ITEM (vectors), "gimp-vectors-fill-dialog", _("Fill Path"), GIMP_ICON_TOOL_BUCKET_FILL, GIMP_HELP_PATH_FILL, data); }
static void offset_half_xy_callback (GtkWidget *widget, OffsetDialog *dialog) { GimpImage *image = dialog->image; if (image) { GimpItem *item = GIMP_ITEM (gimp_image_get_active_drawable (image)); gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (dialog->off_se), 0, gimp_item_get_width (item) / 2); gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (dialog->off_se), 1, gimp_item_get_height (item) / 2); } }
void gimp_drawable_curves_spline (GimpDrawable *drawable, GimpProgress *progress, gint32 channel, const guint8 *points, gint n_points) { GimpCurvesConfig *config; GimpCurve *curve; gint i; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (! gimp_drawable_is_indexed (drawable)); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); g_return_if_fail (channel >= GIMP_HISTOGRAM_VALUE && channel <= GIMP_HISTOGRAM_ALPHA); if (channel == GIMP_HISTOGRAM_ALPHA) g_return_if_fail (gimp_drawable_has_alpha (drawable)); if (gimp_drawable_is_gray (drawable)) g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE || channel == GIMP_HISTOGRAM_ALPHA); config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL); curve = config->curve[channel]; gimp_data_freeze (GIMP_DATA (curve)); /* FIXME: create a curves object with the right number of points */ /* unset the last point */ gimp_curve_set_point (curve, curve->n_points - 1, -1, -1); n_points = MIN (n_points / 2, curve->n_points); for (i = 0; i < n_points; i++) gimp_curve_set_point (curve, i, (gdouble) points[i * 2] / 255.0, (gdouble) points[i * 2 + 1] / 255.0); gimp_data_thaw (GIMP_DATA (curve)); gimp_drawable_curves (drawable, progress, config); g_object_unref (config); }
void select_stroke_last_vals_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpDrawable *drawable; GimpContext *context; GtkWidget *widget; GimpStrokeOptions *options; GError *error = NULL; return_if_no_image (image, data); return_if_no_context (context, data); return_if_no_widget (widget, data); drawable = gimp_image_get_active_drawable (image); if (! drawable) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, _("There is no active layer or channel to stroke to.")); return; } options = g_object_get_data (G_OBJECT (image->gimp), "saved-stroke-options"); if (options) g_object_ref (options); else options = gimp_stroke_options_new (image->gimp, context, TRUE); if (! gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)), drawable, context, options, NULL, TRUE, NULL, &error)) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } else { gimp_image_flush (image); } g_object_unref (options); }
gboolean gimp_item_get_popup_size (GimpViewable *viewable, gint width, gint height, gboolean dot_for_dot, gint *popup_width, gint *popup_height) { GimpItem *item = GIMP_ITEM (viewable); GimpImage *image = gimp_item_get_image (item); if (image && ! image->gimp->config->layer_previews) return FALSE; if (gimp_item_get_width (item) > width || gimp_item_get_height (item) > height) { gboolean scaling_up; gdouble xres = 1.0; gdouble yres = 1.0; if (image) gimp_image_get_resolution (image, &xres, &yres); gimp_viewable_calc_preview_size (gimp_item_get_width (item), gimp_item_get_height (item), width * 2, height * 2, dot_for_dot, xres, yres, popup_width, popup_height, &scaling_up); if (scaling_up) { *popup_width = gimp_item_get_width (item); *popup_height = gimp_item_get_height (item); } return TRUE; } return FALSE; }
static GimpValueArray * selection_bounds_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; GimpImage *image; gboolean non_empty = FALSE; gint32 x1 = 0; gint32 y1 = 0; gint32 x2 = 0; gint32 y2 = 0; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); if (success) { gint x, y, w, h; non_empty = gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)), &x, &y, &w, &h); x1 = x; y1 = y; x2 = x + w; y2 = y + h; } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) { g_value_set_boolean (gimp_value_array_index (return_vals, 1), non_empty); g_value_set_int (gimp_value_array_index (return_vals, 2), x1); g_value_set_int (gimp_value_array_index (return_vals, 3), y1); g_value_set_int (gimp_value_array_index (return_vals, 4), x2); g_value_set_int (gimp_value_array_index (return_vals, 5), y2); } return return_vals; }
GimpLayer * gimp_image_merge_down (GimpImage *image, GimpLayer *current_layer, GimpContext *context, GimpMergeType merge_type) { GimpLayer *layer; GList *list; GList *layer_list; GSList *merge_list; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); for (list = GIMP_LIST (image->layers)->list, layer_list = NULL; list && !layer_list; list = g_list_next (list)) { layer = list->data; if (layer == current_layer) break; } for (layer_list = g_list_next (list), merge_list = NULL; layer_list && !merge_list; layer_list = g_list_next (layer_list)) { layer = layer_list->data; if (gimp_item_get_visible (GIMP_ITEM (layer))) merge_list = g_slist_append (NULL, layer); } merge_list = g_slist_prepend (merge_list, current_layer); gimp_set_busy (image->gimp); layer = gimp_image_merge_layers (image, merge_list, context, merge_type, _("Merge Down")); g_slist_free (merge_list); gimp_unset_busy (image->gimp); return layer; }
GimpUndo * gimp_image_undo_push_text_layer (GimpImage *image, const gchar *undo_desc, GimpTextLayer *layer, const GParamSpec *pspec) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL); return gimp_image_undo_push (image, GIMP_TYPE_TEXT_UNDO, GIMP_UNDO_TEXT_LAYER, undo_desc, GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE, "item", layer, "param", pspec, NULL); }
GimpUndo * gimp_image_undo_push_drawable_mod (GimpImage *image, const gchar *undo_desc, GimpDrawable *drawable, gboolean copy_buffer) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL); return gimp_image_undo_push (image, GIMP_TYPE_DRAWABLE_MOD_UNDO, GIMP_UNDO_DRAWABLE_MOD, undo_desc, GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE, "item", drawable, "copy-buffer", copy_buffer, NULL); }
GimpUndo * gimp_image_undo_push_mask (GimpImage *image, const gchar *undo_desc, GimpChannel *mask) { g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (GIMP_IS_CHANNEL (mask), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL); return gimp_image_undo_push (image, GIMP_TYPE_MASK_UNDO, GIMP_UNDO_MASK, undo_desc, GIMP_IS_SELECTION (mask) ? GIMP_DIRTY_SELECTION : GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE, "item", mask, NULL); }
static void gimp_paint_tool_motion (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool); GimpPaintCore *core = paint_tool->core; GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpCoords curr_coords; gint off_x, off_y; GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display); if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool))) return; curr_coords = *coords; gimp_paint_core_smooth_coords (core, paint_options, &curr_coords); gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); curr_coords.x -= off_x; curr_coords.y -= off_y; /* don't paint while the Shift key is pressed for line drawing */ if (paint_tool->draw_line) { gimp_paint_core_set_current_coords (core, &curr_coords); return; } gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_paint_core_interpolate (core, drawable, paint_options, &curr_coords, time); gimp_projection_flush_now (gimp_image_get_projection (image)); gimp_display_flush_now (display); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); }
void vectors_stroke_last_vals_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpVectors *vectors; GimpDrawable *drawable; GimpContext *context; GtkWidget *widget; GimpStrokeDesc *desc; GError *error = NULL; return_if_no_vectors (image, vectors, data); return_if_no_context (context, data); return_if_no_widget (widget, data); drawable = gimp_image_get_active_drawable (image); if (! drawable) { gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, _("There is no active layer or channel to stroke to.")); return; } desc = g_object_get_data (G_OBJECT (image->gimp), "saved-stroke-desc"); if (desc) g_object_ref (desc); else desc = gimp_stroke_desc_new (image->gimp, context); if (! gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, desc, FALSE, NULL, &error)) { gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, "%s", error->message); g_clear_error (&error); } else { gimp_image_flush (image); } g_object_unref (desc); }
static void gimp_image_map_tool_add_guide (GimpImageMapTool *im_tool) { GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool); GimpItem *item; GimpImage *image; GimpOrientationType orientation; gint position; if (im_tool->percent_guide) return; item = GIMP_ITEM (im_tool->drawable); image = gimp_item_get_image (item); if (options->preview_alignment == GIMP_ALIGN_LEFT || options->preview_alignment == GIMP_ALIGN_RIGHT) { orientation = GIMP_ORIENTATION_VERTICAL; position = (gimp_item_get_offset_x (item) + gimp_item_get_width (item) * options->preview_position); } else { orientation = GIMP_ORIENTATION_HORIZONTAL; position = (gimp_item_get_offset_y (item) + gimp_item_get_height (item) * options->preview_position); } im_tool->percent_guide = gimp_guide_custom_new (orientation, image->gimp->next_guide_ID++, GIMP_GUIDE_STYLE_SPLIT_VIEW); gimp_image_add_guide (image, im_tool->percent_guide, position); g_signal_connect (im_tool->percent_guide, "removed", G_CALLBACK (gimp_image_map_tool_guide_removed), im_tool); g_signal_connect (im_tool->percent_guide, "notify::position", G_CALLBACK (gimp_image_map_tool_guide_moved), im_tool); }
static GimpValueArray * image_select_color_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 operation; GimpDrawable *drawable; GimpRGB color; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); operation = g_value_get_enum (gimp_value_array_index (args, 1)); drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp); gimp_value_get_rgb (gimp_value_array_index (args, 3), &color); if (success) { GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context); if (pdb_context->sample_merged || gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, 0, error)) { gimp_channel_select_by_color (gimp_image_get_mask (image), drawable, pdb_context->sample_merged, &color, pdb_context->sample_threshold, pdb_context->sample_transparent, pdb_context->sample_criterion, operation, pdb_context->antialias, pdb_context->feather, pdb_context->feather_radius_x, pdb_context->feather_radius_y); } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
void channels_edit_attributes_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpChannel *channel; GtkWidget *widget; GtkWidget *dialog; return_if_no_channel (image, channel, data); return_if_no_widget (widget, data); #define EDIT_DIALOG_KEY "gimp-channel-edit-attributes-dialog" dialog = dialogs_get_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY); if (! dialog) { GimpItem *item = GIMP_ITEM (channel); dialog = channel_options_dialog_new (image, channel, action_data_get_context (data), widget, _("Channel Attributes"), "gimp-channel-edit", "gtk-edit", _("Edit Channel Attributes"), GIMP_HELP_CHANNEL_EDIT, _("Edit Channel Color"), _("_Fill opacity:"), FALSE, gimp_object_get_name (channel), &channel->color, gimp_item_get_visible (item), gimp_item_get_linked (item), gimp_item_get_color_tag (item), gimp_item_get_lock_content (item), gimp_item_get_lock_position (item), channels_edit_attributes_callback, NULL); dialogs_attach_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY, dialog); } gtk_window_present (GTK_WINDOW (dialog)); }
void drawable_flip_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpImage *image; GimpDrawable *drawable; GimpItem *item; GimpContext *context; gint off_x, off_y; gdouble axis = 0.0; return_if_no_drawable (image, drawable, data); return_if_no_context (context, data); item = GIMP_ITEM (drawable); gimp_item_get_offset (item, &off_x, &off_y); switch ((GimpOrientationType) value) { case GIMP_ORIENTATION_HORIZONTAL: axis = ((gdouble) off_x + (gdouble) gimp_item_get_width (item) / 2.0); break; case GIMP_ORIENTATION_VERTICAL: axis = ((gdouble) off_y + (gdouble) gimp_item_get_height (item) / 2.0); break; default: break; } if (gimp_item_get_linked (item)) { gimp_item_linked_flip (item, context, (GimpOrientationType) value, axis, FALSE); } else { gimp_item_flip (item, context, (GimpOrientationType) value, axis, FALSE); } gimp_image_flush (image); }
static GimpChannel * gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select, GimpDisplay *display) { GimpTool *tool = GIMP_TOOL (region_select); GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool); GimpDrawable *drawable; GimpPickable *pickable; GimpRGB color; gint x, y; drawable = gimp_image_get_active_drawable (display->image); x = region_select->x; y = region_select->y; if (! options->sample_merged) { gint off_x, off_y; gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y); x -= off_x; y -= off_y; pickable = GIMP_PICKABLE (drawable); } else { pickable = GIMP_PICKABLE (display->image->projection); } gimp_pickable_flush (pickable); if (gimp_pickable_get_color_at (pickable, x, y, &color)) return gimp_image_contiguous_region_by_color (display->image, drawable, options->sample_merged, options->antialias, options->threshold, options->select_transparent, options->select_criterion, &color); else return NULL; }