~jeremywootten/pantheon-files/various-fixes-part3-fix-network-file-operations

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/***
    Copyright (C) 2010 Cosimo Cecchi <cosimoc@gnome.org>
    Copyright (C) 2015 elementary Developers

    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License version 3, as published
    by the Free Software Foundation.

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranties of
    MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
    PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program. If not, see <http://www.gnu.org/licenses/>.

    Authors: Cosimo Cecchi <cosimoc@gnome.org>
             Julián Unrrein <junrrein@gmail.com>
***/

public class Marlin.ConnectServer.Operation : Gtk.MountOperation {

    private Marlin.ConnectServer.Dialog dialog;

    public Operation (Marlin.ConnectServer.Dialog dialog) {
        this.dialog = dialog;
        this.set_parent (dialog);

        /* Turn the parent's modal functionality off because the mount operation needs to take over */
        this.dialog.modal = false;
        this.reply.connect ( (result) => {
           this.dialog.modal = true;
        });
    }

    /*
      When mounting a network share, the ask_password implementation in
      Gtk.MountOperation asks the user the password in a little separate window.
      But we don't want an extra window. Our ConnectServer.Dialog already
      provided a place to put the password in.

      This ask_password implementation gets the password directly from the
      dialog, so no extra window is spawned.
    */
    public override void ask_password (string message,
                                       string default_user,
                                       string default_domain,
                                       AskPasswordFlags flags) {

        this.dialog.fill_details_async.begin (this, default_user, default_domain, flags,
                                              (source, result) => {
            bool res = this.dialog.fill_details_async.end (result);

            if (res)
                reply (MountOperationResult.HANDLED);
            else
                reply (MountOperationResult.ABORTED);
        });
    }
}