~attente/unity-gtk-module/1208019-2

« back to all changes in this revision

Viewing changes to lib/unity-gtk-menu-item.c

  • Committer: William Hua
  • Date: 2014-04-24 03:51:09 UTC
  • Revision ID: william.hua@canonical.com-20140424035109-qvidewsv4l86hvff
Explain what we're doing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
533
533
            {
534
534
              item->child_shell = unity_gtk_menu_shell_new_internal (GTK_MENU_SHELL (submenu));
535
535
 
536
 
              /* LP: #1208019 */
 
536
              /*
 
537
               * Some applications like Eclipse populate their menus lazily,
 
538
               * i.e. when the user opens them. This is problematic for us
 
539
               * since we can't detect when the menu is opened in Unity. So we
 
540
               * can emit the show signal manually, which should force those
 
541
               * programs to load their menu contents eagerly. Note that
 
542
               * emitting this signal doesn't actually cause the menu to open.
 
543
               *
 
544
               * We defer signal emission to an idle because Eclipse sometimes
 
545
               * doesn't have the menu items ready immediately. The Source and
 
546
               * Refactor menus don't work in particular. My guess is that the
 
547
               * data for those menus is getting generated in a signal handler
 
548
               * for GtkMenuShell's insert, but that handler is getting called
 
549
               * just after this one. So emitting it directly here wouldn't
 
550
               * help at all since the data isn't ready at this point.
 
551
               * Deferring to an idle ensures that the data is ready.
 
552
               *
 
553
               * See LP: #1208019 for more information.
 
554
               */
537
555
              g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, g_signal_emit_show, g_object_ref (submenu), g_object_unref);
538
556
            }
539
557
        }