js: Cleanup usage of StScrollView
Whilst you *can* use add_actor() with ScrollView, it's more idiomatic to work on :child Cleanup a few extras along the way Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3010>
This commit is contained in:
parent
c72742486f
commit
49cca32ca5
@ -84,20 +84,19 @@ export const AuthList = GObject.registerClass({
|
||||
this.label = new St.Label({style_class: 'login-dialog-auth-list-title'});
|
||||
this.add_child(this.label);
|
||||
|
||||
this._scrollView = new St.ScrollView({
|
||||
style_class: 'login-dialog-auth-list-view',
|
||||
});
|
||||
this._scrollView.set_policy(
|
||||
St.PolicyType.NEVER, St.PolicyType.AUTOMATIC);
|
||||
this.add_child(this._scrollView);
|
||||
|
||||
this._box = new St.BoxLayout({
|
||||
vertical: true,
|
||||
style_class: 'login-dialog-auth-list',
|
||||
pseudo_class: 'expanded',
|
||||
});
|
||||
|
||||
this._scrollView.add_child(this._box);
|
||||
this._scrollView = new St.ScrollView({
|
||||
style_class: 'login-dialog-auth-list-view',
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this._box,
|
||||
});
|
||||
this.add_child(this._scrollView);
|
||||
|
||||
this._items = new Map();
|
||||
|
||||
this.connect('key-focus-in', this._moveFocusToItems.bind(this));
|
||||
@ -129,7 +128,7 @@ export const AuthList = GObject.registerClass({
|
||||
scrollToItem(item) {
|
||||
let box = item.get_allocation_box();
|
||||
|
||||
let adjustment = this._scrollView.get_vscroll_bar().get_adjustment();
|
||||
const {adjustment} = this._scrollView.vscroll;
|
||||
|
||||
let value = (box.y1 + adjustment.step_increment / 2.0) - (adjustment.page_size / 2.0);
|
||||
adjustment.ease(value, {
|
||||
|
@ -168,10 +168,8 @@ const UserList = GObject.registerClass({
|
||||
style_class: 'login-dialog-user-list-view',
|
||||
x_expand: true,
|
||||
y_expand: true,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
});
|
||||
this.set_policy(
|
||||
St.PolicyType.NEVER,
|
||||
St.PolicyType.AUTOMATIC);
|
||||
|
||||
this._box = new St.BoxLayout({
|
||||
vertical: true,
|
||||
@ -179,7 +177,7 @@ const UserList = GObject.registerClass({
|
||||
pseudo_class: 'expanded',
|
||||
});
|
||||
|
||||
this.add_child(this._box);
|
||||
this.child = this._box;
|
||||
this._items = {};
|
||||
}
|
||||
|
||||
@ -226,7 +224,7 @@ const UserList = GObject.registerClass({
|
||||
scrollToItem(item) {
|
||||
let box = item.get_allocation_box();
|
||||
|
||||
let adjustment = this.get_vscroll_bar().get_adjustment();
|
||||
const {adjustment} = this.vscroll;
|
||||
|
||||
let value = (box.y1 + adjustment.step_increment / 2.0) - (adjustment.page_size / 2.0);
|
||||
adjustment.ease(value, {
|
||||
@ -238,7 +236,7 @@ const UserList = GObject.registerClass({
|
||||
jumpToItem(item) {
|
||||
let box = item.get_allocation_box();
|
||||
|
||||
let adjustment = this.get_vscroll_bar().get_adjustment();
|
||||
const {adjustment} = this.vscroll;
|
||||
|
||||
let value = (box.y1 + adjustment.step_increment / 2.0) - (adjustment.page_size / 2.0);
|
||||
|
||||
@ -487,17 +485,16 @@ export const LoginDialog = GObject.registerClass({
|
||||
|
||||
this._userSelectionBox.add_child(this._notListedButton);
|
||||
|
||||
const bannerBox = new St.BoxLayout({vertical: true});
|
||||
|
||||
this._bannerView = new St.ScrollView({
|
||||
style_class: 'login-dialog-banner-view',
|
||||
opacity: 0,
|
||||
vscrollbar_policy: St.PolicyType.AUTOMATIC,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: bannerBox,
|
||||
});
|
||||
this.add_child(this._bannerView);
|
||||
|
||||
let bannerBox = new St.BoxLayout({vertical: true});
|
||||
|
||||
this._bannerView.add_child(bannerBox);
|
||||
this._bannerLabel = new St.Label({
|
||||
style_class: 'login-dialog-banner',
|
||||
text: '',
|
||||
|
@ -520,15 +520,15 @@ var BaseAppView = GObject.registerClass({
|
||||
y_expand: true,
|
||||
reactive: true,
|
||||
enable_mouse_scrolling: false,
|
||||
hscrollbar_policy: St.PolicyType.EXTERNAL,
|
||||
vscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this._grid,
|
||||
});
|
||||
this._scrollView.set_policy(St.PolicyType.EXTERNAL, St.PolicyType.NEVER);
|
||||
|
||||
this._canScroll = true; // limiting scrolling speed
|
||||
this._scrollTimeoutId = 0;
|
||||
this._scrollView.connect('scroll-event', this._onScroll.bind(this));
|
||||
|
||||
this._scrollView.add_child(this._grid);
|
||||
|
||||
const scroll = this._scrollView.hscroll;
|
||||
this._adjustment = scroll.adjustment;
|
||||
this._adjustment.connect('notify::value', adj => {
|
||||
|
@ -954,8 +954,8 @@ class CalendarMessageList extends St.Widget {
|
||||
style_class: 'vfade',
|
||||
overlay_scrollbars: true,
|
||||
x_expand: true, y_expand: true,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
});
|
||||
this._scrollView.set_policy(St.PolicyType.NEVER, St.PolicyType.AUTOMATIC);
|
||||
box.add_child(this._scrollView);
|
||||
|
||||
let hbox = new St.BoxLayout({style_class: 'message-list-controls'});
|
||||
@ -1008,7 +1008,7 @@ class CalendarMessageList extends St.Widget {
|
||||
'actor-added', this._sync.bind(this),
|
||||
'actor-removed', this._sync.bind(this),
|
||||
this);
|
||||
this._scrollView.add_child(this._sectionList);
|
||||
this._scrollView.child = this._sectionList;
|
||||
|
||||
this._mediaSection = new Mpris.MediaSection();
|
||||
this._addSection(this._mediaSection);
|
||||
|
@ -870,17 +870,17 @@ class ChatNotificationBanner extends MessageTray.NotificationBanner {
|
||||
this.emit('unfocused');
|
||||
});
|
||||
|
||||
this._contentArea = new St.BoxLayout({
|
||||
style_class: 'chat-body',
|
||||
vertical: true,
|
||||
});
|
||||
this._scrollArea = new St.ScrollView({
|
||||
style_class: 'chat-scrollview vfade',
|
||||
vscrollbar_policy: St.PolicyType.AUTOMATIC,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
visible: this.expanded,
|
||||
child: this._contentArea,
|
||||
});
|
||||
this._contentArea = new St.BoxLayout({
|
||||
style_class: 'chat-body',
|
||||
vertical: true,
|
||||
});
|
||||
this._scrollArea.add_child(this._contentArea);
|
||||
|
||||
this.setExpandedBody(this._scrollArea);
|
||||
this.setExpandedLines(CHAT_EXPAND_LINES);
|
||||
|
@ -919,20 +919,21 @@ class DateMenuButton extends PanelMenu.Button {
|
||||
vbox.add_child(this._date);
|
||||
vbox.add_child(this._calendar);
|
||||
|
||||
this._displaysSection = new St.ScrollView({
|
||||
style_class: 'datemenu-displays-section vfade',
|
||||
x_expand: true,
|
||||
overlay_scrollbars: true,
|
||||
});
|
||||
this._displaysSection.set_policy(St.PolicyType.NEVER, St.PolicyType.EXTERNAL);
|
||||
vbox.add_child(this._displaysSection);
|
||||
|
||||
const displaysBox = new St.BoxLayout({
|
||||
vertical: true,
|
||||
x_expand: true,
|
||||
style_class: 'datemenu-displays-box',
|
||||
});
|
||||
this._displaysSection.add_child(displaysBox);
|
||||
|
||||
this._displaysSection = new St.ScrollView({
|
||||
style_class: 'datemenu-displays-section vfade',
|
||||
x_expand: true,
|
||||
overlay_scrollbars: true,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
vscrollbar_policy: St.PolicyType.EXTERNAL,
|
||||
child: displaysBox,
|
||||
});
|
||||
vbox.add_child(this._displaysSection);
|
||||
|
||||
this._eventsItem = new EventsSection();
|
||||
displaysBox.add_child(this._eventsItem);
|
||||
|
@ -259,16 +259,16 @@ export const ListSection = GObject.registerClass({
|
||||
_init(params) {
|
||||
this._title = new St.Label({style_class: 'dialog-list-title'});
|
||||
|
||||
this._listScrollView = new St.ScrollView({
|
||||
style_class: 'dialog-list-scrollview',
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
});
|
||||
|
||||
this.list = new St.BoxLayout({
|
||||
style_class: 'dialog-list-box',
|
||||
vertical: true,
|
||||
});
|
||||
this._listScrollView.add_child(this.list);
|
||||
|
||||
this._listScrollView = new St.ScrollView({
|
||||
style_class: 'dialog-list-scrollview',
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this.list,
|
||||
});
|
||||
|
||||
let defaultParams = {
|
||||
style_class: 'dialog-list',
|
||||
|
@ -162,9 +162,8 @@ const Notebook = GObject.registerClass({
|
||||
labelBox.add_child(label);
|
||||
this.tabControls.add_child(labelBox);
|
||||
|
||||
let scrollview = new St.ScrollView({y_expand: true});
|
||||
scrollview.get_hscroll_bar().hide();
|
||||
scrollview.add_child(child);
|
||||
const scrollview = new St.ScrollView({y_expand: true, child});
|
||||
scrollview.hscroll.hide();
|
||||
|
||||
const tabData = {
|
||||
child,
|
||||
@ -395,7 +394,7 @@ class ObjInspector extends St.ScrollView {
|
||||
|
||||
this._parentList = [];
|
||||
|
||||
this.get_hscroll_bar().hide();
|
||||
this.hscroll.hide();
|
||||
this._container = new St.BoxLayout({
|
||||
name: 'LookingGlassPropertyInspector',
|
||||
style_class: 'lg-dialog',
|
||||
@ -403,7 +402,7 @@ class ObjInspector extends St.ScrollView {
|
||||
x_expand: true,
|
||||
y_expand: true,
|
||||
});
|
||||
this.add_child(this._container);
|
||||
this.child = this._container;
|
||||
|
||||
this._lookingGlass = lookingGlass;
|
||||
}
|
||||
|
@ -1016,9 +1016,9 @@ export class PopupSubMenu extends PopupMenuBase {
|
||||
style_class: 'popup-sub-menu',
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
vscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this.box,
|
||||
});
|
||||
|
||||
this.actor.add_child(this.box);
|
||||
this.actor._delegate = this;
|
||||
this.actor.clip_to_allocation = true;
|
||||
this.actor.connect('key-press-event', this._onKeyPressEvent.bind(this));
|
||||
|
@ -573,9 +573,9 @@ export const SearchResultsView = GObject.registerClass({
|
||||
style_class: 'search-display vfade',
|
||||
x_expand: true,
|
||||
y_expand: true,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this._content,
|
||||
});
|
||||
this._scrollView.set_policy(St.PolicyType.NEVER, St.PolicyType.AUTOMATIC);
|
||||
this._scrollView.add_child(this._content);
|
||||
|
||||
let action = new Clutter.PanAction({interpolate: true});
|
||||
action.connect('pan', this._onPan.bind(this));
|
||||
|
@ -409,10 +409,11 @@ export const SwitcherList = GObject.registerClass({
|
||||
this._scrollView = new St.ScrollView({
|
||||
style_class: 'hfade',
|
||||
enable_mouse_scrolling: false,
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
vscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this._list,
|
||||
});
|
||||
this._scrollView.set_policy(St.PolicyType.NEVER, St.PolicyType.NEVER);
|
||||
|
||||
this._scrollView.add_child(this._list);
|
||||
this.add_child(this._scrollView);
|
||||
|
||||
// Those arrows indicate whether scrolling in one direction is possible
|
||||
|
@ -43,13 +43,15 @@ const NotificationsBox = GObject.registerClass({
|
||||
name: 'unlockDialogNotifications',
|
||||
});
|
||||
|
||||
this._scrollView = new St.ScrollView({hscrollbar_policy: St.PolicyType.NEVER});
|
||||
this._notificationBox = new St.BoxLayout({
|
||||
vertical: true,
|
||||
style_class: 'unlock-dialog-notifications-container',
|
||||
});
|
||||
this._scrollView.add_child(this._notificationBox);
|
||||
|
||||
this._scrollView = new St.ScrollView({
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
child: this._notificationBox,
|
||||
});
|
||||
this.add_child(this._scrollView);
|
||||
|
||||
this._settings = new Gio.Settings({
|
||||
|
Loading…
x
Reference in New Issue
Block a user