Overlay: Use @index_, not @position, in reorder()

We named the argument `position` in the code and doc arguments, but the
rest of the documentation referred to `index` instead. That was maybe
meant to hint at the child property named :index, but we can simply be
fully clear here. We can call the argument `index_`, replacing the local
variable with that name, thus avoiding any possible confusion with the
unrelated ::get-child-position, and refer users to :index for completion

`index_` is used instead of plain `index` in case anyone is #including
<strings.h> and getting the old index() function superseded by strchr();
see https://gitlab.gnome.org/GNOME/gtk/merge_requests/932#note_531149
This commit is contained in:
Daniel Boles 2019-06-13 18:25:07 +01:00
parent 8393c6d9be
commit 321a21959e
2 changed files with 9 additions and 9 deletions

View File

@ -534,13 +534,13 @@ gtk_overlay_remove (GtkContainer *container,
* gtk_overlay_reorder_overlay: * gtk_overlay_reorder_overlay:
* @overlay: a #GtkOverlay * @overlay: a #GtkOverlay
* @child: the overlaid #GtkWidget to move * @child: the overlaid #GtkWidget to move
* @position: the new index for @child in the list of overlay children * @index_: the new index for @child in the list of overlay children
* of @overlay, starting from 0. If negative, indicates the end of * of @overlay, starting from 0. If negative, indicates the end of
* the list * the list
* *
* Moves @child to a new @index in the list of @overlay children. * Moves @child to a new @index in the list of @overlay children.
* The list contains overlays in the order that these were * The list contains overlays in the order that these were
* added to @overlay. * added to @overlay by default. See also #GtkOverlay:index.
* *
* A widgets index in the @overlay children list determines which order * A widgets index in the @overlay children list determines which order
* the children are drawn if they overlap. The first child is drawn at * the children are drawn if they overlap. The first child is drawn at
@ -551,7 +551,7 @@ gtk_overlay_remove (GtkContainer *container,
void void
gtk_overlay_reorder_overlay (GtkOverlay *overlay, gtk_overlay_reorder_overlay (GtkOverlay *overlay,
GtkWidget *child, GtkWidget *child,
gint position) int index_)
{ {
GtkOverlayPrivate *priv; GtkOverlayPrivate *priv;
GSList *old_link; GSList *old_link;
@ -580,15 +580,15 @@ gtk_overlay_reorder_overlay (GtkOverlay *overlay,
g_return_if_fail (old_link != NULL); g_return_if_fail (old_link != NULL);
if (position < 0) if (index_ < 0)
{ {
new_link = NULL; new_link = NULL;
index = g_slist_length (priv->children) - 1; index = g_slist_length (priv->children) - 1;
} }
else else
{ {
new_link = g_slist_nth (priv->children, position); new_link = g_slist_nth (priv->children, index_);
index = MIN (position, g_slist_length (priv->children) - 1); index = MIN (index_, g_slist_length (priv->children) - 1);
} }
if (index == old_index) if (index == old_index)

View File

@ -86,7 +86,7 @@ void gtk_overlay_add_overlay (GtkOverlay *overlay,
GDK_AVAILABLE_IN_3_18 GDK_AVAILABLE_IN_3_18
void gtk_overlay_reorder_overlay (GtkOverlay *overlay, void gtk_overlay_reorder_overlay (GtkOverlay *overlay,
GtkWidget *child, GtkWidget *child,
gint position); int index_);
GDK_AVAILABLE_IN_3_18 GDK_AVAILABLE_IN_3_18
gboolean gtk_overlay_get_overlay_pass_through (GtkOverlay *overlay, gboolean gtk_overlay_get_overlay_pass_through (GtkOverlay *overlay,
GtkWidget *widget); GtkWidget *widget);