Window


Object Hierarchy:

Gtk.Window Gtk.Window Gtk.Window Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.Window Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.Window Atk.Implementor->Gtk.Bin Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Window Gtk.Buildable->Gtk.Bin Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget

Description:

[ CCode ( type_id = "gtk_window_get_type ()" ) ]
public class Window : Bin, Implementor, Buildable

A GtkWindow is a toplevel window which can contain other widgets.

Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,...).

GtkWindow as GtkBuildable

The GtkWindow implementation of the Buildable interface supports a custom `< accel-groups>` element, which supports any number of `<group>` elements representing the AccelGroup objects you want to add to your window (synonymous with add_accel_group.

It also supports the `<initial-focus>` element, whose name property names the widget to receive the focus when the window is mapped.

An example of a UI definition fragment with accel groups:

<object class="GtkWindow">
<accel-groups>
<group name="accelgroup1"/>
</accel-groups>
<initial-focus name="thunderclap"/>
</object>

...

<object class="GtkAccelGroup" id="accelgroup1"/>

The GtkWindow implementation of the Buildable interface supports setting a child as the titlebar by specifying “titlebar” as the “type” attribute of a `<child>` element.

CSS nodes

window.background
├── decoration
├── <titlebar child>.titlebar [.default-decoration]
╰── <child>
main CSS node with name window and style class .background, and a subnode with name decoration.

Style classes that are typically used with the main CSS node are .csd (when client-side decorations are in use), .solid-csd (for client-side decorations without invisible borders), .ssd (used by mutter when rendering server-side decorations). GtkWindow also represents window states with the following style classes on the main node: .tiled, .maximized, .fullscreen. Specialized types of window often add their own discriminating style classes, such as .popup or .tooltip.

GtkWindow adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.

GtkWindow

Example: Window:

public class Application : Gtk.Window {
public Application () {
// Sets the title of the Window:
this.title = "My Gtk.Window";

// Center window at startup:
this.window_position = Gtk.WindowPosition.CENTER;

// Sets the default size of a window:
this.set_default_size (350, 70);

// Whether the titlebar should be hidden during maximization.
this.hide_titlebar_when_maximized = false;

// Method called on pressing [X]
this.destroy.connect (() => {
// Print "Bye!" to our console:
print ("Bye!\n");

// Terminate the mainloop: (main returns 0)
Gtk.main_quit ();
});

// Widget content:
this.add (new Gtk.Label ("Hello, world!"));
}

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}

valac --pkg gtk+-3.0 Gtk.Window.vala


Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Static methods:

Creation methods:

Methods:

Signals:

Inherited Members:

All known members inherited from class Gtk.Bin
All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor