From 4612957073c41b6f15e8b36de14f43fb40cd9bfb Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 16 Mar 2009 18:02:24 +0900 Subject: [PATCH] Indicate filtered cases in data sheet. Add feature to indicate filtered out cases on data sheet. Closes bug #20828 --- lib/gtk-contrib/gtkextra-sheet.h | 1 + lib/gtk-contrib/psppire-sheet.c | 21 +++++++++++++++++++ src/ui/gui/psppire-data-editor.c | 12 ++++++++--- src/ui/gui/psppire-data-store.c | 29 +++++++++++++++++++++++++++ src/ui/gui/psppire-data-store.h | 5 +++++ src/ui/gui/psppire-var-store.c | 2 ++ src/ui/gui/sheet/psppire-sheetmodel.c | 11 ++++++++-- src/ui/gui/sheet/psppire-sheetmodel.h | 2 ++ 8 files changed, 78 insertions(+), 5 deletions(-) diff --git a/lib/gtk-contrib/gtkextra-sheet.h b/lib/gtk-contrib/gtkextra-sheet.h index 16d6b5b4..6cad27fc 100644 --- a/lib/gtk-contrib/gtkextra-sheet.h +++ b/lib/gtk-contrib/gtkextra-sheet.h @@ -40,6 +40,7 @@ struct _PsppireSheetButton gboolean label_visible; GtkJustification justification; + gboolean overstruck; }; struct _PsppireSheetCell diff --git a/lib/gtk-contrib/psppire-sheet.c b/lib/gtk-contrib/psppire-sheet.c index 74b8be97..8a537536 100644 --- a/lib/gtk-contrib/psppire-sheet.c +++ b/lib/gtk-contrib/psppire-sheet.c @@ -4747,6 +4747,26 @@ draw_button (PsppireSheet *sheet, GdkWindow *window, allocation.x, allocation.y, allocation.width, allocation.height); + if ( button->overstruck) + { + GdkPoint points[2] = { + {allocation.x, allocation.y}, + {allocation.x + allocation.width, + allocation.y + allocation.height} + }; + + gtk_paint_polygon (sheet->button->style, + window, + button->state, + shadow_type, + NULL, + GTK_WIDGET (sheet), + "button", + points, + 2, + TRUE); + } + if (button->label_visible) { text_height = DEFAULT_ROW_HEIGHT - @@ -5335,6 +5355,7 @@ psppire_sheet_button_new (void) button->label = NULL; button->label_visible = TRUE; button->justification = GTK_JUSTIFY_FILL; + button->overstruck = FALSE; return button; } diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 86119191..a608e6de 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -380,9 +380,15 @@ psppire_data_editor_set_property (GObject *object, g_object_ref (de->data_store); for (i = 0 ; i < 4 ; ++i ) - g_object_set (de->data_sheet[i], - "model", de->data_store, - NULL); + { + g_object_set (de->data_sheet[i], + "model", de->data_store, + NULL); + + g_signal_connect_swapped (de->data_store->dict, "filter-changed", + G_CALLBACK (gtk_widget_queue_draw), + de->data_sheet[i]); + } g_signal_connect (de->data_store->dict, "backend-changed", G_CALLBACK (new_variables_callback), de); diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index c8804f48..f36fe38a 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -263,6 +263,7 @@ static GtkJustification get_column_justification (const PsppireSheetModel *model static gchar * get_row_button_label (const PsppireSheetModel *model, gint row); static gboolean get_row_sensitivity (const PsppireSheetModel *model, gint row); +static gboolean get_row_overstrike (const PsppireSheetModel *model, gint row); static void @@ -285,6 +286,7 @@ psppire_data_store_sheet_model_init (PsppireSheetModelIface *iface) iface->get_row_title = get_row_button_label; iface->get_row_sensitivity = get_row_sensitivity; + iface->get_row_overstrike = get_row_overstrike; } @@ -1003,3 +1005,30 @@ psppire_data_store_insert_values (PsppireDataStore *ds, return TRUE; } + +static gboolean +get_row_overstrike (const PsppireSheetModel *model, gint row) +{ + union value val; + PsppireDataStore *ds = PSPPIRE_DATA_STORE (model); + + const struct dictionary *dict = ds->dict->dict; + + const struct variable *filter = dict_get_filter (dict); + + if ( row < 0 || row >= datasheet_get_row_cnt (ds->datasheet)) + return FALSE; + + if ( ! filter) + return FALSE; + + g_assert (var_is_numeric (filter)); + + if ( ! datasheet_get_value (ds->datasheet, row, + var_get_case_index (filter), + &val, 0) ) + return FALSE; + + + return (val.f == 0.0); +} diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index 5ffd85d6..bbb44ee2 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -116,6 +116,11 @@ gboolean psppire_data_store_set_string (PsppireDataStore *ds, const gchar *text, glong row, glong column); + +gboolean psppire_data_store_filtered (PsppireDataStore *ds, + glong row); + + casenumber psppire_data_store_get_case_count (const PsppireDataStore *ds); size_t psppire_data_store_get_value_count (const PsppireDataStore *ds); diff --git a/src/ui/gui/psppire-var-store.c b/src/ui/gui/psppire-var-store.c index 82a7ef10..b092de30 100644 --- a/src/ui/gui/psppire-var-store.c +++ b/src/ui/gui/psppire-var-store.c @@ -301,6 +301,8 @@ psppire_var_store_sheet_model_init (PsppireSheetModelIface *iface) iface->get_row_title = get_row_title; iface->get_row_sensitivity = get_row_sensitivity; + + iface->get_row_overstrike = NULL; } /** diff --git a/src/ui/gui/sheet/psppire-sheetmodel.c b/src/ui/gui/sheet/psppire-sheetmodel.c index 61b667d4..a948d453 100644 --- a/src/ui/gui/sheet/psppire-sheetmodel.c +++ b/src/ui/gui/sheet/psppire-sheetmodel.c @@ -1,5 +1,5 @@ /* PsppireSheetModel --- an abstract model for the PsppireSheet widget. - * Copyright (C) 2006, 2008 Free Software Foundation + Copyright (C) 2006, 2008 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -482,6 +482,8 @@ psppire_sheet_model_get_column_button (const PsppireSheetModel *model, if ( PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_column_title) button->label = PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_column_title (model, col); + button->overstruck = FALSE; + return button; } @@ -534,7 +536,12 @@ psppire_sheet_model_get_row_button (const PsppireSheetModel *model, g_return_val_if_fail (PSPPIRE_IS_SHEET_MODEL (model), NULL); if ( PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_row_title) - button->label = PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_row_title (model, row); + button->label = + PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_row_title (model, row); + + if ( PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_row_overstrike) + button->overstruck = + PSPPIRE_SHEET_MODEL_GET_IFACE (model)->get_row_overstrike (model, row); return button; } diff --git a/src/ui/gui/sheet/psppire-sheetmodel.h b/src/ui/gui/sheet/psppire-sheetmodel.h index 7869791e..c8519077 100644 --- a/src/ui/gui/sheet/psppire-sheetmodel.h +++ b/src/ui/gui/sheet/psppire-sheetmodel.h @@ -128,6 +128,8 @@ struct _PsppireSheetModelIface gchar * (*get_row_subtitle) (const PsppireSheetModel *, gint row); glong (*get_row_count) (const PsppireSheetModel *model); gboolean (*get_row_sensitivity) (const PsppireSheetModel *, gint row); + + gboolean (*get_row_overstrike) (const PsppireSheetModel *, gint row); }; -- 2.30.2