48c875
From c2529913c72a00c5228d02a8e18a3991ac8ba00a Mon Sep 17 00:00:00 2001
48c875
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
48c875
Date: Fri, 8 Jul 2016 10:30:51 -0300
48c875
Subject: [PATCH 09/26] Introduce ISO List dialog
48c875
48c875
The motivation for this dialog started with rhbz #1310624, where it was
48c875
reported that foreign menu was causing too many debug messages to be
48c875
printed to the console, because remote viewer had a timeout of 5 seconds
48c875
to refresh the ISO list automatically.
48c875
48c875
As a workaround, the timeout was adjusted for 5 minutes, but it could
48c875
cause more problems, such as inconsistencies between what was shown by
48c875
remote viewer and what the server had configured.
48c875
48c875
Another issue caused by displaying the ISO files as a menu item was that
48c875
if the list was too long, it would take all the available space on the
48c875
screen. In the end, a menu item was not the correct choice of UI
48c875
component for this use case.
48c875
48c875
In order to solve both problems, we now present the ISO list as a
48c875
dedicated dialog, where the refresh of ISO list is triggered manually by
48c875
the user and the list is contained within the dialog, by displaying de
48c875
files in a treeview.
48c875
48c875
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
48c875
---
48c875
 po/POTFILES.in                             |   2 +
48c875
 src/Makefile.am                            |   3 +
48c875
 src/remote-viewer-iso-list-dialog.c        | 365 +++++++++++++++++++++++++++++
48c875
 src/remote-viewer-iso-list-dialog.h        |  58 +++++
48c875
 src/resources/ui/remote-viewer-iso-list.ui | 158 +++++++++++++
48c875
 src/resources/virt-viewer.gresource.xml    |   1 +
48c875
 6 files changed, 587 insertions(+)
48c875
 create mode 100644 src/remote-viewer-iso-list-dialog.c
48c875
 create mode 100644 src/remote-viewer-iso-list-dialog.h
48c875
 create mode 100644 src/resources/ui/remote-viewer-iso-list.ui
48c875
48c875
diff --git a/po/POTFILES.in b/po/POTFILES.in
48c875
index 69d9fef..371c242 100644
48c875
--- a/po/POTFILES.in
48c875
+++ b/po/POTFILES.in
48c875
@@ -1,9 +1,11 @@
48c875
 data/remote-viewer.appdata.xml.in
48c875
 data/remote-viewer.desktop.in
48c875
 data/virt-viewer-mime.xml.in
48c875
+src/remote-viewer-iso-list-dialog.c
48c875
 src/remote-viewer-main.c
48c875
 src/remote-viewer.c
48c875
 [type: gettext/glade] src/resources/ui/remote-viewer-connect.ui
