mate-desktop/mate-panel — pull request #122 by emanuele-f (2013-09-23 11:56:16+00:00)
Title: 1.6

### Patch feature
This patch makes panel-menu-button and panel-menu-bar load at startup and reload when needed without the need of user activity on the menu. This makes sense since menu applet will be likely activated by the user during its session, so there so need to defer menu loading. Moreover, it results in a more reactive user experience.

### Background
This feature has been requested by many users for a long time. Some examples:
* Jan 17th 2006 https://bugs.launchpad.net/ubuntu/+source/gnome-panel/+bug/12040
* May 07th 2013 http://forums.mate-desktop.org/viewtopic.php?f=2&t=1770

### Brief changes description
##### When menu is created:
* Don't copy IconToLoad (refcount is 1)
* Don't free IconToLoad, so refcount is still 1 (GtkImage lives)
* Add IconToLoad to icons_loaded for theme_change

##### When theme changes:
* GtkImage is unmapped by destroy_image_menu_items
* icons_loaded are re-preloaded into icons_to_load
* icons_loaded is cleaned (but items are not freed becouse they still are into icons_to_load)
* icons_to_load loaded fill icons_loaded again

##### When menu tree changes:
* submenu_destroy destroys the entire menu tree
* "destroy" signal causes image_menu_items to be cleared, icon to be freed and icons_loaded to be cleared
* tree is rebuilt
* icons_loaded are rebuilt

##### When a menu is destroyed:
* submenu_destroy destroys the entire menu tree
* "destroy" signal causes image_menu_items to be cleared, icon to be freed and icons_loaded to be cleared

### Bugs fixes and improvements
* Possible memory leak: `orig:1891` attaches a signal callback to the image to clean it from image_menu_loaded. But, since menu is destroyed by gtk_widget_destroy and its children are not destroyed, the signal emitted. I fix this by implementing the *submenu_destroy* (`mod:234`)
* Useles icon_to_load_copy `orig:274`: this function create a copy of an IconToLoad to increment its .pixmap reference count, so that on free (`orig:573`) it is still alive. I remove this free and add the icon to icons_loaded, which is useful to rebuild icon on theme change

### Further improvements
* Most of the time in first menu loading is taken in reading **.desktop files**. Caching them would reduce startup time. See https://people.gnome.org/~lcolitti/gnome-startup/analysis/ (section Opening the main menu)
* Some **svg icons** really represent a bottle neck for the menu loading. Function *gdk_pixbuf_new_from_file* can stuck several seconds when Gnome theme is applied.