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

Marc-André Lureau mlureau at redhat.com
Thu Mar 5 17:55:41 UTC 2015



----- Original Message -----
> On Wed, Mar 4, 2015 at 7:01 PM, Marc-André Lureau
> <marcandre.lureau at gmail.com> wrote:
> > ---
> >  src/virt-viewer-app.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> > index ed47a19..93a84dd 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;
> > @@ -2404,6 +2405,19 @@ 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)
> >  {
> > @@ -2418,6 +2432,35 @@ 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"));
> > +
> > +    gchar *path;
> 
> Declare the vars in the beginning of the function, please.

I am not sure we have such requirement, you know c99, for 16 years,.. :)

> 
> > +    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);
> 
> Hmm. This g_object_unref(builder); belongs to the previous commit.
> 

right

> > +
> >  present:
> >      gtk_window_set_transient_for(GTK_WINDOW(preferences),
> >                                   GTK_WINDOW(parent));
> > --
> > 2.1.0
> >
> > _______________________________________________
> > virt-tools-list mailing list
> > virt-tools-list at redhat.com
> > https://www.redhat.com/mailman/listinfo/virt-tools-list
> 
> 
> 
> --
> Fabiano Fidêncio
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list




More information about the virt-tools-list mailing list