java-gnome version 4.0.15

org.gnome.gtk
Class Gtk

Object
  extended by org.gnome.glib.Glib
      extended by org.gnome.gtk.Gtk

public final class Gtk
extends Glib

The GTK widget toolkit initialization and main loop entry point. A typical program written with java-gnome will boil down to this:

 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.

Since:
4.0.0
Author:
Andrew Cowie

Method Summary
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 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.
 
Methods inherited from class org.gnome.glib.Glib
getRealName, getSystemConfigDirs, getSystemDataDirs, getUserCacheDir, getUserConfigDir, getUserDataDir, getUserName, getUserSpecialDir, reloadUserSpecialDirsCache, setProgramName
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSettings

public static Settings getSettings()
Get the Settings object for the default Screen.

Since:
4.0.14

init

public static void init(String[] args)
Initialize the GTK libraries. This must be called before any other org.gnome.* classes are used.

Parameters:
args - The command line arguments array. This is passed to the underlying library to allowing user (or window manager) to alter GTK's behaviour.
Since:
4.0.0

isInitialized

public static boolean isInitialized()
Has GTK been initialized yet?

Since:
4.0.15

main

public static void main()
This method blocks, ie, it does not return until the GTK main loop is terminated.

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)

Since:
4.0.0

mainQuit

public static void mainQuit()
Exit the main loop. Since main loops can be nested, this does not necessarily imply application termination, but if you have a typical GTK program with a single call to 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.

Since:
4.0.0

renderIcon

public static Pixbuf renderIcon(Widget source,
                                Stock stock,
                                IconSize size)
Lookup the Pixbuf corresponding to a stock icon of a certain 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).

Since:
4.0.9

setDefaultIcon

public 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. See the documentation for Window's setIcon() for further details about how to specify icons.

Since:
4.0.5

showURI

public static boolean showURI(URI uri)
Launch the user's preferred application to handle (display) the the supplied URI. This is most commonly used for raising URLs in the user's web browser, but the capability is more general than that; any URI conveying a MIME type that the desktop knows how to interpret will be handled.

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.

Since:
4.0.9


java-gnome