quickSettings: Rename 'label' property to 'title'
We'll soon add a subtitle, so rename the label property to something that is a bit more semantic.Add a warning when trying to set the old 'label' property. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2619>
This commit is contained in:
parent
4786109adf
commit
2d2172da32
@ -30,7 +30,7 @@
|
|||||||
&:ltr > StBoxLayout { padding-left: $base_padding*2.5; }
|
&:ltr > StBoxLayout { padding-left: $base_padding*2.5; }
|
||||||
&:rtl > StBoxLayout { padding-right: $base_padding*2.5; }
|
&:rtl > StBoxLayout { padding-right: $base_padding*2.5; }
|
||||||
|
|
||||||
.quick-toggle-label { font-weight: bold; }
|
.quick-toggle-title { font-weight: bold; }
|
||||||
.quick-toggle-icon, .quick-toggle-arrow { icon-size: $base_icon_size; }
|
.quick-toggle-icon, .quick-toggle-arrow { icon-size: $base_icon_size; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ var QuickSettingsItem = GObject.registerClass({
|
|||||||
|
|
||||||
var QuickToggle = GObject.registerClass({
|
var QuickToggle = GObject.registerClass({
|
||||||
Properties: {
|
Properties: {
|
||||||
'label': GObject.ParamSpec.override('label', St.Button),
|
'title': GObject.ParamSpec.string('title', '', '',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
null),
|
||||||
'icon-name': GObject.ParamSpec.override('icon-name', St.Button),
|
'icon-name': GObject.ParamSpec.override('icon-name', St.Button),
|
||||||
'gicon': GObject.ParamSpec.object('gicon', '', '',
|
'gicon': GObject.ParamSpec.object('gicon', '', '',
|
||||||
GObject.ParamFlags.READWRITE,
|
GObject.ParamFlags.READWRITE,
|
||||||
@ -76,21 +78,26 @@ var QuickToggle = GObject.registerClass({
|
|||||||
GObject.BindingFlags.SYNC_CREATE |
|
GObject.BindingFlags.SYNC_CREATE |
|
||||||
GObject.BindingFlags.BIDIRECTIONAL);
|
GObject.BindingFlags.BIDIRECTIONAL);
|
||||||
|
|
||||||
this._label = new St.Label({
|
this._title = new St.Label({
|
||||||
style_class: 'quick-toggle-label',
|
style_class: 'quick-toggle-title',
|
||||||
y_align: Clutter.ActorAlign.CENTER,
|
y_align: Clutter.ActorAlign.CENTER,
|
||||||
x_align: Clutter.ActorAlign.START,
|
x_align: Clutter.ActorAlign.START,
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
});
|
});
|
||||||
this.label_actor = this._label;
|
this.label_actor = this._title;
|
||||||
this._box.add_child(this._label);
|
this._box.add_child(this._title);
|
||||||
|
|
||||||
this._label.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
this._title.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
||||||
|
|
||||||
this.bind_property('label',
|
this.bind_property('title',
|
||||||
this._label, 'text',
|
this._title, 'text',
|
||||||
GObject.BindingFlags.SYNC_CREATE);
|
GObject.BindingFlags.SYNC_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set label(label) {
|
||||||
|
console.warn('Trying to set label on QuickToggle. Use title instead.');
|
||||||
|
this.title = label;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var QuickMenuToggle = GObject.registerClass({
|
var QuickMenuToggle = GObject.registerClass({
|
||||||
|
@ -11,7 +11,7 @@ class RotationToggle extends QuickToggle {
|
|||||||
this._systemActions = new SystemActions.getDefault();
|
this._systemActions = new SystemActions.getDefault();
|
||||||
|
|
||||||
super._init({
|
super._init({
|
||||||
label: _('Auto Rotate'),
|
title: _('Auto Rotate'),
|
||||||
});
|
});
|
||||||
|
|
||||||
this._systemActions.bind_property('can-lock-orientation',
|
this._systemActions.bind_property('can-lock-orientation',
|
||||||
|
@ -148,7 +148,7 @@ const BtClient = GObject.registerClass({
|
|||||||
const BluetoothToggle = GObject.registerClass(
|
const BluetoothToggle = GObject.registerClass(
|
||||||
class BluetoothToggle extends QuickToggle {
|
class BluetoothToggle extends QuickToggle {
|
||||||
_init(client) {
|
_init(client) {
|
||||||
super._init({label: _('Bluetooth')});
|
super._init({title: _('Bluetooth')});
|
||||||
|
|
||||||
this._client = client;
|
this._client = client;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ const DarkModeToggle = GObject.registerClass(
|
|||||||
class DarkModeToggle extends QuickToggle {
|
class DarkModeToggle extends QuickToggle {
|
||||||
_init() {
|
_init() {
|
||||||
super._init({
|
super._init({
|
||||||
label: _('Dark Style'),
|
title: _('Dark Style'),
|
||||||
iconName: 'dark-mode-symbolic',
|
iconName: 'dark-mode-symbolic',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1319,8 +1319,8 @@ const NMToggle = GObject.registerClass({
|
|||||||
this._itemBinding.bind('icon-name',
|
this._itemBinding.bind('icon-name',
|
||||||
this, 'icon-name', GObject.BindingFlags.DEFAULT);
|
this, 'icon-name', GObject.BindingFlags.DEFAULT);
|
||||||
this._itemBinding.bind_full('name',
|
this._itemBinding.bind_full('name',
|
||||||
this, 'label', GObject.BindingFlags.DEFAULT,
|
this, 'title', GObject.BindingFlags.DEFAULT,
|
||||||
(bind, source) => [true, this._transformLabel(source)],
|
(bind, source) => [true, this._transformTitle(source)],
|
||||||
null);
|
null);
|
||||||
|
|
||||||
this.connect('clicked', () => this.activate());
|
this.connect('clicked', () => this.activate());
|
||||||
@ -1360,7 +1360,7 @@ const NMToggle = GObject.registerClass({
|
|||||||
// transform function for property binding:
|
// transform function for property binding:
|
||||||
// Ignore the provided label if there are multiple active
|
// Ignore the provided label if there are multiple active
|
||||||
// items, and replace it with something like "VPN (2)"
|
// items, and replace it with something like "VPN (2)"
|
||||||
_transformLabel(source) {
|
_transformTitle(source) {
|
||||||
const nActive = this.checked
|
const nActive = this.checked
|
||||||
? [...this._getActiveItems()].length
|
? [...this._getActiveItems()].length
|
||||||
: 0;
|
: 0;
|
||||||
|
@ -17,7 +17,7 @@ const NightLightToggle = GObject.registerClass(
|
|||||||
class NightLightToggle extends QuickToggle {
|
class NightLightToggle extends QuickToggle {
|
||||||
_init() {
|
_init() {
|
||||||
super._init({
|
super._init({
|
||||||
label: _('Night Light'),
|
title: _('Night Light'),
|
||||||
iconName: 'night-light-symbolic',
|
iconName: 'night-light-symbolic',
|
||||||
toggleMode: true,
|
toggleMode: true,
|
||||||
});
|
});
|
||||||
|
@ -17,17 +17,17 @@ const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(PowerProfilesIface);
|
|||||||
|
|
||||||
const PROFILE_PARAMS = {
|
const PROFILE_PARAMS = {
|
||||||
'performance': {
|
'performance': {
|
||||||
label: C_('Power profile', 'Performance'),
|
title: C_('Power profile', 'Performance'),
|
||||||
iconName: 'power-profile-performance-symbolic',
|
iconName: 'power-profile-performance-symbolic',
|
||||||
},
|
},
|
||||||
|
|
||||||
'balanced': {
|
'balanced': {
|
||||||
label: C_('Power profile', 'Balanced'),
|
title: C_('Power profile', 'Balanced'),
|
||||||
iconName: 'power-profile-balanced-symbolic',
|
iconName: 'power-profile-balanced-symbolic',
|
||||||
},
|
},
|
||||||
|
|
||||||
'power-saver': {
|
'power-saver': {
|
||||||
label: C_('Power profile', 'Power Saver'),
|
title: C_('Power profile', 'Power Saver'),
|
||||||
iconName: 'power-profile-power-saver-symbolic',
|
iconName: 'power-profile-power-saver-symbolic',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -83,11 +83,11 @@ class PowerProfilesToggle extends QuickMenuToggle {
|
|||||||
.map(p => p.Profile.unpack())
|
.map(p => p.Profile.unpack())
|
||||||
.reverse();
|
.reverse();
|
||||||
for (const profile of profiles) {
|
for (const profile of profiles) {
|
||||||
const {label, iconName} = PROFILE_PARAMS[profile];
|
const {title, iconName} = PROFILE_PARAMS[profile];
|
||||||
if (!label)
|
if (!title)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const item = new PopupMenu.PopupImageMenuItem(label, iconName);
|
const item = new PopupMenu.PopupImageMenuItem(title, iconName);
|
||||||
item.connect('activate',
|
item.connect('activate',
|
||||||
() => (this._proxy.ActiveProfile = profile));
|
() => (this._proxy.ActiveProfile = profile));
|
||||||
this._profileItems.set(profile, item);
|
this._profileItems.set(profile, item);
|
||||||
|
@ -93,7 +93,7 @@ const RfkillToggle = GObject.registerClass(
|
|||||||
class RfkillToggle extends QuickToggle {
|
class RfkillToggle extends QuickToggle {
|
||||||
_init() {
|
_init() {
|
||||||
super._init({
|
super._init({
|
||||||
label: _('Airplane Mode'),
|
title: _('Airplane Mode'),
|
||||||
iconName: 'airplane-mode-symbolic',
|
iconName: 'airplane-mode-symbolic',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ const PowerToggle = GObject.registerClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.set({
|
this.set({
|
||||||
label: _('%d\u2009%%').format(this._proxy.Percentage),
|
title: _('%d\u2009%%').format(this._proxy.Percentage),
|
||||||
fallback_icon_name: this._proxy.IconName,
|
fallback_icon_name: this._proxy.IconName,
|
||||||
gicon,
|
gicon,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user