[virt-tools-list] [PATCHv3 virt-viewer 08/10] Sync preferences widgets with session properties

Marc-André Lureau marcandre.lureau at gmail.com
Thu Mar 5 19:12:27 UTC 2015


---
 src/virt-viewer-app.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 0b11aa1..7a9da52 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -113,6 +113,7 @@ struct _VirtViewerAppPrivate {
     GHashTable *initial_display_map;
     gchar *clipboard;
     GtkWidget *preferences;
+    GtkFileChooser *preferences_shared_folder;
     gboolean direct;
     gboolean verbose;
     gboolean enable_accel;
@@ -2405,12 +2406,26 @@ virt_viewer_app_get_windows(VirtViewerApp *self)
     return self->priv->windows;
 }
 
+static void
+share_folder_changed(VirtViewerApp *self)
+{
+    gchar *folder;
+
+    folder = gtk_file_chooser_get_filename(self->priv->preferences_shared_folder);
+
+    g_object_set(virt_viewer_app_get_session(self),
+                 "shared-folder", folder, NULL);
+
+    g_free(folder);
+}
+
 void
 virt_viewer_app_show_preferences(VirtViewerApp *self, GtkWidget *parent)
 {
     GtkWidget *preferences = self->priv->preferences;
 
     if (!preferences) {
+        gchar *path;
         GtkBuilder *builder = virt_viewer_util_load_ui("virt-viewer-preferences.xml");
 
         gtk_builder_connect_signals(builder, self);
@@ -2418,6 +2433,32 @@ virt_viewer_app_show_preferences(VirtViewerApp *self, GtkWidget *parent)
         preferences = GTK_WIDGET(gtk_builder_get_object(builder, "preferences"));
         self->priv->preferences = preferences;
 
+        g_object_bind_property(virt_viewer_app_get_session(self),
+                           "share-folder",
+                           gtk_builder_get_object(builder, "cbsharefolder"),
+                           "active",
+                           G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
+
+        g_object_bind_property(virt_viewer_app_get_session(self),
+                           "share-folder-ro",
+                           gtk_builder_get_object(builder, "cbsharefolderro"),
+                           "active",
+                           G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
+
+        self->priv->preferences_shared_folder =
+            GTK_FILE_CHOOSER(gtk_builder_get_object(builder, "fcsharefolder"));
+
+        g_object_get(virt_viewer_app_get_session(self),
+                     "shared-folder", &path, NULL);
+
+        gtk_file_chooser_set_filename(self->priv->preferences_shared_folder, path);
+        g_free(path);
+
+        virt_viewer_signal_connect_object(self->priv->preferences_shared_folder,
+                                          "file-set",
+                                          G_CALLBACK(share_folder_changed), self,
+                                          G_CONNECT_SWAPPED);
+
         g_object_unref(builder);
     }
 
-- 
2.1.0




More information about the virt-tools-list mailing list