[gimp] app: add gimp_container_tree_store_columns_add()



commit 104d0ffb3efd813a34efbb11566ea1e9c6444875
Author: Michael Natterer <mitch gimp org>
Date:   Mon May 17 21:22:36 2010 +0200

    app: add gimp_container_tree_store_columns_add()
    
    which adds a column to the GType array used for creating a
    GimpContainerTreeStore.

 app/widgets/gimpcontainertreestore.c |   15 +++++++++++++++
 app/widgets/gimpcontainertreestore.h |    4 ++++
 app/widgets/gimpcontainertreeview.c  |   27 ++++++++++++++++++++-------
 app/widgets/gimpitemtreeview.c       |   26 ++++++++++----------------
 app/widgets/gimplayertreeview.c      |   26 ++++++++++----------------
 5 files changed, 59 insertions(+), 39 deletions(-)
---
diff --git a/app/widgets/gimpcontainertreestore.c b/app/widgets/gimpcontainertreestore.c
index 57a8f43..dfd54f4 100644
--- a/app/widgets/gimpcontainertreestore.c
+++ b/app/widgets/gimpcontainertreestore.c
@@ -405,6 +405,21 @@ gimp_container_tree_store_set_view_size (GimpContainerTreeStore *store)
 
 /*  private functions  */
 
+gint
+gimp_container_tree_store_columns_add (GType *types,
+                                       gint  *n_types,
+                                       GType  type)
+{
+  g_return_val_if_fail (types != NULL, 0);
+  g_return_val_if_fail (n_types != NULL, 0);
+  g_return_val_if_fail (*n_types >= 0, 0);
+
+  types[*n_types] = type;
+  (*n_types)++;
+
+  return *n_types - 1;
+}
+
 static void
 gimp_container_tree_store_set (GimpContainerTreeStore *store,
                                GtkTreeIter            *iter,
diff --git a/app/widgets/gimpcontainertreestore.h b/app/widgets/gimpcontainertreestore.h
index 715ba74..34a605b 100644
--- a/app/widgets/gimpcontainertreestore.h
+++ b/app/widgets/gimpcontainertreestore.h
@@ -56,6 +56,10 @@ struct _GimpContainerTreeStoreClass
 
 GType          gimp_container_tree_store_get_type      (void) G_GNUC_CONST;
 
+gint           gimp_container_tree_store_columns_add   (GType                  *types,
+                                                        gint                   *n_types,
+                                                        GType                   type);
+
 GtkTreeModel * gimp_container_tree_store_new           (GimpContainerView      *container_view,
                                                         gint                    n_columns,
                                                         GType                  *types);
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index ec0745b..eb483ff 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -172,13 +172,26 @@ gimp_container_tree_view_init (GimpContainerTreeView *tree_view)
                                                  GIMP_TYPE_CONTAINER_TREE_VIEW,
                                                  GimpContainerTreeViewPriv);
 
-  tree_view->n_model_columns = GIMP_CONTAINER_TREE_VIEW_N_COLUMNS;
-
-  tree_view->model_columns[GIMP_CONTAINER_TREE_VIEW_COLUMN_RENDERER]        = GIMP_TYPE_VIEW_RENDERER;
-  tree_view->model_columns[GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME]            = G_TYPE_STRING;
-  tree_view->model_columns[GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME_ATTRIBUTES] = PANGO_TYPE_ATTR_LIST;
-  tree_view->model_columns[GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME_SENSITIVE]  = G_TYPE_BOOLEAN;
-  tree_view->model_columns[GIMP_CONTAINER_TREE_VIEW_COLUMN_USER_DATA]       = G_TYPE_POINTER;
+  g_assert (GIMP_CONTAINER_TREE_VIEW_COLUMN_RENDERER ==
+            gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                                   &tree_view->n_model_columns,
+                                                   GIMP_TYPE_VIEW_RENDERER));
+  g_assert (GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME ==
+            gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                                   &tree_view->n_model_columns,
+                                                   G_TYPE_STRING));
+  g_assert (GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME_ATTRIBUTES ==
+            gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                                   &tree_view->n_model_columns,
+                                                   PANGO_TYPE_ATTR_LIST));
+  g_assert (GIMP_CONTAINER_TREE_VIEW_COLUMN_NAME_SENSITIVE ==
+            gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                                   &tree_view->n_model_columns,
+                                                   G_TYPE_BOOLEAN));
+  g_assert (GIMP_CONTAINER_TREE_VIEW_COLUMN_USER_DATA ==
+            gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                                   &tree_view->n_model_columns,
+                                                   G_TYPE_POINTER));
 
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box->scrolled_win),
                                        GTK_SHADOW_IN);
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index b78bc75..276e2e5 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -44,6 +44,7 @@
 
 #include "vectors/gimpvectors.h"
 
