Commit dc65f101 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

applied patch from David Gowers which adds "gimp-edit-named-delete".

2005-09-05  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/edit.pdb: applied patch from David Gowers which
	adds "gimp-edit-named-delete". Addresses bug #315130. Added
	"gimp-edit-named-rename" additionally.

	* libgimp/gimp.def: changed accordingly.

	* app/pdb/edit_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpedit_pdb.[ch]: regenerated.
parent dd1d7498
2005-09-05 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/edit.pdb: applied patch from David Gowers which
adds "gimp-edit-named-delete". Addresses bug #315130. Added
"gimp-edit-named-rename" additionally.
* libgimp/gimp.def: changed accordingly.
* app/pdb/edit_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpedit_pdb.[ch]: regenerated.
2005-09-05 Michael Natterer <mitch@gimp.org>
* app/core/gimp-edit.c: don't let named cut/copy affect the global
......
......@@ -50,6 +50,8 @@ static ProcRecord edit_named_copy_proc;
static ProcRecord edit_named_copy_visible_proc;
static ProcRecord edit_named_paste_proc;
static ProcRecord edit_named_paste_as_new_proc;
static ProcRecord edit_named_delete_proc;
static ProcRecord edit_named_rename_proc;
static ProcRecord edit_clear_proc;
static ProcRecord edit_fill_proc;
static ProcRecord edit_bucket_fill_proc;
......@@ -69,6 +71,8 @@ register_edit_procs (Gimp *gimp)
procedural_db_register (gimp, &edit_named_copy_visible_proc);
procedural_db_register (gimp, &edit_named_paste_proc);
procedural_db_register (gimp, &edit_named_paste_as_new_proc);
procedural_db_register (gimp, &edit_named_delete_proc);
procedural_db_register (gimp, &edit_named_rename_proc);
procedural_db_register (gimp, &edit_clear_proc);
procedural_db_register (gimp, &edit_fill_proc);
procedural_db_register (gimp, &edit_bucket_fill_proc);
......@@ -616,15 +620,17 @@ edit_named_copy_visible_invoker (Gimp *gimp,
if (success)
{
if (strlen (buffer_name) > 0)
success = (strlen (buffer_name) > 0);
if (success)
{
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
......@@ -849,6 +855,147 @@ static ProcRecord edit_named_paste_as_new_proc =
{ { edit_named_paste_as_new_invoker } }
};
static Argument *
edit_named_delete_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gchar *buffer_name;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
if (success)
success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer));
}
return procedural_db_return_args (&edit_named_delete_proc, success);
}
static ProcArg edit_named_delete_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
}
};
static ProcRecord edit_named_delete_proc =
{
"gimp-edit-named-delete",
"gimp-edit-named-delete",
"Deletes a named buffer.",
"This procedure deletes a named buffer.",
"David Gowers <neota@softhome.net>",
"David Gowers <neota@softhome.net>",
"2005",
NULL,
GIMP_INTERNAL,
1,
edit_named_delete_inargs,
0,
NULL,
{ { edit_named_delete_invoker } }
};
static Argument *
edit_named_rename_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *buffer_name;
gchar *new_name;
gchar *real_name = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
if (new_name == NULL || !g_utf8_validate (new_name, -1, NULL))
success = FALSE;
if (success)
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL && strlen (new_name) > 0);
if (success)
{
gimp_object_set_name (GIMP_OBJECT (buffer), new_name);
real_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (buffer)));
}
}
return_args = procedural_db_return_args (&edit_named_rename_proc, success);
if (success)
return_args[1].value.pdb_pointer = real_name;
return return_args;
}
static ProcArg edit_named_rename_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
},
{
GIMP_PDB_STRING,
"new-name",
"The buffer's new name"
}
};
static ProcArg edit_named_rename_outargs[] =
{
{
GIMP_PDB_STRING,
"real-name",
"The real name given to the buffer"
}
};
static ProcRecord edit_named_rename_proc =
{
"gimp-edit-named-rename",
"gimp-edit-named-rename",
"Renames a named buffer.",
"This procedure renames a named buffer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
2,
edit_named_rename_inargs,
1,
edit_named_rename_outargs,
{ { edit_named_rename_invoker } }
};
static Argument *
edit_clear_invoker (Gimp *gimp,
GimpContext *context,
......
......@@ -75,7 +75,7 @@ void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
void register_vectors_procs (Gimp *gimp);
/* 471 procedures registered total */
/* 473 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -102,109 +102,109 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Context"), 0.121);
register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.168);
(* status_callback) (NULL, _("Convert"), 0.167);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.174);
(* status_callback) (NULL, _("Display procedures"), 0.173);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.183);
(* status_callback) (NULL, _("Drawable procedures"), 0.182);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Transformation procedures"), 0.257);
(* status_callback) (NULL, _("Transformation procedures"), 0.256);
register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.291);
(* status_callback) (NULL, _("Edit procedures"), 0.29);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.323);
(* status_callback) (NULL, _("File Operations"), 0.326);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.344);
(* status_callback) (NULL, _("Floating selections"), 0.347);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.357);
(* status_callback) (NULL, _("Font UI"), 0.359);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.363);
(* status_callback) (NULL, _("Fonts"), 0.366);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.367);
(* status_callback) (NULL, _("Gimprc procedures"), 0.37);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.382);
(* status_callback) (NULL, _("Gradient"), 0.385);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.446);
(* status_callback) (NULL, _("Gradient UI"), 0.448);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.452);
(* status_callback) (NULL, _("Gradients"), 0.455);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.463);
(* status_callback) (NULL, _("Guide procedures"), 0.465);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.476);
(* status_callback) (NULL, _("Help procedures"), 0.478);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.478);
(* status_callback) (NULL, _("Image"), 0.48);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.611);
(* status_callback) (NULL, _("Layer"), 0.613);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.669);
(* status_callback) (NULL, _("Message procedures"), 0.67);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.675);
(* status_callback) (NULL, _("Miscellaneous"), 0.677);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.682);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.683);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.713);
(* status_callback) (NULL, _("Palette"), 0.715);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.743);
(* status_callback) (NULL, _("Palette UI"), 0.744);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.749);
(* status_callback) (NULL, _("Palettes"), 0.751);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.758);
(* status_callback) (NULL, _("Parasite procedures"), 0.759);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.783);
(* status_callback) (NULL, _("Paths"), 0.784);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.817);
(* status_callback) (NULL, _("Pattern"), 0.818);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.822);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.828);
(* status_callback) (NULL, _("Patterns"), 0.829);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.837);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.849);
(* status_callback) (NULL, _("Procedural database"), 0.85);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.868);
(* status_callback) (NULL, _("Progress"), 0.869);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.883);
(* status_callback) (NULL, _("Image mask"), 0.884);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.919);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.92);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.93);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.938);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.939);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.951);
......
......@@ -172,8 +172,10 @@ EXPORTS
gimp_edit_named_copy
gimp_edit_named_copy_visible
gimp_edit_named_cut
gimp_edit_named_delete
gimp_edit_named_paste
gimp_edit_named_paste_as_new
gimp_edit_named_rename
gimp_edit_paste
gimp_edit_paste_as_new
gimp_edit_stroke
......
......@@ -397,6 +397,72 @@ gimp_edit_named_paste_as_new (const gchar *buffer_name)
return image_ID;
}
/**
* gimp_edit_named_delete:
* @buffer_name: The buffer name.
*
* Deletes a named buffer.
*
* This procedure deletes a named buffer.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.4
*/
gboolean
gimp_edit_named_delete (const gchar *buffer_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-edit-named-delete",
&nreturn_vals,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_edit_named_rename:
* @buffer_name: The buffer name.
* @new_name: The buffer's new name.
*
* Renames a named buffer.
*
* This procedure renames a named buffer.
*
* Returns: The real name given to the buffer.
*
* Since: GIMP 2.4
*/
gchar *
gimp_edit_named_rename (const gchar *buffer_name,
const gchar *new_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *real_name = NULL;
return_vals = gimp_run_procedure ("gimp-edit-named-rename",
&nreturn_vals,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_STRING, new_name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
real_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return real_name;
}
/**
* gimp_edit_clear:
* @drawable_ID: The drawable to clear from.
......
......@@ -45,6 +45,9 @@ gint32 gimp_edit_named_paste (gint32 drawable_ID,
const gchar *buffer_name,
gboolean paste_into);
gint32 gimp_edit_named_paste_as_new (const gchar *buffer_name);
gboolean gimp_edit_named_delete (const gchar *buffer_name);
gchar* gimp_edit_named_rename (const gchar *buffer_name,
const gchar *new_name);
gboolean gimp_edit_clear (gint32 drawable_ID);
gboolean gimp_edit_fill (gint32 drawable_ID,
GimpFillType fill_type);
......
......@@ -316,6 +316,7 @@ HELP
{ name => 'buffer_name', type => 'string',
desc => 'The name of the buffer to create' }
);
@outargs = (
{ name => 'real_name', type => 'string', init => 1,
desc => 'The real name given to the buffer' }
......@@ -324,15 +325,17 @@ HELP
%invoke = (
code => <<CODE
{
if (strlen (buffer_name) > 0)
success = (strlen (buffer_name) > 0);
if (success)
{
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
CODE
......@@ -431,6 +434,82 @@ CODE
);
}
sub edit_named_delete {
$blurb = 'Deletes a named buffer.';
$help = <<'HELP';
This procedure deletes a named buffer.
HELP
$author = $copyright = 'David Gowers <neota@softhome.net>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'buffer_name', type => 'string',
desc => 'The buffer name' }
);
%invoke = (
code => <<CODE
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
if (success)
success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer));
}
CODE
);
}
sub edit_named_rename {
$blurb = 'Renames a named buffer.';
$help = <<'HELP';
This procedure renames a named buffer.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'buffer_name', type => 'string',
desc => 'The buffer name' },
{ name => 'new_name', type => 'string',
desc => 'The buffer\'s new name' }
);
@outargs = (
{ name => 'real_name', type => 'string', init => 1,
desc => 'The real name given to the buffer' }
);
%invoke = (
code => <<CODE
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL && strlen (new_name) > 0);
if (success)
{
gimp_object_set_name (GIMP_OBJECT (buffer), new_name);
real_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (buffer)));
}
}
CODE
);
}
sub edit_clear {
$blurb = 'Clear selected area of drawable.';
......@@ -670,6 +749,7 @@ CODE
);
}
@headers = qw(<string.h> "core/gimp.h" "core/gimp-edit.h"
"core/gimpcontainer.h" "core/gimpimage.h" "core/gimpprogress.h"
"gimp-intl.h");
......@@ -678,7 +758,8 @@ CODE
edit_paste edit_paste_as_new
edit_named_cut edit_named_copy edit_named_copy_visible
edit_named_paste edit_named_paste_as_new
edit_clear edit_fill edit_bucket_fill edit_blend edit_stroke);
edit_named_delete edit_named_rename
edit_clear edit_fill edit_bucket_fill edit_blend edit_stroke );
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Edit procedures';
......
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