From 8298a4c6e326a39e204ca58d686497758333a102 Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Sun, 3 May 2015 22:22:02 +0200 Subject: [PATCH] fixed initial show of names in header window. Variable names only showed up after switching between variable and data window. The reason is that the buttons of the columns are not created. This is due to interdependency between the size allocation and the button creation. I removed the need_button mechanism. --- src/ui/gui/pspp-sheet-view-column.c | 25 ++++------------------- src/ui/gui/pspp-sheet-view-column.h | 3 --- src/ui/gui/pspp-sheet-view.c | 31 ----------------------------- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/src/ui/gui/pspp-sheet-view-column.c b/src/ui/gui/pspp-sheet-view-column.c index 5e5804e812..d463367201 100644 --- a/src/ui/gui/pspp-sheet-view-column.c +++ b/src/ui/gui/pspp-sheet-view-column.c @@ -512,7 +512,6 @@ pspp_sheet_view_column_init (PsppSheetViewColumn *tree_column) tree_column->use_resized_width = FALSE; tree_column->title = g_strdup (""); tree_column->quick_edit = TRUE; - tree_column->need_button = FALSE; } static void @@ -1021,10 +1020,8 @@ pspp_sheet_view_column_create_button (PsppSheetViewColumn *tree_column) g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view)); g_return_if_fail (tree_column->button == NULL); - gtk_widget_push_composite_child (); tree_column->button = gtk_button_new (); gtk_widget_add_events (tree_column->button, GDK_POINTER_MOTION_MASK); - gtk_widget_pop_composite_child (); /* make sure we own a reference to it as well. */ if (tree_view->priv->header_window) @@ -1097,8 +1094,7 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) model = NULL; /* Create a button if necessary */ - if (tree_column->need_button && - tree_column->visible && + if (tree_column->visible && tree_column->button == NULL && tree_column->tree_view && gtk_widget_get_realized (tree_column->tree_view)) @@ -1212,7 +1208,7 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) { if (tree_column->visible) { - gtk_widget_show_now (tree_column->button); + gtk_widget_show (tree_column->button); if (tree_column->window) { if (tree_column->resizable) @@ -1586,7 +1582,7 @@ _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column) g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view)); g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (tree_view))); g_return_if_fail (tree_view->priv->header_window != NULL); - if (!column->need_button || !column->button) + if (!column->button) return; g_return_if_fail (column->button != NULL); @@ -1654,8 +1650,7 @@ _pspp_sheet_view_column_set_tree_view (PsppSheetViewColumn *column, g_assert (column->tree_view == NULL); column->tree_view = GTK_WIDGET (tree_view); - if (column->need_button) - pspp_sheet_view_column_create_button (column); + pspp_sheet_view_column_create_button (column); column->property_changed_signal = g_signal_connect_swapped (tree_view, @@ -4396,15 +4391,3 @@ pspp_sheet_view_column_can_focus (PsppSheetViewColumn *tree_column) { return tree_column->reorderable || tree_column->clickable; } - -void -pspp_sheet_view_column_set_need_button (PsppSheetViewColumn *tree_column, - gboolean need_button) -{ - if (tree_column->need_button != need_button) - { - tree_column->need_button = need_button; - pspp_sheet_view_column_update_button (tree_column); - _pspp_sheet_view_column_realize_button (tree_column); - } -} diff --git a/src/ui/gui/pspp-sheet-view-column.h b/src/ui/gui/pspp-sheet-view-column.h index 9a0e9b5d60..95ba779508 100644 --- a/src/ui/gui/pspp-sheet-view-column.h +++ b/src/ui/gui/pspp-sheet-view-column.h @@ -111,7 +111,6 @@ struct _PsppSheetViewColumn guint PSEAL (selectable) : 1; guint PSEAL (row_head) : 1; guint PSEAL (tabbable) : 1; - guint PSEAL (need_button) : 1; }; struct _PsppSheetViewColumnClass @@ -262,8 +261,6 @@ void pspp_sheet_view_column_size_request (PsppSheetView void pspp_sheet_view_column_size_allocate (PsppSheetViewColumn *tree_column, GtkAllocation *allocation); gboolean pspp_sheet_view_column_can_focus (PsppSheetViewColumn *tree_column); -void pspp_sheet_view_column_set_need_button (PsppSheetViewColumn *tree_column, - gboolean need_button); G_END_DECLS diff --git a/src/ui/gui/pspp-sheet-view.c b/src/ui/gui/pspp-sheet-view.c index c2e3fe4579..7c80ec0c02 100644 --- a/src/ui/gui/pspp-sheet-view.c +++ b/src/ui/gui/pspp-sheet-view.c @@ -1979,12 +1979,6 @@ pspp_sheet_view_size_allocate_columns (GtkWidget *widget, pspp_sheet_view_column_size_allocate (column, &col_allocation); - if (span_intersects (col_allocation.x, col_allocation.width, - gtk_adjustment_get_value (tree_view->priv->hadjustment), - allocation.width) - && gtk_widget_get_realized (widget)) - pspp_sheet_view_column_set_need_button (column, TRUE); - if (column->window) gdk_window_move_resize (column->window, col_allocation.x + (rtl ? 0 : col_allocation.width) - TREE_VIEW_DRAG_WIDTH/2, @@ -6713,13 +6707,6 @@ pspp_sheet_view_focus_column (PsppSheetView *tree_view, g_return_if_fail (focus_column != NULL); tree_view->priv->focus_column = focus_column; - if (!focus_column->button) - { - pspp_sheet_view_column_set_need_button (focus_column, TRUE); - // g_return_if_fail (focus_column->button != NULL); - if (focus_column->button == NULL) - return; - } if (gtk_container_get_focus_child (GTK_CONTAINER (tree_view)) != focus_column->button) gtk_widget_grab_focus (focus_column->button); @@ -6850,7 +6837,6 @@ pspp_sheet_view_header_focus (PsppSheetView *tree_view, if (column->visible && pspp_sheet_view_column_can_focus (column)) { - pspp_sheet_view_column_set_need_button (column, TRUE); if (column->button) { pspp_sheet_view_focus_column (tree_view, column, @@ -8993,23 +8979,6 @@ pspp_sheet_view_adjustment_changed (GtkAdjustment *adjustment, if (!tree_view->priv->in_top_row_to_dy) pspp_sheet_view_dy_to_top_row (tree_view); } - - for (list = tree_view->priv->columns; list; list = list->next) - { - PsppSheetViewColumn *column = list->data; - GtkAllocation *col_allocation = &column->allocation; - GtkAllocation widget_allocation; - gtk_widget_get_allocation (GTK_WIDGET (tree_view), &widget_allocation); - - if (span_intersects (col_allocation->x, col_allocation->width, - gtk_adjustment_get_value (tree_view->priv->hadjustment), - widget_allocation.width)) - { - pspp_sheet_view_column_set_need_button (column, TRUE); - if (!column->button) - pspp_sheet_view_column_update_button (column); - } - } } } -- 2.30.2