[gimp] Add basic support for trees of containers in GimpContainerView classes
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add basic support for trees of containers in GimpContainerView classes
- Date: Sat, 1 Aug 2009 17:19:58 +0000 (UTC)
commit ee022e907eb2b9b5437f477fabdfe821ae61b04e
Author: Michael Natterer <mitch gimp org>
Date: Sat Aug 1 19:13:35 2009 +0200
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.
app/widgets/gimpcontainercombobox.c | 2 +
app/widgets/gimpcontainerentry.c | 2 +
app/widgets/gimpcontainergridview.c | 2 +
app/widgets/gimpcontainertreeview.c | 10 +++++---
app/widgets/gimpcontainerview.c | 38 +++++++++++++++++++++++++++++++++-
app/widgets/gimpcontainerview.h | 1 +
app/widgets/gimpitemtreeview.c | 5 +++-
app/widgets/gimplayertreeview.c | 5 +++-
8 files changed, 57 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimpcontainercombobox.c b/app/widgets/gimpcontainercombobox.c
index 9343bcc..53a9633 100644
--- a/app/widgets/gimpcontainercombobox.c
+++ b/app/widgets/gimpcontainercombobox.c
@@ -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));
diff --git a/app/widgets/gimpcontainerentry.c b/app/widgets/gimpcontainerentry.c
index 0e54251..c6f9e65 100644
--- a/app/widgets/gimpcontainerentry.c
+++ b/app/widgets/gimpcontainerentry.c
@@ -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);
diff --git a/app/widgets/gimpcontainergridview.c b/app/widgets/gimpcontainergridview.c
index 13dd25f..afb6f20 100644
--- a/app/widgets/gimpcontainergridview.c
+++ b/app/widgets/gimpcontainergridview.c
@@ -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);
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index 9726e4d..697a8c8 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -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);
diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c
index a45c14c..c571a60 100644
--- a/app/widgets/gimpcontainerview.c
+++ b/app/widgets/gimpcontainerview.c
@@ -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)
diff --git a/app/widgets/gimpcontainerview.h b/app/widgets/gimpcontainerview.h
index 88fc68e..167d34f 100644
--- a/app/widgets/gimpcontainerview.h
+++ b/app/widgets/gimpcontainerview.h
@@ -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,
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index ee81739..0087a5a 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -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,
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index d96c079..4c8a27a 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]