[gimp] app: move all GimpStrokeOptions members to private
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: move all GimpStrokeOptions members to private
- Date: Sat, 5 Mar 2011 20:00:46 +0000 (UTC)
commit fc7bd98d927a99bbc83a8b85af9bbef4654e923c
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 5 21:00:28 2011 +0100
app: move all GimpStrokeOptions members to private
app/core/gimpchannel.c | 15 ++-
app/core/gimpdrawable-stroke.c | 21 +++--
app/core/gimpstrokeoptions.c | 192 ++++++++++++++++++++++++++++++++-------
app/core/gimpstrokeoptions.h | 56 ++++++------
app/dialogs/stroke-dialog.c | 6 +-
app/vectors/gimpvectors.c | 15 ++-
app/widgets/gimpdasheditor.c | 6 +-
app/widgets/gimpstrokeeditor.c | 6 +-
8 files changed, 228 insertions(+), 89 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index a1a9ab8..3940c95 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -731,7 +731,7 @@ gimp_channel_stroke (GimpItem *item,
gimp_item_get_offset (GIMP_ITEM (channel), &offset_x, &offset_y);
- switch (stroke_options->method)
+ switch (gimp_stroke_options_get_method (stroke_options))
{
case GIMP_STROKE_METHOD_LIBART:
gimp_drawable_stroke_boundary (drawable,
@@ -744,16 +744,21 @@ gimp_channel_stroke (GimpItem *item,
case GIMP_STROKE_METHOD_PAINT_CORE:
{
- GimpPaintInfo *paint_info;
- GimpPaintCore *core;
+ GimpPaintInfo *paint_info;
+ GimpPaintCore *core;
+ GimpPaintOptions *paint_options;
+ gboolean emulate_dynamics;
paint_info = gimp_context_get_paint_info (GIMP_CONTEXT (stroke_options));
core = g_object_new (paint_info->paint_type, NULL);
+ paint_options = gimp_stroke_options_get_paint_options (stroke_options);
+ emulate_dynamics = gimp_stroke_options_get_emulate_dynamics (stroke_options);
+
retval = gimp_paint_core_stroke_boundary (core, drawable,
- stroke_options->paint_options,
- stroke_options->emulate_dynamics,
+ paint_options,
+ emulate_dynamics,
segs_in, n_segs_in,
offset_x, offset_y,
push_undo, error);
diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c
index f91f495..0cb786e 100644
--- a/app/core/gimpdrawable-stroke.c
+++ b/app/core/gimpdrawable-stroke.c
@@ -371,9 +371,13 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
if (do_stroke)
{
GimpStrokeOptions *stroke_options = GIMP_STROKE_OPTIONS (options);
- gdouble width = stroke_options->width;
+ gdouble width;
+ GimpUnit unit;
- if (stroke_options->unit != GIMP_UNIT_PIXEL)
+ width = gimp_stroke_options_get_width (stroke_options);
+ unit = gimp_stroke_options_get_unit (stroke_options);
+
+ if (unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
@@ -382,16 +386,15 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
gimp_scan_convert_set_pixel_ratio (scan_convert, yres / xres);
- width = gimp_units_to_pixels (stroke_options->width,
- stroke_options->unit, yres);
+ width = gimp_units_to_pixels (width, unit, yres);
}
gimp_scan_convert_stroke (scan_convert, width,
- stroke_options->join_style,
- stroke_options->cap_style,
- stroke_options->miter_limit,
- stroke_options->dash_offset,
- stroke_options->dash_info);
+ gimp_stroke_options_get_join_style (stroke_options),
+ gimp_stroke_options_get_cap_style (stroke_options),
+ gimp_stroke_options_get_miter_limit (stroke_options),
+ gimp_stroke_options_get_dash_offset (stroke_options),
+ gimp_stroke_options_get_dash_info (stroke_options));
}
/* fill a 1-bpp Tilemanager with black, this will describe the shape
diff --git a/app/core/gimpstrokeoptions.c b/app/core/gimpstrokeoptions.c
index 14398de..6b5163a 100644
--- a/app/core/gimpstrokeoptions.c
+++ b/app/core/gimpstrokeoptions.c
@@ -70,6 +70,35 @@ enum
};
+typedef struct _GimpStrokeOptionsPrivate GimpStrokeOptionsPrivate;
+
+struct _GimpStrokeOptionsPrivate
+{
+ GimpStrokeMethod method;
+
+ /* options for medhod == LIBART */
+ gdouble width;
+ GimpUnit unit;
+
+ GimpCapStyle cap_style;
+ GimpJoinStyle join_style;
+
+ gdouble miter_limit;
+
+ gdouble dash_offset;
+ GArray *dash_info;
+
+ /* options for method == PAINT_TOOL */
+ GimpPaintOptions *paint_options;
+ gboolean emulate_dynamics;
+};
+
+#define GET_PRIVATE(options) \
+ G_TYPE_INSTANCE_GET_PRIVATE (options, \
+ GIMP_TYPE_STROKE_OPTIONS, \
+ GimpStrokeOptionsPrivate)
+
+
static void gimp_stroke_options_config_iface_init (gpointer iface,
gpointer iface_data);
@@ -178,6 +207,8 @@ gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass)
"emulate-brush-dynamics", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+
+ g_type_class_add_private (klass, sizeof (GimpStrokeOptionsPrivate));
}
static void
@@ -202,12 +233,12 @@ gimp_stroke_options_init (GimpStrokeOptions *options)
static void
gimp_stroke_options_finalize (GObject *object)
{
- GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (object);
+ GimpStrokeOptionsPrivate *private = GET_PRIVATE (object);
- if (options->paint_options)
+ if (private->paint_options)
{
- g_object_unref (options->paint_options);
- options->paint_options = NULL;
+ g_object_unref (private->paint_options);
+ private->paint_options = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -219,31 +250,32 @@ gimp_stroke_options_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (object);
+ GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (object);
+ GimpStrokeOptionsPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_METHOD:
- options->method = g_value_get_enum (value);
+ private->method = g_value_get_enum (value);
break;
case PROP_WIDTH:
- options->width = g_value_get_double (value);
+ private->width = g_value_get_double (value);
break;
case PROP_UNIT:
- options->unit = g_value_get_int (value);
+ private->unit = g_value_get_int (value);
break;
case PROP_CAP_STYLE:
- options->cap_style = g_value_get_enum (value);
+ private->cap_style = g_value_get_enum (value);
break;
case PROP_JOIN_STYLE:
- options->join_style = g_value_get_enum (value);
+ private->join_style = g_value_get_enum (value);
break;
case PROP_MITER_LIMIT:
- options->miter_limit = g_value_get_double (value);
+ private->miter_limit = g_value_get_double (value);
break;
case PROP_DASH_OFFSET:
- options->dash_offset = g_value_get_double (value);
+ private->dash_offset = g_value_get_double (value);
break;
case PROP_DASH_INFO:
{
@@ -257,12 +289,12 @@ gimp_stroke_options_set_property (GObject *object,
break;
case PROP_PAINT_OPTIONS:
- if (options->paint_options)
- g_object_unref (options->paint_options);
- options->paint_options = g_value_dup_object (value);
+ if (private->paint_options)
+ g_object_unref (private->paint_options);
+ private->paint_options = g_value_dup_object (value);
break;
case PROP_EMULATE_DYNAMICS:
- options->emulate_dynamics = g_value_get_boolean (value);
+ private->emulate_dynamics = g_value_get_boolean (value);
break;
default:
@@ -277,46 +309,46 @@ gimp_stroke_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (object);
+ GimpStrokeOptionsPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_METHOD:
- g_value_set_enum (value, options->method);
+ g_value_set_enum (value, private->method);
break;
case PROP_WIDTH:
- g_value_set_double (value, options->width);
+ g_value_set_double (value, private->width);
break;
case PROP_UNIT:
- g_value_set_int (value, options->unit);
+ g_value_set_int (value, private->unit);
break;
case PROP_CAP_STYLE:
- g_value_set_enum (value, options->cap_style);
+ g_value_set_enum (value, private->cap_style);
break;
case PROP_JOIN_STYLE:
- g_value_set_enum (value, options->join_style);
+ g_value_set_enum (value, private->join_style);
break;
case PROP_MITER_LIMIT:
- g_value_set_double (value, options->miter_limit);
+ g_value_set_double (value, private->miter_limit);
break;
case PROP_DASH_OFFSET:
- g_value_set_double (value, options->dash_offset);
+ g_value_set_double (value, private->dash_offset);
break;
case PROP_DASH_INFO:
{
GValueArray *value_array;
- value_array = gimp_dash_pattern_to_value_array (options->dash_info);
+ value_array = gimp_dash_pattern_to_value_array (private->dash_info);
g_value_take_boxed (value, value_array);
}
break;
case PROP_PAINT_OPTIONS:
- g_value_set_object (value, options->paint_options);
+ g_value_set_object (value, private->paint_options);
break;
case PROP_EMULATE_DYNAMICS:
- g_value_set_boolean (value, options->emulate_dynamics);
+ g_value_set_boolean (value, private->emulate_dynamics);
break;
default:
@@ -328,16 +360,17 @@ gimp_stroke_options_get_property (GObject *object,
static GimpConfig *
gimp_stroke_options_duplicate (GimpConfig *config)
{
- GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (config);
- GimpStrokeOptions *new_options;
+ GimpStrokeOptions *options = GIMP_STROKE_OPTIONS (config);
+ GimpStrokeOptionsPrivate *private = GET_PRIVATE (options);
+ GimpStrokeOptions *new_options;
new_options = GIMP_STROKE_OPTIONS (parent_config_iface->duplicate (config));
- if (options->paint_options)
+ if (private->paint_options)
{
GObject *paint_options;
- paint_options = gimp_config_duplicate (GIMP_CONFIG (options->paint_options));
+ paint_options = gimp_config_duplicate (GIMP_CONFIG (private->paint_options));
g_object_set (new_options, "paint-options", paint_options, NULL);
g_object_unref (paint_options);
}
@@ -384,6 +417,87 @@ gimp_stroke_options_new (Gimp *gimp,
return options;
}
+GimpStrokeMethod
+gimp_stroke_options_get_method (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options),
+ GIMP_STROKE_METHOD_LIBART);
+
+ return GET_PRIVATE (options)->method;
+}
+
+gdouble
+gimp_stroke_options_get_width (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), 1.0);
+
+ return GET_PRIVATE (options)->width;
+}
+
+GimpUnit
+gimp_stroke_options_get_unit (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), GIMP_UNIT_PIXEL);
+
+ return GET_PRIVATE (options)->unit;
+}
+
+GimpCapStyle
+gimp_stroke_options_get_cap_style (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), GIMP_CAP_BUTT);
+
+ return GET_PRIVATE (options)->cap_style;
+}
+
+GimpJoinStyle
+gimp_stroke_options_get_join_style (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), GIMP_JOIN_MITER);
+
+ return GET_PRIVATE (options)->join_style;
+}
+
+gdouble
+gimp_stroke_options_get_miter_limit (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), 1.0);
+
+ return GET_PRIVATE (options)->miter_limit;
+}
+
+gdouble
+gimp_stroke_options_get_dash_offset (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), 0.0);
+
+ return GET_PRIVATE (options)->dash_offset;
+}
+
+GArray *
+gimp_stroke_options_get_dash_info (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
+
+ return GET_PRIVATE (options)->dash_info;
+}
+
+GimpPaintOptions *
+gimp_stroke_options_get_paint_options (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
+
+ return GET_PRIVATE (options)->paint_options;
+}
+
+gboolean
+gimp_stroke_options_get_emulate_dynamics (GimpStrokeOptions *options)
+{
+ g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), FALSE);
+
+ return GET_PRIVATE (options)->emulate_dynamics;
+}
+
/**
* gimp_stroke_options_take_dash_pattern:
* @options: a #GimpStrokeOptions object
@@ -400,16 +514,20 @@ gimp_stroke_options_take_dash_pattern (GimpStrokeOptions *options,
GimpDashPreset preset,
GArray *pattern)
{
+ GimpStrokeOptionsPrivate *private;
+
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (preset == GIMP_DASH_CUSTOM || pattern == NULL);
+ private = GET_PRIVATE (options);
+
if (preset != GIMP_DASH_CUSTOM)
pattern = gimp_dash_pattern_new_from_preset (preset);
- if (options->dash_info)
- gimp_dash_pattern_free (options->dash_info);
+ if (private->dash_info)
+ gimp_dash_pattern_free (private->dash_info);
- options->dash_info = pattern;
+ private->dash_info = pattern;
g_object_notify (G_OBJECT (options), "dash-info");
@@ -422,10 +540,14 @@ gimp_stroke_options_prepare (GimpStrokeOptions *options,
GimpContext *context,
gboolean use_default_values)
{
+ GimpStrokeOptionsPrivate *private;
+
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (GIMP_IS_CONTEXT (context));
- switch (options->method)
+ private = GET_PRIVATE (options);
+
+ switch (private->method)
{
case GIMP_STROKE_METHOD_LIBART:
break;
diff --git a/app/core/gimpstrokeoptions.h b/app/core/gimpstrokeoptions.h
index e1224bb..f7737a5 100644
--- a/app/core/gimpstrokeoptions.h
+++ b/app/core/gimpstrokeoptions.h
@@ -37,25 +37,7 @@ typedef struct _GimpStrokeOptionsClass GimpStrokeOptionsClass;
struct _GimpStrokeOptions
{
- GimpFillOptions parent_instance;
-
- GimpStrokeMethod method;
-
- /* options for medhod == LIBART */
- gdouble width;
- GimpUnit unit;
-
- GimpCapStyle cap_style;
- GimpJoinStyle join_style;
-
- gdouble miter_limit;
-
- gdouble dash_offset;
- GArray *dash_info;
-
- /* options for method == PAINT_TOOL */
- GimpPaintOptions *paint_options;
- gboolean emulate_dynamics;
+ GimpFillOptions parent_instance;
};
struct _GimpStrokeOptionsClass
@@ -67,19 +49,33 @@ struct _GimpStrokeOptionsClass
};
-GType gimp_stroke_options_get_type (void) G_GNUC_CONST;
+GType gimp_stroke_options_get_type (void) G_GNUC_CONST;
+
+GimpStrokeOptions * gimp_stroke_options_new (Gimp *gimp,
+ GimpContext *context,
+ gboolean use_context_color);
+
+GimpStrokeMethod gimp_stroke_options_get_method (GimpStrokeOptions *options);
+
+gdouble gimp_stroke_options_get_width (GimpStrokeOptions *options);
+GimpUnit gimp_stroke_options_get_unit (GimpStrokeOptions *options);
+GimpCapStyle gimp_stroke_options_get_cap_style (GimpStrokeOptions *options);
+GimpJoinStyle gimp_stroke_options_get_join_style (GimpStrokeOptions *options);
+gdouble gimp_stroke_options_get_miter_limit (GimpStrokeOptions *options);
+gdouble gimp_stroke_options_get_dash_offset (GimpStrokeOptions *options);
+GArray * gimp_stroke_options_get_dash_info (GimpStrokeOptions *options);
+
+GimpPaintOptions * gimp_stroke_options_get_paint_options (GimpStrokeOptions *options);
+gboolean gimp_stroke_options_get_emulate_dynamics (GimpStrokeOptions *options);
-GimpStrokeOptions * gimp_stroke_options_new (Gimp *gimp,
- GimpContext *context,
- gboolean use_context_color);
-void gimp_stroke_options_take_dash_pattern (GimpStrokeOptions *options,
- GimpDashPreset preset,
- GArray *pattern);
+void gimp_stroke_options_take_dash_pattern (GimpStrokeOptions *options,
+ GimpDashPreset preset,
+ GArray *pattern);
-void gimp_stroke_options_prepare (GimpStrokeOptions *options,
- GimpContext *context,
- gboolean use_default_values);
-void gimp_stroke_options_finish (GimpStrokeOptions *options);
+void gimp_stroke_options_prepare (GimpStrokeOptions *options,
+ GimpContext *context,
+ gboolean use_default_values);
+void gimp_stroke_options_finish (GimpStrokeOptions *options);
#endif /* __GIMP_STROKE_OPTIONS_H__ */
diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c
index 88b5c69..b7a3a7f 100644
--- a/app/dialogs/stroke-dialog.c
+++ b/app/dialogs/stroke-dialog.c
@@ -182,7 +182,8 @@ stroke_dialog_new (GimpItem *item,
gtk_widget_show (stroke_editor);
gtk_widget_set_sensitive (stroke_editor,
- options->method == GIMP_STROKE_METHOD_LIBART);
+ gimp_stroke_options_get_method (options) ==
+ GIMP_STROKE_METHOD_LIBART);
g_object_set_data (G_OBJECT (libart_radio), "set_sensitive", stroke_editor);
}
@@ -212,7 +213,8 @@ stroke_dialog_new (GimpItem *item,
gtk_widget_show (vbox);
gtk_widget_set_sensitive (vbox,
- options->method == GIMP_STROKE_METHOD_PAINT_CORE);
+ gimp_stroke_options_get_method (options) ==
+ GIMP_STROKE_METHOD_PAINT_CORE);
g_object_set_data (G_OBJECT (paint_radio), "set_sensitive", vbox);
hbox = gtk_hbox_new (FALSE, 6);
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index 205f365..97f463f 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -558,7 +558,7 @@ gimp_vectors_stroke (GimpItem *item,
return FALSE;
}
- switch (stroke_options->method)
+ switch (gimp_stroke_options_get_method (stroke_options))
{
case GIMP_STROKE_METHOD_LIBART:
retval = gimp_drawable_stroke_vectors (drawable,
@@ -568,16 +568,21 @@ gimp_vectors_stroke (GimpItem *item,
case GIMP_STROKE_METHOD_PAINT_CORE:
{
- GimpPaintInfo *paint_info;
- GimpPaintCore *core;
+ GimpPaintInfo *paint_info;
+ GimpPaintCore *core;
+ GimpPaintOptions *paint_options;
+ gboolean emulate_dynamics;
paint_info = gimp_context_get_paint_info (GIMP_CONTEXT (stroke_options));
core = g_object_new (paint_info->paint_type, NULL);
+ paint_options = gimp_stroke_options_get_paint_options (stroke_options);
+ emulate_dynamics = gimp_stroke_options_get_emulate_dynamics (stroke_options);
+
retval = gimp_paint_core_stroke_vectors (core, drawable,
- stroke_options->paint_options,
- stroke_options->emulate_dynamics,
+ paint_options,
+ emulate_dynamics,
vectors, push_undo, error);
g_object_unref (core);
diff --git a/app/widgets/gimpdasheditor.c b/app/widgets/gimpdasheditor.c
index c1e3a12..c135348 100644
--- a/app/widgets/gimpdasheditor.c
+++ b/app/widgets/gimpdasheditor.c
@@ -464,6 +464,8 @@ gimp_dash_editor_shift_left (GimpDashEditor *editor)
static void
update_segments_from_options (GimpDashEditor *editor)
{
+ GArray *dash_info;
+
if (editor->stroke_options == NULL || editor->segments == NULL)
return;
@@ -471,7 +473,9 @@ update_segments_from_options (GimpDashEditor *editor)
gtk_widget_queue_draw (GTK_WIDGET (editor));
- gimp_dash_pattern_fill_segments (editor->stroke_options->dash_info,
+ dash_info = gimp_stroke_options_get_dash_info (editor->stroke_options);
+
+ gimp_dash_pattern_fill_segments (dash_info,
editor->segments, editor->n_segments);
}
diff --git a/app/widgets/gimpstrokeeditor.c b/app/widgets/gimpstrokeeditor.c
index 9646de7..68ea7e4 100644
--- a/app/widgets/gimpstrokeeditor.c
+++ b/app/widgets/gimpstrokeeditor.c
@@ -372,7 +372,8 @@ gimp_stroke_editor_combo_update (GtkTreeModel *model,
if (gimp_int_store_lookup_by_value (model, GIMP_DASH_CUSTOM, &iter))
{
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- GIMP_INT_STORE_USER_DATA, options->dash_info,
+ GIMP_INT_STORE_USER_DATA,
+ gimp_stroke_options_get_dash_info (options),
-1);
}
}
@@ -398,7 +399,8 @@ gimp_stroke_editor_combo_fill (GimpStrokeOptions *options,
if (value == GIMP_DASH_CUSTOM)
{
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- GIMP_INT_STORE_USER_DATA, options->dash_info,
+ GIMP_INT_STORE_USER_DATA,
+ gimp_stroke_options_get_dash_info (options),
-1);
g_signal_connect_object (options, "notify::dash-info",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]