#include "executor.h"
#include "helper.h"
+#include <language/lexer/lexer.h>
#include <libpspp/message.h>
#include <stdlib.h>
+#include "help-menu.h"
#include "psppire.h"
-#include "psppire-syntax-window.h"
-
#include "psppire-data-window.h"
#include "psppire-window-register.h"
-#include "psppire.h"
-#include "help-menu.h"
#include "psppire-syntax-window.h"
#include "syntax-editor-source.h"
-#include <language/lexer/lexer.h>
#include "xalloc.h"
}
+static void
+psppire_syntax_window_dispose (GObject *obj)
+{
+ PsppireSyntaxWindow *sw = (PsppireSyntaxWindow *)obj;
+
+ GtkClipboard *clip_selection;
+ GtkClipboard *clip_primary;
+
+ if (sw->dispose_has_run)
+ return;
+
+ clip_selection = gtk_widget_get_clipboard (GTK_WIDGET (sw), GDK_SELECTION_CLIPBOARD);
+ clip_primary = gtk_widget_get_clipboard (GTK_WIDGET (sw), GDK_SELECTION_PRIMARY);
+
+ g_signal_handler_disconnect (clip_primary, sw->sel_handler);
+
+ g_signal_handler_disconnect (clip_selection, sw->ps_handler);
+
+ /* Make sure dispose does not run twice. */
+ sw->dispose_has_run = TRUE;
+
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+
+
static void
psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
parent_class = g_type_class_peek_parent (class);
+
+ gobject_class->dispose = psppire_syntax_window_dispose;
}
sw);
}
+
+/* Check to see if CLIP holds a target which we know how to paste,
+ and set the sensitivity of the Paste action accordingly.
+ */
static void
-on_owner_change (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer data)
+set_paste_sensitivity (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer data)
{
gint i;
gboolean compatible_target = FALSE;
if ( result )
{
char *fn = g_filename_display_name (filename);
- gchar *msg = g_strdup_printf (_("Saved file \"%s\""), fn);
+ gchar *msg = g_strdup_printf (_("Saved file `%s'"), fn);
g_free (fn);
gtk_statusbar_push (GTK_STATUSBAR (se->sb), se->text_context, msg);
gtk_text_buffer_set_modified (buffer, FALSE);
GtkClipboard *clip_primary = gtk_widget_get_clipboard (GTK_WIDGET (window), GDK_SELECTION_PRIMARY);
window->cliptext = NULL;
+ window->dispose_has_run = FALSE;
window->edit_delete = get_action_assert (xml, "edit_delete");
window->edit_copy = get_action_assert (xml, "edit_copy");
g_signal_connect (window->buffer, "modified-changed",
G_CALLBACK (on_modified_changed), window);
- g_signal_connect_swapped (clip_primary, "owner-change",
- G_CALLBACK (selection_changed), window);
+ window->sel_handler = g_signal_connect_swapped (clip_primary, "owner-change",
+ G_CALLBACK (selection_changed), window);
- g_signal_connect (clip_selection, "owner-change",
- G_CALLBACK (on_owner_change), window);
+ window->ps_handler = g_signal_connect (clip_selection, "owner-change",
+ G_CALLBACK (set_paste_sensitivity), window);
connect_help (xml);
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
- _("Cannot load syntax file '%s'"),
+ _("Cannot load syntax file `%s'"),
fn);
g_free (fn);
iface->load = syntax_load;
}
-
-