Commit 77ba473f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Prepare for enabling private contexts for plug-ins and scripts:

2004-09-22  Michael Natterer  <mitch@gimp.org>

	Prepare for enabling private contexts for plug-ins and scripts:

	* app/plug-in/plug-in.[ch]: removed the "context" member from
	the PlugIn struct and added it to PlugInProcFrame instead.

	* app/plug-in/plug-in-message.c
	* app/plug-in/plug-in-progress.c
	* app/plug-in/plug-in-run.c: changed accordingly.
parent 531935c7
2004-09-22 Michael Natterer <mitch@gimp.org>
Prepare for enabling private contexts for plug-ins and scripts:
* app/plug-in/plug-in.[ch]: removed the "context" member from
the PlugIn struct and added it to PlugInProcFrame instead.
* app/plug-in/plug-in-message.c
* app/plug-in/plug-in-progress.c
* app/plug-in/plug-in-run.c: changed accordingly.
2004-09-22 Sven Neumann <sven@gimp.org>
* plug-ins/common/bumpmap.c: moved the preview to the left.
......@@ -5,7 +16,6 @@
2004-09-22 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-types.h
* app/plug-in/plug-in.[ch]: added struct PlugInProcFrame which
contains the ProcRecord, the proc's GMainLoop and its return
values.
......
......@@ -344,10 +344,16 @@ static void
plug_in_handle_proc_run (PlugIn *plug_in,
GPProcRun *proc_run)
{
const gchar *proc_name = NULL;
ProcRecord *proc_rec;
Argument *args;
Argument *return_vals;
PlugInProcFrame *proc_frame;
const gchar *proc_name = NULL;
ProcRecord *proc_rec;
Argument *args;
Argument *return_vals;
if (plug_in->temp_proc_frames)
proc_frame = plug_in->temp_proc_frames->data;
else
proc_frame = &plug_in->main_proc_frame;
proc_rec = procedural_db_lookup (plug_in->gimp, proc_run->name);
......@@ -382,7 +388,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, plug_in->context,
return_vals = procedural_db_execute (plug_in->gimp, proc_frame->context,
plug_in->progress,
proc_name, args);
......
......@@ -129,7 +129,8 @@ gboolean
plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback)
{
ProcRecord *proc_rec;
PlugInProcFrame *proc_frame;
ProcRecord *proc_rec;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
......@@ -147,6 +148,11 @@ plug_in_progress_install (PlugIn *plug_in,
return FALSE;
}
if (plug_in->temp_proc_frames)
proc_frame = plug_in->temp_proc_frames->data;
else
proc_frame = &plug_in->main_proc_frame;
if (plug_in->progress)
{
plug_in_progress_end (plug_in);
......@@ -159,7 +165,7 @@ plug_in_progress_install (PlugIn *plug_in,
}
plug_in->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"context", plug_in->context,
"context", proc_frame->context,
"callback-name", progress_callback,
NULL);
......
......@@ -250,7 +250,6 @@ plug_in_new (Gimp *gimp,
plug_in = g_new0 (PlugIn, 1);
plug_in->gimp = gimp;
plug_in->context = g_object_ref (context);
plug_in->ref_count = 1;
......@@ -277,6 +276,7 @@ plug_in_new (Gimp *gimp,
proc_frame = &plug_in->main_proc_frame;
proc_frame->context = g_object_ref (context);
proc_frame->proc_rec = proc_rec;
proc_frame->main_loop = NULL;
proc_frame->return_vals = NULL;
......@@ -322,7 +322,7 @@ plug_in_unref (PlugIn *plug_in)
if (plug_in->progress)
g_object_unref (plug_in->progress);
g_object_unref (plug_in->context);
g_object_unref (plug_in->main_proc_frame.context);
g_free (plug_in);
}
......@@ -868,16 +868,19 @@ plug_in_pop (Gimp *gimp)
}
void
plug_in_proc_frame_push (PlugIn *plug_in,
ProcRecord *proc_rec)
plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
ProcRecord *proc_rec)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (proc_rec != NULL);
proc_frame = g_new0 (PlugInProcFrame, 1);
proc_frame->context = g_object_ref (context);
proc_frame->proc_rec = proc_rec;
plug_in->temp_proc_frames = g_list_prepend (plug_in->temp_proc_frames,
......@@ -897,6 +900,7 @@ plug_in_proc_frame_pop (PlugIn *plug_in)
plug_in->temp_proc_frames = g_list_remove (plug_in->temp_proc_frames,
proc_frame);
g_object_unref (proc_frame->context);
g_free (proc_frame);
}
......
......@@ -28,16 +28,16 @@
struct _PlugInProcFrame
{
ProcRecord *proc_rec;
GMainLoop *main_loop;
Argument *return_vals;
gint n_return_vals;
GimpContext *context;
ProcRecord *proc_rec;
GMainLoop *main_loop;
Argument *return_vals;
gint n_return_vals;
};
struct _PlugIn
{
Gimp *gimp;
GimpContext *context;
gint ref_count;
......@@ -104,6 +104,7 @@ void plug_in_push (Gimp *gimp,
void plug_in_pop (Gimp *gimp);
void plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
ProcRecord *proc_rec);
void plug_in_proc_frame_pop (PlugIn *plug_in);
......
......@@ -50,6 +50,7 @@
/* local function prototypes */
static Argument * plug_in_temp_run (ProcRecord *proc_rec,
GimpContext *context,
GimpProgress *progress,
Argument *args,
gint argc);
......@@ -81,7 +82,7 @@ plug_in_run (Gimp *gimp,
if (proc_rec->proc_type == GIMP_TEMPORARY)
{
return_vals = plug_in_temp_run (proc_rec, progress, args, argc);
return_vals = plug_in_temp_run (proc_rec, context, progress, args, argc);
goto done;
}
......@@ -235,6 +236,7 @@ plug_in_repeat (Gimp *gimp,
static Argument *
plug_in_temp_run (ProcRecord *proc_rec,
GimpContext *context,
GimpProgress *progress,
Argument *args,
gint argc)
......@@ -248,7 +250,7 @@ plug_in_temp_run (ProcRecord *proc_rec,
{
GPProcRun proc_run;
plug_in_proc_frame_push (plug_in, proc_rec);
plug_in_proc_frame_push (plug_in, context, proc_rec);
proc_run.name = proc_rec->name;
proc_run.nparams = argc;
......
......@@ -50,6 +50,7 @@
/* local function prototypes */
static Argument * plug_in_temp_run (ProcRecord *proc_rec,
GimpContext *context,
GimpProgress *progress,
Argument *args,
gint argc);
......@@ -81,7 +82,7 @@ plug_in_run (Gimp *gimp,
if (proc_rec->proc_type == GIMP_TEMPORARY)
{
return_vals = plug_in_temp_run (proc_rec, progress, args, argc);
return_vals = plug_in_temp_run (proc_rec, context, progress, args, argc);
goto done;
}
......@@ -235,6 +236,7 @@ plug_in_repeat (Gimp *gimp,
static Argument *
plug_in_temp_run (ProcRecord *proc_rec,
GimpContext *context,
GimpProgress *progress,
Argument *args,
gint argc)
......@@ -248,7 +250,7 @@ plug_in_temp_run (ProcRecord *proc_rec,
{
GPProcRun proc_run;
plug_in_proc_frame_push (plug_in, proc_rec);
plug_in_proc_frame_push (plug_in, context, proc_rec);
proc_run.name = proc_rec->name;
proc_run.nparams = argc;
......
......@@ -344,10 +344,16 @@ static void
plug_in_handle_proc_run (PlugIn *plug_in,
GPProcRun *proc_run)
{
const gchar *proc_name = NULL;
ProcRecord *proc_rec;
Argument *args;
Argument *return_vals;
PlugInProcFrame *proc_frame;
const gchar *proc_name = NULL;
ProcRecord *proc_rec;
Argument *args;
Argument *return_vals;
if (plug_in->temp_proc_frames)
proc_frame = plug_in->temp_proc_frames->data;
else
proc_frame = &plug_in->main_proc_frame;
proc_rec = procedural_db_lookup (plug_in->gimp, proc_run->name);
......@@ -382,7 +388,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, plug_in->context,
return_vals = procedural_db_execute (plug_in->gimp, proc_frame->context,
plug_in->progress,
proc_name, args);
......
......@@ -129,7 +129,8 @@ gboolean
plug_in_progress_install (PlugIn *plug_in,
const gchar *progress_callback)
{
ProcRecord *proc_rec;
PlugInProcFrame *proc_frame;
ProcRecord *proc_rec;
g_return_val_if_fail (plug_in != NULL, FALSE);
g_return_val_if_fail (progress_callback != NULL, FALSE);
......@@ -147,6 +148,11 @@ plug_in_progress_install (PlugIn *plug_in,
return FALSE;
}
if (plug_in->temp_proc_frames)
proc_frame = plug_in->temp_proc_frames->data;
else
proc_frame = &plug_in->main_proc_frame;
if (plug_in->progress)
{
plug_in_progress_end (plug_in);
......@@ -159,7 +165,7 @@ plug_in_progress_install (PlugIn *plug_in,
}
plug_in->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"context", plug_in->context,
"context", proc_frame->context,
"callback-name", progress_callback,
NULL);
......
......@@ -50,6 +50,7 @@
/* local function prototypes */
static Argument * plug_in_temp_run (ProcRecord *proc_rec,
GimpContext *context,
GimpProgress *progress,
Argument *args,
gint argc);
......@@ -81,7 +82,7 @@ plug_in_run (Gimp *gimp,
if (proc_rec->proc_type == GIMP_TEMPORARY)
{
return_vals = plug_in_temp_run (proc_rec, progress, args, argc);
return_vals = plug_in_temp_run (proc_rec, context, progress, args, argc);
goto done;
}
......@@ -235,6 +236,7 @@ plug_in_repeat (Gimp *gimp,
static Argument *
plug_in_temp_run (ProcRecord *proc_rec,
GimpContext *context,
GimpProgress *progress,
Argument *args,
gint argc)
......@@ -248,7 +250,7 @@ plug_in_temp_run (ProcRecord *proc_rec,
{
GPProcRun proc_run;
plug_in_proc_frame_push (plug_in, proc_rec);
plug_in_proc_frame_push (plug_in, context, proc_rec);
proc_run.name = proc_rec->name;
proc_run.nparams = argc;
......
......@@ -250,7 +250,6 @@ plug_in_new (Gimp *gimp,
plug_in = g_new0 (PlugIn, 1);
plug_in->gimp = gimp;
plug_in->context = g_object_ref (context);
plug_in->ref_count = 1;
......@@ -277,6 +276,7 @@ plug_in_new (Gimp *gimp,
proc_frame = &plug_in->main_proc_frame;
proc_frame->context = g_object_ref (context);
proc_frame->proc_rec = proc_rec;
proc_frame->main_loop = NULL;
proc_frame->return_vals = NULL;
......@@ -322,7 +322,7 @@ plug_in_unref (PlugIn *plug_in)
if (plug_in->progress)
g_object_unref (plug_in->progress);
g_object_unref (plug_in->context);
g_object_unref (plug_in->main_proc_frame.context);
g_free (plug_in);
}
......@@ -868,16 +868,19 @@ plug_in_pop (Gimp *gimp)
}
void
plug_in_proc_frame_push (PlugIn *plug_in,
ProcRecord *proc_rec)
plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
ProcRecord *proc_rec)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (proc_rec != NULL);
proc_frame = g_new0 (PlugInProcFrame, 1);
proc_frame->context = g_object_ref (context);
proc_frame->proc_rec = proc_rec;
plug_in->temp_proc_frames = g_list_prepend (plug_in->temp_proc_frames,
......@@ -897,6 +900,7 @@ plug_in_proc_frame_pop (PlugIn *plug_in)
plug_in->temp_proc_frames = g_list_remove (plug_in->temp_proc_frames,
proc_frame);
g_object_unref (proc_frame->context);
g_free (proc_frame);
}
......
......@@ -28,16 +28,16 @@
struct _PlugInProcFrame
{
ProcRecord *proc_rec;
GMainLoop *main_loop;
Argument *return_vals;
gint n_return_vals;
GimpContext *context;
ProcRecord *proc_rec;
GMainLoop *main_loop;
Argument *return_vals;
gint n_return_vals;
};
struct _PlugIn
{
Gimp *gimp;
GimpContext *context;
gint ref_count;
......@@ -104,6 +104,7 @@ void plug_in_push (Gimp *gimp,
void plug_in_pop (Gimp *gimp);
void plug_in_proc_frame_push (PlugIn *plug_in,
GimpContext *context,
ProcRecord *proc_rec);
void plug_in_proc_frame_pop (PlugIn *plug_in);
......
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