Can't get gtk::HeaderBar to show close (x) button

Hello everyone,

I’m currently learning how to use gtk-rs. I’m playing around with the gtk::HeaderBar, but I am having trouble getting the close (x) button to appear. This is how it currently looks:


I read online that the set_decoration_layout allows to have the close button show. I added header_bar.set_decoration_layout(Some("menu:minimize,close")); but that didn’t seem help.

I am not sure what I am doing doing wrong here… I provided the code below for you to see.

extern crate gtk;
extern crate gio;

use gtk::prelude::*;
use gio::prelude::*;

use gtk::{Application, ApplicationWindow, HeaderBar};

fn main() {
    let application = Application::new(
    ).expect("failed to initalize GTK application");

    application.connect_activate(|app| {
        let window = ApplicationWindow::new(app);
        window.set_default_size(350, 70);

        let header_bar = HeaderBar::new();
        header_bar.set_title(Some("My HeaderBar"));


I think for GTK4 the close button is there by default, see

I figured it out. There is a method called set_show_close_button. If you set it to true, the buttons will show.


1 Like

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