[virt-tools-list] [PATCH virt-viewer 2/4] Run ISO dialog when 'Change CD' menu is activated
Eduardo Lima (Etrunko)
etrunko at redhat.com
Tue Jan 24 11:46:55 UTC 2017
On 24/01/17 09:11, Christophe Fergeau wrote:
> On Mon, Jan 23, 2017 at 05:28:14PM -0200, Eduardo Lima (Etrunko) wrote:
>> Also moves 'Change CD' menu item from the toplevel menu to a subitem
>> under 'File' toplevel menu.
>>
>> In order to avoid object interdependency, it is necessary to make the
>> ovirt foreign-menu pointer from RemoteViewer, acessible via property, so
>
> 'accessible'. Behaviour of the menu with this patch is quite odd, maybe
> a few bits from the next patch belong in here? However, I think I'd just
> merge both patches (?).
I think it is a good idea, indeed, will do it, and also "merge" de
commit messages.
>
> Apart from this,
> Acked-by: Christophe Fergeau <cfergeau at redhat.com>
>
> Christophe
>
>> it can be passed to the dialog as an opaque GObject.
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
>> ---
>> src/remote-viewer.c | 37 +++++++++++++++++++++++++++++++++++++
>> src/resources/ui/virt-viewer.ui | 19 ++++++++++---------
>> src/virt-viewer-window.c | 37 +++++++++++++++++++++++++++++++++++++
>> 3 files changed, 84 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
>> index c84a35b..29d7db1 100644
>> --- a/src/remote-viewer.c
>> +++ b/src/remote-viewer.c
>> @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
>> #define GET_PRIVATE(o) \
>> (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate))
>>
>> +enum RemoteViewerProperties {
>> + PROP_0,
>> +#ifdef HAVE_OVIRT
>> + PROP_OVIRT_FOREIGN_MENU,
>> +#endif
>> +};
>> +
>> #ifdef HAVE_OVIRT
>> static OvirtVm * choose_vm(GtkWindow *main_window,
>> char **vm_name,
>> @@ -214,6 +221,25 @@ end:
>> }
>>
>> static void
>> +remote_viewer_get_property(GObject *object, guint property_id,
>> + GValue *value, GParamSpec *pspec)
>> +{
>> + RemoteViewer *self = REMOTE_VIEWER(object);
>> + RemoteViewerPrivate *priv = self->priv;
>> +
>> + switch (property_id) {
>> +#ifdef HAVE_OVIRT
>> + case PROP_OVIRT_FOREIGN_MENU:
>> + g_value_set_object(value, priv->ovirt_foreign_menu);
>> + break;
>> +#endif
>> +
>> + default:
>> + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
>> + }
>> +}
>> +
>> +static void
>> remote_viewer_class_init (RemoteViewerClass *klass)
>> {
>> GObjectClass *object_class = G_OBJECT_CLASS (klass);
>> @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass)
>>
>> g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
>>
>> + object_class->get_property = remote_viewer_get_property;
>> object_class->dispose = remote_viewer_dispose;
>>
>> g_app_class->local_command_line = remote_viewer_local_command_line;
>> @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClass *klass)
>> #else
>> (void) gtk_app_class;
>> #endif
>> +
>> +#ifdef HAVE_OVIRT
>> + g_object_class_install_property(object_class,
>> + PROP_OVIRT_FOREIGN_MENU,
>> + g_param_spec_object("ovirt-foreign-menu",
>> + "oVirt Foreign Menu",
>> + "Object which is used as interface to oVirt",
>> + OVIRT_TYPE_FOREIGN_MENU,
>> + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
>> +#endif
>> }
>>
>> static void
>> diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui
>> index 6e3c5ad..e9609ec 100644
>> --- a/src/resources/ui/virt-viewer.ui
>> +++ b/src/resources/ui/virt-viewer.ui
>> @@ -1,6 +1,7 @@
>> <?xml version="1.0" encoding="UTF-8"?>
>> +<!-- Generated with glade 3.20.0 -->
>> <interface>
>> - <!-- interface-requires gtk+ 2.6 -->
>> + <requires lib="gtk+" version="3.0"/>
>> <object class="GtkAccelGroup" id="accelgroup"/>
>> <object class="GtkApplicationWindow" id="viewer">
>> <property name="can_focus">False</property>
>> @@ -73,6 +74,14 @@
>> </object>
>> </child>
>> <child>
>> + <object class="GtkMenuItem" id="menu-change-cd">
>> + <property name="can_focus">False</property>
>> + <property name="label" translatable="yes">_Change CD</property>
>> + <property name="use_underline">True</property>
>> + <signal name="activate" handler="virt_viewer_window_menu_change_cd_activate" swapped="no"/>
>> + </object>
>> + </child>
>> + <child>
>> <object class="GtkMenuItem" id="menu-preferences">
>> <property name="visible">True</property>
>> <property name="can_focus">False</property>
>> @@ -247,14 +256,6 @@
>> </child>
>> </object>
>> </child>
>> - <child>
>> - <object class="GtkMenuItem" id="menu-change-cd">
>> - <property name="use_action_appearance">False</property>
>> - <property name="can_focus">False</property>
>> - <property name="label" translatable="yes">_Change CD</property>
>> - <property name="use_underline">True</property>
>> - </object>
>> - </child>
>> </object>
>> <packing>
>> <property name="expand">False</property>
>> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
>> index 99fd102..8eda12e 100644
>> --- a/src/virt-viewer-window.c
>> +++ b/src/virt-viewer-window.c
>> @@ -43,6 +43,8 @@
>> #include "virt-viewer-util.h"
>> #include "virt-viewer-timed-revealer.h"
>>
>> +#include "remote-viewer-iso-list-dialog.h"
>> +
>> #define ZOOM_STEP 10
>>
>> /* Signal handlers for main window (move in a VirtViewerMainWindow?) */
>> @@ -62,6 +64,7 @@ void virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi
>> void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self);
>> void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self);
>> void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, VirtViewerWindow *self);
>> +void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, VirtViewerWindow *self);
>>
>>
>> /* Internal methods */
>> @@ -1056,6 +1059,40 @@ virt_viewer_window_menu_help_about(GtkWidget *menu G_GNUC_UNUSED,
>> g_object_unref(G_OBJECT(about));
>> }
>>
>> +static void
>> +iso_dialog_response(GtkDialog *dialog,
>> + gint response_id,
>> + gpointer user_data G_GNUC_UNUSED)
>> +{
>> + if (response_id == GTK_RESPONSE_NONE)
>> + return;
>> +
>> + gtk_widget_destroy(GTK_WIDGET(dialog));
>> +}
>> +
>> +void
>> +virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED,
>> + VirtViewerWindow *self)
>> +{
>> + VirtViewerWindowPrivate *priv = self->priv;
>> + GtkWidget *dialog;
>> + GObject *foreign_menu;
>> +
>> + g_object_get(G_OBJECT(priv->app), "ovirt-foreign-menu", &foreign_menu, NULL);
>> + dialog = remote_viewer_iso_list_dialog_new(GTK_WINDOW(priv->window), foreign_menu);
>> + g_object_unref(foreign_menu);
>> +
>> + if (!dialog)
>> + dialog = gtk_message_dialog_new(GTK_WINDOW(priv->window),
>> + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
>> + GTK_MESSAGE_ERROR,
>> + GTK_BUTTONS_CLOSE,
>> + _("Unable to connnect to oVirt"));
>> +
>> + g_signal_connect(dialog, "response", G_CALLBACK(iso_dialog_response), NULL);
>> + gtk_widget_show_all(dialog);
>> + gtk_dialog_run(GTK_DIALOG(dialog));
>> +}
>>
>> static void
>> virt_viewer_window_toolbar_setup(VirtViewerWindow *self)
>> --
>> 2.9.3
>>
>> _______________________________________________
>> virt-tools-list mailing list
>> virt-tools-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list
--
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko at redhat.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20170124/6b0d0500/attachment.sig>
More information about the virt-tools-list
mailing list