* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkbutton.h"
#include "gtkalignment.h"
#include "gtklabel.h"
-#include "gtkhbox.h"
+#include "gtkbox.h"
#include "gtkmarshalers.h"
#include "gtkarrow.h"
#include "gtkcellareacontext.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
+#include "a11y/gtktreeviewaccessible.h"
/**
GtkTreeViewColumnSizing column_type;
gint padding;
gint resized_width;
+ gint x_offset;
gint width;
gint fixed_width;
gint min_width;
PROP_0,
PROP_VISIBLE,
PROP_RESIZABLE,
+ PROP_X_OFFSET,
PROP_WIDTH,
PROP_SPACING,
PROP_SIZING,
FALSE,
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",
*
* The #GtkCellArea used to layout cell renderers for this column.
*
+ * If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area()
+ * a horizontally oriented #GtkCellAreaBox will be used.
+ *
* Since: 3.0
*/
g_object_class_install_property (object_class,
GtkTreeViewColumn *tree_column = (GtkTreeViewColumn *) object;
GtkTreeViewColumnPrivate *priv = tree_column->priv;
+ /* Remove this column from its treeview,
+ * in case this column is destroyed before its treeview.
+ */
+ if (priv->tree_view)
+ gtk_tree_view_remove_column (GTK_TREE_VIEW (priv->tree_view), tree_column);
+
if (priv->cell_area_context)
{
g_signal_handler_disconnect (priv->cell_area_context,
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));
if (event->type == GDK_BUTTON_PRESS &&
priv->reorderable &&
- ((GdkEventButton *)event)->button == 1)
+ ((GdkEventButton *)event)->button == GDK_BUTTON_PRIMARY)
{
priv->maybe_reordered = TRUE;
- gdk_window_get_pointer (gtk_button_get_event_window (GTK_BUTTON (widget)),
- &priv->drag_x,
- &priv->drag_y,
- NULL);
+ gdk_window_get_device_position (gtk_button_get_event_window (GTK_BUTTON (widget)),
+ gdk_event_get_device (event),
+ &priv->drag_x,
+ &priv->drag_y,
+ NULL);
gtk_widget_grab_focus (widget);
}
/**
* gtk_tree_view_column_new_with_attributes:
- * @title: The title to set the header to.
- * @cell: The #GtkCellRenderer.
- * @Varargs: A %NULL-terminated list of attributes.
- *
- * Creates a new #GtkTreeViewColumn with a number of default values. This is
- * equivalent to calling gtk_tree_view_column_set_title(),
+ * @title: The title to set the header to
+ * @cell: The #GtkCellRenderer
+ * @...: A %NULL-terminated list of attributes
+ *
+ * Creates a new #GtkTreeViewColumn with a number of default values.
+ * This is equivalent to calling gtk_tree_view_column_set_title(),
* gtk_tree_view_column_pack_start(), and
* gtk_tree_view_column_set_attributes() on the newly created #GtkTreeViewColumn.
*
/**
* gtk_tree_view_column_set_attributes:
- * @tree_column: A #GtkTreeViewColumn.
+ * @tree_column: A #GtkTreeViewColumn
* @cell_renderer: the #GtkCellRenderer we're setting the attributes of
- * @Varargs: A %NULL-terminated list of attributes.
- *
+ * @...: A %NULL-terminated list of attributes
+ *
* Sets the attributes in the list as the attributes of @tree_column.
* The attributes should be in attribute/column order, as in
* gtk_tree_view_column_add_attribute(). All existing attributes
* are removed, and replaced with the new attributes.
- **/
+ */
void
gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
_gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
if (priv->tree_view)
- _gtk_tree_view_reset_header_styles (GTK_TREE_VIEW (priv->tree_view));
+ {
+ _gtk_tree_view_reset_header_styles (GTK_TREE_VIEW (priv->tree_view));
+ _gtk_tree_view_accessible_toggle_visibility (GTK_TREE_VIEW (priv->tree_view),
+ tree_column);
+ }
gtk_tree_view_column_update_button (tree_column);
g_object_notify (G_OBJECT (tree_column), "visible");
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)
{
int width)
{
GtkTreeViewColumnPrivate *priv;
- GtkAllocation allocation;
gboolean rtl;
+ GtkAllocation allocation = { 0, 0, 0, 0 };
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
priv = tree_column->priv;
+ 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);
- allocation.x = x_offset;
- allocation.y = 0;
- allocation.width = width;
- allocation.height = _gtk_tree_view_get_header_height (GTK_TREE_VIEW (priv->tree_view));
+ if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
+ {
+ allocation.x = x_offset;
+ allocation.y = 0;
+ allocation.width = width;
+ allocation.height = _gtk_tree_view_get_header_height (GTK_TREE_VIEW (priv->tree_view));
- gtk_widget_size_allocate (priv->button, &allocation);
+ gtk_widget_size_allocate (priv->button, &allocation);
+ }
if (priv->window)
{
TREE_VIEW_DRAG_WIDTH, allocation.height);
}
+ g_object_notify (G_OBJECT (tree_column), "x-offset");
g_object_notify (G_OBJECT (tree_column), "width");
}
* Return value: the title of the column. This string should not be
* modified or freed.
**/
-G_CONST_RETURN gchar *
+const gchar *
gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), NULL);
* @tree_column: A #GtkTreeViewColumn.
* @clickable: %TRUE if the header is active.
*
- * Sets the header to be active if @active is %TRUE. When the header is active,
- * then it can take keyboard focus, and can be clicked.
+ * Sets the header to be active if @clickable is %TRUE. When the header is
+ * active, then it can take keyboard focus, and can be clicked.
**/
void
gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
priv = tree_column->priv;
+ if (! gtk_cell_area_has_renderer (priv->cell_area, cell_renderer))
+ return FALSE;
+
gtk_tree_view_get_background_area (GTK_TREE_VIEW (priv->tree_view),
NULL, tree_column, &cell_area);
&allocation);
if (x_offset)
- {
- GdkRectangle button_allocation;
+ *x_offset = allocation.x - cell_area.x;
- /* Retrieve column offset */
- gtk_widget_get_allocation (priv->button, &button_allocation);
- *x_offset = allocation.x - button_allocation.x;
- }
if (width)
*width = allocation.width;