(by Mattias Karlsson)

There are currently some problems related to the clipboard and Edit actions (Cut, Copy and Paste) in Gazpacho. This page contains some ideas on how to solve these problems and also how to make Gazpacho behave more like other Gnome programs in this regard. The approach is quite simple but it require some modifications to both the behavior of the Edit actions as well as the Gazpacho clipboard. The main problems with the current system can be found in the following bugs:

The behavior of the Edit actions aren't really that complex, but lets start by defining the functionality we want them to provide, i.e. the things we would want to do with them:

  1. It should be possible to Cut/Copy a widget form Project A and Paste it in project B
  2. It should be possible to undo Cut and Paste actions
  3. It should be possible to Paste a widget multiple times
  4. There should be support for some sort of clipboard history or similar to allow switching place of two or more widgets.

Multiple Projects and Undo

Currently the undo functionality of a Cut action is just a Paste action and vice versa. This means that when undoing a cut it's assumed that the widget is on the clipboard and when undoing a Paste the widget will be placed on the clipboard. This works ok when there is only a single project but will fail completely when there are multiple projects available at the same time since the undo stack is separate for each project but the clipboard is shared.

To be able to undo a Cut/Copy from project A and Paste in project B we must store the widget with the action command and use this rather than the clipboard when undoing/redoing. The behavior of the Edit actions could stay more or less the same with a few exception:

Multiple Paste

To make it possible to paste a widget multiple times the latest addition to the clipboard must not be removed when doing a Paste. So far so good. The only problem with this is that you might paste a widget that already exist in the project, e.g. you will suddenly have two label3 in vbox1. This should probably be handled by checking whether there are conflicts when pasting and generate a new name immediately.

Clipboard History

Sometimes you want to switch the locations of two or more widgets. To do this you have to do a number of Cut actions in a row and then an equal number of Paste actions. But since the widget will not be removed from the clipboard when doing a Paste only the widget from the latest Cut will be available for pasting. To solve this some sort of clipboard history must be available to the user. For example:

Use a clipboard containing a list of N elements. Each Cut/Copy action adds a copy of the selected widget to the front of the list and at the same time removes the last element in the list. It's then possible to open a clipboard window, select an item in the history and paste it.