add the new context to gimp->context_list in gimp_context_constructor(),

2003-10-14  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontext.c: add the new context to gimp->context_list
	in gimp_context_constructor(), not in set_property(). Cleanup.

	* app/tools/gimptextoptions.c: added finalizer so we don't leak
	the options' GtkTextBuffer and GimpText objects. Cleanup.
This commit is contained in:
Michael Natterer 2003-10-14 16:40:02 +00:00 committed by Michael Natterer
parent d9e5024a5c
commit e8508ded68
3 changed files with 101 additions and 104 deletions

View File

@ -1,3 +1,11 @@
2003-10-14 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontext.c: add the new context to gimp->context_list
in gimp_context_constructor(), not in set_property(). Cleanup.
* app/tools/gimptextoptions.c: added finalizer so we don't leak
the options' GtkTextBuffer and GimpText objects. Cleanup.
2003-10-14 Sven Neumann <sven@gimp.org>
* app/widgets/gimptemplateeditor.c (gimp_template_editor_new):

View File

@ -718,95 +718,77 @@ gimp_context_constructor (GType type,
g_assert (GIMP_IS_GIMP (gimp));
gimp->context_list = g_list_prepend (gimp->context_list, object);
g_signal_connect_object (gimp->images, "remove",
G_CALLBACK (gimp_context_image_removed),
object,
0);
G_CALLBACK (gimp_context_image_removed),
object, 0);
g_signal_connect_object (gimp->displays, "remove",
G_CALLBACK (gimp_context_display_removed),
object,
0);
G_CALLBACK (gimp_context_display_removed),
object, 0);
g_signal_connect_object (gimp->tool_info_list, "remove",
G_CALLBACK (gimp_context_tool_removed),
object,
0);
G_CALLBACK (gimp_context_tool_removed),
object, 0);
g_signal_connect_object (gimp->tool_info_list, "thaw",
G_CALLBACK (gimp_context_tool_list_thaw),
object,
0);
G_CALLBACK (gimp_context_tool_list_thaw),
object, 0);
g_signal_connect_object (gimp->brush_factory->container, "remove",
G_CALLBACK (gimp_context_brush_removed),
object,
0);
G_CALLBACK (gimp_context_brush_removed),
object, 0);
g_signal_connect_object (gimp->brush_factory->container, "thaw",
G_CALLBACK (gimp_context_brush_list_thaw),
object,
0);
G_CALLBACK (gimp_context_brush_list_thaw),
object, 0);
g_signal_connect_object (gimp->pattern_factory->container, "remove",
G_CALLBACK (gimp_context_pattern_removed),
object,
0);
G_CALLBACK (gimp_context_pattern_removed),
object, 0);
g_signal_connect_object (gimp->pattern_factory->container, "thaw",
G_CALLBACK (gimp_context_pattern_list_thaw),
object,
0);
G_CALLBACK (gimp_context_pattern_list_thaw),
object, 0);
g_signal_connect_object (gimp->gradient_factory->container, "remove",
G_CALLBACK (gimp_context_gradient_removed),
object,
0);
G_CALLBACK (gimp_context_gradient_removed),
object, 0);
g_signal_connect_object (gimp->gradient_factory->container, "thaw",
G_CALLBACK (gimp_context_gradient_list_thaw),
object,
0);
G_CALLBACK (gimp_context_gradient_list_thaw),
object, 0);
g_signal_connect_object (gimp->palette_factory->container, "remove",
G_CALLBACK (gimp_context_palette_removed),
object,
0);
G_CALLBACK (gimp_context_palette_removed),
object, 0);
g_signal_connect_object (gimp->palette_factory->container, "thaw",
G_CALLBACK (gimp_context_palette_list_thaw),
object,
0);
G_CALLBACK (gimp_context_palette_list_thaw),
object, 0);
g_signal_connect_object (gimp->fonts, "remove",
G_CALLBACK (gimp_context_font_removed),
object,
0);
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_CALLBACK (gimp_context_font_list_thaw),
object, 0);
g_signal_connect_object (gimp->named_buffers, "remove",
G_CALLBACK (gimp_context_buffer_removed),
object,
0);
G_CALLBACK (gimp_context_buffer_removed),
object, 0);
g_signal_connect_object (gimp->named_buffers, "thaw",
G_CALLBACK (gimp_context_buffer_list_thaw),
object,
0);
object, 0);
g_signal_connect_object (gimp->documents, "remove",
G_CALLBACK (gimp_context_imagefile_removed),
object,
0);
G_CALLBACK (gimp_context_imagefile_removed),
object, 0);
g_signal_connect_object (gimp->documents, "thaw",
G_CALLBACK (gimp_context_imagefile_list_thaw),
object,
0);
G_CALLBACK (gimp_context_imagefile_list_thaw),
object, 0);
g_signal_connect_object (gimp->templates, "remove",
G_CALLBACK (gimp_context_template_removed),
object,
0);
G_CALLBACK (gimp_context_template_removed),
object, 0);
g_signal_connect_object (gimp->templates, "thaw",
G_CALLBACK (gimp_context_template_list_thaw),
object,
0);
G_CALLBACK (gimp_context_template_list_thaw),
object, 0);
return object;
}
@ -814,9 +796,7 @@ gimp_context_constructor (GType type,
static void
gimp_context_dispose (GObject *object)
{
GimpContext *context;
context = GIMP_CONTEXT (object);
GimpContext *context = GIMP_CONTEXT (object);
if (context->gimp)
{
@ -831,9 +811,7 @@ gimp_context_dispose (GObject *object)
static void
gimp_context_finalize (GObject *object)
{
GimpContext *context;
context = GIMP_CONTEXT (object);
GimpContext *context = GIMP_CONTEXT (object);
if (context->parent)
gimp_context_set_parent (context, NULL);
@ -934,16 +912,12 @@ gimp_context_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpContext *context;
context = GIMP_CONTEXT (object);
GimpContext *context = GIMP_CONTEXT (object);
switch (property_id)
{
case GIMP_CONTEXT_PROP_GIMP:
context->gimp = g_value_get_object (value);
context->gimp->context_list = g_list_prepend (context->gimp->context_list,
context);
break;
case GIMP_CONTEXT_PROP_IMAGE:
gimp_context_set_image (context, g_value_get_object (value));
@ -1002,9 +976,7 @@ gimp_context_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpContext *context;
context = GIMP_CONTEXT (object);
GimpContext *context = GIMP_CONTEXT (object);
switch (property_id)
{
@ -1076,11 +1048,9 @@ static gsize
gimp_context_get_memsize (GimpObject *object,
gsize *gui_size)
{
GimpContext *context;
GimpContext *context = GIMP_CONTEXT (object);
gsize memsize = 0;
context = GIMP_CONTEXT (object);
if (context->tool_name)
memsize += strlen (context->tool_name) + 1;

View File

@ -60,21 +60,22 @@ enum
static void gimp_text_options_init (GimpTextOptions *options);
static void gimp_text_options_class_init (GimpTextOptionsClass *options_class);
static void gimp_text_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_text_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_text_options_finalize (GObject *object);
static void gimp_text_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_text_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_text_options_notify_font (GimpContext *context,
GParamSpec *pspec,
GimpText *text);
static void gimp_text_notify_font (GimpText *text,
GParamSpec *pspec,
GimpContext *context);
static void gimp_text_options_notify_font (GimpContext *context,
GParamSpec *pspec,
GimpText *text);
static void gimp_text_options_notify_text_font (GimpText *text,
GParamSpec *pspec,
GimpContext *context);
static GimpToolOptionsClass *parent_class = NULL;
@ -117,6 +118,7 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_text_options_finalize;
object_class->set_property = gimp_text_options_set_property;
object_class->get_property = gimp_text_options_get_property;
@ -129,21 +131,38 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
static void
gimp_text_options_init (GimpTextOptions *options)
{
GObject *text;
text = g_object_new (GIMP_TYPE_TEXT, NULL);
options->text = GIMP_TEXT (text);
options->buffer = gimp_prop_text_buffer_new (text, "text", -1);
options->text = g_object_new (GIMP_TYPE_TEXT, NULL);
options->buffer = gimp_prop_text_buffer_new (G_OBJECT (options->text),
"text", -1);
g_signal_connect_object (options, "notify::font",
G_CALLBACK (gimp_text_options_notify_font),
text, 0);
g_signal_connect_object (text, "notify::font",
G_CALLBACK (gimp_text_notify_font),
options->text, 0);
g_signal_connect_object (options->text, "notify::font",
G_CALLBACK (gimp_text_options_notify_text_font),
options, 0);
}
static void
gimp_text_options_finalize (GObject *object)
{
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
if (options->buffer)
{
g_object_unref (options->buffer);
options->buffer = NULL;
}
if (options->text)
{
g_object_unref (options->text);
options->text = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_text_options_set_property (GObject *object,
guint property_id,
@ -192,7 +211,7 @@ gimp_text_options_notify_font (GimpContext *context,
GimpFont *font = gimp_context_get_font (context);
g_signal_handlers_block_by_func (text,
gimp_text_notify_font,
gimp_text_options_notify_text_font,
context);
g_object_set (text,
@ -200,14 +219,14 @@ gimp_text_options_notify_font (GimpContext *context,
NULL);
g_signal_handlers_unblock_by_func (text,
gimp_text_notify_font,
gimp_text_options_notify_text_font,
context);
}
static void
gimp_text_notify_font (GimpText *text,
GParamSpec *pspec,
GimpContext *context)
gimp_text_options_notify_text_font (GimpText *text,
GParamSpec *pspec,
GimpContext *context)
{
GimpObject *font;
gchar *value;