From: Ben Pfaff Date: Wed, 4 Sep 2013 04:52:55 +0000 (-0700) Subject: psppire-var-sheet: Factor out code into new function path_string_to_var(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbe1233f0ed396751b3311f9468dc6e774ed6416;p=pspp psppire-var-sheet: Factor out code into new function path_string_to_var(). An upcoming commit will add a second user. --- 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);