dateMenu: Do not ellipsize date header

Currently the width of the calendar column is solely determined
by the calendar, while other elements are ellipsized as necessary.

While that is the desired behavior for the events-, world clocks-
and weather sections, we don't want to cut off the date in the
header. However switching to bold text made that more likely in
non-English locales or when using large text, so explicitly take
it into account for the width negotiation.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2230
This commit is contained in:
Florian Müllner 2020-09-24 04:46:47 +02:00
parent 3fb321fd21
commit 494e628c38

View File

@ -762,15 +762,20 @@ class FreezableBinLayout extends Clutter.BinLayout {
var CalendarColumnLayout = GObject.registerClass( var CalendarColumnLayout = GObject.registerClass(
class CalendarColumnLayout extends Clutter.BoxLayout { class CalendarColumnLayout extends Clutter.BoxLayout {
_init(actor) { _init(actors) {
super._init({ orientation: Clutter.Orientation.VERTICAL }); super._init({ orientation: Clutter.Orientation.VERTICAL });
this._calActor = actor; this._colActors = actors;
} }
vfunc_get_preferred_width(container, forHeight) { vfunc_get_preferred_width(container, forHeight) {
if (!this._calActor || this._calActor.get_parent() != container) const actors =
this._colActors.filter(a => a.get_parent() === container);
if (actors.length === 0)
return super.vfunc_get_preferred_width(container, forHeight); return super.vfunc_get_preferred_width(container, forHeight);
return this._calActor.get_preferred_width(forHeight); return actors.reduce(([minAcc, natAcc], child) => {
const [min, nat] = child.get_preferred_width(forHeight);
return [Math.max(minAcc, min), Math.max(natAcc, nat)];
}, [0, 0]);
} }
}); });
@ -821,6 +826,7 @@ class DateMenuButton extends PanelMenu.Button {
layout.frozen = !_isToday(date); layout.frozen = !_isToday(date);
this._eventsItem.setDate(date); this._eventsItem.setDate(date);
}); });
this._date = new TodayButton(this._calendar);
this.menu.connect('open-state-changed', (menu, isOpen) => { this.menu.connect('open-state-changed', (menu, isOpen) => {
// Whenever the menu is opened, select today // Whenever the menu is opened, select today
@ -837,15 +843,13 @@ class DateMenuButton extends PanelMenu.Button {
hbox.add_child(this._messageList); hbox.add_child(this._messageList);
// Fill up the second column // Fill up the second column
let boxLayout = new CalendarColumnLayout(this._calendar); const boxLayout = new CalendarColumnLayout([this._calendar, this._date]);
vbox = new St.Widget({ style_class: 'datemenu-calendar-column', vbox = new St.Widget({ style_class: 'datemenu-calendar-column',
layout_manager: boxLayout }); layout_manager: boxLayout });
boxLayout.hookup_style(vbox); boxLayout.hookup_style(vbox);
hbox.add(vbox); hbox.add(vbox);
this._date = new TodayButton(this._calendar);
vbox.add_actor(this._date); vbox.add_actor(this._date);
vbox.add_actor(this._calendar); vbox.add_actor(this._calendar);
this._displaysSection = new St.ScrollView({ style_class: 'datemenu-displays-section vfade', this._displaysSection = new St.ScrollView({ style_class: 'datemenu-displays-section vfade',