public final class Gtk extends Glib
public class ComeOnBabyLightMyFire { public static void main(String[] args) { Gtk.init(args); // build user interface Gtk.main(); } }There. Now you know everything you need to know.
:)
In due
course we will write some tutorials to help you along.Modifier and Type | Method and Description |
---|---|
static boolean |
eventsPending()
Are there any internal Events queued up waiting to be processed?
|
static Settings |
getSettings()
Get the Settings object for the default Screen.
|
static void |
init(String[] args)
Initialize the GTK libraries.
|
static boolean |
isInitialized()
Has GTK been initialized yet?
|
static void |
main()
This method blocks, ie, it does not return until the GTK main loop is
terminated.
|
static boolean |
mainIterationDo(boolean block)
Run a single iteration of the GTK main loop.
|
static void |
mainQuit()
Exit the main loop.
|
static Pixbuf |
renderIcon(Widget source,
Stock stock,
IconSize size)
Lookup the Pixbuf corresponding to a stock icon of a certain size.
|
static void |
setDefaultIcon(Pixbuf icon)
Set the icon that will be used for all Windows in this application that
do not have an one explicitly set.
|
static boolean |
showURI(URI uri)
Launch the user's preferred application to handle (display) the the
supplied URI.
|
formatSize, formatSize, getProgramName, getRealName, getSystemConfigDirs, getSystemDataDirs, getUserCacheDir, getUserConfigDir, getUserDataDir, getUserName, getUserSpecialDir, idleAdd, markupEscapeText, reloadUserSpecialDirsCache, setProgramName
public static boolean eventsPending()
Gtk.mainIterationDo()
.public static Settings getSettings()
public static void init(String[] args)
args
- The command line arguments array. This is passed to the
underlying library to allowing user (or window manager) to
alter GTK's behaviour.public static boolean isInitialized()
public static void main()
You can nest calls to Gtk.main()
! If you do, then calling
mainQuit()
will make the innermost invocation of
the main loop return. (This is how modal Dialog boxes run and block the
rest of the application while still accepting events themselves)
public static boolean mainIterationDo(boolean block)
In GUI programming we work extremely hard not to block the main loop since this will cause the user interface to "freeze"; ordinarily we do intensive computations in a worker thread and since java-gnome is thread safe you can simply call your GUI updates from there.
Occasionally, however, there is a circumstance where you are in the midst of a busy computation and need to explicitly let the GUI update itself and to let other idle handlers run. If so you can use the following idiom:
while (Gtk.eventsPending()) { Gtk.mainIterationDo(false); }
This function is not a replacement for using Gtk.main()
to initiate event handling in your program.
Because we have worker threads you really should not need it in normal work. We have exposed it as we found it a workaround for TextView not doing its vertical size allocation until after the current signal handlers have run.
true
if Gtk.mainQuit()
was
called inside the inner-most main loop.public static void mainQuit()
Gtk.main()
at the end of
your Java main()
function, then calling
Gtk.mainQuit()
in a signal handler somewhere will return
the program flow to main()
on your way exiting.public static Pixbuf renderIcon(Widget source, Stock stock, IconSize size)
You need to specify a Widget in order that the most correct theme engine and Style are employed to pick the appropriate image. This is redundant in most programs where we don't interfere with the theming or styling; just pass in your top level Window (or for that matter, any other Widget you have handy).
public static void setDefaultIcon(Pixbuf icon)
setIcon()
for further details about how
to specify icons.public static boolean showURI(URI uri)
Typical examples for URIs understood by GNOME are:
file:///home/george/Desktop/image.png
http://java-gnome.sourceforge.net/
mailto:george@example.com
The launching will take appreciable real time, but this call does not block on the application being launched terminating. Think fork+exec.
This function will return true
if the call succeeds, and
false
otherwise.