3

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

Ricky Kresslein
  • 372
  • 1
  • 13

2 Answers2

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

nielsdg
  • 2,318
  • 1
  • 13
  • 22
  • I've included `use::glib::*` as `use::glib::auto::functions` was private. I then included the line `set_application_name("rkCounter");` just above the `// Load CSS and connect...` comment in my code. Unfortunately the name remains "org.rk.Counter". Am I doing something wrong? – Ricky Kresslein Feb 07 '22 at 11:45
0

https://gtk-rs.org/gtk-rs-core/git/docs/glib/fn.set_prgname.html

gtk4::glib::set_prgname(Some("Your app name"));
KRypt0n_
  • 1
  • 1
  • Hi, thank you for your answer. On stackoverflow, it's nice to not only post code or links, but also add a few words, e.g. what your code does or where in the question's example code it fits into. – Caesar Aug 01 '22 at 07:05