Align Label text in Button and Tooltip text of Cinnamon Desklet to left

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
kanchudeep

Align Label text in Button and Tooltip text of Cinnamon Desklet to left

Post by kanchudeep »

I have a Cinnamon Desklet which consists of a Button. The Button has a Label (with some text) and also a Tooltip:

Code: Select all

const Desklet = imports.ui.desklet;
const St = imports.gi.St;
const Tooltips = imports.ui.tooltips;

function MyDesklet(metadata, desklet_id) {
    this._init(metadata, desklet_id);
}

MyDesklet.prototype = {
    __proto__: Desklet.Desklet.prototype,

    _init: function(metadata, desklet_id) {
        Desklet.Desklet.prototype._init.call(this, metadata, desklet_id);

        this.setupUI();
    },

    setupUI: function() {
        // main container for the desklet
        this.boxLayout = new St.BoxLayout({
            vertical: true,
            width: 100,
            height: 40
        });

        let label = new St.Label({text: "Label text"});
        // style does not work
        let button = new St.Button({child: label, style: "text-align: left;"});
        let tooltip = new Tooltips.Tooltip(button,
                _("Tooltip\ntext"));
        // Does not work
        tooltip.style = "text-align: left;";

        this.boxLayout.add_actor(button);
        this.setContent(this.boxLayout);
    }
}

function main(metadata, desklet_id) {
    return new MyDesklet(metadata, desklet_id);
}
The above code results in this Desklet:
desklet.png
How can the Label text inside the Button and the Tooltip text be aligned to left instead of centre?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Compiz, Conky, Docks & Widgets”