'Set GTK Application Title

I've created a GTK 4 app using Gtk-rs. In all the tutorials and documentation I read through to create it, I saw that I should make the application_id something unique such as "org.rk.Counter", which is what I have chosen. Unfortunately, that shows up as the application name in the dock. Here is my code:

fn main() {
        // Create a new application
        let app = Application::builder()
            .application_id("org.rk.Counter")
            .build();
        
        // Load CSS and connect to "activate" signal of "app"
        app.connect_startup(|_| load_css());
        app.connect_activate(build_ui);
    
        // Run the application
        app.run();
    }

fn build_ui(app: &Application) {
    // ...

    let window = ApplicationWindow::builder()
        .application(app)
        .title("rkCounter")
        .child(&main_grid)
        .build();

    window.set_default_size(290, 380);

    window.present();
}

The window has the correct title, as set in build_ui(), but here is how it displays on the icon:

App title

How can I change the title for the icon? Should I disregard the advice I saw and change the .application_id()?



Solution 1:[1]

The way you create the application id is correct. It's really just meant as a way of uniquely identifying your application.

What you're looking for here is glib::functions::set_application_name()

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 nielsdg