gui: Support Ctrl+W to close windows and add File|Close to menus.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 28 May 2023 03:18:07 +0000 (20:18 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 28 May 2023 03:18:07 +0000 (20:18 -0700)
Requested by Matthias Faeth.

src/ui/gui/output-window.ui
src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-output-window.c

index 0f04244fc75c0802287caca73bd67224311a7582..f1fcdff20370cd8aa80eb818c2de5e700b1c543e 100644 (file)
        </item>
       </section>
       <section>
+       <item>
+         <attribute name="label" translatable="yes">_Close</attribute>
+         <attribute name="accel">&lt;Primary&gt;w</attribute>
+         <attribute name="action">win.close</attribute>
+       </item>
        <item>
          <attribute name="label" translatable="yes">_Quit</attribute>
          <attribute name="accel">&lt;Primary&gt;q</attribute>
index e29f469b4ac0754ffc65c9d9d5d27f928930033a..ecb9f121af44d08d2a14f246e99097c354b0a903 100644 (file)
@@ -1311,9 +1311,17 @@ create_file_menu (PsppireDataWindow *dw)
 
   gtk_menu_attach (GTK_MENU (menu), gtk_separator_menu_item_new (), 0, 1, 12, 13);
 
+
+  {
+    GtkWidget *close = gtk_menu_item_new_with_mnemonic (_("_Close"));
+    gtk_menu_attach (GTK_MENU (menu), close,     0, 1, 13, 14);
+
+    connect_action_to_menuitem (G_ACTION_MAP (dw), "close", close, "<Primary>W");
+  }
+
   {
     GtkWidget *quit = gtk_menu_item_new_with_mnemonic (_("_Quit"));
-    gtk_menu_attach (GTK_MENU (menu), quit,     0, 1, 13, 14);
+    gtk_menu_attach (GTK_MENU (menu), quit,     0, 1, 14, 15);
 
     connect_action_to_menuitem (G_ACTION_MAP (g_application_get_default ()),
                                "quit", quit, "<Primary>Q");
@@ -1558,6 +1566,12 @@ psppire_data_window_finish_init (PsppireDataWindow *de,
     g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (save_as));
   }
 
+  {
+    GSimpleAction *close_action = g_simple_action_new ("close", NULL);
+    g_signal_connect_swapped (close_action, "activate", G_CALLBACK (gtk_window_close), de);
+    g_action_map_add_action (G_ACTION_MAP (de), G_ACTION (close_action));
+  }
+
   {
     GSimpleAction *rename_dataset_act = g_simple_action_new ("rename-dataset", NULL);
     g_signal_connect_swapped (rename_dataset_act, "activate",
index 14fc1fd0dcd5588d47bab694006ef8ddb624506a..a5f66fab6ba0dd1785d9b38869147890af149b1e 100644 (file)
@@ -481,6 +481,15 @@ psppire_output_window_init (PsppireOutputWindow *window)
     g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (export));
   }
 
+  {
+    GSimpleAction *close = g_simple_action_new ("close", NULL);
+    g_signal_connect_swapped (close, "activate", G_CALLBACK (gtk_window_close), window);
+    g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (close));
+
+    const gchar *accels[2] = { "<Primary>W", NULL};
+    gtk_application_set_accels_for_action (app, "win.close", accels);
+  }
+
   {
     GSimpleAction *select_all = g_simple_action_new ("select-all", NULL);
     g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (select_all));