calender: Use MessageList.MessageView to display messages

Fully drop message list sections, since we don't use them anymore.
The messages and notifications of different sources will be added to the
MessageView in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3012>
This commit is contained in:
Julian Sparber 2025-01-27 15:21:35 +01:00 committed by Marge Bot
parent 996480908d
commit b2829ac066

View File

@ -5,6 +5,7 @@ import GObject from 'gi://GObject';
import Shell from 'gi://Shell'; import Shell from 'gi://Shell';
import St from 'gi://St'; import St from 'gi://St';
import * as MessageList from './messageList.js';
import * as PopupMenu from './popupMenu.js'; import * as PopupMenu from './popupMenu.js';
import {ensureActorVisibleInScrollView} from '../misc/animationUtils.js'; import {ensureActorVisibleInScrollView} from '../misc/animationUtils.js';
@ -797,8 +798,8 @@ class DoNotDisturbSwitch extends PopupMenu.Switch {
export const CalendarMessageList = GObject.registerClass( export const CalendarMessageList = GObject.registerClass(
class CalendarMessageList extends St.Widget { class CalendarMessageList extends St.Widget {
_init() { constructor() {
super._init({ super({
style_class: 'message-list', style_class: 'message-list',
layout_manager: new Clutter.BinLayout(), layout_manager: new Clutter.BinLayout(),
x_expand: true, x_expand: true,
@ -815,10 +816,13 @@ class CalendarMessageList extends St.Widget {
}); });
this.add_child(box); this.add_child(box);
this._messageView = new MessageList.MessageView();
this._scrollView = new St.ScrollView({ this._scrollView = new St.ScrollView({
style_class: 'vfade', style_class: 'vfade',
overlay_scrollbars: true, overlay_scrollbars: true,
x_expand: true, y_expand: true, x_expand: true, y_expand: true,
child: this._messageView,
}); });
box.add_child(this._scrollView); box.add_child(this._scrollView);
@ -854,7 +858,7 @@ class CalendarMessageList extends St.Widget {
accessible_name: C_('action', 'Clear all notifications'), accessible_name: C_('action', 'Clear all notifications'),
}); });
this._clearButton.connect('clicked', () => { this._clearButton.connect('clicked', () => {
this._sectionList.get_children().forEach(s => s.clear()); this._messageView.clear();
}); });
hbox.add_child(this._clearButton); hbox.add_child(this._clearButton);
@ -862,38 +866,16 @@ class CalendarMessageList extends St.Widget {
this._clearButton, 'visible', this._clearButton, 'visible',
GObject.BindingFlags.INVERT_BOOLEAN); GObject.BindingFlags.INVERT_BOOLEAN);
this._sectionList = new St.BoxLayout({ this._messageView.connectObject(
style_class: 'message-list-sections',
orientation: Clutter.Orientation.VERTICAL,
x_expand: true,
y_expand: true,
});
this._sectionList.connectObject(
'child-added', this._sync.bind(this),
'child-removed', this._sync.bind(this),
this);
this._scrollView.child = this._sectionList;
}
_addSection(section) {
section.connectObject(
'notify::visible', this._sync.bind(this),
'notify::empty', this._sync.bind(this),
'notify::can-clear', this._sync.bind(this),
'destroy', () => this._sectionList.remove_child(section),
'message-focused', (_s, messageActor) => { 'message-focused', (_s, messageActor) => {
ensureActorVisibleInScrollView(this._scrollView, messageActor); ensureActorVisibleInScrollView(this._scrollView, messageActor);
}, this); }, this);
this._sectionList.add_child(section);
}
_sync() { this._messageView.bind_property('empty',
let sections = this._sectionList.get_children(); this._placeholder, 'visible',
GObject.BindingFlags.SYNC_CREATE);
let empty = sections.every(s => s.empty || !s.visible); this._messageView.bind_property('can-clear',
this._placeholder.visible = empty; this._clearButton, 'reactive',
GObject.BindingFlags.SYNC_CREATE);
let canClear = sections.some(s => s.canClear && s.visible);
this._clearButton.reactive = canClear;
} }
}); });