Commit 430b0e55 authored by Michael Natterer's avatar Michael Natterer 😴

app: add a GimpContext parameter to all functions which create GimpData

and pass a context whereever needed. Fix up gimp_tool_preset_new()
to actually make a copy of the context's active tool's options.
parent 9a1617ba
......@@ -121,13 +121,16 @@ data_new_cmd_callback (GtkAction *action,
if (gimp_data_factory_view_has_data_new_func (view))
{
GimpContext *context;
GimpData *data;
GimpDataFactory *factory;
GimpContext *context;
GimpData *data;
factory = gimp_data_factory_view_get_data_factory (view);
context =
gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
data = gimp_data_factory_data_new (gimp_data_factory_view_get_data_factory (view), _("Untitled"));
data = gimp_data_factory_data_new (factory, _("Untitled"), context);
if (data)
{
......
......@@ -114,7 +114,10 @@ gimp_gradients_add_gradient (Gimp *gimp,
const gchar *name,
const gchar *id)
{
GimpGradient *gradient = GIMP_GRADIENT (gimp_gradient_new (name));
GimpGradient *gradient;
gradient = GIMP_GRADIENT (gimp_gradient_new (name,
gimp_get_user_context (gimp)));
gimp_data_make_internal (GIMP_DATA (gradient), id);
......
......@@ -399,7 +399,8 @@ gimp_brush_get_checksum (GimpTagged *tagged)
/* public functions */
GimpData *
gimp_brush_new (const gchar *name)
gimp_brush_new (const gchar *name,
GimpContext *context)
{
g_return_val_if_fail (name != NULL, NULL);
......@@ -409,13 +410,13 @@ gimp_brush_new (const gchar *name)
}
GimpData *
gimp_brush_get_standard (void)
gimp_brush_get_standard (GimpContext *context)
{
static GimpData *standard_brush = NULL;
if (! standard_brush)
{
standard_brush = gimp_brush_new ("Standard");
standard_brush = gimp_brush_new ("Standard", context);
gimp_data_clean (standard_brush);
gimp_data_make_internal (standard_brush, "gimp-brush-standard");
......
......@@ -80,8 +80,9 @@ struct _GimpBrushClass
GType gimp_brush_get_type (void) G_GNUC_CONST;
GimpData * gimp_brush_new (const gchar *name);
GimpData * gimp_brush_get_standard (void);
GimpData * gimp_brush_new (const gchar *name,
GimpContext *context);
GimpData * gimp_brush_get_standard (GimpContext *context);
GimpBrush * gimp_brush_select_brush (GimpBrush *brush,
const GimpCoords *last_coords,
......
......@@ -2490,7 +2490,7 @@ gimp_context_brush_list_thaw (GimpContainer *container,
brush = gimp_context_find_object (context, container,
context->brush_name,
gimp_brush_get_standard ());
gimp_brush_get_standard (context));
gimp_context_real_set_brush (context, brush);
}
......@@ -2520,7 +2520,7 @@ gimp_context_real_set_brush (GimpContext *context,
GimpBrush *brush)
{
if (! standard_brush)
standard_brush = GIMP_BRUSH (gimp_brush_get_standard ());
standard_brush = GIMP_BRUSH (gimp_brush_get_standard (context));
if (context->brush == brush)
return;
......@@ -2630,7 +2630,7 @@ gimp_context_dynamics_list_thaw (GimpContainer *container,
dynamics = gimp_context_find_object (context, container,
context->dynamics_name,
gimp_dynamics_get_standard ());
gimp_dynamics_get_standard (context));
gimp_context_real_set_dynamics (context, dynamics);
}
......@@ -2641,7 +2641,7 @@ gimp_context_real_set_dynamics (GimpContext *context,
{
if (! standard_dynamics)
{
standard_dynamics = GIMP_DYNAMICS (gimp_dynamics_get_standard ());
standard_dynamics = GIMP_DYNAMICS (gimp_dynamics_get_standard (context));
}
if (context->dynamics == dynamics)
......@@ -2736,7 +2736,7 @@ gimp_context_pattern_list_thaw (GimpContainer *container,
pattern = gimp_context_find_object (context, container,
context->pattern_name,
gimp_pattern_get_standard ());
gimp_pattern_get_standard (context));
gimp_context_real_set_pattern (context, pattern);
}
......@@ -2766,7 +2766,7 @@ gimp_context_real_set_pattern (GimpContext *context,
GimpPattern *pattern)
{
if (! standard_pattern)
standard_pattern = GIMP_PATTERN (gimp_pattern_get_standard ());
standard_pattern = GIMP_PATTERN (gimp_pattern_get_standard (context));
if (context->pattern == pattern)
return;
......@@ -2858,7 +2858,7 @@ gimp_context_gradient_list_thaw (GimpContainer *container,
gradient = gimp_context_find_object (context, container,
context->gradient_name,
gimp_gradient_get_standard ());
gimp_gradient_get_standard (context));
gimp_context_real_set_gradient (context, gradient);
}
......@@ -2888,7 +2888,7 @@ gimp_context_real_set_gradient (GimpContext *context,
GimpGradient *gradient)
{
if (! standard_gradient)
standard_gradient = GIMP_GRADIENT (gimp_gradient_get_standard ());
standard_gradient = GIMP_GRADIENT (gimp_gradient_get_standard (context));
if (context->gradient == gradient)
return;
......@@ -2980,7 +2980,7 @@ gimp_context_palette_list_thaw (GimpContainer *container,
palette = gimp_context_find_object (context, container,
context->palette_name,
gimp_palette_get_standard ());
gimp_palette_get_standard (context));
gimp_context_real_set_palette (context, palette);
}
......@@ -3010,7 +3010,7 @@ gimp_context_real_set_palette (GimpContext *context,
GimpPalette *palette)
{
if (! standard_palette)
standard_palette = GIMP_PALETTE (gimp_palette_get_standard ());
standard_palette = GIMP_PALETTE (gimp_palette_get_standard (context));
if (context->palette == palette)
return;
......@@ -3120,7 +3120,7 @@ gimp_context_tool_preset_list_thaw (GimpContainer *container,
tool_preset = gimp_context_find_object (context, container,
context->tool_preset_name,
gimp_tool_preset_get_standard ());
gimp_tool_preset_get_standard (context));
gimp_context_real_set_tool_preset (context, tool_preset);
}
......@@ -3130,14 +3130,10 @@ gimp_context_real_set_tool_preset (GimpContext *context,
GimpToolPreset *tool_preset)
{
if (! standard_tool_preset)
{
standard_tool_preset = GIMP_TOOL_PRESET (gimp_tool_preset_get_standard ());
}
standard_tool_preset = GIMP_TOOL_PRESET (gimp_tool_preset_get_standard (context));
if (context->tool_preset == tool_preset)
{
return;
}
return;
if (context->tool_preset_name && tool_preset != standard_tool_preset)
{
......
......@@ -478,15 +478,17 @@ gimp_data_factory_data_free (GimpDataFactory *factory)
GimpData *
gimp_data_factory_data_new (GimpDataFactory *factory,
const gchar *name)
const gchar *name,
GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (*name != '\0', NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
if (factory->priv->data_new_func)
{
GimpData *data = factory->priv->data_new_func (name);
GimpData *data = factory->priv->data_new_func (name, context);
if (data)
{
......@@ -574,12 +576,14 @@ gimp_data_factory_data_delete (GimpDataFactory *factory,
}
GimpData *
gimp_data_factory_data_get_standard (GimpDataFactory *factory)
gimp_data_factory_data_get_standard (GimpDataFactory *factory,
GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
if (factory->priv->data_get_standard_func)
return factory->priv->data_get_standard_func ();
return factory->priv->data_get_standard_func (context);
return NULL;
}
......
......@@ -25,10 +25,11 @@
#include "gimpobject.h"
typedef GimpData * (* GimpDataNewFunc) (const gchar *name);
typedef GimpData * (* GimpDataNewFunc) (const gchar *name,
GimpContext *context);
typedef GList * (* GimpDataLoadFunc) (const gchar *filename,
GError **error);
typedef GimpData * (* GimpDataGetStandardFunc) (void);
typedef GimpData * (* GimpDataGetStandardFunc) (GimpContext *context);
typedef struct _GimpDataFactoryLoaderEntry GimpDataFactoryLoaderEntry;
......@@ -83,14 +84,16 @@ void gimp_data_factory_data_save (GimpDataFactory *factory);
void gimp_data_factory_data_free (GimpDataFactory *factory);
GimpData * gimp_data_factory_data_new (GimpDataFactory *factory,
const gchar *name);
const gchar *name,
GimpContext *context);
GimpData * gimp_data_factory_data_duplicate (GimpDataFactory *factory,
GimpData *data);
gboolean gimp_data_factory_data_delete (GimpDataFactory *factory,
GimpData *data,
gboolean delete_from_disk,
GError **error);
GimpData * gimp_data_factory_data_get_standard (GimpDataFactory *factory);
GimpData * gimp_data_factory_data_get_standard (GimpDataFactory *factory,
GimpContext *context);
gboolean gimp_data_factory_data_save_single (GimpDataFactory *factory,
GimpData *data,
GError **error);
......
......@@ -378,7 +378,8 @@ gimp_dynamics_get_extension (GimpData *data)
/* public functions */
GimpData *
gimp_dynamics_new (const gchar *name)
gimp_dynamics_new (const gchar *name,
GimpContext *context)
{
return g_object_new (GIMP_TYPE_DYNAMICS,
"name", name,
......@@ -386,13 +387,13 @@ gimp_dynamics_new (const gchar *name)
}
GimpData *
gimp_dynamics_get_standard (void)
gimp_dynamics_get_standard (GimpContext *context)
{
static GimpData *standard_dynamics = NULL;
if (! standard_dynamics)
{
standard_dynamics = gimp_dynamics_new ("Standard dynamics");
standard_dynamics = gimp_dynamics_new ("Standard dynamics", context);
gimp_data_clean (standard_dynamics);
gimp_data_make_internal (standard_dynamics, "gimp-dynamics-standard");
......
......@@ -56,8 +56,9 @@ struct _GimpDynamicsClass
GType gimp_dynamics_get_type (void) G_GNUC_CONST;
GimpData * gimp_dynamics_new (const gchar *name);
GimpData * gimp_dynamics_get_standard (void);
GimpData * gimp_dynamics_new (const gchar *name,
GimpContext *context);
GimpData * gimp_dynamics_get_standard (GimpContext *context);
GimpDynamicsOutput * gimp_dynamics_get_output (GimpDynamics *dynamics,
GimpDynamicsOutputType type);
......
......@@ -322,7 +322,8 @@ gimp_gradient_get_checksum (GimpTagged *tagged)
/* public functions */
GimpData *
gimp_gradient_new (const gchar *name)
gimp_gradient_new (const gchar *name,
GimpContext *context)
{
GimpGradient *gradient;
......@@ -339,13 +340,13 @@ gimp_gradient_new (const gchar *name)
}
GimpData *
gimp_gradient_get_standard (void)
gimp_gradient_get_standard (GimpContext *context)
{
static GimpData *standard_gradient = NULL;
if (! standard_gradient)
{
standard_gradient = gimp_gradient_new ("Standard");
standard_gradient = gimp_gradient_new ("Standard", context);
gimp_data_clean (standard_gradient);
gimp_data_make_internal (standard_gradient, "gimp-gradient-standard");
......
......@@ -67,8 +67,9 @@ struct _GimpGradientClass
GType gimp_gradient_get_type (void) G_GNUC_CONST;
GimpData * gimp_gradient_new (const gchar *name);
GimpData * gimp_gradient_get_standard (void);
GimpData * gimp_gradient_new (const gchar *name,
GimpContext *context);
GimpData * gimp_gradient_get_standard (GimpContext *context);
GimpGradientSegment * gimp_gradient_get_color_at (GimpGradient *gradient,
GimpContext *context,
......
......@@ -65,7 +65,7 @@ gimp_palette_import_from_gradient (GimpGradient *gradient,
g_return_val_if_fail (palette_name != NULL, NULL);
g_return_val_if_fail (n_colors > 1, NULL);
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
dx = 1.0 / (n_colors - 1);
......@@ -225,12 +225,15 @@ gimp_palette_import_create_image_palette (gpointer data,
static GimpPalette *
gimp_palette_import_make_palette (GHashTable *table,
const gchar *palette_name,
GimpContext *context,
gint n_colors)
{
GimpPalette *palette = GIMP_PALETTE (gimp_palette_new (palette_name));
GSList *list = NULL;
GimpPalette *palette;
GSList *list = NULL;
GSList *iter;
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
if (! table)
return palette;
......@@ -356,6 +359,7 @@ gimp_palette_import_extract (GimpImage *image,
GimpPalette *
gimp_palette_import_from_image (GimpImage *image,
GimpContext *context,
const gchar *palette_name,
gint n_colors,
gint threshold,
......@@ -367,6 +371,7 @@ gimp_palette_import_from_image (GimpImage *image,
gint width, height;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (palette_name != NULL, NULL);
g_return_val_if_fail (n_colors > 1, NULL);
g_return_val_if_fail (threshold > 0, NULL);
......@@ -398,7 +403,8 @@ gimp_palette_import_from_image (GimpImage *image,
x, y, width, height,
n_colors, threshold);
return gimp_palette_import_make_palette (colors, palette_name, n_colors);
return gimp_palette_import_make_palette (colors, palette_name, context,
n_colors);
}
......@@ -406,6 +412,7 @@ gimp_palette_import_from_image (GimpImage *image,
GimpPalette *
gimp_palette_import_from_indexed_image (GimpImage *image,
GimpContext *context,
const gchar *palette_name)
{
GimpPalette *palette;
......@@ -415,10 +422,11 @@ gimp_palette_import_from_indexed_image (GimpImage *image,
GimpRGB color;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (gimp_image_base_type (image) == GIMP_INDEXED, NULL);
g_return_val_if_fail (palette_name != NULL, NULL);
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
colormap = gimp_image_get_colormap (image);
n_colors = gimp_image_get_colormap_size (image);
......@@ -446,6 +454,7 @@ gimp_palette_import_from_indexed_image (GimpImage *image,
GimpPalette *
gimp_palette_import_from_drawable (GimpDrawable *drawable,
GimpContext *context,
const gchar *palette_name,
gint n_colors,
gint threshold,
......@@ -457,6 +466,7 @@ gimp_palette_import_from_drawable (GimpDrawable *drawable,
gint off_x, off_y;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (palette_name != NULL, NULL);
g_return_val_if_fail (n_colors > 1, NULL);
......@@ -485,19 +495,22 @@ gimp_palette_import_from_drawable (GimpDrawable *drawable,
x, y, width, height,
n_colors, threshold);
return gimp_palette_import_make_palette (colors, palette_name, n_colors);
return gimp_palette_import_make_palette (colors, palette_name, context,
n_colors);
}
/* create a palette from a file **********************************/
GimpPalette *
gimp_palette_import_from_file (const gchar *filename,
gimp_palette_import_from_file (GimpContext *context,
const gchar *filename,
const gchar *palette_name,
GError **error)
{
GList *palette_list = NULL;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (palette_name != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
......@@ -509,23 +522,23 @@ gimp_palette_import_from_file (const gchar *filename,
break;
case GIMP_PALETTE_FILE_FORMAT_ACT:
palette_list = gimp_palette_load_act (filename, error);
palette_list = gimp_palette_load_act (context, filename, error);
break;
case GIMP_PALETTE_FILE_FORMAT_RIFF_PAL:
palette_list = gimp_palette_load_riff (filename, error);
palette_list = gimp_palette_load_riff (context, filename, error);
break;
case GIMP_PALETTE_FILE_FORMAT_PSP_PAL:
palette_list = gimp_palette_load_psp (filename, error);
palette_list = gimp_palette_load_psp (context, filename, error);
break;
case GIMP_PALETTE_FILE_FORMAT_ACO:
palette_list = gimp_palette_load_aco (filename, error);
palette_list = gimp_palette_load_aco (context, filename, error);
break;
case GIMP_PALETTE_FILE_FORMAT_CSS:
palette_list = gimp_palette_load_css (filename, error);
palette_list = gimp_palette_load_css (context, filename, error);
break;
default:
......
......@@ -25,18 +25,22 @@ GimpPalette * gimp_palette_import_from_gradient (GimpGradient *gradient,
const gchar *palette_name,
gint n_colors);
GimpPalette * gimp_palette_import_from_image (GimpImage *image,
GimpContext *context,
const gchar *palette_name,
gint n_colors,
gint treshold,
gboolean selection_only);
GimpPalette * gimp_palette_import_from_indexed_image (GimpImage *image,
GimpContext *context,
const gchar *palette_name);
GimpPalette * gimp_palette_import_from_drawable (GimpDrawable *drawable,
GimpContext *context,
const gchar *palette_name,
gint n_colors,
gint threshold,
gboolean selection_only);
GimpPalette * gimp_palette_import_from_file (const gchar *filename,
GimpPalette * gimp_palette_import_from_file (GimpContext *context,
const gchar *filename,
const gchar *palette_name,
GError **error);
......
......@@ -250,7 +250,8 @@ gimp_palette_load (const gchar *filename,
}
GList *
gimp_palette_load_act (const gchar *filename,
gimp_palette_load_act (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPalette *palette;
......@@ -274,7 +275,7 @@ gimp_palette_load_act (const gchar *filename,
}
palette_name = g_filename_display_basename (filename);
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
g_free (palette_name);
while (read (fd, color_bytes, 3) == 3)
......@@ -295,7 +296,8 @@ gimp_palette_load_act (const gchar *filename,
}
GList *
gimp_palette_load_riff (const gchar *filename,
gimp_palette_load_riff (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPalette *palette;
......@@ -319,7 +321,7 @@ gimp_palette_load_riff (const gchar *filename,
}
palette_name = g_filename_display_basename (filename);
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
g_free (palette_name);
lseek (fd, 28, SEEK_SET);
......@@ -343,7 +345,8 @@ gimp_palette_load_riff (const gchar *filename,
}
GList *
gimp_palette_load_psp (const gchar *filename,
gimp_palette_load_psp (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPalette *palette;
......@@ -375,7 +378,7 @@ gimp_palette_load_psp (const gchar *filename,
}
palette_name = g_filename_display_basename (filename);
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
g_free (palette_name);
lseek (fd, 16, SEEK_SET);
......@@ -434,7 +437,8 @@ gimp_palette_load_psp (const gchar *filename,
}
GList *
gimp_palette_load_aco (const gchar *filename,
gimp_palette_load_aco (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPalette *palette;
......@@ -476,7 +480,7 @@ gimp_palette_load_aco (const gchar *filename,
}
palette_name = g_filename_display_basename (filename);
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
palette = GIMP_PALETTE (gimp_palette_new (palette_name, context));
g_free (palette_name);
format_version = header[1] + (header[0] << 8);
......@@ -602,7 +606,8 @@ gimp_palette_load_aco (const gchar *filename,
GList *
gimp_palette_load_css (const gchar *filename,
gimp_palette_load_css (GimpContext *context,
const gchar *filename,
GError **error)
{
GimpPalette *palette;
......@@ -630,7 +635,7 @@ gimp_palette_load_css (const gchar *filename,
}
name = g_filename_display_basename (filename);
palette = GIMP_PALETTE (gimp_palette_new (name));
palette = GIMP_PALETTE (gimp_palette_new (name, context));
g_free (name);
do
......
......@@ -36,15 +36,20 @@ typedef enum
GList * gimp_palette_load (const gchar *filename,
GError **error);
GList * gimp_palette_load_act (const gchar *filename,
GList * gimp_palette_load_act (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_palette_load_riff (const gchar *filename,
GList * gimp_palette_load_riff (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_palette_load_psp (const gchar *filename,
GList * gimp_palette_load_psp (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_palette_load_aco (const gchar *filename,
GList * gimp_palette_load_aco (GimpContext *context,
const gchar *filename,
GError **error);
GList * gimp_palette_load_css (const gchar *filename,
GList * gimp_palette_load_css (GimpContext *context,
const gchar *filename,
GError **error);
GimpPaletteFileFormat gimp_palette_load_detect_format (const gchar *filename);
......
......@@ -272,7 +272,8 @@ gimp_palette_get_description (GimpViewable *viewable,
}
GimpData *
gimp_palette_new (const gchar *name)
gimp_palette_new (const gchar *name,
GimpContext *context)
{
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (*name != '\0', NULL);
......@@ -283,13 +284,13 @@ gimp_palette_new (const gchar *name)
}
GimpData *
gimp_palette_get_standard (void)
gimp_palette_get_standard (GimpContext *context)
{
static GimpData *standard_palette = NULL;
if (! standard_palette)
{
standard_palette = gimp_palette_new ("Standard");
standard_palette = gimp_palette_new ("Standard", context);
gimp_data_clean (standard_palette);
gimp_data_make_internal (standard_palette, "gimp-palette-standard");
......
......@@ -60,8 +60,9 @@ struct _GimpPaletteClass
GType gimp_palette_get_type (void) G_GNUC_CONST;
GimpData * gimp_palette_new (const gchar *name);
GimpData * gimp_palette_get_standard (void);
GimpData * gimp_palette_new (const gchar *name,
GimpContext *context);
GimpData * gimp_palette_get_standard (GimpContext *context);
GimpPaletteEntry * gimp_palette_add_entry (GimpPalette *palette,
gint position,
......
......@@ -209,7 +209,8 @@ gimp_pattern_get_checksum (GimpTagged *tagged)
}
GimpData *
gimp_pattern_new (const gchar *name)
gimp_pattern_new (const gchar *name,
GimpContext *context)
{
GimpPattern *pattern;
guchar *data;
......@@ -236,13 +237,13 @@ gimp_pattern_new (const gchar *name)
}
GimpData *
gimp_pattern_get_standard (void)
gimp_pattern_get_standard (GimpContext *context)
{
static GimpData *standard_pattern = NULL;
if (! standard_pattern)
{
standard_pattern = gimp_pattern_new ("Standard");
standard_pattern = gimp_pattern_new ("Standard", context);
gimp_data_clean (standard_pattern);
gimp_data_make_internal (standard_pattern, "gimp-pattern-standard");
......
......@@ -47,8 +47,9 @@ struct _GimpPatternClass
GType gimp_pattern_get_type (void) G_GNUC_CONST;
GimpData * gimp_pattern_new (const gchar *name);
GimpData * gimp_pattern_get_standard (void);
GimpData * gimp_pattern_new (const gchar *name,
GimpContext *context);
GimpData * gimp_pattern_get_standard (GimpContext *context);
TempBuf * gimp_pattern_get_mask (const GimpPattern *pattern);
......
......@@ -24,6 +24,7 @@
#include "core-types.h"
#include "gimptoolinfo.h"
#include "gimptooloptions.h"
#include "gimptoolpreset.h"
#include "gimptoolpreset-load.h"
......@@ -84,8 +85,8 @@ gimp_tool_preset_class_init (GimpToolPresetClass *klass)
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_TOOL_OPTIONS,
"tool-options", NULL,
GIMP_TYPE_TOOL_PRESET,
GIMP_CONFIG_PARAM_AGGREGATE);
GIMP_TYPE_TOOL_OPTIONS,
GIMP_PARAM_STATIC_STRINGS);
}
static void
......@@ -190,22 +191,37 @@ gimp_tool_preset_get_extension (GimpData *data)
/* public functions */
GimpData *
gimp_tool_preset_new (const gchar *name)
gimp_tool_preset_new (const gchar *name,
GimpContext *context)
{
GimpToolInfo *tool_info;
const gchar *stock_id;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
tool_info = gimp_context_get_tool (context);
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
return g_object_new (GIMP_TYPE_TOOL_PRESET,
"name", name,
// "tool-options", options,
"name", name,
"stock-id", stock_id,
"tool-options", tool_info->tool_options,
NULL);
}