added context->serialize_props mask which enables specifying exactly which

2004-07-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontext.[ch]: added context->serialize_props mask
	which enables specifying exactly which properties will be
	serialized. Also fixes a bug that prevented undefined properties
	from being serialized, breaking tool_options and device status
	serialization.

	* app/core/gimptoolinfo.c (gimp_tool_info_new): make only the
	properties in the tool_info->context_props mask serializable, also
	configure/initialize tool_info->tool_options.

	* app/tools/gimp-tools.c (gimp_tools_register): removed
	tool_options initialization that is now done in
	gimp_tool_info_new().

	* app/widgets/gimpdeviceinfo.c: make only the properties in
	GIMP_DEVICE_INFO_CONTEXT_MASK serializable.

	* app/widgets/gimpdevicestatus.c: add the device table to its
	parent container again. Fixes "missing" devices.

	* app/core/gimptooloptions.c
	* app/widgets/gimpdevices.c: cleanup / code review.
This commit is contained in:
Michael Natterer 2004-07-03 20:27:28 +00:00 committed by Michael Natterer
parent 04ed4a8a0f
commit 23f6a194ac
9 changed files with 586 additions and 556 deletions

View File

@ -1,3 +1,28 @@
2004-07-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontext.[ch]: added context->serialize_props mask
which enables specifying exactly which properties will be
serialized. Also fixes a bug that prevented undefined properties
from being serialized, breaking tool_options and device status
serialization.
* app/core/gimptoolinfo.c (gimp_tool_info_new): make only the
properties in the tool_info->context_props mask serializable, also
configure/initialize tool_info->tool_options.
* app/tools/gimp-tools.c (gimp_tools_register): removed
tool_options initialization that is now done in
gimp_tool_info_new().
* app/widgets/gimpdeviceinfo.c: make only the properties in
GIMP_DEVICE_INFO_CONTEXT_MASK serializable.
* app/widgets/gimpdevicestatus.c: add the device table to its
parent container again. Fixes "missing" devices.
* app/core/gimptooloptions.c
* app/widgets/gimpdevices.c: cleanup / code review.
2004-07-03 Michael Natterer <mitch@gimp.org>
* app/tools/gimppainttool.c (gimp_paint_tool_cursor_update): if

View File

