changed to return a gboolean (gtk_ctree_insert_gnode): new function for

Wed Aug  5 02:57:20 1998  Lars Hamann  <lars@gtk.org>

        * gtk/gtkctree.h:
        * gtk/gtkctree.c:
        (gtk_ctree_find): changed to return a gboolean
        (gtk_ctree_insert_gnode): new function for recursive insertion of a
        GNode tree.
        (gtk_ctree_real_select_recursive): fix for extended selection
        (gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
        (gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
This commit is contained in:
Lars Hamann 1998-08-05 02:11:32 +00:00 committed by Tim Janik
parent c4b3014e09
commit e3b8e18524
10 changed files with 213 additions and 18 deletions

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

View File

@ -1,3 +1,14 @@
Wed Aug 5 02:57:20 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.h:
* gtk/gtkctree.c:
(gtk_ctree_find): changed to return a gboolean
(gtk_ctree_insert_gnode): new function for recursive insertion of a
GNode tree.
(gtk_ctree_real_select_recursive): fix for extended selection
(gtk_ctree_sort_recursive): in case node == NULL, sort root nodes too.
(gtk_ctree_set_node_info) (set_node_info): few fixes for expanded flag
Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org> Tue Aug 4 16:18:26 1998 Tim Janik <timj@gtk.org>
* configure.in: version bump to 1.1.1, binary age 0, interface age 0. * configure.in: version bump to 1.1.1, binary age 0, interface age 0.

1
NEWS
View File

@ -4,6 +4,7 @@ What is new in GTK+ 1.1.1:
* Key binding support for GtkListItems and GtkList. * Key binding support for GtkListItems and GtkList.
* Extended selection mode and autoscrolling for GtkLists. * Extended selection mode and autoscrolling for GtkLists.
* A GtkCtree now operates on GtkCTreeNode* structures rather than GList*. * A GtkCtree now operates on GtkCTreeNode* structures rather than GList*.
* GtkCTreeNodes can now be created from GNode trees.
* Bug fixes for GtkNotebook, GtkCList, GtkCombo and GdkWindow reparentation. * Bug fixes for GtkNotebook, GtkCList, GtkCombo and GdkWindow reparentation.

View File

@ -3079,7 +3079,7 @@ set_node_info (GtkCTree *ctree,
tree_cell->text = g_strdup (text); tree_cell->text = g_strdup (text);
tree_cell->spacing = spacing; tree_cell->spacing = spacing;
if (expanded) if (GTK_CTREE_ROW (node)->expanded)
{ {
tree_cell->pixmap = pixmap_opened; tree_cell->pixmap = pixmap_opened;
tree_cell->mask = mask_opened; tree_cell->mask = mask_opened;
@ -3763,6 +3763,75 @@ gtk_ctree_insert (GtkCTree *ctree,
return node; return node;
} }
GtkCTreeNode *
gtk_ctree_insert_gnode (GtkCTree *ctree,
GtkCTreeNode *parent,
GtkCTreeNode *sibling,
GNode *gnode,
GtkCTreeGNodeFunc func,
gpointer data)
{
GtkCTreeNode *cnode = NULL;
GtkCTreeNode *child = NULL;
GtkCTreeNode *new_child;
GtkCTreeRow *new_row;
gboolean thaw;
GNode *work;
guint depth = 1;
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (gnode != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
if (sibling)
g_return_val_if_fail (GTK_CTREE_ROW (sibling)->parent == parent, NULL);
if (parent)
depth = GTK_CTREE_ROW (parent)->level + 1;
if (!(new_row = row_new (ctree)))
return NULL;
if (!(cnode = GTK_CTREE_NODE (g_list_alloc ())))
return NULL;
GTK_CTREE_ROW (cnode) = new_row;
set_node_info (ctree, cnode, "", 0, NULL, NULL, NULL, NULL, TRUE, FALSE);
if (!func (ctree, depth, gnode, cnode, data))
{
tree_delete_row (ctree, cnode, NULL);
return NULL;
}
if ((thaw = !GTK_CLIST_FROZEN (GTK_CLIST (ctree))))
gtk_clist_freeze (GTK_CLIST (ctree));
if (ctree->auto_sort)
{
if (parent)
sibling = GTK_CTREE_ROW (parent)->children;
else
sibling = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
while (sibling && ctree->node_compare (ctree, cnode, sibling) > 0)
sibling = GTK_CTREE_ROW (sibling)->sibling;
}
gtk_ctree_link (ctree, cnode, parent, sibling, TRUE);
for (work = g_node_last_child (gnode); work; work = work->prev)
{
new_child = gtk_ctree_insert_gnode (ctree, cnode, child,
work, func, data);
if (new_child)
child = new_child;
}
if (thaw)
gtk_clist_thaw (GTK_CLIST (ctree));
return cnode;
}
void void
gtk_ctree_remove (GtkCTree *ctree, gtk_ctree_remove (GtkCTree *ctree,
GtkCTreeNode *node) GtkCTreeNode *node)
@ -3847,6 +3916,7 @@ gtk_ctree_post_recursive (GtkCTree *ctree,
g_return_if_fail (ctree != NULL); g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree)); g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
if (node) if (node)
work = GTK_CTREE_ROW (node)->children; work = GTK_CTREE_ROW (node)->children;
@ -3876,6 +3946,7 @@ gtk_ctree_post_recursive_to_depth (GtkCTree *ctree,
g_return_if_fail (ctree != NULL); g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree)); g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
if (depth < 0) if (depth < 0)
{ {
@ -3913,6 +3984,7 @@ gtk_ctree_pre_recursive (GtkCTree *ctree,
g_return_if_fail (ctree != NULL); g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree)); g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
if (node) if (node)
{ {
@ -3942,6 +4014,7 @@ gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree,
g_return_if_fail (ctree != NULL); g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree)); g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
if (depth < 0) if (depth < 0)
{ {
@ -4030,11 +4103,17 @@ gtk_ctree_find_glist_ptr (GtkCTree *ctree,
return node; return node;
} }
gint gboolean
gtk_ctree_find (GtkCTree *ctree, gtk_ctree_find (GtkCTree *ctree,
GtkCTreeNode *node, GtkCTreeNode *node,
GtkCTreeNode *child) GtkCTreeNode *child)
{ {
if (!child)
return FALSE;
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
while (node) while (node)
{ {
if (node == child) if (node == child)
@ -4054,6 +4133,8 @@ gtk_ctree_is_ancestor (GtkCTree *ctree,
GtkCTreeNode *node, GtkCTreeNode *node,
GtkCTreeNode *child) GtkCTreeNode *child)
{ {
g_return_val_if_fail (node != NULL, FALSE);
return gtk_ctree_find (ctree, GTK_CTREE_ROW (node)->children, child); return gtk_ctree_find (ctree, GTK_CTREE_ROW (node)->children, child);
} }
@ -4064,6 +4145,9 @@ gtk_ctree_find_by_row_data (GtkCTree *ctree,
{ {
GtkCTreeNode *work; GtkCTreeNode *work;
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
while (node) while (node)
{ {
if (GTK_CTREE_ROW (node)->row.data == data) if (GTK_CTREE_ROW (node)->row.data == data)
@ -4085,6 +4169,11 @@ gtk_ctree_find_by_row_data_custom (GtkCTree *ctree,
{ {
GtkCTreeNode *work; GtkCTreeNode *work;
g_return_val_if_fail (func != NULL, NULL);
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
while (node) while (node)
{ {
if (!func (GTK_CTREE_ROW (node)->row.data, data)) if (!func (GTK_CTREE_ROW (node)->row.data, data))
@ -4377,8 +4466,8 @@ gtk_ctree_real_select_recursive (GtkCTree *ctree,
clist = GTK_CLIST (ctree); clist = GTK_CLIST (ctree);
if ((state && if ((state &&
(clist->selection_mode != GTK_SELECTION_MULTIPLE || (clist->selection_mode == GTK_SELECTION_BROWSE ||
clist->selection_mode == GTK_SELECTION_EXTENDED)) || clist->selection_mode == GTK_SELECTION_SINGLE)) ||
(!state && clist->selection_mode == GTK_SELECTION_BROWSE)) (!state && clist->selection_mode == GTK_SELECTION_BROWSE))
return; return;
@ -4389,6 +4478,17 @@ gtk_ctree_real_select_recursive (GtkCTree *ctree,
thaw = TRUE; thaw = TRUE;
} }
if (clist->selection_mode == GTK_SELECTION_EXTENDED)
{
if (clist->anchor != -1)
GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
if (state) if (state)
gtk_ctree_post_recursive (ctree, node, gtk_ctree_post_recursive (ctree, node,
GTK_CTREE_FUNC (tree_select), NULL); GTK_CTREE_FUNC (tree_select), NULL);
@ -4513,17 +4613,18 @@ gtk_ctree_set_node_info (GtkCTree *ctree,
} }
set_node_info (ctree, node, text, spacing, pixmap_closed, mask_closed, set_node_info (ctree, node, text, spacing, pixmap_closed, mask_closed,
pixmap_opened, mask_opened, is_leaf, old_expanded); pixmap_opened, mask_opened, is_leaf, expanded);
if (!is_leaf && !old_leaf) if (!is_leaf && !old_leaf)
{ {
GTK_CTREE_ROW (node)->expanded = old_expanded;
if (expanded && !old_expanded) if (expanded && !old_expanded)
gtk_ctree_expand (ctree, node); gtk_ctree_expand (ctree, node);
else if (!expanded && old_expanded) else if (!expanded && old_expanded)
gtk_ctree_collapse (ctree, node); gtk_ctree_collapse (ctree, node);
} }
GTK_CTREE_ROW (node)->expanded = expanded; GTK_CTREE_ROW (node)->expanded = (is_leaf) ? FALSE : expanded;
tree_draw_node (ctree, node); tree_draw_node (ctree, node);
} }
@ -4973,12 +5074,15 @@ gtk_ctree_sort_recursive (GtkCTree *ctree,
clist->undo_unselection = NULL; clist->undo_unselection = NULL;
} }
if (node && gtk_ctree_is_visible (ctree, node)) if (!node || (node && gtk_ctree_is_visible (ctree, node)))
focus_node = focus_node =
GTK_CTREE_NODE (g_list_nth (clist->row_list, clist->focus_row)); GTK_CTREE_NODE (g_list_nth (clist->row_list, clist->focus_row));
gtk_ctree_post_recursive (ctree, node, GTK_CTREE_FUNC (tree_sort), NULL); gtk_ctree_post_recursive (ctree, node, GTK_CTREE_FUNC (tree_sort), NULL);
if (!node)
tree_sort (ctree, NULL, NULL);
if (focus_node) if (focus_node)
{ {
clist->focus_row = g_list_position (clist->row_list,(GList *)focus_node); clist->focus_row = g_list_position (clist->row_list,(GList *)focus_node);
@ -5019,7 +5123,7 @@ gtk_ctree_sort (GtkCTree *ctree,
clist->undo_unselection = NULL; clist->undo_unselection = NULL;
} }
if (node && gtk_ctree_is_visible (ctree, node)) if (!node || (node && gtk_ctree_is_visible (ctree, node)))
focus_node = GTK_CTREE_NODE focus_node = GTK_CTREE_NODE
(g_list_nth (clist->row_list, clist->focus_row)); (g_list_nth (clist->row_list, clist->focus_row));

View File

@ -29,6 +29,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#pragma }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define GTK_TYPE_CTREE (gtk_ctree_get_type ()) #define GTK_TYPE_CTREE (gtk_ctree_get_type ())
@ -84,16 +85,23 @@ typedef gint (*GtkCTreeCompareFunc) (GtkCTree *ctree,
const GtkCTreeNode *node1, const GtkCTreeNode *node1,
const GtkCTreeNode *node2); const GtkCTreeNode *node2);
typedef gboolean (*GtkCTreeGNodeFunc) (GtkCTree *ctree,
guint depth,
GNode *gnode,
GtkCTreeNode *cnode,
gpointer data);
struct _GtkCTree struct _GtkCTree
{ {
GtkCList clist; GtkCList clist;
GdkGC *xor_gc; GdkGC *xor_gc;
GdkGC *lines_gc; GdkGC *lines_gc;
GdkWindow *drag_icon; GdkWindow *drag_icon;
gint icon_width; gint icon_width;
gint icon_height; gint icon_height;
gint tree_indent; gint tree_indent;
gint tree_column; gint tree_column;
gint drag_row; gint drag_row;
@ -101,7 +109,7 @@ struct _GtkCTree
GtkCTreeNode *drag_target; GtkCTreeNode *drag_target;
gint insert_pos; gint insert_pos;
GtkCTreeCompareFunc node_compare; GtkCTreeCompareFunc node_compare;
guint auto_sort : 1; guint auto_sort : 1;
guint reorderable : 1; guint reorderable : 1;
guint use_icons : 1; guint use_icons : 1;
@ -113,7 +121,7 @@ struct _GtkCTree
struct _GtkCTreeClass struct _GtkCTreeClass
{ {
GtkCListClass parent_class; GtkCListClass parent_class;
void (*tree_select_row) (GtkCTree *ctree, void (*tree_select_row) (GtkCTree *ctree,
GtkCTreeNode *row, GtkCTreeNode *row,
gint column); gint column);
@ -135,18 +143,18 @@ struct _GtkCTreeClass
struct _GtkCTreeRow struct _GtkCTreeRow
{ {
GtkCListRow row; GtkCListRow row;
GtkCTreeNode *parent; GtkCTreeNode *parent;
GtkCTreeNode *sibling; GtkCTreeNode *sibling;
GtkCTreeNode *children; GtkCTreeNode *children;
GdkPixmap *pixmap_closed; GdkPixmap *pixmap_closed;
GdkBitmap *mask_closed; GdkBitmap *mask_closed;
GdkPixmap *pixmap_opened; GdkPixmap *pixmap_opened;
GdkBitmap *mask_opened; GdkBitmap *mask_opened;
guint16 level; guint16 level;
guint is_leaf : 1; guint is_leaf : 1;
guint expanded : 1; guint expanded : 1;
}; };
@ -181,6 +189,12 @@ GtkCTreeNode * gtk_ctree_insert (GtkCTree *ctree,
GdkBitmap *mask_opened, GdkBitmap *mask_opened,
gboolean is_leaf, gboolean is_leaf,
gboolean expanded); gboolean expanded);
GtkCTreeNode * gtk_ctree_insert_gnode (GtkCTree *ctree,
GtkCTreeNode *parent,
GtkCTreeNode *sibling,
GNode *gnode,
GtkCTreeGNodeFunc func,
gpointer data);
void gtk_ctree_remove (GtkCTree *ctree, void gtk_ctree_remove (GtkCTree *ctree,
GtkCTreeNode *node); GtkCTreeNode *node);
@ -213,7 +227,7 @@ GtkCTreeNode * gtk_ctree_last (GtkCTree *ctree,
GtkCTreeNode *node); GtkCTreeNode *node);
GtkCTreeNode * gtk_ctree_find_glist_ptr (GtkCTree *ctree, GtkCTreeNode * gtk_ctree_find_glist_ptr (GtkCTree *ctree,
GtkCTreeRow *ctree_row); GtkCTreeRow *ctree_row);
gint gtk_ctree_find (GtkCTree *ctree, gboolean gtk_ctree_find (GtkCTree *ctree,
GtkCTreeNode *node, GtkCTreeNode *node,
GtkCTreeNode *child); GtkCTreeNode *child);
gboolean gtk_ctree_is_ancestor (GtkCTree *ctree, gboolean gtk_ctree_is_ancestor (GtkCTree *ctree,
@ -378,7 +392,6 @@ void gtk_ctree_sort (GtkCTree *ctree,
GtkCTreeNode *node); GtkCTreeNode *node);
void gtk_ctree_sort_recursive (GtkCTree *ctree, void gtk_ctree_sort_recursive (GtkCTree *ctree,
GtkCTreeNode *node); GtkCTreeNode *node);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */