Class Breakpoint

All Implemented Interfaces:
Buildable, Proxy

@Generated("org.javagi.JavaGI") public final class Breakpoint extends GObject implements Buildable

Describes a breakpoint for Window or Dialog.

Breakpoints are used to create adaptive UI, allowing to change the layout depending on available size.

Breakpoint is a size threshold, specified by its condition, as well as one or more setters.

Each setter has a target object, a property and a value. When a breakpoint is applied, each setter sets the target property on their target object to the specified value, and reset it back to the original value when it's unapplied.

For more complicated scenarios, Breakpoint::apply and Breakpoint::unapply can be used instead.

Breakpoints can be used within Window, ApplicationWindow, Dialog or BreakpointBin.

AdwBreakpoint as GtkBuildable:

AdwBreakpoint supports specifying its condition via the <condition> element. The contents of the element must be a string in a format accepted by BreakpointCondition.parse(String).

It also supports adding setters via the <setter> element. Each <setter> element must have the object attribute specifying the target object, and the property attribute specifying the property name. The contents of the element are used as the setter value.

For G_TYPE_OBJECT and G_TYPE_BOXED derived properties, empty contents are treated as NULL.

Setter values can be translated with the usual translatable, context and comments attributes.

Example of an AdwBreakpoint UI definition:

<object class="AdwBreakpoint">
  <condition>max-width: 400px</condition>
  <setter object="button" property="visible">True</setter>
  <setter object="box" property="orientation">vertical</setter>
  <setter object="page" property="title" translatable="yes">Example</setter>
</object>
Since:
1.4
  • Constructor Details

    • Breakpoint

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

      public Breakpoint(BreakpointCondition condition)
      Creates a new AdwBreakpoint with condition.
      Parameters:
      condition - the condition
      Since:
      1.4
    • Breakpoint

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

    • getType

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

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

      protected Breakpoint 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 GObject
      Returns:
      the instance as if it were its parent type
    • addSetter

      public void addSetter(GObject object, String property, @Nullable Value value)

      Adds a setter to self.

      The setter will automatically set property on object to value when applying the breakpoint, and set it back to its original value upon unapplying it.

      ::: note Setting properties to their original values does not work for properties that have irreversible side effects. For example, changing Gtk.Button:label while Gtk.Button:icon-name is set will reset the icon. However, resetting the label will not set icon-name to its original value.

      Use the Breakpoint::apply and Breakpoint::unapply signals for those properties instead, as follows:

      static void
      breakpoint_apply_cb (MyWidget *self)
      {
        gtk_button_set_icon_name (self->button, "go-previous-symbolic");
      }
      
      static void
      breakpoint_apply_cb (MyWidget *self)
      {
        gtk_button_set_label (self->button, _("_Back"));
      }
      
      // ...
      
      g_signal_connect_swapped (breakpoint, "apply",
                                G_CALLBACK (breakpoint_apply_cb), self);
      g_signal_connect_swapped (breakpoint, "unapply",
                                G_CALLBACK (breakpoint_unapply_cb), self);
      
      Parameters:
      object - the target object
      property - the target property
      value - the value to set
      Since:
      1.4
    • addSetters

      public void addSetters(@Nullable GObject @Nullable [] objects, @Nullable String @Nullable [] names, @Nullable Value @Nullable [] values)

      Adds nSetters setters to self.

      This is a convenience function for adding multiple setters at once.

      See addSetter(GObject, String, Value).

      This function is meant to be used by language bindings.

      Parameters:
      objects - setter target object
      names - setter target properties
      values - setter values
      Since:
      1.4
    • getCondition

      public @Nullable BreakpointCondition getCondition()
      Gets the condition for self.
      Returns:
      the condition
      Since:
      1.4
    • setCondition

      public void setCondition(@Nullable BreakpointCondition condition)
      Sets the condition for self.
      Parameters:
      condition - the new condition
      Since:
      1.4
    • onApply

      Emitted when the breakpoint is applied.

      This signal is emitted after the setters have been applied.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      1.4
      See Also:
    • emitApply

      public void emitApply()
      Emits the "apply" signal. See onApply(Breakpoint.ApplyCallback).
    • onUnapply

      Emitted when the breakpoint is unapplied.

      This signal is emitted before resetting the setter values.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      1.4
      See Also:
    • emitUnapply

      public void emitUnapply()
      Emits the "unapply" signal. See onUnapply(Breakpoint.UnapplyCallback).
    • builder

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