On Mon, Sep 05, 2016 at 02:15:18PM +0200, Christophe Fergeau wrote: > On Tue, Aug 02, 2016 at 06:17:31PM +0200, Christophe Fergeau wrote: > > > Eduardo Lima (Etrunko) (10): > > > ovirt-foreign-menu: Remove timer used to refresh iso list > > > ovirt-foreign-menu: Add accessors for current iso and iso list > > > ovirt-foreign-menu: Remove GtkMenu related functions > > > ovirt-foreign-menu: Notify of new files even if nothing changed > > > UI: Make 'Change CD' menu item a submenu under 'File' toplevel menu > > > Introduce ISO List dialog > > > Run iso-dialog when 'Change CD' menu is activated > > > remote-viewer: Make ovirt-foreign-menu a property > > > iso-dialog: Implement functionality provided by oVirt foreign menu > > > iso-dialog: Use header bar for buttons > > > > I'm not sure how to approach this series as I don't think > > 'ovirt-foreign-menu: Add accessors for current iso and iso list' > > See the attached patch for some variation around this which avoids > relying on notify::file and add an async method to do it. > > Christophe > From 910272343409332953fe9a91b8e6d8398290c380 Mon Sep 17 00:00:00 2001 > From: Christophe Fergeau <cfergeau@xxxxxxxxxx> > Date: Mon, 5 Sep 2016 12:13:42 +0200 > Subject: [virt-viewer] Add ovirt_foreign_menu_set_current_iso_name_async > > --- > src/ovirt-foreign-menu.c | 42 +++++++++++++++++++++++++------------ > src/ovirt-foreign-menu.h | 9 +++++++- > src/remote-viewer-iso-list-dialog.c | 14 +++++++------ > 3 files changed, 45 insertions(+), 20 deletions(-) > > diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c > index 8320552..2923554 100644 > --- a/src/ovirt-foreign-menu.c > +++ b/src/ovirt-foreign-menu.c > @@ -47,7 +47,7 @@ static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu > static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu); > static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu *menu); > static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu); > -static void updated_cdrom_cb(GObject *source_object, GAsyncResult *result, gpointer user_data); > +static void iso_name_set_cb(GObject *source_object, GAsyncResult *result, gpointer user_data); > > G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT) > > @@ -102,8 +102,14 @@ ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) > > > void > -ovirt_foreign_menu_set_current_iso_name(OvirtForeignMenu *foreign_menu, char *name) > +ovirt_foreign_menu_set_current_iso_name_async(OvirtForeignMenu *foreign_menu, > + char *name, > + GCancellable *cancellable, > + GAsyncReadyCallback callback, > + gpointer user_data) > { > + GTask *task = g_task_new(foreign_menu, cancellable, callback, user_data); > + > g_return_if_fail(foreign_menu->priv->cdrom != NULL); > g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); > > @@ -120,9 +126,17 @@ ovirt_foreign_menu_set_current_iso_name(OvirtForeignMenu *foreign_menu, char *na > NULL); > ovirt_cdrom_update_async(foreign_menu->priv->cdrom, TRUE, > foreign_menu->priv->proxy, NULL, > - updated_cdrom_cb, foreign_menu); > + iso_name_set_cb, task); > } > > +gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreign_menu, > + GAsyncResult *result, > + GError **error) > +{ > + g_return_val_if_fail(OVIRT_IS_FOREIGN_MENU(foreign_menu), FALSE); > + > + return g_task_propagate_boolean(G_TASK(result), error); > +} > > GList* > ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *foreign_menu) > @@ -359,15 +373,16 @@ ovirt_foreign_menu_start(OvirtForeignMenu *menu) > } > > > -static void updated_cdrom_cb(GObject *source_object, > - GAsyncResult *result, > - gpointer user_data) > +static void iso_name_set_cb(GObject *source_object, > + GAsyncResult *result, > + gpointer user_data) > { > GError *error = NULL; > OvirtForeignMenu *foreign_menu; > gboolean updated; > + GTask *task = G_TASK(user_data); > > - foreign_menu = OVIRT_FOREIGN_MENU(user_data); > + foreign_menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task)); > updated = ovirt_cdrom_update_finish(OVIRT_CDROM(source_object), > result, &error); > g_debug("Finished updating cdrom content"); > @@ -375,14 +390,19 @@ static void updated_cdrom_cb(GObject *source_object, > g_free(foreign_menu->priv->current_iso_name); > foreign_menu->priv->current_iso_name = foreign_menu->priv->next_iso_name; > foreign_menu->priv->next_iso_name = NULL; > - goto end; > + g_task_return_boolean(task, TRUE); > + return; > } > > /* Reset old state back as we were not successful in switching to > * the new ISO */ > if (error != NULL) { > g_warning("failed to update cdrom resource: %s", error->message); > - g_clear_error(&error); > + g_task_return_error(task, error); > + } else { > + g_warn_if_reached(); > + g_task_return_error(task, g_error_new_literal(OVIRT_ERROR, OVIRT_ERROR_FAILED, > + "failed to update cdrom resource")); > } > g_debug("setting OvirtCdrom:file back to '%s'", > foreign_menu->priv->current_iso_name); > @@ -390,12 +410,8 @@ static void updated_cdrom_cb(GObject *source_object, > "file", foreign_menu->priv->current_iso_name, > NULL); > g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); 'task' needs to be unref'ed here too. Christophe
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list