diff options
author | Lars Hamann <lars@gtk.org> | 1998-12-02 00:52:14 +0000 |
---|---|---|
committer | Lars Hamann <lars@src.gnome.org> | 1998-12-02 00:52:14 +0000 |
commit | 4ebc61c067af80a3cd24f1cfd79ec6b6be80e350 (patch) | |
tree | 9113164bd41b9a111b0a0512bda4eca1a4491ee0 /gtk/gtkctree.c | |
parent | 70784023413b1e6fb748ad5e51d8d311ed651f0f (diff) | |
download | gtk+-4ebc61c067af80a3cd24f1cfd79ec6b6be80e350.tar.gz |
new class method/signal row_move. new public function. emit a row_move
Tue Dec 1 22:45:58 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkclist.h (struct _GtkCListClass): new class method/signal
row_move.
* gtk/gtkclist.c (gtk_clist_row_move): new public function.
emit a row_move signal
(real_row_move): move source_row to dest_row
(gtk_clist_swap_rows): use gtk_clist_row_move calls.
(gtk_clist_columns_autosize): resize all columns to their optimal
width
* gtk/gtkctree.c (real_row_move): use gtk_ctree_move to move
entire sub-tree.
* gtk/gtknotebook.c (gtk_notebook_nth_page): get nth page widget.
Diffstat (limited to 'gtk/gtkctree.c')
-rw-r--r-- | gtk/gtkctree.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c index 6750279aec..132e3a44b6 100644 --- a/gtk/gtkctree.c +++ b/gtk/gtkctree.c @@ -207,6 +207,9 @@ static void real_tree_move (GtkCTree *ctree, GtkCTreeNode *node, GtkCTreeNode *new_parent, GtkCTreeNode *new_sibling); +static void real_row_move (GtkCList *clist, + gint source_row, + gint dest_row); static void gtk_ctree_link (GtkCTree *ctree, GtkCTreeNode *node, GtkCTreeNode *parent, @@ -424,6 +427,7 @@ gtk_ctree_class_init (GtkCTreeClass *klass) clist_class->select_row = real_select_row; clist_class->unselect_row = real_unselect_row; + clist_class->row_move = real_row_move; clist_class->undo_selection = real_undo_selection; clist_class->resync_selection = resync_selection; clist_class->selection_find = selection_find; @@ -2650,6 +2654,56 @@ gtk_ctree_unlink (GtkCTree *ctree, } static void +real_row_move (GtkCList *clist, + gint source_row, + gint dest_row) +{ + GtkCTree *ctree; + GtkCTreeNode *node; + + g_return_if_fail (clist != NULL); + g_return_if_fail (GTK_IS_CTREE (clist)); + + if (GTK_CLIST_AUTO_SORT (clist)) + return; + + if (source_row < 0 || source_row >= clist->rows || + dest_row < 0 || dest_row >= clist->rows || + source_row == dest_row) + return; + + ctree = GTK_CTREE (clist); + node = GTK_CTREE_NODE (g_list_nth (clist->row_list, source_row)); + + if (source_row < dest_row) + { + GtkCTreeNode *work; + + dest_row++; + work = GTK_CTREE_ROW (node)->children; + + while (work && GTK_CTREE_ROW (work)->level > GTK_CTREE_ROW (node)->level) + { + work = GTK_CTREE_NODE_NEXT (work); + dest_row++; + } + + if (dest_row > clist->rows) + dest_row = clist->rows; + } + + if (dest_row < clist->rows) + { + GtkCTreeNode *sibling; + + sibling = GTK_CTREE_NODE (g_list_nth (clist->row_list, dest_row)); + gtk_ctree_move (ctree, node, GTK_CTREE_ROW (sibling)->parent, sibling); + } + else + gtk_ctree_move (ctree, node, NULL, NULL); +} + +static void real_tree_move (GtkCTree *ctree, GtkCTreeNode *node, GtkCTreeNode *new_parent, |