[virt-tools-list] [PATCH virt-viewer 09/10] Run iso-dialog when 'Change CD' menu is activated

Eduardo Lima (Etrunko) etrunko at redhat.com
Fri Jan 13 21:11:11 UTC 2017


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"));
+
+    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




More information about the virt-tools-list mailing list