libgimp: move _gimp_read_expect_msg() back to gimp.c

and make it distinguish between old and new plug-in running.
This commit is contained in:
Michael Natterer 2019-08-02 18:26:52 +02:00
parent 856fe16070
commit 366047f423
5 changed files with 50 additions and 43 deletions

View File

@ -36,6 +36,7 @@ void _gimp_config (GPConfig *config);
void _gimp_loop (GimpRunProc run_proc); void _gimp_loop (GimpRunProc run_proc);
void _gimp_read_expect_msg (GimpWireMessage *msg, void _gimp_read_expect_msg (GimpWireMessage *msg,
gint type); gint type);
void _gimp_process_message (GimpWireMessage *msg);
G_END_DECLS G_END_DECLS

View File

@ -801,6 +801,38 @@ gimp_quit (void)
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }
void
_gimp_read_expect_msg (GimpWireMessage *msg,
gint type)
{
while (TRUE)
{
if (! gimp_wire_read_msg (_gimp_readchannel, msg, NULL))
gimp_quit ();
if (msg->type == type)
return; /* up to the caller to call wire_destroy() */
if (msg->type == GP_TEMP_PROC_RUN || msg->type == GP_QUIT)
{
if (PLUG_IN)
{
_gimp_plug_in_process_message (PLUG_IN, msg);
}
else
{
_gimp_process_message (msg);
}
}
else
{
g_error ("unexpected message: %d", msg->type);
}
gimp_wire_destroy (msg);
}
}
GimpValueArray * GimpValueArray *
gimp_run_procedure_with_array (const gchar *name, gimp_run_procedure_with_array (const gchar *name,
GimpValueArray *arguments) GimpValueArray *arguments)

View File

@ -48,7 +48,6 @@
static gpointer gimp_param_copy (gpointer boxed); static gpointer gimp_param_copy (gpointer boxed);
static void gimp_param_free (gpointer boxed); static void gimp_param_free (gpointer boxed);
static void gimp_process_message (GimpWireMessage *msg);
static void gimp_single_message (void); static void gimp_single_message (void);
static gboolean gimp_extension_read (GIOChannel *channel, static gboolean gimp_extension_read (GIOChannel *channel,
GIOCondition condition, GIOCondition condition,
@ -589,31 +588,6 @@ gimp_extension_process (guint timeout)
#endif #endif
} }
void
_gimp_read_expect_msg (GimpWireMessage *msg,
gint type)
{
while (TRUE)
{
if (! gimp_wire_read_msg (_gimp_readchannel, msg, NULL))
gimp_quit ();
if (msg->type == type)
return; /* up to the caller to call wire_destroy() */
if (msg->type == GP_TEMP_PROC_RUN || msg->type == GP_QUIT)
{
gimp_process_message (msg);
}
else
{
g_error ("unexpected message: %d", msg->type);
}
gimp_wire_destroy (msg);
}
}
/** /**
* gimp_run_procedure: (skip) * gimp_run_procedure: (skip)
* @name: the name of the procedure to run * @name: the name of the procedure to run
@ -1261,8 +1235,8 @@ gimp_plugin_icon_register (const gchar *procedure_name,
/* private functions */ /* private functions */
static void void
gimp_process_message (GimpWireMessage *msg) _gimp_process_message (GimpWireMessage *msg)
{ {
switch (msg->type) switch (msg->type)
{ {
@ -1307,7 +1281,7 @@ gimp_single_message (void)
if (! gimp_wire_read_msg (_gimp_readchannel, &msg, NULL)) if (! gimp_wire_read_msg (_gimp_readchannel, &msg, NULL))
gimp_quit (); gimp_quit ();
gimp_process_message (&msg); _gimp_process_message (&msg);
gimp_wire_destroy (&msg); gimp_wire_destroy (&msg);
} }

View File

@ -36,8 +36,6 @@
static void gimp_plug_in_register (GimpPlugIn *plug_in, static void gimp_plug_in_register (GimpPlugIn *plug_in,
gboolean init); gboolean init);
static void gimp_plug_in_loop (GimpPlugIn *plug_in); static void gimp_plug_in_loop (GimpPlugIn *plug_in);
static void gimp_plug_in_process_message (GimpPlugIn *plug_in,
GimpWireMessage *msg);
static void gimp_plug_in_proc_run (GimpPlugIn *plug_in, static void gimp_plug_in_proc_run (GimpPlugIn *plug_in,
GPProcRun *proc_run); GPProcRun *proc_run);
static void gimp_plug_in_temp_proc_run (GimpPlugIn *plug_in, static void gimp_plug_in_temp_proc_run (GimpPlugIn *plug_in,
@ -233,14 +231,14 @@ _gimp_plug_in_single_message (GimpPlugIn *plug_in)
if (! gimp_wire_read_msg (_gimp_readchannel, &msg, NULL)) if (! gimp_wire_read_msg (_gimp_readchannel, &msg, NULL))
gimp_quit (); gimp_quit ();
gimp_plug_in_process_message (plug_in, &msg); _gimp_plug_in_process_message (plug_in, &msg);
gimp_wire_destroy (&msg); gimp_wire_destroy (&msg);
} }
static void void
gimp_plug_in_process_message (GimpPlugIn *plug_in, _gimp_plug_in_process_message (GimpPlugIn *plug_in,
GimpWireMessage *msg) GimpWireMessage *msg)
{ {
switch (msg->type) switch (msg->type)
{ {

View File

@ -49,15 +49,17 @@ struct _GimpPlugInPrivate
}; };
void _gimp_plug_in_query (GimpPlugIn *plug_in); void _gimp_plug_in_query (GimpPlugIn *plug_in);
void _gimp_plug_in_init (GimpPlugIn *plug_in); void _gimp_plug_in_init (GimpPlugIn *plug_in);
void _gimp_plug_in_run (GimpPlugIn *plug_in); void _gimp_plug_in_run (GimpPlugIn *plug_in);
void _gimp_plug_in_quit (GimpPlugIn *plug_in); void _gimp_plug_in_quit (GimpPlugIn *plug_in);
gboolean _gimp_plug_in_extension_read (GIOChannel *channel, gboolean _gimp_plug_in_extension_read (GIOChannel *channel,
GIOCondition condition, GIOCondition condition,
gpointer data); gpointer data);
void _gimp_plug_in_single_message (GimpPlugIn *plug_in); void _gimp_plug_in_single_message (GimpPlugIn *plug_in);
void _gimp_plug_in_process_message (GimpPlugIn *plug_in,
GimpWireMessage *msg);
G_END_DECLS G_END_DECLS