app: add gimp_data_factory_get_data_path[_writable]()

which return GLists of GFiles. Use the new API in GimpDataFactory's
default implementations.
This commit is contained in:
Michael Natterer 2018-06-03 20:42:21 +02:00
parent 4ab0891be2
commit 68cf2641f8
2 changed files with 53 additions and 24 deletions

View File

@ -882,6 +882,50 @@ gimp_data_factory_has_data_new_func (GimpDataFactory *factory)
return factory->priv->data_new_func != NULL;
}
GList *
gimp_data_factory_get_data_path (GimpDataFactory *factory)
{
GimpDataFactoryPrivate *priv = GET_PRIVATE (factory);
gchar *path = NULL;
GList *list = NULL;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_object_get (priv->gimp->config,
priv->path_property_name, &path,
NULL);
if (path)
{
list = gimp_config_path_expand_to_files (path, NULL);
g_free (path);
}
return list;
}
GList *
gimp_data_factory_get_data_path_writable (GimpDataFactory *factory)
{
GimpDataFactoryPrivate *priv = GET_PRIVATE (factory);
gchar *path = NULL;
GList *list = NULL;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_object_get (priv->gimp->config,
priv->writable_property_name, &path,
NULL);
if (path)
{
list = gimp_config_path_expand_to_files (path, NULL);
g_free (path);
}
return list;
}
/* private functions */
@ -928,22 +972,12 @@ gimp_data_factory_data_load (GimpDataFactory *factory,
GimpContext *context,
GHashTable *cache)
{
gchar *p;
gchar *wp;
GList *path;
GList *writable_path;
GList *list;
g_object_get (factory->priv->gimp->config,
factory->priv->path_property_name, &p,
factory->priv->writable_property_name, &wp,
NULL);
path = gimp_config_path_expand_to_files (p, NULL);
writable_path = gimp_config_path_expand_to_files (wp, NULL);
g_free (p);
g_free (wp);
path = gimp_data_factory_get_data_path (factory);
writable_path = gimp_data_factory_get_data_path_writable (factory);
for (list = path; list; list = g_list_next (list))
{
@ -967,22 +1001,12 @@ static GFile *
gimp_data_factory_get_save_dir (GimpDataFactory *factory,
GError **error)
{
gchar *p;
gchar *wp;
GList *path;
GList *writable_path;
GFile *writable_dir = NULL;
g_object_get (factory->priv->gimp->config,
factory->priv->path_property_name, &p,
factory->priv->writable_property_name, &wp,
NULL);
path = gimp_config_path_expand_to_files (p, NULL);
writable_path = gimp_config_path_expand_to_files (wp, NULL);
g_free (p);
g_free (wp);
path = gimp_data_factory_get_data_path (factory);
writable_path = gimp_data_factory_get_data_path_writable (factory);
if (writable_path)
{

View File

@ -126,6 +126,7 @@ GimpData * gimp_data_factory_data_get_standard (GimpDataFactory *factory,
gboolean gimp_data_factory_data_save_single (GimpDataFactory *factory,
GimpData *data,
GError **error);
GType gimp_data_factory_get_data_type (GimpDataFactory *factory);
GimpContainer * gimp_data_factory_get_container (GimpDataFactory *factory);
GimpContainer * gimp_data_factory_get_container_obsolete
@ -133,5 +134,9 @@ GimpContainer * gimp_data_factory_get_container_obsolete
Gimp * gimp_data_factory_get_gimp (GimpDataFactory *factory);
gboolean gimp_data_factory_has_data_new_func (GimpDataFactory *factory);
GList * gimp_data_factory_get_data_path (GimpDataFactory *factory);
GList * gimp_data_factory_get_data_path_writable
(GimpDataFactory *factory);
#endif /* __GIMP_DATA_FACTORY_H__ */