diff --git a/ChangeLog b/ChangeLog index 7971fdd9c6..d37b6af947 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-09-26 Sven Neumann + + * app/widgets/Makefile.am + * app/widgets/widgets-types.h + * app/widgets/gimpstrokeeditor.[ch]: added a (yet rudimentary) + widget to view/edit a GimpStrokeOption. + + * app/widgets/gimptemplateeditor.[ch]: derive it directly from + GtkVBox; it doesn't need any GimpEditor functionality. + 2003-09-26 Manish Singh * tools/pdbgen/pdb/edit.pdb @@ -31,8 +41,8 @@ * app/core/Makefile.am * app/core/core-types.h: Changed accordingly. - * app/core/gimpitem.[ch]: Changed the Signature of - gimp_item_stroke to accept a GimpObject instead of a + * app/core/gimpitem.[ch]: Changed the signature of + gimp_item_stroke() to accept a GimpObject instead of a GimpPaintInfo. This enables us to pass GimpStrokeOptions to it. To be cleaned up for 2.2. diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am index 7f8eb789ea..0593623fdc 100644 --- a/app/widgets/Makefile.am +++ b/app/widgets/Makefile.am @@ -144,6 +144,8 @@ libappwidgets_a_sources = \ gimppropwidgets.h \ gimpselectioneditor.c \ gimpselectioneditor.h \ + gimpstrokeeditor.c \ + gimpstrokeeditor.h \ gimptemplateeditor.c \ gimptemplateeditor.h \ gimptemplateview.c \ diff --git a/app/widgets/gimpstrokeeditor.c b/app/widgets/gimpstrokeeditor.c new file mode 100644 index 0000000000..ea12e7641a --- /dev/null +++ b/app/widgets/gimpstrokeeditor.c @@ -0,0 +1,159 @@ +/* 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 + +#include "libgimpwidgets/gimpwidgets.h" + +#include "widgets-types.h" + +#include "core/gimpstrokeoptions.h" + +#include "gimpenummenu.h" +#include "gimppropwidgets.h" +#include "gimpstrokeeditor.h" + +#include "gimp-intl.h" + + +#define SB_WIDTH 10 + + +static void gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass); +static void gimp_stroke_editor_init (GimpStrokeEditor *editor); + +static void gimp_stroke_editor_finalize (GObject *object); + + +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), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gimp_stroke_editor_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpStrokeEditor), + 0, /* n_preallocs */ + (GInstanceInitFunc) gimp_stroke_editor_init, + }; + + 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); + + object_class->finalize = gimp_stroke_editor_finalize; +} + +static void +gimp_stroke_editor_init (GimpStrokeEditor *editor) +{ +} + +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 * +gimp_stroke_editor_new (GimpStrokeOptions *options) +{ + GimpStrokeEditor *editor; + GtkWidget *table; + GtkWidget *menu; + GtkWidget *button; + gint row = 0; + + g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL); + + editor = g_object_new (GIMP_TYPE_STROKE_EDITOR, NULL); + + editor->options = options; + g_object_ref (options); + + table = gtk_table_new (4, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 2); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0); + gtk_widget_show (table); + + gimp_prop_scale_entry_new (G_OBJECT (options), "width", + GTK_TABLE (table), 0, row++, + _("Stroke Width:"), + 1.0, 1.0, 1, + FALSE, 0.0, 0.0); + + menu = gimp_prop_enum_option_menu_new (G_OBJECT (options), "cap-style", + 0, 0); + gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, + _("Cap Style:"), 1.0, 0.5, + menu, 2, TRUE); + + menu = gimp_prop_enum_option_menu_new (G_OBJECT (options), "join-style", + 0, 0); + gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, + _("Join Style:"), 1.0, 0.5, + menu, 2, TRUE); + + gimp_prop_scale_entry_new (G_OBJECT (options), "miter", + GTK_TABLE (table), 0, row++, + _("Miter:"), + 1.0, 1.0, 1, + FALSE, 0.0, 0.0); + + button = gimp_prop_check_button_new (G_OBJECT (options), "antialias", + _("Antialiasing")); + gtk_table_attach (GTK_TABLE (table), button, 1, 3, row, row + 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (button); + row++; + + return GTK_WIDGET (editor); +} diff --git a/app/widgets/gimpstrokeeditor.h b/app/widgets/gimpstrokeeditor.h new file mode 100644 index 0000000000..bbf74272ce --- /dev/null +++ b/app/widgets/gimpstrokeeditor.h @@ -0,0 +1,57 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpstrokeeditor.h + * Copyright (C) 2003 Sven Neumann + * + * 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. + */ + +#ifndef __GIMP_STROKE_EDITOR_H__ +#define __GIMP_STROKE_EDITOR_H__ + + +#include + + +#define GIMP_TYPE_STROKE_EDITOR (gimp_stroke_editor_get_type ()) +#define GIMP_STROKE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STROKE_EDITOR, GimpStrokeEditor)) +#define GIMP_STROKE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STROKE_EDITOR, GimpStrokeEditorClass)) +#define GIMP_IS_STROKE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STROKE_EDITOR)) +#define GIMP_IS_STROKE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_STROKE_EDITOR)) +#define GIMP_STROKE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_STROKE_EDITOR, GimpStrokeEditorClass)) + + +typedef struct _GimpStrokeEditorClass GimpStrokeEditorClass; + +struct _GimpStrokeEditor +{ + GtkVBox parent_instance; + + GimpStrokeOptions *options; +}; + +struct _GimpStrokeEditorClass +{ + GtkVBoxClass parent_class; +}; + + +GType gimp_stroke_editor_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options); + + +#endif /* __GIMP_STROKE_EDITOR_H__ */ diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c index f39332f2a9..53dcda21d8 100644 --- a/app/widgets/gimptemplateeditor.c +++ b/app/widgets/gimptemplateeditor.c @@ -62,7 +62,7 @@ static void gimp_template_editor_icon_changed (GimpContext *context, GimpTemplateEditor *editor); -static GimpEditorClass *parent_class = NULL; +static GtkVBoxClass *parent_class = NULL; GType @@ -85,7 +85,7 @@ gimp_template_editor_get_type (void) (GInstanceInitFunc) gimp_template_editor_init, }; - view_type = g_type_register_static (GIMP_TYPE_EDITOR, + view_type = g_type_register_static (GTK_TYPE_VBOX, "GimpTemplateEditor", &view_info, 0); } diff --git a/app/widgets/gimptemplateeditor.h b/app/widgets/gimptemplateeditor.h index 79f02ff085..74422eb05e 100644 --- a/app/widgets/gimptemplateeditor.h +++ b/app/widgets/gimptemplateeditor.h @@ -23,7 +23,7 @@ #define __GIMP_TEMPLATE_EDITOR_H__ -#include "gimpeditor.h" +#include #define GIMP_TYPE_TEMPLATE_EDITOR (gimp_template_editor_get_type ()) @@ -38,36 +38,36 @@ typedef struct _GimpTemplateEditorClass GimpTemplateEditorClass; struct _GimpTemplateEditor { - GimpEditor parent_instance; + GtkVBox parent_instance; - GimpTemplate *template; - gulong memsize; + GimpTemplate *template; + gulong memsize; - GimpContainer *stock_id_container; - GimpContext *stock_id_context; + GimpContainer *stock_id_container; + GimpContext *stock_id_context; - GtkWidget *aspect_button; - gboolean block_aspect; + GtkWidget *aspect_button; + gboolean block_aspect; - GtkWidget *size_se; - GtkWidget *memsize_label; - GtkWidget *resolution_se; + GtkWidget *size_se; + GtkWidget *memsize_label; + GtkWidget *resolution_se; }; struct _GimpTemplateEditorClass { - GimpEditorClass parent_class; + GtkVBoxClass parent_class; }; -GType gimp_template_editor_get_type (void) G_GNUC_CONST; +GType gimp_template_editor_get_type (void) G_GNUC_CONST; -GtkWidget * gimp_template_editor_new (Gimp *gimp, - gboolean edit_template); +GtkWidget * gimp_template_editor_new (Gimp *gimp, + gboolean edit_template); -void gimp_template_editor_set_template (GimpTemplateEditor *editor, - GimpTemplate *template); -GimpTemplate * gimp_template_editor_get_template (GimpTemplateEditor *editor); +void gimp_template_editor_set_template (GimpTemplateEditor *editor, + GimpTemplate *template); +GimpTemplate * gimp_template_editor_get_template (GimpTemplateEditor *editor); #endif /* __GIMP_TEMPLATE_EDITOR_H__ */ diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index 112b40e5e2..72c00e6e02 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -68,6 +68,7 @@ typedef struct _GimpBrushEditor GimpBrushEditor; typedef struct _GimpGradientEditor GimpGradientEditor; typedef struct _GimpPaletteEditor GimpPaletteEditor; typedef struct _GimpSelectionEditor GimpSelectionEditor; +typedef struct _GimpStrokeEditor GimpStrokeEditor; typedef struct _GimpTemplateEditor GimpTemplateEditor; typedef struct _GimpUndoEditor GimpUndoEditor;