gui: Factor out duplicated code for executing and pasting syntax.
[pspp-builds.git] / src / ui / gui / comments-dialog.c
index 49d143cb6c51f379df11ad5172c789fada53a7f6..78cc74dea61d8500cf978d5cd8fe0e291aefcfda 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007  Free Software Foundation
+   Copyright (C) 2007, 2010  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
@@ -20,8 +20,7 @@
 #include "helper.h"
 #include "psppire-data-window.h"
 #include "psppire-data-editor.h"
-#include <language/syntax-string-source.h>
-#include "helper.h"
+#include "executor.h"
 #include "psppire-var-store.h"
 #include <ui/syntax-gen.h>
 
@@ -91,11 +90,10 @@ wrap_line (GtkTextBuffer *buffer,
 
 
 void
-comments_dialog (GObject *o, gpointer data)
+comments_dialog (PsppireDataWindow *de)
 {
   GtkTextIter iter;
   gint response ;
-  PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
   struct comment_dialog cd;
 
   GtkBuilder *xml = builder_new ("psppire.ui");
@@ -145,7 +143,7 @@ comments_dialog (GObject *o, gpointer data)
   }
 
   cd.xml = xml;
-  cd.dict = vs->dict;
+  g_object_get (vs, "dictionary", &cd.dict, NULL);
 
   g_signal_connect (buffer, "mark-set",
                    G_CALLBACK (set_column_number), label);
@@ -165,23 +163,10 @@ comments_dialog (GObject *o, gpointer data)
   switch (response)
     {
     case GTK_RESPONSE_OK:
-      {
-       gchar *syntax = generate_syntax (&cd);
-
-       struct getl_interface *sss = create_syntax_string_source (syntax);
-       execute_syntax (sss);
-
-       g_free (syntax);
-      }
+      g_free (execute_syntax_string (generate_syntax (&cd)));
       break;
     case PSPPIRE_RESPONSE_PASTE:
-      {
-       gchar *syntax = generate_syntax (&cd);
-
-       paste_syntax_in_new_window (syntax);
-
-       g_free (syntax);
-      }
+      g_free (paste_syntax_to_window (generate_syntax (&cd)));
       break;
     default:
       break;