[gnome-shell/gnome-3-36] dateMenu: Do not ellipsize date header



commit 2f136422869c0f87cb2c5b5750f3387c3e75de99
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Sep 24 04:46:47 2020 +0200

    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

 js/ui/dateMenu.js | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index e0cf298471..387ceeef47 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -572,15 +572,20 @@ class FreezableBinLayout extends Clutter.BinLayout {
 
 var CalendarColumnLayout = GObject.registerClass(
 class CalendarColumnLayout extends Clutter.BoxLayout {
-    _init(actor) {
+    _init(actors) {
         super._init({ orientation: Clutter.Orientation.VERTICAL });
-        this._calActor = actor;
+        this._colActors = actors;
     }
 
     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 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]);
     }
 });
 
@@ -631,6 +636,7 @@ class DateMenuButton extends PanelMenu.Button {
             layout.frozen = !_isToday(date);
             this._messageList.setDate(date);
         });
+        this._date = new TodayButton(this._calendar);
 
         this.menu.connect('open-state-changed', (menu, isOpen) => {
             // Whenever the menu is opened, select today
@@ -647,15 +653,13 @@ class DateMenuButton extends PanelMenu.Button {
         hbox.add_child(this._messageList);
 
         // 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',
                                layout_manager: boxLayout });
         boxLayout.hookup_style(vbox);
         hbox.add(vbox);
 
-        this._date = new TodayButton(this._calendar);
         vbox.add_actor(this._date);
-
         vbox.add_actor(this._calendar);
 
         this._displaysSection = new St.ScrollView({ style_class: 'datemenu-displays-section vfade',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]