gimp/libgimpconfig/gimpconfig-utils.c

462 lines
12 KiB
C
Raw Normal View History

/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Utitility functions for GimpConfig.
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; 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 "libgimpbase/gimpbase.h"
#include "gimpconfigtypes.h"
2005-01-26 03:11:26 +08:00
#include "gimpconfigwriter.h"
#include "gimpconfig-iface.h"
#include "gimpconfig-params.h"
#include "gimpconfig-utils.h"
static gboolean
gimp_config_diff_property (GObject *a,
GObject *b,
GParamSpec *prop_spec)
{
GValue a_value = { 0, };
GValue b_value = { 0, };
gboolean retval = FALSE;
g_value_init (&a_value, prop_spec->value_type);
g_value_init (&b_value, prop_spec->value_type);
g_object_get_property (a, prop_spec->name, &a_value);
g_object_get_property (b, prop_spec->name, &b_value);
if (g_param_values_cmp (prop_spec, &a_value, &b_value))
{
if ((prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE) &&
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
GIMP_TYPE_CONFIG))
{
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
g_value_get_object (&b_value)))
{
retval = TRUE;
}
}
else
{
retval = TRUE;
}
}
g_value_unset (&a_value);
g_value_unset (&b_value);
return retval;
}
static GList *
gimp_config_diff_same (GObject *a,
GObject *b,
GParamFlags flags)
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
{
GParamSpec **param_specs;
guint n_param_specs;
gint i;
GList *list = NULL;
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a),
&n_param_specs);
for (i = 0; i < n_param_specs; i++)
{
GParamSpec *prop_spec = param_specs[i];
if (! flags || ((prop_spec->flags & flags) == flags))
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
{
if (gimp_config_diff_property (a, b, prop_spec))
list = g_list_prepend (list, prop_spec);
}
}
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
g_free (param_specs);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
return list;
}
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
static GList *
gimp_config_diff_other (GObject *a,
GObject *b,
GParamFlags flags)
{
GParamSpec **param_specs;
guint n_param_specs;
gint i;
GList *list = NULL;
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a),
&n_param_specs);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
for (i = 0; i < n_param_specs; i++)
{
GParamSpec *a_spec = param_specs[i];
GParamSpec *b_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (b),
a_spec->name);
if (b_spec &&
(a_spec->value_type == b_spec->value_type) &&
(! flags || (a_spec->flags & b_spec->flags & flags) == flags))
{
if (gimp_config_diff_property (a, b, b_spec))
list = g_list_prepend (list, b_spec);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
}
}
g_free (param_specs);
return list;
}
/**
* gimp_config_diff:
* @a: a #GObject
* @b: another #GObject object
* @flags: a mask of GParamFlags
*
* Compares all properties of @a and @b that have all @flags set. If
* @flags is 0, all properties are compared.
*
* If the two objects are not of the same type, only properties that
* exist in both object classes and are of the same value_type are
* compared.
*
* Return value: a GList of differing GParamSpecs.
*
* Since: GIMP 2.4
**/
GList *
gimp_config_diff (GObject *a,
GObject *b,
GParamFlags flags)
{
GList *diff;
g_return_val_if_fail (G_IS_OBJECT (a), NULL);
g_return_val_if_fail (G_IS_OBJECT (b), NULL);
if (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b))
diff = gimp_config_diff_same (a, b, flags);
else
diff = gimp_config_diff_other (a, b, flags);
return g_list_reverse (diff);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
}
/**
* gimp_config_sync:
* @src: a #GObject
* @dest: another #GObject
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
* @flags: a mask of GParamFlags
*
* Compares all read- and write-able properties from @src and @dest
* that have all @flags set. Differing values are then copied from
* @src to @dest. If @flags is 0, all differing read/write properties.
*
* Properties marked as "construct-only" are not touched.
*
* If the two objects are not of the same type, only properties that
* exist in both object classes and are of the same value_type are
* synchronized
*
* Return value: %TRUE if @dest was modified, %FALSE otherwise
*
* Since: GIMP 2.4
**/
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
gboolean
gimp_config_sync (GObject *src,
GObject *dest,
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
GParamFlags flags)
{
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
GList *diff;
GList *list;
g_return_val_if_fail (G_IS_OBJECT (src), FALSE);
g_return_val_if_fail (G_IS_OBJECT (dest), FALSE);
/* we use the internal versions here for a number of reasons:
* - it saves a g_list_reverse()
* - it avoids duplicated parameter checks
* - it makes GimpTemplateEditor work (resolution is set before size)
*/
if (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest))
diff = gimp_config_diff_same (src, dest, (flags | G_PARAM_READWRITE));
else
diff = gimp_config_diff_other (src, dest, flags);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
if (!diff)
return FALSE;
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
for (list = diff; list; list = list->next)
{
GParamSpec *prop_spec = list->data;
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
if (! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
{
GValue value = { 0, };
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
g_value_init (&value, prop_spec->value_type);
g_object_get_property (src, prop_spec->name, &value);
g_object_set_property (dest, prop_spec->name, &value);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
g_value_unset (&value);
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
}
}
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
g_list_free (diff);
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
return TRUE;
}
/**
* gimp_config_reset_properties:
* @object: a #GObject
*
* Resets all writable properties of @object to the default values as
* defined in their #GParamSpec. Properties marked as "construct-only"
* are not touched.
*
* If you want to reset a #GimpConfig object, please use gimp_config_reset().
*
* Since: GIMP 2.4
**/
void
gimp_config_reset_properties (GObject *object)
{
GObjectClass *klass;
GParamSpec **property_specs;
GValue value = { 0, };
guint n_property_specs;
guint i;
g_return_if_fail (G_IS_OBJECT (object));
klass = G_OBJECT_GET_CLASS (object);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
if (!property_specs)
return;
g_object_freeze_notify (object);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec;
prop_spec = property_specs[i];
if ((prop_spec->flags & G_PARAM_WRITABLE) &&
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
{
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
if (G_IS_PARAM_SPEC_OBJECT (prop_spec))
{
if ((prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE) &&
(prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE) &&
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
app/widgets/gimpdocked.[ch] renamed GimpDockedIface to 2003-10-11 Sven Neumann <sven@gimp.org> * app/widgets/gimpdocked.[ch] * app/widgets/widgets-types.h: renamed GimpDockedIface to GimpDockedInterface. * app/display/gimpnavigationview.c * app/widgets/gimpcoloreditor.c * app/widgets/gimpcontainereditor.c * app/widgets/gimpcontainerview.c * app/widgets/gimpeditor.c * app/widgets/gimpimageeditor.c * app/widgets/gimpitemtreeview.c * app/widgets/gimptooloptionseditor.c: changed accordingly. * app/config/config-types.h * app/config/gimpconfig.[ch] * app/config/gimpconfig-deserialize.[ch] * app/config/gimpconfig-serialize.[ch] * app/config/gimpconfig-utils.[ch]: added a GimpConfig typedef and changed the GimpConfig API to take GimpConfig instead of GObject pointers. * app/config/gimpconfig-dump.c * app/config/gimprc.c * app/config/test-config.c * app/core/gimp-documents.c * app/core/gimp-parasites.c * app/core/gimp-templates.c * app/core/gimp.[ch] * app/core/gimpcontainer.c * app/core/gimpcontext.c * app/core/gimpdocumentlist.c * app/core/gimpgrid.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimpparasitelist.c * app/core/gimptemplate.c * app/core/gimptooloptions.c * app/core/gimpviewable.c * app/gui/grid-dialog.c * app/gui/preferences-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tool-options-commands.c * app/paint/gimppaintcore.c * app/pdb/gimprc_cmds.c * app/text/gimptext-parasite.c * app/text/gimptext.c * app/text/gimptextlayer.c * app/tools/gimp-tools.c * app/tools/gimptexttool.c * app/widgets/gimpdevices.c * app/widgets/gimptemplateeditor.c * app/widgets/gimptemplateview.c * tools/pdbgen/pdb/gimprc.pdb: changed accordingly.
2003-10-11 22:30:18 +08:00
GIMP_TYPE_CONFIG))
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
{
g_value_init (&value, prop_spec->value_type);
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
g_object_get_property (object, prop_spec->name, &value);
gimp_config_reset (g_value_get_object (&value));
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
g_value_unset (&value);
}
}
else
{
g_value_init (&value, prop_spec->value_type);
g_param_value_set_default (prop_spec, &value);
app/widgets/gimpdocked.[ch] renamed GimpDockedIface to 2003-10-11 Sven Neumann <sven@gimp.org> * app/widgets/gimpdocked.[ch] * app/widgets/widgets-types.h: renamed GimpDockedIface to GimpDockedInterface. * app/display/gimpnavigationview.c * app/widgets/gimpcoloreditor.c * app/widgets/gimpcontainereditor.c * app/widgets/gimpcontainerview.c * app/widgets/gimpeditor.c * app/widgets/gimpimageeditor.c * app/widgets/gimpitemtreeview.c * app/widgets/gimptooloptionseditor.c: changed accordingly. * app/config/config-types.h * app/config/gimpconfig.[ch] * app/config/gimpconfig-deserialize.[ch] * app/config/gimpconfig-serialize.[ch] * app/config/gimpconfig-utils.[ch]: added a GimpConfig typedef and changed the GimpConfig API to take GimpConfig instead of GObject pointers. * app/config/gimpconfig-dump.c * app/config/gimprc.c * app/config/test-config.c * app/core/gimp-documents.c * app/core/gimp-parasites.c * app/core/gimp-templates.c * app/core/gimp.[ch] * app/core/gimpcontainer.c * app/core/gimpcontext.c * app/core/gimpdocumentlist.c * app/core/gimpgrid.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimpparasitelist.c * app/core/gimptemplate.c * app/core/gimptooloptions.c * app/core/gimpviewable.c * app/gui/grid-dialog.c * app/gui/preferences-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tool-options-commands.c * app/paint/gimppaintcore.c * app/pdb/gimprc_cmds.c * app/text/gimptext-parasite.c * app/text/gimptext.c * app/text/gimptextlayer.c * app/tools/gimp-tools.c * app/tools/gimptexttool.c * app/widgets/gimpdevices.c * app/widgets/gimptemplateeditor.c * app/widgets/gimptemplateview.c * tools/pdbgen/pdb/gimprc.pdb: changed accordingly.
2003-10-11 22:30:18 +08:00
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-13 03:06:25 +08:00
g_object_set_property (object, prop_spec->name, &value);
g_value_unset (&value);
}
}
}
g_free (property_specs);
g_object_thaw_notify (object);
}
/**
* gimp_config_reset_property:
* @object: a #GObject
* @property_name: name of the property to reset
*
* Resets the property named @property_name to its default value. The
* property must be writable and must not be marked as "construct-only".
*
* Since: GIMP 2.4
**/
void
gimp_config_reset_property (GObject *object,
const gchar *property_name)
{
GObjectClass *klass;
GParamSpec *prop_spec;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (property_name != NULL);
klass = G_OBJECT_GET_CLASS (object);
prop_spec = g_object_class_find_property (klass, property_name);
if (!prop_spec)
return;
if ((prop_spec->flags & G_PARAM_WRITABLE) &&
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
{
GValue value = { 0, };
if (G_IS_PARAM_SPEC_OBJECT (prop_spec))
{
if ((prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE) &&
(prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE) &&
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
GIMP_TYPE_CONFIG))
{
g_value_init (&value, prop_spec->value_type);
g_object_get_property (object, prop_spec->name, &value);
gimp_config_reset (g_value_get_object (&value));
g_value_unset (&value);
}
}
else
{
g_value_init (&value, prop_spec->value_type);
g_param_value_set_default (prop_spec, &value);
g_object_set_property (object, prop_spec->name, &value);
g_value_unset (&value);
}
}
}
/*
* GimpConfig string utilities
*/
/**
* gimp_config_string_append_escaped:
* @string: pointer to a #GString
* @val: a string to append or %NULL
*
* Escapes and quotes @val and appends it to @string. The escape
* algorithm is different from the one used by g_strescape() since it
* leaves non-ASCII characters intact and thus preserves UTF-8
* strings. Only control characters and quotes are being escaped.
*
* Since: GIMP 2.4
**/
void
gimp_config_string_append_escaped (GString *string,
const gchar *val)
{
g_return_if_fail (string != NULL);
if (val)
{
const guchar *p;
gchar buf[4] = { '\\', 0, 0, 0 };
gint len;
g_string_append_c (string, '\"');
for (p = (const guchar *) val, len = 0; *p; p++)
{
if (*p < ' ' || *p == '\\' || *p == '\"')
{
g_string_append_len (string, val, len);
len = 2;
switch (*p)
{
case '\b':
buf[1] = 'b';
break;
case '\f':
buf[1] = 'f';
break;
case '\n':
buf[1] = 'n';
break;
case '\r':
buf[1] = 'r';
break;
case '\t':
buf[1] = 't';
break;
case '\\':
case '"':
buf[1] = *p;
break;
default:
len = 4;
buf[1] = '0' + (((*p) >> 6) & 07);
buf[2] = '0' + (((*p) >> 3) & 07);
buf[3] = '0' + ((*p) & 07);
break;
}
g_string_append_len (string, buf, len);
val = (const gchar *) p + 1;
len = 0;
}
else
{
len++;
}
}
g_string_append_len (string, val, len);
g_string_append_c (string, '\"');
}
else
{
g_string_append_len (string, "\"\"", 2);
}
}