From: John Darrington Date: Tue, 18 Nov 2008 00:32:39 +0000 (+0900) Subject: Removed the visibility predicate from the row/column models. X-Git-Tag: v0.7.1~153 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5bf90ff8baa7a81274421acb24a915c953e560f;p=pspp-builds.git Removed the visibility predicate from the row/column models. These predicates have never been used, and just complicate things. --- diff --git a/lib/gtksheet/gsheet-column-iface.c b/lib/gtksheet/gsheet-column-iface.c index ca5bd5b6..c2fc1758 100644 --- a/lib/gtksheet/gsheet-column-iface.c +++ b/lib/gtksheet/gsheet-column-iface.c @@ -36,11 +36,8 @@ enum { static guint sheet_column_signals[LAST_SIGNAL]; - - static void g_sheet_column_base_init (gpointer g_class); - GType g_sheet_column_get_type (void) { @@ -122,19 +119,6 @@ g_sheet_column_get_width (const GSheetColumn *column, glong col) -gboolean -g_sheet_column_get_visibility (const GSheetColumn *column, - glong col) -{ - g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE); - - g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_visibility); - - return (G_SHEET_COLUMN_GET_IFACE (column)->get_visibility) (column, - col); - -} - gboolean g_sheet_column_get_sensitivity (const GSheetColumn *column, glong col) @@ -254,16 +238,14 @@ g_sheet_column_start_pixel (const GSheetColumn *geo, glong col) gint start_pixel = 0; g_return_val_if_fail (G_IS_SHEET_COLUMN (geo), -1); - g_return_val_if_fail (col < g_sheet_column_get_column_count (geo), -1); + g_return_val_if_fail (col <= g_sheet_column_get_column_count (geo), -1); - for ( i = 0 ; i < col ; ++i ) + for (i = 0; i < col; ++i) { - if ( g_sheet_column_get_visibility (geo, i)) - start_pixel += g_sheet_column_get_width (geo, i); + start_pixel += g_sheet_column_get_width (geo, i); } return start_pixel; - } @@ -278,6 +260,3 @@ g_sheet_column_columns_changed (GSheetColumn *geo, first, n_columns); } - - - diff --git a/lib/gtksheet/gsheet-column-iface.h b/lib/gtksheet/gsheet-column-iface.h index 4ad1d3fc..7b3128c2 100644 --- a/lib/gtksheet/gsheet-column-iface.h +++ b/lib/gtksheet/gsheet-column-iface.h @@ -50,7 +50,6 @@ struct _GSheetColumnIface gint (* get_width) (const GSheetColumn *gcolumn, glong col); void (* set_width) (GSheetColumn *gcolumn, glong col, gint width); - gboolean (* get_visibility) (const GSheetColumn *gcolumn, glong col); gboolean (* get_sensitivity) (const GSheetColumn *gcolumn, glong col); const GtkSheetButton * (* get_button) (const GSheetColumn *gcolumn, glong col); GtkJustification (* get_justification) (const GSheetColumn *gcolumn, glong col); diff --git a/lib/gtksheet/gsheet-hetero-column.c b/lib/gtksheet/gsheet-hetero-column.c index 1344b839..04e1a4d5 100644 --- a/lib/gtksheet/gsheet-hetero-column.c +++ b/lib/gtksheet/gsheet-hetero-column.c @@ -121,14 +121,6 @@ g_sheet_hetero_column_get_sensitivity (const GSheetColumn *geom, glong u) } -static gboolean -g_sheet_hetero_column_get_visibility (const GSheetColumn *geom, glong u) -{ - return TRUE; -} - - - static gchar * g_sheet_hetero_column_get_button_label (const GSheetColumn *geom, glong u) { @@ -202,7 +194,6 @@ g_sheet_column_init (GSheetColumnIface *iface) iface->get_width = g_sheet_hetero_column_get_width ; iface->set_width = hetero_column_set_width ; iface->get_sensitivity = g_sheet_hetero_column_get_sensitivity ; - iface->get_visibility = g_sheet_hetero_column_get_visibility ; iface->get_justification = g_sheet_hetero_column_get_justification; iface->get_column_count = g_sheet_hetero_column_get_column_count; diff --git a/lib/gtksheet/gsheet-hetero-column.h b/lib/gtksheet/gsheet-hetero-column.h index 507bc20a..9b19c1f3 100644 --- a/lib/gtksheet/gsheet-hetero-column.h +++ b/lib/gtksheet/gsheet-hetero-column.h @@ -41,7 +41,6 @@ extern "C" { gint width; gboolean is_sensitive; - gboolean is_visible; }; diff --git a/lib/gtksheet/gsheet-row-iface.c b/lib/gtksheet/gsheet-row-iface.c index 878d2bde..4bbd2e1c 100644 --- a/lib/gtksheet/gsheet-row-iface.c +++ b/lib/gtksheet/gsheet-row-iface.c @@ -127,19 +127,6 @@ g_sheet_row_get_height (const GSheetRow *row_geo, -gboolean -g_sheet_row_get_visibility (const GSheetRow *row_geo, - glong row) -{ - g_return_val_if_fail (G_IS_SHEET_ROW (row_geo), FALSE); - - g_assert (G_SHEET_ROW_GET_IFACE (row_geo)->get_visibility); - - return (G_SHEET_ROW_GET_IFACE (row_geo)->get_visibility) (row_geo, - row); - -} - gboolean g_sheet_row_get_sensitivity (const GSheetRow *row_geo, glong row) @@ -150,7 +137,6 @@ g_sheet_row_get_sensitivity (const GSheetRow *row_geo, return (G_SHEET_ROW_GET_IFACE (row_geo)->get_sensitivity) (row_geo, row); - } @@ -201,6 +187,8 @@ g_sheet_row_get_row_count (const GSheetRow *geo) * @sheet: pointer to the sheet * * Returns the top y pixel for ROW. + * ROW may point to the row BELOW the last row, in which case it should + * return the position where it would start if it existed. * Instances may override this method in order to achieve time and/or memory * optmisation. * @@ -215,15 +203,14 @@ g_sheet_row_start_pixel (const GSheetRow *geo, glong row) g_return_val_if_fail (G_IS_SHEET_ROW (geo), -1); g_return_val_if_fail (row >= 0, -1); - g_return_val_if_fail (row < g_sheet_row_get_row_count (geo), -1); + g_return_val_if_fail (row <= g_sheet_row_get_row_count (geo), -1); if ( G_SHEET_ROW_GET_IFACE (geo)->top_ypixel) return (G_SHEET_ROW_GET_IFACE (geo)->top_ypixel)(geo, row); - for ( i = 0 ; i < row ; ++i ) + for (i = 0; i < row; ++i) { - if ( g_sheet_row_get_visibility (geo, i)) - start_pixel += g_sheet_row_get_height (geo, i); + start_pixel += g_sheet_row_get_height (geo, i); } return start_pixel; @@ -244,12 +231,10 @@ g_sheet_row_pixel_to_row (const GSheetRow *geo, gint pixel) for (i = 0; i < g_sheet_row_get_row_count (geo); ++i ) { if (pixel >= cy && - pixel <= (cy + g_sheet_row_get_height (geo, i)) && - g_sheet_row_get_visibility (geo, i)) + pixel <= (cy + g_sheet_row_get_height (geo, i))) return i; - if (g_sheet_row_get_visibility (geo, i)) - cy += g_sheet_row_get_height (geo, i); + cy += g_sheet_row_get_height (geo, i); } /* no match */ diff --git a/lib/gtksheet/gsheet-row-iface.h b/lib/gtksheet/gsheet-row-iface.h index ded46671..ce67b326 100644 --- a/lib/gtksheet/gsheet-row-iface.h +++ b/lib/gtksheet/gsheet-row-iface.h @@ -53,8 +53,6 @@ struct _GSheetRowIface gint (* get_height) (const GSheetRow *grow, glong row); void (* set_height) (GSheetRow *grow, glong row, gint height); - gboolean (* get_visibility) (const GSheetRow *grow, glong row); - gboolean (* get_sensitivity) (const GSheetRow *grow, glong row); const GtkSheetButton * (* get_button) (const GSheetRow *grow, glong row); diff --git a/lib/gtksheet/gsheet-uniform-column.c b/lib/gtksheet/gsheet-uniform-column.c index 5093da2f..c0f6732a 100644 --- a/lib/gtksheet/gsheet-uniform-column.c +++ b/lib/gtksheet/gsheet-uniform-column.c @@ -90,7 +90,6 @@ g_sheet_uniform_column_new (gint width, gint n_columns) ug = G_SHEET_UNIFORM_COLUMN(retval); ug->n_columns = n_columns; ug->width = width; - ug->is_visible = TRUE; ug->is_sensitive = FALSE; return retval; @@ -113,15 +112,6 @@ g_sheet_uniform_column_get_sensitivity (const GSheetColumn *geom, glong u) } -static gboolean -g_sheet_uniform_column_get_visibility (const GSheetColumn *geom, glong u) -{ - GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom); - - return ug->is_visible; -} - - static gchar * g_sheet_uniform_column_get_button_label (const GSheetColumn *geom, glong u) { @@ -176,7 +166,6 @@ g_sheet_column_init (GSheetColumnIface *iface) { iface->get_width = g_sheet_uniform_column_get_width ; iface->get_sensitivity = g_sheet_uniform_column_get_sensitivity ; - iface->get_visibility = g_sheet_uniform_column_get_visibility ; iface->get_justification = g_sheet_uniform_column_get_justification; iface->get_column_count = g_sheet_uniform_column_get_column_count; iface->get_button_label = g_sheet_uniform_column_get_button_label; diff --git a/lib/gtksheet/gsheet-uniform-column.h b/lib/gtksheet/gsheet-uniform-column.h index e56037b4..51fc53a0 100644 --- a/lib/gtksheet/gsheet-uniform-column.h +++ b/lib/gtksheet/gsheet-uniform-column.h @@ -42,7 +42,6 @@ extern "C" { gint n_columns; gint width; gboolean is_sensitive; - gboolean is_visible; }; struct _GSheetUniformColumnClass diff --git a/lib/gtksheet/gsheet-uniform-row.c b/lib/gtksheet/gsheet-uniform-row.c index 7ab9b600..847916c5 100644 --- a/lib/gtksheet/gsheet-uniform-row.c +++ b/lib/gtksheet/gsheet-uniform-row.c @@ -90,7 +90,6 @@ g_sheet_uniform_row_new (gint height, gint n_rows) ug = G_SHEET_UNIFORM_ROW(retval); ug->n_rows = n_rows; ug->height = height; - ug->is_visible = TRUE; return retval; } @@ -112,15 +111,6 @@ g_sheet_uniform_row_get_sensitivity (const GSheetRow *geom, glong u) } -static gboolean -g_sheet_uniform_row_get_visibility (const GSheetRow *geom, glong u) -{ - GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW (geom); - - return ug->is_visible; -} - - static gchar * g_sheet_uniform_row_get_button_label (const GSheetRow *geom, glong u) { @@ -192,7 +182,6 @@ g_sheet_row_init (GSheetRowIface *iface) { iface->get_height = g_sheet_uniform_row_get_height; iface->get_sensitivity = g_sheet_uniform_row_get_sensitivity ; - iface->get_visibility = g_sheet_uniform_row_get_visibility; iface->get_row_count = g_sheet_uniform_row_get_row_count; iface->get_button_label = g_sheet_uniform_row_get_button_label; iface->top_ypixel = g_sheet_uniform_row_top_ypixel; diff --git a/lib/gtksheet/gsheet-uniform-row.h b/lib/gtksheet/gsheet-uniform-row.h index 845dbf6b..96551f3f 100644 --- a/lib/gtksheet/gsheet-uniform-row.h +++ b/lib/gtksheet/gsheet-uniform-row.h @@ -40,7 +40,6 @@ extern "C" { gint n_rows; gint height; - gboolean is_visible; }; struct _GSheetUniformRowClass diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index e46edc70..dc9bf25b 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -202,11 +202,10 @@ column_from_xpixel (const GtkSheet *sheet, gint x) i < g_sheet_column_get_column_count (sheet->column_geometry); i++) { if (x >= cx && - x <= (cx + g_sheet_column_get_width (sheet->column_geometry, i)) && - g_sheet_column_get_visibility (sheet->column_geometry, i)) + x <= (cx + g_sheet_column_get_width (sheet->column_geometry, i))) return i; - if ( g_sheet_column_get_visibility (sheet->column_geometry, i)) - cx += g_sheet_column_get_width (sheet->column_geometry, i); + + cx += g_sheet_column_get_width (sheet->column_geometry, i); } /* no match */ @@ -270,7 +269,6 @@ POSSIBLE_YDRAG (const GtkSheet *sheet, gint y, gint *drag_row) ydrag = g_sheet_row_start_pixel (sheet->row_geometry, row) + CELL_SPACING; if (y <= ydrag + DRAG_WIDTH / 2 && row != 0) { - while (!g_sheet_row_get_visibility (sheet->row_geometry, row - 1) && row > 0) row--; *drag_row = row - 1; return g_sheet_row_get_sensitivity (sheet->row_geometry, row - 1); } @@ -1516,8 +1514,7 @@ gtk_sheet_moveto (GtkSheet *sheet, { while (min_row >= 0 && min_row > min_visible_row (sheet)) { - if (g_sheet_row_get_visibility (sheet->row_geometry, min_row)) - adjust += g_sheet_row_get_height (sheet->row_geometry, min_row); + adjust += g_sheet_row_get_height (sheet->row_geometry, min_row); if (adjust >= height) { @@ -1557,8 +1554,7 @@ gtk_sheet_moveto (GtkSheet *sheet, { while (min_col >= 0 && min_col > min_visible_column (sheet)) { - if (g_sheet_column_get_visibility (sheet->column_geometry, min_col)) - adjust += g_sheet_column_get_width (sheet->column_geometry, min_col); + adjust += g_sheet_column_get_width (sheet->column_geometry, min_col); if (adjust >= width) { @@ -2151,12 +2147,6 @@ gtk_sheet_cell_draw_bg (GtkSheet *sheet, gint row, gint col) col >= g_sheet_column_get_column_count (sheet->column_geometry)) return; - if (! g_sheet_column_get_visibility (sheet->column_geometry, col)) - return; - - if (! g_sheet_row_get_visibility (sheet->row_geometry, row)) - return; - gtk_sheet_get_attributes (sheet, row, col, &attributes); /* select GC for background rectangle */ @@ -2226,8 +2216,6 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return; if (col < 0 || col >= g_sheet_column_get_column_count (sheet->column_geometry)) return; - if (! g_sheet_column_get_visibility (sheet->column_geometry, col)) return; - if (!g_sheet_row_get_visibility (sheet->row_geometry, row)) return; widget = GTK_WIDGET (sheet); @@ -2477,9 +2465,7 @@ gtk_sheet_range_draw_selection (GtkSheet *sheet, GtkSheetRange range) { for (j = range.col0; j <= range.coli; j++) { - - if (gtk_sheet_cell_get_state (sheet, i, j) == GTK_STATE_SELECTED && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i)) + if (gtk_sheet_cell_get_state (sheet, i, j) == GTK_STATE_SELECTED) { area.x = g_sheet_column_start_pixel (sheet->column_geometry, j); if ( sheet->row_titles_visible) @@ -3079,7 +3065,6 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE; if (state == GTK_STATE_SELECTED && selected && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i) && (i == sheet->range.row0 || i == sheet->range.rowi || j == sheet->range.col0 || j == sheet->range.coli || i == new_range.row0 || i == new_range.rowi || @@ -3159,8 +3144,7 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) selected= (i <= new_range.rowi && i >= new_range.row0 && j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE; - if (state == GTK_STATE_SELECTED && !selected && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i)) + if (state == GTK_STATE_SELECTED && !selected) { x = g_sheet_column_start_pixel (sheet->column_geometry, j); @@ -3195,7 +3179,6 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE; if (state != GTK_STATE_SELECTED && selected && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i) && (i != sheet->active_cell.row || j != sheet->active_cell.col)) { @@ -3232,57 +3215,52 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) { for (j = aux_range.col0; j <= aux_range.coli; j++) { + state = gtk_sheet_cell_get_state (sheet, i, j); - if (g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i)) - { - - state = gtk_sheet_cell_get_state (sheet, i, j); + mask1 = i == sheet->range.row0 ? 1 : 0; + mask1 = i == sheet->range.rowi ? mask1 + 2 : mask1; + mask1 = j == sheet->range.col0 ? mask1 + 4 : mask1; + mask1 = j == sheet->range.coli ? mask1 + 8 : mask1; - mask1 = i == sheet->range.row0 ? 1 : 0; - mask1 = i == sheet->range.rowi ? mask1 + 2 : mask1; - mask1 = j == sheet->range.col0 ? mask1 + 4 : mask1; - mask1 = j == sheet->range.coli ? mask1 + 8 : mask1; - - mask2 = i == new_range.row0 ? 1 : 0; - mask2 = i == new_range.rowi ? mask2 + 2 : mask2; - mask2 = j == new_range.col0 ? mask2 + 4 : mask2; - mask2 = j == new_range.coli ? mask2 + 8 : mask2; - if (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED)) - { - x = g_sheet_column_start_pixel (sheet->column_geometry, j); - y = g_sheet_row_start_pixel (sheet->row_geometry, i); - width = g_sheet_column_get_width (sheet->column_geometry, j); - height = g_sheet_row_get_height (sheet->row_geometry, i); - if (mask2 & 1) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x + 1, y - 1, - width, 3); - - - if (mask2 & 2) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x + 1, y + height - 1, - width, 3); - - if (mask2 & 4) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x - 1, y + 1, - 3, height); - - - if (mask2 & 8) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x + width - 1, y + 1, - 3, height); - } + mask2 = i == new_range.row0 ? 1 : 0; + mask2 = i == new_range.rowi ? mask2 + 2 : mask2; + mask2 = j == new_range.col0 ? mask2 + 4 : mask2; + mask2 = j == new_range.coli ? mask2 + 8 : mask2; + if (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED)) + { + x = g_sheet_column_start_pixel (sheet->column_geometry, j); + y = g_sheet_row_start_pixel (sheet->row_geometry, i); + width = g_sheet_column_get_width (sheet->column_geometry, j); + height = g_sheet_row_get_height (sheet->row_geometry, i); + if (mask2 & 1) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x + 1, y - 1, + width, 3); + + + if (mask2 & 2) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x + 1, y + height - 1, + width, 3); + + if (mask2 & 4) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x - 1, y + 1, + 3, height); + + + if (mask2 & 8) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x + width - 1, y + 1, + 3, height); } } } @@ -3797,15 +3775,6 @@ gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column) return FALSE; } - if (column >= 0 && row >= 0) - { - if (! g_sheet_column_get_visibility (sheet->column_geometry, column) - || !g_sheet_row_get_visibility (sheet->row_geometry, row)) - { - return FALSE; - } - } - g_signal_emit (sheet, sheet_signals[TRAVERSE], 0, sheet->active_cell.row, sheet->active_cell.col, &row, &column, &forbid_move); @@ -5392,7 +5361,6 @@ gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column) if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; if (!sheet->column_titles_visible) return; - if (!g_sheet_column_get_visibility (sheet->column_geometry, column)) return; if (column < min_visible_column (sheet)) return; if (column > max_visible_column (sheet)) return; @@ -5422,7 +5390,6 @@ gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row) if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; if (!sheet->row_titles_visible) return; - if (!g_sheet_row_get_visibility (sheet->row_geometry, row)) return; if (row < min_visible_row (sheet)) return; if (row > max_visible_row (sheet)) return; diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 18aaaeba..dee18378 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -882,7 +882,6 @@ psppire_data_store_sheet_column_init (GSheetColumnIface *iface) iface->get_column_count = geometry_get_column_count; iface->get_width = geometry_get_width; iface->set_width = geometry_set_width; - iface->get_visibility = always_true; iface->get_sensitivity = geometry_get_sensitivity; iface->get_justification = geometry_get_justification; iface->get_button_label = geometry_get_column_button_label; @@ -962,7 +961,6 @@ psppire_data_store_sheet_row_init (GSheetRowIface *iface) iface->get_height = geometry_get_height; iface->set_height = 0; - iface->get_visibility = always_true; iface->get_sensitivity = geometry_get_row_sensitivity; iface->top_ypixel = geometry_get_top_ypixel; iface->pixel_to_row = geometry_pixel_to_row; diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index fa356b81..8fe5fc66 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -847,8 +847,7 @@ psppire_var_store_sheet_row_init (GSheetRowIface *iface) { iface->get_row_count = geometry_get_row_count; iface->get_height = geometry_get_height; - iface->set_height = 0; - iface->get_visibility = always_true; + iface->set_height = NULL; iface->get_sensitivity = geometry_is_sensitive; iface->get_button_label = geometry_get_button_label;