Given a Gtk.MenuBar with some MenuItems, I'm looking for a way to rearrange the order in which the MenuItems appear.
Here's a basic MenuBar with two MenuItems "foo" and "bar":
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
win= Gtk.Window()
mbar= Gtk.MenuBar()
win.add(mbar)
m1= Gtk.MenuItem('foo')
mbar.append(m1)
m2= Gtk.MenuItem('bar')
mbar.append(m2)
win.connect('destroy', Gtk.main_quit)
win.show_all()
Gtk.main()
The "foo" MenuItem will be left of "bar". I want to now move "bar" to the left of "foo".
Unlike the Menu class, MenuBar does not have a reorder_child
method:
mbar.reorder_child(m2, 0)
# throws: 'MenuBar' object has no attribute 'reorder_child'
Neither does it have a "position" child property like many other container widgets.
mbar.child_set_property(m2, 'position', 0)
# shows warning: container class 'GtkMenuBar' has no child property named 'position'
So the only solution I could think of was to remove "bar" and then insert it at the desired location:
mbar.remove(m2)
mbar.insert(m2, 0)
# works
So my question is: Is there no better way to reorder MenuItems in a MenuBar? Other container widgets provide a method to reorder their children, so surely the MenuBar should as well?