statusMenu: port to new gdmuser api

https://bugzilla.gnome.org/show_bug.cgi?id=631888
This commit is contained in:
Ray Strode 2010-10-07 18:22:20 -04:00
parent 7ce5ea4142
commit ba0a038247

View File

@ -31,6 +31,8 @@ StatusMenuButton.prototype = {
this.actor.set_child(box); this.actor.set_child(box);
this._gdm = Gdm.UserManager.ref_default(); this._gdm = Gdm.UserManager.ref_default();
this._gdm.queue_load()
this._user = this._gdm.get_user(GLib.get_user_name()); this._user = this._gdm.get_user(GLib.get_user_name());
this._presence = new GnomeSession.Presence(); this._presence = new GnomeSession.Presence();
@ -48,27 +50,31 @@ StatusMenuButton.prototype = {
this._presence.connect('StatusChanged', Lang.bind(this, this._updatePresenceIcon)); this._presence.connect('StatusChanged', Lang.bind(this, this._updatePresenceIcon));
this._presence.getStatus(Lang.bind(this, this._updatePresenceIcon)); this._presence.getStatus(Lang.bind(this, this._updatePresenceIcon));
this._name = new St.Label({ text: this._user.get_real_name() }); this._name = new St.Label();
box.add(this._name, { y_align: St.Align.MIDDLE, y_fill: false }); box.add(this._name, { y_align: St.Align.MIDDLE, y_fill: false });
this._userNameChangedId = this._user.connect('notify::display-name', Lang.bind(this, this._updateUserName)); this._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._updateUserName));
this._userChangedId = this._user.connect('changed', Lang.bind(this, this._updateUserName));
this._createSubMenu(); this._createSubMenu();
this._gdm.connect('users-loaded', Lang.bind(this, this._updateSwitchUser)); this._gdm.connect('notify::is-loaded', Lang.bind(this, this._updateSwitchUser));
this._gdm.connect('user-added', Lang.bind(this, this._updateSwitchUser)); this._gdm.connect('user-added', Lang.bind(this, this._updateSwitchUser));
this._gdm.connect('user-removed', Lang.bind(this, this._updateSwitchUser)); this._gdm.connect('user-removed', Lang.bind(this, this._updateSwitchUser));
}, },
_onDestroy: function() { _onDestroy: function() {
this._user.disconnect(this._userNameChangedId); this._user.disconnect(this._userLoadedId);
this._user.disconnect(this._userChangedId);
}, },
_updateUserName: function() { _updateUserName: function() {
if (this._user.is_loaded)
this._name.set_text(this._user.get_real_name()); this._name.set_text(this._user.get_real_name());
else
this._name.set_text("");
}, },
_updateSwitchUser: function() { _updateSwitchUser: function() {
let users = this._gdm.list_users(); if (this._gdm.can_switch ())
if (users.length > 1)
this._loginScreenItem.actor.show(); this._loginScreenItem.actor.show();
else else
this._loginScreenItem.actor.hide(); this._loginScreenItem.actor.hide();