Class BuilderListItemFactory

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class BuilderListItemFactory extends ListItemFactory

Creates widgets by instantiating GtkBuilder UI templates.

The templates must extend the class that the parent widget expects. For example, a factory provided to Gtk.ListView:factory must have a template that extends ListItem.

Templates typically use Expression to obtain data from the items in the model.

Example:

  <interface>
    <template class="GtkListItem">
      <property name="child">
        <object class="GtkLabel">
          <property name="xalign">0</property>
          <binding name="label">
            <lookup name="name" type="SettingsKey">
              <lookup name="item">GtkListItem</lookup>
            </lookup>
          </binding>
        </object>
      </property>
    </template>
  </interface>

A common approach is to embed such templates as CDATA marked sections into a surrounding UI file. Note that if you use this approach, extracting translatable strings with xgettext will not work for strings inside the marked section.

  • Constructor Details

    • BuilderListItemFactory

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

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

    • getType

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

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

      protected BuilderListItemFactory 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 ListItemFactory
      Returns:
      the instance as if it were its parent type
    • fromBytes

      public static ListItemFactory fromBytes(@Nullable BuilderScope scope, byte[] bytes)
      Creates a new GtkBuilderListItemFactory that instantiates widgets using bytes as the data to pass to GtkBuilder.
      Parameters:
      scope - A scope to use when instantiating
      bytes - the GBytes containing the UI definition to instantiate
      Returns:
      a new GtkBuilderListItemFactory
    • fromResource

      public static ListItemFactory fromResource(@Nullable BuilderScope scope, String resourcePath)
      Creates a new GtkBuilderListItemFactory that instantiates widgets using data read from the given resourcePath to pass to GtkBuilder.
      Parameters:
      scope - A scope to use when instantiating
      resourcePath - valid path to a resource that contains the UI definition
      Returns:
      a new GtkBuilderListItemFactory
    • getBytes

      public byte[] getBytes()
      Gets the data used as the GtkBuilder UI template for constructing listitems.
      Returns:
      The GtkBuilder data
    • getResource

      public @Nullable String getResource()
      If the data references a resource, gets the path of that resource.
      Returns:
      The path to the resource
    • getScope

      public @Nullable BuilderScope getScope()
      Gets the scope used when constructing listitems.
      Returns:
      The scope used when constructing listitems
    • builder

      A BuilderListItemFactory.Builder object constructs a BuilderListItemFactory with the specified properties. Use the various set...() methods to set properties, and finish construction with BuilderListItemFactory.Builder.build().
      Returns:
      the builder object