diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 941f64b53..e3adfcabb 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -19,6 +19,11 @@ const Tweener = imports.ui.tweener; const SLIDER_SCROLL_STEP = 0.05; /* Slider scrolling step in % */ +const Ornament = { + NONE: 0, + DOT: 1, +}; + function _ensureStyle(actor) { if (actor.get_children) { let children = actor.get_children(); @@ -53,6 +58,7 @@ const PopupBaseMenuItem = new Lang.Class({ this.actor._delegate = this; this._children = []; + this._ornament = Ornament.NONE; this._dot = null; this._columnWidths = null; this._spacing = 0; @@ -176,19 +182,18 @@ const PopupBaseMenuItem = new Lang.Class({ this._removeChild(child); }, - setShowDot: function(show) { - if (show) { - if (this._dot) - return; + setOrnament: function(ornament) { + if (ornament == this._ornament) + return; + this._ornament = ornament; + + if (ornament == Ornament.DOT) { this._dot = new St.DrawingArea({ style_class: 'popup-menu-item-dot' }); this._dot.connect('repaint', Lang.bind(this, this._onRepaintDot)); this.actor.add_actor(this._dot); this.actor.add_accessible_state (Atk.StateType.CHECKED); - } else { - if (!this._dot) - return; - + } else if (ornament == Ornament.NONE) { this._dot.destroy(); this._dot = null; this.actor.remove_accessible_state (Atk.StateType.CHECKED); @@ -1890,7 +1895,8 @@ const RemoteMenu = new Lang.Class({ item = new PopupMenuItem(label); item._remoteTarget = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_TARGET, null).deep_unpack(); action.items.push(item); - item.setShowDot(action.state.deep_unpack() == item._remoteTarget); + item.setOrnament(action.state.deep_unpack() == item._remoteTarget ? + Ornament.DOT : Ornament.NONE); specificSignalId = item.connect('activate', Lang.bind(this, function(item) { this.actionGroup.activate_action(action_id, GLib.Variant.new_string(item._remoteTarget)); })); @@ -2026,7 +2032,8 @@ const RemoteMenu = new Lang.Class({ break; case 's': for (let i = 0; i < action.items.length; i++) - action.items[i].setShowDot(action.items[i]._remoteTarget == action.state.deep_unpack()); + action.items[i].setOrnament(action.items[i]._remoteTarget == action.state.deep_unpack() ? + Ornament.DOT : Ornament.NONE); } } }, diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 3dc173b99..28e5b861a 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -417,7 +417,7 @@ const InputSourceIndicator = new Lang.Class({ [oldSource, this._currentSource] = [this._currentSource, newSource]; if (oldSource) { - oldSource.menuItem.setShowDot(false); + oldSource.menuItem.setOrnament(PopupMenu.Ornament.NONE); oldSource.indicatorLabel.hide(); } @@ -435,7 +435,7 @@ const InputSourceIndicator = new Lang.Class({ this.actor.show(); - newSource.menuItem.setShowDot(true); + newSource.menuItem.setOrnament(PopupMenu.Ornament.DOT); newSource.indicatorLabel.show(); this._buildPropSection(newSource.properties); @@ -660,7 +660,8 @@ const InputSourceIndicator = new Lang.Class({ item.prop = prop; radioGroup.push(item); item.radioGroup = radioGroup; - item.setShowDot(prop.get_state() == IBus.PropState.CHECKED); + item.setOrnament(prop.get_state() == IBus.PropState.CHECKED ? + PopupMenu.Ornament.DOT : PopupMenu.Ornament.NONE); item.connect('activate', Lang.bind(this, function() { if (item.prop.get_state() == IBus.PropState.CHECKED) return; @@ -668,12 +669,12 @@ const InputSourceIndicator = new Lang.Class({ let group = item.radioGroup; for (let i = 0; i < group.length; ++i) { if (group[i] == item) { - item.setShowDot(true); + item.setOrnament(PopupMenu.Ornament.DOT); item.prop.set_state(IBus.PropState.CHECKED); this._ibusManager.activateProperty(item.prop.get_key(), IBus.PropState.CHECKED); } else { - group[i].setShowDot(false); + group[i].setOrnament(PopupMenu.Ornament.NONE); group[i].prop.set_state(IBus.PropState.UNCHECKED); this._ibusManager.activateProperty(group[i].prop.get_key(), IBus.PropState.UNCHECKED); diff --git a/js/ui/status/network.js b/js/ui/status/network.js index fe60a7cad..60c164b7c 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -588,7 +588,7 @@ const NMDevice = new Lang.Class({ title = _("Connected (private)"); } this._activeConnectionItem = new PopupMenu.PopupMenuItem(title, { reactive: false }); - this._activeConnectionItem.setShowDot(true); + this._activeConnectionItem.setOrnament(PopupMenu.Ornament.DOT); }, _deviceStateChanged: function(device, newstate, oldstate, reason) { @@ -1371,7 +1371,7 @@ const NMDeviceWireless = new Lang.Class({ this._activeConnectionItem = new PopupMenu.PopupImageMenuItem(title, 'network-wireless-connected-symbolic', { reactive: false }); - this._activeConnectionItem.setShowDot(true); + this._activeConnectionItem.setOrnament(PopupMenu.Ornament.DOT); }, _createAutomaticConnection: function(apObj) {