added CONSTRUCT_ONLY "data-factory" property. Removed

2004-09-26  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdataeditor.[ch]: added CONSTRUCT_ONLY
	"data-factory" property. Removed gimp_data_editor_construct().

	* app/widgets/gimpbrusheditor.c
	* app/widgets/gimpgradienteditor.c
	* app/widgets/gimppaletteeditor.c: pass the construct parameters
	to g_object_new().
This commit is contained in:
Michael Natterer 2004-09-26 19:26:37 +00:00 committed by Michael Natterer
parent 07e65b01cd
commit db85b16927
6 changed files with 73 additions and 92 deletions

View File

@ -1,3 +1,13 @@
2004-09-26 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdataeditor.[ch]: added CONSTRUCT_ONLY
"data-factory" property. Removed gimp_data_editor_construct().
* app/widgets/gimpbrusheditor.c
* app/widgets/gimpgradienteditor.c
* app/widgets/gimppaletteeditor.c: pass the construct parameters
to g_object_new().
2004-09-26 Sven Neumann <sven@gimp.org>
* app/widgets/gimpcolorframe.c: changed label alignment to be more

View File

@ -289,19 +289,9 @@ gimp_brush_editor_set_data (GimpDataEditor *editor,
GtkWidget *
gimp_brush_editor_new (Gimp *gimp)
{
GimpBrushEditor *editor;
editor = g_object_new (GIMP_TYPE_BRUSH_EDITOR, NULL);
if (! gimp_data_editor_construct (GIMP_DATA_EDITOR (editor),
gimp->brush_factory,
NULL, NULL, NULL))
{
g_object_unref (editor);
return NULL;
}
return GTK_WIDGET (editor);
return g_object_new (GIMP_TYPE_BRUSH_EDITOR,
"data-factory", gimp->brush_factory,
NULL);
}

View File

@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdataeditor.c
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2002-2004 Michael Natterer <mitch@gimp.org>
*
* 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
@ -43,11 +43,22 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_DATA_FACTORY
};
static void gimp_data_editor_class_init (GimpDataEditorClass *klass);
static void gimp_data_editor_init (GimpDataEditor *view);
static void gimp_data_editor_docked_iface_init (GimpDockedInterface *docked_iface);
static void gimp_data_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_data_editor_dispose (GObject *object);
static void gimp_data_editor_set_aux_info (GimpDocked *docked,
@ -120,9 +131,17 @@ gimp_data_editor_class_init (GimpDataEditorClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_data_editor_set_property;
object_class->dispose = gimp_data_editor_dispose;
klass->set_data = gimp_data_editor_real_set_data;
g_object_class_install_property (object_class, PROP_DATA_FACTORY,
g_param_spec_object ("data-factory",
NULL, NULL,
GIMP_TYPE_DATA_FACTORY,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
@ -133,8 +152,7 @@ gimp_data_editor_init (GimpDataEditor *editor)
editor->data_editable = FALSE;
editor->name_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (editor), editor->name_entry,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (editor), editor->name_entry, FALSE, FALSE, 0);
gtk_widget_show (editor->name_entry);
g_signal_connect (editor->name_entry, "activate",
@ -168,6 +186,25 @@ gimp_data_editor_docked_iface_init (GimpDockedInterface *docked_iface)
docked_iface->get_aux_info = gimp_data_editor_get_aux_info;
}
static void
gimp_data_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpDataEditor *editor = GIMP_DATA_EDITOR (object);
switch (property_id)
{
case PROP_DATA_FACTORY:
editor->data_factory = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_data_editor_dispose (GObject *object)
{
@ -266,38 +303,6 @@ gimp_data_editor_real_set_data (GimpDataEditor *editor,
gtk_widget_set_sensitive (editor->name_entry, editor->data_editable);
}
gboolean
gimp_data_editor_construct (GimpDataEditor *editor,
GimpDataFactory *data_factory,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier)
{
GimpData *data;
g_return_val_if_fail (GIMP_IS_DATA_EDITOR (editor), FALSE);
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (data_factory), FALSE);
g_return_val_if_fail (menu_factory == NULL ||
GIMP_IS_MENU_FACTORY (menu_factory), FALSE);
g_return_val_if_fail (menu_factory == NULL ||
menu_identifier != NULL, FALSE);
editor->data_factory = data_factory;
if (menu_factory && menu_identifier && ui_identifier)
gimp_editor_create_menu (GIMP_EDITOR (editor),
menu_factory, menu_identifier, ui_identifier,
editor);
data = (GimpData *)
gimp_context_get_by_type (gimp_get_user_context (data_factory->gimp),
data_factory->container->children_type);
gimp_data_editor_set_data (editor, data);
return TRUE;
}
void
gimp_data_editor_set_data (GimpDataEditor *editor,
GimpData *data)
@ -377,4 +382,3 @@ gimp_data_editor_save_dirty (GimpDataEditor *editor)
if (data && data->dirty && data->writable)
gimp_data_factory_data_save_single (editor->data_factory, data);
}

View File

@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdataeditor.h
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2002-2004 Michael Natterer <mitch@gimp.org>
*
* 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
@ -55,7 +55,6 @@ struct _GimpDataEditorClass
GimpEditorClass parent_class;
/* virtual functions */
void (* set_data) (GimpDataEditor *editor,
GimpData *data);
};
@ -63,12 +62,6 @@ struct _GimpDataEditorClass
GType gimp_data_editor_get_type (void) G_GNUC_CONST;
gboolean gimp_data_editor_construct (GimpDataEditor *editor,
GimpDataFactory *data_factory,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_identifier);
void gimp_data_editor_set_data (GimpDataEditor *editor,
GimpData *data);
GimpData * gimp_data_editor_get_data (GimpDataEditor *editor);

View File

@ -507,20 +507,12 @@ GtkWidget *
gimp_gradient_editor_new (Gimp *gimp,
GimpMenuFactory *menu_factory)
{
GimpGradientEditor *editor;
editor = g_object_new (GIMP_TYPE_GRADIENT_EDITOR, NULL);
if (! gimp_data_editor_construct (GIMP_DATA_EDITOR (editor),
gimp->gradient_factory,
menu_factory, "<GradientEditor>",
"/gradient-editor-popup"))
{
g_object_unref (editor);
return NULL;
}
return GTK_WIDGET (editor);
return g_object_new (GIMP_TYPE_GRADIENT_EDITOR,
"menu-factory", menu_factory,
"menu-identifier", "<GradientEditor>",
"ui-path", "/gradient-editor-popup",
"data-factory", gimp->gradient_factory,
NULL);
}
void

View File

@ -500,20 +500,12 @@ GtkWidget *
gimp_palette_editor_new (Gimp *gimp,
GimpMenuFactory *menu_factory)
{
GimpPaletteEditor *editor;
editor = g_object_new (GIMP_TYPE_PALETTE_EDITOR, NULL);
if (! gimp_data_editor_construct (GIMP_DATA_EDITOR (editor),
gimp->palette_factory,
menu_factory, "<PaletteEditor>",
"/palette-editor-popup"))
{
g_object_unref (editor);
return NULL;
}
return GTK_WIDGET (editor);
return g_object_new (GIMP_TYPE_PALETTE_EDITOR,
"menu-factory", menu_factory,
"menu-identifier", "<PaletteEditor>",
"ui-path", "/palette-editor-popup",
"data-factory", gimp->palette_factory,
NULL);
}
void