Context cleanup continued:

2004-04-15  Michael Natterer  <mitch@gimp.org>

	Context cleanup continued:

	* app/core/gimpitem.[ch]: added context parameter to
	GimpItem::stroke().

	* app/core/gimpchannel.c (gimp_channel_stroke)
	* app/vectors/gimpvectors.c (gimp_vectors_stroke): use it to get
	default values from instead of gimp_get_user_context().

	* app/core/gimpselection.c
	* app/gui/stroke-dialog.c
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/pdb/paths.pdb: changed accordingly.

	* app/pdb/edit_cmds.c
	* app/pdb/paths_cmds.c: regenerated.

	* app/plug-in/plug-in.[ch]: added GimpContext member to the PlugIn
	struct. Added context parameter to plug_in_new(),
	plug_in_call_query() and plug_in_call_init().

	* app/plug-in/plug-in-run.[ch]: added context parameters to
	plug_in_run() and plug_in_repeat().

	* app/gui/plug-in-commands.c
	* app/gui/vectors-commands.c
	* app/pdb/procedural_db.c
	* app/widgets/gimphelp.c: pass a context to plug_in_run() and
	plug_in_repeat().

	* app/plug-in/plug-in-message.c (plug_in_handle_proc_run): call
	procedures with the plug-in's context.

	* app/plug-in/plug-ins.c: use a temporary context for running the
	plug-ins' query() and init() functions. Use the same context for
	running automatic extensions. This temporarily separates the main
	Script-Fu extension from the user context (i.e. scripts have no
	way of setting/getting the global FG, BG, brush etc.).
This commit is contained in:
Michael Natterer 2004-04-15 13:10:51 +00:00 committed by Michael Natterer
parent 99309dde33
commit 837fa4294d
35 changed files with 279 additions and 172 deletions

View File

@ -1,3 +1,44 @@
2004-04-15 Michael Natterer <mitch@gimp.org>
Context cleanup continued:
* app/core/gimpitem.[ch]: added context parameter to
GimpItem::stroke().
* app/core/gimpchannel.c (gimp_channel_stroke)
* app/vectors/gimpvectors.c (gimp_vectors_stroke): use it to get
default values from instead of gimp_get_user_context().
* app/core/gimpselection.c
* app/gui/stroke-dialog.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/paths.pdb: changed accordingly.
* app/pdb/edit_cmds.c
* app/pdb/paths_cmds.c: regenerated.
* app/plug-in/plug-in.[ch]: added GimpContext member to the PlugIn
struct. Added context parameter to plug_in_new(),
plug_in_call_query() and plug_in_call_init().
* app/plug-in/plug-in-run.[ch]: added context parameters to
plug_in_run() and plug_in_repeat().
* app/gui/plug-in-commands.c
* app/gui/vectors-commands.c
* app/pdb/procedural_db.c
* app/widgets/gimphelp.c: pass a context to plug_in_run() and
plug_in_repeat().
* app/plug-in/plug-in-message.c (plug_in_handle_proc_run): call
procedures with the plug-in's context.
* app/plug-in/plug-ins.c: use a temporary context for running the
plug-ins' query() and init() functions. Use the same context for
running automatic extensions. This temporarily separates the main
Script-Fu extension from the user context (i.e. scripts have no
way of setting/getting the global FG, BG, brush etc.).
2004-04-15 Sven Neumann <sven@gimp.org>
* NEWS

View File

