GObject * gimp_curves_config_new_spline (gint32 channel, const gdouble *points, gint n_points) { GimpCurvesConfig *config; GimpCurve *curve; gint i; g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE && channel <= GIMP_HISTOGRAM_ALPHA, NULL); g_return_val_if_fail (points != NULL, NULL); g_return_val_if_fail (n_points >= 2 && n_points <= 1024, NULL); config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL); curve = config->curve[channel]; gimp_data_freeze (GIMP_DATA (curve)); gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH); gimp_curve_set_n_samples (curve, n_points); /* unset the last point */ gimp_curve_set_point (curve, curve->n_points - 1, -1.0, -1.0); for (i = 0; i < n_points; i++) gimp_curve_set_point (curve, i, (gdouble) points[i * 2], (gdouble) points[i * 2 + 1]); gimp_data_thaw (GIMP_DATA (curve)); return G_OBJECT (config); }
static GimpValueArray * palette_delete_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; const gchar *name; name = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error); if (palette && gimp_data_is_deletable (GIMP_DATA (palette))) success = gimp_data_factory_data_delete (gimp->palette_factory, GIMP_DATA (palette), TRUE, error); else success = FALSE; } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
GObject * gimp_curves_config_new_explicit (gint32 channel, const gdouble *samples, gint n_samples) { GimpCurvesConfig *config; GimpCurve *curve; gint i; g_return_val_if_fail (channel >= GIMP_HISTOGRAM_VALUE && channel <= GIMP_HISTOGRAM_ALPHA, NULL); g_return_val_if_fail (samples != NULL, NULL); g_return_val_if_fail (n_samples >= 2 && n_samples <= 4096, NULL); config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL); curve = config->curve[channel]; gimp_data_freeze (GIMP_DATA (curve)); gimp_curve_set_curve_type (curve, GIMP_CURVE_FREE); gimp_curve_set_n_samples (curve, n_samples); for (i = 0; i < n_samples; i++) gimp_curve_set_curve (curve, (gdouble) i / (gdouble) (n_samples - 1), (gdouble) samples[i]); gimp_data_thaw (GIMP_DATA (curve)); return G_OBJECT (config); }
void gradient_editor_load_right_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data); GimpGradient *gradient; GimpGradientSegment *seg; GimpRGB color; GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED; gradient = GIMP_GRADIENT (data_editor->data); switch (value) { case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT: if (editor->control_sel_r->next != NULL) seg = editor->control_sel_r->next; else seg = gimp_gradient_segment_get_first (editor->control_sel_r); color = seg->left_color; color_type = seg->left_color_type; break; case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT: color = editor->control_sel_l->left_color; color_type = editor->control_sel_l->left_color_type; break; case GRADIENT_EDITOR_COLOR_FOREGROUND: gimp_context_get_foreground (data_editor->context, &color); break; case GRADIENT_EDITOR_COLOR_BACKGROUND: gimp_context_get_background (data_editor->context, &color); break; default: /* Load a color */ color = editor->saved_colors[value - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM]; break; } gimp_data_freeze (GIMP_DATA (gradient)); gimp_gradient_segment_range_blend (gradient, editor->control_sel_l, editor->control_sel_r, &editor->control_sel_l->left_color, &color, TRUE, TRUE); gimp_gradient_segment_set_right_color_type (gradient, editor->control_sel_l, color_type); gimp_data_thaw (GIMP_DATA (gradient)); }
static void gimp_brush_editor_update_brush (GtkAdjustment *adjustment, GimpBrushEditor *editor) { GimpBrushGenerated *brush; gdouble radius; gint spikes; gdouble hardness; gdouble ratio; gdouble angle; gdouble spacing; if (! GIMP_IS_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data)) return; brush = GIMP_BRUSH_GENERATED (GIMP_DATA_EDITOR (editor)->data); radius = gtk_adjustment_get_value (editor->radius_data); spikes = ROUND (gtk_adjustment_get_value (editor->spikes_data)); hardness = gtk_adjustment_get_value (editor->hardness_data); ratio = gtk_adjustment_get_value (editor->aspect_ratio_data); angle = gtk_adjustment_get_value (editor->angle_data); spacing = gtk_adjustment_get_value (editor->spacing_data); if (radius != gimp_brush_generated_get_radius (brush) || spikes != gimp_brush_generated_get_spikes (brush) || hardness != gimp_brush_generated_get_hardness (brush) || ratio != gimp_brush_generated_get_aspect_ratio (brush) || angle != gimp_brush_generated_get_angle (brush) || spacing != gimp_brush_get_spacing (GIMP_BRUSH (brush))) { g_signal_handlers_block_by_func (brush, gimp_brush_editor_notify_brush, editor); gimp_data_freeze (GIMP_DATA (brush)); g_object_freeze_notify (G_OBJECT (brush)); gimp_brush_generated_set_radius (brush, radius); gimp_brush_generated_set_spikes (brush, spikes); gimp_brush_generated_set_hardness (brush, hardness); gimp_brush_generated_set_aspect_ratio (brush, ratio); gimp_brush_generated_set_angle (brush, angle); gimp_brush_set_spacing (GIMP_BRUSH (brush), spacing); g_object_thaw_notify (G_OBJECT (brush)); gimp_data_thaw (GIMP_DATA (brush)); g_signal_handlers_unblock_by_func (brush, gimp_brush_editor_notify_brush, editor); } }
static GimpValueArray * palette_is_editable_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; const gchar *name; gboolean editable = FALSE; name = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error); if (palette) editable = gimp_data_is_writable (GIMP_DATA (palette)); else success = FALSE; } 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), editable); return return_vals; }
static GValueArray * palette_set_columns_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *name; gint32 columns; name = g_value_get_string (&args->values[0]); columns = g_value_get_int (&args->values[1]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) gimp_palette_set_columns (palette, columns); else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
static GValueArray * palette_is_editable_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gboolean editable = FALSE; name = g_value_get_string (&args->values[0]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) editable = GIMP_DATA (palette)->writable; else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_boolean (&return_vals->values[1], editable); return return_vals; }
void dynamics_actions_update (GimpActionGroup *group, gpointer user_data) { GimpContext *context = action_data_get_context (user_data); GimpDynamics *dynamics = NULL; GimpData *data = NULL; const gchar *filename = NULL; if (context) { dynamics = gimp_context_get_dynamics (context); if (dynamics) { data = GIMP_DATA (dynamics); filename = gimp_data_get_filename (data); } } #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) SET_SENSITIVE ("dynamics-edit", dynamics); SET_SENSITIVE ("dynamics-duplicate", dynamics && GIMP_DATA_GET_CLASS (data)->duplicate); SET_SENSITIVE ("dynamics-copy-location", dynamics && filename); SET_SENSITIVE ("dynamics-delete", dynamics && gimp_data_is_deletable (data)); #undef SET_SENSITIVE }
GimpGradient * gimp_pdb_get_gradient (Gimp *gimp, const gchar *name, gboolean writable, GError **error) { GimpGradient *gradient; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty gradient name")); return NULL; } gradient = (GimpGradient *) gimp_pdb_get_data_factory_item (gimp->gradient_factory, name); if (! gradient) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Gradient '%s' not found"), name); } else if (writable && ! gimp_data_is_writable (GIMP_DATA (gradient))) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Gradient '%s' is not editable"), name); return NULL; } return gradient; }
GimpDynamics * gimp_pdb_get_dynamics (Gimp *gimp, const gchar *name, gboolean writable, GError **error) { GimpDynamics *dynamics; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty paint dynamics name")); return NULL; } dynamics = (GimpDynamics *) gimp_pdb_get_data_factory_item (gimp->dynamics_factory, name); if (! dynamics) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Paint dynamics '%s' not found"), name); } else if (writable && ! gimp_data_is_writable (GIMP_DATA (dynamics))) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Paint dynamics '%s' is not editable"), name); return NULL; } return dynamics; }
GimpData * gimp_pattern_new (GimpContext *context, const gchar *name) { GimpPattern *pattern; guchar *data; gint row, col; g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name[0] != '\n', NULL); pattern = g_object_new (GIMP_TYPE_PATTERN, "name", name, NULL); pattern->mask = gimp_temp_buf_new (32, 32, babl_format ("R'G'B' u8")); data = gimp_temp_buf_get_data (pattern->mask); for (row = 0; row < gimp_temp_buf_get_height (pattern->mask); row++) for (col = 0; col < gimp_temp_buf_get_width (pattern->mask); col++) { memset (data, (col % 2) && (row % 2) ? 255 : 0, 3); data += 3; } return GIMP_DATA (pattern); }
GimpPalette * gimp_pdb_get_palette (Gimp *gimp, const gchar *name, gboolean writable, GError **error) { GimpPalette *palette; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty palette name")); return NULL; } palette = (GimpPalette *) gimp_pdb_get_data_factory_item (gimp->palette_factory, name); if (! palette) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Palette '%s' not found"), name); } else if (writable && ! gimp_data_is_writable (GIMP_DATA (palette))) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Palette '%s' is not editable"), name); return NULL; } return palette; }
GimpData * gimp_brush_generated_new (const gchar *name, GimpBrushGeneratedShape shape, gfloat radius, gint spikes, gfloat hardness, gfloat aspect_ratio, gfloat angle) { GimpBrushGenerated *brush; g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (*name != '\0', NULL); brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED, "name", name, "mime-type", "application/x-gimp-brush-generated", "spacing", 20.0, "shape", shape, "radius", radius, "spikes", spikes, "hardness", hardness, "aspect-ratio", aspect_ratio, "angle", angle, NULL); return GIMP_DATA (brush); }
GimpBrush * gimp_pdb_get_brush (Gimp *gimp, const gchar *name, gboolean writable, GError **error) { GimpBrush *brush; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty brush name")); return NULL; } brush = (GimpBrush *) gimp_pdb_get_data_factory_item (gimp->brush_factory, name); if (! brush) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Brush '%s' not found"), name); } else if (writable && ! gimp_data_is_writable (GIMP_DATA (brush))) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Brush '%s' is not editable"), name); return NULL; } return brush; }
void gimp_curve_delete_point (GimpCurve *curve, gint point) { g_return_if_fail (GIMP_IS_CURVE (curve)); g_return_if_fail (point >= 0 && point < curve->n_points); if (point == 0) { curve->points[0].x = 0.0; curve->points[0].y = 0.0; } else if (point == curve->n_points - 1) { curve->points[curve->n_points - 1].x = 1.0; curve->points[curve->n_points - 1].y = 1.0; } else { curve->points[point].x = -1.0; curve->points[point].y = -1.0; } g_object_notify (G_OBJECT (curve), "points"); gimp_data_dirty (GIMP_DATA (curve)); }
static void palette_editor_edit_color_update (GimpColorDialog *dialog, const GimpRGB *color, GimpColorDialogState state, GimpPaletteEditor *editor) { GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data); switch (state) { case GIMP_COLOR_DIALOG_UPDATE: break; case GIMP_COLOR_DIALOG_OK: if (editor->color) { editor->color->color = *color; gimp_data_dirty (GIMP_DATA (palette)); } /* Fallthrough */ case GIMP_COLOR_DIALOG_CANCEL: gtk_widget_hide (editor->color_dialog); break; } }
void tool_presets_actions_update (GimpActionGroup *group, gpointer user_data) { GimpContext *context = action_data_get_context (user_data); GimpToolPreset *tool_preset = NULL; GimpData *data = NULL; GFile *file = NULL; if (context) { tool_preset = gimp_context_get_tool_preset (context); if (tool_preset) { data = GIMP_DATA (tool_preset); file = gimp_data_get_file (data); } } #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) SET_SENSITIVE ("tool-presets-edit", tool_preset); SET_SENSITIVE ("tool-presets-duplicate", tool_preset && GIMP_DATA_GET_CLASS (data)->duplicate); SET_SENSITIVE ("tool-presets-copy-location", file); SET_SENSITIVE ("tool-presets-show-in-file-manager", file); SET_SENSITIVE ("tool-presets-restore", tool_preset); SET_SENSITIVE ("tool-presets-delete", tool_preset && gimp_data_is_deletable (data)); #undef SET_SENSITIVE }
void context_brush_shape_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; const char *value_desc; gimp_brush_generated_set_shape (generated, (GimpBrushGeneratedShape) value); gimp_enum_get_value (GIMP_TYPE_BRUSH_GENERATED_SHAPE, value, NULL, NULL, &value_desc, NULL); display = action_data_get_display (data); if (value_desc && display) { action_message (display, G_OBJECT (brush), _("Brush Shape: %s"), value_desc); } } }
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 context_brush_radius_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; gdouble radius; gdouble min_radius; radius = gimp_brush_generated_get_radius (generated); /* If the user uses a high precision radius adjustment command * then we allow a minimum radius of 0.1 px, otherwise we set the * minimum radius to 1.0 px and adjust the radius to 1.0 px if it * is less than 1.0 px. This prevents irritating 0.1, 1.1, 2.1 etc * radius sequences when 1.0 px steps are used. */ switch ((GimpActionSelectType) value) { case GIMP_ACTION_SELECT_SMALL_PREVIOUS: case GIMP_ACTION_SELECT_SMALL_NEXT: case GIMP_ACTION_SELECT_PERCENT_PREVIOUS: case GIMP_ACTION_SELECT_PERCENT_NEXT: min_radius = 0.1; break; default: min_radius = 1.0; if (radius < 1.0) radius = 1.0; break; } radius = action_select_value ((GimpActionSelectType) value, radius, min_radius, 4000.0, min_radius, 0.1, 1.0, 10.0, 0.05, FALSE); gimp_brush_generated_set_radius (generated, radius); display = action_data_get_display (data); if (display) { action_message (action_data_get_display (data), G_OBJECT (brush), _("Brush Radius: %2.2f"), radius); } } }
static void palette_editor_drop_palette (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { gimp_data_editor_set_data (GIMP_DATA_EDITOR (data), GIMP_DATA (viewable)); }
static GimpData * gimp_pattern_duplicate (GimpData *data) { GimpPattern *pattern = g_object_new (GIMP_TYPE_PATTERN, NULL); pattern->mask = gimp_temp_buf_copy (GIMP_PATTERN (data)->mask); return GIMP_DATA (pattern); }
void gimp_drawable_curves_explicit (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)); gimp_curve_set_curve_type (curve, GIMP_CURVE_FREE); for (i = 0; i < 256; i++) gimp_curve_set_curve (curve, (gdouble) i / 255.0, (gdouble) points[i] / 255.0); gimp_data_thaw (GIMP_DATA (curve)); gimp_drawable_curves (drawable, progress, config); g_object_unref (config); }
static GValueArray * palette_entry_set_name_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *name; gint32 entry_num; const gchar *entry_name; name = g_value_get_string (&args->values[0]); entry_num = g_value_get_int (&args->values[1]); entry_name = g_value_get_string (&args->values[2]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { if (entry_num >= 0 && entry_num < palette->n_colors) { GimpPaletteEntry *entry = g_list_nth_data (palette->colors, entry_num); g_free (entry->name); entry->name = g_strdup (entry_name); gimp_data_dirty (GIMP_DATA (palette)); } else success = FALSE; } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
static void gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell, const gchar *path_str, const gchar *new_name, GimpDataFactoryView *view) { GimpContainerTreeView *tree_view; GtkTreePath *path; GtkTreeIter iter; tree_view = GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_EDITOR (view)->view); path = gtk_tree_path_new_from_string (path_str); if (gtk_tree_model_get_iter (tree_view->model, &iter, path)) { GimpViewRenderer *renderer; GimpData *data; gchar *name; gtk_tree_model_get (tree_view->model, &iter, tree_view->model_column_renderer, &renderer, -1); data = GIMP_DATA (renderer->viewable); if (! new_name) new_name = ""; name = g_strstrip (g_strdup (new_name)); if (data->writable && strlen (name)) { gimp_object_take_name (GIMP_OBJECT (data), name); } else { g_free (name); name = gimp_viewable_get_description (renderer->viewable, NULL); gtk_list_store_set (GTK_LIST_STORE (tree_view->model), &iter, tree_view->model_column_name, name, -1); g_free (name); } g_object_unref (renderer); } gtk_tree_path_free (path); }
void gradient_editor_right_color_type_cmd_callback (GtkAction *action, GtkAction *current, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gint value; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); if (gradient && value >= 0) { GimpGradientColor color_type = value; GimpRGB color; gimp_gradient_get_color_at (gradient, GIMP_DATA_EDITOR (editor)->context, editor->control_sel_r, editor->control_sel_r->right, FALSE, &color); gimp_data_freeze (GIMP_DATA (gradient)); gimp_gradient_segment_set_right_color_type (gradient, editor->control_sel_r, color_type); if (color_type == GIMP_GRADIENT_COLOR_FIXED) gimp_gradient_segment_set_right_color (gradient, editor->control_sel_r, &color); gimp_data_thaw (GIMP_DATA (gradient)); } }
static GValueArray * palette_delete_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *name; name = g_value_get_string (&args->values[0]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->deletable) { GError *error = NULL; success = gimp_data_factory_data_delete (gimp->palette_factory, GIMP_DATA (palette), TRUE, &error); if (! success) { gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, "%s", error->message); g_clear_error (&error); } } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
void tool_options_delete_preset_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpEditor *editor = GIMP_EDITOR (data); GimpContext *context = gimp_get_user_context (gimp_editor_get_ui_manager (editor)->gimp); GimpToolInfo *tool_info = gimp_context_get_tool (context); GimpToolPreset *preset; preset = (GimpToolPreset *) gimp_container_get_child_by_index (tool_info->presets, value); if (preset && gimp_data_is_deletable (GIMP_DATA (preset))) { GimpDataFactory *factory = context->gimp->tool_preset_factory; GtkWidget *dialog; dialog = data_delete_dialog_new (factory, GIMP_DATA (preset), NULL, GTK_WIDGET (editor)); gtk_widget_show (dialog); } }
void gimp_curve_set_curve_type (GimpCurve *curve, GimpCurveType curve_type) { g_return_if_fail (GIMP_IS_CURVE (curve)); if (curve->curve_type != curve_type) { g_object_freeze_notify (G_OBJECT (curve)); curve->curve_type = curve_type; if (curve_type == GIMP_CURVE_SMOOTH) { gint n_points; gint i; for (i = 0; i < curve->n_points; i++) { curve->points[i].x = -1; curve->points[i].y = -1; } /* pick some points from the curve and make them control * points */ n_points = CLAMP (9, curve->n_points / 2, curve->n_points); for (i = 0; i < n_points; i++) { gint sample = i * (curve->n_samples - 1) / (n_points - 1); gint point = i * (curve->n_points - 1) / (n_points - 1); curve->points[point].x = ((gdouble) sample / (gdouble) (curve->n_samples - 1)); curve->points[point].y = curve->samples[sample]; } g_object_notify (G_OBJECT (curve), "points"); } g_object_notify (G_OBJECT (curve), "curve-type"); g_object_thaw_notify (G_OBJECT (curve)); gimp_data_dirty (GIMP_DATA (curve)); } }