Re: Finding Version of GTK installed

On Tue, 2006-12-05 at 12:06 -0500, David Vandepol wrote:
Thanks,  you're right, I am looking for a "run-time" type of detection to
see if the GUI for the installer will even show up.
The installer that I'm creating is Java based, and I'm trying not to mix
too many languages unneccessarily, is there any known way to fine the
versions in Java?  I've looked at API's but havn't been able to find
anything other than

Without using a native call into the GTK libraries, you cannot find out
such information from Java.  JAF itself doesn't use GTK either, but only
uses the gtk engine shared libraries if available.  And even then it can
only use certain engines (like bluecurve or pixmap-based ones).

GTKLookAndFeel.isSupportedLookAndFeel()  but that doesn't give enough
information to determine if the version is actually what my product
supports or not.  Worst case senario I have to execute some C code during
the installation.

If your app is in Swing, why are you worried about this in the first
place?  Java Swing doesn't really use GTK directly anyway, and certain
it never worked with my default theme.  If the user has a version of GTK
or a theme that Java's JAF doesn't like it won't work anyway, so how
would you deal with this situation?


David VandePol

On Tue, Dec 05, 2006 at 09:42:02AM -0500, David Vandepol wrote:
      I'm still having problems.  When I run java tool and view all of
LaF's GTK is displayed, however gtk isn't available in the pkg-config

Does the LaF actually use Gtk+ or just emulates the look?
And if it uses Gtk+, does it use the common library or some
private copy?

AFAIK Java 1.5 Gtk+ LaF is Synth-based.

Just to be clear, GTK is installed
with Red Hat OS correct?

In a typical installation, yes.  But it is not mandatory.

I installed all the packages when installing the
OS and I assumed that it would be installed.

If you installed everything you should have Gtk+.

And java picks it up.

Or maybe not.

there are other gtk packs in the pkgconfig folder, such as
.  Do you or anyone know why the required info is not in pkgconfig?

First of all, pkg-config is intended for *compile time*
detection, and .pc files are in the develoment package, not
in run-time, you can't detect Gtk+ run-time with pkg-config
(of course if you installed everything, you should have the
development package too, but maybe you did not install
really everything).

So if you want to detect the run-time, forget pkg-config
and run something like this:

#include <dlfcn.h>
#include <stdio.h>
    void *gtk;
    int *maj, *min, *mic;
    int status = 1;

    gtk = dlopen("", RTLD_LAZY);
    if (!gtk)
        return 1;
    maj = dlsym(gtk, "gtk_major_version");
    min = dlsym(gtk, "gtk_minor_version");
    mic = dlsym(gtk, "gtk_micro_version");
    if (maj && min && mic) {
        printf("%d.%d.%d\n", *maj, *min, *mic);
        status = 0;
    return status;

(needs dlopen(), i.e. Linux, BSD, or something like that)

or just do

           gtk_major_version(), gtk_minor_version(), gtk_micro_version());

but such a program has to be linked with the lowest
acceptable version of Gtk+ to make sense, then it can be run
on systems with higher Gtk+.

Or depending on what you do, you can ask the package
management system...

Generally, the answer to the run-time environment question
`if I run something using Foo, what version of Foo it will
get dynamically linked with' is to actually do it and check
the outcome.


gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]