[virt-tools-list] [virt-viewer][PATCH 4/4 v3] virt-viewer-app: Added reconnect button to preferences

Lukas Venhoda lvenhoda at redhat.com
Wed May 13 14:51:03 UTC 2015


Added a new preferences tab, and a check button "Reconnect" into
virt-viewer-preferences.xml. They are implicitly set to hidden.

If can_reconnect is set to true (while constructing virt-viewer-app),
both the tab and the button will be shown.
---
Changes since v2:
 - Moved the visibility and binding code back into virt-viewer-window
   - Still technically inside of preferences, but preferences was moved
     into virt-viewer-window
 - Check if we can reconnect, before binding the button

Changes since v1:
 - Added a new preferences tab "General"
 - Moved the reconnect button into preferences under General tab
 - Moved all of visibility and binding code into virt-viewer-app
---
 src/virt-viewer-preferences.xml | 59 +++++++++++++++++++++++++++++++++++++++++
 src/virt-viewer-window.c        | 14 ++++++++++
 2 files changed, 73 insertions(+)

diff --git a/src/virt-viewer-preferences.xml b/src/virt-viewer-preferences.xml
index f9738c5..c4da109 100644
--- a/src/virt-viewer-preferences.xml
+++ b/src/virt-viewer-preferences.xml
@@ -121,6 +121,65 @@
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkVBox" id="preferences-general-vbox">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">18</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Connection</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkTable" id="table2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="border_width">6</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">12</property>
+                    <property name="row_spacing">6</property>
+                    <child>
+                      <object class="GtkCheckButton" id="cbreconnect">
+                        <property name="label" translatable="yes">Reconnect on domain restart</property>
+                        <property name="visible">False</property>
+                        <property name="can_focus">False</property>
+                        <property name="receives_default">False</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">General</property>
+              </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">True</property>
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index f66bd50..311b787 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1619,6 +1619,20 @@ virt_viewer_window_get_preferences(VirtViewerWindow *self)
     preferences = GTK_WIDGET(gtk_builder_get_object(builder, "preferences"));
     self->priv->preferences = preferences;

+    gboolean can_reconnect;
+    g_object_get(G_OBJECT(self->priv->app), "can-reconnect", &can_reconnect, NULL);
+    if (can_reconnect)
+    {
+        g_object_set (gtk_builder_get_object(builder, "cbreconnect"), "visible", TRUE, NULL);
+        g_object_set (gtk_builder_get_object(builder, "preferences-general-vbox"), "visible", TRUE, NULL);
+
+        g_object_bind_property(self->priv->app,
+                           "reconnect",
+                           gtk_builder_get_object(builder, "cbreconnect"),
+                           "active",
+                           G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
+    }
+
     g_object_set (gtk_builder_get_object(builder, "cbsharefolder"),
                   "sensitive", can_share_folder, NULL);
     g_object_set (gtk_builder_get_object(builder, "cbsharefolderro"),
--
2.4.0




More information about the virt-tools-list mailing list