Commit 3d0c025a authored by Martin Nordholts's avatar Martin Nordholts

app: Support obsolete data resources

Add support for having obsolete data resources. An obsolete resource
is not shown in the UI or managed in any way, but it will be
considered when plug-ins requests resources. This in order to maintain
backwards compatibility for plug-ins.
parent 4df574ac
......@@ -42,12 +42,19 @@
#define WRITABLE_PATH_KEY "gimp-data-factory-writable-path"
/* Data files that have this string in their path are considered
* obsolete and are only kept around for backwards compatibility
*/
#define GIMP_OBSOLETE_DATA_DIR_NAME "gimp-obsolete-files"
struct _GimpDataFactoryPriv
{
Gimp *gimp;
GimpContainer *container;
GimpContainer *container_obsolete;
gchar *path_property_name;
gchar *writable_property_name;
......@@ -102,6 +109,7 @@ gimp_data_factory_init (GimpDataFactory *factory)
factory->priv->gimp = NULL;
factory->priv->container = NULL;
factory->priv->container_obsolete = NULL;
factory->priv->path_property_name = NULL;
factory->priv->writable_property_name = NULL;
factory->priv->loader_entries = NULL;
......@@ -121,6 +129,12 @@ gimp_data_factory_finalize (GObject *object)
factory->priv->container = NULL;
}
if (factory->priv->container_obsolete)
{
g_object_unref (factory->priv->container_obsolete);
factory->priv->container_obsolete = NULL;
}
if (factory->priv->path_property_name)
{
g_free (factory->priv->path_property_name);
......@@ -145,6 +159,8 @@ gimp_data_factory_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (factory->priv->container),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (factory->priv->container_obsolete),
gui_size);
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
......@@ -175,6 +191,9 @@ gimp_data_factory_new (Gimp *gimp,
factory->priv->container = gimp_list_new (data_type, TRUE);
gimp_list_set_sort_func (GIMP_LIST (factory->priv->container),
(GCompareFunc) gimp_data_compare);
factory->priv->container_obsolete = gimp_list_new (data_type, TRUE);
gimp_list_set_sort_func (GIMP_LIST (factory->priv->container_obsolete),
(GCompareFunc) gimp_data_compare);
factory->priv->path_property_name = g_strdup (path_property_name);
factory->priv->writable_property_name = g_strdup (writable_property_name);
......@@ -630,6 +649,14 @@ gimp_data_factory_get_container (GimpDataFactory *factory)
return factory->priv->container;
}
GimpContainer *
gimp_data_factory_get_container_obsolete (GimpDataFactory *factory)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
return factory->priv->container_obsolete;
}
Gimp *
gimp_data_factory_get_gimp (GimpDataFactory *factory)
{
......@@ -783,7 +810,13 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
data->mtime = file_data->mtime;
data->dirty = FALSE;
gimp_container_add (factory->priv->container, GIMP_OBJECT (data));
if (strstr (file_data->dirname, GIMP_OBSOLETE_DATA_DIR_NAME))
gimp_container_add (factory->priv->container_obsolete,
GIMP_OBJECT (data));
else
gimp_container_add (factory->priv->container,
GIMP_OBJECT (data));
g_object_unref (data);
}
......
......@@ -95,6 +95,8 @@ gboolean gimp_data_factory_data_save_single (GimpDataFactory *factory,
GimpData *data,
GError **error);
GimpContainer * gimp_data_factory_get_container (GimpDataFactory *factory);
GimpContainer * gimp_data_factory_get_container_obsolete
(GimpDataFactory *factory);
Gimp * gimp_data_factory_get_gimp (GimpDataFactory *factory);
gboolean gimp_data_factory_has_data_new_func (GimpDataFactory *factory);
......
......@@ -41,6 +41,21 @@
#include "gimp-intl.h"
static GimpObject *
gimp_pdb_get_data_factory_item (GimpDataFactory *data_factory,
const gchar *name)
{
GimpObject *gimp_object;
gimp_object = gimp_container_get_child_by_name (gimp_data_factory_get_container (data_factory), name);
if (! gimp_object)
gimp_object = gimp_container_get_child_by_name (gimp_data_factory_get_container_obsolete (data_factory), name);
return gimp_object;
}
GimpBrush *
gimp_pdb_get_brush (Gimp *gimp,
const gchar *name,
......@@ -59,8 +74,7 @@ gimp_pdb_get_brush (Gimp *gimp,
return NULL;
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp_data_factory_get_container (gimp->brush_factory), name);
brush = (GimpBrush *) gimp_pdb_get_data_factory_item (gimp->brush_factory, name);
if (! brush)
{
......@@ -120,8 +134,7 @@ gimp_pdb_get_pattern (Gimp *gimp,
return NULL;
}
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp_data_factory_get_container (gimp->pattern_factory), name);
pattern = (GimpPattern *) gimp_pdb_get_data_factory_item (gimp->pattern_factory, name);
if (! pattern)
{
......@@ -150,8 +163,7 @@ gimp_pdb_get_gradient (Gimp *gimp,
return NULL;
}
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp_data_factory_get_container (gimp->gradient_factory), name);
gradient = (GimpGradient *) gimp_pdb_get_data_factory_item (gimp->gradient_factory, name);
if (! gradient)
{
......@@ -186,8 +198,7 @@ gimp_pdb_get_palette (Gimp *gimp,
return NULL;
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp_data_factory_get_container (gimp->palette_factory), name);
palette = (GimpPalette *) gimp_pdb_get_data_factory_item (gimp->palette_factory, name);
if (! palette)
{
......
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