mirror of https://github.com/GNOME/gimp.git
libgimpconfig: add function which (de)desialize from/to a GimpParasite
This commit is contained in:
parent
3c1871680c
commit
82b11c361a
|
@ -457,6 +457,46 @@ gimp_config_serialize_to_string (GimpConfig *config,
|
||||||
return g_string_free (str, FALSE);
|
return g_string_free (str, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_config_serialize_to_parasite:
|
||||||
|
* @config: a #GObject that implements the #GimpConfigInterface.
|
||||||
|
* @parasite_name: the new parasite's name
|
||||||
|
* @pparasite_flags: the new parasite's flags
|
||||||
|
* @data: user data passed to the serialize implementation.
|
||||||
|
*
|
||||||
|
* Serializes the object properties of @config to a #GimpParasite.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): the newly allocated #GimpParasite.
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
GimpParasite *
|
||||||
|
gimp_config_serialize_to_parasite (GimpConfig *config,
|
||||||
|
const gchar *parasite_name,
|
||||||
|
guint parasite_flags,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GimpParasite *parasite;
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
|
||||||
|
g_return_val_if_fail (parasite_name != NULL, NULL);
|
||||||
|
|
||||||
|
str = gimp_config_serialize_to_string (config, data);
|
||||||
|
|
||||||
|
if (! str)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
parasite = gimp_parasite_new (parasite_name,
|
||||||
|
parasite_flags,
|
||||||
|
0, NULL);
|
||||||
|
|
||||||
|
parasite->size = strlen (str) + 1;
|
||||||
|
parasite->data = str;
|
||||||
|
|
||||||
|
return parasite;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_config_deserialize_file:
|
* gimp_config_deserialize_file:
|
||||||
* @config: a #GObject that implements the #GimpConfigInterface.
|
* @config: a #GObject that implements the #GimpConfigInterface.
|
||||||
|
@ -618,7 +658,7 @@ gimp_config_deserialize_stream (GimpConfig *config,
|
||||||
* Since: 2.4
|
* Since: 2.4
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
gimp_config_deserialize_string (GimpConfig *config,
|
gimp_config_deserialize_string (GimpConfig *config,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gint text_len,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
|
@ -648,6 +688,41 @@ gimp_config_deserialize_string (GimpConfig *config,
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_config_deserialize_parasite:
|
||||||
|
* @config: a #GObject that implements the #GimpConfigInterface.
|
||||||
|
* @parasite: parasite containing a serialized config string
|
||||||
|
* @data: client data
|
||||||
|
* @error: return location for a possible error
|
||||||
|
*
|
||||||
|
* Configures @config from @parasite. Basically this function creates
|
||||||
|
* a properly configured #GScanner for you and calls the deserialize
|
||||||
|
* function of the @config's #GimpConfigInterface.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if deserialization succeeded, %FALSE otherwise.
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
gimp_config_deserialize_parasite (GimpConfig *config,
|
||||||
|
const GimpParasite *parasite,
|
||||||
|
gpointer data,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
|
||||||
|
g_return_val_if_fail (parasite != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
if (! gimp_parasite_data (parasite))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return gimp_config_deserialize_string (config,
|
||||||
|
gimp_parasite_data (parasite),
|
||||||
|
gimp_parasite_data_size (parasite),
|
||||||
|
data,
|
||||||
|
error);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_config_deserialize_return:
|
* gimp_config_deserialize_return:
|
||||||
* @scanner: a #GScanner
|
* @scanner: a #GScanner
|
||||||
|
|
|
@ -71,66 +71,77 @@ struct _GimpConfigInterface
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GType gimp_config_get_type (void) G_GNUC_CONST;
|
GType gimp_config_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
gboolean gimp_config_serialize_to_file (GimpConfig *config,
|
gboolean gimp_config_serialize_to_file (GimpConfig *config,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
const gchar *header,
|
const gchar *header,
|
||||||
const gchar *footer,
|
const gchar *footer,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean gimp_config_serialize_to_gfile (GimpConfig *config,
|
gboolean gimp_config_serialize_to_gfile (GimpConfig *config,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
const gchar *header,
|
const gchar *header,
|
||||||
const gchar *footer,
|
const gchar *footer,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean gimp_config_serialize_to_stream (GimpConfig *config,
|
gboolean gimp_config_serialize_to_stream (GimpConfig *config,
|
||||||
GOutputStream *output,
|
GOutputStream *output,
|
||||||
const gchar *header,
|
const gchar *header,
|
||||||
const gchar *footer,
|
const gchar *footer,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean gimp_config_serialize_to_fd (GimpConfig *config,
|
gboolean gimp_config_serialize_to_fd (GimpConfig *config,
|
||||||
gint fd,
|
gint fd,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
gchar * gimp_config_serialize_to_string (GimpConfig *config,
|
gchar * gimp_config_serialize_to_string (GimpConfig *config,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
gboolean gimp_config_deserialize_file (GimpConfig *config,
|
GimpParasite *
|
||||||
const gchar *filename,
|
gimp_config_serialize_to_parasite (GimpConfig *config,
|
||||||
gpointer data,
|
const gchar *parasite_name,
|
||||||
GError **error);
|
guint parasite_flags,
|
||||||
gboolean gimp_config_deserialize_gfile (GimpConfig *config,
|
gpointer data);
|
||||||
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,
|
gboolean gimp_config_deserialize_file (GimpConfig *config,
|
||||||
GimpConfigWriter *writer,
|
const gchar *filename,
|
||||||
gpointer data);
|
gpointer data,
|
||||||
gboolean gimp_config_deserialize (GimpConfig *config,
|
GError **error);
|
||||||
GScanner *scanner,
|
gboolean gimp_config_deserialize_gfile (GimpConfig *config,
|
||||||
gint nest_level,
|
GFile *file,
|
||||||
gpointer data);
|
gpointer data,
|
||||||
gpointer gimp_config_duplicate (GimpConfig *config);
|
GError **error);
|
||||||
gboolean gimp_config_is_equal_to (GimpConfig *a,
|
gboolean gimp_config_deserialize_stream (GimpConfig *config,
|
||||||
GimpConfig *b);
|
GInputStream *input,
|
||||||
void gimp_config_reset (GimpConfig *config);
|
gpointer data,
|
||||||
gboolean gimp_config_copy (GimpConfig *src,
|
GError **error);
|
||||||
GimpConfig *dest,
|
gboolean gimp_config_deserialize_string (GimpConfig *config,
|
||||||
GParamFlags flags);
|
const gchar *text,
|
||||||
|
gint text_len,
|
||||||
|
gpointer data,
|
||||||
|
GError **error);
|
||||||
|
gboolean gimp_config_deserialize_parasite (GimpConfig *config,
|
||||||
|
const GimpParasite *parasite,
|
||||||
|
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
|
G_END_DECLS
|
||||||
|
|
|
@ -25,6 +25,7 @@ EXPORTS
|
||||||
gimp_config_deserialize
|
gimp_config_deserialize
|
||||||
gimp_config_deserialize_file
|
gimp_config_deserialize_file
|
||||||
gimp_config_deserialize_gfile
|
gimp_config_deserialize_gfile
|
||||||
|
gimp_config_deserialize_parasite
|
||||||
gimp_config_deserialize_properties
|
gimp_config_deserialize_properties
|
||||||
gimp_config_deserialize_property
|
gimp_config_deserialize_property
|
||||||
gimp_config_deserialize_return
|
gimp_config_deserialize_return
|
||||||
|
@ -51,6 +52,7 @@ EXPORTS
|
||||||
gimp_config_serialize_to_fd
|
gimp_config_serialize_to_fd
|
||||||
gimp_config_serialize_to_file
|
gimp_config_serialize_to_file
|
||||||
gimp_config_serialize_to_gfile
|
gimp_config_serialize_to_gfile
|
||||||
|
gimp_config_serialize_to_parasite
|
||||||
gimp_config_serialize_to_stream
|
gimp_config_serialize_to_stream
|
||||||
gimp_config_serialize_to_string
|
gimp_config_serialize_to_string
|
||||||
gimp_config_serialize_value
|
gimp_config_serialize_value
|
||||||
|
|
Loading…
Reference in New Issue