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

lagarcia at linux.vnet.ibm.com lagarcia at linux.vnet.ibm.com
Fri Jan 18 17:27:38 UTC 2013


From: Leonardo Garcia <lagarcia at 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 88274ed..88ea48a 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -60,6 +60,7 @@ void virt_viewer_window_menu_actions_smartcard_insert(GtkWidget *menu, VirtViewe
 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_actions_poweroff(GtkWidget *src, VirtViewerWindow *self);
 void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self);
 
 /* Internal methods */
@@ -747,6 +748,31 @@ virt_viewer_window_menu_actions_shutdown(GtkWidget *src G_GNUC_UNUSED,
 }
 
 
+G_MODULE_EXPORT void
+virt_viewer_window_menu_actions_poweroff(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 (virDomainDestroy(*dom) == 0)
+        DEBUG_LOG("Domain %s was powered off", domname);
+    else
+        virt_viewer_app_simple_message_dialog(priv->app,
+                                              "Failed to power off 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 903b7c4..8abef70 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -128,6 +128,16 @@
                         <signal name="activate" handler="virt_viewer_window_menu_actions_shutdown" swapped="no"/>
                       </object>
                     </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menu-acitons-poweroff">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="label" translatable="yes">Forced Shutdown</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="virt_viewer_window_menu_actions_poweroff" swapped="no"/>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>
-- 
1.7.1




More information about the virt-tools-list mailing list