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