[polari/wip/fmuellner/window-experiments: 32/32] roomList: Add "Open in Window" to context menu



commit 221d1de7e7f9b843043a0027de8ab60d1731f3ec
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 19 18:46:13 2016 +0200

    roomList: Add "Open in Window" to context menu

 src/application.js |   14 ++++++++++++++
 src/mainWindow.js  |    5 +++++
 src/roomList.js    |    2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 46fbde8..8e22f31 100644
--- a/src/application.js
+++ b/src/application.js
@@ -82,6 +82,9 @@ const Application = new Lang.Class({
             activate: Lang.bind(this, this._onNewWindow) },
           { name: 'run-in-background',
             activate: Lang.bind(this, this._onRunInBackground) },
+          { name: 'open-in-window',
+            parameter_type: GLib.VariantType.new('s'),
+            activate: Lang.bind(this, this._onOpenInWindow) },
           { name: 'help',
             activate: Lang.bind(this, this._onShowHelp),
             accels: ['F1'] },
@@ -538,6 +541,17 @@ const Application = new Lang.Class({
         }
     },
 
+    _onOpenInWindow: function(action, param) {
+        let [roomId] = param.get_string();
+        let room = this._chatroomManager.getRoomById(roomId);
+        if (!room)
+            return;
+        let window = new MainWindow.MainWindow({ application: this,
+                                                 active_room: room,
+                                                 single_room: true });
+        window.present();
+    },
+
     _onShowHelp: function() {
         Utils.openURL('help:org.gnome.Polari', Gtk.get_current_event_time());
     },
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 5f1987f..c802f17 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -331,6 +331,11 @@ const MainWindow = new Lang.Class({
         this._membersChangedId = 0;
         this._channelChangedId = 0;
 
+        if (this._singleRoom) {
+            if (this._room && (!room || this._room.id != room.id))
+                this.destroy();
+        }
+
         this._room = room;
 
         this.notify('active-room');
diff --git a/src/roomList.js b/src/roomList.js
index 7a17b66..538b718 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -132,6 +132,8 @@ const RoomRow = new Lang.Class({
             let isRoom = this._room.type == Tp.HandleType.ROOM;
             menu.append(isRoom ? _("Leave chatroom") : _("End conversation"),
                         'app.leave-room(("%s", ""))'.format(this._room.id));
+            menu.append(_("Open in Window"),
+                        'app.open-in-window("%s")'.format(this._room.id));
 
             this._popover = Gtk.Popover.new_from_model(this, menu);
             this._popover.connect('notify::visible', _onPopoverVisibleChanged);


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