2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-05-13 20:16:55 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-05-13 20:16:55 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-05-13 20:16:55 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-05-13 20:16:55 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-03-30 01:19:01 +08:00
|
|
|
#include <gegl.h>
|
2001-05-13 20:16:55 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "widgets-types.h"
|
2001-05-13 20:16:55 +08:00
|
|
|
|
2007-05-27 23:13:45 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2001-11-24 00:25:01 +08:00
|
|
|
#include "gimpcontainereditor.h"
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "gimpcontainerview.h"
|
|
|
|
#include "gimpcontainerview-utils.h"
|
2001-11-24 00:25:01 +08:00
|
|
|
#include "gimpdockable.h"
|
2001-05-13 20:16:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-11-24 00:25:01 +08:00
|
|
|
GimpContainerView *
|
|
|
|
gimp_container_view_get_by_dockable (GimpDockable *dockable)
|
|
|
|
{
|
2008-03-13 00:58:28 +08:00
|
|
|
GtkWidget *child;
|
2001-11-24 00:25:01 +08:00
|
|
|
|
2003-04-12 00:51:49 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
|
2001-11-24 00:25:01 +08:00
|
|
|
|
2008-03-13 00:58:28 +08:00
|
|
|
child = gtk_bin_get_child (GTK_BIN (dockable));
|
2001-11-24 00:25:01 +08:00
|
|
|
|
2008-03-13 00:58:28 +08:00
|
|
|
if (child)
|
2003-04-12 00:51:49 +08:00
|
|
|
{
|
2008-03-13 00:58:28 +08:00
|
|
|
if (GIMP_IS_CONTAINER_EDITOR (child))
|
2001-11-24 00:25:01 +08:00
|
|
|
{
|
2008-03-13 00:58:28 +08:00
|
|
|
return GIMP_CONTAINER_EDITOR (child)->view;
|
2001-11-24 00:25:01 +08:00
|
|
|
}
|
2008-03-13 00:58:28 +08:00
|
|
|
else if (GIMP_IS_CONTAINER_VIEW (child))
|
2001-11-24 00:25:01 +08:00
|
|
|
{
|
2008-03-13 00:58:28 +08:00
|
|
|
return GIMP_CONTAINER_VIEW (child);
|
2001-11-24 00:25:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-05-27 23:13:45 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_container_view_remove_active (GimpContainerView *view)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpContainer *container;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
|
|
|
|
|
|
|
context = gimp_container_view_get_context (view);
|
|
|
|
container = gimp_container_view_get_container (view);
|
|
|
|
|
|
|
|
if (context && container)
|
|
|
|
{
|
2011-03-13 09:14:44 +08:00
|
|
|
GType children_type;
|
2007-05-27 23:13:45 +08:00
|
|
|
GimpObject *active;
|
|
|
|
|
2011-03-13 09:14:44 +08:00
|
|
|
children_type = gimp_container_get_children_type (container);
|
|
|
|
|
|
|
|
active = gimp_context_get_by_type (context, children_type);
|
2007-05-27 23:13:45 +08:00
|
|
|
|
|
|
|
if (active)
|
|
|
|
{
|
|
|
|
GimpObject *new;
|
|
|
|
|
2011-03-13 09:14:44 +08:00
|
|
|
new = gimp_container_get_neighbor_of (container, active);
|
2007-05-27 23:13:45 +08:00
|
|
|
|
|
|
|
if (new)
|
2011-03-13 09:14:44 +08:00
|
|
|
gimp_context_set_by_type (context, children_type, new);
|
2007-05-27 23:13:45 +08:00
|
|
|
|
|
|
|
gimp_container_remove (container, active);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|