:right-sidebar: True CellRenderer =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 List views use widgets for displaying their contents .. class:: CellRenderer(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.CellRendererPixbuf`, :class:`~gi.repository.Gtk.CellRendererProgress`, :class:`~gi.repository.Gtk.CellRendererSpinner`, :class:`~gi.repository.Gtk.CellRendererText`, :class:`~gi.repository.Gtk.CellRendererToggle` :Constructors: :: CellRenderer(**properties) Methods ------- .. rst-class:: interim-class .. class:: CellRenderer :no-index: .. method:: activate(event: ~gi.repository.Gdk.Event, widget: ~gi.repository.Gtk.Widget, path: str, background_area: ~gi.repository.Gdk.Rectangle, cell_area: ~gi.repository.Gdk.Rectangle, flags: ~gi.repository.Gtk.CellRendererState) -> bool 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:: 4.10 Please do not use it in newly written code :param event: a ``GdkEvent`` :param widget: widget that received the event :param path: widget-dependent string representation of the event location; e.g. for ``GtkTreeView``, a string representation of ``GtkTreePath`` :param background_area: background area as passed to gtk_cell_renderer_render() :param cell_area: cell area as passed to gtk_cell_renderer_render() :param flags: render flags .. method:: get_aligned_area(widget: ~gi.repository.Gtk.Widget, flags: ~gi.repository.Gtk.CellRendererState, cell_area: ~gi.repository.Gdk.Rectangle) -> ~gi.repository.Gdk.Rectangle Gets the aligned area used by ``cell`` inside ``cell_area``. Used for finding the appropriate edit and focus rectangle. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to :param flags: render flags :param cell_area: cell area which would be passed to gtk_cell_renderer_render() .. method:: get_alignment() -> tuple[float, float] Fills in ``xalign`` and ``yalign`` with the appropriate values of ``cell``. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_fixed_size() -> tuple[int, int] Fills in ``width`` and ``height`` with the appropriate size of ``cell``. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_is_expanded() -> bool Checks whether the given ``GtkCellRenderer`` is expanded. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_is_expander() -> bool Checks whether the given ``GtkCellRenderer`` is an expander. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_padding() -> tuple[int, int] Fills in ``xpad`` and ``ypad`` with the appropriate values of ``cell``. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_preferred_height(widget: ~gi.repository.Gtk.Widget) -> tuple[int, int] Retrieves a renderer’s natural size when rendered to ``widget``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to .. method:: get_preferred_height_for_width(widget: ~gi.repository.Gtk.Widget, width: int) -> tuple[int, int] Retrieves a cell renderers’s minimum and natural height if it were rendered to ``widget`` with the specified ``width``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to :param width: the size which is available for allocation .. method:: get_preferred_size(widget: ~gi.repository.Gtk.Widget) -> tuple[~gi.repository.Gtk.Requisition, ~gi.repository.Gtk.Requisition] Retrieves the minimum and natural size of a cell taking into account the widget’s preference for height-for-width management. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to .. method:: get_preferred_width(widget: ~gi.repository.Gtk.Widget) -> tuple[int, int] Retrieves a renderer’s natural size when rendered to ``widget``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to .. method:: get_preferred_width_for_height(widget: ~gi.repository.Gtk.Widget, height: int) -> tuple[int, int] Retrieves a cell renderers’s minimum and natural width if it were rendered to ``widget`` with the specified ``height``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to :param height: the size which is available for allocation .. method:: get_request_mode() -> ~gi.repository.Gtk.SizeRequestMode Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_sensitive() -> bool Returns the cell renderer’s sensitivity. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: get_state(widget: ~gi.repository.Gtk.Widget | None, cell_state: ~gi.repository.Gtk.CellRendererState) -> ~gi.repository.Gtk.StateFlags Translates the cell renderer state to ``GtkStateFlags``, based on the cell renderer and widget sensitivity, and the given ``GtkCellRenderer``State. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: a ``GtkWidget`` :param cell_state: cell renderer state .. method:: get_visible() -> bool Returns the cell renderer’s visibility. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: is_activatable() -> bool Checks whether the cell renderer can do something when activated. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: set_alignment(xalign: float, yalign: float) -> None Sets the renderer’s alignment within its available space. .. deprecated:: 4.10 Please do not use it in newly written code :param xalign: the x alignment of the cell renderer :param yalign: the y alignment of the cell renderer .. method:: set_fixed_size(width: int, height: int) -> None Sets the renderer size to be explicit, independent of the properties set. .. deprecated:: 4.10 Please do not use it in newly written code :param width: the width of the cell renderer, or -1 :param height: the height of the cell renderer, or -1 .. method:: set_is_expanded(is_expanded: bool) -> None Sets whether the given ``GtkCellRenderer`` is expanded. .. deprecated:: 4.10 Please do not use it in newly written code :param is_expanded: whether ``cell`` should be expanded .. method:: set_is_expander(is_expander: bool) -> None Sets whether the given ``GtkCellRenderer`` is an expander. .. deprecated:: 4.10 Please do not use it in newly written code :param is_expander: whether ``cell`` is an expander .. method:: set_padding(xpad: int, ypad: int) -> None Sets the renderer’s padding. .. deprecated:: 4.10 Please do not use it in newly written code :param xpad: the x padding of the cell renderer :param ypad: the y padding of the cell renderer .. method:: set_sensitive(sensitive: bool) -> None Sets the cell renderer’s sensitivity. .. deprecated:: 4.10 Please do not use it in newly written code :param sensitive: the sensitivity of the cell .. method:: set_visible(visible: bool) -> None Sets the cell renderer’s visibility. .. deprecated:: 4.10 Please do not use it in newly written code :param visible: the visibility of the cell .. method:: snapshot(snapshot: ~gi.repository.Gtk.Snapshot, widget: ~gi.repository.Gtk.Widget, background_area: ~gi.repository.Gdk.Rectangle, cell_area: ~gi.repository.Gdk.Rectangle, flags: ~gi.repository.Gtk.CellRendererState) -> None 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 the ``GtkCellRenderer`` 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:: 4.10 Please do not use it in newly written code :param snapshot: a ``GtkSnapshot`` to draw to :param widget: the widget owning ``window`` :param background_area: entire cell area (including tree expanders and maybe padding on the sides) :param cell_area: area normally rendered by a cell renderer :param flags: flags that affect rendering .. method:: start_editing(event: ~gi.repository.Gdk.Event | None, widget: ~gi.repository.Gtk.Widget, path: str, background_area: ~gi.repository.Gdk.Rectangle, cell_area: ~gi.repository.Gdk.Rectangle, flags: ~gi.repository.Gtk.CellRendererState) -> ~gi.repository.Gtk.CellEditable | None Starts editing the contents of this ``cell``, through a new ``GtkCellEditable`` widget created by the ``GtkCellRenderer``Class.start_editing virtual function. .. deprecated:: 4.10 Please do not use it in newly written code :param event: a ``GdkEvent`` :param widget: widget that received the event :param path: widget-dependent string representation of the event location; e.g. for ``GtkTreeView``, a string representation of ``GtkTreePath`` :param background_area: background area as passed to gtk_cell_renderer_render() :param cell_area: cell area as passed to gtk_cell_renderer_render() :param flags: render flags .. method:: stop_editing(canceled: bool) -> None Informs the cell renderer that the editing is stopped. If ``canceled`` is :const:`True`, the cell renderer will emit the ``GtkCellRenderer``::editing-canceled signal. This function should be called by cell renderer implementations in response to the ``GtkCellEditable::editing-done`` signal of ``GtkCellEditable``. .. deprecated:: 4.10 Please do not use it in newly written code :param canceled: :const:`True` if the editing has been canceled Properties ---------- .. rst-class:: interim-class .. class:: CellRenderer :no-index: .. attribute:: props.cell_background :type: str .. attribute:: props.cell_background_rgba :type: ~gi.repository.Gdk.RGBA Cell background as a ``GdkRGBA`` .. attribute:: props.cell_background_set :type: bool .. attribute:: props.editing :type: bool .. attribute:: props.height :type: int .. attribute:: props.is_expanded :type: bool .. attribute:: props.is_expander :type: bool .. attribute:: props.mode :type: ~gi.repository.Gtk.CellRendererMode .. attribute:: props.sensitive :type: bool .. attribute:: props.visible :type: bool .. attribute:: props.width :type: int .. attribute:: props.xalign :type: float .. attribute:: props.xpad :type: int .. attribute:: props.yalign :type: float .. attribute:: props.ypad :type: int Signals ------- .. rst-class:: interim-class .. class:: CellRenderer.signals :no-index: .. method:: editing_canceled() -> None 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: :func:`~gi.repository.Gtk.CellRenderer.stop_editing`. .. method:: editing_started(editable: ~gi.repository.Gtk.CellEditable, path: str) -> None 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 a ``GtkComboBox``. See :func:`~gi.repository.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: .. code-block:: C :dedent: 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); } } :param editable: the ``GtkCellEditable`` :param path: the path identifying the edited cell Virtual Methods --------------- .. rst-class:: interim-class .. class:: CellRenderer :no-index: .. method:: do_activate(event: ~gi.repository.Gdk.Event, widget: ~gi.repository.Gtk.Widget, path: str, background_area: ~gi.repository.Gdk.Rectangle, cell_area: ~gi.repository.Gdk.Rectangle, flags: ~gi.repository.Gtk.CellRendererState) -> bool 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:: 4.10 Please do not use it in newly written code :param event: a ``GdkEvent`` :param widget: widget that received the event :param path: widget-dependent string representation of the event location; e.g. for ``GtkTreeView``, a string representation of ``GtkTreePath`` :param background_area: background area as passed to gtk_cell_renderer_render() :param cell_area: cell area as passed to gtk_cell_renderer_render() :param flags: render flags .. method:: do_editing_canceled() -> None Signal gets emitted when the user cancels the process of editing a cell. .. method:: do_editing_started(editable: ~gi.repository.Gtk.CellEditable, path: str) -> None Signal gets emitted when a cell starts to be edited. :param editable: :param path: .. method:: do_get_aligned_area(widget: ~gi.repository.Gtk.Widget, flags: ~gi.repository.Gtk.CellRendererState, cell_area: ~gi.repository.Gdk.Rectangle) -> ~gi.repository.Gdk.Rectangle Gets the aligned area used by ``cell`` inside ``cell_area``. Used for finding the appropriate edit and focus rectangle. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to :param flags: render flags :param cell_area: cell area which would be passed to gtk_cell_renderer_render() .. method:: do_get_preferred_height(widget: ~gi.repository.Gtk.Widget) -> tuple[int, int] Retrieves a renderer’s natural size when rendered to ``widget``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to .. method:: do_get_preferred_height_for_width(widget: ~gi.repository.Gtk.Widget, width: int) -> tuple[int, int] Retrieves a cell renderers’s minimum and natural height if it were rendered to ``widget`` with the specified ``width``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to :param width: the size which is available for allocation .. method:: do_get_preferred_width(widget: ~gi.repository.Gtk.Widget) -> tuple[int, int] Retrieves a renderer’s natural size when rendered to ``widget``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to .. method:: do_get_preferred_width_for_height(widget: ~gi.repository.Gtk.Widget, height: int) -> tuple[int, int] Retrieves a cell renderers’s minimum and natural width if it were rendered to ``widget`` with the specified ``height``. .. deprecated:: 4.10 Please do not use it in newly written code :param widget: the ``GtkWidget`` this cell will be rendering to :param height: the size which is available for allocation .. method:: do_get_request_mode() -> ~gi.repository.Gtk.SizeRequestMode Gets whether the cell renderer prefers a height-for-width layout or a width-for-height layout. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: do_snapshot(snapshot: ~gi.repository.Gtk.Snapshot, widget: ~gi.repository.Gtk.Widget, background_area: ~gi.repository.Gdk.Rectangle, cell_area: ~gi.repository.Gdk.Rectangle, flags: ~gi.repository.Gtk.CellRendererState) -> None 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 the ``GtkCellRenderer`` 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:: 4.10 Please do not use it in newly written code :param snapshot: a ``GtkSnapshot`` to draw to :param widget: the widget owning ``window`` :param background_area: entire cell area (including tree expanders and maybe padding on the sides) :param cell_area: area normally rendered by a cell renderer :param flags: flags that affect rendering .. method:: do_start_editing(event: ~gi.repository.Gdk.Event | None, widget: ~gi.repository.Gtk.Widget, path: str, background_area: ~gi.repository.Gdk.Rectangle, cell_area: ~gi.repository.Gdk.Rectangle, flags: ~gi.repository.Gtk.CellRendererState) -> ~gi.repository.Gtk.CellEditable | None Starts editing the contents of this ``cell``, through a new ``GtkCellEditable`` widget created by the ``GtkCellRenderer``Class.start_editing virtual function. .. deprecated:: 4.10 Please do not use it in newly written code :param event: a ``GdkEvent`` :param widget: widget that received the event :param path: widget-dependent string representation of the event location; e.g. for ``GtkTreeView``, a string representation of ``GtkTreePath`` :param background_area: background area as passed to gtk_cell_renderer_render() :param cell_area: cell area as passed to gtk_cell_renderer_render() :param flags: render flags Fields ------ .. rst-class:: interim-class .. class:: CellRenderer :no-index: .. attribute:: parent_instance .. attribute:: priv