Commit 30f1e8ef authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added gimp_buffer_get_bytes() and gimp_buffer_get_image_type().

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

	* app/core/gimpbuffer.[ch]: added gimp_buffer_get_bytes()
	and gimp_buffer_get_image_type().

	* tools/pdbgen/pdb/edit.pdb: removed edit_named_rename() and
	edit_named_delete().

	* tools/pdbgen/Makefile.am
	* tools/pdbgen/groups.pl
	* tools/pdbgen/pdb/buffer.pdb: new PDB group featuring
	buffer_rename(), delete(), get_width(), get_height(), get_bytes(),
	get_image_type().

	* app/pdb/Makefile.am
	* libgimp/Makefile.am
	* libgimp/gimp.def: changed accordingly.

	* app/pdb/buffer_cmds.c
	* app/pdb/edit_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimp_pdb.h
	* libgimp/gimpbuffer_pdb.[ch]
	* libgimp/gimpedit_pdb.[ch]: (re)generated.
parent 5e2033cb
2005-09-27 Michael Natterer <mitch@gimp.org>
* app/core/gimpbuffer.[ch]: added gimp_buffer_get_bytes()
and gimp_buffer_get_image_type().
* tools/pdbgen/pdb/edit.pdb: removed edit_named_rename() and
edit_named_delete().
* tools/pdbgen/Makefile.am
* tools/pdbgen/groups.pl
* tools/pdbgen/pdb/buffer.pdb: new PDB group featuring
buffer_rename(), delete(), get_width(), get_height(), get_bytes(),
get_image_type().
* app/pdb/Makefile.am
* libgimp/Makefile.am
* libgimp/gimp.def: changed accordingly.
* app/pdb/buffer_cmds.c
* app/pdb/edit_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimp_pdb.h
* libgimp/gimpbuffer_pdb.[ch]
* libgimp/gimpedit_pdb.[ch]: (re)generated.
2005-09-27 DindinX <dindinx@gimp.org>
* libgimpwidgets/gimpzoommodel.c: zooming out more is zooming out
......
......@@ -378,3 +378,27 @@ gimp_buffer_get_height (const GimpBuffer *buffer)
return tile_manager_height (buffer->tiles);
}
gint
gimp_buffer_get_bytes (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
return tile_manager_bpp (buffer->tiles);
}
GimpImageType
gimp_buffer_get_image_type (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
switch (tile_manager_bpp (buffer->tiles))
{
case 1: return GIMP_GRAY_IMAGE;
case 2: return GIMP_GRAYA_IMAGE;
case 3: return GIMP_RGB_IMAGE;
case 4: return GIMP_RGBA_IMAGE;
}
return 0;
}
......@@ -46,16 +46,19 @@ struct _GimpBufferClass
};
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
const gchar *name);
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
const gchar *name);
gint gimp_buffer_get_width (const GimpBuffer *buffer);
gint gimp_buffer_get_height (const GimpBuffer *buffer);
gint gimp_buffer_get_width (const GimpBuffer *buffer);
gint gimp_buffer_get_height (const GimpBuffer *buffer);
gint gimp_buffer_get_bytes (const GimpBuffer *buffer);
GimpImageType gimp_buffer_get_image_type (const GimpBuffer *buffer);
#endif /* __GIMP_BUFFER_H__ */
......@@ -15,6 +15,7 @@ libapppdb_a_SOURCES = \
brush_cmds.c \
brush_select_cmds.c \
brushes_cmds.c \
buffer_cmds.c \
channel_cmds.c \
color_cmds.c \
context_cmds.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "pdb-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpbuffer.h"
#include "core/gimpcontainer.h"
#include "gimp-intl.h"
static ProcRecord buffer_rename_proc;
static ProcRecord buffer_delete_proc;
static ProcRecord buffer_get_width_proc;
static ProcRecord buffer_get_height_proc;
static ProcRecord buffer_get_bytes_proc;
static ProcRecord buffer_get_image_type_proc;
void
register_buffer_procs (Gimp *gimp)
{
procedural_db_register (gimp, &buffer_rename_proc);
procedural_db_register (gimp, &buffer_delete_proc);
procedural_db_register (gimp, &buffer_get_width_proc);
procedural_db_register (gimp, &buffer_get_height_proc);
procedural_db_register (gimp, &buffer_get_bytes_proc);
procedural_db_register (gimp, &buffer_get_image_type_proc);
}
static Argument *
buffer_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 (&buffer_rename_proc, success);
if (success)
return_args[1].value.pdb_pointer = real_name;
return return_args;
}
static ProcArg buffer_rename_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
},
{
GIMP_PDB_STRING,
"new-name",
"The buffer's new name"
}
};
static ProcArg buffer_rename_outargs[] =
{
{
GIMP_PDB_STRING,
"real-name",
"The real name given to the buffer"
}
};
static ProcRecord buffer_rename_proc =
{
"gimp-buffer-rename",
"gimp-buffer-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,
buffer_rename_inargs,
1,
buffer_rename_outargs,
{ { buffer_rename_invoker } }
};
static Argument *
buffer_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 (&buffer_delete_proc, success);
}
static ProcArg buffer_delete_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
}
};
static ProcRecord buffer_delete_proc =
{
"gimp-buffer-delete",
"gimp-buffer-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,
buffer_delete_inargs,
0,
NULL,
{ { buffer_delete_invoker } }
};
static Argument *
buffer_get_width_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *buffer_name;
GimpBuffer *buffer = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
}
return_args = procedural_db_return_args (&buffer_get_width_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_buffer_get_width (buffer);
return return_args;
}
static ProcArg buffer_get_width_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
}
};
static ProcArg buffer_get_width_outargs[] =
{
{
GIMP_PDB_INT32,
"width",
"The buffer width"
}
};
static ProcRecord buffer_get_width_proc =
{
"gimp-buffer-get-width",
"gimp-buffer-get-width",
"Retrieves the specified buffer's width.",
"This procedure retrieves the specified named buffer's width.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
1,
buffer_get_width_inargs,
1,
buffer_get_width_outargs,
{ { buffer_get_width_invoker } }
};
static Argument *
buffer_get_height_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *buffer_name;
GimpBuffer *buffer = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
}
return_args = procedural_db_return_args (&buffer_get_height_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_buffer_get_height (buffer);
return return_args;
}
static ProcArg buffer_get_height_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
}
};
static ProcArg buffer_get_height_outargs[] =
{
{
GIMP_PDB_INT32,
"height",
"The buffer height"
}
};
static ProcRecord buffer_get_height_proc =
{
"gimp-buffer-get-height",
"gimp-buffer-get-height",
"Retrieves the specified buffer's height.",
"This procedure retrieves the specified named buffer's height.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
1,
buffer_get_height_inargs,
1,
buffer_get_height_outargs,
{ { buffer_get_height_invoker } }
};
static Argument *
buffer_get_bytes_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *buffer_name;
GimpBuffer *buffer = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
}
return_args = procedural_db_return_args (&buffer_get_bytes_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_buffer_get_bytes (buffer);
return return_args;
}
static ProcArg buffer_get_bytes_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
}
};
static ProcArg buffer_get_bytes_outargs[] =
{
{
GIMP_PDB_INT32,
"bytes",
"The buffer bpp"
}
};
static ProcRecord buffer_get_bytes_proc =
{
"gimp-buffer-get-bytes",
"gimp-buffer-get-bytes",
"Retrieves the specified buffer's bytes.",
"This procedure retrieves the specified named buffer's bytes.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
1,
buffer_get_bytes_inargs,
1,
buffer_get_bytes_outargs,
{ { buffer_get_bytes_invoker } }
};
static Argument *
buffer_get_image_type_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *buffer_name;
GimpBuffer *buffer = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
}
return_args = procedural_db_return_args (&buffer_get_image_type_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_buffer_get_image_type (buffer);
return return_args;
}
static ProcArg buffer_get_image_type_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The buffer name"
}
};
static ProcArg buffer_get_image_type_outargs[] =
{
{
GIMP_PDB_INT32,
"image-type",
"The buffer image type"
}
};
static ProcRecord buffer_get_image_type_proc =
{
"gimp-buffer-get-image-type",
"gimp-buffer-get-image-type",
"Retrieves the specified buffer's image type.",
"This procedure retrieves the specified named buffer's image type.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
1,
buffer_get_image_type_inargs,
1,
buffer_get_image_type_outargs,
{ { buffer_get_image_type_invoker } }
};
......@@ -50,8 +50,6 @@ 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;
......@@ -71,8 +69,6 @@ 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);
......@@ -855,147 +851,6 @@ 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