2003-09-27 01:33:49 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2003-09-27 22:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2003-09-27 01:33:49 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpstrokeoptions.h"
|
|
|
|
|
|
|
|
#include "gimppropwidgets.h"
|
|
|
|
#include "gimpstrokeeditor.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2003-10-02 03:55:13 +08:00
|
|
|
PROP_OPTIONS,
|
|
|
|
PROP_RESOLUTION
|
2003-09-28 03:05:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GtkVBoxClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_stroke_editor_get_type (void)
|
|
|
|
{
|
|
|
|
static GType view_type = 0;
|
|
|
|
|
|
|
|
if (! view_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo view_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpStrokeEditorClass),
|
2003-09-28 03:05:13 +08:00
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
2003-09-27 01:33:49 +08:00
|
|
|
(GClassInitFunc) gimp_stroke_editor_class_init,
|
|
|
|
NULL, /* class_finalize */
|
2003-09-28 03:05:13 +08:00
|
|
|
NULL, /* class_data */
|
2003-09-27 01:33:49 +08:00
|
|
|
sizeof (GimpStrokeEditor),
|
2003-09-28 03:05:13 +08:00
|
|
|
0, /* n_preallocs */
|
|
|
|
NULL /* instance_init */
|
2003-09-27 01:33:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
view_type = g_type_register_static (GTK_TYPE_VBOX,
|
|
|
|
"GimpStrokeEditor",
|
|
|
|
&view_info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return view_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
object_class->constructor = gimp_stroke_editor_constructor;
|
|
|
|
object_class->set_property = gimp_stroke_editor_set_property;
|
|
|
|
object_class->get_property = gimp_stroke_editor_get_property;
|
|
|
|
object_class->finalize = gimp_stroke_editor_finalize;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_OPTIONS,
|
|
|
|
g_param_spec_object ("options", NULL, NULL,
|
|
|
|
GIMP_TYPE_STROKE_OPTIONS,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2003-10-02 03:55:13 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_RESOLUTION,
|
|
|
|
g_param_spec_double ("resolution", NULL, NULL,
|
|
|
|
GIMP_MIN_RESOLUTION,
|
|
|
|
GIMP_MAX_RESOLUTION,
|
|
|
|
72.0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2003-09-27 01:33:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-09-28 03:05:13 +08:00
|
|
|
gimp_stroke_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2003-09-27 01:33:49 +08:00
|
|
|
{
|
2003-09-28 03:05:13 +08:00
|
|
|
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OPTIONS:
|
|
|
|
editor->options = GIMP_STROKE_OPTIONS (g_value_dup_object (value));
|
|
|
|
break;
|
2003-10-02 03:55:13 +08:00
|
|
|
case PROP_RESOLUTION:
|
|
|
|
editor->resolution = g_value_get_double (value);
|
|
|
|
break;
|
2003-09-28 03:05:13 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2003-09-27 01:33:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-09-28 03:05:13 +08:00
|
|
|
gimp_stroke_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2003-09-27 01:33:49 +08:00
|
|
|
{
|
|
|
|
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
switch (property_id)
|
2003-09-27 01:33:49 +08:00
|
|
|
{
|
2003-09-28 03:05:13 +08:00
|
|
|
case PROP_OPTIONS:
|
|
|
|
g_value_set_object (value, editor->options);
|
|
|
|
break;
|
2003-10-02 03:55:13 +08:00
|
|
|
case PROP_RESOLUTION:
|
|
|
|
g_value_set_double (value, editor->resolution);
|
|
|
|
break;
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2003-09-27 01:33:49 +08:00
|
|
|
}
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_stroke_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
2003-09-27 01:33:49 +08:00
|
|
|
{
|
|
|
|
GimpStrokeEditor *editor;
|
|
|
|
GtkWidget *table;
|
2003-09-28 03:05:13 +08:00
|
|
|
GtkWidget *box;
|
2003-10-02 03:55:13 +08:00
|
|
|
GtkWidget *size;
|
2003-09-27 01:33:49 +08:00
|
|
|
GtkWidget *button;
|
2003-09-28 03:05:13 +08:00
|
|
|
GObject *object;
|
2003-09-27 01:33:49 +08:00
|
|
|
gint row = 0;
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
editor = GIMP_STROKE_EDITOR (object);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
g_assert (editor->options != NULL);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 04:04:07 +08:00
|
|
|
table = gtk_table_new (5, 3, FALSE);
|
2003-09-27 01:33:49 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
2003-09-28 03:05:13 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
2003-09-27 01:33:49 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2003-10-02 03:55:13 +08:00
|
|
|
size = gimp_prop_size_entry_new (G_OBJECT (editor->options), "width", "unit",
|
|
|
|
"%a", GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
|
|
|
editor->resolution);
|
|
|
|
gimp_size_entry_set_pixel_digits (GIMP_SIZE_ENTRY (size), 1);
|
2003-09-27 22:58:46 +08:00
|
|
|
|
2003-10-02 03:55:13 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
|
|
|
_("Stroke _Width:"), 1.0, 0.5,
|
|
|
|
size, 1, FALSE);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
box = gimp_prop_enum_stock_box_new (G_OBJECT (editor->options), "cap-style",
|
|
|
|
"gimp-cap", 0, 0);
|
2003-09-27 01:33:49 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
2003-09-27 22:58:46 +08:00
|
|
|
_("_Cap Style:"), 1.0, 0.5,
|
2003-09-28 03:05:13 +08:00
|
|
|
box, 2, TRUE);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
box = gimp_prop_enum_stock_box_new (G_OBJECT (editor->options), "join-style",
|
|
|
|
"gimp-join", 0, 0);
|
2003-09-27 01:33:49 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
2003-09-27 22:58:46 +08:00
|
|
|
_("_Join Style:"), 1.0, 0.5,
|
2003-09-28 03:05:13 +08:00
|
|
|
box, 2, TRUE);
|
2003-09-27 01:33:49 +08:00
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
gimp_prop_scale_entry_new (G_OBJECT (editor->options), "miter",
|
2003-09-27 01:33:49 +08:00
|
|
|
GTK_TABLE (table), 0, row++,
|
2003-09-27 22:58:46 +08:00
|
|
|
_("_Miter Limit:"),
|
2003-09-27 01:33:49 +08:00
|
|
|
1.0, 1.0, 1,
|
|
|
|
FALSE, 0.0, 0.0);
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
button = gimp_prop_check_button_new (G_OBJECT (editor->options), "antialias",
|
|
|
|
_("_Antialiasing"));
|
2003-09-27 22:58:46 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), button, 0, 2, row, row + 1,
|
2003-09-27 01:33:49 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
row++;
|
|
|
|
|
2003-09-29 19:13:21 +08:00
|
|
|
box = gimp_prop_enum_radio_frame_new (G_OBJECT (editor->options), "style",
|
|
|
|
_("Style"), 0, 0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), box, 0, 3, row, row + 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (box);
|
|
|
|
row++;
|
|
|
|
|
2003-09-28 03:05:13 +08:00
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_stroke_editor_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpStrokeEditor *editor = GIMP_STROKE_EDITOR (object);
|
|
|
|
|
|
|
|
if (editor->options)
|
|
|
|
{
|
|
|
|
g_object_unref (editor->options);
|
|
|
|
editor->options = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2003-10-02 03:55:13 +08:00
|
|
|
gimp_stroke_editor_new (GimpStrokeOptions *options,
|
|
|
|
gdouble resolution)
|
2003-09-28 03:05:13 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
|
|
|
|
|
2003-11-02 04:21:26 +08:00
|
|
|
return g_object_new (GIMP_TYPE_STROKE_EDITOR,
|
|
|
|
"options", options,
|
|
|
|
"resolution", resolution,
|
|
|
|
NULL);
|
2003-09-27 01:33:49 +08:00
|
|
|
}
|