Refactor the Help menu.
[pspp-builds.git] / src / ui / gui / psppire-syntax-window.c
index 48e1ea44fe73d3873c4631d6e5b4bc06311e4636..3541a165705b20dbed1b68cf366db4e17d1c0c51 100644 (file)
@@ -30,7 +30,7 @@
 #include "psppire-data-window.h"
 #include "psppire-window-register.h"
 #include "psppire.h"
-#include "about.h"
+#include "help-menu.h"
 #include "psppire-syntax-window.h"
 #include "syntax-editor-source.h"
 #include <language/lexer/lexer.h>
@@ -392,7 +392,7 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
   GtkBuilder *xml = builder_new ("syntax-editor.ui");
   GtkWidget *box = gtk_vbox_new (FALSE, 0);
 
-  GtkWidget *menubar = get_widget_assert (xml, "menubar2");
+  GtkWidget *menubar = get_widget_assert (xml, "menubar");
   GtkWidget *sw = get_widget_assert (xml, "scrolledwindow8");
 
 
@@ -437,21 +437,6 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
                    window);
 #endif
 
-  {
-    GtkAction *abt = get_action_assert (xml, "help_about");
-    g_object_set (abt, "stock-id", "gtk-about", NULL);
-
-    g_signal_connect (abt,
-                     "activate",
-                     G_CALLBACK (about_new),
-                     window);
-  }
-
-  g_signal_connect (get_action_assert (xml,"help_reference"),
-                   "activate",
-                   G_CALLBACK (reference_manual),
-                   NULL);
-
   g_signal_connect_swapped (get_action_assert (xml, "file_save"),
                    "activate",
                    G_CALLBACK (syntax_save),
@@ -496,8 +481,10 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
   {
   GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (xml, "uimanager1", GTK_TYPE_UI_MANAGER));
 
+  merge_help_menu (uim);
+
   PSPPIRE_WINDOW (window)->menu =
-    GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar2/windows/windows_minimise_all")->parent);
+    GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar/windows/windows_minimise_all")->parent);
   }
 
   g_object_unref (xml);
@@ -545,12 +532,26 @@ gboolean
 syntax_load (PsppireWindow *window, const gchar *filename)
 {
   GError *err = NULL;
-  gchar *text;
+  gchar *text_locale = NULL;
+  gchar *text_utf8 = NULL;
+  gsize len_locale = -1;
+  gsize len_utf8 = -1;
   GtkTextIter iter;
   PsppireSyntaxWindow *sw = PSPPIRE_SYNTAX_WINDOW (window);
 
   /* FIXME: What if it's a very big file ? */
-  if ( ! g_file_get_contents (filename, &text, NULL, &err) )
+  if ( ! g_file_get_contents (filename, &text_locale, &len_locale, &err) )
+    {
+      error_dialog (GTK_WINDOW (window), filename, err);
+      g_clear_error (&err);
+      return FALSE;
+    }
+
+  text_utf8 = g_locale_to_utf8 (text_locale, len_locale, NULL, &len_utf8, &err);
+
+  free (text_locale);
+
+  if ( text_utf8 == NULL )
     {
       error_dialog (GTK_WINDOW (window), filename, err);
       g_clear_error (&err);
@@ -559,10 +560,12 @@ syntax_load (PsppireWindow *window, const gchar *filename)
 
   gtk_text_buffer_get_iter_at_line (sw->buffer, &iter, 0);
 
-  gtk_text_buffer_insert (sw->buffer, &iter, text, -1);
+  gtk_text_buffer_insert (sw->buffer, &iter, text_utf8, len_utf8);
 
   gtk_text_buffer_set_modified (sw->buffer, FALSE);
 
+  free (text_utf8);
+
   return TRUE;
 }