From bbe1233f0ed396751b3311f9468dc6e774ed6416 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 3 Sep 2013 21:52:55 -0700 Subject: [PATCH] psppire-var-sheet: Factor out code into new function path_string_to_var(). An upcoming commit will add a second user. --- src/ui/gui/psppire-var-sheet.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index b52d420262..5f617afebe 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -143,6 +143,19 @@ scroll_to_bottom (GtkWidget *widget, } } +static struct variable * +path_string_to_var (PsppireVarSheet *var_sheet, gchar *path_string) +{ + GtkTreePath *path; + gint row; + + path = gtk_tree_path_new_from_string (path_string); + row = gtk_tree_path_get_indices (path)[0]; + gtk_tree_path_free (path); + + return psppire_dict_get_variable (var_sheet->dict, row); +} + static void on_var_column_edited (GtkCellRendererText *cell, gchar *path_string, @@ -155,17 +168,11 @@ on_var_column_edited (GtkCellRendererText *cell, enum vs_column column_id; struct variable *var; int width, decimals; - GtkTreePath *path; - gint row; - - path = gtk_tree_path_new_from_string (path_string); - row = gtk_tree_path_get_indices (path)[0]; - gtk_tree_path_free (path); column_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-id")); - var = psppire_dict_get_variable (var_sheet->dict, row); + var = path_string_to_var (var_sheet, path_string); if (var == NULL) { g_return_if_fail (column_id == VS_NAME); -- 2.30.2