In a GNOME extension settings window, how do I stretch a text field to take the whole row?

I am working on this extension and for the settings window, I would like the text field where users type their message to take the whole row. Right now, it takes half of it because of the space for a label.

Also, how would I do it in both gtk4 and gtk3?

Thanks for any help!

'use strict';

//Import required libraries
const { Gio, GObject, Gtk } =;
const ExtensionUtils = imports.misc.extensionUtils;//Access to settings from schema

function init() {}


//Dectect Gnome Version Number
const Config = imports.misc.config;
const [major, minor] = Config.PACKAGE_VERSION.split('.').map(s => Number(s));

function fillPreferencesWindow(window) {
    if (major >= 42) {//Check for Gnome 42 or above
        const Adw =;

        //Create a preferences page and group
        const page = new Adw.PreferencesPage();
        const group = new Adw.PreferencesGroup({ title: 'Write your message' });

        let settings = ExtensionUtils.getSettings();

        //Add the row for the text entry
        const messageRow = new Adw.ActionRow();
        let messageText = new Gtk.EntryBuffer({ text: settings.get_string('message') })
        let messageEntry = new  Gtk.Entry({
          buffer: messageText,
          hexpand: true,
          halign: Gtk.Align.CENTER,
        messageRow.activatable_widget = messageEntry;

Don’t use an action row, which only expects custom widgets as pre- or suffix to the title label.

You can use the more generic PreferencesRow instead, or consider an alternative UI if the default list pattern doesn’t suit your needs.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.