[virt-tools-list] [virt-viewer][PATCH 4/6] Add menu action to reboot virtual machine.
lagarcia at linux.vnet.ibm.com
lagarcia at linux.vnet.ibm.com
Fri Jan 18 17:27:36 UTC 2013
From: Leonardo Garcia <lagarcia at br.ibm.com>
---
src/Makefile.am | 12 ++++++++----
src/virt-viewer-window.c | 28 ++++++++++++++++++++++++++++
src/virt-viewer.c | 1 -
src/virt-viewer.h | 2 ++
src/virt-viewer.xml | 16 ++++++++++++++++
5 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 05e20b2..f90d229 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -104,16 +104,19 @@ endif
bin_PROGRAMS += remote-viewer
-remote_viewer_SOURCES = \
- $(COMMON_SOURCES) \
- remote-viewer.h remote-viewer.c \
- remote-viewer-main.c \
+remote_viewer_SOURCES = \
+ $(COMMON_SOURCES) \
+ remote-viewer.h remote-viewer.c \
+ remote-viewer-main.c \
+ virt-viewer-events.h virt-viewer-events.c \
+ virt-viewer.h virt-viewer.c \
$(NULL)
remote_viewer_LDFLAGS = \
-lm \
$(GLIB2_LIBS) \
$(GTK_LIBS) \
$(LIBXML2_LIBS) \
+ $(LIBVIRT_LIBS) \
$(NULL)
remote_viewer_CFLAGS = \
-DLOCALE_DIR=\""$(datadir)/locale"\" \
@@ -121,6 +124,7 @@ remote_viewer_CFLAGS = \
$(GLIB2_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBXML2_CFLAGS) \
+ $(LIBVIRT_CFLAGS) \
$(WARN_CFLAGS) \
$(NULL)
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index e9982a4..abb3fbc 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -34,11 +34,13 @@
#include <locale.h>
#include <glib/gprintf.h>
#include <glib/gi18n.h>
+#include <libvirt/libvirt.h>
#include "virt-gtk-compat.h"
#include "virt-viewer-window.h"
#include "virt-viewer-session.h"
#include "virt-viewer-app.h"
+#include "virt-viewer.h"
#include "virt-viewer-util.h"
#include "view/autoDrawer.h"
@@ -56,6 +58,7 @@ void virt_viewer_window_menu_file_screenshot(GtkWidget *menu, VirtViewerWindow *
void virt_viewer_window_menu_actions_usb_device_selection(GtkWidget *menu, VirtViewerWindow *self);
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_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self);
/* Internal methods */
@@ -693,6 +696,31 @@ virt_viewer_window_menu_file_quit(GtkWidget *src G_GNUC_UNUSED,
}
+G_MODULE_EXPORT void
+virt_viewer_window_menu_actions_reboot(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 (virDomainReboot(*dom, 0) == 0)
+ DEBUG_LOG("Domain %s is being rebooted\n", domname);
+ else
+ virt_viewer_app_simple_message_dialog(priv->app,
+ "Failed to reboot domain %s",
+ domname);
+}
+
+
static void
virt_viewer_window_toolbar_leave_fullscreen(GtkWidget *button G_GNUC_UNUSED,
VirtViewerWindow *self)
diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index 3be0c49..e4b5eba 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -35,7 +35,6 @@
#include <glib/gprintf.h>
#include <glib/gi18n.h>
-#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
#include <libxml/xpath.h>
#include <libxml/uri.h>
diff --git a/src/virt-viewer.h b/src/virt-viewer.h
index de2485a..f0b231a 100644
--- a/src/virt-viewer.h
+++ b/src/virt-viewer.h
@@ -24,6 +24,8 @@
#define VIRT_VIEWER_H
#include <glib-object.h>
+#include <libvirt/libvirt.h>
+
#include "virt-viewer-app.h"
G_BEGIN_DECLS
diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
index 42f58f0..2268e65 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -102,6 +102,22 @@
<signal name="activate" handler="virt_viewer_window_menu_actions_smartcard_remove" swapped="no"/>
</object>
</child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="separatormenuitem5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menu-actions-reboot">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="label" translatable="yes">Restart</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="virt_viewer_window_menu_actions_reboot" swapped="no"/>
+ </object>
+ </child>
</object>
</child>
</object>
--
1.7.1
More information about the virt-tools-list
mailing list