[virt-tools-list] [virt-viewer][PATCH 3/3] virt-viewer-window: Added reconnect button to GUI

Lukas Venhoda lvenhoda at redhat.com
Tue May 12 10:21:27 UTC 2015


Added a reconnect CheckMenuItem into virt-viewer.xml.
This button is implicitly set to hidden.
If compiling virt-viewer, USING_VIRT_VIEWER is defined and
visibility of the button is set to true in virt_viewer_window_init.

The reconnect button callback gets the button state (true/false) and set
the reconnect property of virt-viewer to the button state value.
---
The button is in Menu-File-Reconnect for now, but this can be changed.
---
 src/virt-viewer-window.c | 13 +++++++++++++
 src/virt-viewer.xml      |  9 +++++++++
 2 files changed, 22 insertions(+)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index d67fbc1..629c8f4 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -56,6 +56,7 @@ void virt_viewer_window_menu_help_guest_details(GtkWidget *menu, VirtViewerWindo
 void virt_viewer_window_menu_view_fullscreen(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_send(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_file_screenshot(GtkWidget *menu, VirtViewerWindow *self);
+void virt_viewer_window_menu_file_reconnect(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_file_usb_device_selection(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWindow *self);
 void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self);
@@ -311,6 +312,10 @@ virt_viewer_window_init (VirtViewerWindow *self)
     gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-file-screenshot")), FALSE);
     gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-preferences")), FALSE);

+#ifdef USING_VIRT_VIEWER
+    gtk_widget_set_visible(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-file-reconnect")), TRUE);
+#endif
+
     gtk_builder_connect_signals(priv->builder, self);

     priv->accel_group = GTK_ACCEL_GROUP(gtk_builder_get_object(priv->builder, "accelgroup"));
@@ -1005,6 +1010,14 @@ virt_viewer_window_menu_file_screenshot(GtkWidget *menu G_GNUC_UNUSED,
 }

 G_MODULE_EXPORT void
+virt_viewer_window_menu_file_reconnect(GtkWidget *menu, VirtViewerWindow *self)
+{
+    gboolean reconnect = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu));
+
+    g_object_set(self->priv->app, "reconnect", reconnect, NULL);
+}
+
+G_MODULE_EXPORT void
 virt_viewer_window_menu_file_usb_device_selection(GtkWidget *menu G_GNUC_UNUSED,
                                                   VirtViewerWindow *self)
 {
diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
index 07948bd..ed8bdca 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -49,6 +49,15 @@
                       </object>
                     </child>
                     <child>
+                      <object class="GtkCheckMenuItem" id="menu-file-reconnect">
+                        <property name="visible">False</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="label" translatable="yes">Reconnect</property>
+                        <signal name="toggled" handler="virt_viewer_window_menu_file_reconnect" swapped="no"/>
+                      </object>
+                    </child>
+                    <child>
                       <object class="GtkMenuItem" id="menu-file-smartcard-insert">
                         <property name="can_focus">False</property>
                         <property name="use_action_appearance">False</property>
--
2.4.0




More information about the virt-tools-list mailing list