1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #include "config.h" 19 20 #include <gegl.h> 21 #include <gtk/gtk.h> 22 23 #include "widgets-types.h" 24 25 #include "core/gimpcontainer.h" 26 #include "core/gimpcontext.h" 27 28 #include "gimpcontainereditor.h" 29 #include "gimpcontainerview.h" 30 #include "gimpcontainerview-utils.h" 31 #include "gimpdockable.h" 32 33 34 /* public functions */ 35 36 GimpContainerView * gimp_container_view_get_by_dockable(GimpDockable * dockable)37gimp_container_view_get_by_dockable (GimpDockable *dockable) 38 { 39 GtkWidget *child; 40 41 g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL); 42 43 child = gtk_bin_get_child (GTK_BIN (dockable)); 44 45 if (child) 46 { 47 if (GIMP_IS_CONTAINER_EDITOR (child)) 48 { 49 return GIMP_CONTAINER_EDITOR (child)->view; 50 } 51 else if (GIMP_IS_CONTAINER_VIEW (child)) 52 { 53 return GIMP_CONTAINER_VIEW (child); 54 } 55 } 56 57 return NULL; 58 } 59 60 void gimp_container_view_remove_active(GimpContainerView * view)61gimp_container_view_remove_active (GimpContainerView *view) 62 { 63 GimpContext *context; 64 GimpContainer *container; 65 66 g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); 67 68 context = gimp_container_view_get_context (view); 69 container = gimp_container_view_get_container (view); 70 71 if (context && container) 72 { 73 GType children_type; 74 GimpObject *active; 75 76 children_type = gimp_container_get_children_type (container); 77 78 active = gimp_context_get_by_type (context, children_type); 79 80 if (active) 81 { 82 GimpObject *new; 83 84 new = gimp_container_get_neighbor_of (container, active); 85 86 if (new) 87 gimp_context_set_by_type (context, children_type, new); 88 89 gimp_container_remove (container, active); 90 } 91 } 92 } 93