GNOME Bugzilla – Bug 666683
gtk_menu_reorder_child should send a signal to notify interested parties
Last modified: 2018-04-15 00:09:30 UTC
Hello! gtk_menu_reorder_child just quietly does its work and updates the way the widget is drawn. I think it would be nicer if it also sent out a signal when it happened. A) It would be analogous to "add" and "remove" signals. B) It seems common to have calls that change the visible state of a widget cause a signal (even if just a "notify::" one). C) There are consumers today that would be interested. I noticed because I was pointed at a bug [1] in libdbusmenu due to this. If ya'll agree that would be a good thing, I can work on whipping up a patch. Maybe a signal like "void reordered (GtkMenu *menu, GtkWidget *child, int old_pos, int new_pos, gpointer data)" ? [1] https://bugs.launchpad.net/dbusmenu/+bug/785852
I'd say you need a "position" child property and use the "child-notify::position" signal?
Created attachment 224566 [details] [review] Proposed patch How about this? It does not emit a signal on add or removal of items, but does emit a child-notify whenever an item changes position due to add/removal/reorder of other items. I figured it was best to not keep track of position state separately, since that might easily get out of sync, so I calculate the position of an item upon request. Seems like a request that won't happen often, and I'd rather optimize for maintainability in this case.
Created attachment 273014 [details] [review] Add "position" child property to track GtkMenuShell children
I did a noddy update to get this to apply on trunk - please review.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new