Commit 7902e11b authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/core/gimpstrokeoptions.[ch] app/widgets/gimpdasheditor.c small change

2005-05-19  Sven Neumann  <sven@gimp.org>

	* app/core/gimpstrokeoptions.[ch]
	* app/widgets/gimpdasheditor.c
	* app/widgets/gimpstrokeeditor.c: small change to the internal API
	to reduce code and conversion between GArray and GValueArray.
parent 9bb255a3
2005-05-19 Sven Neumann <sven@gimp.org>
* app/core/gimpstrokeoptions.[ch]
* app/widgets/gimpdasheditor.c
* app/widgets/gimpstrokeeditor.c: small change to the internal API
to reduce code and conversion between GArray and GValueArray.
2005-05-19 Sven Neumann <sven@gimp.org>
* app/core/gimpdashpattern.[ch]
......
......@@ -66,10 +66,6 @@ static void gimp_stroke_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_stroke_options_set_dash_info (GimpStrokeOptions *options,
GArray *pattern,
GimpDashPreset preset);
static guint stroke_options_signals[LAST_SIGNAL] = { 0 };
......@@ -206,9 +202,9 @@ gimp_stroke_options_set_property (GObject *object,
options->dash_offset = g_value_get_double (value);
break;
case PROP_DASH_INFO:
gimp_stroke_options_set_dash_info (options,
gimp_dash_pattern_from_value (value),
GIMP_DASH_CUSTOM);
gimp_stroke_options_set_dash_pattern (options,
GIMP_DASH_CUSTOM,
gimp_dash_pattern_from_value (value));
break;
default:
......@@ -261,30 +257,35 @@ gimp_stroke_options_get_property (GObject *object,
}
}
/**
* gimp_stroke_options_set_dash_pattern:
* @options: a #GimpStrokeOptions object
* @preset: a value out of the #GimpDashPreset enum
* @pattern: a #GArray or %NULL if @preset is not %GIMP_DASH_CUSTOM
*
* Sets the dash pattern. Either a @preset is passed and @pattern is
* %NULL or @preset is %GIMP_DASH_CUSTOM and @pattern is the #GArray
* to use as the dash pattern. Note that this function takes ownership
* of the passed pattern.
*/
void
gimp_stroke_options_set_dash_preset (GimpStrokeOptions *options,
GimpDashPreset preset)
gimp_stroke_options_set_dash_pattern (GimpStrokeOptions *options,
GimpDashPreset preset,
GArray *pattern)
{
if (preset == GIMP_DASH_CUSTOM)
return;
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (preset == GIMP_DASH_CUSTOM || pattern == NULL);
gimp_stroke_options_set_dash_info (options,
gimp_dash_pattern_from_preset (preset),
preset);
g_object_notify (G_OBJECT (options), "dash-info");
}
if (preset != GIMP_DASH_CUSTOM)
pattern = gimp_dash_pattern_from_preset (preset);
static void
gimp_stroke_options_set_dash_info (GimpStrokeOptions *options,
GArray *pattern,
GimpDashPreset preset)
{
if (options->dash_info)
g_array_free (options->dash_info, TRUE);
options->dash_info = pattern;
g_object_notify (G_OBJECT (options), "dash-info");
g_signal_emit (options,
stroke_options_signals [DASH_INFO_CHANGED], 0,
preset);
......
......@@ -65,9 +65,11 @@ struct _GimpStrokeOptionsClass
};
GType gimp_stroke_options_get_type (void) G_GNUC_CONST;
GType gimp_stroke_options_get_type (void) G_GNUC_CONST;
void gimp_stroke_options_set_dash_pattern (GimpStrokeOptions *options,
GimpDashPreset preset,
GArray *pattern);
void gimp_stroke_options_set_dash_preset (GimpStrokeOptions *options,
GimpDashPreset preset);
#endif /* __GIMP_STROKE_OPTIONS_H__ */
......@@ -486,23 +486,12 @@ update_segments_from_options (GimpDashEditor *editor)
static void
update_options_from_segments (GimpDashEditor *editor)
{
GArray *pattern;
GValue value = { 0, };
GArray *pattern = gimp_dash_pattern_from_segments (editor->segments,
editor->n_segments,
editor->dash_length);
pattern = gimp_dash_pattern_from_segments (editor->segments,
editor->n_segments,
editor->dash_length);
g_value_init (&value, G_TYPE_VALUE_ARRAY);
gimp_dash_pattern_value_set (pattern, &value);
g_array_free (pattern, TRUE);
g_object_set_property (G_OBJECT (editor->stroke_options),
"dash-info", &value);
g_value_unset (&value);
gimp_stroke_options_set_dash_pattern (editor->stroke_options,
GIMP_DASH_CUSTOM, pattern);
}
static void
......
......@@ -44,20 +44,20 @@ static void gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass);
static GObject * gimp_stroke_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_stroke_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_stroke_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_stroke_editor_finalize (GObject *object);
static gboolean gimp_stroke_editor_paint_button (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
static void gimp_stroke_editor_dash_preset (GtkWidget *widget,
gpointer data);
static void gimp_stroke_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_stroke_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_stroke_editor_finalize (GObject *object);
static gboolean gimp_stroke_editor_paint_button (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
static void gimp_stroke_editor_dash_preset (GtkWidget *widget,
GimpStrokeOptions *options);
......@@ -354,11 +354,14 @@ gimp_stroke_editor_paint_button (GtkWidget *widget,
}
static void
gimp_stroke_editor_dash_preset (GtkWidget *widget,
gpointer data)
gimp_stroke_editor_dash_preset (GtkWidget *widget,
GimpStrokeOptions *options)
{
gint value;
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
gimp_stroke_options_set_dash_preset (GIMP_STROKE_OPTIONS (data), value);
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
value != GIMP_DASH_CUSTOM)
{
gimp_stroke_options_set_dash_pattern (options, value, NULL);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment