added new utility functions gimp_config_connect() and

2003-02-10  Sven Neumann  <sven@gimp.org>

	* app/config/gimpconfig-utils.[ch]: added new utility functions
	gimp_config_connect() and gimp_config_disconnect() and documented
	most functions.

	* app/tools/gimptexttool.c (gimp_text_tool_connect): use the new
	GimpConfig utility functions.
This commit is contained in:
Sven Neumann 2003-02-10 14:13:55 +00:00 committed by Sven Neumann
parent 599c2b904f
commit 5d402908f8
8 changed files with 202 additions and 24 deletions

View file

@ -1,3 +1,12 @@
2003-02-10 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-utils.[ch]: added new utility functions
gimp_config_connect() and gimp_config_disconnect() and documented
most functions.
* app/tools/gimptexttool.c (gimp_text_tool_connect): use the new
GimpConfig utility functions.
2003-02-10 Sven Neumann <sven@gimp.org>
* app/config/gimprc.c (gimp_rc_query): allow to query for gimp

View file

@ -30,6 +30,17 @@
#include "gimpconfig-utils.h"
/**
* gimp_config_diff:
* @a: a #GObject
* @b: another #GObject of the same type as @a
* @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.
*
* Return value: a GList of differing GParamSpecs.
**/
GList *
gimp_config_diff (GObject *a,
GObject *b,
@ -74,6 +85,71 @@ gimp_config_diff (GObject *a,
return g_list_reverse (list);
}
static void
gimp_config_connect_notify (GObject *src,
GParamSpec *param_spec,
GObject *dest)
{
GValue value = { 0, };
g_value_init (&value, param_spec->value_type);
g_object_get_property (src, param_spec->name, &value);
g_object_set_property (dest, param_spec->name, &value);
g_value_unset (&value);
}
/**
* gimp_config_connect:
* @src: a #GObject
* @dest: another #GObject of the same type as @src
*
* Connects @dest with @src so that all property changes of @src are
* applied to @dest using a "notify" handler.
**/
void
gimp_config_connect (GObject *src,
GObject *dest)
{
g_return_if_fail (G_IS_OBJECT (src));
g_return_if_fail (G_IS_OBJECT (dest));
g_return_if_fail (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest));
g_signal_connect_object (src, "notify",
G_CALLBACK (gimp_config_connect_notify),
dest, 0);
}
/**
* gimp_config_disconnect:
* @src: a #GObject
* @dest: another #GObject of the same type as @src
*
* Removes a connection between @dest and @src that was previously set
* up using gimp_config_connect().
**/
void
gimp_config_disconnect (GObject *src,
GObject *dest)
{
g_return_if_fail (G_IS_OBJECT (src));
g_return_if_fail (G_IS_OBJECT (dest));
g_signal_handlers_disconnect_by_func (src,
G_CALLBACK (gimp_config_connect_notify),
dest);
}
/**
* gimp_config_copy_properties:
* @src: a #GObject
* @dest: another #GObject of the same type as @src
*
* Retrieves all read and writeable property settings from @src and
* applies the values to @dest.
**/
void
gimp_config_copy_properties (GObject *src,
GObject *dest)
@ -117,6 +193,13 @@ gimp_config_copy_properties (GObject *src,
g_free (property_specs);
}
/**
* gimp_config_reset_properties:
* @object: a #GObject
*
* Resets all writable properties of @object to the default values as
* defined in their #GParamSpec.
**/
void
gimp_config_reset_properties (GObject *object)
{
@ -158,6 +241,10 @@ gimp_config_reset_properties (GObject *object)
}
/*
* GimpConfig path utilities
*/
gchar *
gimp_config_build_data_path (const gchar *name)
{

View file

@ -26,6 +26,10 @@
GList * gimp_config_diff (GObject *a,
GObject *b,
GParamFlags flags);
void gimp_config_connect (GObject *src,
GObject *dest);
void gimp_config_disconnect (GObject *src,
GObject *dest);
void gimp_config_copy_properties (GObject *src,
GObject *dest);
void gimp_config_reset_properties (GObject *object);

View file

@ -295,21 +295,6 @@ text_tool_create_layer (GimpTextTool *text_tool)
gimp_image_flush (gimage);
}
static void
gimp_text_tool_notify (GObject *tool,
GParamSpec *param_spec,
GObject *text)
{
GValue value = { 0, };
g_value_init (&value, param_spec->value_type);
g_object_get_property (tool, param_spec->name, &value);
g_object_set_property (text, param_spec->name, &value);
g_value_unset (&value);
}
static void
gimp_text_tool_connect (GimpTextTool *tool,
GimpText *text)
@ -323,9 +308,8 @@ gimp_text_tool_connect (GimpTextTool *tool,
if (tool->text)
{
g_signal_handlers_disconnect_by_func (options->text,
gimp_text_tool_notify,
tool->text);
gimp_config_disconnect (G_OBJECT (options->text),
G_OBJECT (tool->text));
g_object_unref (tool->text);
tool->text = NULL;
@ -338,9 +322,8 @@ gimp_text_tool_connect (GimpTextTool *tool,
gimp_config_copy_properties (G_OBJECT (tool->text),
G_OBJECT (options->text));
g_signal_connect (options->text, "notify",
G_CALLBACK (gimp_text_tool_notify),
tool->text);
gimp_config_connect (G_OBJECT (options->text),
G_OBJECT (tool->text));
}
}

View file

@ -1,3 +1,7 @@
2003-02-10 Sven Neumann <sven@gimp.org>
* libgimp/tmpl/gimpenums.sgml: regenerated.
2003-02-06 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-docs.sgml

View file

@ -274,9 +274,9 @@ Enums and definitions.
</para>
@GIMP_HORIZONTAL:
@GIMP_VERTICAL:
@GIMP_UNKNOWN:
@GIMP_ORIENTATION_HORIZONTAL:
@GIMP_ORIENTATION_VERTICAL:
@GIMP_ORIENTATION_UNKNOWN:
<!-- ##### ENUM GimpPaintApplicationMode ##### -->
<para>

View file

@ -30,6 +30,17 @@
#include "gimpconfig-utils.h"
/**
* gimp_config_diff:
* @a: a #GObject
* @b: another #GObject of the same type as @a
* @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.
*
* Return value: a GList of differing GParamSpecs.
**/
GList *
gimp_config_diff (GObject *a,
GObject *b,
@ -74,6 +85,71 @@ gimp_config_diff (GObject *a,
return g_list_reverse (list);
}
static void
gimp_config_connect_notify (GObject *src,
GParamSpec *param_spec,
GObject *dest)
{
GValue value = { 0, };
g_value_init (&value, param_spec->value_type);
g_object_get_property (src, param_spec->name, &value);
g_object_set_property (dest, param_spec->name, &value);
g_value_unset (&value);
}
/**
* gimp_config_connect:
* @src: a #GObject
* @dest: another #GObject of the same type as @src
*
* Connects @dest with @src so that all property changes of @src are
* applied to @dest using a "notify" handler.
**/
void
gimp_config_connect (GObject *src,
GObject *dest)
{
g_return_if_fail (G_IS_OBJECT (src));
g_return_if_fail (G_IS_OBJECT (dest));
g_return_if_fail (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest));
g_signal_connect_object (src, "notify",
G_CALLBACK (gimp_config_connect_notify),
dest, 0);
}
/**
* gimp_config_disconnect:
* @src: a #GObject
* @dest: another #GObject of the same type as @src
*
* Removes a connection between @dest and @src that was previously set
* up using gimp_config_connect().
**/
void
gimp_config_disconnect (GObject *src,
GObject *dest)
{
g_return_if_fail (G_IS_OBJECT (src));
g_return_if_fail (G_IS_OBJECT (dest));
g_signal_handlers_disconnect_by_func (src,
G_CALLBACK (gimp_config_connect_notify),
dest);
}
/**
* gimp_config_copy_properties:
* @src: a #GObject
* @dest: another #GObject of the same type as @src
*
* Retrieves all read and writeable property settings from @src and
* applies the values to @dest.
**/
void
gimp_config_copy_properties (GObject *src,
GObject *dest)
@ -117,6 +193,13 @@ gimp_config_copy_properties (GObject *src,
g_free (property_specs);
}
/**
* gimp_config_reset_properties:
* @object: a #GObject
*
* Resets all writable properties of @object to the default values as
* defined in their #GParamSpec.
**/
void
gimp_config_reset_properties (GObject *object)
{
@ -158,6 +241,10 @@ gimp_config_reset_properties (GObject *object)
}
/*
* GimpConfig path utilities
*/
gchar *
gimp_config_build_data_path (const gchar *name)
{

View file

@ -26,6 +26,10 @@
GList * gimp_config_diff (GObject *a,
GObject *b,
GParamFlags flags);
void gimp_config_connect (GObject *src,
GObject *dest);
void gimp_config_disconnect (GObject *src,
GObject *dest);
void gimp_config_copy_properties (GObject *src,
GObject *dest);
void gimp_config_reset_properties (GObject *object);