gimp r25384 - in trunk: . app/pdb libgimp plug-ins/print



Author: neo
Date: Sun Apr  6 21:30:59 2008
New Revision: 25384
URL: http://svn.gnome.org/viewvc/gimp?rev=25384&view=rev

Log:
2008-04-06  Sven Neumann  <sven gimp org>

	* tools/pdbgen/pdb/procedural_db.pdb: added new procedure
	gimp-procedural-db-proc-exists.

	* app/pdb/internal-procs.c
	* app/pdb/procedural-db-cmds.c
	* libgimp/gimpproceduraldb_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.

	* plug-ins/print/print.c (page_setup): use the new procedure.



Modified:
   trunk/ChangeLog
   trunk/app/pdb/internal-procs.c
   trunk/app/pdb/procedural-db-cmds.c
   trunk/libgimp/gimp.def
   trunk/libgimp/gimpproceduraldb_pdb.c
   trunk/libgimp/gimpproceduraldb_pdb.h
   trunk/plug-ins/print/print.c

Modified: trunk/app/pdb/internal-procs.c
==============================================================================
--- trunk/app/pdb/internal-procs.c	(original)
+++ trunk/app/pdb/internal-procs.c	Sun Apr  6 21:30:59 2008
@@ -29,7 +29,7 @@
 #include "internal-procs.h"
 
 
-/* 583 procedures registered total */
+/* 584 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)

Modified: trunk/app/pdb/procedural-db-cmds.c
==============================================================================
--- trunk/app/pdb/procedural-db-cmds.c	(original)
+++ trunk/app/pdb/procedural-db-cmds.c	Sun Apr  6 21:30:59 2008
@@ -129,6 +129,34 @@
 }
 
 static GValueArray *
+procedural_db_proc_exists_invoker (GimpProcedure      *procedure,
+                                   Gimp               *gimp,
+                                   GimpContext        *context,
+                                   GimpProgress       *progress,
+                                   const GValueArray  *args,
+                                   GError            **error)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  const gchar *procedure_name;
+  gboolean exists = FALSE;
+
+  procedure_name = g_value_get_string (&args->values[0]);
+
+  if (success)
+    {
+      exists = (gimp_pdb_lookup_procedure (gimp->pdb, procedure_name) != NULL);
+    }
+
+  return_vals = gimp_procedure_get_return_values (procedure, success);
+
+  if (success)
+    g_value_set_boolean (&return_vals->values[1], exists);
+
+  return return_vals;
+}
+
+static GValueArray *
 procedural_db_proc_info_invoker (GimpProcedure      *procedure,
                                  Gimp               *gimp,
                                  GimpContext        *context,
@@ -550,6 +578,36 @@
   g_object_unref (procedure);
 
   /*
+   * gimp-procedural-db-proc-exists
+   */
+  procedure = gimp_procedure_new (procedural_db_proc_exists_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-procedural-db-proc-exists");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-procedural-db-proc-exists",
+                                     "Checks if the specified procedure exists in the procedural database",
+                                     "This procedure checks if the specified procedure is registered in the procedural database.",
+                                     "Sven Neumann <sven gimp org>",
+                                     "Sven Neumann",
+                                     "2008",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("procedure-name",
+                                                       "procedure name",
+                                                       "The procedure name",
+                                                       FALSE, FALSE, TRUE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_boolean ("exists",
+                                                         "exists",
+                                                         "Whether a procedure of that name is registered",
+                                                         FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-procedural-db-proc-info
    */
   procedure = gimp_procedure_new (procedural_db_proc_info_invoker);

Modified: trunk/libgimp/gimp.def
==============================================================================
--- trunk/libgimp/gimp.def	(original)
+++ trunk/libgimp/gimp.def	Sun Apr  6 21:30:59 2008
@@ -540,6 +540,7 @@
 	gimp_procedural_db_get_data
 	gimp_procedural_db_get_data_size
 	gimp_procedural_db_proc_arg
+	gimp_procedural_db_proc_exists
 	gimp_procedural_db_proc_info
 	gimp_procedural_db_proc_val
 	gimp_procedural_db_query

Modified: trunk/libgimp/gimpproceduraldb_pdb.c
==============================================================================
--- trunk/libgimp/gimpproceduraldb_pdb.c	(original)
+++ trunk/libgimp/gimpproceduraldb_pdb.c	Sun Apr  6 21:30:59 2008
@@ -163,6 +163,39 @@
 }
 
 /**
+ * gimp_procedural_db_proc_exists:
+ * @procedure_name: The procedure name.
+ *
+ * Checks if the specified procedure exists in the procedural database
+ *
+ * This procedure checks if the specified procedure is registered in
+ * the procedural database.
+ *
+ * Returns: Whether a procedure of that name is registered.
+ *
+ * Since: GIMP 2.6
+ */
+gboolean
+gimp_procedural_db_proc_exists (const gchar *procedure_name)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean exists = FALSE;
+
+  return_vals = gimp_run_procedure ("gimp-procedural-db-proc-exists",
+                                    &nreturn_vals,
+                                    GIMP_PDB_STRING, procedure_name,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    exists = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return exists;
+}
+
+/**
  * _gimp_procedural_db_proc_info:
  * @procedure_name: The procedure name.
  * @blurb: A short blurb.

Modified: trunk/libgimp/gimpproceduraldb_pdb.h
==============================================================================
--- trunk/libgimp/gimpproceduraldb_pdb.h	(original)
+++ trunk/libgimp/gimpproceduraldb_pdb.h	Sun Apr  6 21:30:59 2008
@@ -40,6 +40,7 @@
                                                            const gchar       *proc_type,
                                                            gint              *num_matches,
                                                            gchar           ***procedure_names);
+gboolean                 gimp_procedural_db_proc_exists   (const gchar       *procedure_name);
 G_GNUC_INTERNAL gboolean _gimp_procedural_db_proc_info    (const gchar       *procedure_name,
                                                            gchar            **blurb,
                                                            gchar            **help,

Modified: trunk/plug-ins/print/print.c
==============================================================================
--- trunk/plug-ins/print/print.c	(original)
+++ trunk/plug-ins/print/print.c	Sun Apr  6 21:30:59 2008
@@ -294,8 +294,6 @@
 {
   GtkPrintOperation  *operation;
   gchar              *name;
-  gchar             **matches;
-  gint                num_matches;
 
   gimp_ui_init (PLUG_IN_BINARY, FALSE);
 
@@ -310,19 +308,13 @@
   /* now notify a running print procedure about this change */
   name = print_temp_proc_name (image_ID);
 
-  /* FIXME: There should be a better way to query for a procedure.
-   *        Also this code has a race condition. The best solution
+  /* FIXME: This code has a race condition. The best solution
    *        would be to catch the error somehow (see bug #344818).
    */
-  gimp_procedural_db_query (name,
-                            ".*", ".*", ".*", ".*", ".*", ".*",
-                            &num_matches, &matches);
-
-  if (num_matches)
+  if (gimp_procedural_db_proc_exists (name))
     {
       GimpParam *return_vals;
       gint       n_return_vals;
-      gint       i;
 
       return_vals = gimp_run_procedure (name,
                                         &n_return_vals,
@@ -330,11 +322,6 @@
                                         GIMP_PDB_END);
 
       gimp_destroy_params (return_vals, n_return_vals);
-
-      for (i = 0; i < num_matches; i++)
-        g_free (matches[i]);
-
-      g_free (matches);
     }
 
   g_free (name);



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