[gimp] pdb, libgimp: add gimp-item-{get,set}-expanded()



commit 4db000a522bd9ddbb07d11d986a95d5c306a3a5a
Author: Ell <ell_se yahoo com>
Date:   Sun Oct 22 11:59:43 2017 -0400

    pdb, libgimp: add gimp-item-{get,set}-expanded()
    
    ... which call gimp_viewable_{get,set}_expanded()

 app/pdb/internal-procs.c  |    2 +-
 app/pdb/item-cmds.c       |  111 +++++++++++++++++++++++++++++++++++++++++++++
 libgimp/gimp.def          |    2 +
 libgimp/gimpitem_pdb.c    |   66 +++++++++++++++++++++++++++
 libgimp/gimpitem_pdb.h    |    3 +
 tools/pdbgen/pdb/item.pdb |   54 ++++++++++++++++++++++
 6 files changed, 237 insertions(+), 1 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 9083d52..bb09351 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 812 procedures registered total */
+/* 814 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/item-cmds.c b/app/pdb/item-cmds.c
index 2a19e25..bdc1bae 100644
--- a/app/pdb/item-cmds.c
+++ b/app/pdb/item-cmds.c
@@ -445,6 +445,59 @@ item_get_children_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+item_get_expanded_invoker (GimpProcedure         *procedure,
+                           Gimp                  *gimp,
+                           GimpContext           *context,
+                           GimpProgress          *progress,
+                           const GimpValueArray  *args,
+                           GError               **error)
+{
+  gboolean success = TRUE;
+  GimpValueArray *return_vals;
+  GimpItem *item;
+  gboolean expanded = FALSE;
+
+  item = gimp_value_get_item (gimp_value_array_index (args, 0), gimp);
+
+  if (success)
+    {
+      expanded = gimp_viewable_get_expanded (GIMP_VIEWABLE (item));
+    }
+
+  return_vals = gimp_procedure_get_return_values (procedure, success,
+                                                  error ? *error : NULL);
+
+  if (success)
+    g_value_set_boolean (gimp_value_array_index (return_vals, 1), expanded);
+
+  return return_vals;
+}
+
+static GimpValueArray *
+item_set_expanded_invoker (GimpProcedure         *procedure,
+                           Gimp                  *gimp,
+                           GimpContext           *context,
+                           GimpProgress          *progress,
+                           const GimpValueArray  *args,
+                           GError               **error)
+{
+  gboolean success = TRUE;
+  GimpItem *item;
+  gboolean expanded;
+
+  item = gimp_value_get_item (gimp_value_array_index (args, 0), gimp);
+  expanded = g_value_get_boolean (gimp_value_array_index (args, 1));
+
+  if (success)
+    {
+      gimp_viewable_set_expanded (GIMP_VIEWABLE (item), expanded);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 item_get_name_invoker (GimpProcedure         *procedure,
                        Gimp                  *gimp,
                        GimpContext           *context,
@@ -1321,6 +1374,64 @@ register_item_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-item-get-expanded
+   */
+  procedure = gimp_procedure_new (item_get_expanded_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-item-get-expanded");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-item-get-expanded",
+                                     "Returns whether the item is expanded.",
+                                     "This procedure returns TRUE if the specified item is expanded.",
+                                     "Ell",
+                                     "Ell",
+                                     "2017",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_item_id ("item",
+                                                        "item",
+                                                        "The item",
+                                                        pdb->gimp, FALSE,
+                                                        GIMP_PARAM_READWRITE));
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_boolean ("expanded",
+                                                         "expanded",
+                                                         "TRUE if the item is expanded, FALSE otherwise",
+                                                         FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-item-set-expanded
+   */
+  procedure = gimp_procedure_new (item_set_expanded_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-item-set-expanded");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-item-set-expanded",
+                                     "Sets the expanded state of the item.",
+                                     "This procedure expands or collapses the item.",
+                                     "Ell",
+                                     "Ell",
+                                     "2017",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_item_id ("item",
+                                                        "item",
+                                                        "The item",
+                                                        pdb->gimp, FALSE,
+                                                        GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("expanded",
+                                                     "expanded",
+                                                     "TRUE to expand the item, FALSE to collapse the item",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-item-get-name
    */
   procedure = gimp_procedure_new (item_get_name_invoker);
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 3c3ddc7..96922b1 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -556,6 +556,7 @@ EXPORTS
        gimp_item_detach_parasite
        gimp_item_get_children
        gimp_item_get_color_tag
+        gimp_item_get_expanded
        gimp_item_get_image
        gimp_item_get_linked
        gimp_item_get_lock_content
@@ -576,6 +577,7 @@ EXPORTS
        gimp_item_is_valid
        gimp_item_is_vectors
        gimp_item_set_color_tag
+        gimp_item_set_expanded
        gimp_item_set_linked
        gimp_item_set_lock_content
        gimp_item_set_lock_position
diff --git a/libgimp/gimpitem_pdb.c b/libgimp/gimpitem_pdb.c
index c1a004f..275946c 100644
--- a/libgimp/gimpitem_pdb.c
+++ b/libgimp/gimpitem_pdb.c
@@ -469,6 +469,72 @@ gimp_item_get_children (gint32  item_ID,
 }
 
 /**
+ * gimp_item_get_expanded:
+ * @item_ID: The item.
+ *
+ * Returns whether the item is expanded.
+ *
+ * This procedure returns TRUE if the specified item is expanded.
+ *
+ * Returns: TRUE if the item is expanded, FALSE otherwise.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_item_get_expanded (gint32 item_ID)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean expanded = FALSE;
+
+  return_vals = gimp_run_procedure ("gimp-item-get-expanded",
+                                    &nreturn_vals,
+                                    GIMP_PDB_ITEM, item_ID,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    expanded = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return expanded;
+}
+
+/**
+ * gimp_item_set_expanded:
+ * @item_ID: The item.
+ * @expanded: TRUE to expand the item, FALSE to collapse the item.
+ *
+ * Sets the expanded state of the item.
+ *
+ * This procedure expands or collapses the item.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_item_set_expanded (gint32   item_ID,
+                        gboolean expanded)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-item-set-expanded",
+                                    &nreturn_vals,
+                                    GIMP_PDB_ITEM, item_ID,
+                                    GIMP_PDB_INT32, expanded,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
  * gimp_item_get_name:
  * @item_ID: The item.
  *
diff --git a/libgimp/gimpitem_pdb.h b/libgimp/gimpitem_pdb.h
index 6b81f04..213df44 100644
--- a/libgimp/gimpitem_pdb.h
+++ b/libgimp/gimpitem_pdb.h
@@ -46,6 +46,9 @@ gboolean      gimp_item_is_group          (gint32              item_ID);
 gint32        gimp_item_get_parent        (gint32              item_ID);
 gint*         gimp_item_get_children      (gint32              item_ID,
                                            gint               *num_children);
+gboolean      gimp_item_get_expanded      (gint32              item_ID);
+gboolean      gimp_item_set_expanded      (gint32              item_ID,
+                                           gboolean            expanded);
 gchar*        gimp_item_get_name          (gint32              item_ID);
 gboolean      gimp_item_set_name          (gint32              item_ID,
                                            const gchar        *name);
diff --git a/tools/pdbgen/pdb/item.pdb b/tools/pdbgen/pdb/item.pdb
index b6f5ff9..d01fc8c 100644
--- a/tools/pdbgen/pdb/item.pdb
+++ b/tools/pdbgen/pdb/item.pdb
@@ -420,6 +420,59 @@ CODE
     );
 }
 
+sub item_get_expanded {
+    $blurb = 'Returns whether the item is expanded.';
+
+    $help = <<HELP;
+This procedure returns TRUE if the specified item is expanded.
+HELP
+
+    &ell_pdb_misc('2017', '2.10');
+
+    @inargs = (
+       { name => 'item', type => 'item',
+         desc => 'The item' }
+    );
+
+    @outargs = (
+       { name => 'expanded', type => 'boolean',
+         desc => 'TRUE if the item is expanded, FALSE otherwise' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  expanded = gimp_viewable_get_expanded (GIMP_VIEWABLE (item));
+}
+CODE
+    );
+}
+
+sub item_set_expanded {
+    $blurb = 'Sets the expanded state of the item.';
+
+    $help = <<HELP;
+This procedure expands or collapses the item.
+HELP
+
+    &ell_pdb_misc('2017', '2.10');
+
+    @inargs = (
+       { name => 'item', type => 'item',
+         desc => 'The item' },
+    { name => 'expanded', type => 'boolean',
+         desc => 'TRUE to expand the item, FALSE to collapse the item' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  gimp_viewable_set_expanded (GIMP_VIEWABLE (item), expanded);
+}
+CODE
+    );
+}
+
 sub item_get_name {
     $blurb = "Get the name of the specified item.";
 
@@ -917,6 +970,7 @@ CODE
            item_is_group
             item_get_parent
            item_get_children
+            item_get_expanded item_set_expanded
             item_get_name item_set_name
             item_get_visible item_set_visible
             item_get_linked item_set_linked


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