Reimplement the Windows menu.
[pspp] / src / ui / gui / psppire-output-window.c
index 074f90a88be77477ac9d9f8e095b058801464fad..469966af2325adf73faafbba8e29194dcfc7168a 100644 (file)
@@ -28,7 +28,6 @@
 #include "libpspp/cast.h"
 #include "libpspp/message.h"
 #include "libpspp/string-map.h"
-#include "output/cairo.h"
 #include "output/chart-item.h"
 #include "output/driver-provider.h"
 #include "output/message-item.h"
@@ -39,6 +38,7 @@
 #include "ui/gui/help-menu.h"
 #include "ui/gui/builder-wrapper.h"
 #include "ui/gui/psppire-output-view.h"
+#include "ui/gui/windows-menu.h"
 
 #include "gl/xalloc.h"
 
@@ -139,17 +139,27 @@ psppire_output_submit (struct output_driver *this,
 {
   struct psppire_output_driver *pod = psppire_output_cast (this);
   PsppireOutputWindow *window;
+  bool new;
 
-  if (pod->window == NULL)
+  new = pod->window == NULL;
+  if (new)
     {
       pod->window = PSPPIRE_OUTPUT_WINDOW (psppire_output_window_new ());
-      gtk_widget_show_all (GTK_WIDGET (pod->window));
       pod->window->driver = pod;
     }
   window = pod->window;
 
   psppire_output_view_put (window->view, item);
 
+  if (new)
+    {
+      /* We could have called this earlier in the previous "if (new)" block,
+         but doing it here finds, in a plain GTK+ environment, a bug that
+         otherwise only showed up on an Ubuntu Unity desktop.  See bug
+         #43362. */
+      gtk_widget_show_all (GTK_WIDGET (pod->window));
+    }
+
   gtk_window_set_urgency_hint (GTK_WINDOW (pod->window), TRUE);
 }
 
@@ -223,6 +233,7 @@ enum
     FT_HTML,
     FT_ODT,
     FT_TXT,
+    FT_ASCII,
     FT_PS,
     FT_CSV,
     n_FT
@@ -236,6 +247,7 @@ struct file_types ft[n_FT] = {
   {N_("HTML (*.html)"),                   ".html"},
   {N_("OpenDocument (*.odt)"),            ".odt"},
   {N_("Text (*.txt)"),                    ".txt"},
+  {N_("Text [plain] (*.txt)"),            ".txt"},
   {N_("PostScript (*.ps)"),               ".ps"},
   {N_("Comma-Separated Values (*.csv)"),  ".csv"}
 };
@@ -341,8 +353,8 @@ psppire_output_window_export (PsppireOutputWindow *window)
   GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Export Output"),
                                         GTK_WINDOW (window),
                                         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);
@@ -434,6 +446,10 @@ psppire_output_window_export (PsppireOutputWindow *window)
          break;
 
        case FT_TXT:
+          string_map_insert (&options, "box", "unicode");
+         /* Fall through */
+
+       case FT_ASCII:
           string_map_insert (&options, "headers", "false");
           string_map_insert (&options, "paginate", "false");
           string_map_insert (&options, "squeeze", "true");
@@ -458,11 +474,10 @@ psppire_output_window_export (PsppireOutputWindow *window)
 static void
 psppire_output_window_init (PsppireOutputWindow *window)
 {
-  GtkBuilder *xml;
-
-  xml = builder_new ("output-window.ui");
+  GtkBuilder *xml = builder_new ("output-window.ui");
 
-  gtk_widget_reparent (get_widget_assert (xml, "vbox1"), GTK_WIDGET (window));
+  GtkWidget *box = get_widget_assert (xml, "box1");
+  gtk_container_add (GTK_CONTAINER (window), box);
 
   window->dispose_has_run = FALSE;
 
@@ -480,18 +495,14 @@ psppire_output_window_init (PsppireOutputWindow *window)
                    G_CALLBACK (cancel_urgency),
                    NULL);
 
-  g_signal_connect (get_action_assert (xml,"windows_minimise-all"),
-                   "activate",
-                   G_CALLBACK (psppire_window_minimise_all),
-                   NULL);
+  GtkWidget *menubar = get_widget_assert (xml, "menubar");
 
-  {
-    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)));
+    
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
+                        create_help_menu (GTK_WINDOW (window)));
 
-    PSPPIRE_WINDOW (window)->menu =
-      GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar/windows_menuitem/windows_minimise-all")->parent);
-  }
 
   g_signal_connect_swapped (get_action_assert (xml, "file_export"), "activate",
                             G_CALLBACK (psppire_output_window_export), window);