added "gchar *default_font". and its blurb.

2003-03-25  Michael Natterer  <mitch@gimp.org>

	* app/config/gimpcoreconfig.[ch]: added "gchar *default_font".
	* app/config/gimprc-blurbs.h: and its blurb.

	* app/core/gimp.[ch]: keep a GimpFontList around.

	* app/core/gimpcontext.[ch]: added a GimpFont and all needed
	fonctions to let it work like brush, pattern etc.

	* app/core/gimpdatalist.c: cosmetic.
This commit is contained in:
Michael Natterer 2003-03-25 22:06:03 +00:00 committed by Michael Natterer
parent bc9676e462
commit 47419bbcec
9 changed files with 281 additions and 5 deletions

View File

@ -1,3 +1,15 @@
2003-03-25 Michael Natterer <mitch@gimp.org>
* app/config/gimpcoreconfig.[ch]: added "gchar *default_font".
* app/config/gimprc-blurbs.h: and its blurb.
* app/core/gimp.[ch]: keep a GimpFontList around.
* app/core/gimpcontext.[ch]: added a GimpFont and all needed
fonctions to let it work like brush, pattern etc.
* app/core/gimpdatalist.c: cosmetic.
2003-03-25 Michael Natterer <mitch@gimp.org>
* app/text/Makefile.am

View File

@ -53,6 +53,7 @@ static void gimp_core_config_get_property (GObject *object,
#define DEFAULT_PATTERN "Pine"
#define DEFAULT_PALETTE "Default"
#define DEFAULT_GRADIENT "FG to BG (RGB)"
#define DEFAULT_FONT "Sans"
#define DEFAULT_COMMENT "Created with The GIMP"
enum
@ -71,6 +72,7 @@ enum
PROP_DEFAULT_PATTERN,
PROP_DEFAULT_PALETTE,
PROP_DEFAULT_GRADIENT,
PROP_DEFAULT_FONT,
PROP_DEFAULT_COMMENT,
PROP_DEFAULT_IMAGE_TYPE,
PROP_DEFAULT_IMAGE_WIDTH,
@ -197,6 +199,10 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
"default-gradient", DEFAULT_GRADIENT_BLURB,
DEFAULT_GRADIENT,
0);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_FONT,
"default-font", DEFAULT_FONT_BLURB,
DEFAULT_FONT,
0);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_COMMENT,
"default-comment", DEFAULT_COMMENT_BLURB,
DEFAULT_COMMENT,
@ -304,6 +310,7 @@ gimp_core_config_finalize (GObject *object)
g_free (core_config->default_pattern);
g_free (core_config->default_palette);
g_free (core_config->default_gradient);
g_free (core_config->default_font);
g_free (core_config->default_comment);
g_free (core_config->plug_in_rc_path);
g_free (core_config->module_load_inhibit);
@ -374,6 +381,10 @@ gimp_core_config_set_property (GObject *object,
g_free (core_config->default_gradient);
core_config->default_gradient = g_value_dup_string (value);
break;
case PROP_DEFAULT_FONT:
g_free (core_config->default_font);
core_config->default_font = g_value_dup_string (value);
break;
case PROP_DEFAULT_COMMENT:
g_free (core_config->default_comment);
core_config->default_comment = g_value_dup_string (value);
@ -489,6 +500,9 @@ gimp_core_config_get_property (GObject *object,
case PROP_DEFAULT_GRADIENT:
g_value_set_string (value, core_config->default_gradient);
break;
case PROP_DEFAULT_FONT:
g_value_set_string (value, core_config->default_font);
break;
case PROP_DEFAULT_COMMENT:
g_value_set_string (value, core_config->default_comment);
break;

View File

@ -53,6 +53,7 @@ struct _GimpCoreConfig
gchar *default_pattern;
gchar *default_palette;
gchar *default_gradient;
gchar *default_font;
gchar *default_comment;
GimpImageBaseType default_image_type;
gint default_image_width;

View File

@ -45,6 +45,10 @@ N_("Context-dependent cursors are cool. They are enabled by default. " \
N_("When enabled, this will ensure that each pixel of an image gets " \
"mapped to a pixel on the screen.")
#define DEFAULT_FONT_BLURB \
"Specify a default font. The font is searched for in the " \
"fontconfig font path."
#define DEFAULT_GRADIENT_BLURB \
"Specify a default gradient. The gradient is searched for in the " \
"specified gradient path."

View File

@ -36,6 +36,8 @@
#include "paint/paint.h"
#include "text/gimpfontlist.h"
#include "xcf/xcf.h"
#include "gimp.h"
@ -226,6 +228,9 @@ gimp_init (Gimp *gimp)
GIMP_CONTAINER_POLICY_STRONG);
gimp_object_set_name (GIMP_OBJECT (gimp->named_buffers), "named buffers");
gimp->fonts = gimp_font_list_new ();
gimp_object_set_name (GIMP_OBJECT (gimp->fonts), "fonts");
gimp->brush_factory = NULL;
gimp->pattern_factory = NULL;
gimp->gradient_factory = NULL;
@ -348,6 +353,12 @@ gimp_finalize (GObject *object)
gimp->palette_factory = NULL;
}
if (gimp->fonts)
{
g_object_unref (gimp->fonts);
gimp->fonts = NULL;
}
if (gimp->named_buffers)
{
g_object_unref (gimp->named_buffers);
@ -438,6 +449,7 @@ gimp_get_memsize (GimpObject *object)
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->global_buffer));
memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->named_buffers)) +
gimp_object_get_memsize (GIMP_OBJECT (gimp->fonts)) +
gimp_object_get_memsize (GIMP_OBJECT (gimp->brush_factory)) +
gimp_object_get_memsize (GIMP_OBJECT (gimp->pattern_factory)) +
gimp_object_get_memsize (GIMP_OBJECT (gimp->gradient_factory)) +

