parallel members to arrays
[pspp] / src / ui / gui / psppire-dialog-action-recode-different.c
index 2d28146c792f348f1baf42f2c0b5bcf1cef609b8..a49d05306ea1f17820d3b429a17dc2374374a505 100644 (file)
@@ -41,8 +41,8 @@ difx_variable_treeview_is_populated (PsppireDialogActionRecode *rd)
 {
   PsppireDialogActionRecodeDifferent *rdd = PSPPIRE_DIALOG_ACTION_RECODE_DIFFERENT (rd);
   GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->variable_treeview));
-  
-  if (g_hash_table_size (rdd->varmap) != gtk_tree_model_iter_n_children (model, NULL) )
+
+  if (g_hash_table_size (rdd->varmap) != gtk_tree_model_iter_n_children (model, NULL))
     return FALSE;
 
   return TRUE;
@@ -57,12 +57,12 @@ dialog_state_valid (gpointer data)
 {
   PsppireDialogActionRecode *rd = data;
   GtkTreeIter not_used;
-      
-  if ( ! rd->value_map )
+
+  if (! rd->value_map)
     return FALSE;
 
-  if ( ! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map),
-                                       &not_used) )
+  if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map),
+                                       &not_used))
     return FALSE;
 
 
@@ -122,7 +122,7 @@ nlp_create (const char *name, const char *label)
 
   nlp->label = NULL;
 
-  if ( 0 != strcmp ("", label))
+  if (0 != strcmp ("", label))
     nlp->label = g_strdup (label);
 
   return nlp;
@@ -132,7 +132,7 @@ static void
 nlp_destroy (gpointer data)
 {
   struct nlp *nlp = data ;
-  if ( ! nlp )
+  if (! nlp)
     return;
 
   g_free (nlp->name);
@@ -155,16 +155,18 @@ render_new_var_name (GtkTreeViewColumn *tree_column,
 
   struct variable *var = NULL;
 
-  gtk_tree_model_get (tree_model, iter, 
+  gtk_tree_model_get (tree_model, iter,
                      0, &var,
                      -1);
 
   nlp = g_hash_table_lookup (rdd->varmap, var);
 
-  if ( nlp )
+  if (nlp)
     g_object_set (cell, "text", nlp->name, NULL);
   else
     g_object_set (cell, "text", "", NULL);
+
+  var_unref (var);
 }
 
 static void
@@ -190,7 +192,7 @@ on_change_clicked (GObject *obj, gpointer data)
   const gchar *dest_var_label =
     gtk_entry_get_text (GTK_ENTRY (rd->new_label_entry));
 
-  if ( NULL == rows || rows->next != NULL)
+  if (NULL == rows || rows->next != NULL)
     goto finish;
 
   gtk_tree_model_get_iter (model, &iter, rows->data);
@@ -206,7 +208,7 @@ on_change_clicked (GObject *obj, gpointer data)
   gtk_tree_model_row_changed (model, rows->data, &iter);
 
  finish:
-  g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+  g_list_foreach (rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL);
   g_list_free (rows);
 }
 
@@ -227,7 +229,7 @@ on_selection_change (GtkTreeSelection *selection, gpointer data)
 
   GList *rows = gtk_tree_selection_get_selected_rows (selection, &model);
 
-  if ( rows && !rows->next)
+  if (rows && !rows->next)
     {
       /* Exactly one row is selected */
       struct nlp *nlp;
@@ -243,7 +245,7 @@ on_selection_change (GtkTreeSelection *selection, gpointer data)
       g_return_if_fail (ok);
 
       gtk_tree_model_get (model, &iter,
-                         0, &var, 
+                         0, &var,
                          -1);
 
       nlp = g_hash_table_lookup (rdd->varmap, var);
@@ -270,7 +272,7 @@ on_selection_change (GtkTreeSelection *selection, gpointer data)
     }
 
 
-  g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+  g_list_foreach (rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL);
   g_list_free (rows);
 }
 
@@ -312,13 +314,14 @@ populate_treeview (PsppireDialogActionRecode *act)
 }
 
 
-static void
-psppire_dialog_action_recode_different_activate (PsppireDialogAction *a)
+static GtkBuilder *
+psppire_dialog_action_recode_different_activate (PsppireDialogAction *a, GVariant *param)
 {
   PsppireDialogActionRecode *act = PSPPIRE_DIALOG_ACTION_RECODE (a);
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
 
-  psppire_dialog_action_recode_pre_activate (act, populate_treeview);
+  GtkBuilder *xml = psppire_dialog_action_recode_pre_activate (act,
+                                                              populate_treeview);
 
   gtk_window_set_title (GTK_WINDOW (pda->dialog),
                        _("Recode into Different Variables"));
@@ -327,7 +330,7 @@ psppire_dialog_action_recode_different_activate (PsppireDialogAction *a)
                        _("Recode into Different Variables: Old and New Values "));
 
   gtk_widget_show (act->output_variable_box);
-  
+
   g_signal_connect_swapped (act->old_and_new_dialog, "show",
                            G_CALLBACK (on_old_new_show), act);
 
@@ -335,9 +338,7 @@ psppire_dialog_action_recode_different_activate (PsppireDialogAction *a)
 
   psppire_dialog_action_set_valid_predicate (pda,
                                             dialog_state_valid);
-
-  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_recode_different_parent_class)->activate)
-    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_recode_different_parent_class)->activate (pda);
+  return xml;
 }
 
 static void
@@ -349,7 +350,7 @@ append_into_clause (const PsppireDialogActionRecode *rd, struct string *dds)
   GtkTreeIter iter;
   ds_put_cstr (dds, "\n\tINTO ");
   gboolean ok;
-      
+
   for (ok = psppire_var_view_get_iter_first (PSPPIRE_VAR_VIEW (rd->variable_treeview), &iter);
        ok;
        ok = psppire_var_view_get_iter_next (PSPPIRE_VAR_VIEW (rd->variable_treeview), &iter))
@@ -358,7 +359,7 @@ append_into_clause (const PsppireDialogActionRecode *rd, struct string *dds)
       const struct variable *var = psppire_var_view_get_variable (PSPPIRE_VAR_VIEW (rd->variable_treeview), 0, &iter);
 
       nlp = g_hash_table_lookup (rdd->varmap, var);
-           
+
       ds_put_cstr (dds, nlp->name);
       ds_put_cstr (dds, " ");
     }
@@ -434,7 +435,7 @@ target_is_string (const PsppireDialogActionRecode *rd)
 static void
 psppire_dialog_action_recode_different_class_init (PsppireDialogActionRecodeDifferentClass *class)
 {
-  psppire_dialog_action_set_activation (class, psppire_dialog_action_recode_different_activate);
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_recode_different_activate;
 
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = diff_generate_syntax;
   PSPPIRE_DIALOG_ACTION_RECODE_CLASS (class)->target_is_string = target_is_string;