From a0bac37037e42c7c9b90cb702866b297dbcab79e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 10 Jul 2012 22:08:25 -0700 Subject: [PATCH] psppire-var-sheet: Refresh var sheet when variables change. Otherwise changes made through popup dialogs in the variable sheet don't necessarily show until the mouse moves across the row that changed. Reported by John Darrington. --- src/ui/gui/psppire-empty-list-store.c | 14 ++++++++++++++ src/ui/gui/psppire-empty-list-store.h | 2 ++ src/ui/gui/psppire-var-sheet.c | 18 ++++++++++++++++++ src/ui/gui/psppire-var-sheet.h | 1 + 4 files changed, 35 insertions(+) diff --git a/src/ui/gui/psppire-empty-list-store.c b/src/ui/gui/psppire-empty-list-store.c index b7bc569def..1658d1fde5 100644 --- a/src/ui/gui/psppire-empty-list-store.c +++ b/src/ui/gui/psppire-empty-list-store.c @@ -180,6 +180,20 @@ psppire_empty_list_store_set_n_rows (PsppireEmptyListStore *obj, obj->n_rows = n_rows; } +void +psppire_empty_list_store_row_changed (PsppireEmptyListStore *obj, + gint row) +{ + GtkTreeModel *tree_model = GTK_TREE_MODEL (obj); + GtkTreeIter iter; + GtkTreePath *path; + + path = gtk_tree_path_new_from_indices (row, -1); + gtk_tree_model_get_iter (tree_model, &iter, path); + gtk_tree_model_row_changed (tree_model, path, &iter); + gtk_tree_path_free (path); +} + void psppire_empty_list_store_row_inserted (PsppireEmptyListStore *obj, gint row) diff --git a/src/ui/gui/psppire-empty-list-store.h b/src/ui/gui/psppire-empty-list-store.h index ae6d36c483..c2078439d1 100644 --- a/src/ui/gui/psppire-empty-list-store.h +++ b/src/ui/gui/psppire-empty-list-store.h @@ -56,6 +56,8 @@ gint psppire_empty_list_store_get_n_rows (const PsppireEmptyListStore *); void psppire_empty_list_store_set_n_rows (PsppireEmptyListStore *, gint n_rows); +void psppire_empty_list_store_row_changed (PsppireEmptyListStore *, + gint row); void psppire_empty_list_store_row_inserted (PsppireEmptyListStore *, gint row); void psppire_empty_list_store_row_deleted (PsppireEmptyListStore *, diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index 930c27797f..76cf51038d 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -1266,6 +1266,20 @@ refresh_model (PsppireVarSheet *var_sheet) } } +static void +on_var_changed (PsppireDict *dict, glong row, PsppireVarSheet *var_sheet) +{ + PsppireEmptyListStore *store; + + g_return_if_fail (dict == var_sheet->dict); + + store = PSPPIRE_EMPTY_LIST_STORE (pspp_sheet_view_get_model ( + PSPP_SHEET_VIEW (var_sheet))); + g_return_if_fail (store != NULL); + + psppire_empty_list_store_row_changed (store, row); +} + static void on_var_inserted (PsppireDict *dict, glong row, PsppireVarSheet *var_sheet) { @@ -1341,6 +1355,10 @@ psppire_var_sheet_set_dictionary (PsppireVarSheet *var_sheet, = g_signal_connect (dict, "backend-changed", G_CALLBACK (on_backend_changed), var_sheet); + var_sheet->dict_signals[PSPPIRE_VAR_SHEET_VARIABLE_CHANGED] + = g_signal_connect (dict, "variable-changed", + G_CALLBACK (on_var_changed), var_sheet); + var_sheet->dict_signals[PSPPIRE_VAR_SHEET_VARIABLE_DELETED] = g_signal_connect (dict, "variable-inserted", G_CALLBACK (on_var_inserted), var_sheet); diff --git a/src/ui/gui/psppire-var-sheet.h b/src/ui/gui/psppire-var-sheet.h index 754dd25892..cd4bd20b3b 100644 --- a/src/ui/gui/psppire-var-sheet.h +++ b/src/ui/gui/psppire-var-sheet.h @@ -47,6 +47,7 @@ typedef struct _PsppireVarSheetClass PsppireVarSheetClass; enum { PSPPIRE_VAR_SHEET_BACKEND_CHANGED, + PSPPIRE_VAR_SHEET_VARIABLE_CHANGED, PSPPIRE_VAR_SHEET_VARIABLE_INSERTED, PSPPIRE_VAR_SHEET_VARIABLE_DELETED, PSPPIRE_VAR_SHEET_N_SIGNALS -- 2.30.2