new functions, recursive process tree to specified depth

* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
  (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
  tree to specified depth
  (gtk_ctree_expand_to_depth): expand tree to specified depth
  (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
This commit is contained in:
Lars Hamann 1998-07-20 19:45:45 +00:00
parent bfa2ec274b
commit cebb7bfc9f
9 changed files with 255 additions and 26 deletions

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -1,3 +1,11 @@
Mon Jul 20 21:28:18 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
(gtk_ctree_pre_recursive_to_depth): new functions, recursive process
tree to specified depth
(gtk_ctree_expand_to_depth): expand tree to specified depth
(gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
Sun Jul 19 23:51:05 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case

View File

@ -125,6 +125,9 @@ static void tree_expand (GtkCTree *ctree,
static void tree_collapse (GtkCTree *ctree,
GList *node,
gpointer data);
static void tree_collapse_to_depth (GtkCTree *ctree,
GList *node,
gint depth);
static void tree_toggle_expansion (GtkCTree *ctree,
GList *node,
gpointer data);
@ -3225,6 +3228,15 @@ tree_collapse (GtkCTree *ctree,
data);
}
static void
tree_collapse_to_depth (GtkCTree *ctree,
GList *node,
gint depth)
{
if (node && GTK_CTREE_ROW (node)->level == depth)
gtk_ctree_collapse_recursive (ctree, node);
}
static void
tree_toggle_expansion (GtkCTree *ctree,
GList *node,
@ -3883,6 +3895,9 @@ gtk_ctree_post_recursive (GtkCTree *ctree,
GList *work;
GList *tmp;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (node)
work = GTK_CTREE_ROW (node)->children;
else
@ -3899,6 +3914,44 @@ gtk_ctree_post_recursive (GtkCTree *ctree,
func (ctree, node, data);
}
void
gtk_ctree_post_recursive_to_depth (GtkCTree *ctree,
GList *node,
gint depth,
GtkCTreeFunc func,
gpointer data)
{
GList *work;
GList *tmp;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (depth < 0)
{
gtk_ctree_post_recursive (ctree, node, func, data);
return;
}
if (node)
work = GTK_CTREE_ROW (node)->children;
else
work = GTK_CLIST (ctree)->row_list;
if (work && GTK_CTREE_ROW (work)->level <= depth)
{
while (work)
{
tmp = GTK_CTREE_ROW (work)->sibling;
gtk_ctree_post_recursive_to_depth (ctree, work, depth, func, data);
work = tmp;
}
}
if (node && GTK_CTREE_ROW (node)->level <= depth)
func (ctree, node, data);
}
void
gtk_ctree_pre_recursive (GtkCTree *ctree,
GList *node,
@ -3908,6 +3961,8 @@ gtk_ctree_pre_recursive (GtkCTree *ctree,
GList *work;
GList *tmp;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (node)
{
@ -3925,6 +3980,45 @@ gtk_ctree_pre_recursive (GtkCTree *ctree,
}
}
void
gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree,
GList *node,
gint depth,
GtkCTreeFunc func,
gpointer data)
{
GList *work;
GList *tmp;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (depth < 0)
{
gtk_ctree_pre_recursive (ctree, node, func, data);
return;
}
if (node)
{
work = GTK_CTREE_ROW (node)->children;
if (GTK_CTREE_ROW (node)->level <= depth)
func (ctree, node, data);
}
else
work = GTK_CLIST (ctree)->row_list;
if (work && GTK_CTREE_ROW (work)->level <= depth)
{
while (work)
{
tmp = GTK_CTREE_ROW (work)->sibling;
gtk_ctree_pre_recursive_to_depth (ctree, work, depth, func, data);
work = tmp;
}
}
}
gboolean
gtk_ctree_is_visible (GtkCTree *ctree,
GList *node)
@ -4085,6 +4179,7 @@ gtk_ctree_expand_recursive (GtkCTree *ctree,
gboolean thaw = FALSE;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
clist = GTK_CLIST (ctree);
@ -4104,6 +4199,36 @@ gtk_ctree_expand_recursive (GtkCTree *ctree,
gtk_clist_thaw (clist);
}
void
gtk_ctree_expand_to_depth (GtkCTree *ctree,
GList *node,
gint depth)
{
GtkCList *clist;
gboolean thaw = FALSE;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
clist = GTK_CLIST (ctree);
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
if (((node && gtk_ctree_is_visible (ctree, node)) || !node) &&
!GTK_CLIST_FROZEN (clist))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
gtk_ctree_post_recursive_to_depth (ctree, node, depth,
GTK_CTREE_FUNC (tree_expand), NULL);
if (thaw)
gtk_clist_thaw (clist);
}
void
gtk_ctree_collapse (GtkCTree *ctree,
GList *node)
@ -4125,6 +4250,7 @@ gtk_ctree_collapse_recursive (GtkCTree *ctree,
gboolean thaw = FALSE;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
@ -4144,6 +4270,37 @@ gtk_ctree_collapse_recursive (GtkCTree *ctree,
gtk_clist_thaw (clist);
}
void
gtk_ctree_collapse_to_depth (GtkCTree *ctree,
GList *node,
gint depth)
{
GtkCList *clist;
gboolean thaw = FALSE;
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
clist = GTK_CLIST (ctree);
if (((node && gtk_ctree_is_visible (ctree, node)) || !node) &&
!GTK_CLIST_FROZEN (clist))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
gtk_ctree_post_recursive_to_depth (ctree, node, depth,
GTK_CTREE_FUNC (tree_collapse_to_depth),
GINT_TO_POINTER (depth));
if (thaw)
gtk_clist_thaw (clist);
}
void
gtk_ctree_toggle_expansion (GtkCTree *ctree,
GList *node)

View File

@ -181,32 +181,42 @@ void gtk_ctree_remove (GtkCTree *ctree,
* information *
***********************************************************/
void gtk_ctree_post_recursive (GtkCTree *ctree,
GList *node,
GtkCTreeFunc func,
gpointer data);
void gtk_ctree_pre_recursive (GtkCTree *ctree,
GList *node,
GtkCTreeFunc func,
gpointer data);
gboolean gtk_ctree_is_visible (GtkCTree *ctree,
GList *node);
GList * gtk_ctree_last (GtkCTree *ctree,
GList *node);
GList * gtk_ctree_find_glist_ptr (GtkCTree *ctree,
GtkCTreeRow *ctree_row);
gint gtk_ctree_find (GtkCTree *ctree,
GList *node,
GList *child);
gboolean gtk_ctree_is_ancestor (GtkCTree *ctree,
GList *node,
GList *child);
GList * gtk_ctree_find_by_row_data (GtkCTree *ctree,
GList *node,
gpointer data);
gboolean gtk_ctree_is_hot_spot (GtkCTree *ctree,
gint x,
gint y);
void gtk_ctree_post_recursive (GtkCTree *ctree,
GList *node,
GtkCTreeFunc func,
gpointer data);
void gtk_ctree_post_recursive_to_depth (GtkCTree *ctree,
GList *node,
gint depth,
GtkCTreeFunc func,
gpointer data);
void gtk_ctree_pre_recursive (GtkCTree *ctree,
GList *node,
GtkCTreeFunc func,
gpointer data);
void gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree,
GList *node,
gint depth,
GtkCTreeFunc func,
gpointer data);
gboolean gtk_ctree_is_visible (GtkCTree *ctree,
GList *node);
GList * gtk_ctree_last (GtkCTree *ctree,
GList *node);
GList * gtk_ctree_find_glist_ptr (GtkCTree *ctree,
GtkCTreeRow *ctree_row);
gint gtk_ctree_find (GtkCTree *ctree,
GList *node,
GList *child);
gboolean gtk_ctree_is_ancestor (GtkCTree *ctree,
GList *node,
GList *child);
GList * gtk_ctree_find_by_row_data (GtkCTree *ctree,
GList *node,
gpointer data);
gboolean gtk_ctree_is_hot_spot (GtkCTree *ctree,
gint x,
gint y);
/***********************************************************
* Tree signals : move, expand, collapse, (un)select *
@ -220,10 +230,16 @@ void gtk_ctree_expand (GtkCTree *ctree,
GList *node);
void gtk_ctree_expand_recursive (GtkCTree *ctree,
GList *node);
void gtk_ctree_expand_to_depth (GtkCTree *ctree,
GList *node,
gint depth);
void gtk_ctree_collapse (GtkCTree *ctree,
GList *node);
void gtk_ctree_collapse_recursive (GtkCTree *ctree,
GList *node);
void gtk_ctree_collapse_to_depth (GtkCTree *ctree,
GList *node,
gint depth);
void gtk_ctree_toggle_expansion (GtkCTree *ctree,
GList *node);
void gtk_ctree_toggle_expansion_recursive (GtkCTree *ctree,