View File

@ -108,6 +108,8 @@ struct _Gimp
GimpBuffer *global_buffer;
GimpContainer *named_buffers;
GimpContainer *fonts;
GimpDataFactory *brush_factory;
GimpDataFactory *pattern_factory;
GimpDataFactory *gradient_factory;

View File

@ -48,6 +48,8 @@
#include "gimppattern.h"
#include "gimptoolinfo.h"
#include "text/gimpfont.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-types.h"
#include "config/gimpconfig-params.h"
@ -187,6 +189,17 @@ static void gimp_context_palette_list_thaw (GimpContainer *container,
static void gimp_context_real_set_palette (GimpContext *context,
GimpPalette *palatte);
/* font */
static void gimp_context_font_dirty (GimpFont *font,
GimpContext *context);
static void gimp_context_font_removed (GimpContainer *container,
GimpFont *font,
GimpContext *context);
static void gimp_context_font_list_thaw (GimpContainer *container,
GimpContext *context);
static void gimp_context_real_set_font (GimpContext *context,
GimpFont *font);
/* buffer */
static void gimp_context_buffer_dirty (GimpBuffer *buffer,
GimpContext *context);
@ -235,6 +248,7 @@ enum
PATTERN_CHANGED,
GRADIENT_CHANGED,
PALETTE_CHANGED,
FONT_CHANGED,
BUFFER_CHANGED,
IMAGEFILE_CHANGED,
LAST_SIGNAL
@ -255,6 +269,7 @@ static gchar *gimp_context_prop_names[] =
"pattern",
"gradient",
"palette",
"font",
"buffer",
"imagefile"
};
@ -275,6 +290,7 @@ static GType gimp_context_prop_types[] =
0,
0,
0,
0,
0
};
@ -288,6 +304,7 @@ static GimpBrush *standard_brush = NULL;
static GimpPattern *standard_pattern = NULL;
static GimpGradient *standard_gradient = NULL;
static GimpPalette *standard_palette = NULL;
static GimpFont *standard_font = NULL;
GType
@ -454,6 +471,16 @@ gimp_context_class_init (GimpContextClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_PALETTE);
gimp_context_signals[FONT_CHANGED] =
g_signal_new ("font_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpContextClass, font_changed),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_FONT);
gimp_context_signals[BUFFER_CHANGED] =
g_signal_new ("buffer_changed",
G_TYPE_FROM_CLASS (klass),
@ -493,6 +520,7 @@ gimp_context_class_init (GimpContextClass *klass)
klass->pattern_changed = NULL;
klass->gradient_changed = NULL;
klass->palette_changed = NULL;
klass->font_changed = NULL;
klass->buffer_changed = NULL;
klass->imagefile_changed = NULL;
@ -502,6 +530,7 @@ gimp_context_class_init (GimpContextClass *klass)
gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN] = GIMP_TYPE_PATTERN;
gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT] = GIMP_TYPE_GRADIENT;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE] = GIMP_TYPE_PALETTE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT] = GIMP_TYPE_FONT;
gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER] = GIMP_TYPE_BUFFER;
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE] = GIMP_TYPE_IMAGEFILE;
@ -580,6 +609,12 @@ gimp_context_class_init (GimpContextClass *klass)
GIMP_TYPE_PALETTE,
G_PARAM_WRITABLE);
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_FONT,
gimp_context_prop_names[GIMP_CONTEXT_PROP_FONT],
NULL,
GIMP_TYPE_FONT,
G_PARAM_WRITABLE);
g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_BUFFER,
g_param_spec_object (gimp_context_prop_names[GIMP_CONTEXT_PROP_BUFFER],
NULL, NULL,
@ -620,6 +655,9 @@ gimp_context_init (GimpContext *context)
context->palette = NULL;
context->palette_name = NULL;
context->font = NULL;
context->font_name = NULL;
context->buffer = NULL;
context->imagefile = NULL;
}
@ -701,6 +739,15 @@ gimp_context_constructor (GType type,
object,
0);
g_signal_connect_object (gimp->fonts, "remove",
G_CALLBACK (gimp_context_font_removed),
object,
0);
g_signal_connect_object (gimp->fonts, "thaw",
G_CALLBACK (gimp_context_font_list_thaw),
object,
0);
g_signal_connect_object (gimp->named_buffers, "remove",
G_CALLBACK (gimp_context_buffer_removed),
object,
@ -807,6 +854,17 @@ gimp_context_finalize (GObject *object)
context->palette_name = NULL;
}
if (context->font)
{
g_object_unref (context->font);
context->font = NULL;
}
if (context->font_name)
{
g_free (context->font_name);
context->font_name = NULL;
}
if (context->buffer)
{
g_object_unref (context->buffer);
@ -872,6 +930,9 @@ gimp_context_set_property (GObject *object,
case GIMP_CONTEXT_PROP_PALETTE:
gimp_context_set_palette (context, g_value_get_object (value));
break;
case GIMP_CONTEXT_PROP_FONT:
gimp_context_set_font (context, g_value_get_object (value));
break;
case GIMP_CONTEXT_PROP_BUFFER:
gimp_context_set_buffer (context, g_value_get_object (value));
break;
@ -942,6 +1003,9 @@ gimp_context_get_property (GObject *object,
case GIMP_CONTEXT_PROP_PALETTE:
g_value_set_object (value, gimp_context_get_palette (context));
break;
case GIMP_CONTEXT_PROP_FONT:
g_value_set_object (value, gimp_context_get_font (context));
break;
case GIMP_CONTEXT_PROP_BUFFER:
g_value_set_object (value, gimp_context_get_buffer (context));
break;
@ -974,6 +1038,9 @@ gimp_context_get_memsize (GimpObject *object)
if (context->palette_name)
memsize += strlen (context->palette_name) + 1;
if (context->font_name)
memsize += strlen (context->font_name) + 1;
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
@ -1010,6 +1077,7 @@ gimp_context_serialize_property (GObject *object,
case GIMP_CONTEXT_PROP_PATTERN:
case GIMP_CONTEXT_PROP_GRADIENT:
case GIMP_CONTEXT_PROP_PALETTE:
case GIMP_CONTEXT_PROP_FONT:
serialize_obj = g_value_get_object (value);
break;
@ -1079,6 +1147,12 @@ gimp_context_deserialize_property (GObject *object,
name_loc = &context->palette_name;
break;
case GIMP_CONTEXT_PROP_FONT:
container = context->gimp->fonts;
current = (GimpObject *) context->font;
name_loc = &context->font_name;
break;
default:
return FALSE;
}
@ -1366,6 +1440,14 @@ gimp_context_copy_property (GimpContext *src,
dest_name_loc = &dest->palette_name;
break;
case GIMP_CONTEXT_PROP_FONT:
gimp_context_real_set_font (dest, src->font);
object = src->font;
standard_object = standard_font;
src_name = src->font_name;
dest_name_loc = &dest->font_name;
break;
case GIMP_CONTEXT_PROP_BUFFER:
gimp_context_real_set_buffer (dest, src->buffer);
break;
@ -2578,6 +2660,141 @@ gimp_context_real_set_palette (GimpContext *context,
}
/*****************************************************************************/
/* font *****************************************************************/
GimpFont *
gimp_context_get_font (GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return context->font;
}
void
gimp_context_set_font (GimpContext *context,
GimpFont *font)
{
g_return_if_fail (GIMP_IS_CONTEXT (context));
context_find_defined (context, GIMP_CONTEXT_PROP_FONT);
gimp_context_real_set_font (context, font);
}
void
gimp_context_font_changed (GimpContext *context)
{
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_signal_emit (context,
gimp_context_signals[FONT_CHANGED], 0,
context->font);
}
/* the active palette was modified */
static void
gimp_context_font_dirty (GimpFont *font,
GimpContext *context)
{
g_free (context->font_name);
context->font_name = g_strdup (GIMP_OBJECT (font)->name);
g_object_notify (G_OBJECT (context), "font");
gimp_context_font_changed (context);
}
/* the global font list is there again after refresh */
static void
gimp_context_font_list_thaw (GimpContainer *container,
GimpContext *context)
{
GimpFont *font;
if (! context->font_name)
context->font_name = g_strdup (context->gimp->config->default_font);
if ((font = (GimpFont *)
gimp_container_get_child_by_name (container,
context->font_name)))
{
gimp_context_real_set_font (context, font);
return;
}
if (gimp_container_num_children (container))
gimp_context_real_set_font
(context,
GIMP_FONT (gimp_container_get_child_by_index (container, 0)));
else
gimp_context_real_set_font (context,
GIMP_FONT (gimp_font_get_standard ()));
}
/* the active font disappeared */
static void
gimp_context_font_removed (GimpContainer *container,
GimpFont *font,
GimpContext *context)
{
if (font == context->font)
{
context->font = NULL;
g_signal_handlers_disconnect_by_func (font,
gimp_context_font_dirty,
context);
g_object_unref (font);
if (! gimp_container_frozen (container))
gimp_context_font_list_thaw (container, context);
}
}
static void
gimp_context_real_set_font (GimpContext *context,
GimpFont *font)
{
if (! standard_font)
standard_font = GIMP_FONT (gimp_font_get_standard ());
if (context->font == font)
return;
if (context->font_name && font != standard_font)
{
g_free (context->font_name);
context->font_name = NULL;
}
/* disconnect from the old font's signals */
if (context->font)
{
g_signal_handlers_disconnect_by_func (context->font,
gimp_context_font_dirty,
context);
g_object_unref (context->font);
}
context->font = font;
if (font)
{
g_object_ref (font);
g_signal_connect_object (font, "name_changed",
G_CALLBACK (gimp_context_font_dirty),
context,
0);
if (font != standard_font)
context->font_name = g_strdup (GIMP_OBJECT (font)->name);
}
g_object_notify (G_OBJECT (context), "font");
gimp_context_font_changed (context);
}
/*****************************************************************************/
/* buffer ******************************************************************/

View File

@ -41,8 +41,9 @@ typedef enum
GIMP_CONTEXT_PROP_PATTERN = 10,
GIMP_CONTEXT_PROP_GRADIENT = 11,
GIMP_CONTEXT_PROP_PALETTE = 12,
GIMP_CONTEXT_PROP_BUFFER = 13,
GIMP_CONTEXT_PROP_IMAGEFILE = 14,
GIMP_CONTEXT_PROP_FONT = 13,
GIMP_CONTEXT_PROP_BUFFER = 14,
GIMP_CONTEXT_PROP_IMAGEFILE = 15,
GIMP_CONTEXT_LAST_PROP = GIMP_CONTEXT_PROP_IMAGEFILE
} GimpContextPropType;
@ -60,8 +61,9 @@ typedef enum
GIMP_CONTEXT_PATTERN_MASK = 1 << 10,
GIMP_CONTEXT_GRADIENT_MASK = 1 << 11,
GIMP_CONTEXT_PALETTE_MASK = 1 << 12,
GIMP_CONTEXT_BUFFER_MASK = 1 << 13,
GIMP_CONTEXT_IMAGEFILE_MASK = 1 << 14,
GIMP_CONTEXT_FONT_MASK = 1 << 13,
GIMP_CONTEXT_BUFFER_MASK = 1 << 14,
GIMP_CONTEXT_IMAGEFILE_MASK = 1 << 15,
/* aliases */
GIMP_CONTEXT_PAINT_PROPS_MASK = (GIMP_CONTEXT_FOREGROUND_MASK |
@ -75,6 +77,7 @@ typedef enum
GIMP_CONTEXT_DISPLAY_MASK |
GIMP_CONTEXT_TOOL_MASK |
GIMP_CONTEXT_PALETTE_MASK |
GIMP_CONTEXT_FONT_MASK |
GIMP_CONTEXT_BUFFER_MASK |
GIMP_CONTEXT_IMAGEFILE_MASK |
GIMP_CONTEXT_PAINT_PROPS_MASK)
@ -125,6 +128,9 @@ struct _GimpContext
GimpPalette *palette;
gchar *palette_name;
GimpFont *font;
gchar *font_name;
GimpBuffer *buffer;
GimpImagefile *imagefile;
};
@ -157,6 +163,8 @@ struct _GimpContextClass
GimpGradient *gradient);
void (* palette_changed) (GimpContext *context,
GimpPalette *palette);
void (* font_changed) (GimpContext *context,
GimpFont *font);
void (* buffer_changed) (GimpContext *context,
GimpBuffer *buffer);
void (* imagefile_changed) (GimpContext *context,
@ -302,6 +310,13 @@ void gimp_context_set_palette (GimpContext *context,
void gimp_context_palette_changed (GimpContext *context);
/* font */
GimpFont * gimp_context_get_font (GimpContext *context);
void gimp_context_set_font (GimpContext *context,
GimpFont *font);
void gimp_context_font_changed (GimpContext *context);
/* buffer */
GimpBuffer * gimp_context_get_buffer (GimpContext *context);
void gimp_context_set_buffer (GimpContext *context,

View File

@ -135,7 +135,6 @@ gimp_data_list_remove (GimpContainer *container,
GimpContainer *
gimp_data_list_new (GType children_type)
{
GimpDataList *list;