[polari/wip/fmuellner/nickserv: 17/20] roomStack: Ask users whether to save "identify" passwords



commit 93ddc94e01c2879e82e6484994bf37fb8265f9b9
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 2 15:28:38 2016 +0200

    roomStack: Ask users whether to save "identify" passwords
    
    We now have everything in place to allow saving users' NickServ
    passwords, so listen for the room's ::identify-sent signal and
    slide down an info bar to ask the user for confirmation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709982

 src/roomStack.js |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 65 insertions(+), 4 deletions(-)
---
diff --git a/src/roomStack.js b/src/roomStack.js
index d8e444c..a5855b0 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -2,6 +2,7 @@ const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
+const Tp = imports.gi.TelepathyGLib;
 
 const AccountsMonitor = imports.accountsMonitor;
 const ChatView = imports.chatView;
@@ -89,6 +90,60 @@ const RoomStack = new Lang.Class({
     }
 });
 
+const SavePasswordConfirmationBar = new Lang.Class({
+    Name: 'SavePasswordConfirmationBar',
+    Extends: Gtk.Revealer,
+
+    _init: function(room) {
+        this._room = room;
+
+        this.parent({ valign: Gtk.Align.START });
+
+        this._createWidget();
+
+        this._identifySentId = this._room.connect('identify-sent', () => {
+            this.reveal_child = true;
+        });
+        this._infoBar.connect('response', () => { this.reveal_child = false; });
+    },
+
+    _createWidget: function() {
+        this._infoBar = new Gtk.InfoBar({ show_close_button: true })
+        this.add(this._infoBar);
+
+        let target = new GLib.Variant('o', this._room.account.object_path);
+        let button = new Gtk.Button({ label: _("_Save Password"),
+                                      use_underline: true,
+                                      action_name: 'app.save-identify-password',
+                                      action_target: target });
+        this._infoBar.add_action_widget(button, Gtk.ResponseType.ACCEPT);
+
+        let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
+        this._infoBar.get_content_area().add(box);
+
+        let title = _("Should the password be saved?");
+        this._titleLabel = new Gtk.Label({ halign: Gtk.Align.START,
+                                           valign: Gtk.Align.CENTER });
+        this._titleLabel.set_markup('<b>' + title + '</b>');
+        box.add(this._titleLabel);
+
+        let accountName = this._room.account.display_name;
+        let text = _("Identification will happen automatically the next time you connect to 
%s").format(accountName);
+        this._subtitleLabel = new Gtk.Label({ label: text });
+        box.add(this._subtitleLabel);
+
+        this._infoBar.show_all();
+    },
+
+    vfunc_destroy: function() {
+        if (this._identifySentId)
+            this._room.disconnect(this._identifySentId);
+        this._identifySentId = 0;
+
+        this.parent();
+    }
+});
+
 const ChatPlaceholder = new Lang.Class({
     Name: 'ChatPlaceholder',
     Extends: Gtk.Overlay,
@@ -129,17 +184,23 @@ const ChatPlaceholder = new Lang.Class({
 
 const RoomView = new Lang.Class({
     Name: 'RoomView',
-    Extends: Gtk.Box,
+    Extends: Gtk.Overlay,
 
     _init: function(room, sizeGroup) {
-        this.parent({ orientation: Gtk.Orientation.VERTICAL });
+        this.parent();
+
+        let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
+        this.add(box);
+
+        if (room.type == Tp.HandleType.CONTACT)
+            this.add_overlay(new SavePasswordConfirmationBar(room));
 
         this._view = new ChatView.ChatView(room);
-        this.add(this._view);
+        box.add(this._view);
 
         this._entryArea = new EntryArea.EntryArea({ room: room,
                                                     sensitive: false });
-        this.add(this._entryArea);
+        box.add(this._entryArea);
 
         this._view.bind_property('max-nick-chars',
                                  this._entryArea, 'max-nick-chars',


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