Class Window

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, Proxy
Direct Known Subclasses:
AboutWindow, PreferencesWindow

@Generated("org.javagi.JavaGI") public class Window extends Window implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager

A freeform window.

window

The AdwWindow widget is a subclass of Window which has no titlebar area. Instead, ToolbarView can be used together with HeaderBar or HeaderBar as follows:

<object class="AdwWindow">
  <property name="content">
    <object class="AdwToolbarView">
      <child type="top">
        <object class="AdwHeaderBar"/>
      </child>
      <property name="content">
        <!-- ... -->
      </property>
    </object>
  </property>
</object>

Using Gtk.Window:titlebar or Gtk.Window:child is not supported and will result in a crash. Use Window:content instead.

Dialogs

AdwWindow can contain Dialog. Use Dialog.present(Widget) with the window or a widget within a window to show a dialog.

Breakpoints

AdwWindow can be used with Breakpoint the same way as BreakpointBin. Refer to that widget's documentation for details.

Example:

<object class="AdwWindow">
  <property name="content">
    <object class="AdwToolbarView">
      <child type="top">
        <object class="AdwHeaderBar"/>
      </child>
      <property name="content">
        <!-- ... -->
      </property>
      <child type="bottom">
        <object class="GtkActionBar" id="bottom_bar">
          <property name="revealed">True</property>
          <property name="visible">False</property>
        </object>
      </child>
    </object>
  </property>
  <child>
    <object class="AdwBreakpoint">
      <condition>max-width: 500px</condition>
      <setter object="bottom_bar" property="visible">True</setter>
    </object>
  </child>
</object>

When breakpoints are used, the minimum size must be larger than the smallest UI state. AdwWindow defaults to the minimum size of 360×200 px. If that's too small, set the Gtk.Widget:width-request and Gtk.Widget:height-request properties manually.

Adaptive Preview

AdwWindow has a debug tool called adaptive preview. It can be opened from GTK Inspector or by pressing Ctrl+Shift+M, and controlled via the Window:adaptive-preview property.

  • Constructor Details

    • Window

      public Window(MemorySegment address)
      Create a Window instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Window

      public Window()
      Create a new Window.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Window class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Window asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Window
      Returns:
      the instance as if it were its parent type
    • addBreakpoint

      public void addBreakpoint(Breakpoint breakpoint)
      Adds breakpoint to self.
      Parameters:
      breakpoint - the breakpoint to add
      Since:
      1.4
    • getAdaptivePreview

      public boolean getAdaptivePreview()
      Gets whether adaptive preview for this Window is currently open.
      Returns:
      whether adaptive preview is open.
      Since:
      1.7
    • getContent

      public @Nullable Widget getContent()

      Gets the content widget of self.

      This method should always be used instead of Window#getChild.

      Returns:
      the content widget of this Window
    • getCurrentBreakpoint

      public @Nullable Breakpoint getCurrentBreakpoint()
      Gets the current breakpoint.
      Returns:
      the current breakpoint
      Since:
      1.4
    • getDialogs

      public ListModel getDialogs()

      Returns a ListModel that contains the open dialogs of self.

      This can be used to keep an up-to-date view.

      Returns:
      a list model for the dialogs of this Window
      Since:
      1.5
    • getVisibleDialog

      public @Nullable Dialog getVisibleDialog()
      Returns the currently visible dialog in self, if there's one.
      Returns:
      the visible dialog
      Since:
      1.5
    • setAdaptivePreview

      public void setAdaptivePreview(boolean adaptivePreview)

      Sets whether adaptive preview for this Window is currently open.

      Adaptive preview is a debugging tool used for testing the window contents at specific screen sizes, simulating mobile environment.

      Adaptive preview can always be accessed from inspector. This function allows applications to open it manually.

      Most applications should not use this function.

      Parameters:
      adaptivePreview - whether to open adaptive preview
      Since:
      1.7
    • setContent

      public void setContent(@Nullable Widget content)

      Sets the content widget of self.

      This method should always be used instead of Window#setChild.

      Parameters:
      content - the content widget
    • builder

      public static Window.Builder<? extends Window.Builder> builder()
      A Window.Builder object constructs a Window with the specified properties. Use the various set...() methods to set properties, and finish construction with Window.Builder.build().
      Returns:
      the builder object