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



commit d28af77fc254d72397de69eeda96800aba15cedf
Author: Jehan <jehan girinstud io>
Date:   Fri Aug 9 02:32:52 2019 +0200

    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.

 libgimp/gimpprocbrowserdialog.c | 74 +++++++++++++++++++++++++++++++----------
 1 file changed, 57 insertions(+), 17 deletions(-)
---
diff --git a/libgimp/gimpprocbrowserdialog.c b/libgimp/gimpprocbrowserdialog.c
index 86945fa365..9125cd65ef 100644
--- a/libgimp/gimpprocbrowserdialog.c
+++ b/libgimp/gimpprocbrowserdialog.c
@@ -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;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]