forked from AuroraMiddleware/gtk
Bug 539377 – Unnecessary warnings when GtkTreeView is not realized
Adapt gtk_tree_view_get_path_at_pos() and gtk_tree_view_get_drag_dest_row() to just return FALSE when bin_window is NULL and not hit a warning. Makes this case consistent with the tree view not having a model. Documentation has been updated to clarify this, unit test has been added. Fixes bug 539377, based on a patch by Bjorn Lindqvist.
This commit is contained in:
parent
ff10f9ce02
commit
069a593b0f
@ -12642,7 +12642,8 @@ gtk_tree_view_get_bin_window (GtkTreeView *tree_view)
|
||||
* with the column at that point. @cell_x and @cell_y return the coordinates
|
||||
* relative to the cell background (i.e. the @background_area passed to
|
||||
* gtk_cell_renderer_render()). This function is only meaningful if
|
||||
* @tree_view is realized.
|
||||
* @tree_view is realized. Therefore this function will always return %FALSE
|
||||
* if @tree_view is not realized or does not have a model.
|
||||
*
|
||||
* For converting widget coordinates (eg. the ones you get from
|
||||
* GtkWidget::query-tooltip), please see
|
||||
@ -12664,13 +12665,15 @@ gtk_tree_view_get_path_at_pos (GtkTreeView *tree_view,
|
||||
gint y_offset;
|
||||
|
||||
g_return_val_if_fail (tree_view != NULL, FALSE);
|
||||
g_return_val_if_fail (tree_view->priv->bin_window != NULL, FALSE);
|
||||
|
||||
if (path)
|
||||
*path = NULL;
|
||||
if (column)
|
||||
*column = NULL;
|
||||
|
||||
if (tree_view->priv->bin_window == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return FALSE;
|
||||
|
||||
@ -13493,9 +13496,12 @@ gtk_tree_view_get_drag_dest_row (GtkTreeView *tree_view,
|
||||
* @pos: Return location for the drop position, or %NULL
|
||||
*
|
||||
* Determines the destination row for a given position. @drag_x and
|
||||
* @drag_y are expected to be in widget coordinates.
|
||||
* @drag_y are expected to be in widget coordinates. This function is only
|
||||
* meaningful if @tree_view is realized. Therefore this function will always
|
||||
* return %FALSE if @tree_view is not realized or does not have a model.
|
||||
*
|
||||
* Return value: whether there is a row at the given position.
|
||||
* Return value: whether there is a row at the given position, %TRUE if this
|
||||
* is indeed the case.
|
||||
**/
|
||||
gboolean
|
||||
gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
|
||||
@ -13519,12 +13525,13 @@ gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
|
||||
g_return_val_if_fail (tree_view != NULL, FALSE);
|
||||
g_return_val_if_fail (drag_x >= 0, FALSE);
|
||||
g_return_val_if_fail (drag_y >= 0, FALSE);
|
||||
g_return_val_if_fail (tree_view->priv->bin_window != NULL, FALSE);
|
||||
|
||||
|
||||
if (path)
|
||||
*path = NULL;
|
||||
|
||||
if (tree_view->priv->bin_window == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -69,6 +69,33 @@ test_bug_546005 (void)
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
test_bug_539377 (void)
|
||||
{
|
||||
GtkWidget *view;
|
||||
GtkTreePath *path;
|
||||
GtkListStore *list_store;
|
||||
|
||||
/* Test provided by Bjorn Lindqvist */
|
||||
|
||||
/* Non-realized view, no model */
|
||||
view = gtk_tree_view_new ();
|
||||
g_assert (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view), 10, 10, &path,
|
||||
NULL, NULL, NULL) == FALSE);
|
||||
g_assert (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), 10, 10,
|
||||
&path, NULL) == FALSE);
|
||||
|
||||
/* Non-realized view, with model */
|
||||
list_store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (view),
|
||||
GTK_TREE_MODEL (list_store));
|
||||
|
||||
g_assert (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view), 10, 10, &path,
|
||||
NULL, NULL, NULL) == FALSE);
|
||||
g_assert (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), 10, 10,
|
||||
&path, NULL) == FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
@ -76,6 +103,7 @@ main (int argc,
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/TreeView/cursor/bug-546005", test_bug_546005);
|
||||
g_test_add_func ("/TreeView/cursor/bug-539377", test_bug_539377);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user