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

2
  • Does this error persist when you launch the app using a .desktop file? Commented Feb 2, 2022 at 20:51
  • @SylvesterKruin Yes, the screenshot was taken after launching it using a .desktop file. Commented Feb 2, 2022 at 23:00

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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?
0

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

gtk4::glib::set_prgname(Some("Your app name"));

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.