app/core/Makefile.am app/core/core-types.h added first draft of a GimpText

2002-10-10  Sven Neumann  <sven@gimp.org>

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimptext.[ch]: added first draft of a GimpText object.
This commit is contained in:
Sven Neumann 2002-10-10 14:30:01 +00:00 committed by Sven Neumann
parent 9e4b059e35
commit ce3af12618
9 changed files with 479 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2002-10-10 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* app/tools/gimptexttool.c

View File

@ -154,6 +154,8 @@ libappcore_a_sources = \
gimppreviewcache.h \
gimpscanconvert.c \
gimpscanconvert.h \
gimptext.c \
gimptext.h \
gimptoolinfo.c \
gimptoolinfo.h \
gimpunit.c \

View File

@ -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;

176
app/core/gimptext.c Normal file
View File

@ -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 <glib-object.h>
#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;
}
}

53
app/core/gimptext.h Normal file
View File

@ -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__ */

176
app/text/gimptext.c Normal file
View File

@ -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 <glib-object.h>
#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;
}
}

53
app/text/gimptext.h Normal file
View File

@ -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__ */

View File

@ -1,3 +1,7 @@
2002-10-10 Sven Neumann <sven@gimp.org>
* POTFILES.in: added new files.
2002-10-10 Stanislav Brabec <sbrabec@suse.cz>
* cs.po: Updated Czech translation. Recode to UTF-8.

View File

@ -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