psppire-var-sheet: Factor out code into new function path_string_to_var().
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 4 Sep 2013 04:52:55 +0000 (21:52 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 4 Sep 2013 04:56:30 +0000 (21:56 -0700)
An upcoming commit will add a second user.

src/ui/gui/psppire-var-sheet.c

index b52d420262d7dbd37a15291fd175e35abf7246ff..5f617afebe2b7d8944c51a7834068e933bb78c65 100644 (file)
@@ -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);