Previously, when a dialog box's "paste" button was pressed, a
new syntax window was created and the syntax pasted to it. This
change alters that behaviour. Now there is just one syntax window
that is used for all paste operations. Fixes bug #27686
#include <data/settings.h>
#include "psppire-data-store.h"
#include <data/settings.h>
#include "psppire-data-store.h"
#include "gl/configmake.h"
#include "xalloc.h"
#include "gl/configmake.h"
#include "xalloc.h"
+
+
+static gboolean
+on_delete (GtkWindow *window, GdkEvent *e, GtkWindow **addr)
+{
+ *addr = NULL;
+
+ return FALSE;
+}
+
void
paste_syntax_in_new_window (const gchar *syntax)
{
void
paste_syntax_in_new_window (const gchar *syntax)
{
- GtkWidget *se = psppire_syntax_window_new ();
+ static GtkWidget *the_syntax_pasteboard = NULL;
+
+ if ( NULL == the_syntax_pasteboard)
+ {
+ the_syntax_pasteboard = psppire_syntax_window_new ();
+ g_signal_connect (the_syntax_pasteboard, "delete-event", G_CALLBACK (on_delete),
+ &the_syntax_pasteboard);
+ }
+
+ gtk_text_buffer_insert_at_cursor (PSPPIRE_SYNTAX_WINDOW (the_syntax_pasteboard)->buffer,
+ syntax, -1);
- gtk_text_buffer_insert_at_cursor (PSPPIRE_SYNTAX_WINDOW (se)->buffer, syntax, -1);
+ gtk_text_buffer_insert_at_cursor (PSPPIRE_SYNTAX_WINDOW (the_syntax_pasteboard)->buffer,
+ "\n", 1);
+ gtk_widget_show (the_syntax_pasteboard);