foreign-menu: Don't show empty foreign menu on secondary displays

When using ovirt://, the foreign menu will only be shown in the primary
window after getting notified about OvirtForeignMenu::files (ie when
it managed to fetch some ISO files to show in the foreign menu).

However, for secondary windows, the foreign menu will be added to the
window even if there are no files to show. This commit makes sure we
destroy the window foreign menu whenever it would be empty.
This commit is contained in:
Christophe Fergeau 2015-03-12 17:11:25 +01:00
parent f2967d0d88
commit 32d0ae09b8
2 changed files with 9 additions and 1 deletions

View File

@ -467,6 +467,9 @@ GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu)
char *current_iso;
g_debug("Creating GtkMenu for foreign menu");
if (foreign_menu->priv->iso_names == NULL) {
return NULL;
}
current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu);
gtk_menu = gtk_menu_new();
for (it = foreign_menu->priv->iso_names; it != NULL; it = it->next) {

View File

@ -757,7 +757,12 @@ ovirt_foreign_menu_update(RemoteViewer *app, VirtViewerWindow *win)
}
submenu = ovirt_foreign_menu_get_gtk_menu(app->priv->ovirt_foreign_menu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu), submenu);
if (submenu != NULL) {
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu), submenu);
} else {
/* No items to show, no point in showing the menu */
g_object_set_data(G_OBJECT(win), "foreign-menu", NULL);
}
gtk_widget_show_all(menu);
}