Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hamster: explicitly set application ID and prgname on startup #556

Merged
merged 2 commits into from
Feb 13, 2020

Conversation

mwilck
Copy link
Contributor

@mwilck mwilck commented Feb 12, 2020

Under wayland, passing application_id to Gtk.Application.Init()
is not sufficient to set the application ID and program name
so that the shell sees it. See e.g.

https://www.programcreek.com/python/example/87806/gi.repository.GLib.set_prgname
https://gitlab.gnome.org/GNOME/gtk/issues/653
https://gitlab.gnome.org/GNOME/gtk/commit/72ec8963d7df0e39f688838e42445c869e4875c9

This should fix #541.

@@ -141,6 +144,8 @@ def on_activate_quit(self, data=None):

def on_startup(self, data=None):
logger.debug("startup")
glib.set_application_name(self.__app_id__)
glib.set_prgname(self.__app_id__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are both of those necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not to fix the icon name. But I think this way we're on the safe side.

@ederag
Copy link
Collaborator

ederag commented Feb 12, 2020

Interesting, and thanks for the links ! Need to test and read.

@ederag
Copy link
Collaborator

ederag commented Feb 13, 2020

That yields both under wayland and gnome the left image.
Screenshot_20200213_070607 Screenshot_20200213_092815

which is exactly what hamster --name=org.gnome.Hamster.GUI gave;
and that I found ugly at first (too much information for a casual user).
Right image is the result of c3ae7b1

Your link to commit eventually lead me to
https://developer.gnome.org/gtk4/stable/gtk-migrating-3-to-4.html#id-1.6.4.3.13

In GTK 4 we want the application's GApplication 'application-id' (and therefore the D-Bus name),
the desktop file basename and Wayland's xdg-shell app_id to match.
In order to achieve this with GTK 3.x call g_set_prgname()
with the same application ID you passed to GtkApplication.
Rename your desktop files to match the application ID if needed.

The call to g_set_prgname() can be removed once you fully migrated to GTK 4.

So the set_application_name is redundant with app_id=, let's remove it,
and just keep set_prgname.

Let's just use the application_id property,
that clarifies the changes to be made then (a single line).

@mwilck
Copy link
Contributor Author

mwilck commented Feb 13, 2020

Wow, thanks for sorting this out. Not really obvious for the casual programmer, is it?

@mwilck
Copy link
Contributor Author

mwilck commented Feb 13, 2020

Fine with me, please merge at your discretion.

@ederag
Copy link
Collaborator

ederag commented Feb 13, 2020

@mwilck, @bochecha Thanks for the confirmations (I take the thumb up as one).
And indeed, it's not obvious; nice team work !

@ederag ederag merged commit c78079f into projecthamster:master Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon missing / App tracking broken in Gnome/Wayland
3 participants