Commit 104d0ffb authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: add gimp_container_tree_store_columns_add()

which adds a column to the GType array used for creating a
GimpContainerTreeStore.
parent 82a5c62e
......@@ -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,
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment