[gtk+] Make GtkCellArea use GtkStyleContext



commit 41d6837fa2d3566b5a0a45fdc3bf92d8d5f70ed1
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                    |   77 +++++----------------------------
 gtk/gtkcellarea.h                    |    4 --
 gtk/gtkiconview.c                    |    2 -
 gtk/gtktreeviewcolumn.c              |    2 -
 6 files changed, 12 insertions(+), 77 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 1da47e2..c75d5bb 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -4426,8 +4426,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 3d75c0d..1b3ce2a 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -417,7 +417,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
@@ -428,7 +427,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 bd13672..9ee63ae 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 {
@@ -905,7 +902,6 @@ gtk_cell_area_finalize (GObject *object)
   g_hash_table_destroy (priv->focus_siblings);
 
   g_free (priv->current_path);
-  g_free (priv->style_detail);
 
   G_OBJECT_CLASS (gtk_cell_area_parent_class)->finalize (object);
 }
@@ -1103,8 +1099,6 @@ render_cell (GtkCellRenderer        *renderer,
           gdk_rectangle_union (&data->focus_rect, &cell_focus, &data->focus_rect);
         }
     }
-  else
-    flags &= ~GTK_CELL_RENDERER_FOCUSED;
 
   gtk_cell_renderer_render (renderer, data->cr, data->widget,
                             cell_background, &inner_area, flags);
@@ -1152,22 +1146,25 @@ 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);
+
+      renderer_state = gtk_cell_renderer_get_state (NULL, widget, flags);
+      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);
 
+      gtk_style_context_restore (style_context);
       cairo_restore (cr);
     }
 }
@@ -1776,56 +1773,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 2b0f707..e206605 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 2e2f3e9..602f5b1 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 ad338e8..809eec1 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]