mirror of https://github.com/GNOME/gimp.git
libgimp: change GimpPlugIn and GimpProcedures so temp procs work
This commit is contained in:
parent
0a02855a59
commit
d64c0ebd30
|
@ -2699,7 +2699,7 @@ gimp_temp_proc_run (GPProcRun *proc_run)
|
|||
{
|
||||
GimpProcedure *procedure;
|
||||
|
||||
procedure = gimp_plug_in_get_procedure (PLUG_IN, proc_run->name);
|
||||
procedure = gimp_plug_in_get_temp_procedure (PLUG_IN, proc_run->name);
|
||||
|
||||
if (procedure)
|
||||
{
|
||||
|
|
|
@ -619,13 +619,13 @@ EXPORTS
|
|||
gimp_patterns_set_popup
|
||||
gimp_pencil
|
||||
gimp_plug_in_add_menu_branch
|
||||
gimp_plug_in_add_procedure
|
||||
gimp_plug_in_add_temp_procedure
|
||||
gimp_plug_in_create_procedure
|
||||
gimp_plug_in_get_procedure
|
||||
gimp_plug_in_get_procedures
|
||||
gimp_plug_in_get_temp_procedure
|
||||
gimp_plug_in_get_temp_procedures
|
||||
gimp_plug_in_get_type
|
||||
gimp_plug_in_info_set_callbacks
|
||||
gimp_plug_in_remove_procedure
|
||||
gimp_plug_in_remove_temp_procedure
|
||||
gimp_plug_in_set_help_domain
|
||||
gimp_plug_in_set_translation_domain
|
||||
gimp_plugin_domain_register
|
||||
|
@ -660,6 +660,8 @@ EXPORTS
|
|||
gimp_procedure_get_menu_label
|
||||
gimp_procedure_get_menu_paths
|
||||
gimp_procedure_get_name
|
||||
gimp_procedure_get_plug_in
|
||||
gimp_procedure_get_proc_type
|
||||
gimp_procedure_get_return_values
|
||||
gimp_procedure_get_type
|
||||
gimp_procedure_new
|
||||
|
|
|
@ -34,8 +34,6 @@ struct _GimpPlugInMenuBranch
|
|||
|
||||
struct _GimpPlugInPrivate
|
||||
{
|
||||
GList *procedures;
|
||||
|
||||
gchar *translation_domain_name;
|
||||
GFile *translation_domain_path;
|
||||
|
||||
|
@ -43,6 +41,8 @@ struct _GimpPlugInPrivate
|
|||
GFile *help_domain_uri;
|
||||
|
||||
GList *menu_branches;
|
||||
|
||||
GList *temp_procedures;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "gimp.h"
|
||||
#include "gimpplugin-private.h"
|
||||
#include "gimpprocedure-private.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -66,10 +67,10 @@ gimp_plug_in_finalize (GObject *object)
|
|||
GimpPlugIn *plug_in = GIMP_PLUG_IN (object);
|
||||
GList *list;
|
||||
|
||||
if (plug_in->priv->procedures)
|
||||
if (plug_in->priv->temp_procedures)
|
||||
{
|
||||
g_list_free_full (plug_in->priv->procedures, g_object_unref);
|
||||
plug_in->priv->procedures = NULL;
|
||||
g_list_free_full (plug_in->priv->temp_procedures, g_object_unref);
|
||||
plug_in->priv->temp_procedures = NULL;
|
||||
}
|
||||
|
||||
g_clear_pointer (&plug_in->priv->translation_domain_name, g_free);
|
||||
|
@ -160,53 +161,57 @@ gimp_plug_in_create_procedure (GimpPlugIn *plug_in,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_add_procedure (GimpPlugIn *plug_in,
|
||||
GimpProcedure *procedure)
|
||||
gimp_plug_in_add_temp_procedure (GimpPlugIn *plug_in,
|
||||
GimpProcedure *procedure)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
||||
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
|
||||
|
||||
plug_in->priv->procedures = g_list_prepend (plug_in->priv->procedures,
|
||||
g_object_ref (procedure));
|
||||
plug_in->priv->temp_procedures = g_list_prepend (plug_in->priv->temp_procedures,
|
||||
g_object_ref (procedure));
|
||||
|
||||
_gimp_procedure_register (procedure);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_remove_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
gimp_plug_in_remove_temp_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpProcedure *procedure;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
procedure = gimp_plug_in_get_procedure (plug_in, name);
|
||||
procedure = gimp_plug_in_get_temp_procedure (plug_in, name);
|
||||
|
||||
if (procedure)
|
||||
{
|
||||
plug_in->priv->procedures = g_list_remove (plug_in->priv->procedures,
|
||||
procedure);
|
||||
_gimp_procedure_unregister (procedure);
|
||||
|
||||
plug_in->priv->temp_procedures = g_list_remove (plug_in->priv->temp_procedures,
|
||||
procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
gimp_plug_in_get_procedures (GimpPlugIn *plug_in)
|
||||
gimp_plug_in_get_temp_procedures (GimpPlugIn *plug_in)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
||||
|
||||
return plug_in->priv->procedures;
|
||||
return plug_in->priv->temp_procedures;
|
||||
}
|
||||
|
||||
GimpProcedure *
|
||||
gimp_plug_in_get_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
gimp_plug_in_get_temp_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
for (list = plug_in->priv->procedures; list; list = g_list_next (list))
|
||||
for (list = plug_in->priv->temp_procedures; list; list = g_list_next (list))
|
||||
{
|
||||
GimpProcedure *procedure = list->data;
|
||||
|
||||
|
|
|
@ -90,13 +90,13 @@ void gimp_plug_in_add_menu_branch (GimpPlugIn *plug_in,
|
|||
GimpProcedure * gimp_plug_in_create_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
void gimp_plug_in_add_procedure (GimpPlugIn *plug_in,
|
||||
void gimp_plug_in_add_temp_procedure (GimpPlugIn *plug_in,
|
||||
GimpProcedure *procedure);
|
||||
void gimp_plug_in_remove_procedure (GimpPlugIn *plug_in,
|
||||
void gimp_plug_in_remove_temp_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
GList * gimp_plug_in_get_procedures (GimpPlugIn *plug_in);
|
||||
GimpProcedure * gimp_plug_in_get_procedure (GimpPlugIn *plug_in,
|
||||
GList * gimp_plug_in_get_temp_procedures (GimpPlugIn *plug_in);
|
||||
GimpProcedure * gimp_plug_in_get_temp_procedure (GimpPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
|
||||
|
|
|
@ -34,13 +34,14 @@
|
|||
#include "gimpprocedure-private.h"
|
||||
|
||||
|
||||
extern GIOChannel *_writechannel;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
_gimp_procedure_register (GimpProcedure *procedure)
|
||||
{
|
||||
extern GIOChannel *_writechannel;
|
||||
|
||||
GParamSpec **args;
|
||||
GParamSpec **return_vals;
|
||||
gint n_args;
|
||||
|
@ -65,7 +66,7 @@ _gimp_procedure_register (GimpProcedure *procedure)
|
|||
proc_install.date = (gchar *) gimp_procedure_get_date (procedure);
|
||||
proc_install.menu_label = (gchar *) gimp_procedure_get_menu_label (procedure);
|
||||
proc_install.image_types = (gchar *) gimp_procedure_get_image_types (procedure);
|
||||
proc_install.type = GIMP_PLUGIN;
|
||||
proc_install.type = gimp_procedure_get_proc_type (procedure);
|
||||
proc_install.nparams = n_args;
|
||||
proc_install.nreturn_vals = n_return_vals;
|
||||
proc_install.params = g_new0 (GPParamDef, n_args);
|
||||
|
@ -103,3 +104,14 @@ _gimp_procedure_register (GimpProcedure *procedure)
|
|||
list->data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gimp_procedure_unregister (GimpProcedure *procedure)
|
||||
{
|
||||
GPProcUninstall proc_uninstall;
|
||||
|
||||
proc_uninstall.name = (gchar *) gimp_procedure_get_name (procedure);
|
||||
|
||||
if (! gp_proc_uninstall_write (_writechannel, &proc_uninstall, NULL))
|
||||
gimp_quit ();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
void _gimp_procedure_register (GimpProcedure *procedure);
|
||||
void _gimp_procedure_register (GimpProcedure *procedure);
|
||||
void _gimp_procedure_unregister (GimpProcedure *procedure);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -51,6 +51,9 @@ gimp_pdb_error_quark (void)
|
|||
|
||||
struct _GimpProcedurePrivate
|
||||
{
|
||||
GimpPlugIn *plug_in; /* the procedure's plug-in */
|
||||
GimpPDBProcType proc_type; /* procedure type */
|
||||
|
||||
gchar *name; /* procedure name */
|
||||
gchar *menu_label;
|
||||
gchar *blurb; /* Short procedure description */
|
||||
|
@ -113,6 +116,7 @@ gimp_procedure_finalize (GObject *object)
|
|||
GimpProcedure *procedure = GIMP_PROCEDURE (object);
|
||||
gint i;
|
||||
|
||||
g_clear_object (&procedure->priv->plug_in);
|
||||
g_clear_pointer (&procedure->priv->name, g_free);
|
||||
|
||||
gimp_procedure_free_strings (procedure);
|
||||
|
@ -146,22 +150,44 @@ gimp_procedure_finalize (GObject *object)
|
|||
/* public functions */
|
||||
|
||||
GimpProcedure *
|
||||
gimp_procedure_new (const gchar *name,
|
||||
GimpRunFunc run_func)
|
||||
gimp_procedure_new (GimpPlugIn *plug_in,
|
||||
const gchar *name,
|
||||
GimpPDBProcType proc_type,
|
||||
GimpRunFunc run_func)
|
||||
{
|
||||
GimpProcedure *procedure;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (proc_type != GIMP_INTERNAL, NULL);
|
||||
g_return_val_if_fail (run_func != NULL, NULL);
|
||||
|
||||
procedure = g_object_new (GIMP_TYPE_PROCEDURE, NULL);
|
||||
|
||||
procedure->priv->name = g_strdup (name);
|
||||
procedure->priv->run_func = run_func;
|
||||
procedure->priv->plug_in = g_object_ref (plug_in);
|
||||
procedure->priv->proc_type = proc_type;
|
||||
procedure->priv->name = g_strdup (name);
|
||||
procedure->priv->run_func = run_func;
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
GimpPlugIn *
|
||||
gimp_procedure_get_plug_in (GimpProcedure *procedure)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
|
||||
|
||||
return procedure->priv->plug_in;
|
||||
}
|
||||
|
||||
GimpPDBProcType
|
||||
gimp_procedure_get_proc_type (GimpProcedure *procedure)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), GIMP_PLUGIN);
|
||||
|
||||
return procedure->priv->proc_type;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_procedure_set_strings (GimpProcedure *procedure,
|
||||
const gchar *menu_label,
|
||||
|
|
|
@ -58,9 +58,14 @@ struct _GimpProcedureClass
|
|||
|
||||
GType gimp_procedure_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpProcedure * gimp_procedure_new (const gchar *name,
|
||||
GimpProcedure * gimp_procedure_new (GimpPlugIn *plug_in,
|
||||
const gchar *name,
|
||||
GimpPDBProcType proc_type,
|
||||
GimpRunFunc run_func);
|
||||
|
||||
GimpPlugIn * gimp_procedure_get_plug_in (GimpProcedure *procedure);
|
||||
GimpPDBProcType gimp_procedure_get_proc_type (GimpProcedure *procedure);
|
||||
|
||||
void gimp_procedure_set_strings (GimpProcedure *procedure,
|
||||
const gchar *menu_label,
|
||||
const gchar *blurb,
|
||||
|
|
Loading…
Reference in New Issue