Gtk.CellRenderer¶
- Subclasses:
Gtk.CellRendererPixbuf
,Gtk.CellRendererProgress
,Gtk.CellRendererSpinner
,Gtk.CellRendererText
,Gtk.CellRendererToggle
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
w |
|||
r/w |
|||
r/w/en |
|||
r |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal gets emitted when the user cancels the process of editing a cell. |
|
This signal gets emitted when a cell starts to be edited. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.CellRenderer(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
An object for rendering a single cell
The
GtkCellRenderer
is a base class of a set of objects used for rendering a cell to acairo_t
. These objects are used primarily by theGtkTreeView
widget, though they aren’t tied to them in any specific way. It is worth noting thatGtkCellRenderer
is not aGtkWidget
and cannot be treated as such.The primary use of a
GtkCellRenderer
is for drawing a certain graphical elements on acairo_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 ``GObject``s property system. Then, the cell is measured usingGtk.CellRenderer.get_preferred_size
(). Finally, the cell is rendered in the correct location usingGtk.CellRenderer.snapshot
().There are a number of rules that must be followed when writing a new
GtkCellRenderer
. First and foremost, it’s important that a certain set of properties will always yield a cell renderer of the same size, barring a style change. TheGtkCellRenderer
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 “activatable” like
GtkCellRenderer``Toggle, which toggles when it gets activated by a mouse click, or it can be “editable” like ``GtkCellRenderer``Text, which allows the user to edit the text using a widget implementing the ``GtkCellEditable
interface, e.g.GtkEntry
. To make a cell renderer activatable or editable, you have to implement the ``GtkCellRenderer``Class.activate or ``GtkCellRenderer``Class.start_editing virtual functions, respectively.Many properties of
GtkCellRenderer
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.Deprecated since version 4.10: List views use widgets for displaying their contents
- activate(event, widget, path, background_area, cell_area, flags)[source]¶
- Parameters:
event (
Gdk.Event
) – aGdkEvent
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtkTreeView
, a string representation ofGtkTreePath
background_area (
Gdk.Rectangle
) – background area as passed to gtk_cell_renderer_render()cell_area (
Gdk.Rectangle
) – cell area as passed to gtk_cell_renderer_render()flags (
Gtk.CellRendererState
) – render flags
- Returns:
True
if the event was consumed/handled- Return type:
Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example,
GtkCellRendererToggle
toggles when it gets a mouse click.Deprecated since version 4.10.
- get_aligned_area(widget, flags, cell_area)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering toflags (
Gtk.CellRendererState
) – render flagscell_area (
Gdk.Rectangle
) – cell area which would be passed to gtk_cell_renderer_render()
- Returns:
the return location for the space inside cell_area that would actually be used to render.
- Return type:
aligned_area:
Gdk.Rectangle
Gets the aligned area used by self inside cell_area. Used for finding the appropriate edit and focus rectangle.
Deprecated since version 4.10.
- get_alignment()[source]¶
- Returns:
- xalign:
location to fill in with the x alignment of the cell
- yalign:
location to fill in with the y alignment of the cell
- Return type:
Fills in xalign and yalign with the appropriate values of self.
Deprecated since version 4.10.
- get_fixed_size()[source]¶
- Returns:
- width:
location to fill in with the fixed width of the cell
- height:
location to fill in with the fixed height of the cell
- Return type:
Fills in width and height with the appropriate size of self.
Deprecated since version 4.10.
- get_is_expanded()[source]¶
-
Checks whether the given
GtkCellRenderer
is expanded.Deprecated since version 4.10.
- get_is_expander()[source]¶
-
Checks whether the given
GtkCellRenderer
is an expander.Deprecated since version 4.10.
- get_padding()[source]¶
- Returns:
- xpad:
location to fill in with the x padding of the cell
- ypad:
location to fill in with the y padding of the cell
- Return type:
Fills in xpad and ypad with the appropriate values of self.
Deprecated since version 4.10.
- get_preferred_height(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering to- Returns:
- minimum_size:
location to store the minimum size
- natural_size:
location to store the natural size
- Return type:
Retrieves a renderer’s natural size when rendered to widget.
Deprecated since version 4.10.
- get_preferred_height_for_width(widget, width)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering towidth (
int
) – the size which is available for allocation
- Returns:
- minimum_height:
location for storing the minimum size
- natural_height:
location for storing the preferred size
- Return type:
Retrieves a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
Deprecated since version 4.10.
- get_preferred_size(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering to- Returns:
- minimum_size:
location for storing the minimum size
- natural_size:
location for storing the natural size
- Return type:
(minimum_size:
Gtk.Requisition
, natural_size:Gtk.Requisition
)
Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management.
Deprecated since version 4.10.
- get_preferred_width(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering to- Returns:
- minimum_size:
location to store the minimum size
- natural_size:
location to store the natural size
- Return type:
Retrieves a renderer’s natural size when rendered to widget.
Deprecated since version 4.10.
- get_preferred_width_for_height(widget, height)[source]¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering toheight (
int
) – the size which is available for allocation
- Returns:
- minimum_width:
location for storing the minimum size
- natural_width:
location for storing the preferred size
- Return type:
Retrieves a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
Deprecated since version 4.10.
- get_request_mode()[source]¶
- Returns:
The
GtkSizeRequestMode
preferred by this renderer.- Return type:
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
Deprecated since version 4.10.
- get_state(widget, cell_state)[source]¶
- Parameters:
widget (
Gtk.Widget
orNone
) – aGtkWidget
cell_state (
Gtk.CellRendererState
) – cell renderer state
- Returns:
the widget state flags applying to self
- Return type:
Translates the cell renderer state to
GtkStateFlags
, based on the cell renderer and widget sensitivity, and the given ``GtkCellRenderer``State.Deprecated since version 4.10.
- is_activatable()[source]¶
-
Checks whether the cell renderer can do something when activated.
Deprecated since version 4.10.
- set_alignment(xalign, yalign)[source]¶
- Parameters:
Sets the renderer’s alignment within its available space.
Deprecated since version 4.10.
- set_fixed_size(width, height)[source]¶
- Parameters:
Sets the renderer size to be explicit, independent of the properties set.
Deprecated since version 4.10.
- set_is_expanded(is_expanded)[source]¶
- Parameters:
is_expanded (
bool
) – whether self should be expanded
Sets whether the given
GtkCellRenderer
is expanded.Deprecated since version 4.10.
- set_is_expander(is_expander)[source]¶
- Parameters:
is_expander (
bool
) – whether self is an expander
Sets whether the given
GtkCellRenderer
is an expander.Deprecated since version 4.10.
- set_padding(xpad, ypad)[source]¶
- Parameters:
Sets the renderer’s padding.
Deprecated since version 4.10.
- set_sensitive(sensitive)[source]¶
- Parameters:
sensitive (
bool
) – the sensitivity of the cell
Sets the cell renderer’s sensitivity.
Deprecated since version 4.10.
- set_visible(visible)[source]¶
- Parameters:
visible (
bool
) – the visibility of the cell
Sets the cell renderer’s visibility.
Deprecated since version 4.10.
- snapshot(snapshot, widget, background_area, cell_area, flags)[source]¶
- Parameters:
snapshot (
Gtk.Snapshot
) – aGtkSnapshot
to draw towidget (
Gtk.Widget
) – the widget owning windowbackground_area (
Gdk.Rectangle
) – entire cell area (including tree expanders and maybe padding on the sides)cell_area (
Gdk.Rectangle
) – area normally rendered by a cell rendererflags (
Gtk.CellRendererState
) – flags that affect rendering
Invokes the virtual render function of the
GtkCellRenderer
. The three passed-in rectangles are areas in cr. Most renderers will draw within cell_area; the xalign, yalign, xpad, and ypad fields of theGtkCellRenderer
should be honored with respect to cell_area. background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window.Deprecated since version 4.10.
- start_editing(event, widget, path, background_area, cell_area, flags)[source]¶
- Parameters:
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtkTreeView
, a string representation ofGtkTreePath
background_area (
Gdk.Rectangle
) – background area as passed to gtk_cell_renderer_render()cell_area (
Gdk.Rectangle
) – cell area as passed to gtk_cell_renderer_render()flags (
Gtk.CellRendererState
) – render flags
- Returns:
A new
GtkCellEditable
for editing this self, orNone
if editing is not possible- Return type:
Starts editing the contents of this self, through a new
GtkCellEditable
widget created by the ``GtkCellRenderer``Class.start_editing virtual function.Deprecated since version 4.10.
- stop_editing(canceled)[source]¶
-
Informs the cell renderer that the editing is stopped. If canceled is
True
, the cell renderer will emit theGtkCellRenderer
::editing-canceled
signal.This function should be called by cell renderer implementations in response to the
GtkCellEditable::editing-done
signal ofGtkCellEditable
.Deprecated since version 4.10.
- do_activate(event, widget, path, background_area, cell_area, flags) virtual¶
- Parameters:
event (
Gdk.Event
) – aGdkEvent
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtkTreeView
, a string representation ofGtkTreePath
background_area (
Gdk.Rectangle
) – background area as passed to gtk_cell_renderer_render()cell_area (
Gdk.Rectangle
) – cell area as passed to gtk_cell_renderer_render()flags (
Gtk.CellRendererState
) – render flags
- Returns:
True
if the event was consumed/handled- Return type:
Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example,
GtkCellRendererToggle
toggles when it gets a mouse click.Deprecated since version 4.10.
- do_editing_canceled() virtual¶
Signal gets emitted when the user cancels the process of editing a cell.
- do_editing_started(editable, path) virtual¶
- Parameters:
editable (
Gtk.CellEditable
) –path (
str
) –
Signal gets emitted when a cell starts to be edited.
- do_get_aligned_area(widget, flags, cell_area) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering toflags (
Gtk.CellRendererState
) – render flagscell_area (
Gdk.Rectangle
) – cell area which would be passed to gtk_cell_renderer_render()
- Returns:
the return location for the space inside cell_area that would actually be used to render.
- Return type:
aligned_area:
Gdk.Rectangle
Gets the aligned area used by cell inside cell_area. Used for finding the appropriate edit and focus rectangle.
Deprecated since version 4.10.
- do_get_preferred_height(widget) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering to- Returns:
- minimum_size:
location to store the minimum size
- natural_size:
location to store the natural size
- Return type:
Retrieves a renderer’s natural size when rendered to widget.
Deprecated since version 4.10.
- do_get_preferred_height_for_width(widget, width) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering towidth (
int
) – the size which is available for allocation
- Returns:
- minimum_height:
location for storing the minimum size
- natural_height:
location for storing the preferred size
- Return type:
Retrieves a cell renderers’s minimum and natural height if it were rendered to widget with the specified width.
Deprecated since version 4.10.
- do_get_preferred_width(widget) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering to- Returns:
- minimum_size:
location to store the minimum size
- natural_size:
location to store the natural size
- Return type:
Retrieves a renderer’s natural size when rendered to widget.
Deprecated since version 4.10.
- do_get_preferred_width_for_height(widget, height) virtual¶
- Parameters:
widget (
Gtk.Widget
) – theGtkWidget
this cell will be rendering toheight (
int
) – the size which is available for allocation
- Returns:
- minimum_width:
location for storing the minimum size
- natural_width:
location for storing the preferred size
- Return type:
Retrieves a cell renderers’s minimum and natural width if it were rendered to widget with the specified height.
Deprecated since version 4.10.
- do_get_request_mode() virtual¶
- Returns:
The
GtkSizeRequestMode
preferred by this renderer.- Return type:
Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout.
Deprecated since version 4.10.
- do_snapshot(snapshot, widget, background_area, cell_area, flags) virtual¶
- Parameters:
snapshot (
Gtk.Snapshot
) – aGtkSnapshot
to draw towidget (
Gtk.Widget
) – the widget owning windowbackground_area (
Gdk.Rectangle
) – entire cell area (including tree expanders and maybe padding on the sides)cell_area (
Gdk.Rectangle
) – area normally rendered by a cell rendererflags (
Gtk.CellRendererState
) – flags that affect rendering
Invokes the virtual render function of the
GtkCellRenderer
. The three passed-in rectangles are areas in cr. Most renderers will draw within cell_area; the xalign, yalign, xpad, and ypad fields of theGtkCellRenderer
should be honored with respect to cell_area. background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window.Deprecated since version 4.10.
- do_start_editing(event, widget, path, background_area, cell_area, flags) virtual¶
- Parameters:
widget (
Gtk.Widget
) – widget that received the eventpath (
str
) – widget-dependent string representation of the event location; e.g. forGtkTreeView
, a string representation ofGtkTreePath
background_area (
Gdk.Rectangle
) – background area as passed to gtk_cell_renderer_render()cell_area (
Gdk.Rectangle
) – cell area as passed to gtk_cell_renderer_render()flags (
Gtk.CellRendererState
) – render flags
- Returns:
A new
GtkCellEditable
for editing this cell, orNone
if editing is not possible- Return type:
Starts editing the contents of this cell, through a new
GtkCellEditable
widget created by the ``GtkCellRenderer``Class.start_editing virtual function.Deprecated since version 4.10.
Signal Details¶
- Gtk.CellRenderer.signals.editing_canceled(cell_renderer)¶
- Signal Name:
editing-canceled
- Flags:
- Parameters:
cell_renderer (
Gtk.CellRenderer
) – The object which received the signal
This signal gets emitted when the user cancels the process of editing a cell. For example, an editable cell renderer could be written to cancel editing when the user presses Escape.
See also:
Gtk.CellRenderer.stop_editing
().
- Gtk.CellRenderer.signals.editing_started(cell_renderer, editable, path)¶
- Signal Name:
editing-started
- Flags:
- Parameters:
cell_renderer (
Gtk.CellRenderer
) – The object which received the signaleditable (
Gtk.CellEditable
) – theGtkCellEditable
path (
str
) – the path identifying the edited cell
This signal gets emitted when a cell starts to be edited. The intended use of this signal is to do special setup on editable, e.g. adding a
GtkEntryCompletion
or setting up additional columns in aGtkComboBox
.See
Gtk.CellEditable.start_editing
() for information on the lifecycle of the editable and a way to do setup that doesn’t depend on the renderer.Note that GTK doesn’t guarantee that cell renderers will continue to use the same kind of widget for editing in future releases, therefore you should check the type of editable before doing any specific setup, as in the following example:
static void text_editing_started (GtkCellRenderer *cell, GtkCellEditable *editable, const char *path, gpointer data) { if (GTK_IS_ENTRY (editable)) { GtkEntry *entry = GTK_ENTRY (editable); // ... create a GtkEntryCompletion gtk_entry_set_completion (entry, completion); } }
Property Details¶
- Gtk.CellRenderer.props.cell_background¶
- Gtk.CellRenderer.props.cell_background_rgba¶
-
Cell background as a
GdkRGBA
- Gtk.CellRenderer.props.cell_background_set¶
- Name:
cell-background-set
- Type:
- Default Value:
- Flags:
- Gtk.CellRenderer.props.height¶
- Name:
height
- Type:
- Default Value:
-1
- Flags:
- Gtk.CellRenderer.props.is_expanded¶
- Name:
is-expanded
- Type:
- Default Value:
- Flags:
- Gtk.CellRenderer.props.is_expander¶
- Name:
is-expander
- Type:
- Default Value:
- Flags:
- Gtk.CellRenderer.props.mode¶
- Name:
mode
- Type:
- Default Value:
- Flags:
- Gtk.CellRenderer.props.sensitive¶
- Name:
sensitive
- Type:
- Default Value:
- Flags:
- Gtk.CellRenderer.props.visible¶
- Name:
visible
- Type:
- Default Value:
- Flags:
- Gtk.CellRenderer.props.width¶
- Name:
width
- Type:
- Default Value:
-1
- Flags:
- Gtk.CellRenderer.props.xalign¶
- Name:
xalign
- Type:
- Default Value:
0.5
- Flags:
- Gtk.CellRenderer.props.xpad¶
- Name:
xpad
- Type:
- Default Value:
0
- Flags:
- Gtk.CellRenderer.props.yalign¶
- Name:
yalign
- Type:
- Default Value:
0.5
- Flags:
- Gtk.CellRenderer.props.ypad¶
- Name:
ypad
- Type:
- Default Value:
0
- Flags: