[gimp] app: fix the brush editor to not dirty every brush set on it
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix the brush editor to not dirty every brush set on it
- Date: Tue, 24 Feb 2015 19:27:08 +0000 (UTC)
commit f425f539f8f443441ff84e0d074bc8373a4b5e23
Author: Michael Natterer <mitch gimp org>
Date: Tue Feb 24 20:23:55 2015 +0100
app: fix the brush editor to not dirty every brush set on it
gimp_brush_editor_update_brush(): only set the brush property whose
GtkAdjustment has changed, and only set it if it is different from the
current value. Before, simply setting a brush on the editor would
cause all properties to be written back to the brush unconditionally.
gimp_brush_editor_notify_brush(): unrelated cleanup: use brush
accessors instead of direct struct access, remove an update of the
radius property from the shape updating code that was probably left
over from copy and paste.
app/widgets/gimpbrusheditor.c | 95 ++++++++++++++++++++---------------------
1 files changed, 46 insertions(+), 49 deletions(-)
---
diff --git a/app/widgets/gimpbrusheditor.c b/app/widgets/gimpbrusheditor.c
index b4459f2..7f89329 100644
--- a/app/widgets/gimpbrusheditor.c
+++ b/app/widgets/gimpbrusheditor.c
@@ -325,53 +325,53 @@ gimp_brush_editor_update_brush (GtkAdjustment *adjustment,
GimpBrushEditor *editor)
{
GimpBrushGenerated *brush;
- gdouble radius;
- gint spikes;
- gdouble hardness;
- gdouble ratio;
- gdouble angle;
- gdouble spacing;
+ gdouble value;
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));
+ g_signal_handlers_block_by_func (brush,
+ gimp_brush_editor_notify_brush,
+ editor);
- 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);
+ value = gtk_adjustment_get_value (adjustment);
- 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);
+ if (adjustment == editor->radius_data)
+ {
+ if (value != gimp_brush_generated_get_radius (brush))
+ gimp_brush_generated_set_radius (brush, value);
+ }
+ else if (adjustment == editor->spikes_data)
+ {
+ if (ROUND (value) != gimp_brush_generated_get_spikes (brush))
+ gimp_brush_generated_set_spikes (brush, ROUND (value));
+ }
+ else if (adjustment == editor->hardness_data)
+ {
+ if (value != gimp_brush_generated_get_hardness (brush))
+ gimp_brush_generated_set_hardness (brush, value);
}
+ else if (adjustment == editor->aspect_ratio_data)
+ {
+ if (value != gimp_brush_generated_get_aspect_ratio (brush))
+ gimp_brush_generated_set_aspect_ratio (brush, value);
+ }
+ else if (adjustment == editor->angle_data)
+ {
+ if (value != gimp_brush_generated_get_angle (brush))
+ gimp_brush_generated_set_angle (brush, value);
+ }
+ else if (adjustment == editor->spacing_data)
+ {
+ if (value != gimp_brush_get_spacing (GIMP_BRUSH (brush)))
+ gimp_brush_set_spacing (GIMP_BRUSH (brush), value);
+ }
+
+ g_signal_handlers_unblock_by_func (brush,
+ gimp_brush_editor_notify_brush,
+ editor);
}
static void
@@ -398,9 +398,9 @@ gimp_brush_editor_update_shape (GtkWidget *widget,
}
static void
-gimp_brush_editor_notify_brush (GimpBrushGenerated *brush,
- GParamSpec *pspec,
- GimpBrushEditor *editor)
+gimp_brush_editor_notify_brush (GimpBrushGenerated *brush,
+ GParamSpec *pspec,
+ GimpBrushEditor *editor)
{
GtkAdjustment *adj = NULL;
gdouble value = 0.0;
@@ -417,34 +417,31 @@ gimp_brush_editor_notify_brush (GimpBrushGenerated *brush,
g_signal_handlers_unblock_by_func (editor->shape_group,
gimp_brush_editor_update_shape,
editor);
-
- adj = editor->radius_data;
- value = brush->radius;
}
else if (! strcmp (pspec->name, "radius"))
{
adj = editor->radius_data;
- value = brush->radius;
+ value = gimp_brush_generated_get_radius (brush);
}
else if (! strcmp (pspec->name, "spikes"))
{
adj = editor->spikes_data;
- value = brush->spikes;
+ value = gimp_brush_generated_get_spikes (brush);
}
else if (! strcmp (pspec->name, "hardness"))
{
adj = editor->hardness_data;
- value = brush->hardness;
+ value = gimp_brush_generated_get_hardness (brush);
}
else if (! strcmp (pspec->name, "angle"))
{
adj = editor->angle_data;
- value = brush->angle;
+ value = gimp_brush_generated_get_angle (brush);
}
else if (! strcmp (pspec->name, "aspect-ratio"))
{
adj = editor->aspect_ratio_data;
- value = brush->aspect_ratio;
+ value = gimp_brush_generated_get_aspect_ratio (brush);
}
else if (! strcmp (pspec->name, "spacing"))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]