From f3f7dd9e0c14ce82e655b7af6efc14b32f25f332 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Tue, 5 Jun 2001 15:30:53 +0000 Subject: [PATCH] Fix segfault found by Vitaly Tishkov . Mon Jun 4 15:05:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): Fix segfault found by Vitaly Tishkov . (gtk_tree_view_column_set_min_width): ditto. --- ChangeLog | 6 +++++ ChangeLog.pre-2-0 | 6 +++++ ChangeLog.pre-2-10 | 6 +++++ ChangeLog.pre-2-2 | 6 +++++ ChangeLog.pre-2-4 | 6 +++++ ChangeLog.pre-2-6 | 6 +++++ ChangeLog.pre-2-8 | 6 +++++ gtk/gtktreeview.c | 58 ++++++++++++++++++++--------------------- gtk/gtktreeviewcolumn.c | 36 +++++++++++++++++++------ 9 files changed, 98 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 8db2edeb2c..9c6b5c9dce 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Mon Jun 4 15:05:24 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_max_width): + Fix segfault found by Vitaly Tishkov . + (gtk_tree_view_column_set_min_width): ditto. + Tue Jun 5 11:04:06 2001 Owen Taylor * gdk/gdkpixmap.h (GDK_PIXMAP_GET_CLASS): diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 73b915a70c..89d56bc46d 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -3803,6 +3803,7 @@ gtk_tree_view_focus (GtkContainer *container, g_return_val_if_fail (GTK_IS_TREE_VIEW (container), FALSE); g_return_val_if_fail (GTK_WIDGET_VISIBLE (container), FALSE); + g_print ("gtk_tree_view_focus\n"); tree_view = GTK_TREE_VIEW (container); if (!GTK_WIDGET_IS_SENSITIVE (container)) @@ -5559,52 +5560,49 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view, { GtkRBTree *cursor_tree = NULL; GtkRBNode *cursor_node = NULL; + GtkRBTree *new_cursor_tree = NULL; + GtkRBNode *new_cursor_node = NULL; GtkTreePath *cursor_path = NULL; cursor_path = NULL; if (tree_view->priv->cursor) cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor); - g_print ("up_down: cursor path is %s\n", cursor_path?"non NULL":"NULL"); + if (cursor_path == NULL) + return; + _gtk_tree_view_find_node (tree_view, cursor_path, - &cursor_tree, - &cursor_node); - gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); - if (tree_view->priv->cursor) - { - gtk_tree_row_reference_free (tree_view->priv->cursor); - tree_view->priv->cursor = NULL; - } + &cursor_tree, &cursor_node); if (count == -1) _gtk_rbtree_prev_full (cursor_tree, cursor_node, - &cursor_tree, &cursor_node); + &new_cursor_tree, &new_cursor_node); else _gtk_rbtree_next_full (cursor_tree, cursor_node, - &cursor_tree, &cursor_node); - gtk_tree_path_free (cursor_path); + &new_cursor_tree, &new_cursor_node); - if (cursor_node) + if (new_cursor_node) { - cursor_path = _gtk_tree_view_find_path (tree_view, - cursor_tree, - cursor_node); - if (cursor_path) - { - _gtk_tree_selection_internal_select_node (tree_view->priv->selection, - cursor_node, - cursor_tree, - cursor_path, - extend_selection?0:0); + gtk_tree_path_free (cursor_path); - tree_view->priv->cursor = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, cursor_path); - gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); - - gtk_tree_path_free (cursor_path); - } - gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node); - gtk_widget_grab_focus (GTK_WIDGET (tree_view)); + cursor_path = _gtk_tree_view_find_path (tree_view, new_cursor_tree, new_cursor_node); + _gtk_tree_selection_internal_select_node (tree_view->priv->selection, + new_cursor_node, + new_cursor_tree, + cursor_path, + extend_selection?GDK_SHIFT_MASK:0); + gtk_tree_row_reference_free (tree_view->priv->cursor); + tree_view->priv->cursor = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, cursor_path); + gtk_tree_view_clamp_node_visible (tree_view, new_cursor_tree, new_cursor_node); } + else + { + gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node); + } + + gtk_widget_grab_focus (GTK_WIDGET (tree_view)); + gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); + gtk_tree_path_free (cursor_path); } void diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 26d8743df4..72737f7364 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -235,7 +235,7 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class) PROP_ALIGNMENT, g_param_spec_float ("alignment", _("Alignment"), - _("Alignment of the column header text or widget"), + _("X Alignment of the column header text or widget"), 0.0, 1.0, 0.5, @@ -1422,13 +1422,18 @@ gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column, if (min_width == tree_column->min_width) return; + if (tree_column->tree_view == NULL) + { + tree_column->min_width = min_width; + return; + } + real_min_width = (tree_column->min_width == -1) ? tree_column->button->requisition.width : tree_column->min_width; /* We want to queue a resize if the either the old min_size or the * new min_size determined the size of the column */ - if (tree_column->tree_view && - GTK_WIDGET_REALIZED (tree_column->tree_view)) + if (GTK_WIDGET_REALIZED (tree_column->tree_view)) { if ((tree_column->min_width > tree_column->width) || (tree_column->min_width == -1 && @@ -1477,7 +1482,7 @@ void gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column, gint max_width) { - gint real_min_width; + gint real_max_width; g_return_if_fail (tree_column != NULL); g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column)); @@ -1486,8 +1491,14 @@ gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column, if (max_width == tree_column->max_width) return; - real_min_width = tree_column->min_width == -1 ? - tree_column->button->requisition.width : tree_column->min_width; + if (tree_column->tree_view == NULL) + { + tree_column->max_width = max_width; + return; + } + + real_max_width = tree_column->max_width == -1 ? + tree_column->button->requisition.width : tree_column->max_width; if (tree_column->tree_view && GTK_WIDGET_REALIZED (tree_column->tree_view) && @@ -1497,8 +1508,8 @@ gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column, tree_column->max_width = max_width; - if (real_min_width > max_width) - tree_column->min_width = max_width; + if (real_max_width > max_width) + tree_column->max_width = max_width; g_object_notify (G_OBJECT (tree_column), "max_width"); } @@ -1689,6 +1700,15 @@ gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column, g_object_notify (G_OBJECT (tree_column), "alignment"); } +/** + * gtk_tree_view_column_get_alignment: + * @tree_column: A #GtkTreeViewColumn. + * + * Returns the current x alignment of @tree_column. This value can range + * between 0.0 and 1.0. + * + * Return value: The current alignent of @tree_column. + **/ gfloat gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column) {