After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 315130 - PDB interface to copy/cut/paste named
PDB interface to copy/cut/paste named
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: libgimp
unspecified
Other All
: Normal normal
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2005-09-02 15:51 UTC by david gowers
Modified: 2005-09-27 09:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fixes the mentioned shortcomings (10.21 KB, patch)
2005-09-04 11:23 UTC, david gowers
needs-work Details | Review
adds 'copy visible named' to menus (2.98 KB, patch)
2005-09-04 12:49 UTC, david gowers
committed Details | Review
buffers.pdb - implements gimp-buffer-delete, if pdbgen understood it. (1.66 KB, text/plain)
2005-09-04 12:52 UTC, david gowers
  Details
implements gimp-buffer-delete (2.09 KB, application/x-compressed-tar)
2005-09-04 16:01 UTC, david gowers
  Details
diff implementing 'gimp-edit-named-delete' PDB func (1.80 KB, patch)
2005-09-05 03:21 UTC, david gowers
committed Details | Review

Description david gowers 2005-09-02 15:51:43 UTC
My plugin needs to copy/paste, and it would be much better if it could do it
without clobbering the existing clipboard content.
To be specific: my '24bit backbuffer simulation' plugin exploits the conversion
abilities of paste; it keeps a temporary indexed image  to paste areas into for
indexization. It then copies them and pastes them back into the current image to
finish.

The only workable workaround I know is a bit ugly and slow:
 * paste the selection on a new layer.
   after pasting the indexized selection back, copy this layer and destroy it.
Comment 1 Michael Natterer 2005-09-02 16:10:57 UTC
It's actually a bug if important core functionality is missing
in the PDB. Moreover it's trivial to implement.
Comment 2 david gowers 2005-09-02 16:38:06 UTC
.. I'm lost as to how to do that. 
copy/cut/paste named seem to be implemented entirely in
app/actions/edit-commands.c. Would i need to move the guts of them out into a
file in libgimp/ and then add pdb entries wrapping them in
tools/pdbgen/pdb/edit.pdb?
Comment 3 Michael Natterer 2005-09-02 17:34:11 UTC
Um, no the functionality would go to app/core/gimp-edit.c, and actually
I'm almost finished hacking this...

Your report didn't sound as if you were about to implement this,
sorry for being fast this time :)
Comment 4 Michael Natterer 2005-09-02 22:52:07 UTC
Fixed in CVS:

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

	* app/core/gimp-edit.[ch] (gimp_edit_paste_as_new): don't create a
	display here.

	(gimp_edit_named_cut)
	(gimp_edit_named_copy)
	(gimp_edit_named_copy_visible): new functions containing named
	buffer wrappers around the functions affecting the global buffer
	only.

	* app/actions/edit-commands.c: use the new functions instead of
	implementing them here, create a display for the image returned
	by paste as new.

	* app/actions/buffers-commands.c
	* app/widgets/gimptoolbox-dnd.c: create displays here too.

	* tools/pdbgen/pdb/edit.pdb: added wrappers for paste as new and
	wrappers for all the cut/copy/paste named stuff.
	Fixes bug #315130. Cleaned up and de-obfuscated.

	* libgimp/gimp.def: changed accordingly.

	* app/pdb/edit_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpedit_pdb.[ch]: regenerated.
Comment 5 david gowers 2005-09-04 07:16:59 UTC
There are still a few things missing that would make this work best:

* delete-named-buffer PDB entry (otherwise, plugins will create more and more
duplicate named buffers as they are rerun.)
* 'copy visible named' menu item.

I'll look into it.
Comment 6 Michael Natterer 2005-09-04 10:13:30 UTC
Right, reopening.
Comment 7 david gowers 2005-09-04 11:23:52 UTC
Created attachment 51779 [details] [review]
fixes the mentioned shortcomings

This patch implements:

* PDB entry 'gimp-buffer-delete'
* 'edit->buffer->copy visible named' menu item.

Check line #170 -- Do I need to unref there, after removing the buffer from its
container? That's what i do currently.

This was surprisingly easy to do :)

Touched files:

app/actions/edit-actions.c
app/actions/edit-commands.[ch]
menus/image-menu.xml.in 
tools/pdbgen/pdb/edit.pdb
app/pdb/edit_cmds.c
libgimp/gimpedit_pdb.[ch]
Comment 8 Michael Natterer 2005-09-04 11:43:04 UTC
Thanks for the patch, some comments:

