Rename myreversefunc -> psppire_data_store_string_to_value
[pspp] / src / ui / gui / psppire-dialog-action-compute.c
index 46944c3fd3da9c37f1045fb6e639b03d92124d42..2a9b68906593cf69b6549062087d62cab86cd0aa 100644 (file)
@@ -22,7 +22,7 @@
 #include <language/expressions/public.h>
 
 #include "psppire-var-view.h"
-
+#include "dict-display.h"
 #include "psppire-dialog.h"
 #include "psppire-keypad.h"
 #include "psppire-selector.h"
@@ -35,7 +35,7 @@ G_DEFINE_TYPE (PsppireDialogActionCompute, psppire_dialog_action_compute, PSPPIR
 
 
 static char *
-generate_syntax (PsppireDialogAction *act)
+generate_syntax (const PsppireDialogAction *act)
 {
   PsppireDialogActionCompute *cd = PSPPIRE_DIALOG_ACTION_COMPUTE (act);
   gchar *text;
@@ -365,10 +365,10 @@ static void
 insert_source_row_into_text_view (GtkTreeIter iter,
                                  GtkWidget *dest,
                                  GtkTreeModel *model,
-                                 gpointer data
-                                 )
+                                 gpointer data)
 {
   GtkTreePath *path;
+  GtkTreeModel *m;
   PsppireDict *dict;
   gint *idx;
   struct variable *var;
@@ -377,20 +377,8 @@ insert_source_row_into_text_view (GtkTreeIter iter,
 
   g_return_if_fail (GTK_IS_TEXT_VIEW (dest));
 
-  if ( GTK_IS_TREE_MODEL_FILTER (model))
-    {
-      dict = PSPPIRE_DICT (gtk_tree_model_filter_get_model
-                          (GTK_TREE_MODEL_FILTER(model)));
-
-      gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
-                                                       (model),
-                                                       &dict_iter, &iter);
-    }
-  else
-    {
-      dict = PSPPIRE_DICT (model);
-      dict_iter = iter;
-    }
+  get_base_model (model, &iter, &m, &dict_iter);
+  dict = PSPPIRE_DICT (m);
 
   path = gtk_tree_model_get_path (GTK_TREE_MODEL (dict), &dict_iter);
 
@@ -405,7 +393,6 @@ insert_source_row_into_text_view (GtkTreeIter iter,
   erase_selection (buffer);
 
   gtk_text_buffer_insert_at_cursor (buffer, var_get_name (var), -1);
-
 }
 
 static void
@@ -467,14 +454,14 @@ insert_function_into_syntax_area (GtkTreeIter iter,
 }
 
 
-
-static void
-psppire_dialog_action_compute_activate (GtkAction *a)
+static GtkBuilder *
+psppire_dialog_action_compute_activate (PsppireDialogAction *a, GVariant *param)
 {
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
   PsppireDialogActionCompute *act = PSPPIRE_DIALOG_ACTION_COMPUTE (a);
 
-  GtkBuilder *xml = builder_new ("compute.ui");
+  GtkBuilder *xml = builder_new ( "compute.ui");
+
   pda->dialog = get_widget_assert   (xml, "compute-variable-dialog");
   pda->source = get_widget_assert   (xml, "compute-treeview1");
 
@@ -503,7 +490,7 @@ psppire_dialog_action_compute_activate (GtkAction *a)
                    G_CALLBACK (on_expression_toggle), pda);
 
   g_signal_connect (act->str_btn, "toggled",
-                   G_CALLBACK (on_type_toggled), pda);
+                   G_CALLBACK (on_type_toggled), pda);
 
 
   g_object_set (pda->source,
@@ -533,18 +520,14 @@ psppire_dialog_action_compute_activate (GtkAction *a)
   psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
   psppire_dialog_action_set_refresh (pda, refresh);
 
-  g_object_unref (xml);
-
-  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_compute_parent_class)->activate)
-    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_compute_parent_class)->activate (pda);
+  return xml;
 }
 
 static void
 psppire_dialog_action_compute_class_init (PsppireDialogActionComputeClass *class)
 {
-  GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_compute_activate;
 
-  action_class->activate = psppire_dialog_action_compute_activate;
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }