Commit f96aae68 authored by Carlos Garnacho's avatar Carlos Garnacho

Add gtk_cell_renderer_get_state()

This is a helper function to help retrieve a GtkStateFlags
from a GtkCellRendererState, also given the cell renderer
and widget sensitivities.
parent 22527e80
......@@ -4557,6 +4557,7 @@ gtk_cell_renderer_get_alignment
gtk_cell_renderer_set_alignment
gtk_cell_renderer_get_padding
gtk_cell_renderer_set_padding
gtk_cell_renderer_get_state
gtk_cell_renderer_is_activatable
<SUBSECTION Width-for-height>
......
......@@ -463,6 +463,7 @@ gtk_cell_renderer_get_preferred_width_for_height
gtk_cell_renderer_get_request_mode
gtk_cell_renderer_get_sensitive
gtk_cell_renderer_get_size
gtk_cell_renderer_get_state
gtk_cell_renderer_get_type G_GNUC_CONST
gtk_cell_renderer_get_visible
gtk_cell_renderer_is_activatable
......
......@@ -1663,3 +1663,48 @@ gtk_cell_renderer_get_aligned_area (GtkCellRenderer *cell,
g_assert ((aligned_area->x - cell_area->x) + aligned_area->width <= cell_area->width);
g_assert ((aligned_area->y - cell_area->y) + aligned_area->height <= cell_area->height);
}
/**
* gtk_cell_renderer_get_state:
* @cell: a #GtkCellRenderer, or %NULL
* @widget: a #GtkWidget, or %NULL
* @cell_state: cell renderer state
*
* Translates the cell renderer state to a #GtkStateFlags,
* based on the cell renderer and widget sensitivity, and
* the given #GtkCellRendererState
*
* Returns: the widget state flags applying to @cell
*
* Since: 3.0
**/
GtkStateFlags
gtk_cell_renderer_get_state (GtkCellRenderer *cell,
GtkWidget *widget,
GtkCellRendererState cell_state)
{
GtkStateFlags state = 0;
g_return_val_if_fail (!cell || GTK_IS_CELL_RENDERER (cell), 0);
g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), 0);
if ((widget && !gtk_widget_get_sensitive (widget)) ||
(cell && !gtk_cell_renderer_get_sensitive (cell)))
state |= GTK_STATE_FLAG_INSENSITIVE;
else
{
if ((cell_state & GTK_CELL_RENDERER_SELECTED) != 0)
{
state |= GTK_STATE_FLAG_SELECTED;
if ((widget && gtk_widget_has_focus (widget)) &&
(cell_state & GTK_CELL_RENDERER_FOCUSED) != 0)
state |= GTK_STATE_FLAG_FOCUSED;
}
if ((cell_state & GTK_CELL_RENDERER_PRELIT) != 0)
state |= GTK_STATE_FLAG_PRELIGHT;
}
return state;
}
......@@ -262,6 +262,10 @@ void _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
gint *x_offset,
gint *y_offset);
GtkStateFlags gtk_cell_renderer_get_state (GtkCellRenderer *cell,
GtkWidget *widget,
GtkCellRendererState cell_state);
G_END_DECLS
#endif /* __GTK_CELL_RENDERER_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment