[gtk+/treeview-style: 1/11] Add gtk_cell_renderer_get_state()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-style: 1/11] Add gtk_cell_renderer_get_state()
- Date: Sun, 23 Jan 2011 19:21:46 +0000 (UTC)
commit 01eaccc20480dd81802449b03cb24bb661d7123a
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jan 23 14:12:36 2011 +0100
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.
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkcellrenderer.c | 45 ++++++++++++++++++++++++++++++++++
gtk/gtkcellrenderer.h | 4 +++
4 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 585b044..ab9b936 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -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>
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ada6a64..0dff645 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -461,6 +461,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
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index ced210e..ef4ec62 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -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;
+}
diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h
index 22e8637..8ae77f6 100644
--- a/gtk/gtkcellrenderer.h
+++ b/gtk/gtkcellrenderer.h
@@ -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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]