Commit 4db000a5 authored by Ell's avatar Ell

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

... which call gimp_viewable_{get,set}_expanded()
parent d027a059
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 812 procedures registered total */
/* 814 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -444,6 +444,59 @@ item_get_children_invoker (GimpProcedure *procedure,
return return_vals;
}
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,
......@@ -1320,6 +1373,64 @@ register_item_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
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
*/
......
......@@ -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
......
......@@ -468,6 +468,72 @@ gimp_item_get_children (gint32 item_ID,
return child_ids;
}
/**
* 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.
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment