Class MarkAttributes

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class MarkAttributes extends GObject

The source mark attributes object.

GtkSourceMarkAttributes is an object specifying attributes used by a View to visually show lines marked with Marks of a specific category. It allows you to define a background color of a line, an icon shown in gutter and tooltips.

The background color is used as a background of a line where a mark is placed and it can be set with setBackground(RGBA). To check if any custom background color was defined and what color it is, use getBackground(RGBA).

An icon is a graphic element which is shown in the gutter of a view. An example use is showing a red filled circle in a debugger to show that a breakpoint was set in certain line. To get an icon that will be placed in a gutter, first a base for it must be specified and then renderIcon(Widget, int) must be called. There are several ways to specify a base for an icon:

Using any of the above functions overrides the one used earlier. But note that a getter counterpart of earlier used function can still return some value, but it is just not used when rendering the proper icon.

To provide meaningful tooltips for a given mark of a category, you should connect to MarkAttributes::query-tooltip-text or MarkAttributes::query-tooltip-markup where the latter takes precedence.

  • Constructor Details

    • MarkAttributes

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

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

    • getType

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

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

      protected MarkAttributes 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
    • getBackground

      public boolean getBackground(RGBA background)
      Stores background color in background.
      Parameters:
      background - a GdkRGBA.
      Returns:
      whether background color for this MarkAttributes was set.
    • getGicon

      public Icon getGicon()

      Gets a Icon to be used as a base for rendered icon.

      Note that the icon can be null if it wasn't set earlier.

      Returns:
      An icon. The icon belongs to this MarkAttributes and should not be unreffed.
    • getIconName

      public String getIconName()

      Gets a name of an icon to be used as a base for rendered icon.

      Note that the icon name can be null if it wasn't set earlier.

      Returns:
      An icon name. The string belongs to this MarkAttributes and should not be freed.
    • getPixbuf

      public Pixbuf getPixbuf()

      Gets a Pixbuf to be used as a base for rendered icon.

      Note that the pixbuf can be null if it wasn't set earlier.

      Returns:
      A pixbuf. The pixbuf belongs to this MarkAttributes and should not be unreffed.
    • getTooltipMarkup

      public String getTooltipMarkup(Mark mark)

      Queries for a tooltip by emitting a MarkAttributes::query-tooltip-markup signal.

      The tooltip may contain a markup.

      Parameters:
      mark - a GtkSourceMark.
      Returns:
      A tooltip. The returned string should be freed by using g_free() when done with it.
    • getTooltipText

      public String getTooltipText(Mark mark)

      Queries for a tooltip by emitting a MarkAttributes::query-tooltip-text signal.

      The tooltip is a plain text.

      Parameters:
      mark - a GtkSourceMark.
      Returns:
      A tooltip. The returned string should be freed by using g_free() when done with it.
    • renderIcon

      public Paintable renderIcon(Widget widget, int size)

      Renders an icon of given size.

      The base of the icon is set by the last call to one of:

      size cannot be lower than 1.

      Parameters:
      widget - widget of which style settings may be used.
      size - size of the rendered icon.
      Returns:
      A GdkPaintable. The paintable belongs to this MarkAttributes and should not be unreffed.
    • setBackground

      public void setBackground(RGBA background)
      Sets background color to the one given in background.
      Parameters:
      background - a GdkRGBA.
    • setGicon

      public void setGicon(Icon gicon)
      Sets an icon to be used as a base for rendered icon.
      Parameters:
      gicon - a GIcon to be used.
    • setIconName

      public void setIconName(String iconName)
      Sets a name of an icon to be used as a base for rendered icon.
      Parameters:
      iconName - name of an icon to be used.
    • setPixbuf

      public void setPixbuf(Pixbuf pixbuf)
      Sets a pixbuf to be used as a base for rendered icon.
      Parameters:
      pixbuf - a GdkPixbuf to be used.
    • onQueryTooltipMarkup

      The code should connect to this signal to provide a tooltip for given mark. The tooltip can contain a markup.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitQueryTooltipMarkup

      public String emitQueryTooltipMarkup(@Nullable Mark mark)
      Emits the "query-tooltip-markup" signal. See onQueryTooltipMarkup(MarkAttributes.QueryTooltipMarkupCallback).
    • onQueryTooltipText

      The code should connect to this signal to provide a tooltip for given mark. The tooltip should be just a plain text.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitQueryTooltipText

      public String emitQueryTooltipText(@Nullable Mark mark)
      Emits the "query-tooltip-text" signal. See onQueryTooltipText(MarkAttributes.QueryTooltipTextCallback).
    • builder

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