Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set GTK Application Title

Tags:

rust

gtk

gtk-rs

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()?

like image 444
Ricky Kresslein Avatar asked Mar 13 '26 17:03

Ricky Kresslein


1 Answers

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()

like image 169
nielsdg Avatar answered Mar 16 '26 05:03

nielsdg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!