Gtk.CellRenderer

const Gtk = imports.gi.Gtk;

let cell_renderer = new Gtk.CellRenderer({
    cell_background: value,
    cell_background_gdk: value,
    cell_background_rgba: value,
    cell_background_set: value,
    height: value,
    is_expanded: value,
    is_expander: value,
    mode: value,
    sensitive: value,
    visible: value,
    width: value,
    xalign: value,
    xpad: value,
    yalign: value,
    ypad: value,
});
  

The Gtk.CellRenderer is a base class of a set of objects used for rendering a cell to a #cairo_t. These objects are used primarily by the Gtk.TreeView widget, though they aren't tied to them in any specific way. It is worth noting that Gtk.CellRenderer is not a Gtk.Widget and cannot be treated as such.

The primary use of a Gtk.CellRenderer is for drawing a certain graphical elements on a #cairo_t. Typically, one cell renderer is used to draw many cells on the screen. To this extent, it isn't expected that a CellRenderer keep any permanent state around. Instead, any state is set just prior to use using #GObjects property system. Then, the cell is measured using Gtk.get_size. Finally, the cell is rendered in the correct location using Gtk.render.

There are a number of rules that must be followed when writing a new Gtk.CellRenderer. First and foremost, it's important that a certain set of properties will always yield a cell renderer of the same size, barring a Gtk.Style change. The Gtk.CellRenderer also has a number of generic properties that are expected to be honored by all children.

Beyond merely rendering a cell, cell renderers can optionally provide active user interface elements. A cell renderer can be <firstterm>activatable</firstterm> like Gtk.CellRendererToggle, which toggles when it gets activated by a mouse click, or it can be <firstterm>editable</firstterm> like Gtk.CellRendererText, which allows the user to edit the text using a Gtk.Entry. To make a cell renderer activatable or editable, you have to implement the Gtk.CellRendererClass.activate or Gtk.CellRendererClass.start_editing virtual functions, respectively.

Many properties of Gtk.CellRenderer and its subclasses have a corresponding "set" property, e.g. "cell-background-set" corresponds to "cell-background". These "set" properties reflect whether a property has been set or not. You should not set them independently.

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.CellRenderer