Commit 79d92a5d authored by Michael Natterer's avatar Michael Natterer 😴

libgimp: remove a lot of cruft because script-fu is ported now

Also remove all legacy code from GimpProcView and
GimpProcBrowserDialog.
parent 103a7e4f
Pipeline #104019 passed with stages
in 16 minutes and 26 seconds
......@@ -638,11 +638,7 @@ EXPORTS
gimp_pdb_get_last_status
gimp_pdb_get_type
gimp_pdb_lookup_procedure
gimp_pdb_proc_argument
gimp_pdb_proc_info
gimp_pdb_proc_return_value
gimp_pdb_procedure_exists
gimp_pdb_query
gimp_pdb_query_procedures
gimp_pdb_run_procedure
gimp_pdb_run_procedure_array
......
......@@ -1514,156 +1514,6 @@ gimp_pdb_temp_name (void)
return _gimp_pdb_temp_name ();
}
/**
* gimp_pdb_query:
* @name: The regex for procedure name.
* @blurb: The regex for procedure blurb.
* @help: The regex for procedure help.
* @authors: The regex for procedure authors.
* @copyright: The regex for procedure copyright.
* @date: The regex for procedure date.
* @proc_type: The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension', 'Temporary Procedure' }.
* @num_matches: (out): The number of matching procedures.
* @procedure_names: (out) (array length=num_matches) (element-type gchar*) (transfer full): The list of procedure names.
*
* Queries the procedural database for its contents using regular
* expression matching.
*
* This procedure queries the contents of the procedural database. It
* is supplied with seven arguments matching procedures on { name,
* blurb, help, authors, copyright, date, procedure type}. This is
* accomplished using regular expression matching. For instance, to
* find all procedures with \"jpeg\" listed in the blurb, all seven
* arguments can be supplied as \".*\", except for the second, which
* can be supplied as \".*jpeg.*\". There are two return arguments for
* this procedure. The first is the number of procedures matching the
* query. The second is a concatenated list of procedure names
* corresponding to those matching the query. If no matching entries
* are found, then the returned string is NULL and the number of
* entries is 0.
*
* Returns: TRUE on success.
**/
gboolean
gimp_pdb_query (const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *authors,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gint *num_matches,
gchar ***procedure_names)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
return _gimp_pdb_query (name,
blurb, help,
authors, copyright, date,
proc_type,
num_matches, procedure_names);
}
/**
* gimp_pdb_proc_info:
* @procedure_name: The procedure name.
* @blurb: A short blurb.
* @help: Detailed procedure help.
* @authors: Authors of the procedure.
* @copyright: The copyright.
* @date: Copyright date.
* @proc_type: The procedure type.
* @num_args: The number of input arguments.
* @num_values: The number of return values.
* @args: The input arguments.
* @return_vals: The return values.
*
* Queries the procedural database for information on the specified
* procedure.
*
* This procedure returns information on the specified procedure. A
* short blurb, detailed help, authors, copyright information,
* procedure type, number of input, and number of return values are
* returned. Additionally this function returns specific information
* about each input argument and return value.
*
* Returns: TRUE on success.
*/
gboolean
gimp_pdb_proc_info (const gchar *procedure_name,
gchar **blurb,
gchar **help,
gchar **authors,
gchar **copyright,
gchar **date,
GimpPDBProcType *proc_type,
gint *num_args,
gint *num_values,
GimpParamDef **args,
GimpParamDef **return_vals)
{
gint i;
gboolean success = TRUE;
success = _gimp_pdb_proc_info (procedure_name,
blurb,
help,
authors,
copyright,
date,
proc_type,
num_args,
num_values);
if (success)
{
*args = g_new0 (GimpParamDef, *num_args);
*return_vals = g_new0 (GimpParamDef, *num_values);
for (i = 0; i < *num_args; i++)
{
GParamSpec *pspec = gimp_pdb_proc_argument (procedure_name, i);
GimpParamDef *arg = &(*args)[i];
if (! pspec)
{
g_free (*args);
g_free (*return_vals);
return FALSE;
}
arg->type = _gimp_pdb_gtype_to_arg_type (pspec->value_type);
arg->name = g_strdup (g_param_spec_get_name (pspec));
arg->description = g_strdup (g_param_spec_get_blurb (pspec));
g_param_spec_unref (pspec);
}
for (i = 0; i < *num_values; i++)
{
GParamSpec *pspec = gimp_pdb_proc_return_value (procedure_name, i);
GimpParamDef *val = &(*return_vals)[i];
if (! pspec)
{
g_free (*args);
g_free (*return_vals);
return FALSE;
}
val->type = _gimp_pdb_gtype_to_arg_type (pspec->value_type);
val->name = g_strdup (g_param_spec_get_name (pspec));
val->description = g_strdup (g_param_spec_get_blurb (pspec));
g_param_spec_unref (pspec);
}
}
return success;
}
/* private functions */
......
......@@ -377,27 +377,7 @@ gboolean gimp_register_thumbnail_loader (const gchar *load_proc,
/* pdb stuff that should now be done using GimpPDB
*/
gchar * gimp_pdb_temp_name (void);
gboolean gimp_pdb_query (const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *authors,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gint *num_matches,
gchar ***procedure_names);
gboolean gimp_pdb_proc_info (const gchar *procedure_name,
gchar **blurb,
gchar **help,
gchar **authors,
gchar **copyright,
gchar **date,
GimpPDBProcType *proc_type,
gint *num_args,
gint *num_values,
GimpParamDef **args,
GimpParamDef **return_vals);
gchar * gimp_pdb_temp_name (void);
#endif /* GIMP_DISABLE_COMPAT_CRUFT */
......
......@@ -447,51 +447,6 @@ _gimp_pdb_error_quark (void)
/* Temporary API, to go away before 3.0 */
/**
* gimp_pdb_proc_argument:
* @procedure_name: The procedure name.
* @arg_num: The argument number.
*
* Queries the procedural database for information on the specified
* procedure's argument.
*
* This procedure returns the #GParamSpec of procedure_name's argument.
*
* Returns: (transfer full): The GParamSpec of the argument.
* The returned value must be freed with g_param_spec_unref().
*
* Since: 3.0
**/
GParamSpec *
gimp_pdb_proc_argument (const gchar *procedure_name,
gint arg_num)
{
return _gimp_pdb_proc_argument (procedure_name, arg_num);
}
/**
* gimp_pdb_proc_return_value:
* @procedure_name: The procedure name.
* @val_num: The return value number.
*
* Queries the procedural database for information on the specified
* procedure's return value.
*
* This procedure returns the #GParamSpec of procedure_name's return
* value.
*
* Returns: (transfer full): The GParamSpec of the return value.
* The returned value must be freed with g_param_spec_unref().
*
* Since: 3.0
**/
GParamSpec *
gimp_pdb_proc_return_value (const gchar *procedure_name,
gint val_num)
{
return _gimp_pdb_proc_return_value (procedure_name, val_num);
}
/**
* gimp_pdb_get_last_error:
* @pdb: a #GimpPDB.
......
......@@ -103,12 +103,6 @@ gchar ** gimp_pdb_query_procedures (GimpPDB *pdb,
const gchar * gimp_pdb_get_last_error (GimpPDB *pdb);
GimpPDBStatusType gimp_pdb_get_last_status (GimpPDB *pdb);
/* Temporary API, to go away before 3.0 */
GParamSpec * gimp_pdb_proc_argument (const gchar *procedure_name,
gint arg_num);
GParamSpec * gimp_pdb_proc_return_value (const gchar *procedure_name,
gint val_num);
/* Cruft API */
......
......@@ -221,14 +221,14 @@ _gimp_pdb_procedure_new (GimpPDB *pdb,
for (i = 0; i < n_params; i++)
{
GParamSpec *pspec = gimp_pdb_proc_argument (name, i);
GParamSpec *pspec = _gimp_pdb_proc_argument (name, i);
gimp_procedure_add_argument (procedure, pspec);
}
for (i = 0; i < n_return_vals; i++)
{
GParamSpec *pspec = gimp_pdb_proc_return_value (name, i);
GParamSpec *pspec = _gimp_pdb_proc_return_value (name, i);
gimp_procedure_add_return_value (procedure, pspec);
}
......
......@@ -353,8 +353,9 @@ browser_search (GimpBrowser *browser,
gint search_type,
GimpProcBrowserDialog *dialog)
{
GimpProcBrowserDialogPrivate *priv = GET_PRIVATE (dialog);
gchar **proc_list;
GimpProcBrowserDialogPrivate *priv = GET_PRIVATE (dialog);
GimpPDB *pdb = gimp_get_pdb ();
gchar **proc_list = NULL;
gint num_procs;
gchar *str;
GRegex *regex;
......@@ -381,13 +382,9 @@ browser_search (GimpBrowser *browser,
case SEARCH_TYPE_ALL:
gimp_browser_show_message (browser, _("Searching"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
else
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", ".*", ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
break;
case SEARCH_TYPE_NAME:
......@@ -407,14 +404,9 @@ browser_search (GimpBrowser *browser,
q++;
}
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
query->str, ".*", ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
else
gimp_pdb_query (query->str,
".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
query->str, ".*", ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
g_string_free (query, TRUE);
}
......@@ -423,73 +415,49 @@ browser_search (GimpBrowser *browser,
case SEARCH_TYPE_BLURB:
gimp_browser_show_message (browser, _("Searching by description"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", query_text, ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
else
gimp_pdb_query (".*", query_text, ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", query_text, ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
break;
case SEARCH_TYPE_HELP:
gimp_browser_show_message (browser, _("Searching by help"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", query_text, ".*", ".*",
".*", ".*", ".*", &num_procs);
else
gimp_pdb_query (".*", ".*", query_text, ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", ".*", query_text, ".*", ".*",
".*", ".*", ".*", &num_procs);
break;
case SEARCH_TYPE_AUTHORS:
gimp_browser_show_message (browser, _("Searching by authors"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", ".*", ".*", query_text,
".*", ".*", ".*", &num_procs);
else
gimp_pdb_query (".*", ".*", ".*", query_text, ".*", ".*", ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", ".*", ".*", ".*", query_text,
".*", ".*", ".*", &num_procs);
break;
case SEARCH_TYPE_COPYRIGHT:
gimp_browser_show_message (browser, _("Searching by copyright"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", ".*", ".*", ".*",
query_text, ".*", ".*", &num_procs);
else
gimp_pdb_query (".*", ".*", ".*", ".*", query_text, ".*", ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", ".*", ".*", ".*", ".*",
query_text, ".*", ".*", &num_procs);
break;
case SEARCH_TYPE_DATE:
gimp_browser_show_message (browser, _("Searching by date"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", ".*", ".*", ".*",
".*", query_text, ".*", &num_procs);
else
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", query_text, ".*",
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", ".*", ".*", ".*", ".*",
".*", query_text, ".*", &num_procs);
break;
case SEARCH_TYPE_PROC_TYPE:
gimp_browser_show_message (browser, _("Searching by type"));
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", ".*", ".*", ".*",
".*", ".*", query_text, &num_procs);
else
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", ".*", query_text,
&num_procs, &proc_list);
proc_list = gimp_pdb_query_procedures (pdb,
".*", ".*", ".*", ".*", ".*",
".*", ".*", query_text, &num_procs);
break;
}
......
......@@ -54,17 +54,11 @@
/* local function prototypes */
static GtkWidget * gimp_proc_view_create_params (const GimpParamDef *params,
gint n_params,
GtkSizeGroup *name_group,
GtkSizeGroup *type_group,
GtkSizeGroup *desc_group);
static GtkWidget * gimp_proc_view_create_args (const gchar *procedure_name,
gint n_args,
gboolean return_values,
GtkSizeGroup *name_group,
GtkSizeGroup *type_group,
GtkSizeGroup *desc_group);
static GtkWidget * gimp_proc_view_create_args (GimpProcedure *procedure,
gboolean return_values,
GtkSizeGroup *name_group,
GtkSizeGroup *type_group,
GtkSizeGroup *desc_group);
/* public functions */
......@@ -84,50 +78,47 @@ GtkWidget *
gimp_proc_view_new (const gchar *procedure_name,
const gchar *menu_path)
{
GimpProcedure *procedure;
GtkWidget *main_vbox;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *grid;
GtkWidget *label;
GtkWidget *notebook;
GtkSizeGroup *name_group;
GtkSizeGroup *type_group;
GtkSizeGroup *desc_group;
gchar *blurb;
gchar *help;
gchar *authors;
gchar *copyright;
gchar *date;
const gchar *blurb;
const gchar *help;
const gchar *help_id;
const gchar *authors;
const gchar *copyright;
const gchar *date;
GimpPDBProcType type;
gint n_params;
gint n_return_vals;
GimpParamDef *params;
GimpParamDef *return_vals;
const gchar *type_str;
gint row;
g_return_val_if_fail (procedure_name != NULL, NULL);
gimp_pdb_proc_info (procedure_name,
&blurb,
&help,
&authors,
&copyright,
&date,
&type,
&n_params,
&n_return_vals,
&params,
&return_vals);
if (blurb && strlen (blurb) < 2) g_clear_pointer (&blurb, g_free);
if (help && strlen (help) < 2) g_clear_pointer (&help, g_free);
if (authors && strlen (authors) < 2) g_clear_pointer (&authors, g_free);
if (date && strlen (date) < 2) g_clear_pointer (&date, g_free);
if (copyright && strlen (copyright) < 2) g_clear_pointer (&copyright, g_free);
procedure = gimp_pdb_lookup_procedure (gimp_get_pdb (),
procedure_name);
type = gimp_procedure_get_proc_type (procedure);
blurb = gimp_procedure_get_blurb (procedure);
help = gimp_procedure_get_help (procedure);
help_id = gimp_procedure_get_help_id (procedure);
authors = gimp_procedure_get_authors (procedure);
copyright = gimp_procedure_get_copyright (procedure);
date = gimp_procedure_get_date (procedure);
if (blurb && strlen (blurb) < 2) blurb = NULL;
if (help && strlen (help) < 2) help = NULL;
if (help_id && strlen (help_id) < 2) help_id = NULL;
if (authors && strlen (authors) < 2) authors = NULL;
if (copyright && strlen (copyright) < 2) copyright = NULL;
if (date && strlen (date) < 2) date = NULL;
if (blurb && help && ! strcmp (blurb, help))
g_clear_pointer (&help, g_free);
help = NULL;
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
......@@ -175,82 +166,34 @@ gimp_proc_view_new (const gchar *procedure_name,
gtk_widget_show (label);
}
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), notebook, FALSE, FALSE, 0);
gtk_widget_show (notebook);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new (_("GValue-based API")));
gtk_widget_show (vbox);
name_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
type_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
desc_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* in parameters */
if (n_params)
{
frame = gimp_frame_new (_("Parameters"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
grid = gimp_proc_view_create_args (procedure_name, n_params, FALSE,
name_group, type_group, desc_group);
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_widget_show (grid);
}
/* out parameters */
if (n_return_vals)
{
frame = gimp_frame_new (_("Return Values"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
grid = gimp_proc_view_create_args (procedure_name, n_return_vals, TRUE,
name_group, type_group, desc_group);
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_widget_show (grid);
}
grid = gimp_proc_view_create_args (procedure, FALSE,
name_group, type_group, desc_group);
g_object_unref (name_group);
g_object_unref (type_group);
g_object_unref (desc_group);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new (_("Legacy API")));
gtk_widget_show (vbox);
name_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
type_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
desc_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* in parameters */
if (n_params)
if (grid)
{
frame = gimp_frame_new (_("Parameters"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
grid = gimp_proc_view_create_params (params, n_params,
name_group, type_group, desc_group);
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_widget_show (grid);
}
/* out parameters */
if (n_return_vals)
grid = gimp_proc_view_create_args (procedure, TRUE,
name_group, type_group, desc_group);
if (grid)
{
frame = gimp_frame_new (_("Return Values"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
grid = gimp_proc_view_create_params (return_vals, n_return_vals,
name_group, type_group, desc_group);
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_widget_show (grid);
}
......@@ -284,7 +227,7 @@ gimp_proc_view_new (const gchar *procedure_name,
/* show the authors & the copyright */
if (! authors && ! date && ! copyright)
goto out;
return main_vbox;
grid = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
......@@ -333,30 +276,6 @@ gimp_proc_view_new (const gchar *procedure_name,
label, 3);
}
out:
g_free (blurb);
g_free (help);
g_free (authors);
g_free (copyright);
g_free (date);
while (n_params--)
{
g_free (params[n_params].name);
g_free (params[n_params].description);
}
g_free (params);
while (n_return_vals--)
{
g_free (return_vals[n_return_vals].name);
g_free (return_vals[n_return_vals].description);
}
g_free (return_vals);
return main_vbox;
}
......@@ -364,92 +283,34 @@ gimp_proc_view_new (const gchar *procedure_name,
/* private functions */
static GtkWidget *
gimp_proc_view_create_params (const GimpParamDef *params,
gint n_params,
GtkSizeGroup *name_group,
GtkSizeGroup *type_group,
GtkSizeGroup *desc_group)
gimp_proc_view_create_args (GimpProcedure *procedure,
gboolean return_values,
GtkSizeGroup *name_group,
GtkSizeGroup *type_group,
GtkSizeGroup *desc_group)
{
GtkWidget *grid;
gint i;
grid = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
for (i = 0; i < n_params; i++)
{
GtkWidget *label;
const gchar *type;
gchar *upper;
/* name */
label = gtk_label_new (params[i].name);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.0);
gtk_size_group_add_widget (name_group, label);
gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1);
gtk_widget_show (label);
/* type */
if (! gimp_enum_get_value (GIMP_TYPE_PDB_ARG_TYPE, params[i].type,
NULL, &type, NULL, NULL))
upper = g_strdup ("UNKNOWN");
else
upper = g_ascii_strup (type, -1);
label = gtk_label_new (upper);
g_free (upper);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_FAMILY, "monospace",
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.0);
gtk_size_group_add_widget (type_group, label);
gtk_grid_attach (GTK_GRID (grid), label, 1, i, 1, 1);
gtk_widget_show (label);
/* description */
label = gtk_label_new (params[i].description);
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.0);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_size_group_add_widget (desc_group, label);
gtk_grid_attach (GTK_GRID (grid), label, 2, i, 1, 1);
gtk_widget_show (label);
}
GtkWidget *grid;
GParamSpec **pspecs;
gint n_pspecs;
gint i;
return grid;
}
if