- you must not unref after removing from the container.
- the new pdb function doesn't live in its file's
  namespace.
- your patch breaks indentation all over the place.

Please fix these issues so the patch can be comitted.
Comment 9 david gowers 2005-09-04 12:49:05 UTC
Created attachment 51782 [details] [review]
adds 'copy visible named' to menus

Fixed coding style issues.
Tried to fix other issues, see following file.
Comment 10 david gowers 2005-09-04 12:52:47 UTC
Created attachment 51783 [details]
buffers.pdb - implements gimp-buffer-delete, if pdbgen understood it.

I based this off the smallest .pdb file, help.pdb.
It causes pdbgen to fail trying to match a regexp , though it seems virtually
identical in every aspect.
What am I doing wrong here?
Comment 11 david gowers 2005-09-04 16:01:43 UTC
Created attachment 51790 [details]
implements gimp-buffer-delete

This file comprises :
 * buffer-delete-cmd.diff (implements all the changes that do not create new
files)
 * app/pdb/buffers_cmds.c
 * libgimp/gimpbuffers_pdb.[ch]
 * tools/pdbgen/pdb/buffers.pdb

Done this way cause i apparently need write-access in order to add files.
(unless there is a option to CVS diff which causes it to generate patches
adding 'unknown' files?)

Anyway, this works and fixes everything you mentioned.
Comment 12 Michael Natterer 2005-09-05 00:40:51 UTC
The attached menu item patch is somehow broken. I applied it
manually anyway:

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

	* app/actions/edit-actions.c
	* app/actions/edit-commands.[ch]
	* menus/image-menu.xml.in: applied modified patch from David
	Gowers which adds an "edit-named-copy-visible" actions and its
	menu item. Addresses bug #315130.


Unfortunately I replied in a hurry before and you misunderstood
me :/ I didn't mean that delete buffer should get its own PDB group,
I was rather thinking of renaming it to gimp-edit-named-delete.
IMHO this single functions doesn't justify adding another group
(unless we find other useful functionality that should go in there).
Comment 13 Michael Natterer 2005-09-05 00:43:42 UTC
Btw, you don't need to attach the autogenerated files.
Comment 14 david gowers 2005-09-05 03:21:30 UTC
Created attachment 51804 [details] [review]
diff implementing 'gimp-edit-named-delete' PDB func

Okay, done.
Comment 15 Michael Natterer 2005-09-05 19:02:50 UTC
Applied to CVS:

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.


Also added "gimp-edit-named-rename". I wonder if your previous
patch with the separate buffer.pdb file wouldn't be the right
thing to do after all...

There is for example no way of getting a buffers size, image
type etc., all things that are needed to use the new buffer API
in a straightforward way.

What do you think?
Comment 16 david gowers 2005-09-06 05:48:49 UTC
Okay.. So one more function, gimp-buffer-get-info, returning (w,h,type); plus
renaming and moving the two recently-added functions?.
Is type derived from bpp? (?) Then how do you tell Indexed/Grey apart?
Comment 17 Michael Natterer 2005-09-06 07:58:00 UTC
I don't really follow your last comment, esp. the last line...
Comment 18 david gowers 2005-09-08 11:15:20 UTC
One more function is needed, in addition to moving named-delete and named-rename
into buffers.pdb, if this change is made. It seems good to me (I prefer
gimp-buffer-* over gimp-edit-named-*.). Whatever is decided, i can make a patch
for it pretty quickly.

by 
"Is type derived from bpp? (?) Then how do you tell Indexed/Grey apart?"
I mean, tile managers don't have knowledge of their type, just bpp, right?
(Indexed and Grey) and (IndexedA and GreyA) are therefore indistinguishable.
It's probably not an issue, as I now realize GIMP probably only keeps Buffers of
RGB(A) or Grey(A) format, and converts indexed(a)->RGB(a) on copy.
Is that correct?
Comment 19 Michael Natterer 2005-09-08 11:45:51 UTC
Buffers can't be indexed, so a bpp->type mapping look as follows:

1 -> GRAY
2 -> GRAYA
3 -> RGB
4 -> RGBA

That's ugly, but the uglyness is internal ;)

Also, the file should be called buffer.pdb, not buffers.pdb (just ad brush.pdb,
pattern.pdb etc.) and the copy/paste functions should stay in edit.pdb
Comment 20 Michael Natterer 2005-09-27 09:16:37 UTC
Fixed in CVS:

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(). Fixes bug #315130.

	* 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.