[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [virt-viewer][PATCH 5/6] Add menu action to shutdown virtual machine.



From: Leonardo Garcia <lagarcia br ibm com>

---
 src/virt-viewer-window.c |   26 ++++++++++++++++++++++++++
 src/virt-viewer.xml      |   10 ++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index abb3fbc..88274ed 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -59,6 +59,7 @@ void virt_viewer_window_menu_actions_usb_device_selection(GtkWidget *menu, VirtV
 void virt_viewer_window_menu_actions_smartcard_insert(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_actions_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_actions_reboot(GtkWidget *src, VirtViewerWindow *self);
+void virt_viewer_window_menu_actions_shutdown(GtkWidget *src, VirtViewerWindow *self);
 void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self);
 
 /* Internal methods */
@@ -721,6 +722,31 @@ virt_viewer_window_menu_actions_reboot(GtkWidget *src G_GNUC_UNUSED,
 }
 
 
+G_MODULE_EXPORT void
+virt_viewer_window_menu_actions_shutdown(GtkWidget *src G_GNUC_UNUSED,
+                                         VirtViewerWindow *self)
+{
+    VirtViewerWindowPrivate *priv = self->priv;
+    const virDomainPtr *dom;
+    const char *domname;
+
+    if (!(dom = virt_viewer_get_domain(VIRT_VIEWER(priv->app)))) {
+        virt_viewer_app_simple_message_dialog(priv->app,
+                                              "Could not get domain information");
+        return;
+    }
+
+    domname = virDomainGetName(*dom);
+
+    if (virDomainShutdown(*dom) == 0)
+        DEBUG_LOG("Domain %s was requested to shutdown", domname);
+    else
+        virt_viewer_app_simple_message_dialog(priv->app,
+                                              "Failed to shutdown domain %s",
+                                              domname);
+}
+
+
 static void
 virt_viewer_window_toolbar_leave_fullscreen(GtkWidget *button G_GNUC_UNUSED,
                                             VirtViewerWindow *self)
diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
index 2268e65..903b7c4 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -118,6 +118,16 @@
                         <signal name="activate" handler="virt_viewer_window_menu_actions_reboot" swapped="no"/>
                       </object>
                     </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menu-actions-shutdown">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="label" translatable="yes">Shutdown</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="virt_viewer_window_menu_actions_shutdown" swapped="no"/>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]