[polari/wip/fmuellner/window-experiments: 350/356] app: Implement 'new-window' action



commit cbb0c6c2f4355ebce14d001dd7b338ed305ac7bf
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 14 18:27:05 2016 +0200

    app: Implement 'new-window' action
    
    Now that all code has been adapted to deal with more than a single
    main window, we can provide a 'new-window' action and expose it in
    desktop actions and app menu.

 data/org.gnome.Polari.desktop.in |    5 +++++
 data/resources/menus.ui          |    4 ++++
 src/application.js               |    9 +++++++++
 3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Polari.desktop.in b/data/org.gnome.Polari.desktop.in
index 92bbab1..c940acc 100644
--- a/data/org.gnome.Polari.desktop.in
+++ b/data/org.gnome.Polari.desktop.in
@@ -8,7 +8,12 @@ Type=Application
 MimeType=x-scheme-handler/irc;
 StartupNotify=true
 DBusActivatable=true
+Actions=new-window;
 X-GNOME-UsesNotifications=true
 Categories=GNOME;GTK;Network;IRCClient;
 # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list 
MUST also end with a semicolon!
 Keywords=IRC;Internet;Relay;Chat;
+
+[Desktop Action new-window]
+Name=New Window
+Exec=gapplication action org.gnome.Polari new-window
diff --git a/data/resources/menus.ui b/data/resources/menus.ui
index eff8d78..7b43493 100644
--- a/data/resources/menus.ui
+++ b/data/resources/menus.ui
@@ -2,6 +2,10 @@
   <menu id="app-menu">
     <section>
       <item>
+        <attribute name="action">app.new-window</attribute>
+        <attribute name="label" translatable="yes">New Window</attribute>
+      </item>
+      <item>
         <attribute name="action">app.run-in-background</attribute>
         <attribute name="label" translatable="yes">Run in Background</attribute>
       </item>
diff --git a/src/application.js b/src/application.js
index 1ec386a..85a69d8 100644
--- a/src/application.js
+++ b/src/application.js
@@ -158,6 +158,8 @@ const Application = new Lang.Class({
             parameter_type: GLib.VariantType.new('o') },
           { name: 'start-client',
             activate: Lang.bind(this, this._onStartClient) },
+          { name: 'new-window',
+            activate: Lang.bind(this, this._onNewWindow) },
           { name: 'help',
             activate: Lang.bind(this, this._onShowHelp),
             accels: ['F1'] },
@@ -488,6 +490,13 @@ const Application = new Lang.Class({
         dialog.show();
     },
 
+    _onNewWindow: function() {
+        let activeRoom = this.active_window.active_room;
+        let window = new MainWindow.MainWindow({ application: this,
+                                                 active_room: activeRoom });
+        window.present();
+    },
+
     _createLink: function(file, target) {
         try {
             file.get_parent().make_directory_with_parents(null);


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