[gtk+/treeview-style: 1/8] Make GtkCellArea use GtkStyleContext



commit ec7db99f65da779781530ca5bb3a8397bfd2e57b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jan 12 21:07:05 2011 +0100

    Make GtkCellArea use GtkStyleContext
    
    gtk_cell_area_[gs]et_style_detail() is no longer needed, as
    the passed widget's context would already have all necessary
    info.

 docs/reference/gtk/gtk3-sections.txt |    2 -
 gtk/gtk.symbols                      |    2 -
 gtk/gtkcellarea.c                    |   83 +++++++++-------------------------
 gtk/gtkcellarea.h                    |    4 --
 gtk/gtkiconview.c                    |    2 -
 gtk/gtktreeviewcolumn.c              |    2 -
 6 files changed, 21 insertions(+), 74 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index dfba4d3..89e575f 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -4423,8 +4423,6 @@ gtk_cell_area_foreach
 gtk_cell_area_foreach_alloc
 gtk_cell_area_event
 gtk_cell_area_render
-gtk_cell_area_set_style_detail
-gtk_cell_area_get_style_detail
 gtk_cell_area_get_cell_allocation
 gtk_cell_area_get_cell_at_position
 gtk_cell_area_create_context
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index a8aa36e..964c67f 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -413,7 +413,6 @@ gtk_cell_area_get_preferred_height_for_width
 gtk_cell_area_get_preferred_width
 gtk_cell_area_get_preferred_width_for_height
 gtk_cell_area_get_request_mode
-gtk_cell_area_get_style_detail
 gtk_cell_area_get_type G_GNUC_CONST
 gtk_cell_area_has_renderer
 gtk_cell_area_inner_cell_area
@@ -424,7 +423,6 @@ gtk_cell_area_remove_focus_sibling
 gtk_cell_area_render
 gtk_cell_area_request_renderer
 gtk_cell_area_set_focus_cell
-gtk_cell_area_set_style_detail
 gtk_cell_area_stop_editing
 gtk_cell_editable_editing_done
 gtk_cell_editable_get_type G_GNUC_CONST
diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c
index b9e74ff..ab9362d 100644
--- a/gtk/gtkcellarea.c
+++ b/gtk/gtkcellarea.c
@@ -560,9 +560,6 @@ struct _GtkCellAreaPrivate
 
   /* Tracking which cells are focus siblings of focusable cells */
   GHashTable      *focus_siblings;
-
-  /* Detail string to pass to gtk_paint_*() functions */
-  gchar           *style_detail;
 };
 
 enum {
@@ -1151,21 +1148,33 @@ gtk_cell_area_real_render (GtkCellArea          *area,
       render_data.focus_rect.width != 0 &&
       render_data.focus_rect.height != 0)
     {
-      GtkStateType renderer_state =
-        flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
-        (flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
-         (flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL));
+      GtkStyleContext *style_context;
+      GtkStateFlags renderer_state = 0;
+
+      style_context = gtk_widget_get_style_context (widget);
+      gtk_style_context_save (style_context);
+
+      if (flags & GTK_CELL_RENDERER_INSENSITIVE)
+        renderer_state |= GTK_STATE_FLAG_INSENSITIVE;
+      else
+        {
+          if (flags & GTK_CELL_RENDERER_SELECTED)
+            renderer_state |= GTK_STATE_FLAG_SELECTED;
+
+          if (flags & GTK_CELL_RENDERER_PRELIT)
+            renderer_state |= GTK_STATE_FLAG_PRELIGHT;
+        }
+
+      gtk_style_context_set_state (style_context, renderer_state);
 
       cairo_save (cr);
 
       gdk_cairo_rectangle (cr, background_area);
       cairo_clip (cr);
 
-      gtk_paint_focus (gtk_widget_get_style (widget), cr,
-                       renderer_state, widget,
-                       gtk_cell_area_get_style_detail (area),
-                       render_data.focus_rect.x,     render_data.focus_rect.y,
-                       render_data.focus_rect.width, render_data.focus_rect.height);
+      gtk_render_focus (style_context, cr,
+                        render_data.focus_rect.x,     render_data.focus_rect.y,
+                        render_data.focus_rect.width, render_data.focus_rect.height);
 
       cairo_restore (cr);
     }
@@ -1775,56 +1784,6 @@ gtk_cell_area_render (GtkCellArea          *area,
                g_type_name (G_TYPE_FROM_INSTANCE (area)));
 }
 
-/**
- * gtk_cell_area_set_style_detail:
- * @area: a #GtkCellArea
- * @detail: the #GtkStyle detail string to set
- *
- * Sets the detail string used in any gtk_paint_*() functions
- * used by @area.
- *
- * Since: 3.0
- */
-void
-gtk_cell_area_set_style_detail (GtkCellArea *area,
-                                const gchar *detail)
-{
-  GtkCellAreaPrivate *priv;
-
-  g_return_if_fail (GTK_IS_CELL_AREA (area));
-
-  priv = area->priv;
-
-  if (g_strcmp0 (priv->style_detail, detail) != 0)
-    {
-      g_free (priv->style_detail);
-      priv->style_detail = g_strdup (detail);
-    }
-}
-
-/**
- * gtk_cell_area_get_style_detail:
- * @area: a #GtkCellArea
- *
- * Gets the detail string used in any gtk_paint_*() functions
- * used by @area.
- *
- * Return value: the detail string, the string belongs to the area and should not be freed.
- *
- * Since: 3.0
- */
-G_CONST_RETURN gchar *
-gtk_cell_area_get_style_detail (GtkCellArea *area)
-{
-  GtkCellAreaPrivate *priv;
-
-  g_return_val_if_fail (GTK_IS_CELL_AREA (area), NULL);
-
-  priv = area->priv;
-
-  return priv->style_detail;
-}
-
 static gboolean
 get_cell_allocation (GtkCellRenderer        *renderer,
                      const GdkRectangle     *cell_area,
diff --git a/gtk/gtkcellarea.h b/gtk/gtkcellarea.h
index 78d5e95..52abe23 100644
--- a/gtk/gtkcellarea.h
+++ b/gtk/gtkcellarea.h
@@ -311,10 +311,6 @@ void                  gtk_cell_area_render                         (GtkCellArea
                                                                     const GdkRectangle   *cell_area,
                                                                     GtkCellRendererState  flags,
                                                                     gboolean              paint_focus);
-void                  gtk_cell_area_set_style_detail               (GtkCellArea          *area,
-                                                                    const gchar          *detail);
-G_CONST_RETURN gchar *gtk_cell_area_get_style_detail               (GtkCellArea          *area);
-
 
 void                  gtk_cell_area_get_cell_allocation            (GtkCellArea          *area,
                                                                     GtkCellAreaContext   *context,
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 47dc4c7..686eb9c 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1119,8 +1119,6 @@ gtk_icon_view_constructor (GType               type,
   if (GTK_IS_ORIENTABLE (priv->cell_area))
     gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->cell_area), priv->item_orientation);
 
-  gtk_cell_area_set_style_detail (priv->cell_area, "icon_view");
-
   priv->cell_area_context = gtk_cell_area_create_context (priv->cell_area);
 
   priv->add_editable_id = 
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index eebcf5e..98a7746 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -496,8 +496,6 @@ gtk_tree_view_column_constructor (GType                    type,
       g_object_ref_sink (priv->cell_area);
     }
 
-  gtk_cell_area_set_style_detail (priv->cell_area, "treeview");
-
   priv->add_editable_signal =
     g_signal_connect (priv->cell_area, "add-editable",
 		      G_CALLBACK (gtk_tree_view_column_add_editable_callback),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]