better comment
[pspp] / src / ui / gui / psppire-dialog-action-var-info.c
index dd2c9aefd213724a5e8413ad811c2718dc6a03b9..570ce4ada68d54a40b00745517b2fb65fc609829 100644 (file)
@@ -1,6 +1,6 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013, 2014, 2016  Free Software Foundation
-
+   Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013, 2014, 2016,
+   2020  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -124,21 +124,9 @@ populate_output (GtkTreeSelection *selection, gpointer data)
   psppire_dict_view_get_selected_variables (PSPPIRE_DICT_VIEW (treeview),
                                             &vars, &n_vars);
 
-  if (n_vars > 0)
-    {
-      PsppireDataWindow *dw;
-
-      g_object_get (act, "top-level", &dw, NULL);
-
-      psppire_output_view_clear (act->output);
+  g_return_if_fail (n_vars <= 1);
 
-      output_engine_push ();
-      psppire_output_view_register_driver (act->output);
-      g_free (execute_syntax_string (
-                dw, generate_syntax__ (&act->parent,
-                                       "DISPLAY DICTIONARY /VARIABLES=")));
-      output_engine_pop ();
-    }
+  g_object_set (act->var_info, "variable", n_vars > 0 ? vars[0] : NULL, NULL);
 }
 
 
@@ -165,49 +153,40 @@ jump_to (PsppireDialog *d, gint response, gpointer data)
   g_free (vars);
 }
 
-static void
-psppire_dialog_action_var_info_activate (PsppireDialogAction *a)
+static GtkBuilder *
+psppire_dialog_action_var_info_activate (PsppireDialogAction *a, GVariant *param)
 {
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
   PsppireDialogActionVarInfo *act = PSPPIRE_DIALOG_ACTION_VAR_INFO (pda);
 
-  GHashTable *thing = psppire_dialog_action_get_hash_table (pda);
-  GtkBuilder *xml = g_hash_table_lookup (thing, a);
-  if (!xml)
-    {
-      xml = builder_new ("variable-info.ui");
-      g_hash_table_insert (thing, a, xml);
+  GtkBuilder *xml = builder_new ("variable-info.ui");
+
+  act->var_info = get_widget_assert (xml, "var-info0");
 
-      act->output =
-       psppire_output_view_new (GTK_LAYOUT (get_widget_assert (xml, "layout1")),
-                                NULL, NULL, NULL);
-  
-      pda->dialog = get_widget_assert (xml, "variable-info-dialog");
-      pda->source = get_widget_assert (xml, "treeview2");
+  pda->dialog = get_widget_assert (xml, "variable-info-dialog");
+  pda->source = get_widget_assert (xml, "treeview2");
 
-      g_object_set (pda->source,
-                   "selection-mode", GTK_SELECTION_MULTIPLE,
-                   NULL);
+  g_object_set (pda->source,
+               "selection-mode", GTK_SELECTION_MULTIPLE,
+               NULL);
 
-      g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pda->source)),
-                       "changed", G_CALLBACK (populate_output),
-                       act);
+  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pda->source)),
+                   "changed", G_CALLBACK (populate_output),
+                   act);
 
-      g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to),
-                       pda);
+  g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to),
+                   pda);
 
-      psppire_dialog_action_set_valid_predicate (pda,
-                                                treeview_item_selected);
-    }
-  
-  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate)
-    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate (pda);
+  psppire_dialog_action_set_valid_predicate (pda,
+                                            treeview_item_selected);
+
+  return xml;
 }
 
 static void
 psppire_dialog_action_var_info_class_init (PsppireDialogActionVarInfoClass *class)
 {
-  psppire_dialog_action_set_activation (class, psppire_dialog_action_var_info_activate);
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate =  psppire_dialog_action_var_info_activate;
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }