[gtk/gtk-3-24] TreeMenu: Don't manually reinvent g_list_index()
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24] TreeMenu: Don't manually reinvent g_list_index()
- Date: Wed, 7 Nov 2018 20:57:05 +0000 (UTC)
commit 08bafb4a52e300a85d1246e9229d33b0a264c5ec
Author: Daniel Boles <dboles src gmail com>
Date: Sat Oct 20 15:19:11 2018 +0100
TreeMenu: Don't manually reinvent g_list_index()
g_list_index() "Gets the position of the element containing the given
data (starting from 0)." That is exactly what we were manually doing.
gtk/gtktreemenu.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtktreemenu.c b/gtk/gtktreemenu.c
index 4b12553bef..90408e4b99 100644
--- a/gtk/gtktreemenu.c
+++ b/gtk/gtktreemenu.c
@@ -988,18 +988,11 @@ static gint
menu_item_position (GtkTreeMenu *menu,
GtkWidget *item)
{
- GList *children, *l;
+ GList *children;
gint position;
children = gtk_container_get_children (GTK_CONTAINER (menu));
- for (position = 0, l = children; l; position++, l = l->next)
- {
- GtkWidget *iitem = l->data;
-
- if (item == iitem)
- break;
- }
-
+ position = g_list_index (children, item);
g_list_free (children);
return position;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]