mirror of https://github.com/GNOME/gimp.git
Add basic support for trees of containers in GimpContainerView classes
* app/widgets/gimpcontainerview.[ch]: add and remove container trees recursively. Change virtual function ::add_item() to pass the insert_data of the parent viewable. * app/widgets/gimpcontainercombobox.c * app/widgets/gimpcontainerentry.c * app/widgets/gimpcontainergridview.c: changed accordingly. * app/widgets/gimpcontainertreeview.c * app/widgets/gimpitemtreeview.c * app/widgets/gimplayertreeview.c: dito, but actually use the passed parent_insert_data to insert the item at the right place in the GtkTreeView.
This commit is contained in:
parent
1e5da3939b
commit
ee022e907e
|
@ -58,6 +58,7 @@ static void gimp_container_combo_box_set_context (GimpContainerView *v
|
|||
GimpContext *context);
|
||||
static gpointer gimp_container_combo_box_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
static void gimp_container_combo_box_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
|
@ -315,6 +316,7 @@ gimp_container_combo_box_set_context (GimpContainerView *view,
|
|||
static gpointer
|
||||
gimp_container_combo_box_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index)
|
||||
{
|
||||
GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view));
|
||||
|
|
|
@ -46,6 +46,7 @@ static void gimp_container_entry_set_context (GimpContainerView *view,
|
|||
GimpContext *context);
|
||||
static gpointer gimp_container_entry_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
static void gimp_container_entry_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
|
@ -256,6 +257,7 @@ gimp_container_entry_set_context (GimpContainerView *view,
|
|||
static gpointer
|
||||
gimp_container_entry_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index)
|
||||
{
|
||||
GtkTreeModel *model = gimp_container_entry_get_model (view);
|
||||
|
|
|
@ -63,6 +63,7 @@ static void gimp_container_grid_view_set_context (GimpContainerView *v
|
|||
GimpContext *context);
|
||||
static gpointer gimp_container_grid_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
static void gimp_container_grid_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
|
@ -415,6 +416,7 @@ gimp_container_grid_view_set_context (GimpContainerView *view,
|
|||
static gpointer
|
||||
gimp_container_grid_view_insert_item (GimpContainerView *container_view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index)
|
||||
{
|
||||
GimpContainerGridView *grid_view = GIMP_CONTAINER_GRID_VIEW (container_view);
|
||||
|
|
|
@ -59,6 +59,7 @@ static void gimp_container_tree_view_set_context (GimpContainerVi
|
|||
GimpContext *context);
|
||||
static gpointer gimp_container_tree_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
static void gimp_container_tree_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
|
@ -584,17 +585,18 @@ gimp_container_tree_view_set_context (GimpContainerView *view,
|
|||
static gpointer
|
||||
gimp_container_tree_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index)
|
||||
{
|
||||
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
||||
GtkTreeIter iter;
|
||||
|
||||
/* FIXME tree */
|
||||
|
||||
if (index == -1)
|
||||
gtk_tree_store_append (GTK_TREE_STORE (tree_view->model), &iter, NULL);
|
||||
gtk_tree_store_append (GTK_TREE_STORE (tree_view->model), &iter,
|
||||
parent_insert_data);
|
||||
else
|
||||
gtk_tree_store_insert (GTK_TREE_STORE (tree_view->model), &iter, NULL, index);
|
||||
gtk_tree_store_insert (GTK_TREE_STORE (tree_view->model), &iter,
|
||||
parent_insert_data, index);
|
||||
|
||||
gimp_container_tree_view_set (tree_view, &iter, viewable);
|
||||
|
||||
|
|
|
@ -895,14 +895,28 @@ gimp_container_view_add_foreach (GimpViewable *viewable,
|
|||
{
|
||||
GimpContainerViewInterface *view_iface;
|
||||
GimpContainerViewPrivate *private;
|
||||
GimpViewable *parent;
|
||||
GimpContainer *children;
|
||||
gpointer parent_insert_data = NULL;
|
||||
gpointer insert_data;
|
||||
|
||||
view_iface = GIMP_CONTAINER_VIEW_GET_INTERFACE (view);
|
||||
private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
||||
|
||||
insert_data = view_iface->insert_item (view, viewable, -1);
|
||||
parent = gimp_viewable_get_parent (viewable);
|
||||
|
||||
if (parent)
|
||||
parent_insert_data = g_hash_table_lookup (private->item_hash, parent);
|
||||
|
||||
insert_data = view_iface->insert_item (view, viewable,
|
||||
parent_insert_data, -1);
|
||||
|
||||
g_hash_table_insert (private->item_hash, viewable, insert_data);
|
||||
|
||||
children = gimp_viewable_get_children (viewable);
|
||||
|
||||
if (children)
|
||||
gimp_container_view_add_container (view, children);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -912,6 +926,9 @@ gimp_container_view_add (GimpContainerView *view,
|
|||
{
|
||||
GimpContainerViewInterface *view_iface;
|
||||
GimpContainerViewPrivate *private;
|
||||
GimpViewable *parent;
|
||||
GimpContainer *children;
|
||||
gpointer parent_insert_data = NULL;
|
||||
gpointer insert_data;
|
||||
gint index;
|
||||
|
||||
|
@ -921,9 +938,20 @@ gimp_container_view_add (GimpContainerView *view,
|
|||
index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (viewable));
|
||||
|
||||
insert_data = view_iface->insert_item (view, viewable, index);
|
||||
parent = gimp_viewable_get_parent (viewable);
|
||||
|
||||
if (parent)
|
||||
parent_insert_data = g_hash_table_lookup (private->item_hash, parent);
|
||||
|
||||
insert_data = view_iface->insert_item (view, viewable,
|
||||
parent_insert_data, -1);
|
||||
|
||||
g_hash_table_insert (private->item_hash, viewable, insert_data);
|
||||
|
||||
children = gimp_viewable_get_children (viewable);
|
||||
|
||||
if (children)
|
||||
gimp_container_view_add_container (view, children);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -976,8 +1004,14 @@ gimp_container_view_remove (GimpContainerView *view,
|
|||
GimpContainer *unused)
|
||||
{
|
||||
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
||||
GimpContainer *children;
|
||||
gpointer insert_data;
|
||||
|
||||
children = gimp_viewable_get_children (viewable);
|
||||
|
||||
if (children)
|
||||
gimp_container_view_remove_container (view, children);
|
||||
|
||||
insert_data = g_hash_table_lookup (private->item_hash, viewable);
|
||||
|
||||
if (insert_data)
|
||||
|
|
|
@ -64,6 +64,7 @@ struct _GimpContainerViewInterface
|
|||
GimpContext *context);
|
||||
gpointer (* insert_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
void (* remove_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
|
|
|
@ -107,6 +107,7 @@ static void gimp_item_tree_view_set_context (GimpContainerView *view,
|
|||
|
||||
static gpointer gimp_item_tree_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
static gboolean gimp_item_tree_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *item,
|
||||
|
@ -626,6 +627,7 @@ gimp_item_tree_view_set_context (GimpContainerView *view,
|
|||
static gpointer
|
||||
gimp_item_tree_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index)
|
||||
{
|
||||
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (view);
|
||||
|
@ -633,7 +635,8 @@ gimp_item_tree_view_insert_item (GimpContainerView *view,
|
|||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
GtkTreeIter *iter;
|
||||
|
||||
iter = parent_view_iface->insert_item (view, viewable, index);
|
||||
iter = parent_view_iface->insert_item (view, viewable,
|
||||
parent_insert_data, index);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), iter,
|
||||
item_view->priv->model_column_visible,
|
||||
|
|
|
@ -96,6 +96,7 @@ static void gimp_layer_tree_view_set_context (GimpContainerView *view,
|
|||
GimpContext *context);
|
||||
static gpointer gimp_layer_tree_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index);
|
||||
static gboolean gimp_layer_tree_view_select_item (GimpContainerView *view,
|
||||
GimpViewable *item,
|
||||
|
@ -557,13 +558,15 @@ gimp_layer_tree_view_set_context (GimpContainerView *view,
|
|||
static gpointer
|
||||
gimp_layer_tree_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer parent_insert_data,
|
||||
gint index)
|
||||
{
|
||||
GimpLayerTreeView *layer_view = GIMP_LAYER_TREE_VIEW (view);
|
||||
GimpLayer *layer;
|
||||
GtkTreeIter *iter;
|
||||
|
||||
iter = parent_view_iface->insert_item (view, viewable, index);
|
||||
iter = parent_view_iface->insert_item (view, viewable,
|
||||
parent_insert_data, index);
|
||||
|
||||
layer = GIMP_LAYER (viewable);
|
||||
|
||||
|
|
Loading…
Reference in New Issue