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

Christophe Fergeau cfergeau at redhat.com
Tue Jul 19 16:13:11 UTC 2016


On Sun, Jul 17, 2016 at 11:13:08PM -0300, Eduardo Lima (Etrunko) wrote:
> 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);

Can't most of this be done in glade as well?

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20160719/dd1bf114/attachment.sig>


More information about the virt-tools-list mailing list