Reimplement the Windows menu.
[pspp] / src / ui / gui / psppire-syntax-window.c
index 35f57e587b4cc950f30eaf8ef40683426e7b46e4..f8758a0cd7e2e6a5a2b1b7dbbc6724677b9f289b 100644 (file)
@@ -36,8 +36,8 @@
 #include "ui/gui/psppire-encoding-selector.h"
 #include "ui/gui/psppire-lex-reader.h"
 #include "ui/gui/psppire-syntax-window.h"
-#include "ui/gui/psppire-window-register.h"
 #include "ui/gui/psppire.h"
+#include "ui/gui/windows-menu.h"
 
 #include "gl/localcharset.h"
 #include "gl/xalloc.h"
@@ -296,7 +296,7 @@ clipboard_get_cb (GtkClipboard     *clipboard,
   PsppireSyntaxWindow *sw = data;
   g_assert (info == SELECT_FMT_TEXT);
 
-  gtk_selection_data_set (selection_data, selection_data->target,
+  gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
                          8,
                          (const guchar *) sw->cliptext, strlen (sw->cliptext));
 
@@ -369,27 +369,6 @@ on_edit_copy (PsppireSyntaxWindow *sw)
   set_clip (sw, &begin, &end);
 }
 
-
-/* A callback for when the clipboard contents have been received */
-static void
-contents_received_callback (GtkClipboard *clipboard,
-                           GtkSelectionData *sd,
-                           gpointer data)
-{
-  PsppireSyntaxWindow *syntax_window = data;
-
-  if ( sd->length < 0 )
-    return;
-
-  if ( sd->type != gdk_atom_intern ("UTF8_STRING", FALSE))
-    return;
-
-  gtk_text_buffer_insert_at_cursor (GTK_TEXT_BUFFER (syntax_window->buffer),
-                                   (gchar *) sd->data,
-                                   sd->length);
-
-}
-
 static void
 on_edit_paste (PsppireSyntaxWindow *sw)
 {
@@ -397,10 +376,7 @@ on_edit_paste (PsppireSyntaxWindow *sw)
   GtkClipboard *clipboard =
     gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
 
-  gtk_clipboard_request_contents (clipboard,
-                                 gdk_atom_intern ("UTF8_STRING", TRUE),
-                                 contents_received_callback,
-                                 sw);
+  gtk_text_buffer_paste_clipboard (GTK_TEXT_BUFFER (sw->buffer), clipboard, NULL, TRUE);
 }
 
 
@@ -589,8 +565,8 @@ syntax_pick_filename (PsppireWindow *window)
     gtk_file_chooser_dialog_new (_("Save Syntax"),
                                 GTK_WINDOW (se),
                                 GTK_FILE_CHOOSER_ACTION_SAVE,
-                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                GTK_STOCK_SAVE,   GTK_RESPONSE_ACCEPT,
+                                _("Cancel"), GTK_RESPONSE_CANCEL,
+                                _("Save"),   GTK_RESPONSE_ACCEPT,
                                 NULL);
 
   g_object_set (dialog, "local-only", FALSE, NULL);
@@ -721,7 +697,7 @@ static void
 psppire_syntax_window_init (PsppireSyntaxWindow *window)
 {
   GtkBuilder *xml = builder_new ("syntax-editor.ui");
-  GtkWidget *box = gtk_vbox_new (FALSE, 0);
+  GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 
   GtkWidget *menubar = get_widget_assert (xml, "menubar");
   GtkWidget *sw = get_widget_assert (xml, "scrolledwindow8");
@@ -883,22 +859,11 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
                    G_CALLBACK (on_run_to_end),
                    window);
 
-  g_signal_connect (get_action_assert (xml,"windows_minimise_all"),
-                   "activate",
-                   G_CALLBACK (psppire_window_minimise_all), NULL);
-
-
-
-
-
-  {
-  GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (xml, "uimanager1", GTK_TYPE_UI_MANAGER));
-
-  merge_help_menu (uim);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
+                        create_windows_menu (GTK_WINDOW (window)));
 
-  PSPPIRE_WINDOW (window)->menu =
-    GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar/windows/windows_minimise_all")->parent);
-  }
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
+                        create_help_menu (GTK_WINDOW (window)));
 
   g_object_unref (xml);
 }
@@ -984,7 +949,7 @@ syntax_load (PsppireWindow *window, const gchar *filename,
       sw->encoding = g_strdup (encoding);
     }
 
-  text_utf8 = recode_substring_pool ("UTF-8", encoding,
+  text_utf8 = recode_substring_pool ("UTF-8", sw->encoding,
                                      ss_buffer (text_locale, len_locale),
                                      NULL).string;
   free (text_locale);