stuartlangridge/gnome-shell-clock-override

Not working correctly on a vertical panel

Opened this issue · 3 comments

When using the extension "dash to panel" setting the "Panel screen position" to "left" or "right" to have a vertical panel, the symbols %n to jump a line or %F to draw the ISO date are not working.

All the symbols seem to be ignored, besides a single %S to show the seconds.

I would like to be able to use "%H:%M:%S%n%F" and that they are shown center-aligned on a vertical panel.

After disabling and enabling "Clock override" the correctly formatted string appears for a brief moment. Basically until a new second redraws the clock and only the time is shown.

After investigating the code of both Clock override and Dash to panel, I believe Clock override doesn't take into consideration that the rendering of the panel's clock change when it's vertical.

So I guess the fix would be a new feature for Clock override, to make the override count when the panel is in vertical mode?

The logic of this seems to be done in the file https://github.com/home-sweet-gnome/dash-to-panel/blob/master/panel.js

//code on panel.js:
    _formatVerticalClock: function() {
        let datetime = this.statusArea.dateMenu._clock.clock;
        let datetimeParts = datetime.split(' ');
        let time = datetimeParts[1];
        let clockText = this.statusArea.dateMenu._clockDisplay.clutter_text;
        let setClockText = text => {
            let stacks = text instanceof Array;
            let separator = '\n<span size="xx-small">‧‧</span>\n';
    
            clockText.set_text((stacks ? text.join(separator) : text).trim());
            clockText.set_use_markup(stacks);
            clockText.get_allocation_box();
    
            return !clockText.get_layout().is_ellipsized();
        };

        if (!setClockText(datetime) && 
            !setClockText(datetimeParts) && 
            !setClockText(time)) {
            let timeParts = time.split('∶');

            if (!this._clockFormat) {
                this._clockFormat = Me.desktopSettings.get_string('clock-format');
            }

            if (this._clockFormat == '12h') {
                timeParts.push.apply(timeParts, timeParts.pop().split(' '));
            }

            setClockText(timeParts);
        }
    },
da2x commented

So, you’ve essentially installed two extensions that try to change the clock format. I’m not sure how GNOME handles that situation as it’s not documented. The two extensions aren’t aware of each other. This is an example of a situation that is difficult to resolve when the platform don’t support setting custom date formats.