~ubuntu-branches/ubuntu/saucy/gnome-shell/saucy-proposed

« back to all changes in this revision

Viewing changes to js/gdm/powerMenu.js

Tags: upstream-3.3.90
ImportĀ upstreamĀ versionĀ 3.3.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
const UPowerGlib = imports.gi.UPowerGlib;
23
23
 
24
24
const ConsoleKit = imports.gdm.consoleKit;
 
25
const Systemd = imports.gdm.systemd;
 
26
 
25
27
const PanelMenu = imports.ui.panelMenu;
26
28
const PopupMenu = imports.ui.popupMenu;
27
29
 
28
 
function PowerMenuButton() {
29
 
    this._init();
30
 
}
31
 
 
32
 
PowerMenuButton.prototype = {
33
 
    __proto__: PanelMenu.SystemStatusButton.prototype,
 
30
const PowerMenuButton = new Lang.Class({
 
31
    Name: 'PowerMenuButton',
 
32
    Extends: PanelMenu.SystemStatusButton,
34
33
 
35
34
    _init: function() {
36
 
        PanelMenu.SystemStatusButton.prototype._init.call(this, 'system-shutdown', null);
 
35
        this.parent('system-shutdown', null);
37
36
        this._consoleKitManager = new ConsoleKit.ConsoleKitManager();
 
37
        this._systemdLoginManager = new Systemd.SystemdLoginManager();
38
38
        this._upClient = new UPowerGlib.Client();
39
39
 
40
40
        this._createSubMenu();
64
64
    },
65
65
 
66
66
    _updateHaveShutdown: function() {
67
 
        this._consoleKitManager.CanStopRemote(Lang.bind(this,
68
 
            function(result, error) {
69
 
                if (!error)
70
 
                    this._haveShutdown = result;
71
 
                else
72
 
                    this._haveShutdown = false;
73
 
 
74
 
                if (this._haveShutdown) {
75
 
                    this._powerOffItem.actor.show();
76
 
                } else {
77
 
                    this._powerOffItem.actor.hide();
78
 
                }
79
 
 
80
 
                this._updateVisibility();
81
 
            }));
 
67
 
 
68
        if (Systemd.haveSystemd()) {
 
69
            this._systemdLoginManager.CanPowerOffRemote(Lang.bind(this,
 
70
                function(result, error) {
 
71
                    if (!error)
 
72
                        this._haveShutdown = result != 'no';
 
73
                    else
 
74
                        this._haveShutdown = false;
 
75
 
 
76
                    if (this._haveShutdown)
 
77
                        this._powerOffItem.actor.show();
 
78
                    else
 
79
                        this._powerOffItem.actor.hide();
 
80
 
 
81
                    this._updateVisibility();
 
82
                }));
 
83
        } else {
 
84
            this._consoleKitManager.CanStopRemote(Lang.bind(this,
 
85
                function(result, error) {
 
86
                    if (!error)
 
87
                        this._haveShutdown = result;
 
88
                    else
 
89
                        this._haveShutdown = false;
 
90
 
 
91
                    if (this._haveShutdown) {
 
92
                        this._powerOffItem.actor.show();
 
93
                    } else {
 
94
                        this._powerOffItem.actor.hide();
 
95
                    }
 
96
 
 
97
                    this._updateVisibility();
 
98
                }));
 
99
        }
82
100
    },
83
101
 
84
102
    _updateHaveRestart: function() {
85
 
        this._consoleKitManager.CanRestartRemote(Lang.bind(this,
86
 
            function(result, error) {
87
 
                if (!error)
88
 
                    this._haveRestart = result;
89
 
                else
90
 
                    this._haveRestart = false;
91
 
 
92
 
                if (this._haveRestart) {
93
 
                    this._restartItem.actor.show();
94
 
                } else {
95
 
                    this._restartItem.actor.hide();
96
 
                }
97
 
 
98
 
                this._updateVisibility();
99
 
            }));
 
103
 
 
104
        if (Systemd.haveSystemd()) {
 
105
            this._systemdLoginManager.CanRebootRemote(Lang.bind(this,
 
106
                function(result, error) {
 
107
                    if (!error)
 
108
                        this._haveRestart = result != 'no';
 
109
                    else
 
110
                        this._haveRestart = false;
 
111
 
 
112
                    if (this._haveRestart)
 
113
                        this._restartItem.actor.show();
 
114
                    else
 
115
                        this._restartItem.actor.hide();
 
116
 
 
117
                    this._updateVisibility();
 
118
                }));
 
119
        } else {
 
120
            this._consoleKitManager.CanRestartRemote(Lang.bind(this,
 
121
                function(result, error) {
 
122
                    if (!error)
 
123
                        this._haveRestart = result;
 
124
                    else
 
125
                        this._haveRestart = false;
 
126
 
 
127
                    if (this._haveRestart) {
 
128
                        this._restartItem.actor.show();
 
129
                    } else {
 
130
                        this._restartItem.actor.hide();
 
131
                    }
 
132
 
 
133
                    this._updateVisibility();
 
134
                }));
 
135
        }
100
136
    },
101
137
 
102
138
    _updateHaveSuspend: function() {
135
171
    },
136
172
 
137
173
    _onActivateRestart: function() {
138
 
        if (this._haveRestart)
 
174
        if (!this._haveRestart)
 
175
            return;
 
176
 
 
177
        if (Systemd.haveSystemd())
 
178
            this._systemdLoginManager.RebootRemote(true);
 
179
        else
139
180
            this._consoleKitManager.RestartRemote();
140
181
    },
141
182
 
142
183
    _onActivatePowerOff: function() {
143
 
        if (this._haveShutdown)
 
184
        if (!this._haveShutdown)
 
185
            return;
 
186
 
 
187
        if (Systemd.haveSystemd())
 
188
            this._systemdLoginManager.PowerOffRemote(true);
 
189
        else
144
190
            this._consoleKitManager.StopRemote();
145
191
    }
146
 
};
 
192
});