Introduce GtkMenuTracker

GtkMenuTracker folds a nested structure of sections in a GMenuModel into
a single linear menu, which it expresses to its user by means of 'insert
item at position' and 'remove item at position' callbacks.

The logic for where to insert separators and how to handle action
namespaces is contained within the tracker, removing the need to have
this logic duplicated in the 3 or 4 places that consume GMenuModel.

In comparison with the previous code, the tracker no longer completely
destroys and rebuilds menus every time a single change occurs.  As a
result, the new gtkmenu testcase now runs in approximately 3 seconds
instead of ~60 before.

https://bugzilla.gnome.org/show_bug.cgi?id=696468
This commit is contained in:
Ryan Lortie
2013-03-22 17:24:46 -04:00
parent e250e52175
commit 5617b58420
8 changed files with 598 additions and 328 deletions

View File

@ -34,7 +34,7 @@ G_GNUC_INTERNAL
GType gtk_model_menu_item_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
GtkMenuItem * gtk_model_menu_item_new (GMenuModel *model,
GtkWidget * gtk_model_menu_item_new (GMenuModel *model,
gint item_index,
const gchar *action_namespace);