aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross@linux.intel.com>2006-03-18 13:04:12 +0000
committerRoss Burton <ross@linux.intel.com>2006-03-18 13:04:12 +0000
commit6423185860269f40b3d29c2dbc24aa156b8508d2 (patch)
tree1e2d5e4b914c06e3b26336be177a2d5a2207aaf7
parente4290f65fa8f8ea75edd4ae8a3ee3b77c7b750ea (diff)
downloadlibowl-6423185860269f40b3d29c2dbc24aa156b8508d2.tar.gz
libowl-6423185860269f40b3d29c2dbc24aa156b8508d2.tar.bz2
libowl-6423185860269f40b3d29c2dbc24aa156b8508d2.zip
2006-03-18 Ross Burton <ross@openedhand.com>
* libowl/owltreemodelslice.[ch]: Add owl_tree_model_slice_set_root(). Rename gtk_tree_model_slice_get_model() to owl_tree_model_slice_get_model(). Fix memory leaks and corruption.
-rw-r--r--ChangeLog6
-rw-r--r--libowl/owltreemodelslice.c48
-rw-r--r--libowl/owltreemodelslice.h4
3 files changed, 45 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index e69de29..e0ea59a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,6 @@
+2006-03-18 Ross Burton <ross@openedhand.com>
+
+ * libowl/owltreemodelslice.[ch]:
+ Add owl_tree_model_slice_set_root().
+ Rename gtk_tree_model_slice_get_model() to owl_tree_model_slice_get_model().
+ Fix memory leaks and corruption.
diff --git a/libowl/owltreemodelslice.c b/libowl/owltreemodelslice.c
index 356683f..c0d33a4 100644
--- a/libowl/owltreemodelslice.c
+++ b/libowl/owltreemodelslice.c
@@ -112,7 +112,7 @@ convert_to_child (OwlTreeModelSlice *slice, GtkTreePath *path)
g_assert (path);
if (slice->priv->root == NULL)
- return path;
+ return gtk_tree_path_copy (path);
new_path = gtk_tree_path_copy (slice->priv->root);
depth = gtk_tree_path_get_depth (path);
@@ -128,14 +128,16 @@ owl_tree_model_slice_get_iter (GtkTreeModel *model,
GtkTreePath *path)
{
OwlTreeModelSlice *slice = OWL_TREE_MODEL_SLICE (model);
- GtkTreePath *new_path;
+ GtkTreePath *child_path;
+ gboolean res;
g_return_val_if_fail (slice != NULL, FALSE);
g_return_val_if_fail (slice->priv->child_model != NULL, FALSE);
- new_path = convert_to_child (slice, path);
-
- return gtk_tree_model_get_iter (slice->priv->child_model, iter, new_path);
+ child_path = convert_to_child (slice, path);
+ res = gtk_tree_model_get_iter (slice->priv->child_model, iter, child_path);
+ gtk_tree_path_free (child_path);
+ return res;
}
static void
@@ -253,28 +255,50 @@ owl_tree_model_slice_new (GtkTreeModel *child_model,
slice = g_object_new (OWL_TYPE_TREE_MODEL_SLICE, NULL);
slice->priv->child_model = child_model;
- slice->priv->root = root;
-
+ slice->priv->root = gtk_tree_path_copy (root);
return (GtkTreeModel *)slice;
}
GtkTreeModel *
-gtk_tree_model_slice_get_model (OwlTreeModelSlice *slice)
+owl_tree_model_slice_get_model (OwlTreeModelSlice *slice)
{
g_return_val_if_fail (OWL_IS_TREE_MODEL_SLICE (slice), NULL);
return slice->priv->child_model;
}
+void
+owl_tree_model_slice_set_root (OwlTreeModelSlice *slice, GtkTreePath *root)
+{
+ g_return_if_fail (OWL_IS_TREE_MODEL_SLICE (slice));
+ g_return_if_fail (OWL_IS_TREE_MODEL_SLICE (slice->priv->child_model));
+
+ slice->priv->root = gtk_tree_path_copy (root);
+ /* TODO: emit change events */
+}
-/* TODO */
-void owl_tree_model_slice_convert_child_iter_to_iter (OwlTreeModelSlice *slice,
+#if 0
+/* Not sure we need these */
+void
+owl_tree_model_slice_convert_child_iter_to_iter (OwlTreeModelSlice *slice,
GtkTreeIter *slice_iter,
GtkTreeIter *child_iter);
void owl_tree_model_slice_convert_iter_to_child_iter (OwlTreeModelSlice *slice,
GtkTreeIter *child_iter,
GtkTreeIter *slice_iter);
+#endif
+
+
+/* TODO */
GtkTreePath *owl_tree_model_slice_convert_child_path_to_path (OwlTreeModelSlice *slice,
GtkTreePath *child_path);
-GtkTreePath *owl_tree_model_slice_convert_path_to_child_path (OwlTreeModelSlice *slice,
- GtkTreePath *slice_path);
+
+GtkTreePath *
+owl_tree_model_slice_convert_path_to_child_path (OwlTreeModelSlice *slice, GtkTreePath *slice_path)
+{
+ g_return_val_if_fail (OWL_IS_TREE_MODEL_SLICE (slice), NULL);
+ g_return_val_if_fail (slice->priv->child_model != NULL, NULL);
+ g_return_val_if_fail (slice_path != NULL, NULL);
+
+ return convert_to_child (slice, slice_path);
+}
diff --git a/libowl/owltreemodelslice.h b/libowl/owltreemodelslice.h
index 5564503..b93c62e 100644
--- a/libowl/owltreemodelslice.h
+++ b/libowl/owltreemodelslice.h
@@ -52,7 +52,9 @@ GType owl_tree_model_slice_get_type (void) G_GNUC_CONS
GtkTreeModel *owl_tree_model_slice_new (GtkTreeModel *child_model,
GtkTreePath *root);
-GtkTreeModel *gtk_tree_model_slice_get_model (OwlTreeModelSlice *slice);
+GtkTreeModel *owl_tree_model_slice_get_model (OwlTreeModelSlice *slice);
+
+void owl_tree_model_slice_set_root (OwlTreeModelSlice *slice, GtkTreePath *root);
/* TODO */
void owl_tree_model_slice_convert_child_iter_to_iter (OwlTreeModelSlice *slice,