[virt-tools-list] [PATCH virt-viewer 08/11] Introduce ISO List dialog

Eduardo Lima (Etrunko) etrunko at redhat.com
Mon Jul 18 02:13:08 UTC 2016


Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
 src/Makefile.am                            |   3 +
 src/remote-viewer-iso-list-dialog.c        | 115 +++++++++++++++++++
 src/remote-viewer-iso-list-dialog.h        |  58 ++++++++++
 src/resources/ui/remote-viewer-iso-list.ui | 174 +++++++++++++++++++++++++++++
 src/resources/virt-viewer.gresource.xml    |   1 +
 5 files changed, 351 insertions(+)
 create mode 100644 src/remote-viewer-iso-list-dialog.c
 create mode 100644 src/remote-viewer-iso-list-dialog.h
 create mode 100644 src/resources/ui/remote-viewer-iso-list.ui

diff --git a/src/Makefile.am b/src/Makefile.am
index 0c48e40..66a73f8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ noinst_DATA = \
 	resources/ui/virt-viewer-vm-connection.ui \
 	resources/ui/virt-viewer-preferences.ui \
 	resources/ui/remote-viewer-connect.ui \
+	resources/ui/remote-viewer-iso-list.ui \
 	$(NULL)
 
 EXTRA_DIST =					\
@@ -96,6 +97,8 @@ if HAVE_OVIRT
 libvirt_viewer_la_SOURCES += \
 	ovirt-foreign-menu.h \
 	ovirt-foreign-menu.c \
+	remote-viewer-iso-list-dialog.c \
+	remote-viewer-iso-list-dialog.h \
 	$(NULL)
 endif
 
diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c
new file mode 100644
index 0000000..b3972ac
--- /dev/null
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -0,0 +1,115 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include "remote-viewer-iso-list-dialog.h"
+#include "virt-viewer-util.h"
+
+G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG)
+
+#define DIALOG_PRIVATE(o) \
+        (G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate))
+
+struct _RemoteViewerISOListDialogPrivate
+{
+    GtkBuilder *builder;
+    GtkWidget *notebook;
+};
+
+enum RemoteViewerIsoListDialogPages
+{
+    STATUS_PAGE = 0,
+    ISO_LIST_PAGE,
+};
+
+static void
+remote_viewer_iso_list_dialog_dispose(GObject *object)
+{
+    RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object);
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
+
+    g_clear_object(&priv->builder);
+
+    G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object);
+}
+
+static void
+remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    g_type_class_add_private(klass, sizeof(RemoteViewerISOListDialogPrivate));
+
+    object_class->dispose = remote_viewer_iso_list_dialog_dispose;
+}
+
+static void
+remote_viewer_iso_list_dialog_response(GtkDialog *dialog,
+                                       gint response_id,
+                                       gpointer user_data G_GNUC_UNUSED)
+{
+    RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog);
+    RemoteViewerISOListDialogPrivate *priv = self->priv;
+
+    if (response_id != GTK_RESPONSE_NONE)
+        return;
+
+    gtk_notebook_set_current_page(GTK_NOTEBOOK(priv->notebook), STATUS_PAGE);
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_CLOSE, FALSE);
+}
+
+static void
+remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self)
+{
+    GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(self));
+    RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self);
+
+    gtk_widget_set_size_request(GTK_WIDGET(self), 400, 300);
+    gtk_box_set_spacing(GTK_BOX(content), 6);
+
+    priv->builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui");
+    gtk_builder_connect_signals(priv->builder, self);
+
+    priv->notebook = GTK_WIDGET(gtk_builder_get_object(priv->builder, "notebook"));
+    gtk_box_pack_start(GTK_BOX(content), priv->notebook, TRUE, TRUE, 0);
+
+    gtk_dialog_add_buttons(GTK_DIALOG(self),
+                           _("Refresh"), GTK_RESPONSE_NONE,
+                           _("Close"), GTK_RESPONSE_CLOSE,
+                           NULL);
+
+    gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE);
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_CLOSE, FALSE);
+    g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL);
+}
+
+GtkWidget *
+remote_viewer_iso_list_dialog_new(GtkWindow *parent)
+{
+    return g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG,
+                        "title", _("Change CD"),
+                        "transient-for", parent,
+                        NULL);
+}
diff --git a/src/remote-viewer-iso-list-dialog.h b/src/remote-viewer-iso-list-dialog.h
new file mode 100644
index 0000000..def841b
--- /dev/null
+++ b/src/remote-viewer-iso-list-dialog.h
@@ -0,0 +1,58 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __REMOTE_VIEWER_ISO_LIST_DIALOG_H__
+#define __REMOTE_VIEWER_ISO_LIST_DIALOG_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG remote_viewer_iso_list_dialog_get_type()
+
+#define REMOTE_VIEWER_ISO_LIST_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialog))
+#define REMOTE_VIEWER_ISO_LIST_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogClass))
+#define REMOTE_VIEWER_IS_ISO_LIST_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG))
+#define REMOTE_VIEWER_IS_ISO_LIST_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG))
+#define REMOTE_VIEWER_ISO_LIST_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogClass))
+
+typedef struct _RemoteViewerISOListDialog RemoteViewerISOListDialog;
+typedef struct _RemoteViewerISOListDialogClass RemoteViewerISOListDialogClass;
+typedef struct _RemoteViewerISOListDialogPrivate RemoteViewerISOListDialogPrivate;
+
+struct _RemoteViewerISOListDialog
+{
+    GtkDialog parent;
+
+    RemoteViewerISOListDialogPrivate *priv;
+};
+
+struct _RemoteViewerISOListDialogClass
+{
+    GtkDialogClass parent_class;
+};
+
+GType remote_viewer_iso_list_dialog_get_type(void) G_GNUC_CONST;
+
+GtkWidget *remote_viewer_iso_list_dialog_new(GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* __REMOTE_VIEWER_ISO_LIST_DIALOG_H__ */
diff --git a/src/resources/ui/remote-viewer-iso-list.ui b/src/resources/ui/remote-viewer-iso-list.ui
new file mode 100644
index 0000000..bb2f6c6
--- /dev/null
+++ b/src/resources/ui/remote-viewer-iso-list.ui
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+  <requires lib="gtk+" version="3.16"/>
+  <object class="GtkListStore" id="liststore">
+    <columns>
+      <!-- column-name selected -->
+      <column type="gboolean"/>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name weight -->
+      <column type="gint"/>
+    </columns>
+  </object>
+  <object class="GtkNotebook" id="notebook">
+    <property name="visible">True</property>
+    <property name="can_focus">True</property>
+    <property name="show_tabs">False</property>
+    <property name="show_border">False</property>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="status">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Loading...</property>
+            <property name="yalign">1</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkSpinner" id="spinner">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="active">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child type="tab">
+      <object class="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">page 1</property>
+      </object>
+      <packing>
+        <property name="tab_fill">False</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="box2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Select ISO</property>
+            <property name="xalign">0</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="left_padding">12</property>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="view">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">liststore</property>
+                    <property name="headers_visible">False</property>
+                    <property name="rules_hint">True</property>
+                    <property name="search_column">1</property>
+                    <property name="enable_grid_lines">horizontal</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection" id="treeview-selection"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="selected_column">
+                        <property name="sizing">autosize</property>
+                        <property name="title" translatable="yes">Selected</property>
+                        <child>
+                          <object class="GtkCellRendererToggle" id="cellrenderertoggle"/>
+                          <attributes>
+                            <attribute name="active">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="name_column">
+                        <property name="title" translatable="yes">Name</property>
+                        <property name="expand">True</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext"/>
+                          <attributes>
+                            <attribute name="text">1</attribute>
+                            <attribute name="weight">2</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child type="tab">
+      <object class="GtkLabel" id="label2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">page 2</property>
+      </object>
+      <packing>
+        <property name="position">1</property>
+        <property name="tab_fill">False</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/src/resources/virt-viewer.gresource.xml b/src/resources/virt-viewer.gresource.xml
index b8ced29..0262533 100644
--- a/src/resources/virt-viewer.gresource.xml
+++ b/src/resources/virt-viewer.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/virt-manager/virt-viewer">
     <file>ui/remote-viewer-connect.ui</file>
+    <file>ui/remote-viewer-iso-list.ui</file>
     <file>ui/virt-viewer-about.ui</file>
     <file>ui/virt-viewer-auth.ui</file>
     <file>ui/virt-viewer-guest-details.ui</file>
-- 
2.7.4




More information about the virt-tools-list mailing list