From ce3af126184d5674f9ef9a5f3a90966239f1332f Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 10 Oct 2002 14:30:01 +0000 Subject: [PATCH] app/core/Makefile.am app/core/core-types.h added first draft of a GimpText 2002-10-10 Sven Neumann * app/core/Makefile.am * app/core/core-types.h * app/core/gimptext.[ch]: added first draft of a GimpText object. --- ChangeLog | 6 ++ app/core/Makefile.am | 2 + app/core/core-types.h | 8 +- app/core/gimptext.c | 176 ++++++++++++++++++++++++++++++++++++++++++ app/core/gimptext.h | 53 +++++++++++++ app/text/gimptext.c | 176 ++++++++++++++++++++++++++++++++++++++++++ app/text/gimptext.h | 53 +++++++++++++ po/ChangeLog | 4 + po/POTFILES.in | 2 + 9 files changed, 479 insertions(+), 1 deletion(-) create mode 100644 app/core/gimptext.c create mode 100644 app/core/gimptext.h create mode 100644 app/text/gimptext.c create mode 100644 app/text/gimptext.h diff --git a/ChangeLog b/ChangeLog index 2d3599dc1a..4fc1cd9abc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-10-10 Sven Neumann + + * app/core/Makefile.am + * app/core/core-types.h + * app/core/gimptext.[ch]: added first draft of a GimpText object. + 2002-10-09 Sven Neumann * app/tools/gimptexttool.c diff --git a/app/core/Makefile.am b/app/core/Makefile.am index ab890867ee..20bf7014b9 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -154,6 +154,8 @@ libappcore_a_sources = \ gimppreviewcache.h \ gimpscanconvert.c \ gimpscanconvert.h \ + gimptext.c \ + gimptext.h \ gimptoolinfo.c \ gimptoolinfo.h \ gimpunit.c \ diff --git a/app/core/core-types.h b/app/core/core-types.h index 562978b0bc..a308801e51 100644 --- a/app/core/core-types.h +++ b/app/core/core-types.h @@ -127,7 +127,6 @@ typedef struct _GimpToolInfo GimpToolInfo; /*< proxy-include >*/ typedef struct _GimpImagefile GimpImagefile; typedef struct _GimpList GimpDocumentList; -typedef struct _GimpImageMap GimpImageMap; /* drawable objects */ @@ -156,6 +155,13 @@ typedef struct _GimpPattern GimpPattern; typedef struct _GimpPalette GimpPalette; +/* misc objects */ + +typedef struct _GimpImageMap GimpImageMap; + +typedef struct _GimpText GimpText; + + /* undo objects */ typedef struct _GimpUndo GimpUndo; diff --git a/app/core/gimptext.c b/app/core/gimptext.c new file mode 100644 index 0000000000..e417bd68e9 --- /dev/null +++ b/app/core/gimptext.c @@ -0,0 +1,176 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 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 "core-types.h" + +#include "config/gimpconfig-params.h" + +#include "gimptext.h" + +enum +{ + PROP_0, + PROP_TEXT, + PROP_FONT, + PROP_SIZE, + PROP_SIZE_UNIT, + PROP_LETTER_SPACING, + PROP_LINE_SPACING +}; + +static void gimp_text_class_init (GimpTextClass *klass); +static void gimp_text_finalize (GObject *object); +static void gimp_text_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + +static GObjectClass *parent_class = NULL; + + +GType +gimp_text_get_type (void) +{ + static GType text_type = 0; + + if (! text_type) + { + static const GTypeInfo text_info = + { + sizeof (GimpTextClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gimp_text_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpText), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; + + text_type = g_type_register_static (G_TYPE_OBJECT, + "GimpText", &text_info, 0); + } + + return text_type; +} + +static void +gimp_text_class_init (GimpTextClass *klass) +{ + GObjectClass *object_class; + GParamSpec *param_spec; + + object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gimp_text_finalize; + object_class->set_property = gimp_text_set_property; + + param_spec = g_param_spec_string ("text", NULL, NULL, + NULL, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_TEXT, param_spec); + + param_spec = g_param_spec_string ("font", NULL, NULL, + "Sans", + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_FONT, param_spec); + + param_spec = g_param_spec_double ("size", NULL, NULL, + 18.0, 0.0, G_MAXFLOAT, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_SIZE, param_spec); + + param_spec = gimp_param_spec_unit ("size-unit", NULL, NULL, + GIMP_UNIT_PIXEL, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_SIZE_UNIT, param_spec); + + param_spec = g_param_spec_double ("letter-spacing", NULL, NULL, + 1.0, 0.0, 64.0, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, + PROP_LETTER_SPACING, param_spec); + + param_spec = g_param_spec_double ("line-spacing", NULL, NULL, + 1.0, 0.0, 64.0, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, + PROP_LINE_SPACING, param_spec); +} + +static void +gimp_text_finalize (GObject *object) +{ + GimpText *text = GIMP_TEXT (object); + + if (text->str) + { + g_free (text->str); + text->str = NULL; + } + if (text->font) + { + g_free (text->font); + text->font = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gimp_text_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpText *text = GIMP_TEXT (object); + + switch (property_id) + { + case PROP_TEXT: + g_free (text->str); + text->str = g_value_dup_string (value); + break; + case PROP_FONT: + g_free (text->font); + text->font = g_value_dup_string (value); + break; + case PROP_SIZE: + text->size = g_value_get_double (value); + break; + case PROP_SIZE_UNIT: + text->size_unit = g_value_get_enum (value); + break; + case PROP_LETTER_SPACING: + text->letter_spacing = g_value_get_double (value); + break; + case PROP_LINE_SPACING: + text->line_spacing = g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} diff --git a/app/core/gimptext.h b/app/core/gimptext.h new file mode 100644 index 0000000000..958b2dffe0 --- /dev/null +++ b/app/core/gimptext.h @@ -0,0 +1,53 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 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. + */ + +#ifndef __GIMP_TEXT_H__ +#define __GIMP_TEXT_H__ + +#define GIMP_TYPE_TEXT (gimp_text_get_type ()) +#define GIMP_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TEXT, GimpText)) +#define GIMP_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TEXT, GimpTextClass)) +#define GIMP_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TEXT)) +#define GIMP_IS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TEXT)) +#define GIMP_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TEXT, GimpTextClass)) + + +typedef struct _GimpTextClass GimpTextClass; + +struct _GimpText +{ + GObject parent_instance; + + gchar *str; + gchar *font; + gdouble size; + GimpUnit size_unit; + gdouble letter_spacing; + gdouble line_spacing; +}; + +struct _GimpTextClass +{ + GObjectClass parent_class; +}; + + +GType gimp_text_get_type (void) G_GNUC_CONST; + + +#endif /* __GIMP_TEXT_H__ */ diff --git a/app/text/gimptext.c b/app/text/gimptext.c new file mode 100644 index 0000000000..e417bd68e9 --- /dev/null +++ b/app/text/gimptext.c @@ -0,0 +1,176 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 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 "core-types.h" + +#include "config/gimpconfig-params.h" + +#include "gimptext.h" + +enum +{ + PROP_0, + PROP_TEXT, + PROP_FONT, + PROP_SIZE, + PROP_SIZE_UNIT, + PROP_LETTER_SPACING, + PROP_LINE_SPACING +}; + +static void gimp_text_class_init (GimpTextClass *klass); +static void gimp_text_finalize (GObject *object); +static void gimp_text_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + +static GObjectClass *parent_class = NULL; + + +GType +gimp_text_get_type (void) +{ + static GType text_type = 0; + + if (! text_type) + { + static const GTypeInfo text_info = + { + sizeof (GimpTextClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gimp_text_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpText), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; + + text_type = g_type_register_static (G_TYPE_OBJECT, + "GimpText", &text_info, 0); + } + + return text_type; +} + +static void +gimp_text_class_init (GimpTextClass *klass) +{ + GObjectClass *object_class; + GParamSpec *param_spec; + + object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gimp_text_finalize; + object_class->set_property = gimp_text_set_property; + + param_spec = g_param_spec_string ("text", NULL, NULL, + NULL, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_TEXT, param_spec); + + param_spec = g_param_spec_string ("font", NULL, NULL, + "Sans", + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_FONT, param_spec); + + param_spec = g_param_spec_double ("size", NULL, NULL, + 18.0, 0.0, G_MAXFLOAT, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_SIZE, param_spec); + + param_spec = gimp_param_spec_unit ("size-unit", NULL, NULL, + GIMP_UNIT_PIXEL, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, PROP_SIZE_UNIT, param_spec); + + param_spec = g_param_spec_double ("letter-spacing", NULL, NULL, + 1.0, 0.0, 64.0, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, + PROP_LETTER_SPACING, param_spec); + + param_spec = g_param_spec_double ("line-spacing", NULL, NULL, + 1.0, 0.0, 64.0, + G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); + g_object_class_install_property (object_class, + PROP_LINE_SPACING, param_spec); +} + +static void +gimp_text_finalize (GObject *object) +{ + GimpText *text = GIMP_TEXT (object); + + if (text->str) + { + g_free (text->str); + text->str = NULL; + } + if (text->font) + { + g_free (text->font); + text->font = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gimp_text_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpText *text = GIMP_TEXT (object); + + switch (property_id) + { + case PROP_TEXT: + g_free (text->str); + text->str = g_value_dup_string (value); + break; + case PROP_FONT: + g_free (text->font); + text->font = g_value_dup_string (value); + break; + case PROP_SIZE: + text->size = g_value_get_double (value); + break; + case PROP_SIZE_UNIT: + text->size_unit = g_value_get_enum (value); + break; + case PROP_LETTER_SPACING: + text->letter_spacing = g_value_get_double (value); + break; + case PROP_LINE_SPACING: + text->line_spacing = g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} diff --git a/app/text/gimptext.h b/app/text/gimptext.h new file mode 100644 index 0000000000..958b2dffe0 --- /dev/null +++ b/app/text/gimptext.h @@ -0,0 +1,53 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 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. + */ + +#ifndef __GIMP_TEXT_H__ +#define __GIMP_TEXT_H__ + +#define GIMP_TYPE_TEXT (gimp_text_get_type ()) +#define GIMP_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TEXT, GimpText)) +#define GIMP_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TEXT, GimpTextClass)) +#define GIMP_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TEXT)) +#define GIMP_IS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TEXT)) +#define GIMP_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TEXT, GimpTextClass)) + + +typedef struct _GimpTextClass GimpTextClass; + +struct _GimpText +{ + GObject parent_instance; + + gchar *str; + gchar *font; + gdouble size; + GimpUnit size_unit; + gdouble letter_spacing; + gdouble line_spacing; +}; + +struct _GimpTextClass +{ + GObjectClass parent_class; +}; + + +GType gimp_text_get_type (void) G_GNUC_CONST; + + +#endif /* __GIMP_TEXT_H__ */ diff --git a/po/ChangeLog b/po/ChangeLog index 3a729950e6..0039d31ba0 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2002-10-10 Sven Neumann + + * POTFILES.in: added new files. + 2002-10-10 Stanislav Brabec * cs.po: Updated Czech translation. Recode to UTF-8. diff --git a/po/POTFILES.in b/po/POTFILES.in index 59a1e09191..1f9fcd3ee7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,6 +31,7 @@ app/core/gimpimage-convert.c app/core/gimpimage-mask.c app/core/gimpimage-merge.c app/core/gimpimage-new.c +app/core/gimpimage-text.c app/core/gimpimage.c app/core/gimpimagefile.c app/core/gimpitem.c @@ -142,6 +143,7 @@ app/tools/gimpfreeselecttool.c app/tools/gimpfuzzyselecttool.c app/tools/gimphistogramtool.c app/tools/gimphuesaturationtool.c +app/tools/gimpimagemaptool.c app/tools/gimpinktool.c app/tools/gimpiscissorstool.c app/tools/gimplevelstool.c