new utility function which returns the neighbor of a container's active

2007-05-27  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp-utils.[ch] (gimp_container_get_neighbor_of_active):
	new utility function which returns the neighbor of a container's
	active item.

	* app/widgets/gimpcontainerview-utils.[ch]
	(gimp_container_view_remove_active): remove a container view's
	active item, using above function to select its neighbor.

	* app/actions/data-commands.c
	* app/actions/buffers-commands.c
	* app/actions/documents-commands.c
	* app/actions/templates-commands.c: use above functions to select
	reasonable items when deleting from a list (instead of always
	jumping to the first item).



svn path=/trunk/; revision=22632
This commit is contained in:
Michael Natterer
2007-05-27 15:13:45 +00:00
committed by Michael Natterer
parent e601d3e704
commit 65ef13729f
9 changed files with 130 additions and 32 deletions

View File

@ -52,6 +52,8 @@
#include "gimp.h"
#include "gimp-utils.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpparamspecs.h"
@ -508,3 +510,32 @@ gimp_get_temp_filename (Gimp *gimp,
return filename;
}
GimpObject *
gimp_container_get_neighbor_of_active (GimpContainer *container,
GimpContext *context,
GimpObject *active)
{
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (GIMP_IS_OBJECT (active), NULL);
if (active == gimp_context_get_by_type (context, container->children_type))
{
gint index = gimp_container_get_child_index (container, active);
if (index != -1)
{
GimpObject *new;
new = gimp_container_get_child_by_index (container, index + 1);
if (! new && index > 0)
new = gimp_container_get_child_by_index (container, index - 1);
return new;
}
}
return NULL;
}