@ -140,7 +140,8 @@ plug_in_run_cmd_callback (GtkWidget *widget,
}
/* run the plug-in procedure */
plug_in_run (gimp, proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
plug_in_run (gimp, gimp_get_user_context (gimp),
proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
/* remember only "standard" plug-ins */
if (proc_rec->proc_type == GIMP_PLUGIN &&
@ -173,6 +174,7 @@ plug_in_repeat_cmd_callback (GtkWidget *widget,
interactive = action ? TRUE : FALSE;
plug_in_repeat (gdisp->gimage->gimp,
gimp_get_user_context (gdisp->gimage->gimp),
gimp_display_get_ID (gdisp),
gimp_image_get_ID (gdisp->gimage),
gimp_item_get_ID (GIMP_ITEM (drawable)),

View File

@ -334,7 +334,7 @@ vectors_selection_to_vectors (GimpImage *gimage,
args[2].arg_type = GIMP_PDB_DRAWABLE;
args[2].value.pdb_int = -1; /* unused */
plug_in_run (gimage->gimp,
plug_in_run (gimage->gimp, gimp_get_user_context (gimage->gimp),
proc_rec, args, 3, FALSE, TRUE,
gdisp ? gdisp->ID : 0);

View File

@ -108,6 +108,7 @@ static void gimp_channel_transform (GimpItem *item,
gpointer progress_data);
static gboolean gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values);
@ -574,6 +575,7 @@ gimp_channel_transform (GimpItem *item,
static gboolean
gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values)
@ -618,13 +620,12 @@ gimp_channel_stroke (GimpItem *item,
paint_info->paint_options_type);
/* undefine the paint-relevant context properties and get them
* from the current context
* from the passed context
*/
gimp_context_define_properties (GIMP_CONTEXT (paint_options),
GIMP_CONTEXT_PAINT_PROPS_MASK,
FALSE);
gimp_context_set_parent (GIMP_CONTEXT (paint_options),
gimp_get_user_context (gimage->gimp));
gimp_context_set_parent (GIMP_CONTEXT (paint_options), context);
}
else
{

View File

@ -899,6 +899,7 @@ gimp_item_transform (GimpItem *item,
gboolean
gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values)
{
@ -906,13 +907,15 @@ gimp_item_stroke (GimpItem *item,
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_PAINT_INFO (stroke_desc) ||
GIMP_IS_STROKE_OPTIONS (stroke_desc), FALSE);
item_class = GIMP_ITEM_GET_CLASS (item);
if (item_class->stroke)
return item_class->stroke (item, drawable, stroke_desc, use_default_values);
return item_class->stroke (item, drawable, context,
stroke_desc, use_default_values);
return FALSE;
}

View File

@ -116,6 +116,7 @@ struct _GimpItemClass
gpointer progress_data);
gboolean (* stroke) (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values);
@ -225,6 +226,7 @@ void gimp_item_transform (GimpItem *item,
gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values);

View File

@ -77,6 +77,7 @@ static void gimp_selection_rotate (GimpItem *item,
gboolean clip_result);
static gboolean gimp_selection_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values);
@ -291,6 +292,7 @@ gimp_selection_rotate (GimpItem *item,
static gboolean
gimp_selection_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values)
{
@ -318,7 +320,8 @@ gimp_selection_stroke (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
_("Stroke Selection"));
retval = GIMP_ITEM_CLASS (parent_class)->stroke (item, drawable, stroke_desc,
retval = GIMP_ITEM_CLASS (parent_class)->stroke (item, drawable, context,
stroke_desc,
use_default_values);
gimp_image_undo_group_end (gimage);
@ -331,8 +334,8 @@ gimp_selection_stroke (GimpItem *item,
static void
gimp_selection_invalidate_boundary (GimpDrawable *drawable)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpLayer *layer;
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpLayer *layer;
g_return_if_fail (GIMP_IS_IMAGE (gimage));

View File

@ -55,7 +55,7 @@ static void stroke_dialog_response (GtkWidget *widget,
GtkWidget *dialog);
static void stroke_dialog_paint_info_selected (GtkWidget *menu,
GimpViewable *viewable,
gpointer insert_date,
gpointer insert_data,
GtkWidget *dialog);
@ -331,7 +331,7 @@ stroke_dialog_response (GtkWidget *widget,
options = g_object_get_data (G_OBJECT (dialog), "gimp-paint-info");
}
gimp_item_stroke (item, drawable, options, FALSE);
gimp_item_stroke (item, drawable, context, options, FALSE);
gimp_image_flush (image);
}
/* fallthrough */
@ -345,7 +345,7 @@ stroke_dialog_response (GtkWidget *widget,
static void
stroke_dialog_paint_info_selected (GtkWidget *menu,
GimpViewable *viewable,
gpointer insert_date,
gpointer insert_data,
GtkWidget *dialog)
{
g_object_set_data (G_OBJECT (dialog), "gimp-paint-info", viewable);

View File

@ -140,7 +140,8 @@ plug_in_run_cmd_callback (GtkWidget *widget,
}
/* run the plug-in procedure */
plug_in_run (gimp, proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
plug_in_run (gimp, gimp_get_user_context (gimp),
proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
/* remember only "standard" plug-ins */
if (proc_rec->proc_type == GIMP_PLUGIN &&
@ -173,6 +174,7 @@ plug_in_repeat_cmd_callback (GtkWidget *widget,
interactive = action ? TRUE : FALSE;
plug_in_repeat (gdisp->gimage->gimp,
gimp_get_user_context (gdisp->gimage->gimp),
gimp_display_get_ID (gdisp),
gimp_image_get_ID (gdisp->gimage),
gimp_item_get_ID (GIMP_ITEM (drawable)),

View File

@ -55,7 +55,7 @@ static void stroke_dialog_response (GtkWidget *widget,
GtkWidget *dialog);
static void stroke_dialog_paint_info_selected (GtkWidget *menu,
GimpViewable *viewable,
gpointer insert_date,
gpointer insert_data,
GtkWidget *dialog);
@ -331,7 +331,7 @@ stroke_dialog_response (GtkWidget *widget,
options = g_object_get_data (G_OBJECT (dialog), "gimp-paint-info");
}
gimp_item_stroke (item, drawable, options, FALSE);
gimp_item_stroke (item, drawable, context, options, FALSE);
gimp_image_flush (image);
}
/* fallthrough */
@ -345,7 +345,7 @@ stroke_dialog_response (GtkWidget *widget,
static void
stroke_dialog_paint_info_selected (GtkWidget *menu,
GimpViewable *viewable,
gpointer insert_date,
gpointer insert_data,
GtkWidget *dialog)
{
g_object_set_data (G_OBJECT (dialog), "gimp-paint-info", viewable);

View File

@ -334,7 +334,7 @@ vectors_selection_to_vectors (GimpImage *gimage,
args[2].arg_type = GIMP_PDB_DRAWABLE;
args[2].value.pdb_int = -1; /* unused */
plug_in_run (gimage->gimp,
plug_in_run (gimage->gimp, gimp_get_user_context (gimage->gimp),
proc_rec, args, 3, FALSE, TRUE,
gdisp ? gdisp->ID : 0);

View File

@ -716,7 +716,7 @@ edit_stroke_invoker (Gimp *gimp,
tool_info = gimp_context_get_tool (context);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable,
drawable, context,
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */);
}

View File

@ -310,7 +310,7 @@ procedural_db_execute (Gimp *gimp,
case GIMP_PLUGIN:
case GIMP_EXTENSION:
case GIMP_TEMPORARY:
return_args = plug_in_run (gimp, procedure,
return_args = plug_in_run (gimp, context, procedure,
args, procedure->num_args,
TRUE, FALSE, -1);
break;

View File

@ -310,7 +310,7 @@ procedural_db_execute (Gimp *gimp,
case GIMP_PLUGIN:
case GIMP_EXTENSION:
case GIMP_TEMPORARY:
return_args = plug_in_run (gimp, procedure,
return_args = plug_in_run (gimp, context, procedure,
args, procedure->num_args,
TRUE, FALSE, -1);
break;

View File

@ -310,7 +310,7 @@ procedural_db_execute (Gimp *gimp,
case GIMP_PLUGIN:
case GIMP_EXTENSION:
case GIMP_TEMPORARY:
return_args = plug_in_run (gimp, procedure,
return_args = plug_in_run (gimp, context, procedure,
args, procedure->num_args,
TRUE, FALSE, -1);
break;

View File

@ -606,7 +606,7 @@ path_stroke_current_invoker (Gimp *gimp,
{
GimpToolInfo *tool_info = gimp_context_get_tool (context);
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable,
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable, context,
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */);
}

View File

@ -310,7 +310,7 @@ procedural_db_execute (Gimp *gimp,
case GIMP_PLUGIN:
case GIMP_EXTENSION:
case GIMP_TEMPORARY:
return_args = plug_in_run (gimp, procedure,
return_args = plug_in_run (gimp, context, procedure,
args, procedure->num_args,
TRUE, FALSE, -1);
break;

View File

@ -394,8 +394,7 @@ plug_in_handle_proc_run (PlugIn *plug_in,
/* Execute the procedure even if procedural_db_lookup() returned NULL,
* procedural_db_execute() will return appropriate error return_vals.
*/
return_vals = procedural_db_execute (plug_in->gimp,
gimp_get_user_context (plug_in->gimp),
return_vals = procedural_db_execute (plug_in->gimp, plug_in->context,
proc_name, args);
plug_in_pop (plug_in->gimp);

View File

@ -68,10 +68,8 @@
#include "plug-in-types.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpenvirontable.h"
#include "plug-in.h"
@ -154,15 +152,17 @@ plug_in_exit (Gimp *gimp)
}
void
plug_in_call_query (Gimp *gimp,
PlugInDef *plug_in_def)
plug_in_call_query (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def)
{
PlugIn *plug_in;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (plug_in_def != NULL);
plug_in = plug_in_new (gimp, NULL, plug_in_def->prog);
plug_in = plug_in_new (gimp, context, NULL, plug_in_def->prog);
if (plug_in)
{
@ -193,15 +193,17 @@ plug_in_call_query (Gimp *gimp,
}
void
plug_in_call_init (Gimp *gimp,
PlugInDef *plug_in_def)
plug_in_call_init (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def)
{
PlugIn *plug_in;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (plug_in_def != NULL);
plug_in = plug_in_new (gimp, NULL, plug_in_def->prog);
plug_in = plug_in_new (gimp, context, NULL, plug_in_def->prog);
if (plug_in)
{
@ -233,18 +235,21 @@ plug_in_call_init (Gimp *gimp,
PlugIn *
plug_in_new (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
const gchar *prog)
{
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (prog != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (prog), NULL);
plug_in = g_new0 (PlugIn, 1);
plug_in->gimp = gimp;
plug_in->context = g_object_ref (context);
plug_in->ref_count = 1;
@ -310,6 +315,8 @@ plug_in_unref (PlugIn *plug_in)
if (plug_in->progress)
plug_in_progress_end (plug_in);
g_object_unref (plug_in->context);
g_free (plug_in);
}
}

View File

@ -29,6 +29,7 @@
struct _PlugIn
{
Gimp *gimp;
GimpContext *context;
gint ref_count;
@ -79,11 +80,14 @@ void plug_in_init (Gimp *gimp);
void plug_in_exit (Gimp *gimp);
void plug_in_call_query (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def);
void plug_in_call_init (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def);
PlugIn * plug_in_new (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
const gchar *prog);

View File

@ -33,6 +33,7 @@
#include "base/tile.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "pdb/procedural_db.h"
@ -56,18 +57,20 @@ static Argument * plug_in_get_return_vals (PlugIn *plug_in,
/* public functions */
Argument *
plug_in_run (Gimp *gimp,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID)
plug_in_run (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID)
{
Argument *return_vals = NULL;
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (proc_rec != NULL, NULL);
g_return_val_if_fail (argc == 0 || args != NULL, NULL);
g_return_val_if_fail (proc_rec->proc_type != GIMP_EXTENSION ||
@ -79,7 +82,7 @@ plug_in_run (Gimp *gimp,
goto done;
}
plug_in = plug_in_new (gimp, proc_rec,
plug_in = plug_in_new (gimp, context, proc_rec,
proc_rec->exec_method.plug_in.filename);
if (plug_in)
@ -175,16 +178,18 @@ plug_in_run (Gimp *gimp,
}
void
plug_in_repeat (Gimp *gimp,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface)
plug_in_repeat (Gimp *gimp,
GimpContext *context,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface)
{
Argument *args;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (gimp->last_plug_in)
{
@ -202,7 +207,8 @@ plug_in_repeat (Gimp *gimp,
args[2].value.pdb_int = drawable_ID;
/* run the plug-in procedure */
plug_in_run (gimp, gimp->last_plug_in, args, 3, FALSE, TRUE, display_ID);
plug_in_run (gimp, context, gimp->last_plug_in,
args, 3, FALSE, TRUE, display_ID);
g_free (args);
}

View File

@ -22,22 +22,24 @@
/* Run a plug-in as if it were a procedure database procedure
*/
Argument * plug_in_run (Gimp *gimp,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID);
Argument * plug_in_run (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID);
/* Run the last plug-in again with the same arguments. Extensions
* are exempt from this "privelege".
*/
void plug_in_repeat (Gimp *gimp,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface);
void plug_in_repeat (Gimp *gimp,
GimpContext *context,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface);
#endif /* __PLUG_IN_RUN_H__ */

View File

@ -33,6 +33,7 @@
#include "base/tile.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "pdb/procedural_db.h"
@ -56,18 +57,20 @@ static Argument * plug_in_get_return_vals (PlugIn *plug_in,
/* public functions */
Argument *
plug_in_run (Gimp *gimp,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID)
plug_in_run (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID)
{
Argument *return_vals = NULL;
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (proc_rec != NULL, NULL);
g_return_val_if_fail (argc == 0 || args != NULL, NULL);
g_return_val_if_fail (proc_rec->proc_type != GIMP_EXTENSION ||
@ -79,7 +82,7 @@ plug_in_run (Gimp *gimp,
goto done;
}
plug_in = plug_in_new (gimp, proc_rec,
plug_in = plug_in_new (gimp, context, proc_rec,
proc_rec->exec_method.plug_in.filename);
if (plug_in)
@ -175,16 +178,18 @@ plug_in_run (Gimp *gimp,
}
void
plug_in_repeat (Gimp *gimp,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface)
plug_in_repeat (Gimp *gimp,
GimpContext *context,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface)
{
Argument *args;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (gimp->last_plug_in)
{
@ -202,7 +207,8 @@ plug_in_repeat (Gimp *gimp,
args[2].value.pdb_int = drawable_ID;
/* run the plug-in procedure */
plug_in_run (gimp, gimp->last_plug_in, args, 3, FALSE, TRUE, display_ID);
plug_in_run (gimp, context, gimp->last_plug_in,
args, 3, FALSE, TRUE, display_ID);
g_free (args);
}

View File

@ -22,22 +22,24 @@
/* Run a plug-in as if it were a procedure database procedure
*/
Argument * plug_in_run (Gimp *gimp,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID);
Argument * plug_in_run (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID);
/* Run the last plug-in again with the same arguments. Extensions
* are exempt from this "privelege".
*/
void plug_in_repeat (Gimp *gimp,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface);
void plug_in_repeat (Gimp *gimp,
GimpContext *context,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface);
#endif /* __PLUG_IN_RUN_H__ */

View File

@ -72,7 +72,8 @@ struct _PlugInHelpDomainDef
static void plug_ins_init_file (const GimpDatafileData *file_data,
gpointer user_data);
static void plug_ins_add_to_db (Gimp *gimp);
static void plug_ins_add_to_db (Gimp *gimp,
GimpContext *context);
static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp,
PlugInProcDef *proc_def);
@ -83,19 +84,22 @@ void
plug_ins_init (Gimp *gimp,
GimpInitStatusFunc status_callback)
{
gchar *filename;
gchar *basename;
gchar *path;
GSList *tmp;
GList *extensions = NULL;
gdouble n_plugins;
gdouble n_extensions;
gdouble nth;
GError *error = NULL;
GimpContext *context;
gchar *filename;
gchar *basename;
gchar *path;
GSList *tmp;
GList *extensions = NULL;
gdouble n_plugins;
gdouble n_extensions;
gdouble nth;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL);
context = gimp_context_new (gimp, "temp", NULL);
plug_in_init (gimp);
/* search for binaries in the plug-in directory path */
@ -164,7 +168,7 @@ plug_ins_init (Gimp *gimp,
g_print (_("Querying plug-in: '%s'\n"),
gimp_filename_to_utf8 (plug_in_def->prog));
plug_in_call_query (gimp, plug_in_def);
plug_in_call_query (gimp, context, plug_in_def);
}
}
@ -236,7 +240,7 @@ plug_ins_init (Gimp *gimp,
g_free (filename);
/* add the plug-in procs to the procedure database */
plug_ins_add_to_db (gimp);
plug_ins_add_to_db (gimp, context);
/* sort file procs */
gimp->load_procs = g_slist_sort_with_data (gimp->load_procs,
@ -316,7 +320,7 @@ plug_ins_init (Gimp *gimp,
g_print (_("Initializing plug-in: '%s'\n"),
gimp_filename_to_utf8 (plug_in_def->prog));
plug_in_call_init (gimp, plug_in_def);
plug_in_call_init (gimp, context, plug_in_def);
}
}
@ -358,7 +362,8 @@ plug_ins_init (Gimp *gimp,
(* status_callback) (NULL, proc_def->db_info.name, nth / n_plugins);
plug_in_run (gimp, &proc_def->db_info, NULL, 0, FALSE, TRUE, -1);
plug_in_run (gimp, context, &proc_def->db_info,
NULL, 0, FALSE, TRUE, -1);
}
(* status_callback) (NULL, NULL, 1.0);
@ -372,6 +377,8 @@ plug_ins_init (Gimp *gimp,
g_slist_free (gimp->plug_in_defs);
gimp->plug_in_defs = NULL;
g_object_unref (context);
}
void
@ -907,14 +914,12 @@ plug_ins_init_file (const GimpDatafileData *file_data,
}
static void
plug_ins_add_to_db (Gimp *gimp)
plug_ins_add_to_db (Gimp *gimp,
GimpContext *context)
{
GimpContext *context;
PlugInProcDef *proc_def;
GSList *list;
context = gimp_context_new (gimp, "temp", NULL);
for (list = gimp->plug_in_proc_defs; list; list = g_slist_next (list))
{
proc_def = (PlugInProcDef *) list->data;
@ -965,8 +970,6 @@ plug_ins_add_to_db (Gimp *gimp)
}
}
}
g_object_unref (context);
}
static PlugInProcDef *

View File

@ -394,8 +394,7 @@ plug_in_handle_proc_run (PlugIn *plug_in,
/* Execute the procedure even if procedural_db_lookup() returned NULL,
* procedural_db_execute() will return appropriate error return_vals.
*/
return_vals = procedural_db_execute (plug_in->gimp,
gimp_get_user_context (plug_in->gimp),
return_vals = procedural_db_execute (plug_in->gimp, plug_in->context,
proc_name, args);
plug_in_pop (plug_in->gimp);

View File

@ -33,6 +33,7 @@
#include "base/tile.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "pdb/procedural_db.h"
@ -56,18 +57,20 @@ static Argument * plug_in_get_return_vals (PlugIn *plug_in,
/* public functions */
Argument *
plug_in_run (Gimp *gimp,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID)
plug_in_run (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID)
{
Argument *return_vals = NULL;
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (proc_rec != NULL, NULL);
g_return_val_if_fail (argc == 0 || args != NULL, NULL);
g_return_val_if_fail (proc_rec->proc_type != GIMP_EXTENSION ||
@ -79,7 +82,7 @@ plug_in_run (Gimp *gimp,
goto done;
}
plug_in = plug_in_new (gimp, proc_rec,
plug_in = plug_in_new (gimp, context, proc_rec,
proc_rec->exec_method.plug_in.filename);
if (plug_in)
@ -175,16 +178,18 @@ plug_in_run (Gimp *gimp,
}
void
plug_in_repeat (Gimp *gimp,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface)
plug_in_repeat (Gimp *gimp,
GimpContext *context,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface)
{
Argument *args;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (gimp->last_plug_in)
{
@ -202,7 +207,8 @@ plug_in_repeat (Gimp *gimp,
args[2].value.pdb_int = drawable_ID;
/* run the plug-in procedure */
plug_in_run (gimp, gimp->last_plug_in, args, 3, FALSE, TRUE, display_ID);
plug_in_run (gimp, context, gimp->last_plug_in,
args, 3, FALSE, TRUE, display_ID);
g_free (args);
}

View File

@ -22,22 +22,24 @@
/* Run a plug-in as if it were a procedure database procedure
*/
Argument * plug_in_run (Gimp *gimp,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID);
Argument * plug_in_run (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
Argument *args,
gint argc,
gboolean synchronous,
gboolean destroy_return_vals,
gint gdisp_ID);
/* Run the last plug-in again with the same arguments. Extensions
* are exempt from this "privelege".
*/
void plug_in_repeat (Gimp *gimp,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface);
void plug_in_repeat (Gimp *gimp,
GimpContext *context,
gint display_ID,
gint image_ID,
gint drawable_ID,
gboolean with_interface);
#endif /* __PLUG_IN_RUN_H__ */

View File

@ -68,10 +68,8 @@
#include "plug-in-types.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpenvirontable.h"
#include "plug-in.h"
@ -154,15 +152,17 @@ plug_in_exit (Gimp *gimp)
}
void
plug_in_call_query (Gimp *gimp,
PlugInDef *plug_in_def)
plug_in_call_query (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def)
{
PlugIn *plug_in;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (plug_in_def != NULL);
plug_in = plug_in_new (gimp, NULL, plug_in_def->prog);
plug_in = plug_in_new (gimp, context, NULL, plug_in_def->prog);
if (plug_in)
{
@ -193,15 +193,17 @@ plug_in_call_query (Gimp *gimp,
}
void
plug_in_call_init (Gimp *gimp,
PlugInDef *plug_in_def)
plug_in_call_init (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def)
{
PlugIn *plug_in;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (plug_in_def != NULL);
plug_in = plug_in_new (gimp, NULL, plug_in_def->prog);
plug_in = plug_in_new (gimp, context, NULL, plug_in_def->prog);
if (plug_in)
{
@ -233,18 +235,21 @@ plug_in_call_init (Gimp *gimp,
PlugIn *
plug_in_new (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
const gchar *prog)
{
PlugIn *plug_in;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (prog != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (prog), NULL);
plug_in = g_new0 (PlugIn, 1);
plug_in->gimp = gimp;
plug_in->context = g_object_ref (context);
plug_in->ref_count = 1;
@ -310,6 +315,8 @@ plug_in_unref (PlugIn *plug_in)
if (plug_in->progress)
plug_in_progress_end (plug_in);
g_object_unref (plug_in->context);
g_free (plug_in);
}
}

View File

@ -29,6 +29,7 @@
struct _PlugIn
{
Gimp *gimp;
GimpContext *context;
gint ref_count;
@ -79,11 +80,14 @@ void plug_in_init (Gimp *gimp);
void plug_in_exit (Gimp *gimp);
void plug_in_call_query (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def);
void plug_in_call_init (Gimp *gimp,
GimpContext *context,
PlugInDef *plug_in_def);
PlugIn * plug_in_new (Gimp *gimp,
GimpContext *context,
ProcRecord *proc_rec,
const gchar *prog);

View File

@ -72,7 +72,8 @@ struct _PlugInHelpDomainDef
static void plug_ins_init_file (const GimpDatafileData *file_data,
gpointer user_data);
static void plug_ins_add_to_db (Gimp *gimp);
static void plug_ins_add_to_db (Gimp *gimp,
GimpContext *context);
static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp,
PlugInProcDef *proc_def);
@ -83,19 +84,22 @@ void
plug_ins_init (Gimp *gimp,
GimpInitStatusFunc status_callback)
{
gchar *filename;
gchar *basename;
gchar *path;
GSList *tmp;
GList *extensions = NULL;
gdouble n_plugins;
gdouble n_extensions;
gdouble nth;
GError *error = NULL;
GimpContext *context;
gchar *filename;
gchar *basename;
gchar *path;
GSList *tmp;
GList *extensions = NULL;
gdouble n_plugins;
gdouble n_extensions;
gdouble nth;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL);
context = gimp_context_new (gimp, "temp", NULL);
plug_in_init (gimp);
/* search for binaries in the plug-in directory path */
@ -164,7 +168,7 @@ plug_ins_init (Gimp *gimp,
g_print (_("Querying plug-in: '%s'\n"),
gimp_filename_to_utf8 (plug_in_def->prog));
plug_in_call_query (gimp, plug_in_def);
plug_in_call_query (gimp, context, plug_in_def);
}
}
@ -236,7 +240,7 @@ plug_ins_init (Gimp *gimp,
g_free (filename);
/* add the plug-in procs to the procedure database */
plug_ins_add_to_db (gimp);
plug_ins_add_to_db (gimp, context);
/* sort file procs */
gimp->load_procs = g_slist_sort_with_data (gimp->load_procs,
@ -316,7 +320,7 @@ plug_ins_init (Gimp *gimp,
g_print (_("Initializing plug-in: '%s'\n"),
gimp_filename_to_utf8 (plug_in_def->prog));
plug_in_call_init (gimp, plug_in_def);
plug_in_call_init (gimp, context, plug_in_def);
}
}
@ -358,7 +362,8 @@ plug_ins_init (Gimp *gimp,
(* status_callback) (NULL, proc_def->db_info.name, nth / n_plugins);
plug_in_run (gimp, &proc_def->db_info, NULL, 0, FALSE, TRUE, -1);
plug_in_run (gimp, context, &proc_def->db_info,
NULL, 0, FALSE, TRUE, -1);
}
(* status_callback) (NULL, NULL, 1.0);
@ -372,6 +377,8 @@ plug_ins_init (Gimp *gimp,
g_slist_free (gimp->plug_in_defs);
gimp->plug_in_defs = NULL;
g_object_unref (context);
}
void
@ -907,14 +914,12 @@ plug_ins_init_file (const GimpDatafileData *file_data,
}
static void
plug_ins_add_to_db (Gimp *gimp)
plug_ins_add_to_db (Gimp *gimp,
GimpContext *context)
{
GimpContext *context;
PlugInProcDef *proc_def;
GSList *list;
context = gimp_context_new (gimp, "temp", NULL);
for (list = gimp->plug_in_proc_defs; list; list = g_slist_next (list))
{
proc_def = (PlugInProcDef *) list->data;
@ -965,8 +970,6 @@ plug_ins_add_to_db (Gimp *gimp)
}
}
}
g_object_unref (context);
}
static PlugInProcDef *

View File

@ -114,6 +114,7 @@ static void gimp_vectors_transform (GimpItem *item,
gpointer progress_data);
static gboolean gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values);
@ -563,6 +564,7 @@ gimp_vectors_transform (GimpItem *item,
static gboolean
gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpObject *stroke_desc,
gboolean use_default_values)
{
@ -596,13 +598,12 @@ gimp_vectors_stroke (GimpItem *item,
paint_info->paint_options_type);
/* undefine the paint-relevant context properties and get them
* from the current context
* from the passed context
*/
gimp_context_define_properties (GIMP_CONTEXT (paint_options),
GIMP_CONTEXT_PAINT_PROPS_MASK,
FALSE);
gimp_context_set_parent (GIMP_CONTEXT (paint_options),
gimp_get_user_context (gimage->gimp));
gimp_context_set_parent (GIMP_CONTEXT (paint_options), context);
}
else
{

View File

@ -215,7 +215,8 @@ gimp_help_internal (Gimp *gimp)
args[0].arg_type = GIMP_PDB_INT32;
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
plug_in_run (gimp, proc_rec, args, 1, FALSE, TRUE, -1);
plug_in_run (gimp, gimp_get_user_context (gimp),
proc_rec, args, 1, FALSE, TRUE, -1);
procedural_db_destroy_args (args, 1);
}
@ -288,7 +289,8 @@ gimp_help_call (Gimp *gimp,
args[3].arg_type = GIMP_PDB_STRINGARRAY;
args[3].value.pdb_pointer = help_uris;
plug_in_run (gimp, proc_rec, args, 4, FALSE, TRUE, -1);
plug_in_run (gimp, gimp_get_user_context (gimp),
proc_rec, args, 4, FALSE, TRUE, -1);
procedural_db_destroy_args (args, 4);
}

View File

@ -361,7 +361,7 @@ HELP
tool_info = gimp_context_get_tool (context);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable,
drawable, context,
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */);
}

View File

@ -310,7 +310,7 @@ HELP
{
GimpToolInfo *tool_info = gimp_context_get_tool (context);
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable,
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable, context,
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */);
}