Re: How to detect a gtk desktop programmatically
Tres Finocchiaro via desktop-devel-list <[email protected]>
| Newsgroups | gmane.comp.gnome.desktop |
|---|---|
| Message-ID | <CANQs7dBQ1o1p_Gff2X2yiGm8pijUovLqBSVDOz5F7-U-=UZMvw@mail.gmail.com> |
Just to confirm, OpenJDK is currently leveraging "gtk-theme-name" as you've indicated: https://github.com/AdoptOpenJDK/openjdk-jdk/blob/858ec1c5fad02242b7452099f3d5789e55a79057/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c#L725 I believe question is less about which theme and more about how to know the desktop is running to begin with. Any insight is greatly appreciated. - [email protected] On Wed, Apr 29, 2020 at 3:03 PM Tres Finocchiaro <[email protected]> wrote: > Matthias, > > Thanks for the detailed response. Please accept my lack of knowledge on > the subject as I'm neither an OpenJDK developer nor a C developer, (I > develop using Java, so information is to benefit the bug report against > OpenJDK). That said... > > It appears the environment variable is a preflight which is leveraged to > avoid loading the libraries unintentionally. > > I think what OpenJDK is trying to avoid is blindly loading a library > that's on the system without knowing if it's actually in-use. This > variable -- albeit deprecated -- was a reliable way to know that. > > Here it checks to see if Gnome is running: > > https://github.com/AdoptOpenJDK/openjdk-jdk/blob/634c676e6c145c936b460debaa95d0b6cfa61ae2/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java#L100 > > Here, it configures the look and feel: > > https://github.com/AdoptOpenJDK/openjdk-jdk/blob/634c676e6c145c936b460debaa95d0b6cfa61ae2/src/java.desktop/share/classes/javax/swing/UIManager.java#L665 > > And deeper into the native calls, it interacts with Gtk libraries: > > https://github.com/AdoptOpenJDK/openjdk-jdk/blob/634c676e6c145c936b460debaa95d0b6cfa61ae2/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c#L53 > > So although I can't answer the specific theming questions, I can confirm > the theme seems to apply correctly on systems which utilize it. It's less > of a matter of how to detect the theme and more of a matter of how to > detect that the desktop environment offers a Gtk theme to begin with. > > Albeit deprecated and clunky, GNOME_DESKTOP_SESSION_ID seemed to have been > the way Java's known this historically and removal of it requires a > replacement of which I'm hoping to gain knowledge of. > > - [email protected] > > > On Wed, Apr 29, 2020 at 1:37 PM Matthias Clasen <[email protected]> > wrote: > >> >> Hey Tres, >> >> in my opinion, environment variables are about the worst possible option >> for this sort of thing. >> >> If you are linking against GTK, the easiest way is to just ask GTK itself >> if you need to know >> the theme name: >> >> g_object_get (gtk_settings_get_defautt (), "gtk-theme-name", &theme, >> NULL); >> >> But I am not sure that the theme name is really needed. What information >> are you looking for >> exactly ? And what decision are you going to make based on it ? >> >> _______________________________________________ desktop-devel-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/desktop-devel-list