+#include "gimpcontainertreestore.h"
 #include "gimpcontainerview.h"
 #include "gimpdnd.h"
 #include "gimpdocked.h"
@@ -303,22 +304,15 @@ gimp_item_tree_view_init (GimpItemTreeView *view)
                                             GIMP_TYPE_ITEM_TREE_VIEW,
                                             GimpItemTreeViewPriv);
 
-  /* The following used to read:
-   *
-   * tree_view->model_columns[tree_view->n_model_columns++] = ...
-   *
-   * but combining the two lead to gcc miscompiling the function on ppc/ia64
-   * (model_column_mask and model_column_mask_visible would have the same
-   * value, probably due to bad instruction reordering). See bug #113144 for
-   * more info.
-   */
-  view->priv->model_column_visible = tree_view->n_model_columns;
-  tree_view->model_columns[tree_view->n_model_columns] = G_TYPE_BOOLEAN;
-  tree_view->n_model_columns++;
+  view->priv->model_column_visible =
+    gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                           &tree_view->n_model_columns,
+                                           G_TYPE_BOOLEAN);
 
-  view->priv->model_column_linked = tree_view->n_model_columns;
-  tree_view->model_columns[tree_view->n_model_columns] = G_TYPE_BOOLEAN;
-  tree_view->n_model_columns++;
+  view->priv->model_column_linked =
+    gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                           &tree_view->n_model_columns,
+                                           G_TYPE_BOOLEAN);
 
   gimp_container_tree_view_set_dnd_drop_to_empty (tree_view, TRUE);
 
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index b99c142..bfef07d 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -47,6 +47,7 @@
 
 #include "gimpactiongroup.h"
 #include "gimpcellrendererviewable.h"
+#include "gimpcontainertreestore.h"
 #include "gimpcontainerview.h"
 #include "gimpdnd.h"
 #include "gimphelp-ids.h"
@@ -265,22 +266,15 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
                                             GIMP_TYPE_LAYER_TREE_VIEW,
                                             GimpLayerTreeViewPriv);
 
-  /* The following used to read:
-   *
-   * tree_view->model_columns[tree_view->n_model_columns++] = ...
-   *
-   * but combining the two lead to gcc miscompiling the function on ppc/ia64
-   * (model_column_mask and model_column_mask_visible would have the same
-   * value, probably due to bad instruction reordering). See bug #113144 for
-   * more info.
-   */
-  view->priv->model_column_mask = tree_view->n_model_columns;
-  tree_view->model_columns[tree_view->n_model_columns] = GIMP_TYPE_VIEW_RENDERER;
-  tree_view->n_model_columns++;
+  view->priv->model_column_mask =
+    gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                           &tree_view->n_model_columns,
+                                           GIMP_TYPE_VIEW_RENDERER);
 
-  view->priv->model_column_mask_visible = tree_view->n_model_columns;
-  tree_view->model_columns[tree_view->n_model_columns] = G_TYPE_BOOLEAN;
-  tree_view->n_model_columns++;
+  view->priv->model_column_mask_visible =
+    gimp_container_tree_store_columns_add (tree_view->model_columns,
+                                           &tree_view->n_model_columns,
+                                           G_TYPE_BOOLEAN);
 
   /*  Paint mode menu  */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]