popupMenu: Define the dot next to the menu as an "ornament"
We want to remove switches in remote menus, so make way for a checkmark ornament for the popup menu item. https://bugzilla.gnome.org/show_bug.cgi?id=698427
This commit is contained in:
parent
b5c85eaeca
commit
4a2f54f6ff
@ -19,6 +19,11 @@ const Tweener = imports.ui.tweener;
|
|||||||
|
|
||||||
const SLIDER_SCROLL_STEP = 0.05; /* Slider scrolling step in % */
|
const SLIDER_SCROLL_STEP = 0.05; /* Slider scrolling step in % */
|
||||||
|
|
||||||
|
const Ornament = {
|
||||||
|
NONE: 0,
|
||||||
|
DOT: 1,
|
||||||
|
};
|
||||||
|
|
||||||
function _ensureStyle(actor) {
|
function _ensureStyle(actor) {
|
||||||
if (actor.get_children) {
|
if (actor.get_children) {
|
||||||
let children = actor.get_children();
|
let children = actor.get_children();
|
||||||
@ -53,6 +58,7 @@ const PopupBaseMenuItem = new Lang.Class({
|
|||||||
this.actor._delegate = this;
|
this.actor._delegate = this;
|
||||||
|
|
||||||
this._children = [];
|
this._children = [];
|
||||||
|
this._ornament = Ornament.NONE;
|
||||||
this._dot = null;
|
this._dot = null;
|
||||||
this._columnWidths = null;
|
this._columnWidths = null;
|
||||||
this._spacing = 0;
|
this._spacing = 0;
|
||||||
@ -176,19 +182,18 @@ const PopupBaseMenuItem = new Lang.Class({
|
|||||||
this._removeChild(child);
|
this._removeChild(child);
|
||||||
},
|
},
|
||||||
|
|
||||||
setShowDot: function(show) {
|
setOrnament: function(ornament) {
|
||||||
if (show) {
|
if (ornament == this._ornament)
|
||||||
if (this._dot)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this._ornament = ornament;
|
||||||
|
|
||||||
|
if (ornament == Ornament.DOT) {
|
||||||
this._dot = new St.DrawingArea({ style_class: 'popup-menu-item-dot' });
|
this._dot = new St.DrawingArea({ style_class: 'popup-menu-item-dot' });
|
||||||
this._dot.connect('repaint', Lang.bind(this, this._onRepaintDot));
|
this._dot.connect('repaint', Lang.bind(this, this._onRepaintDot));
|
||||||
this.actor.add_actor(this._dot);
|
this.actor.add_actor(this._dot);
|
||||||
this.actor.add_accessible_state (Atk.StateType.CHECKED);
|
this.actor.add_accessible_state (Atk.StateType.CHECKED);
|
||||||
} else {
|
} else if (ornament == Ornament.NONE) {
|
||||||
if (!this._dot)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._dot.destroy();
|
this._dot.destroy();
|
||||||
this._dot = null;
|
this._dot = null;
|
||||||
this.actor.remove_accessible_state (Atk.StateType.CHECKED);
|
this.actor.remove_accessible_state (Atk.StateType.CHECKED);
|
||||||
@ -1890,7 +1895,8 @@ const RemoteMenu = new Lang.Class({
|
|||||||
item = new PopupMenuItem(label);
|
item = new PopupMenuItem(label);
|
||||||
item._remoteTarget = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_TARGET, null).deep_unpack();
|
item._remoteTarget = model.get_item_attribute_value(index, Gio.MENU_ATTRIBUTE_TARGET, null).deep_unpack();
|
||||||
action.items.push(item);
|
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) {
|
specificSignalId = item.connect('activate', Lang.bind(this, function(item) {
|
||||||
this.actionGroup.activate_action(action_id, GLib.Variant.new_string(item._remoteTarget));
|
this.actionGroup.activate_action(action_id, GLib.Variant.new_string(item._remoteTarget));
|
||||||
}));
|
}));
|
||||||
@ -2026,7 +2032,8 @@ const RemoteMenu = new Lang.Class({
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
for (let i = 0; i < action.items.length; i++)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -417,7 +417,7 @@ const InputSourceIndicator = new Lang.Class({
|
|||||||
[oldSource, this._currentSource] = [this._currentSource, newSource];
|
[oldSource, this._currentSource] = [this._currentSource, newSource];
|
||||||
|
|
||||||
if (oldSource) {
|
if (oldSource) {
|
||||||
oldSource.menuItem.setShowDot(false);
|
oldSource.menuItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
oldSource.indicatorLabel.hide();
|
oldSource.indicatorLabel.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +435,7 @@ const InputSourceIndicator = new Lang.Class({
|
|||||||
|
|
||||||
this.actor.show();
|
this.actor.show();
|
||||||
|
|
||||||
newSource.menuItem.setShowDot(true);
|
newSource.menuItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
newSource.indicatorLabel.show();
|
newSource.indicatorLabel.show();
|
||||||
|
|
||||||
this._buildPropSection(newSource.properties);
|
this._buildPropSection(newSource.properties);
|
||||||
@ -660,7 +660,8 @@ const InputSourceIndicator = new Lang.Class({
|
|||||||
item.prop = prop;
|
item.prop = prop;
|
||||||
radioGroup.push(item);
|
radioGroup.push(item);
|
||||||
item.radioGroup = radioGroup;
|
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() {
|
item.connect('activate', Lang.bind(this, function() {
|
||||||
if (item.prop.get_state() == IBus.PropState.CHECKED)
|
if (item.prop.get_state() == IBus.PropState.CHECKED)
|
||||||
return;
|
return;
|
||||||
@ -668,12 +669,12 @@ const InputSourceIndicator = new Lang.Class({
|
|||||||
let group = item.radioGroup;
|
let group = item.radioGroup;
|
||||||
for (let i = 0; i < group.length; ++i) {
|
for (let i = 0; i < group.length; ++i) {
|
||||||
if (group[i] == item) {
|
if (group[i] == item) {
|
||||||
item.setShowDot(true);
|
item.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
item.prop.set_state(IBus.PropState.CHECKED);
|
item.prop.set_state(IBus.PropState.CHECKED);
|
||||||
this._ibusManager.activateProperty(item.prop.get_key(),
|
this._ibusManager.activateProperty(item.prop.get_key(),
|
||||||
IBus.PropState.CHECKED);
|
IBus.PropState.CHECKED);
|
||||||
} else {
|
} else {
|
||||||
group[i].setShowDot(false);
|
group[i].setOrnament(PopupMenu.Ornament.NONE);
|
||||||
group[i].prop.set_state(IBus.PropState.UNCHECKED);
|
group[i].prop.set_state(IBus.PropState.UNCHECKED);
|
||||||
this._ibusManager.activateProperty(group[i].prop.get_key(),
|
this._ibusManager.activateProperty(group[i].prop.get_key(),
|
||||||
IBus.PropState.UNCHECKED);
|
IBus.PropState.UNCHECKED);
|
||||||
|
@ -588,7 +588,7 @@ const NMDevice = new Lang.Class({
|
|||||||
title = _("Connected (private)");
|
title = _("Connected (private)");
|
||||||
}
|
}
|
||||||
this._activeConnectionItem = new PopupMenu.PopupMenuItem(title, { reactive: false });
|
this._activeConnectionItem = new PopupMenu.PopupMenuItem(title, { reactive: false });
|
||||||
this._activeConnectionItem.setShowDot(true);
|
this._activeConnectionItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
},
|
},
|
||||||
|
|
||||||
_deviceStateChanged: function(device, newstate, oldstate, reason) {
|
_deviceStateChanged: function(device, newstate, oldstate, reason) {
|
||||||
@ -1371,7 +1371,7 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
this._activeConnectionItem = new PopupMenu.PopupImageMenuItem(title,
|
this._activeConnectionItem = new PopupMenu.PopupImageMenuItem(title,
|
||||||
'network-wireless-connected-symbolic',
|
'network-wireless-connected-symbolic',
|
||||||
{ reactive: false });
|
{ reactive: false });
|
||||||
this._activeConnectionItem.setShowDot(true);
|
this._activeConnectionItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
},
|
},
|
||||||
|
|
||||||
_createAutomaticConnection: function(apObj) {
|
_createAutomaticConnection: function(apObj) {
|
||||||
|
Loading…
Reference in New Issue
Block a user