libgimp: make GimpProcBrowserDialog work both with the old and new API.

The dialog was still calling the old API gimp_pdb_query() everywhere,
which made it fail to run when called with the new API (e.g. from the
Python console or directly from an action) whereas it worked well when
called from the old API (e.g. from the Script-fu console). By testing
the existence of the GimpPDB singleton, we can have this dialog work in
both cases.
This commit is contained in:
Jehan 2019-08-09 02:32:52 +02:00
parent 4cef17c7cf
commit d28af77fc2

View file

@ -381,8 +381,13 @@ browser_search (GimpBrowser *browser,
case SEARCH_TYPE_ALL:
gimp_browser_show_message (browser, _("Searching"));
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
if (gimp_get_plug_in ())
proc_list = gimp_pdb_query_procedures (gimp_get_pdb (),
".*", ".*", ".*", ".*", ".*",
".*", ".*", ".*", &num_procs);
else
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
break;
case SEARCH_TYPE_NAME:
@ -402,9 +407,14 @@ browser_search (GimpBrowser *browser,
q++;
}
gimp_pdb_query (query->str,
".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
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);
g_string_free (query, TRUE);
}
@ -413,43 +423,73 @@ browser_search (GimpBrowser *browser,
case SEARCH_TYPE_BLURB:
gimp_browser_show_message (browser, _("Searching by description"));
gimp_pdb_query (".*", query_text, ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
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);
break;
case SEARCH_TYPE_HELP:
gimp_browser_show_message (browser, _("Searching by help"));
gimp_pdb_query (".*", ".*", query_text, ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
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);
break;
case SEARCH_TYPE_AUTHOR:
gimp_browser_show_message (browser, _("Searching by author"));
gimp_pdb_query (".*", ".*", ".*", query_text, ".*", ".*", ".*",
&num_procs, &proc_list);
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);
break;
case SEARCH_TYPE_COPYRIGHT:
gimp_browser_show_message (browser, _("Searching by copyright"));
gimp_pdb_query (".*", ".*", ".*", ".*", query_text, ".*", ".*",
&num_procs, &proc_list);
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);
break;
case SEARCH_TYPE_DATE:
gimp_browser_show_message (browser, _("Searching by date"));
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", query_text, ".*",
&num_procs, &proc_list);
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);
break;
case SEARCH_TYPE_PROC_TYPE:
gimp_browser_show_message (browser, _("Searching by type"));
gimp_pdb_query (".*", ".*", ".*", ".*", ".*", ".*", query_text,
&num_procs, &proc_list);
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);
break;
}