[console/wip/msandova/remember-window-size: 2/3] window: Remove win.new-window action




commit b7c545502ea0812068afd02d0a2b1fc086559103
Author: Maximiliano Sandoval R <msandova gnome org>
Date:   Sat Jul 30 00:46:22 2022 +0200

    window: Remove win.new-window action
    
    We can use app.new-window instead.

 src/help-overlay.ui   |  2 +-
 src/kgx-application.c | 11 +++++++++--
 src/kgx-window.c      | 23 -----------------------
 src/kgx-window.ui     |  2 +-
 4 files changed, 11 insertions(+), 27 deletions(-)
---
diff --git a/src/help-overlay.ui b/src/help-overlay.ui
index 451bfdc..7690815 100644
--- a/src/help-overlay.ui
+++ b/src/help-overlay.ui
@@ -12,7 +12,7 @@
             <property name="title" translatable="yes" context="shortcut window">Application</property>
             <child>
               <object class="GtkShortcutsShortcut">
-                <property name="action-name">win.new-window</property>
+                <property name="action-name">app.new-window</property>
                 <property name="title" translatable="yes" context="shortcut window">New Window</property>
               </object>
             </child>
diff --git a/src/kgx-application.c b/src/kgx-application.c
index f2a0f7f..d1b3c92 100644
--- a/src/kgx-application.c
+++ b/src/kgx-application.c
@@ -340,7 +340,7 @@ kgx_application_startup (GApplication *app)
   G_APPLICATION_CLASS (kgx_application_parent_class)->startup (app);
 
   gtk_application_set_accels_for_action (GTK_APPLICATION (app),
-                                         "win.new-window", new_window_accels);
+                                         "app.new-window", new_window_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (app),
                                          "win.new-tab", new_tab_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (app),
@@ -805,8 +805,15 @@ new_window_activated (GSimpleAction *action,
 {
   KgxApplication *self = KGX_APPLICATION (data);
   guint32 timestamp = GDK_CURRENT_TIME;
+  GtkWindow *active_window;
+  g_autoptr (GFile) dir = NULL;
+
+  active_window = gtk_application_get_active_window (GTK_APPLICATION (self));
+  if (active_window) {
+    dir = kgx_window_get_working_dir (KGX_WINDOW (active_window));
+  }
 
-  kgx_application_add_terminal (self, NULL, timestamp, NULL, NULL, NULL);
+  kgx_application_add_terminal (self, NULL, timestamp, dir, NULL, NULL);
 }
 
 
diff --git a/src/kgx-window.c b/src/kgx-window.c
index 8a31813..edb3e37 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -402,28 +402,6 @@ kgx_window_class_init (KgxWindowClass *klass)
 }
 
 
-static void
-new_activated (GSimpleAction *action,
-               GVariant      *parameter,
-               gpointer       data)
-{
-  KgxWindow *self = data;
-  guint32 timestamp = GDK_CURRENT_TIME;
-  GtkApplication *application = NULL;
-  g_autoptr (GFile) dir = NULL;
-
-  application = gtk_window_get_application (GTK_WINDOW (self));
-  dir = kgx_window_get_working_dir (KGX_WINDOW (data));
-
-  kgx_application_add_terminal (KGX_APPLICATION (application),
-                                NULL,
-                                timestamp,
-                                dir,
-                                NULL,
-                                NULL);
-}
-
-
 static void
 new_tab_activated (GSimpleAction *action,
                    GVariant      *parameter,
@@ -508,7 +486,6 @@ tab_switcher_activated (GSimpleAction *action,
 
 
 static GActionEntry win_entries[] = {
-  { "new-window", new_activated, NULL, NULL, NULL },
   { "new-tab", new_tab_activated, NULL, NULL, NULL },
   { "close-tab", close_tab_activated, NULL, NULL, NULL },
   { "about", about_activated, NULL, NULL, NULL },
diff --git a/src/kgx-window.ui b/src/kgx-window.ui
index 9c44f25..1ea9e6a 100644
--- a/src/kgx-window.ui
+++ b/src/kgx-window.ui
@@ -15,7 +15,7 @@
     <section>
       <item>
         <attribute name="label" translatable="yes">_New Window</attribute>
-        <attribute name="action">win.new-window</attribute>
+        <attribute name="action">app.new-window</attribute>
       </item>
     </section>
     <section>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]