@ -249,7 +249,7 @@ enum
GIMP_CONTEXT_PROP_0,
GIMP_CONTEXT_PROP_GIMP
/* remaining values are in gimpcontext.h */
/* remaining values are in core-types.h */
};
enum
@ -369,17 +369,14 @@ gimp_context_get_type (void)
static void
gimp_context_class_init (GimpContextClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpRGB black;
GimpRGB white;
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_rgba_set (&white, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gimp_context_signals[IMAGE_CHANGED] =
@ -675,6 +672,7 @@ gimp_context_init (GimpContext *context)
context->parent = NULL;
context->defined_props = GIMP_CONTEXT_ALL_PROPS_MASK;
context->serialize_props = GIMP_CONTEXT_ALL_PROPS_MASK;
context->image = NULL;
context->display = NULL;
@ -1122,8 +1120,8 @@ gimp_context_serialize_property (GimpConfig *config,
GimpContext *context = GIMP_CONTEXT (config);
GimpObject *serialize_obj;
/* serialize nothing if the property is not defined */
if (! ((1 << property_id) & context->defined_props))
/* serialize nothing if the property is not in serialize_props */
if (! ((1 << property_id) & context->serialize_props))
return TRUE;
switch (property_id)
@ -1416,6 +1414,26 @@ gimp_context_define_properties (GimpContext *context,
}
/* specify which context properties will be serialized */
void
gimp_context_set_serialize_properties (GimpContext *context,
GimpContextPropMask props_mask)
{
g_return_if_fail (GIMP_IS_CONTEXT (context));
context->serialize_props = props_mask;
}
GimpContextPropMask
gimp_context_get_serialize_properties (GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_CONTEXT (context), 0);
return context->serialize_props;
}
/* copying context properties */
void

View File

@ -45,6 +45,7 @@ struct _GimpContext
GimpContext *parent;
guint32 defined_props;
guint32 serialize_props;
GimpImage *image;
gpointer display;
@ -151,6 +152,16 @@ void gimp_context_define_properties (GimpContext *context,
GimpContextPropMask props_mask,
gboolean defined);
/* specify which context properties will be serialized
*/
void gimp_context_set_serialize_properties (GimpContext *context,
GimpContextPropMask props_mask);
GimpContextPropMask
gimp_context_get_serialize_properties (GimpContext *context);
/* copying context properties
*/
void gimp_context_copy_property (GimpContext *src,

View File

@ -303,6 +303,19 @@ gimp_tool_info_new (Gimp *gimp,
g_object_set (tool_info->tool_options, "tool-info", tool_info, NULL);
if (tool_info->context_props)
{
gimp_context_define_properties (GIMP_CONTEXT (tool_info->tool_options),
tool_info->context_props, FALSE);
gimp_context_copy_properties (gimp_get_user_context (gimp),
GIMP_CONTEXT (tool_info->tool_options),
GIMP_CONTEXT_ALL_PROPS_MASK);
}
gimp_context_set_serialize_properties (GIMP_CONTEXT (tool_info->tool_options),
tool_info->context_props);
if (tool_info->tool_options_type != GIMP_TYPE_TOOL_OPTIONS)
{
tool_info->options_presets = gimp_list_new (tool_info->tool_options_type,

View File

@ -86,9 +86,7 @@ gimp_tool_options_get_type (void)
static void
gimp_tool_options_class_init (GimpToolOptionsClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -117,9 +115,7 @@ gimp_tool_options_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpToolOptions *options;
options = GIMP_TOOL_OPTIONS (object);
GimpToolOptions *options = GIMP_TOOL_OPTIONS (object);
switch (property_id)
{
@ -147,9 +143,7 @@ gimp_tool_options_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpToolOptions *options;
options = GIMP_TOOL_OPTIONS (object);
GimpToolOptions *options = GIMP_TOOL_OPTIONS (object);
switch (property_id)
{

View File

@ -458,16 +458,6 @@ gimp_tools_register (GType tool_type,
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func",
options_gui_func);
if (tool_info->context_props)
{
gimp_context_define_properties (GIMP_CONTEXT (tool_info->tool_options),
tool_info->context_props, FALSE);
gimp_context_copy_properties (gimp_get_user_context (gimp),
GIMP_CONTEXT (tool_info->tool_options),
GIMP_CONTEXT_ALL_PROPS_MASK);
}
gimp_container_add (gimp->tool_info_list, GIMP_OBJECT (tool_info));
g_object_unref (tool_info);

View File

@ -107,11 +107,9 @@ gimp_device_info_get_type (void)
static void
gimp_device_info_class_init (GimpDeviceInfoClass *klass)
{
GObjectClass *object_class;
GObjectClass *object_class = G_OBJECT_CLASS (klass);;
GParamSpec *array_spec;
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
device_info_signals[CHANGED] =
@ -141,7 +139,6 @@ gimp_device_info_class_init (GimpDeviceInfoClass *klass)
GDK_AXIS_IGNORE,
G_PARAM_READWRITE),
GIMP_CONFIG_PARAM_FLAGS);
g_object_class_install_property (object_class, PROP_AXES, array_spec);
array_spec = g_param_spec_value_array ("keys",
@ -151,7 +148,6 @@ gimp_device_info_class_init (GimpDeviceInfoClass *klass)
NULL,
G_PARAM_READWRITE),
GIMP_CONFIG_PARAM_FLAGS);
g_object_class_install_property (object_class, PROP_KEYS, array_spec);
}
@ -187,6 +183,9 @@ gimp_device_info_constructor (GType type,
GIMP_CONTEXT (object),
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_serialize_properties (GIMP_CONTEXT (object),
GIMP_DEVICE_INFO_CONTEXT_MASK);
/* FIXME: this is ugly and needs to be done via "notify" once
* the contexts' properties are dynamic.
*/
@ -215,9 +214,7 @@ gimp_device_info_constructor (GType type,
static void
gimp_device_info_finalize (GObject *object)
{
GimpDeviceInfo *device_info;
device_info = GIMP_DEVICE_INFO (object);
GimpDeviceInfo *device_info = GIMP_DEVICE_INFO (object);
if (device_info->axes)
g_free (device_info->axes);
@ -234,12 +231,8 @@ gimp_device_info_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpDeviceInfo *device_info;
GdkDevice *device;
device_info = GIMP_DEVICE_INFO (object);
device = device_info->device;
GimpDeviceInfo *device_info = GIMP_DEVICE_INFO (object);
GdkDevice *device = device_info->device;
switch (property_id)
{
@ -252,9 +245,7 @@ gimp_device_info_set_property (GObject *object,
case PROP_AXES:
{
GValueArray *array;
array = g_value_get_boxed (value);
GValueArray *array = g_value_get_boxed (value);
if (array)
{
@ -290,9 +281,7 @@ gimp_device_info_set_property (GObject *object,
case PROP_KEYS:
{
GValueArray *array;
array = g_value_get_boxed (value);
GValueArray *array = g_value_get_boxed (value);
if (array)
{
@ -347,12 +336,8 @@ gimp_device_info_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpDeviceInfo *device_info;
GdkDevice *device;
device_info = GIMP_DEVICE_INFO (object);
device = device_info->device;
GimpDeviceInfo *device_info = GIMP_DEVICE_INFO (object);
GdkDevice *device = device_info->device;
switch (property_id)
{

View File

@ -90,8 +90,7 @@ gimp_devices_init (Gimp *gimp,
GimpDeviceInfo *device_info;
device_info = gimp_device_info_new (gimp, device->name);
gimp_container_add (manager->device_info_list,
GIMP_OBJECT (device_info));
gimp_container_add (manager->device_info_list, GIMP_OBJECT (device_info));
g_object_unref (device_info);
gimp_device_info_set_from_device (device_info, device);

View File

@ -116,11 +116,7 @@ gimp_device_status_get_type (void)
static void
gimp_device_status_class_init (GimpDeviceStatusClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -145,6 +141,7 @@ gimp_device_status_init (GimpDeviceStatus *status)
status->table = gtk_table_new (status->num_devices * 3, 7, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (status->table), 6);
gtk_table_set_col_spacings (GTK_TABLE (status->table), 6);
gtk_container_add (GTK_CONTAINER (status), status->table);
gtk_widget_show (status->table);
for (list = gdk_display_list_devices (display), i = 0;
@ -378,7 +375,7 @@ gimp_device_status_update_entry (GimpDeviceInfo *device_info,
}
else
{
GimpContext *context;
GimpContext *context = GIMP_CONTEXT (device_info);
GimpRGB color;
guchar r, g, b;
gchar buf[64];
@ -392,8 +389,6 @@ gimp_device_status_update_entry (GimpDeviceInfo *device_info,
gtk_widget_show (entry->pattern);
gtk_widget_show (entry->gradient);
context = GIMP_CONTEXT (device_info);
gimp_context_get_foreground (context, &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
g_snprintf (buf, sizeof (buf), _("Foreground: %d, %d, %d"), r, g, b);