[virt-tools-list] [PATCH virt-viewer 8/9] Run iso-dialog when 'Change CD' menu is activated
Eduardo Lima (Etrunko)
etrunko at redhat.com
Thu Jan 19 15:07:48 UTC 2017
On 19/01/17 11:06, Christophe Fergeau wrote:
> On Wed, Jan 18, 2017 at 12:16:59PM -0200, Eduardo Lima (Etrunko) wrote:
>> Also makes 'Change CD' menu item a submenu under 'File' toplevel menu
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
>> ---
>> src/resources/ui/virt-viewer.ui | 19 ++++++++++---------
>> src/virt-viewer-window.c | 37 +++++++++++++++++++++++++++++++++++++
>> 2 files changed, 47 insertions(+), 9 deletions(-)
>>
>> 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..a4f531e 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 do connnect to oVirt"));
>
> I don't think remote_viewer_iso_list_dialog_new can return NULL, so this
> could be dropped. If it's needed, s/"Unable do"/"Unable to"
>
In practice it won't, but there is a g_return_val_if_fail() if the
foreign_menu pointer is null, so I added this failsafe here.
--
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/20170119/74ff52cc/attachment.sig>
More information about the virt-tools-list
mailing list