gnome-shell-extensionsgjs

Can I set_markup to a PopupMenuItem?


Since a Label in a PopupMenuItem, I thinks it can be set a pango text here.

PopupMenuItem: A PopupBaseMenuItem that displays text in a St.Label.

const item = new PopupMenu.PopupMenuItem("");
item.actor.set_size(300,150);   <--- effect.
item.actor.create_pango_layout('<span foreground="blue" size="32">fname</span>');  <- not effect
item.actor.set_markup('<span foreground="blue" size="32">fname</span>'); <-- fail, but it worked in vala.

I read popupMenu.js source code before, but now I forgot the url.


Solution

  • You probably want to set this on the internal Clutter.Text of the PopupMenu.PopupMenuItems's St.Label:

    const item = new PopupMenu.PopupMenuItem('');
    
    item.label.clutter_text.set_markup(
      '<span foreground="blue" size="32">fname</span>');
    

    You can bookmark this link to the whole directory of GNOME Shell's UI:

    https://gitlab.gnome.org/GNOME/gnome-shell/tree/main/js/ui