Commit 5f8643a6 authored by Ell's avatar Ell

libgimpconfig: align GimpConfig with the rest of the interfaces

Unlike the last two commits, we don't port GimpConfig to
G_DEFINE_INTERFACE(), since we need to provide a base initializer
for it.  However, this commit aligns it with the rest of our
intefaces, by renaming gimp_config_interface_get_type() to
gimp_config_get_type(), and by performing class initialization for
the interface in a separate function than base initialization.

Keep gimp_config_interface_get_type() around as a deprecated
function, to maintain ABI compatibility.  It will be removed in a
separate commit in master, so that this commit can be easily
cherry-picked to gimp-2-10.
parent 6b40c7f3
......@@ -53,26 +53,33 @@
* The GimpConfig serialization and deserialization interface.
*/
static void gimp_config_iface_base_init (GimpConfigInterface *config_iface);
static gboolean gimp_config_iface_serialize (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data);
static gboolean gimp_config_iface_deserialize (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
static GimpConfig * gimp_config_iface_duplicate (GimpConfig *config);
static gboolean gimp_config_iface_equal (GimpConfig *a,
GimpConfig *b);
static void gimp_config_iface_reset (GimpConfig *config);
static gboolean gimp_config_iface_copy (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags);
/* local function prototypes */
static void gimp_config_iface_default_init (GimpConfigInterface *iface);
static void gimp_config_iface_base_init (GimpConfigInterface *iface);
static gboolean gimp_config_iface_serialize (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data);
static gboolean gimp_config_iface_deserialize (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
static GimpConfig * gimp_config_iface_duplicate (GimpConfig *config);
static gboolean gimp_config_iface_equal (GimpConfig *a,
GimpConfig *b);
static void gimp_config_iface_reset (GimpConfig *config);
static gboolean gimp_config_iface_copy (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags);
/* private functions */
GType
gimp_config_interface_get_type (void)
gimp_config_get_type (void)
{
static GType config_iface_type = 0;
......@@ -81,8 +88,10 @@ gimp_config_interface_get_type (void)
const GTypeInfo config_iface_info =
{
sizeof (GimpConfigInterface),
(GBaseInitFunc) gimp_config_iface_base_init,
(GBaseFinalizeFunc) NULL,
(GBaseInitFunc) gimp_config_iface_base_init,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_config_iface_default_init,
(GClassFinalizeFunc) NULL,
};
config_iface_type = g_type_register_static (G_TYPE_INTERFACE,
......@@ -96,24 +105,31 @@ gimp_config_interface_get_type (void)
return config_iface_type;
}
GType
gimp_config_interface_get_type (void)
{
return gimp_config_get_type ();
}
static void
gimp_config_iface_base_init (GimpConfigInterface *config_iface)
gimp_config_iface_default_init (GimpConfigInterface *iface)
{
if (! config_iface->serialize)
{
config_iface->serialize = gimp_config_iface_serialize;
config_iface->deserialize = gimp_config_iface_deserialize;
config_iface->duplicate = gimp_config_iface_duplicate;
config_iface->equal = gimp_config_iface_equal;
config_iface->reset = gimp_config_iface_reset;
config_iface->copy = gimp_config_iface_copy;
}
iface->serialize = gimp_config_iface_serialize;
iface->deserialize = gimp_config_iface_deserialize;
iface->duplicate = gimp_config_iface_duplicate;
iface->equal = gimp_config_iface_equal;
iface->reset = gimp_config_iface_reset;
iface->copy = gimp_config_iface_copy;
}
static void
gimp_config_iface_base_init (GimpConfigInterface *iface)
{
/* always set these to NULL since we don't want to inherit them
* from parent classes
*/
config_iface->serialize_property = NULL;
config_iface->deserialize_property = NULL;
iface->serialize_property = NULL;
iface->deserialize_property = NULL;
}
static gboolean
......@@ -260,6 +276,10 @@ gimp_config_iface_copy (GimpConfig *src,
return gimp_config_sync (G_OBJECT (src), G_OBJECT (dest), flags);
}
/* public functions */
/**
* gimp_config_serialize_to_file:
* @config: a #GObject that implements the #GimpConfigInterface.
......
......@@ -31,7 +31,7 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define GIMP_TYPE_CONFIG (gimp_config_interface_get_type ())
#define GIMP_TYPE_CONFIG (gimp_config_get_type ())
#define GIMP_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONFIG))
#define GIMP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONFIG, GimpConfig))
#define GIMP_CONFIG_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_CONFIG, GimpConfigInterface))
......@@ -71,66 +71,69 @@ struct _GimpConfigInterface
};
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize_to_file (GimpConfig *config,
const gchar *filename,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_gfile (GimpConfig *config,
GFile *file,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_stream (GimpConfig *config,
GOutputStream *output,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_fd (GimpConfig *config,
gint fd,
gpointer data);
gchar * gimp_config_serialize_to_string (GimpConfig *config,
gpointer data);
gboolean gimp_config_deserialize_file (GimpConfig *config,
const gchar *filename,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_gfile (GimpConfig *config,
GFile *file,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_stream (GimpConfig *config,
GInputStream *input,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_string (GimpConfig *config,
const gchar *text,
gint text_len,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_return (GScanner *scanner,
GTokenType expected_token,
gint nest_level);
gboolean gimp_config_serialize (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data);
gboolean gimp_config_deserialize (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
gpointer gimp_config_duplicate (GimpConfig *config);
gboolean gimp_config_is_equal_to (GimpConfig *a,
GimpConfig *b);
void gimp_config_reset (GimpConfig *config);
gboolean gimp_config_copy (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags);
GType gimp_config_get_type (void) G_GNUC_CONST;
GIMP_DEPRECATED_FOR (gimp_config_get_type)
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize_to_file (GimpConfig *config,
const gchar *filename,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_gfile (GimpConfig *config,
GFile *file,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_stream (GimpConfig *config,
GOutputStream *output,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_fd (GimpConfig *config,
gint fd,
gpointer data);
gchar * gimp_config_serialize_to_string (GimpConfig *config,
gpointer data);
gboolean gimp_config_deserialize_file (GimpConfig *config,
const gchar *filename,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_gfile (GimpConfig *config,
GFile *file,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_stream (GimpConfig *config,
GInputStream *input,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_string (GimpConfig *config,
const gchar *text,
gint text_len,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_return (GScanner *scanner,
GTokenType expected_token,
gint nest_level);
gboolean gimp_config_serialize (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data);
gboolean gimp_config_deserialize (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
gpointer gimp_config_duplicate (GimpConfig *config);
gboolean gimp_config_is_equal_to (GimpConfig *a,
GimpConfig *b);
void gimp_config_reset (GimpConfig *config);
gboolean gimp_config_copy (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags);
G_END_DECLS
......
......@@ -32,6 +32,7 @@ EXPORTS
gimp_config_diff
gimp_config_duplicate
gimp_config_error_quark
gimp_config_get_type
gimp_config_interface_get_type
gimp_config_is_equal_to
gimp_config_path_expand
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment