Js: Use new :icon-name property

Now that we have the new convenience property, apply it to all
icon-only buttons.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2254>
This commit is contained in:
Florian Müllner 2022-03-21 16:44:24 +01:00 committed by Marge Bot
parent d72abf5268
commit 65831f783e
14 changed files with 37 additions and 44 deletions

View File

@ -29,8 +29,11 @@
.horizontal & { padding-left: $base_padding*2; } .horizontal & { padding-left: $base_padding*2; }
} }
.candidate-page-button { padding: $base_padding;} .candidate-page-button {
padding: $base_padding;
& StIcon { icon-size: $base_icon_size; }
}
.candidate-page-button-previous { border-radius: $base_border_radius 0px 0px $base_border_radius; border-right-width: 0;box-shadow: none;} .candidate-page-button-previous { border-radius: $base_border_radius 0px 0px $base_border_radius; border-right-width: 0;box-shadow: none;}
.candidate-page-button-next { border-radius: 0px $base_border_radius $base_border_radius 0px;box-shadow: none;} .candidate-page-button-next { border-radius: 0px $base_border_radius $base_border_radius 0px;box-shadow: none;}
.candidate-page-button-icon { icon-size: $base_icon_size; }

View File

@ -79,6 +79,8 @@
color: $insensitive_fg_color; color: $insensitive_fg_color;
&:hover { color: lighten($insensitive_fg_color, 20%); } &:hover { color: lighten($insensitive_fg_color, 20%); }
&:active { color: darken($insensitive_fg_color, 20%); } &:active { color: darken($insensitive_fg_color, 20%); }
& StIcon { icon-size: 12px; }
} }
} }

View File

@ -123,6 +123,8 @@
margin: 1px; margin: 1px;
&:hover {background-color: transparentize($fg_color, 0.8);} &:hover {background-color: transparentize($fg_color, 0.8);}
&:active {background-color: transparentize($fg_color, 0.9);} &:active {background-color: transparentize($fg_color, 0.9);}
& StIcon { icon-size: $base_icon_size; }
} }
// body // body
@ -157,6 +159,8 @@
// fix margin for last button // fix margin for last button
&:last-child:ltr { margin-right: $base_margin*3; } &:last-child:ltr { margin-right: $base_margin*3; }
&:last-child:rtl { margin-left: $base_margin*3; } &:last-child:rtl { margin-left: $base_margin*3; }
& StIcon { icon-size: $base_icon_size; }
} }
// album-art // album-art

View File

@ -147,7 +147,7 @@ var AuthPrompt = GObject.registerClass({
can_focus: this._hasCancelButton, can_focus: this._hasCancelButton,
x_align: Clutter.ActorAlign.START, x_align: Clutter.ActorAlign.START,
y_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER,
child: new St.Icon({ icon_name: 'go-previous-symbolic' }), icon_name: 'go-previous-symbolic',
}); });
if (this._hasCancelButton) if (this._hasCancelButton)
this.cancelButton.connect('clicked', () => this.cancel()); this.cancelButton.connect('clicked', () => this.cancel());

View File

