[gtk+/native-layout] Completed missing peices of the GtkExtendedCell api



commit 6e705d7087816ed859fc9852c2607b27df08571a
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Jun 16 16:54:46 2010 -0400

    Completed missing peices of the GtkExtendedCell api

 gtk/gtk.symbols       |    2 +
 gtk/gtkextendedcell.c |   84 +++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkextendedcell.h |   47 ++++++++++++++++-----------
 3 files changed, 114 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index aac7d7a..e6c9341 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -1223,9 +1223,11 @@ gtk_expander_set_use_underline
 #if IN_FILE(__GTK_EXTENDED_CELL_C__)
 gtk_extended_cell_get_type G_GNUC_CONST
 gtk_extended_cell_get_desired_height
+gtk_extended_cell_get_desired_size
 gtk_extended_cell_get_desired_width
 gtk_extended_cell_get_height_for_width
 gtk_extended_cell_get_width_for_height
+gtk_extended_cell_is_height_for_width
 #endif
 #endif
 
diff --git a/gtk/gtkextendedcell.c b/gtk/gtkextendedcell.c
index 67c6bac..8b60a92 100644
--- a/gtk/gtkextendedcell.c
+++ b/gtk/gtkextendedcell.c
@@ -48,6 +48,33 @@ gtk_extended_cell_get_type (void)
 }
 
 /**
+ * gtk_extended_cell_is_height_for_width:
+ * @cell: a #GtkExtendedCell instance
+ *
+ * Gets whether the cell renderer prefers a height-for-width layout
+ * or a width-for-height layout.
+ *
+ * Returns: %TRUE if the cell prefers height-for-width, %FALSE if
+ * the cell should be treated with a width-for-height preference.
+ *
+ * Since: 3.0
+ */
+gboolean
+gtk_extended_cell_is_height_for_width (GtkExtendedCell *cell)
+{
+  GtkExtendedCellIface *iface;
+
+  g_return_val_if_fail (GTK_IS_EXTENDED_CELL (cell), FALSE);
+
+  iface = GTK_EXTENDED_CELL_GET_IFACE (cell);
+  if (iface->is_height_for_width)
+    return iface->is_height_for_width (cell);
+
+  /* By default cell renderers are height-for-width. */
+  return TRUE;
+}
+
+/**
  * gtk_extended_cell_get_desired_width:
  * @cell: a #GtkExtendedCell instance
  * @widget: the #GtkWidget this cell will be rendering to
@@ -189,5 +216,62 @@ gtk_extended_cell_get_height_for_width (GtkExtendedCell *cell,
 #endif
 }
 
+/**
+ * gtk_extended_cell_get_desired_size:
+ * @cell: a #GtkExtendedCell instance
+ * @request_natural: Whether to base the contextual request off of the
+ *     base natural or the base minimum
+ * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
+ * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
+ *
+ * Retrieves the minimum and natural size of a cell taking
+ * into account the widget's preference for height-for-width management.
+ *
+ * If request_natural is specified, the non-contextual natural value will
+ * be used to make the contextual request; otherwise the minimum will be used.
+ *
+ * Since: 3.0
+ */
+void
+gtk_extended_cell_get_desired_size (GtkExtendedCell *cell,
+				    GtkWidget       *widget,
+				    gboolean         request_natural,
+				    GtkRequisition  *minimum_size,
+				    GtkRequisition  *natural_size)
+{
+  gint min_width, nat_width;
+  gint min_height, nat_height;
+
+  g_return_if_fail (GTK_IS_EXTENDED_CELL (cell));
+
+  if (gtk_extended_cell_is_height_for_width (cell))
+    {
+      gtk_extended_cell_get_desired_width (cell, widget, &min_width, &nat_width);
+      gtk_extended_cell_get_height_for_width (cell, widget, 
+					      request_natural ? nat_width : min_width,
+					      &min_height, &nat_height);
+    }
+  else
+    {
+      gtk_extended_cell_get_desired_height (cell, widget, &min_height, &nat_height);
+      gtk_extended_cell_get_width_for_height (cell, widget, 
+					      request_natural ? nat_height : min_height,
+					      &min_width, &nat_width);
+    }
+
+  if (minimum_size)
+    {
+      minimum_size->width  = min_width;
+      minimum_size->height = min_height;
+    }
+
+  if (natural_size)
+    {
+      natural_size->width  = nat_width;
+      natural_size->height = nat_height;
+    }
+}
+
+
 #define __GTK_EXTENDED_CELL_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkextendedcell.h b/gtk/gtkextendedcell.h
index 8bd38f7..2946f0d 100644
--- a/gtk/gtkextendedcell.h
+++ b/gtk/gtkextendedcell.h
@@ -41,6 +41,7 @@ struct _GtkExtendedCellIface
   GTypeInterface g_iface;
 
   /* virtual table */
+  gboolean  (* is_height_for_width)  (GtkExtendedCell    *cell);
 
   void      (* get_desired_width)    (GtkExtendedCell    *cell,
 				      GtkWidget          *widget,
@@ -62,26 +63,34 @@ struct _GtkExtendedCellIface
 				      gint               *natural_height);
 };
 
-GType gtk_extended_cell_get_type             (void) G_GNUC_CONST;
+GType     gtk_extended_cell_get_type             (void) G_GNUC_CONST;
 
-void  gtk_extended_cell_get_desired_width    (GtkExtendedCell   *cell,
-					      GtkWidget         *widget,
-					      gint              *minimum_size,
-					      gint              *natural_size);
-void  gtk_extended_cell_get_desired_height   (GtkExtendedCell   *cell,
-					      GtkWidget         *widget,
-					      gint              *minimum_size,
-					      gint              *natural_size);
-void  gtk_extended_cell_get_width_for_height (GtkExtendedCell   *cell,
-					      GtkWidget         *widget,
-					      gint               height,
-					      gint              *minimum_width,
-					      gint              *natural_width);
-void  gtk_extended_cell_get_height_for_width (GtkExtendedCell   *cell,
-					      GtkWidget         *widget,
-					      gint               width,
-					      gint              *minimum_height,
-					      gint              *natural_height);
+gboolean  gtk_extended_cell_is_height_for_width  (GtkExtendedCell   *cell);
+
+void      gtk_extended_cell_get_desired_width    (GtkExtendedCell   *cell,
+						  GtkWidget         *widget,
+						  gint              *minimum_size,
+						  gint              *natural_size);
+void      gtk_extended_cell_get_desired_height   (GtkExtendedCell   *cell,
+						  GtkWidget         *widget,
+						  gint              *minimum_size,
+						  gint              *natural_size);
+void      gtk_extended_cell_get_width_for_height (GtkExtendedCell   *cell,
+						  GtkWidget         *widget,
+						  gint               height,
+						  gint              *minimum_width,
+						  gint              *natural_width);
+void      gtk_extended_cell_get_height_for_width (GtkExtendedCell   *cell,
+						  GtkWidget         *widget,
+						  gint               width,
+						  gint              *minimum_height,
+						  gint              *natural_height);
+
+void      gtk_extended_cell_get_desired_size     (GtkExtendedCell   *cell,
+						  GtkWidget         *widget,
+						  gboolean           request_natural,
+						  GtkRequisition    *minimum_size,
+						  GtkRequisition    *natural_size);
 
 G_END_DECLS
 



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