[virt-tools-list] [PATCH virt-viewer v4 06/12] Introduce ISO List dialog
Eduardo Lima (Etrunko)
etrunko at redhat.com
Tue Nov 1 20:33:36 UTC 2016
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
po/POTFILES.in | 2 +
src/Makefile.am | 3 +
src/remote-viewer-iso-list-dialog.c | 106 ++++++++++++++++++++
src/remote-viewer-iso-list-dialog.h | 58 +++++++++++
src/resources/ui/remote-viewer-iso-list.ui | 155 +++++++++++++++++++++++++++++
src/resources/virt-viewer.gresource.xml | 1 +
6 files changed, 325 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/po/POTFILES.in b/po/POTFILES.in
index 6775f53..54de445 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,9 +1,11 @@
data/remote-viewer.appdata.xml.in
data/remote-viewer.desktop.in
data/virt-viewer-mime.xml.in
+src/remote-viewer-iso-list-dialog.c
src/remote-viewer-main.c
src/remote-viewer.c
[type: gettext/glade] src/resources/ui/remote-viewer-connect.ui
+[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui
[type: gettext/glade] src/resources/ui/virt-viewer-about.ui
src/virt-viewer-app.c
src/virt-viewer-auth.c
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..0fbea28
--- /dev/null
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -0,0 +1,106 @@
+/*
+ * 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
+{
+ GtkWidget *stack;
+};
+
+static void
+remote_viewer_iso_list_dialog_dispose(GObject *object)
+{
+ 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_stack_set_visible_child_full(GTK_STACK(priv->stack), "status",
+ GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT);
+ 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);
+ GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui");
+
+ gtk_builder_connect_signals(builder, self);
+
+ priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack"));
+ gtk_box_pack_start(GTK_BOX(content), priv->stack, TRUE, TRUE, 0);
+
+ g_object_unref(builder);
+
+ 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,
+ "border-width", 18,
+ "default-width", 400,
+ "default-height", 300,
+ 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..624791f
--- /dev/null
+++ b/src/resources/ui/remote-viewer-iso-list.ui
@@ -0,0 +1,155 @@
+<?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="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <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">
+ <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>
+ <packing>
+ <property name="name">status</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <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">
+ <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="bottom_padding">6</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="name">iso-list</property>
+ <property name="position">1</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