@ -308,9 +308,9 @@ var SessionMenuButton = GObject.registerClass({
Signals: { 'session-activated': { param_types: [GObject.TYPE_STRING] } }, Signals: { 'session-activated': { param_types: [GObject.TYPE_STRING] } },
}, class SessionMenuButton extends St.Bin { }, class SessionMenuButton extends St.Bin {
_init() { _init() {
let gearIcon = new St.Icon({ icon_name: 'emblem-system-symbolic' });
let button = new St.Button({ let button = new St.Button({
style_class: 'modal-dialog-button button login-dialog-session-list-button', style_class: 'modal-dialog-button button login-dialog-session-list-button',
icon_name: 'emblem-system-symbolic',
reactive: true, reactive: true,
track_hover: true, track_hover: true,
can_focus: true, can_focus: true,
@ -318,7 +318,6 @@ var SessionMenuButton = GObject.registerClass({
accessible_role: Atk.Role.MENU, accessible_role: Atk.Role.MENU,
x_align: Clutter.ActorAlign.CENTER, x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER,
child: gearIcon,
}); });
super._init({ child: button }); super._init({ child: button });

View File

@ -2665,10 +2665,7 @@ var AppFolderDialog = GObject.registerClass({
can_focus: true, can_focus: true,
x_align: Clutter.ActorAlign.END, x_align: Clutter.ActorAlign.END,
y_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER,
child: new St.Icon({
icon_name: 'document-edit-symbolic', icon_name: 'document-edit-symbolic',
icon_size: 16,
}),
}); });
this._editButton.connect('notify::checked', () => { this._editButton.connect('notify::checked', () => {

View File

@ -469,10 +469,10 @@ var Calendar = GObject.registerClass({
this._backButton = new St.Button({ this._backButton = new St.Button({
style_class: 'calendar-change-month-back pager-button', style_class: 'calendar-change-month-back pager-button',
icon_name: 'pan-start-symbolic',
accessible_name: _('Previous month'), accessible_name: _('Previous month'),
can_focus: true, can_focus: true,
}); });
this._backButton.add_actor(new St.Icon({ icon_name: 'pan-start-symbolic' }));
this._topBox.add(this._backButton); this._topBox.add(this._backButton);
this._backButton.connect('clicked', this._onPrevMonthButtonClicked.bind(this)); this._backButton.connect('clicked', this._onPrevMonthButtonClicked.bind(this));
@ -487,10 +487,10 @@ var Calendar = GObject.registerClass({
this._forwardButton = new St.Button({ this._forwardButton = new St.Button({
style_class: 'calendar-change-month-forward pager-button', style_class: 'calendar-change-month-forward pager-button',
icon_name: 'pan-end-symbolic',
accessible_name: _('Next month'), accessible_name: _('Next month'),
can_focus: true, can_focus: true,
}); });
this._forwardButton.add_actor(new St.Icon({ icon_name: 'pan-end-symbolic' }));
this._topBox.add(this._forwardButton); this._topBox.add(this._forwardButton);
this._forwardButton.connect('clicked', this._onNextMonthButtonClicked.bind(this)); this._forwardButton.connect('clicked', this._onNextMonthButtonClicked.bind(this));

View File

@ -59,14 +59,12 @@ var CandidateArea = GObject.registerClass({
style_class: 'candidate-page-button candidate-page-button-previous button', style_class: 'candidate-page-button candidate-page-button-previous button',
x_expand: true, x_expand: true,
}); });
this._previousButton.child = new St.Icon({ style_class: 'candidate-page-button-icon' });
this._buttonBox.add_child(this._previousButton); this._buttonBox.add_child(this._previousButton);
this._nextButton = new St.Button({ this._nextButton = new St.Button({
style_class: 'candidate-page-button candidate-page-button-next button', style_class: 'candidate-page-button candidate-page-button-next button',
x_expand: true, x_expand: true,
}); });
this._nextButton.child = new St.Icon({ style_class: 'candidate-page-button-icon' });
this._buttonBox.add_child(this._nextButton); this._buttonBox.add_child(this._nextButton);
this.add(this._buttonBox); this.add(this._buttonBox);
@ -104,14 +102,14 @@ var CandidateArea = GObject.registerClass({
this.vertical = false; this.vertical = false;
this.remove_style_class_name('vertical'); this.remove_style_class_name('vertical');
this.add_style_class_name('horizontal'); this.add_style_class_name('horizontal');
this._previousButton.child.icon_name = 'go-previous-symbolic'; this._previousButton.icon_name = 'go-previous-symbolic';
this._nextButton.child.icon_name = 'go-next-symbolic'; this._nextButton.icon_name = 'go-next-symbolic';
} else { // VERTICAL || SYSTEM } else { // VERTICAL || SYSTEM
this.vertical = true; this.vertical = true;
this.add_style_class_name('vertical'); this.add_style_class_name('vertical');
this.remove_style_class_name('horizontal'); this.remove_style_class_name('horizontal');
this._previousButton.child.icon_name = 'go-up-symbolic'; this._previousButton.icon_name = 'go-up-symbolic';
this._nextButton.child.icon_name = 'go-down-symbolic'; this._nextButton.icon_name = 'go-down-symbolic';
} }
} }

View File

@ -421,8 +421,10 @@ class ObjInspector extends St.ScrollView {
hbox.add(button); hbox.add(button);
} }
button = new St.Button({ style_class: 'window-close' }); button = new St.Button({
button.add_actor(new St.Icon({ icon_name: 'window-close-symbolic' })); style_class: 'window-close',
icon_name: 'window-close-symbolic',
});
button.connect('clicked', this.close.bind(this)); button.connect('clicked', this.close.bind(this));
hbox.add(button); hbox.add(button);
if (typeof obj == typeof {}) { if (typeof obj == typeof {}) {
@ -884,11 +886,7 @@ var ActorLink = GObject.registerClass({
}); });
const inspectButton = new St.Button({ const inspectButton = new St.Button({
child: new St.Icon({
icon_name: 'insert-object-symbolic', icon_name: 'insert-object-symbolic',
icon_size: 12,
y_align: Clutter.ActorAlign.CENTER,
}),
reactive: true, reactive: true,
x_expand: true, x_expand: true,
x_align: Clutter.ActorAlign.START, x_align: Clutter.ActorAlign.START,
@ -1304,9 +1302,7 @@ class LookingGlass extends St.BoxLayout {
this.add_actor(toolbar); this.add_actor(toolbar);
const inspectButton = new St.Button({ const inspectButton = new St.Button({
style_class: 'lg-toolbar-button', style_class: 'lg-toolbar-button',
child: new St.Icon({
icon_name: 'find-location-symbolic', icon_name: 'find-location-symbolic',
}),
}); });
toolbar.add_actor(inspectButton); toolbar.add_actor(inspectButton);
inspectButton.connect('clicked', () => { inspectButton.connect('clicked', () => {
@ -1324,9 +1320,7 @@ class LookingGlass extends St.BoxLayout {
const gcButton = new St.Button({ const gcButton = new St.Button({
style_class: 'lg-toolbar-button', style_class: 'lg-toolbar-button',
child: new St.Icon({
icon_name: 'user-trash-full-symbolic', icon_name: 'user-trash-full-symbolic',
}),
}); });
toolbar.add_actor(gcButton); toolbar.add_actor(gcButton);
gcButton.connect('clicked', () => { gcButton.connect('clicked', () => {

View File

@ -362,14 +362,11 @@ var Message = GObject.registerClass({
}); });
titleBox.add_actor(this._secondaryBin); titleBox.add_actor(this._secondaryBin);
const closeIcon = new St.Icon({
icon_name: 'window-close-symbolic',
icon_size: 16,
});
this._closeButton = new St.Button({ this._closeButton = new St.Button({
style_class: 'message-close-button', style_class: 'message-close-button',
child: closeIcon, opacity: 0, icon_name: 'window-close-symbolic',
y_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER,
opacity: 0,
}); });
titleBox.add_actor(this._closeButton); titleBox.add_actor(this._closeButton);
@ -438,10 +435,9 @@ var Message = GObject.registerClass({
} }
addMediaControl(iconName, callback) { addMediaControl(iconName, callback) {
let icon = new St.Icon({ icon_name: iconName, icon_size: 16 });
const button = new St.Button({ const button = new St.Button({
style_class: 'message-media-control', style_class: 'message-media-control',
child: icon, iconName,
}); });
button.connect('clicked', callback); button.connect('clicked', callback);
this._mediaControls.add_actor(button); this._mediaControls.add_actor(button);

View File

@ -37,7 +37,7 @@ class MediaMessage extends MessageList.Message {
this._player.previous(); this._player.previous();
}); });
this._playPauseButton = this.addMediaControl(null, this._playPauseButton = this.addMediaControl('',
() => { () => {
this._player.playPause(); this._player.playPause();
}); });

View File

@ -1091,7 +1091,7 @@ var ScreenshotUI = GObject.registerClass({
this._closeButton = new St.Button({ this._closeButton = new St.Button({
style_class: 'screenshot-ui-close-button', style_class: 'screenshot-ui-close-button',
child: new St.Icon({ icon_name: 'preview-close-symbolic' }), icon_name: 'preview-close-symbolic',
}); });
this._closeButton.add_constraint(new Clutter.BindConstraint({ this._closeButton.add_constraint(new Clutter.BindConstraint({
source: this._panel, source: this._panel,
@ -1203,19 +1203,19 @@ var ScreenshotUI = GObject.registerClass({
this._shotButton = new St.Button({ this._shotButton = new St.Button({
style_class: 'screenshot-ui-shot-cast-button', style_class: 'screenshot-ui-shot-cast-button',
icon_name: 'camera-photo-symbolic',
checked: true, checked: true,
}); });
this._shotButton.set_child(new St.Icon({ icon_name: 'camera-photo-symbolic' }));
this._shotButton.connect('notify::checked', this._shotButton.connect('notify::checked',
this._onShotButtonToggled.bind(this)); this._onShotButtonToggled.bind(this));
this._shotCastContainer.add_child(this._shotButton); this._shotCastContainer.add_child(this._shotButton);
this._castButton = new St.Button({ this._castButton = new St.Button({
style_class: 'screenshot-ui-shot-cast-button', style_class: 'screenshot-ui-shot-cast-button',
icon_name: 'camera-web-symbolic',
toggle_mode: true, toggle_mode: true,
visible: Config.HAVE_RECORDER, visible: Config.HAVE_RECORDER,
}); });
this._castButton.set_child(new St.Icon({ icon_name: 'camera-web-symbolic' }));
this._castButton.connect('notify::checked', this._castButton.connect('notify::checked',
this._onCastButtonToggled.bind(this)); this._onCastButtonToggled.bind(this));
this._shotCastContainer.add_child(this._castButton); this._shotCastContainer.add_child(this._castButton);
@ -1254,9 +1254,9 @@ var ScreenshotUI = GObject.registerClass({
this._showPointerButton = new St.Button({ this._showPointerButton = new St.Button({
style_class: 'screenshot-ui-show-pointer-button', style_class: 'screenshot-ui-show-pointer-button',
icon_name: 'screenshot-ui-show-pointer-symbolic',
toggle_mode: true, toggle_mode: true,
}); });
this._showPointerButton.set_child(new St.Icon({ icon_name: 'screenshot-ui-show-pointer-symbolic' }));
this._showPointerButtonContainer.add_child(this._showPointerButton); this._showPointerButtonContainer.add_child(this._showPointerButton);
this.add_child(new Tooltip(this._showPointerButton, { this.add_child(new Tooltip(this._showPointerButton, {

View File

@ -566,7 +566,7 @@ var UnlockDialog = GObject.registerClass({
opacity: 0, opacity: 0,
x_align: Clutter.ActorAlign.END, x_align: Clutter.ActorAlign.END,
y_align: Clutter.ActorAlign.END, y_align: Clutter.ActorAlign.END,
child: new St.Icon({ icon_name: 'system-users-symbolic' }), icon_name: 'system-users-symbolic',
}); });
this._otherUserButton.set_pivot_point(0.5, 0.5); this._otherUserButton.set_pivot_point(0.5, 0.5);
this._otherUserButton.connect('clicked', this._otherUserClicked.bind(this)); this._otherUserButton.connect('clicked', this._otherUserClicked.bind(this));

View File

@ -188,7 +188,7 @@ var WindowPreview = GObject.registerClass({
this._closeButton = new St.Button({ this._closeButton = new St.Button({
visible: false, visible: false,
style_class: 'window-close', style_class: 'window-close',
child: new St.Icon({ icon_name: 'preview-close-symbolic' }), icon_name: 'preview-close-symbolic',
}); });
this._closeButton.add_constraint(new Clutter.BindConstraint({ this._closeButton.add_constraint(new Clutter.BindConstraint({
source: windowContainer, source: windowContainer,