popupMenu: Remove PopupMenuAlternatingMenuItem

It's now unused.
This commit is contained in:
Jasper St. Pierre 2013-08-16 19:43:04 -04:00
parent 156be19c2d
commit f0e5fb04fc

View File

@ -211,105 +211,6 @@ const PopupSeparatorMenuItem = new Lang.Class({
}
});
const PopupAlternatingMenuItemState = {
DEFAULT: 0,
ALTERNATIVE: 1
}
const PopupAlternatingMenuItem = new Lang.Class({
Name: 'PopupAlternatingMenuItem',
Extends: PopupBaseMenuItem,
_init: function(text, alternateText, params) {
this.parent(params);
this.actor.add_style_class_name('popup-alternating-menu-item');
this._text = text;
this._alternateText = alternateText;
this.label = new St.Label({ text: text });
this.state = PopupAlternatingMenuItemState.DEFAULT;
this.actor.add_child(this.label);
this.actor.label_actor = this.label;
this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped));
},
_onMapped: function() {
if (this.actor.mapped) {
this._capturedEventId = global.stage.connect('captured-event',
Lang.bind(this, this._onCapturedEvent));
this._updateStateFromModifiers();
} else {
if (this._capturedEventId != 0) {
global.stage.disconnect(this._capturedEventId);
this._capturedEventId = 0;
}
}
},
_setState: function(state) {
if (this.state != state) {
if (state == PopupAlternatingMenuItemState.ALTERNATIVE && !this._canAlternate())
return;
this.state = state;
this._updateLabel();
}
},
_updateStateFromModifiers: function() {
let [x, y, mods] = global.get_pointer();
let state;
if ((mods & Clutter.ModifierType.MOD1_MASK) == 0) {
state = PopupAlternatingMenuItemState.DEFAULT;
} else {
state = PopupAlternatingMenuItemState.ALTERNATIVE;
}
this._setState(state);
},
_onCapturedEvent: function(actor, event) {
if (event.type() != Clutter.EventType.KEY_PRESS &&
event.type() != Clutter.EventType.KEY_RELEASE)
return false;
let key = event.get_key_symbol();
if (key == Clutter.KEY_Alt_L || key == Clutter.KEY_Alt_R)
this._updateStateFromModifiers();
return false;
},
_updateLabel: function() {
if (this.state == PopupAlternatingMenuItemState.ALTERNATIVE) {
this.actor.add_style_pseudo_class('alternate');
this.label.set_text(this._alternateText);
} else {
this.actor.remove_style_pseudo_class('alternate');
this.label.set_text(this._text);
}
},
_canAlternate: function() {
if (this.state == PopupAlternatingMenuItemState.DEFAULT && !this._alternateText)
return false;
return true;
},
updateText: function(text, alternateText) {
this._text = text;
this._alternateText = alternateText;
if (!this._canAlternate())
this._setState(PopupAlternatingMenuItemState.DEFAULT);
this._updateLabel();
}
});
const Switch = new Lang.Class({
Name: 'Switch',