'How do I pack a Gtk::Entry into a Gtk::HeaderBar so the entry completely fills the header bar?

I'm making a program in gtkmm-3.0 which has a Gtk::HeaderBar as the title bar.

I'm trying to pack a Gtk::Entry into it using this code:

Gtk::HeaderBar headerBar;
Gtk::Entry entry;

headerBar.set_hexpand();
headerBar.set_halign((Gtk::Align)GTK_ALIGN_FILL);
entry.set_hexpand();
entry.set_halign((Gtk::Align)GTK_ALIGN_FILL);
headerBar.pack_start(uriEntry);
headerBar.set_show_close_button();

The entry is correctly packed, but it only fills half the space of the header bar, which is very confusing. Using headerBar.add(entry) or headerBar.pack_end(entry) does not help the slightest (The entry still fills half the space it's supposed to take).

Also, using headerBar.pack_start() with a Gtk::Button before the headerBar.pack_start(entry) line will put the button in its place, but the entry will stop the expansion at the same point that it stopped before, being shorter than before.

How can I make the entry fill the whole header bar?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source