[gtk+/cellarea-style-transitions: 3/9] cellrenderer: add get_current_state() vmethod



commit 2cec852cf57f094c48405009d48d083877b96bd6
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed May 11 00:29:51 2011 +0200

    cellrenderer: add get_current_state() vmethod
    
    This method is called in gtk_cell_renderer_get_state() and
    will be implemented by cell renderers to return the GtkStateFlags
    applying to the current cell renderer implementation state (i.e.
    a checked GtkCellRendererToggle would return GTK_STATE_FLAG_ACTIVE)

 gtk/gtkcellrenderer.c |   23 ++++++++++++++++++-----
 gtk/gtkcellrenderer.h |    3 ++-
 2 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index 80f267d..89cae62 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -104,6 +104,7 @@ static void gtk_cell_renderer_real_get_aligned_area              (GtkCellRendere
 								  GtkCellRendererState     flags,
 								  const GdkRectangle      *cell_area,
 								  GdkRectangle            *aligned_area);
+static GtkStateFlags gtk_cell_renderer_real_get_current_state    (GtkCellRenderer         *cell);
 
 
 struct _GtkCellRendererPrivate
@@ -200,6 +201,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
   class->get_preferred_width_for_height = gtk_cell_renderer_real_get_preferred_width_for_height;
   class->get_preferred_height_for_width = gtk_cell_renderer_real_get_preferred_height_for_width;
   class->get_aligned_area               = gtk_cell_renderer_real_get_aligned_area;
+  class->get_current_state              = gtk_cell_renderer_real_get_current_state;
 
   /**
    * GtkCellRenderer::editing-canceled:
@@ -1324,6 +1326,11 @@ gtk_cell_renderer_real_get_aligned_area (GtkCellRenderer         *cell,
   aligned_area->y += y_offset;
 }
 
+static GtkStateFlags
+gtk_cell_renderer_real_get_current_state (GtkCellRenderer *cell)
+{
+  return GTK_STATE_FLAG_NORMAL;
+}
 
 /* An internal convenience function for some containers to peek at the
  * cell alignment in a target allocation (used to draw focus and align
@@ -1700,13 +1707,19 @@ gtk_cell_renderer_get_state (GtkCellRenderer      *cell,
   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_is_sensitive (widget)) ||
-      (cell && !gtk_cell_renderer_get_sensitive (cell)) ||
-      (cell_state & GTK_CELL_RENDERER_INSENSITIVE) != 0)
+  if (cell)
     {
-      state |= GTK_STATE_FLAG_INSENSITIVE;
+      state = GTK_CELL_RENDERER_GET_CLASS (cell)->get_current_state (cell);
+
+      if (!gtk_cell_renderer_get_sensitive (cell))
+        state |= GTK_STATE_FLAG_INSENSITIVE;
     }
-  else
+
+  if ((widget && !gtk_widget_is_sensitive (widget)) ||
+      (cell_state & GTK_CELL_RENDERER_INSENSITIVE) != 0)
+    state |= GTK_STATE_FLAG_INSENSITIVE;
+
+  if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
     {
       if ((widget && gtk_widget_has_focus (widget)) &&
           (cell_state & GTK_CELL_RENDERER_FOCUSED) != 0)
diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h
index 8ae77f6..0c05d2f 100644
--- a/gtk/gtkcellrenderer.h
+++ b/gtk/gtkcellrenderer.h
@@ -150,11 +150,12 @@ struct _GtkCellRendererClass
 			     GtkCellEditable *editable,
 			     const gchar     *path);
 
+  GtkStateFlags (* get_current_state)                    (GtkCellRenderer      *cell);
+
   /* Padding for future expansion */
   void (*_gtk_reserved1) (void);
   void (*_gtk_reserved2) (void);
   void (*_gtk_reserved3) (void);
-  void (*_gtk_reserved4) (void);
 };
 
 GType              gtk_cell_renderer_get_type       (void) G_GNUC_CONST;



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