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