From f164436f8695f8994b9a73cf82869ce01ad10eb6 Mon Sep 17 00:00:00 2001 From: Lars Hamann Date: Wed, 11 Nov 1998 20:46:51 +0000 Subject: [PATCH] added ARG_WINDOW_PLACEMENT Wed Nov 11 19:54:58 1998 Lars Hamann * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): added ARG_WINDOW_PLACEMENT * gtk/gtkclist.c (size_allocate_columns): resize column if column button > column width and auto_resize is set (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): consider column button width of auto resized columns (gtk_clist_parent_set): removed * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. (auto_resize_columns): auto_resize all columns (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns (column_auto_resize): respect column button width of auto resized columns --- ChangeLog | 18 +++++++ ChangeLog.pre-2-0 | 18 +++++++ ChangeLog.pre-2-10 | 18 +++++++ ChangeLog.pre-2-2 | 18 +++++++ ChangeLog.pre-2-4 | 18 +++++++ ChangeLog.pre-2-6 | 18 +++++++ ChangeLog.pre-2-8 | 18 +++++++ gtk/gtkclist.c | 97 ++++++++++++++++++------------------- gtk/gtkctree.c | 104 ++++++++++++---------------------------- gtk/gtkscrolledwindow.c | 14 +++++- gtk/testgtk.c | 64 +++++++++---------------- tests/testgtk.c | 64 +++++++++---------------- 12 files changed, 264 insertions(+), 205 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 3daa51721c..ebf52f9c5a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +Wed Nov 11 19:54:58 1998 Lars Hamann + + * gtk/gtkscrolledwindow.c (gtk_scrolled_window_class_init) + (gtk_scrolled_window_set_arg) (gtk_scrolled_window_get_arg): + added ARG_WINDOW_PLACEMENT + + * gtk/gtkclist.c (size_allocate_columns): resize column if column + button > column width and auto_resize is set + (real_clear) (column_auto_resize) (gtk_clist_optimal_column_width): + consider column button width of auto resized columns + (gtk_clist_parent_set): removed + + * gtk/gtkctree.c (gtk_ctree_insert_node): call column_auto_resize. + (auto_resize_columns): auto_resize all columns + (real_tree_collapse) (gtk_ctree_remove_node): call auto_resize_columns + (column_auto_resize): respect column button width of auto resized + columns + 1998-11-10 Martin Baulig * gtk/gtkfeatures.h.in (GTK_HAVE_FEATURES_1_1_4): Define this so diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c index de78722f5b..e39135cddb 100644 --- a/gtk/gtkclist.c +++ b/gtk/gtkclist.c @@ -188,8 +188,6 @@ static gint gtk_clist_focus (GtkContainer *container, GtkDirectionType direction); static void gtk_clist_style_set (GtkWidget *widget, GtkStyle *previous_style); -static void gtk_clist_parent_set (GtkWidget *widget, - GtkWidget *previous_parent); /* GtkContainer Methods */ static void gtk_clist_set_focus_child (GtkContainer *container, @@ -324,7 +322,8 @@ static void draw_rows (GtkCList *clist, /* Size Allocation / Requisition */ static void size_allocate_title_buttons (GtkCList *clist); -static void size_allocate_columns (GtkCList *clist); +static void size_allocate_columns (GtkCList *clist, + gboolean block_resize); static gint list_requisition_width (GtkCList *clist); /* Memory Allocation/Distruction Routines */ @@ -559,7 +558,6 @@ gtk_clist_class_init (GtkCListClass *klass) widget_class->focus_out_event = gtk_clist_focus_out; widget_class->draw_focus = gtk_clist_draw_focus; widget_class->style_set = gtk_clist_style_set; - widget_class->parent_set = gtk_clist_parent_set; /* container_class->add = NULL; use the default GtkContainerClass warning */ /* container_class->remove=NULL; use the default GtkContainerClass warning */ @@ -1530,7 +1528,7 @@ gtk_clist_optimal_column_width (GtkCList *clist, { GtkRequisition requisition; GList *list; - gint width = 0; + gint width; g_return_val_if_fail (clist != NULL, 0); g_return_val_if_fail (GTK_CLIST (clist), 0); @@ -1538,6 +1536,12 @@ gtk_clist_optimal_column_width (GtkCList *clist, if (column < 0 || column > clist->columns) return 0; + if (GTK_CLIST_SHOW_TITLES (clist) && clist->column[column].button) + width = (clist->column[column].button->requisition.width - + (CELL_SPACING + (2 * COLUMN_INSET))); + else + width = 0; + for (list = clist->row_list; list; list = list->next) { GTK_CLIST_CLASS_FW (clist)->cell_size_request @@ -1633,19 +1637,14 @@ column_auto_resize (GtkCList *clist, GTK_CLIST_AUTO_RESIZE_BLOCKED (clist)) return; - GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row, - column, &requisition); + if (clist_row) + GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row, + column, &requisition); + else + requisition.width = 0; if (requisition.width > clist->column[column].width) - { - if (clist->column[column].max_width < 0) - gtk_clist_set_column_width (clist, column, requisition.width); - else if (clist->column[column].max_width > - clist->column[column].width) - gtk_clist_set_column_width (clist, column, - MIN (requisition.width, - clist->column[column].max_width)); - } + gtk_clist_set_column_width (clist, column, requisition.width); else if (requisition.width < old_width && old_width == clist->column[column].width) { @@ -1654,7 +1653,12 @@ column_auto_resize (GtkCList *clist, /* run a "gtk_clist_optimal_column_width" but break, if * the column doesn't shrink */ - new_width = 0; + if (GTK_CLIST_SHOW_TITLES (clist) && clist->column[column].button) + new_width = (clist->column[column].button->requisition.width - + (CELL_SPACING + (2 * COLUMN_INSET))); + else + new_width = 0; + for (list = clist->row_list; list; list = list->next) { GTK_CLIST_CLASS_FW (clist)->cell_size_request @@ -1685,7 +1689,7 @@ real_resize_column (GtkCList *clist, if (clist->column[column].max_width >= 0 && width > clist->column[column].max_width) width = clist->column[column].max_width; - + clist->column[column].width = width; clist->column[column].width_set = TRUE; @@ -1693,7 +1697,7 @@ real_resize_column (GtkCList *clist, * been size_allocated yet, and pointless. Should * a flag be kept */ - size_allocate_columns (clist); + size_allocate_columns (clist, TRUE); size_allocate_title_buttons (clist); if (!GTK_CLIST_FROZEN (clist)) @@ -1804,7 +1808,8 @@ size_allocate_title_buttons (GtkCList *clist) } static void -size_allocate_columns (GtkCList *clist) +size_allocate_columns (GtkCList *clist, + gboolean block_resize) { gint xoffset = CELL_SPACING + COLUMN_INSET; gint last_column; @@ -1824,6 +1829,18 @@ size_allocate_columns (GtkCList *clist) clist->column[i].area.x = xoffset; if (clist->column[i].width_set) { + if (!block_resize && GTK_CLIST_SHOW_TITLES (clist) && + clist->column[i].auto_resize && clist->column[i].button) + { + gint width; + + width = (clist->column[i].button->requisition.width - + (CELL_SPACING + (2 * COLUMN_INSET))); + + if (width > clist->column[i].width) + gtk_clist_set_column_width (clist, i, width); + } + clist->column[i].area.width = clist->column[i].width; xoffset += clist->column[i].width + CELL_SPACING + (2* COLUMN_INSET); } @@ -2670,9 +2687,15 @@ real_clear (GtkCList *clist) g_list_free (free_list); GTK_CLIST_UNSET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED); for (i = 0; i < clist->columns; i++) - if (clist->column[i].auto_resize && clist->column[i].width > 0) - gtk_clist_set_column_width (clist, i, 0); - + if (clist->column[i].auto_resize) + { + if (GTK_CLIST_SHOW_TITLES (clist) && clist->column[i].button) + gtk_clist_set_column_width + (clist, i, (clist->column[i].button->requisition.width - + (CELL_SPACING + (2 * COLUMN_INSET)))); + else + gtk_clist_set_column_width (clist, i, 0); + } /* zero-out the scrollbars */ if (clist->vadjustment) { @@ -3034,11 +3057,8 @@ gtk_clist_set_row_style (GtkCList *clist, } if (GTK_CLIST_AUTO_RESIZE_BLOCKED (clist)) - { - for (i = 0; i < clist->columns; i++) - if (clist->column[i].auto_resize) - column_auto_resize (clist, clist_row, i, old_width[i]); - } + for (i = 0; i < clist->columns; i++) + column_auto_resize (clist, clist_row, i, old_width[i]); g_free (old_width); @@ -4086,7 +4106,6 @@ gtk_clist_finalize (GtkObject *object) * gtk_clist_draw * gtk_clist_expose * gtk_clist_style_set - * gtk_clist_parent_set * gtk_clist_key_press * gtk_clist_button_press * gtk_clist_button_release @@ -4513,24 +4532,6 @@ gtk_clist_style_set (GtkWidget *widget, } } -static void -gtk_clist_parent_set (GtkWidget *widget, - GtkWidget *previous_parent) -{ - GtkCList *clist; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_WIDGET (widget)); - - clist = GTK_CLIST (widget); - - /* create adjustments */ - /* if (!clist->hadjustment) - gtk_clist_set_hadjustment (clist, NULL); - if (!clist->vadjustment) - gtk_clist_set_vadjustment (clist, NULL);*/ -} - static gint gtk_clist_key_press (GtkWidget *widget, GdkEventKey *event) @@ -5177,7 +5178,7 @@ gtk_clist_size_allocate (GtkWidget *widget, } /* column button allocation */ - size_allocate_columns (clist); + size_allocate_columns (clist, FALSE); size_allocate_title_buttons (clist); adjust_adjustments (clist, TRUE); diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c index 16f7c39251..e3283b0906 100644 --- a/gtk/gtkctree.c +++ b/gtk/gtkctree.c @@ -228,6 +228,7 @@ static void column_auto_resize (GtkCList *clist, GtkCListRow *clist_row, gint column, gint old_width); +static void auto_resize_columns (GtkCList *clist); enum { @@ -2860,31 +2861,7 @@ real_tree_collapse (GtkCTree *ctree, if (visible) { /* resize auto_resize columns if needed */ - if (!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist)) - { - GList *list; - gint new_width; - gint i; - - for (i = 0; i < clist->columns; i++) - if (clist->column[i].auto_resize) - { - /* run a "gtk_clist_optimal_column_width" but break, if - * the column doesn't shrink */ - new_width = 0; - for (list = clist->row_list; list; list = list->next) - { - GTK_CLIST_CLASS_FW (clist)->cell_size_request - (clist, GTK_CLIST_ROW (list), i, &requisition); - new_width = MAX (new_width, requisition.width); - if (new_width == clist->column[i].width) - break; - } - - if (new_width < clist->column[i].width) - gtk_clist_set_column_width (clist, i, new_width); - } - } + auto_resize_columns (clist); row = g_list_position (clist->row_list, (GList *)node); if (row < clist->focus_row) @@ -2915,26 +2892,28 @@ column_auto_resize (GtkCList *clist, GTK_CLIST_AUTO_RESIZE_BLOCKED (clist)) return; - GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row, - column, &requisition); + if (clist_row) + GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row, + column, &requisition); + else + requisition.width = 0; if (requisition.width > clist->column[column].width) - { - if (clist->column[column].max_width < 0) - gtk_clist_set_column_width (clist, column, requisition.width); - else if (clist->column[column].max_width > clist->column[column].width) - gtk_clist_set_column_width (clist, column, - MIN (requisition.width, - clist->column[column].max_width)); - } + gtk_clist_set_column_width (clist, column, requisition.width); else if (requisition.width < old_width && old_width == clist->column[column].width) { GList *list; - gint new_width = 0; + gint new_width; /* run a "gtk_clist_optimal_column_width" but break, if * the column doesn't shrink */ + if (GTK_CLIST_SHOW_TITLES (clist) && clist->column[column].button) + new_width = (clist->column[column].button->requisition.width - + (CELL_SPACING + (2 * COLUMN_INSET))); + else + new_width = 0; + for (list = clist->row_list; list; list = list->next) { GTK_CLIST_CLASS_FW (clist)->cell_size_request @@ -2944,11 +2923,22 @@ column_auto_resize (GtkCList *clist, break; } if (new_width < clist->column[column].width) - gtk_clist_set_column_width - (clist, column, MAX (new_width, clist->column[column].min_width)); + gtk_clist_set_column_width (clist, column, new_width); } } +static void +auto_resize_columns (GtkCList *clist) +{ + gint i; + + if (GTK_CLIST_AUTO_RESIZE_BLOCKED (clist)) + return; + + for (i = 0; i < clist->columns; i++) + column_auto_resize (clist, NULL, i, clist->column[i].width); +} + static void cell_size_request (GtkCList *clist, GtkCListRow *clist_row, @@ -3875,17 +3865,9 @@ gtk_ctree_insert_node (GtkCTree *ctree, if (text && !GTK_CLIST_AUTO_RESIZE_BLOCKED (clist) && gtk_ctree_is_viewable (ctree, node)) { - GtkRequisition requisition; - for (i = 0; i < clist->columns; i++) if (clist->column[i].auto_resize) - { - GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, - &(new_row->row), - i, &requisition); - if (requisition.width > clist->column[i].width) - gtk_clist_set_column_width (clist, i, requisition.width); - } + column_auto_resize (clist, &(new_row->row), i, 0); } if (!GTK_CLIST_FROZEN (clist)) @@ -4061,33 +4043,7 @@ gtk_ctree_remove_node (GtkCTree *ctree, !clist->selection && clist->focus_row >= 0) gtk_clist_select_row (clist, clist->focus_row, -1); - if (!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist)) - { - GtkRequisition requisition; - GList *list; - gint new_width; - gint i; - - for (i = 0; i < clist->columns; i++) - if (clist->column[i].auto_resize) - { - /* run a "gtk_clist_optimal_column_width" but break, if - * the column doesn't shrink */ - new_width = 0; - for (list = clist->row_list; list; list = list->next) - { - GTK_CLIST_CLASS_FW (clist)->cell_size_request - (clist, GTK_CLIST_ROW (list), i, &requisition); - new_width = MAX (new_width, requisition.width); - if (new_width == clist->column[i].width) - break; - } - - if (new_width < clist->column[i].width) - gtk_clist_set_column_width (clist, i, new_width); - } - } - + auto_resize_columns (clist); } else gtk_clist_clear (clist); diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index f64f8d771e..ce2964dc9c 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -26,7 +26,8 @@ enum { ARG_0, ARG_VIEWPORT, ARG_HSCROLLBAR_POLICY, - ARG_VSCROLLBAR_POLICY + ARG_VSCROLLBAR_POLICY, + ARG_WINDOW_PLACEMENT }; @@ -114,6 +115,10 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class) GTK_TYPE_POLICY_TYPE, GTK_ARG_READWRITE, ARG_VSCROLLBAR_POLICY); + gtk_object_add_arg_type ("GtkScrolledWindow::window_placement", + GTK_TYPE_CORNER_TYPE, + GTK_ARG_READWRITE, + ARG_WINDOW_PLACEMENT); object_class->set_arg = gtk_scrolled_window_set_arg; object_class->get_arg = gtk_scrolled_window_get_arg; @@ -159,6 +164,10 @@ gtk_scrolled_window_set_arg (GtkObject *object, scrolled_window->hscrollbar_policy, GTK_VALUE_ENUM (*arg)); break; + case ARG_WINDOW_PLACEMENT: + gtk_scrolled_window_set_placement (scrolled_window, + GTK_VALUE_ENUM (*arg)); + break; default: break; } @@ -184,6 +193,9 @@ gtk_scrolled_window_get_arg (GtkObject *object, case ARG_VSCROLLBAR_POLICY: GTK_VALUE_ENUM (*arg) = scrolled_window->vscrollbar_policy; break; + case ARG_WINDOW_PLACEMENT: + GTK_VALUE_ENUM (*arg) = scrolled_window->window_placement; + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/gtk/testgtk.c b/gtk/testgtk.c index fa3429e690..6bc73ff347 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -3725,10 +3725,10 @@ insert_row_clist (GtkWidget *widget, gpointer data) { static char *text[] = { - "This", "is", "a", "inserted", "row.", - "This", "is", "a", "inserted", "row.", - "This", "is", "a", "inserted", "row.", - "This", "is", "a", "inserted", "row." + "This", "is", "an", "inserted", "row.", + "This", "is", "an", "inserted", "row.", + "This", "is", "an", "inserted", "row.", + "This", "is", "an", "inserted", "row." }; static GtkStyle *style1 = NULL; @@ -3908,7 +3908,6 @@ create_clist (void) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled_win), clist); - /*clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS);*/ gtk_signal_connect (GTK_OBJECT (clist), "click_column", (GtkSignalFunc) clist_click_column, NULL); @@ -4006,8 +4005,6 @@ create_clist (void) gtk_clist_set_row_height (GTK_CLIST (clist), 18); gtk_widget_set_usize (clist, -1, 300); - gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100); - for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++) gtk_clist_set_column_width (GTK_CLIST (clist), i, 80); @@ -4296,7 +4293,6 @@ void change_style (GtkWidget *widget, GtkCTree *ctree) if (GTK_CTREE_ROW (node)->children) gtk_ctree_node_set_row_style (ctree, GTK_CTREE_ROW (node)->children, style2); - } void unselect_all (GtkWidget *widget, GtkCTree *ctree) @@ -4307,50 +4303,37 @@ void unselect_all (GtkWidget *widget, GtkCTree *ctree) void remove_selection (GtkWidget *widget, GtkCTree *ctree) { - GtkCTreeNode *work; - GtkCTreeNode *new_sel; + GtkCList *clist; + GtkCTreeNode *node; GList *selection; + GList *list = NULL; - selection = GTK_CLIST (ctree)->selection; - new_sel = NULL; + clist = GTK_CLIST (ctree); - gtk_clist_freeze (GTK_CLIST (ctree)); + gtk_clist_freeze (clist); + for (selection = clist->selection; selection; selection = selection->next) + list = g_list_prepend (list, selection->data); + + selection = clist->selection; while (selection) { - work = selection->data; - selection = selection->next; + node = selection->data; - if (GTK_CTREE_ROW (work)->is_leaf) + if (!g_list_find (list, node)) + break; + + if (GTK_CTREE_ROW (node)->is_leaf) pages--; else - gtk_ctree_post_recursive (ctree, work, + gtk_ctree_post_recursive (ctree, node, (GtkCTreeFunc) count_items, NULL); - if (GTK_CLIST (ctree)->selection_mode == GTK_SELECTION_BROWSE) - { - if (GTK_CTREE_ROW (work)->children) - { - new_sel = GTK_CTREE_ROW (work)->sibling; - if (!new_sel) - new_sel = GTK_CTREE_NODE_NEXT (work); - } - else - { - if (GTK_CTREE_NODE_NEXT (work)) - new_sel = GTK_CTREE_NODE_NEXT (work); - else - new_sel = GTK_CTREE_NODE_PREV (work); - } - } - - gtk_ctree_remove_node (ctree, work); + gtk_ctree_remove_node (ctree, node); + selection = clist->selection; } - - if (new_sel) - gtk_ctree_select (ctree, new_sel); - - gtk_clist_thaw (GTK_CLIST (ctree)); + g_list_free (list); + gtk_clist_thaw (clist); after_press (ctree, NULL); } @@ -4880,7 +4863,6 @@ void create_ctree (void) gtk_container_border_width (GTK_CONTAINER (scrolled_win), 5); gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0); gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_EXTENDED); - gtk_clist_set_column_min_width (GTK_CLIST (ctree), 0, 50); gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE); gtk_clist_set_column_width (GTK_CLIST (ctree), 1, 200); diff --git a/tests/testgtk.c b/tests/testgtk.c index fa3429e690..6bc73ff347 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -3725,10 +3725,10 @@ insert_row_clist (GtkWidget *widget, gpointer data) { static char *text[] = { - "This", "is", "a", "inserted", "row.", - "This", "is", "a", "inserted", "row.", - "This", "is", "a", "inserted", "row.", - "This", "is", "a", "inserted", "row." + "This", "is", "an", "inserted", "row.", + "This", "is", "an", "inserted", "row.", + "This", "is", "an", "inserted", "row.", + "This", "is", "an", "inserted", "row." }; static GtkStyle *style1 = NULL; @@ -3908,7 +3908,6 @@ create_clist (void) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled_win), clist); - /*clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS);*/ gtk_signal_connect (GTK_OBJECT (clist), "click_column", (GtkSignalFunc) clist_click_column, NULL); @@ -4006,8 +4005,6 @@ create_clist (void) gtk_clist_set_row_height (GTK_CLIST (clist), 18); gtk_widget_set_usize (clist, -1, 300); - gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100); - for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++) gtk_clist_set_column_width (GTK_CLIST (clist), i, 80); @@ -4296,7 +4293,6 @@ void change_style (GtkWidget *widget, GtkCTree *ctree) if (GTK_CTREE_ROW (node)->children) gtk_ctree_node_set_row_style (ctree, GTK_CTREE_ROW (node)->children, style2); - } void unselect_all (GtkWidget *widget, GtkCTree *ctree) @@ -4307,50 +4303,37 @@ void unselect_all (GtkWidget *widget, GtkCTree *ctree) void remove_selection (GtkWidget *widget, GtkCTree *ctree) { - GtkCTreeNode *work; - GtkCTreeNode *new_sel; + GtkCList *clist; + GtkCTreeNode *node; GList *selection; + GList *list = NULL; - selection = GTK_CLIST (ctree)->selection; - new_sel = NULL; + clist = GTK_CLIST (ctree); - gtk_clist_freeze (GTK_CLIST (ctree)); + gtk_clist_freeze (clist); + for (selection = clist->selection; selection; selection = selection->next) + list = g_list_prepend (list, selection->data); + + selection = clist->selection; while (selection) { - work = selection->data; - selection = selection->next; + node = selection->data; - if (GTK_CTREE_ROW (work)->is_leaf) + if (!g_list_find (list, node)) + break; + + if (GTK_CTREE_ROW (node)->is_leaf) pages--; else - gtk_ctree_post_recursive (ctree, work, + gtk_ctree_post_recursive (ctree, node, (GtkCTreeFunc) count_items, NULL); - if (GTK_CLIST (ctree)->selection_mode == GTK_SELECTION_BROWSE) - { - if (GTK_CTREE_ROW (work)->children) - { - new_sel = GTK_CTREE_ROW (work)->sibling; - if (!new_sel) - new_sel = GTK_CTREE_NODE_NEXT (work); - } - else - { - if (GTK_CTREE_NODE_NEXT (work)) - new_sel = GTK_CTREE_NODE_NEXT (work); - else - new_sel = GTK_CTREE_NODE_PREV (work); - } - } - - gtk_ctree_remove_node (ctree, work); + gtk_ctree_remove_node (ctree, node); + selection = clist->selection; } - - if (new_sel) - gtk_ctree_select (ctree, new_sel); - - gtk_clist_thaw (GTK_CLIST (ctree)); + g_list_free (list); + gtk_clist_thaw (clist); after_press (ctree, NULL); } @@ -4880,7 +4863,6 @@ void create_ctree (void) gtk_container_border_width (GTK_CONTAINER (scrolled_win), 5); gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0); gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_EXTENDED); - gtk_clist_set_column_min_width (GTK_CLIST (ctree), 0, 50); gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE); gtk_clist_set_column_width (GTK_CLIST (ctree), 1, 200);