48c875
+[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui
48c875
 [type: gettext/glade] src/resources/ui/virt-viewer-about.ui
48c875
 src/virt-viewer-app.c
48c875
 src/virt-viewer-auth.c
48c875
diff --git a/src/Makefile.am b/src/Makefile.am
48c875
index 272c4ff..9748277 100644
48c875
--- a/src/Makefile.am
48c875
+++ b/src/Makefile.am
48c875
@@ -13,6 +13,7 @@ noinst_DATA = \
48c875
 	resources/ui/virt-viewer-vm-connection.ui \
48c875
 	resources/ui/virt-viewer-preferences.ui \
48c875
 	resources/ui/remote-viewer-connect.ui \
48c875
+	resources/ui/remote-viewer-iso-list.ui \
48c875
 	resources/ui/virt-viewer-file-transfer-dialog.ui \
48c875
 	$(NULL)
48c875
 
48c875
@@ -97,6 +98,8 @@ if HAVE_OVIRT
48c875
 libvirt_viewer_la_SOURCES += \
48c875
 	ovirt-foreign-menu.h \
48c875
 	ovirt-foreign-menu.c \
48c875
+	remote-viewer-iso-list-dialog.c \
48c875
+	remote-viewer-iso-list-dialog.h \
48c875
 	$(NULL)
48c875
 endif
48c875
 
48c875
diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c
48c875
new file mode 100644
48c875
index 0000000..f23ddb2
48c875
--- /dev/null
48c875
+++ b/src/remote-viewer-iso-list-dialog.c
48c875
@@ -0,0 +1,365 @@
48c875
+/*
48c875
+ * Virt Viewer: A virtual machine console viewer
48c875
+ *
48c875
+ * Copyright (C) 2017 Red Hat, Inc.
48c875
+ *
48c875
+ * This program is free software; you can redistribute it and/or modify
48c875
+ * it under the terms of the GNU General Public License as published by
48c875
+ * the Free Software Foundation; either version 2 of the License, or
48c875
+ * (at your option) any later version.
48c875
+ *
48c875
+ * This program is distributed in the hope that it will be useful,
48c875
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
48c875
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
48c875
+ * GNU General Public License for more details.
48c875
+ *
48c875
+ * You should have received a copy of the GNU General Public License
48c875
+ * along with this program; if not, write to the Free Software
48c875
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48c875
+ */
48c875
+
48c875
+#include <config.h>
48c875
+
48c875
+#include <glib/gi18n.h>
48c875
+
48c875
+#include "remote-viewer-iso-list-dialog.h"
48c875
+#include "virt-viewer-util.h"
48c875
+#include "ovirt-foreign-menu.h"
48c875
+
48c875
+static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self);
48c875
+static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, const gchar *message);
48c875
+
48c875
+G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG)
48c875
+
48c875
+#define DIALOG_PRIVATE(o) \
48c875
+        (G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate))
48c875
+
48c875
+struct _RemoteViewerISOListDialogPrivate
48c875
+{
48c875
+    GtkListStore *list_store;
48c875
+    GtkWidget *status;
48c875
+    GtkWidget *spinner;
48c875
+    GtkWidget *stack;
48c875
+    GtkWidget *tree_view;
48c875
+    OvirtForeignMenu *foreign_menu;
48c875
+};
48c875
+
48c875
+enum RemoteViewerISOListDialogModel
48c875
+{
48c875
+    ISO_IS_ACTIVE = 0,
48c875
+    ISO_NAME,
48c875
+    FONT_WEIGHT,
48c875
+};
48c875
+
48c875
+enum RemoteViewerISOListDialogProperties {
48c875
+    PROP_0,
48c875
+    PROP_FOREIGN_MENU,
48c875
+};
48c875
+
48c875
+
48c875
+void remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data);
48c875
+void remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data);
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_dispose(GObject *object)
48c875
+{
48c875
+    RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object);
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+
48c875
+    if (priv->foreign_menu) {
48c875
+        g_signal_handlers_disconnect_by_data(priv->foreign_menu, object);
48c875
+        g_clear_object(&priv->foreign_menu);
48c875
+    }
48c875
+    G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object);
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_set_property(GObject *object, guint property_id,
48c875
+                                           const GValue *value, GParamSpec *pspec)
48c875
+{
48c875
+    RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object);
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+
48c875
+    switch (property_id) {
48c875
+    case PROP_FOREIGN_MENU:
48c875
+        priv->foreign_menu = g_value_dup_object(value);
48c875
+        break;
48c875
+    default:
48c875
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
48c875
+    }
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass)
48c875
+{
48c875
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
48c875
+
48c875
+    g_type_class_add_private(klass, sizeof(RemoteViewerISOListDialogPrivate));
48c875
+
48c875
+    object_class->dispose = remote_viewer_iso_list_dialog_dispose;
48c875
+    object_class->set_property = remote_viewer_iso_list_dialog_set_property;
48c875
+
48c875
+    g_object_class_install_property(object_class,
48c875
+                                    PROP_FOREIGN_MENU,
48c875
+                                    g_param_spec_object("foreign-menu",
48c875
+                                                        "oVirt Foreign Menu",
48c875
+                                                        "Object which is used as interface to oVirt",
48c875
+                                                        OVIRT_TYPE_FOREIGN_MENU,
48c875
+                                                        G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self)
48c875
+{
48c875
+    self->priv = DIALOG_PRIVATE(self);
48c875
+    gtk_stack_set_visible_child_full(GTK_STACK(self->priv->stack), "iso-list",
48c875
+                                     GTK_STACK_TRANSITION_TYPE_NONE);
48c875
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE);
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self)
48c875
+{
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+    gchar *current_iso = ovirt_foreign_menu_get_current_iso_name(self->priv->foreign_menu);
48c875
+    gboolean active = (g_strcmp0(current_iso, name) == 0);
48c875
+    gint weight = active ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
48c875
+    GtkTreeIter iter;
48c875
+
48c875
+    gtk_list_store_append(priv->list_store, &iter);
48c875
+    gtk_list_store_set(priv->list_store, &iter,
48c875
+                       ISO_IS_ACTIVE, active,
48c875
+                       ISO_NAME, name,
48c875
+                       FONT_WEIGHT, weight, -1);
48c875
+
48c875
+    if (active) {
48c875
+        GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(priv->list_store), &iter);
48c875
+        gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE);
48c875
+        gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5);
48c875
+        gtk_tree_path_free(path);
48c875
+    }
48c875
+
48c875
+    g_free(current_iso);
48c875
+}
48c875
+
48c875
+static void
48c875
+fetch_iso_names_cb(OvirtForeignMenu *foreign_menu,
48c875
+                   GAsyncResult *result,
48c875
+                   RemoteViewerISOListDialog *self)
48c875
+{
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+    GError *error = NULL;
48c875
+    GList *iso_list;
48c875
+
48c875
+    iso_list = ovirt_foreign_menu_fetch_iso_names_finish(foreign_menu, result, &error);
48c875
+
48c875
+    if (!iso_list) {
48c875
+        const gchar *msg = error ? error->message : _("Failed to fetch CD names");
48c875
+        gchar *markup = g_strdup_printf("%s", msg);
48c875
+
48c875
+        gtk_label_set_markup(GTK_LABEL(priv->status), markup);
48c875
+        gtk_spinner_stop(GTK_SPINNER(priv->spinner));
48c875
+        remote_viewer_iso_list_dialog_show_error(self, msg);
48c875
+        gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE);
48c875
+        g_free(markup);
48c875
+        g_clear_error(&error);
48c875
+        return;
48c875
+    }
48c875
+
48c875
+    g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, self);
48c875
+    remote_viewer_iso_list_dialog_show_files(self);
48c875
+}
48c875
+
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog *self)
48c875
+{
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+
48c875
+    gtk_list_store_clear(priv->list_store);
48c875
+    ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL,
48c875
+                                             (GAsyncReadyCallback) fetch_iso_names_cb,
48c875
+                                             self);
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_response(GtkDialog *dialog,
48c875
+                                       gint response_id,
48c875
+                                       gpointer user_data G_GNUC_UNUSED)
48c875
+{
48c875
+    RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog);
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+
48c875
+    if (response_id != GTK_RESPONSE_NONE)
48c875
+        return;
48c875
+
48c875
+    gtk_spinner_start(GTK_SPINNER(priv->spinner));
48c875
+    gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading..."));
48c875
+    gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status",
48c875
+                                     GTK_STACK_TRANSITION_TYPE_NONE);
48c875
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
48c875
+    remote_viewer_iso_list_dialog_refresh_iso_list(self);
48c875
+}
48c875
+
48c875
+void
48c875
+remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer G_GNUC_UNUSED,
48c875
+                                      gchar *path,
48c875
+                                      gpointer user_data)
48c875
+{
48c875
+    RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(user_data);
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+    GtkTreeModel *model = GTK_TREE_MODEL(priv->list_store);
48c875
+    GtkTreePath *tree_path = gtk_tree_path_new_from_string(path);
48c875
+    GtkTreeIter iter;
48c875
+    gboolean active;
48c875
+    gchar *name;
48c875
+
48c875
+    gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), tree_path, NULL, FALSE);
48c875
+    gtk_tree_model_get_iter(model, &iter, tree_path);
48c875
+    gtk_tree_model_get(model, &iter,
48c875
+                       ISO_IS_ACTIVE, &active,
48c875
+                       ISO_NAME, &name, -1);
48c875
+
48c875
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
48c875
+    gtk_widget_set_sensitive(priv->tree_view, FALSE);
48c875
+
48c875
+    ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, NULL,
48c875
+                                                  (GAsyncReadyCallback)ovirt_foreign_menu_iso_name_changed,
48c875
+                                                  self);
48c875
+    gtk_tree_path_free(tree_path);
48c875
+    g_free(name);
48c875
+}
48c875
+
48c875
+void
48c875
+remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view G_GNUC_UNUSED,
48c875
+                                            GtkTreePath *path,
48c875
+                                            GtkTreeViewColumn *col G_GNUC_UNUSED,
48c875
+                                            gpointer user_data)
48c875
+{
48c875
+    gchar *path_str = gtk_tree_path_to_string(path);
48c875
+    remote_viewer_iso_list_dialog_toggled(NULL, path_str, user_data);
48c875
+    g_free(path_str);
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self)
48c875
+{
48c875
+    GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(self));
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self);
48c875
+    GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui");
48c875
+    GtkCellRendererToggle *cell_renderer;
48c875
+
48c875
+    gtk_builder_connect_signals(builder, self);
48c875
+
48c875
+    priv->status = GTK_WIDGET(gtk_builder_get_object(builder, "status"));
48c875
+    priv->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner"));
48c875
+    priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack"));
48c875
+    gtk_box_pack_start(GTK_BOX(content), priv->stack, TRUE, TRUE, 0);
48c875
+
48c875
+    priv->list_store = GTK_LIST_STORE(gtk_builder_get_object(builder, "liststore"));
48c875
+    priv->tree_view = GTK_WIDGET(gtk_builder_get_object(builder, "view"));
48c875
+    cell_renderer = GTK_CELL_RENDERER_TOGGLE(gtk_builder_get_object(builder, "cellrenderertoggle"));
48c875
+    gtk_cell_renderer_toggle_set_radio(cell_renderer, TRUE);
48c875
+    gtk_cell_renderer_set_padding(GTK_CELL_RENDERER(cell_renderer), 6, 6);
48c875
+
48c875
+    g_object_unref(builder);
48c875
+
48c875
+    gtk_dialog_add_buttons(GTK_DIALOG(self),
48c875
+                           _("Refresh"), GTK_RESPONSE_NONE,
48c875
+                           _("Close"), GTK_RESPONSE_CLOSE,
48c875
+                           NULL);
48c875
+
48c875
+    gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE);
48c875
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
48c875
+    g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL);
48c875
+}
48c875
+
48c875
+static void
48c875
+remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self,
48c875
+                                         const gchar *message)
48c875
+{
48c875
+    GtkWidget *dialog;
48c875
+
48c875
+    g_warn_if_fail(message != NULL);
48c875
+
48c875
+    dialog = gtk_message_dialog_new(GTK_WINDOW(self),
48c875
+                                    GTK_DIALOG_DESTROY_WITH_PARENT,
48c875
+                                    GTK_MESSAGE_ERROR,
48c875
+                                    GTK_BUTTONS_CLOSE,
48c875
+                                    message ? message : _("Unspecified error"));
48c875
+    gtk_dialog_run(GTK_DIALOG(dialog));
48c875
+    gtk_widget_destroy(dialog);
48c875
+}
48c875
+
48c875
+static void
48c875
+ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu,
48c875
+                                    GAsyncResult *result,
48c875
+                                    RemoteViewerISOListDialog *self)
48c875
+{
48c875
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
48c875
+    GtkTreeModel *model = GTK_TREE_MODEL(priv->list_store);
48c875
+    gchar *current_iso;
48c875
+    GtkTreeIter iter;
48c875
+    gchar *name;
48c875
+    gboolean active, match = FALSE;
48c875
+    GError *error = NULL;
48c875
+
48c875
+    /* In the case of error, don't return early, because it is necessary to
48c875
+     * change the ISO back to the original, avoiding a possible inconsistency.
48c875
+     */
48c875
+    if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) {
48c875
+        remote_viewer_iso_list_dialog_show_error(self, error ? error->message : _("Failed to change CD"));
48c875
+        g_clear_error(&error);
48c875
+    }
48c875
+
48c875
+    if (!gtk_tree_model_get_iter_first(model, &iter))
48c875
+        return;
48c875
+
48c875
+    current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu);
48c875
+
48c875
+    do {
48c875
+        gtk_tree_model_get(model, &iter,
48c875
+                           ISO_IS_ACTIVE, &active,
48c875
+                           ISO_NAME, &name, -1);
48c875
+        match = (g_strcmp0(current_iso, name) == 0);
48c875
+
48c875
+        /* iso is not active anymore */
48c875
+        if (active && !match) {
48c875
+            gtk_list_store_set(priv->list_store, &iter,
48c875
+                               ISO_IS_ACTIVE, FALSE,
48c875
+                               FONT_WEIGHT, PANGO_WEIGHT_NORMAL, -1);
48c875
+        } else if (match) {
48c875
+            gtk_list_store_set(priv->list_store, &iter,
48c875
+                               ISO_IS_ACTIVE, TRUE,
48c875
+                               FONT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
48c875
+        }
48c875
+
48c875
+        g_free(name);
48c875
+    } while (gtk_tree_model_iter_next(model, &iter));
48c875
+
48c875
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE);
48c875
+    gtk_widget_set_sensitive(priv->tree_view, TRUE);
48c875
+    g_free(current_iso);
48c875
+}
48c875
+
48c875
+GtkWidget *
48c875
+remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu)
48c875
+{
48c875
+    GtkWidget *dialog;
48c875
+    RemoteViewerISOListDialog *self;
48c875
+
48c875
+    g_return_val_if_fail(foreign_menu != NULL, NULL);
48c875
+
48c875
+    dialog = g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG,
48c875
+                          "title", _("Change CD"),
48c875
+                          "transient-for", parent,
48c875
+                          "border-width", 18,
48c875
+                          "default-width", 400,
48c875
+                          "default-height", 300,
48c875
+                          "foreign-menu", foreign_menu,
48c875
+                          NULL);
48c875
+
48c875
+    self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog);
48c875
+    remote_viewer_iso_list_dialog_refresh_iso_list(self);
48c875
+    return dialog;
48c875
+}
48c875
diff --git a/src/remote-viewer-iso-list-dialog.h b/src/remote-viewer-iso-list-dialog.h
48c875
new file mode 100644
48c875
index 0000000..480777c
48c875
--- /dev/null
48c875
+++ b/src/remote-viewer-iso-list-dialog.h
48c875
@@ -0,0 +1,58 @@
48c875
+/*
48c875
+ * Virt Viewer: A virtual machine console viewer
48c875
+ *
48c875
+ * Copyright (C) 2017 Red Hat, Inc.
48c875
+ *
48c875
+ * This program is free software; you can redistribute it and/or modify
48c875
+ * it under the terms of the GNU General Public License as published by
48c875
+ * the Free Software Foundation; either version 2 of the License, or
48c875
+ * (at your option) any later version.
48c875
+ *
48c875
+ * This program is distributed in the hope that it will be useful,
48c875
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
48c875
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
48c875
+ * GNU General Public License for more details.
48c875
+ *
48c875
+ * You should have received a copy of the GNU General Public License
48c875
+ * along with this program; if not, write to the Free Software
48c875
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48c875
+ */
48c875
+
48c875
+#ifndef __REMOTE_VIEWER_ISO_LIST_DIALOG_H__
48c875
+#define __REMOTE_VIEWER_ISO_LIST_DIALOG_H__
48c875
+
48c875
+#include <gtk/gtk.h>
48c875
+
48c875
+G_BEGIN_DECLS
48c875
+
48c875
+#define REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG remote_viewer_iso_list_dialog_get_type()
48c875
+
48c875
+#define REMOTE_VIEWER_ISO_LIST_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialog))
48c875
+#define REMOTE_VIEWER_ISO_LIST_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogClass))
48c875
+#define REMOTE_VIEWER_IS_ISO_LIST_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG))
48c875
+#define REMOTE_VIEWER_IS_ISO_LIST_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG))
48c875
+#define REMOTE_VIEWER_ISO_LIST_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogClass))
48c875
+
48c875
+typedef struct _RemoteViewerISOListDialog RemoteViewerISOListDialog;
48c875
+typedef struct _RemoteViewerISOListDialogClass RemoteViewerISOListDialogClass;
48c875
+typedef struct _RemoteViewerISOListDialogPrivate RemoteViewerISOListDialogPrivate;
48c875
+
48c875
+struct _RemoteViewerISOListDialog
48c875
+{
48c875
+    GtkDialog parent;
48c875
+
48c875
+    RemoteViewerISOListDialogPrivate *priv;
48c875
+};
48c875
+
48c875
+struct _RemoteViewerISOListDialogClass
48c875
+{
48c875
+    GtkDialogClass parent_class;
48c875
+};
48c875
+
48c875
+GType remote_viewer_iso_list_dialog_get_type(void) G_GNUC_CONST;
48c875
+
48c875
+GtkWidget *remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu);
48c875
+
48c875
+G_END_DECLS
48c875
+
48c875
+#endif /* __REMOTE_VIEWER_ISO_LIST_DIALOG_H__ */
48c875
diff --git a/src/resources/ui/remote-viewer-iso-list.ui b/src/resources/ui/remote-viewer-iso-list.ui
48c875
new file mode 100644
48c875
index 0000000..ab1bdc4
48c875
--- /dev/null
48c875
+++ b/src/resources/ui/remote-viewer-iso-list.ui
48c875
@@ -0,0 +1,158 @@
48c875
+
48c875
+
48c875
+<interface>
48c875
+  <requires lib="gtk+" version="3.16"/>
48c875
+  <object class="GtkListStore" id="liststore">
48c875
+    <columns>
48c875
+      
48c875
+      <column type="gboolean"/>
48c875
+      
48c875
+      <column type="gchararray"/>
48c875
+      
48c875
+      <column type="gint"/>
48c875
+    </columns>
48c875
+  </object>
48c875
+  <object class="GtkStack" id="stack">
48c875
+    <property name="visible">True</property>
48c875
+    <property name="can_focus">False</property>
48c875
+    <child>
48c875
+      <object class="GtkBox">
48c875
+        <property name="visible">True</property>
48c875
+        <property name="can_focus">False</property>
48c875
+        <property name="orientation">vertical</property>
48c875
+        <property name="spacing">6</property>
48c875
+        <child>
48c875
+          <object class="GtkLabel" id="status">
48c875
+            <property name="visible">True</property>
48c875
+            <property name="can_focus">False</property>
48c875
+            <property name="label" translatable="yes">Loading...</property>
48c875
+            <property name="yalign">1</property>
48c875
+            <attributes>
48c875
+              <attribute name="weight" value="bold"/>
48c875
+            </attributes>
48c875
+          </object>
48c875
+          <packing>
48c875
+            <property name="expand">True</property>
48c875
+            <property name="fill">True</property>
48c875
+            <property name="position">0</property>
48c875
+          </packing>
48c875
+        </child>
48c875
+        <child>
48c875
+          <object class="GtkSpinner" id="spinner">
48c875
+            <property name="visible">True</property>
48c875
+            <property name="can_focus">False</property>
48c875
+            <property name="active">True</property>
48c875
+          </object>
48c875
+          <packing>
48c875
+            <property name="expand">False</property>
48c875
+            <property name="fill">True</property>
48c875
+            <property name="position">1</property>
48c875
+          </packing>
48c875
+        </child>
48c875
+        <child>
48c875
+          <object class="GtkLabel">
48c875
+            <property name="visible">True</property>
48c875
+            <property name="can_focus">False</property>
48c875
+          </object>
48c875
+          <packing>
48c875
+            <property name="expand">True</property>
48c875
+            <property name="fill">True</property>
48c875
+            <property name="position">2</property>
48c875
+          </packing>
48c875
+        </child>
48c875
+      </object>
48c875
+      <packing>
48c875
+        <property name="name">status</property>
48c875
+      </packing>
48c875
+    </child>
48c875
+    <child>
48c875
+      <object class="GtkBox">
48c875
+        <property name="visible">True</property>
48c875
+        <property name="can_focus">False</property>
48c875
+        <property name="orientation">vertical</property>
48c875
+        <property name="spacing">6</property>
48c875
+        <child>
48c875
+          <object class="GtkLabel">
48c875
+            <property name="visible">True</property>
48c875
+            <property name="can_focus">False</property>
48c875
+            <property name="label" translatable="yes">Select ISO</property>
48c875
+            <property name="xalign">0</property>
48c875
+            <attributes>
48c875
+              <attribute name="weight" value="bold"/>
48c875
+            </attributes>
48c875
+          </object>
48c875
+          <packing>
48c875
+            <property name="expand">False</property>
48c875
+            <property name="fill">True</property>
48c875
+            <property name="position">0</property>
48c875
+          </packing>
48c875
+        </child>
48c875
+        <child>
48c875
+          <object class="GtkAlignment" id="alignment">
48c875
+            <property name="visible">True</property>
48c875
+            <property name="can_focus">False</property>
48c875
+            <property name="bottom_padding">6</property>
48c875
+            <child>
48c875
+              <object class="GtkScrolledWindow">
48c875
+                <property name="visible">True</property>
48c875
+                <property name="can_focus">True</property>
48c875
+                <property name="shadow_type">in</property>
48c875
+                <child>
48c875
+                  <object class="GtkTreeView" id="view">
48c875
+                    <property name="visible">True</property>
48c875
+                    <property name="can_focus">True</property>
48c875
+                    <property name="model">liststore</property>
48c875
+                    <property name="headers_visible">False</property>
48c875
+                    <property name="rules_hint">True</property>
48c875
+                    <property name="search_column">1</property>
48c875
+                    <property name="enable_grid_lines">horizontal</property>
48c875
+                    <signal name="row-activated" handler="remote_viewer_iso_list_dialog_row_activated" swapped="no"/>
48c875
+                    <child internal-child="selection">
48c875
+                      <object class="GtkTreeSelection" id="treeview-selection"/>
48c875
+                    </child>
48c875
+                    <child>
48c875
+                      <object class="GtkTreeViewColumn" id="selected_column">
48c875
+                        <property name="sizing">autosize</property>
48c875
+                        <property name="title" translatable="yes">Selected</property>
48c875
+                        <child>
48c875
+                          <object class="GtkCellRendererToggle" id="cellrenderertoggle">
48c875
+                            <signal name="toggled" handler="remote_viewer_iso_list_dialog_toggled" swapped="no"/>
48c875
+                          </object>
48c875
+                          <attributes>
48c875
+                            <attribute name="active">0</attribute>
48c875
+                          </attributes>
48c875
+                        </child>
48c875
+                      </object>
48c875
+                    </child>
48c875
+                    <child>
48c875
+                      <object class="GtkTreeViewColumn" id="name_column">
48c875
+                        <property name="title" translatable="yes">Name</property>
48c875
+                        <property name="expand">True</property>
48c875
+                        <child>
48c875
+                          <object class="GtkCellRendererText" id="cellrenderertext"/>
48c875
+                          <attributes>
48c875
+                            <attribute name="text">1</attribute>
48c875
+                            <attribute name="weight">2</attribute>
48c875
+                          </attributes>
48c875
+                        </child>
48c875
+                      </object>
48c875
+                    </child>
48c875
+                  </object>
48c875
+                </child>
48c875
+              </object>
48c875
+            </child>
48c875
+          </object>
48c875
+          <packing>
48c875
+            <property name="expand">True</property>
48c875
+            <property name="fill">True</property>
48c875
+            <property name="position">1</property>
48c875
+          </packing>
48c875
+        </child>
48c875
+      </object>
48c875
+      <packing>
48c875
+        <property name="name">iso-list</property>
48c875
+        <property name="position">1</property>
48c875
+      </packing>
48c875
+    </child>
48c875
+  </object>
48c875
+</interface>
48c875
diff --git a/src/resources/virt-viewer.gresource.xml b/src/resources/virt-viewer.gresource.xml
48c875
index f9b4a9f..334fa47 100644
48c875
--- a/src/resources/virt-viewer.gresource.xml
48c875
+++ b/src/resources/virt-viewer.gresource.xml
48c875
@@ -2,6 +2,7 @@
48c875
 <gresources>
48c875
   <gresource prefix="/org/virt-manager/virt-viewer">
48c875
     <file>ui/remote-viewer-connect.ui</file>
48c875
+    <file>ui/remote-viewer-iso-list.ui</file>
48c875
     <file>ui/virt-viewer-about.ui</file>
48c875
     <file>ui/virt-viewer-auth.ui</file>
48c875
     <file>ui/virt-viewer-guest-details.ui</file>
48c875
-- 
48c875
2.12.0
48c875