Example #1
0
static void
test_position (GtkTreeView *tree_view,
	       GtkTreePath *path,
	       gboolean     use_align,
	       gdouble      row_align)
{
	gint pos;
	gchar *path_str;
	GdkRectangle rect;
	GtkTreeModel *model;
	gint row_start;

	/* Get the location of the path we scrolled to */
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (tree_view),
					   path, NULL, &rect);

	row_start = get_row_start_for_index (GTK_TREE_VIEW (tree_view),
					     gtk_tree_path_get_indices (path)[0]);

	/* Ugh */
	pos = get_pos_from_path (GTK_TREE_VIEW (tree_view),
				 path, rect.height,
			         gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view)));

	/* This is only tested for during test_single() */
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
	if (gtk_tree_model_iter_n_children (model, NULL) == 1) {
                GtkAllocation allocation;
		GtkTreePath *tmppath;

		/* Test nothing is dangling at the bottom; read
		 * description for test_single() for more information.
		 */

		/* FIXME: hardcoded width */
                gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view), 0, allocation.height - 30, &tmppath, NULL, NULL, NULL)) {
			g_assert_not_reached ();
			gtk_tree_path_free (tmppath);
		}
	}

	path_str = gtk_tree_path_to_string (path);
	if (use_align) {
		assert_position_with_align (tree_view, pos, rect.y,
                                            row_start, rect.height, row_align);
	} else {
		assert_position_without_align (tree_view, row_start, rect.height);
	}

	g_free (path_str);
}
Example #2
0
static enum Pos
get_pos_from_path (GtkTreeView   *tree_view,
		   GtkTreePath   *path,
		   gdouble        row_height,
		   GtkAdjustment *vadjustment)
{
	int row_start;

	row_start = get_row_start_for_index (tree_view,
					     gtk_tree_path_get_indices (path)[0]);

	if (row_start + row_height < gtk_adjustment_get_page_size (vadjustment))
		return POS_TOP;

	if (row_start >= gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment))
		return POS_BOTTOM;

	return POS_CENTER;
}
Example #3
0
static enum Pos
get_pos_from_path (GtkTreeView   *tree_view,
		   GtkTreePath   *path,
		   gint           row_height,
		   GtkAdjustment *vadj)
{
	int row_start;

	row_start = get_row_start_for_index (tree_view,
					     gtk_tree_path_get_indices (path)[0]);

	if (row_start + row_height < vadj->page_size)
		return POS_TOP;

	if (row_start >= vadj->upper - vadj->page_size)
		return POS_BOTTOM;

	return POS_CENTER;
}