[gtk+] Add API to get x position of treeview columns



commit eeca20a800be92ef322473d1a065d5d1f8351449
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 10 00:09:25 2011 -0400

    Add API to get x position of treeview columns
    
    Their width was already available.

 gtk/gtk.symbols         |    1 +
 gtk/gtktreeviewcolumn.c |   37 +++++++++++++++++++++++++++++++++++++
 gtk/gtktreeviewcolumn.h |    1 +
 3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index c6def71..97b9790 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -3278,6 +3278,7 @@ gtk_tree_view_column_get_type
 gtk_tree_view_column_get_visible
 gtk_tree_view_column_get_widget
 gtk_tree_view_column_get_width
+gtk_tree_view_column_get_x_offset
 gtk_tree_view_column_new
 gtk_tree_view_column_new_with_area
 gtk_tree_view_column_new_with_attributes
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index bd8cebe..c97f8e5 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -142,6 +142,7 @@ struct _GtkTreeViewColumnPrivate
   GtkTreeViewColumnSizing column_type;
   gint padding;
   gint resized_width;
+  gint x_offset;
   gint width;
   gint fixed_width;
   gint min_width;
@@ -183,6 +184,7 @@ enum
   PROP_0,
   PROP_VISIBLE,
   PROP_RESIZABLE,
+  PROP_X_OFFSET,
   PROP_WIDTH,
   PROP_SPACING,
   PROP_SIZING,
@@ -257,6 +259,16 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
                                                          GTK_PARAM_READWRITE));
   
   g_object_class_install_property (object_class,
+                                   PROP_X_OFFSET,
+                                   g_param_spec_int ("x-offset",
+                                                     P_("X position"),
+                                                     P_("Current X position of the column"),
+                                                     -G_MAXINT,
+                                                     G_MAXINT,
+                                                     0,
+                                                     GTK_PARAM_READABLE));
+
+  g_object_class_install_property (object_class,
                                    PROP_WIDTH,
                                    g_param_spec_int ("width",
 						     P_("Width"),
@@ -687,6 +699,11 @@ gtk_tree_view_column_get_property (GObject         *object,
                            gtk_tree_view_column_get_resizable (tree_column));
       break;
 
+    case PROP_X_OFFSET:
+      g_value_set_int (value,
+                       gtk_tree_view_column_get_x_offset (tree_column));
+      break;
+
     case PROP_WIDTH:
       g_value_set_int (value,
                        gtk_tree_view_column_get_width (tree_column));
@@ -2049,6 +2066,24 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
   return tree_column->priv->width;
 }
 
+/**
+ * gtk_tree_view_column_get_x_offset:
+ * @tree_column: A #GtkTreeViewColumn.
+ * 
+ * Returns the current X offset of @tree_column in pixels.
+ * 
+ * Return value: The current X offset of @tree_column.
+ *
+ * Since: 3.2
+ */
+gint
+gtk_tree_view_column_get_x_offset (GtkTreeViewColumn *tree_column)
+{
+  g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), 0);
+
+  return tree_column->priv->x_offset;
+}
+
 gint
 _gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column)
 {
@@ -2113,6 +2148,7 @@ _gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
   if (priv->width != width)
     gtk_widget_queue_draw (priv->tree_view);
 
+  priv->x_offset = x_offset;
   priv->width = width;
 
   gtk_cell_area_context_allocate (priv->cell_area_context, priv->width - priv->padding, -1);
@@ -2136,6 +2172,7 @@ _gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
 			      TREE_VIEW_DRAG_WIDTH, allocation.height);
     }
 
+  g_object_notify (G_OBJECT (tree_column), "x-offset");
   g_object_notify (G_OBJECT (tree_column), "width");
 }
 
diff --git a/gtk/gtktreeviewcolumn.h b/gtk/gtktreeviewcolumn.h
index f964177..c6b2e79 100644
--- a/gtk/gtktreeviewcolumn.h
+++ b/gtk/gtktreeviewcolumn.h
@@ -142,6 +142,7 @@ gboolean                gtk_tree_view_column_get_resizable       (GtkTreeViewCol
 void                    gtk_tree_view_column_set_sizing          (GtkTreeViewColumn       *tree_column,
 								  GtkTreeViewColumnSizing  type);
 GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing          (GtkTreeViewColumn       *tree_column);
+gint                    gtk_tree_view_column_get_x_offset        (GtkTreeViewColumn       *tree_column);
 gint                    gtk_tree_view_column_get_width           (GtkTreeViewColumn       *tree_column);
 gint                    gtk_tree_view_column_get_fixed_width     (GtkTreeViewColumn       *tree_column);
 void                    gtk_tree_view_column_set_fixed_width     (GtkTreeViewColumn       *tree_column,



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