Trouble with UIManager toolbar/menu re-ordering

Hi all,

I have an example app that I've posted to help illustrate a problem
I've encountered with the UIManager's XML re-ordering for
menus/toolbars after the initial loading has taken place.

I took the stock Gtkmm example project found in
book/menus_and_toolbars and added an extra placeholder called
"NewItems" into the toolbar XML string. I add items to it that are
deliberately out of order. When you click on any button that triggers
the on_action_others() signal, I add a new menu item plus reorder the
items with a new XML string. I make sure the old "UI" from this extra
XML merge id is removed first.

So in addition to the actions that are already present in the example
code, I added new actions:

Last, Middle and First (and also NewItem, but it is not added yet).
Here is the new XML fragment I'm adding:

	ui_info = "<ui>"
		"  <toolbar name='ToolBar'>"
		"   <placeholder name='NewItems'>"
		"     <toolitem action='Last'/>"
		"     <toolitem action='First'/>"
		"     <toolitem action='Middle'/>"
		"   </placeholder>"
		"  </toolbar>"
	m_newItemsMergeId = m_refUIManager->add_ui_from_string(ui_info);

Now the items appear on the toolbar in that order, because this is
done in the ExampleWindow constructor.

When you click on a button that invokes the on_action_others() method,
I attempt to alter the order of the toolbar, plus add the "NewItem"
action to the toolbar:

	m_refUIManager->remove_ui( m_newItemsMergeId );
	Glib::ustring ui_info =
		"  <toolbar name='ToolBar'>"
		"    <placeholder name='NewItems'>"
		"      <toolitem action='NewItem'/>"
		"      <toolitem action='First'/>"
		"      <toolitem action='Middle'/>"
		"      <toolitem action='Last'/>"
		"    </placeholder>"
		"  </toolbar>"
	m_newItemsMergeId = m_refUIManager->add_ui_from_string(ui_info);

Notice the the order has been changed, and the "NewItem" should appear
at first on the toolbar. Unfortunately, the buttons appear in the same
order as before, and the "NewItem" action shows up at the *end*, not
right after the placeholder.

I added a small hack to force the "NewItem" to be at position 3, and
that at least works correctly. But the UIManager seems to not be able
to recognize when a toolbar is reorder via XML merging. Oh, and this
bug happens with the menubar as well, so it's not just isolated in the
toolbar Gtkmm/+ code.

Speaking of that, I don't know if the problem is with gtkmm or with
the underlying gtk+ code. Has anyone else run across this? I have had
this issue for years and have always had to work around it.



Here is the example code:

dooglio gmail com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]