Commit caad58d2 authored by Michael Natterer's avatar Michael Natterer 😴

app: add a GimpContext parameter to GimpDataLoadFunc

parent 4fcf3469
......@@ -278,7 +278,8 @@ data_refresh_cmd_callback (GtkAction *action,
return_if_no_gimp (gimp, user_data);
gimp_set_busy (gimp);
gimp_data_factory_data_refresh (gimp_data_factory_view_get_data_factory (view));
gimp_data_factory_data_refresh (gimp_data_factory_view_get_data_factory (view),
action_data_get_context (user_data));
gimp_unset_busy (gimp);
}
......
......@@ -949,23 +949,28 @@ gimp_restore (Gimp *gimp,
/* initialize the list of gimp brushes */
status_callback (NULL, _("Brushes"), 0.1);
gimp_data_factory_data_init (gimp->brush_factory, gimp->no_data);
gimp_data_factory_data_init (gimp->brush_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of gimp dynamics */
status_callback (NULL, _("Dynamics"), 0.2);
gimp_data_factory_data_init (gimp->dynamics_factory, gimp->no_data);
gimp_data_factory_data_init (gimp->dynamics_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of gimp patterns */
status_callback (NULL, _("Patterns"), 0.3);
gimp_data_factory_data_init (gimp->pattern_factory, gimp->no_data);
gimp_data_factory_data_init (gimp->pattern_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of gimp palettes */
status_callback (NULL, _("Palettes"), 0.4);
gimp_data_factory_data_init (gimp->palette_factory, gimp->no_data);
gimp_data_factory_data_init (gimp->palette_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of gimp gradients */
status_callback (NULL, _("Gradients"), 0.5);
gimp_data_factory_data_init (gimp->gradient_factory, gimp->no_data);
gimp_data_factory_data_init (gimp->gradient_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of fonts */
status_callback (NULL, _("Fonts (this may take a while)"), 0.6);
......@@ -974,7 +979,8 @@ gimp_restore (Gimp *gimp,
/* initialize the list of gimp tool presets */
status_callback (NULL, _("Tool Presets"), 0.65);
gimp_data_factory_data_init (gimp->tool_preset_factory, gimp->no_data);
gimp_data_factory_data_init (gimp->tool_preset_factory, gimp->user_context,
gimp->no_data);
/* initialize the template list */
status_callback (NULL, _("Templates"), 0.7);
......
......@@ -122,7 +122,8 @@ static gint32 abr_rle_decode (FILE *file,
/* public functions */
GList *
gimp_brush_load (const gchar *filename,
gimp_brush_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpBrush *brush;
......@@ -141,7 +142,7 @@ gimp_brush_load (const gchar *filename,
return NULL;
}
brush = gimp_brush_load_brush (fd, filename, error);
brush = gimp_brush_load_brush (context, fd, filename, error);
close (fd);
......@@ -152,7 +153,8 @@ gimp_brush_load (const gchar *filename,
}
GimpBrush *
gimp_brush_load_brush (gint fd,
gimp_brush_load_brush (GimpContext *context,
gint fd,
const gchar *filename,
GError **error)
{
......@@ -400,7 +402,8 @@ gimp_brush_load_brush (gint fd,
}
GList *
gimp_brush_load_abr (const gchar *filename,
gimp_brush_load_abr (GimpContext *context,
const gchar *filename,
GError **error)
{
FILE *file;
......
......@@ -25,13 +25,16 @@
#define GIMP_BRUSH_PSP_FILE_EXTENSION ".jbr"
GList * gimp_brush_load (const gchar *filename,
GList * gimp_brush_load (GimpContext *context,
const gchar *filename,
GError **error);
GimpBrush * gimp_brush_load_brush (gint fd,
GimpBrush * gimp_brush_load_brush (GimpContext *context,
gint fd,
const gchar *filename,
GError **error);
GList * gimp_brush_load_abr (const gchar *filename,
GList * gimp_brush_load_abr (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -43,7 +43,8 @@
GList *
gimp_brush_generated_load (const gchar *filename,
gimp_brush_generated_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpBrush *brush;
......
......@@ -24,7 +24,8 @@
#define GIMP_BRUSH_GENERATED_FILE_EXTENSION ".vbr"
GList * gimp_brush_generated_load (const gchar *filename,
GList * gimp_brush_generated_load (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -55,7 +55,8 @@
GList *
gimp_brush_pipe_load (const gchar *filename,
gimp_brush_pipe_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpBrushPipe *pipe = NULL;
......@@ -209,7 +210,8 @@ gimp_brush_pipe_load (const gchar *filename,
while (pipe->nbrushes < num_of_brushes)
{
pipe->brushes[pipe->nbrushes] = gimp_brush_load_brush (fd, filename, NULL);
pipe->brushes[pipe->nbrushes] = gimp_brush_load_brush (context,
fd, filename, NULL);
if (pipe->brushes[pipe->nbrushes])
{
......
......@@ -23,7 +23,8 @@
#define GIMP_BRUSH_PIPE_FILE_EXTENSION ".gih"
GList * gimp_brush_pipe_load (const gchar *filename,
GList * gimp_brush_pipe_load (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -74,6 +74,7 @@ struct _GimpDataFactoryPriv
static void gimp_data_factory_finalize (GObject *object);
static void gimp_data_factory_data_load (GimpDataFactory *factory,
GimpContext *context,
GHashTable *cache);
static gint64 gimp_data_factory_get_memsize (GimpObject *object,
......@@ -215,9 +216,11 @@ gimp_data_factory_new (Gimp *gimp,
void
gimp_data_factory_data_init (GimpDataFactory *factory,
GimpContext *context,
gboolean no_data)
{
g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
g_return_if_fail (GIMP_IS_CONTEXT (context));
/* Freeze and thaw the container even if no_data,
* this creates the standard data that serves as fallback.
......@@ -233,7 +236,7 @@ gimp_data_factory_data_init (GimpDataFactory *factory,
g_print ("Loading '%s' data\n", name ? name : "???");
}
gimp_data_factory_data_load (factory, NULL);
gimp_data_factory_data_load (factory, context, NULL);
}
gimp_container_thaw (factory->priv->container);
......@@ -304,11 +307,13 @@ gimp_data_factory_data_foreach (GimpDataFactory *factory,
typedef struct
{
GimpDataFactory *factory;
GimpContext *context;
GHashTable *cache;
} GimpDataLoadContext;
static void
gimp_data_factory_data_load (GimpDataFactory *factory,
GimpContext *context,
GHashTable *cache)
{
gchar *path;
......@@ -323,10 +328,11 @@ gimp_data_factory_data_load (GimpDataFactory *factory,
{
GList *writable_list = NULL;
gchar *tmp;
GimpDataLoadContext context;
GimpDataLoadContext load_context;
context.factory = factory;
context.cache = cache;
load_context.factory = factory;
load_context.context = context;
load_context.cache = cache;
tmp = gimp_config_path_expand (path, TRUE, NULL);
g_free (path);
......@@ -345,11 +351,12 @@ gimp_data_factory_data_load (GimpDataFactory *factory,
}
gimp_datafiles_read_directories (path, G_FILE_TEST_IS_REGULAR,
gimp_data_factory_load_data, &context);
gimp_data_factory_load_data,
&load_context);
gimp_datafiles_read_directories (path, G_FILE_TEST_IS_DIR,
gimp_data_factory_load_data_recursive,
&context);
&load_context);
if (writable_path)
{
......@@ -363,11 +370,13 @@ gimp_data_factory_data_load (GimpDataFactory *factory,
}
void
gimp_data_factory_data_refresh (GimpDataFactory *factory)
gimp_data_factory_data_refresh (GimpDataFactory *factory,
GimpContext *context)
{
GHashTable *cache;
g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
g_return_if_fail (GIMP_IS_CONTEXT (context));
gimp_container_freeze (factory->priv->container);
......@@ -387,7 +396,7 @@ gimp_data_factory_data_refresh (GimpDataFactory *factory)
* objects remaining there will be those that are not present on
* the disk (that have to be destroyed)
*/
gimp_data_factory_data_load (factory, cache);
gimp_data_factory_data_load (factory, context, cache);
/* Now all the data is loaded. Free what remains in the cache */
g_hash_table_foreach_remove (cache,
......@@ -832,7 +841,8 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
GList *data_list;
GError *error = NULL;
data_list = loader->load_func (file_data->filename, &error);
data_list = loader->load_func (context->context,
file_data->filename, &error);
if (G_LIKELY (data_list))
{
......
......@@ -27,7 +27,8 @@
typedef GimpData * (* GimpDataNewFunc) (GimpContext *context,
const gchar *name);
typedef GList * (* GimpDataLoadFunc) (const gchar *filename,
typedef GList * (* GimpDataLoadFunc) (GimpContext *context,
const gchar *filename,
GError **error);
typedef GimpData * (* GimpDataGetStandardFunc) (GimpContext *context);
......@@ -78,8 +79,10 @@ GimpDataFactory * gimp_data_factory_new (Gimp *
GimpDataGetStandardFunc get_standard_func);
void gimp_data_factory_data_init (GimpDataFactory *factory,
GimpContext *context,
gboolean no_data);
void gimp_data_factory_data_refresh (GimpDataFactory *factory);
void gimp_data_factory_data_refresh (GimpDataFactory *factory,
GimpContext *context);
void gimp_data_factory_data_save (GimpDataFactory *factory);
void gimp_data_factory_data_free (GimpDataFactory *factory);
......
......@@ -28,7 +28,8 @@
GList *
gimp_dynamics_load (const gchar *filename,
gimp_dynamics_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpDynamics *dynamics;
......
......@@ -22,7 +22,8 @@
#define GIMP_DYNAMICS_FILE_EXTENSION ".gdyn"
GList * gimp_dynamics_load (const gchar *filename,
GList * gimp_dynamics_load (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -38,7 +38,8 @@
GList *
gimp_gradient_load (const gchar *filename,
gimp_gradient_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpGradient *gradient;
......@@ -310,7 +311,8 @@ static const GMarkupParser markup_parser =
GList *
gimp_gradient_load_svg (const gchar *filename,
gimp_gradient_load_svg (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpXmlParser *xml_parser;
......
......@@ -23,9 +23,11 @@
#define GIMP_GRADIENT_SVG_FILE_EXTENSION ".svg"
GList * gimp_gradient_load (const gchar *filename,
GList * gimp_gradient_load (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_gradient_load_svg (const gchar *filename,
GList * gimp_gradient_load_svg (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -518,7 +518,7 @@ gimp_palette_import_from_file (GimpContext *context,
switch (gimp_palette_load_detect_format (filename))
{
case GIMP_PALETTE_FILE_FORMAT_GPL:
palette_list = gimp_palette_load (filename, error);
palette_list = gimp_palette_load (context, filename, error);
break;
case GIMP_PALETTE_FILE_FORMAT_ACT:
......
......@@ -50,7 +50,8 @@
GList *
gimp_palette_load (const gchar *filename,
gimp_palette_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPalette *palette;
......
......@@ -34,7 +34,8 @@ typedef enum
} GimpPaletteFileFormat;
GList * gimp_palette_load (const gchar *filename,
GList * gimp_palette_load (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_palette_load_act (GimpContext *context,
const gchar *filename,
......
......@@ -55,7 +55,8 @@
GList *
gimp_pattern_load (const gchar *filename,
gimp_pattern_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPattern *pattern = NULL;
......@@ -178,7 +179,8 @@ gimp_pattern_load (const gchar *filename,
}
GList *
gimp_pattern_load_pixbuf (const gchar *filename,
gimp_pattern_load_pixbuf (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPattern *pattern;
......
......@@ -22,9 +22,11 @@
#define GIMP_PATTERN_FILE_EXTENSION ".pat"
GList * gimp_pattern_load (const gchar *filename,
GList * gimp_pattern_load (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_pattern_load_pixbuf (const gchar *filename,
GList * gimp_pattern_load_pixbuf (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -23,16 +23,19 @@
#include "core-types.h"
#include "gimpcontext.h"
#include "gimptoolpreset.h"
#include "gimptoolpreset-load.h"
GList *
gimp_tool_preset_load (const gchar *filename,
gimp_tool_preset_load (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpToolPreset *tool_preset;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
......
......@@ -22,7 +22,8 @@
#define GIMP_TOOL_PRESET_FILE_EXTENSION ".gtp"
GList * gimp_tool_preset_load (const gchar *filename,
GList * gimp_tool_preset_load (GimpContext *context,
const gchar *filename,
GError **error);
......
......@@ -47,7 +47,7 @@ brushes_refresh_invoker (GimpProcedure *procedure,
const GValueArray *args,
GError **error)
{
gimp_data_factory_data_refresh (gimp->brush_factory);
gimp_data_factory_data_refresh (gimp->brush_factory, context);
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
}
......
......@@ -46,7 +46,7 @@ gradients_refresh_invoker (GimpProcedure *procedure,
const GValueArray *args,
GError **error)
{
gimp_data_factory_data_refresh (gimp->gradient_factory);
gimp_data_factory_data_refresh (gimp->gradient_factory, context);
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
}
......
......@@ -48,7 +48,7 @@ palettes_refresh_invoker (GimpProcedure *procedure,
const GValueArray *args,
GError **error)
{
gimp_data_factory_data_refresh (gimp->palette_factory);
gimp_data_factory_data_refresh (gimp->palette_factory, context);
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
}
......
......@@ -47,7 +47,7 @@ patterns_refresh_invoker (GimpProcedure *procedure,
const GValueArray *args,
GError **error)
{
gimp_data_factory_data_refresh (gimp->pattern_factory);
gimp_data_factory_data_refresh (gimp->pattern_factory, context);
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
}
......
......@@ -29,7 +29,7 @@ HELP
%invoke = (
code => <<'CODE'
{
gimp_data_factory_data_refresh (gimp->brush_factory);
gimp_data_factory_data_refresh (gimp->brush_factory, context);
}
CODE
);
......
......@@ -29,7 +29,7 @@ HELP
%invoke = (
code => <<'CODE'
{
gimp_data_factory_data_refresh (gimp->gradient_factory);
gimp_data_factory_data_refresh (gimp->gradient_factory, context);
}
CODE
);
......
......@@ -29,7 +29,7 @@ HELP
%invoke = (
code => <<'CODE'
{
gimp_data_factory_data_refresh (gimp->palette_factory);
gimp_data_factory_data_refresh (gimp->palette_factory, context);
}
CODE
);
......
......@@ -29,7 +29,7 @@ HELP
%invoke = (
code => <<'CODE'
{
gimp_data_factory_data_refresh (gimp->pattern_factory);
gimp_data_factory_data_refresh (gimp->pattern_factory, context);
}
CODE
);
......
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