[virt-tools-list] [virt-viewer 1/3] foreign-menu: Don't show empty foreign menu on secondary displays
Christophe Fergeau
cfergeau at redhat.com
Thu Mar 12 16:54:06 UTC 2015
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.
---
src/ovirt-foreign-menu.c | 3 +++
src/remote-viewer.c | 7 ++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 0de13e5..7c95e4c 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -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) {
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 3c81650..12bd912 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -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);
}
--
2.1.0
More information about the virt-tools-list
mailing list