[virt-tools-list] [PATCH virt-viewer v4 03/12] ovirt-foreign-menu: Remove GtkMenu related functions
With this commit, we finish cleaning up ovirt foreign menu code, which only deals with data, leaving the UI bits to be handled properly in the new ISO list dialog. This patch also updates remote-viewer to reflect the change. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 79 src/remote-viewer.c | 52 +-- 2 files changed, 8 insertions(+), 123 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index eec6bc6..493ca47 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -359,22 +359,6 @@ ovirt_foreign_menu_start(OvirtForeignMenu *menu) } -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data); - - -static void -menu_item_set_active_no_signal(GtkMenuItem *menuitem, - gboolean active, - GCallback callback, - gpointer user_data) -{ -g_signal_handlers_block_by_func(menuitem, callback, user_data); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); -g_signal_handlers_unblock_by_func(menuitem, callback, user_data); -} - - static void updated_cdrom_cb(GObject *source_object, GAsyncResult *result, gpointer user_data) @@ -410,69 +394,6 @@ static void updated_cdrom_cb(GObject *source_object, } -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data) -{ -OvirtForeignMenu *foreign_menu; -const char *iso_name = NULL; -gboolean checked; - -checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)); -foreign_menu = OVIRT_FOREIGN_MENU(user_data); -g_return_if_fail(foreign_menu->priv->cdrom != NULL); -g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); - -g_debug("'%s' clicked", gtk_menu_item_get_label(menuitem)); - -/* We only want to move the check mark for the currently selected ISO - * when ovirt_cdrom_update_async() is successful, so for now we move - * the check mark back to where it was before - */ -menu_item_set_active_no_signal(menuitem, !checked, - (GCallback)ovirt_foreign_menu_activate_item_cb, - foreign_menu); - -if (checked) { -iso_name = gtk_menu_item_get_label(menuitem); -} - -ovirt_foreign_menu_set_current_iso_name(foreign_menu, iso_name); -} - - -GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu) -{ -GtkWidget *gtk_menu; -GList *it; -char *current_iso; - -if (foreign_menu->priv->iso_names == NULL) { -g_debug("ISO list is empty, no menu to show"); -return NULL; -} -g_debug("Creating GtkMenu for foreign menu"); -current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu); -gtk_menu = gtk_menu_new(); -for (it = foreign_menu->priv->iso_names; it != NULL; it = it->next) { -GtkWidget *menuitem; - -menuitem = gtk_check_menu_item_new_with_label((char *)it->data); -if (g_strcmp0((char *)it->data, current_iso) == 0) { -g_warn_if_fail(g_strcmp0(current_iso, foreign_menu->priv->current_iso_name) == 0); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), - TRUE); -} -g_signal_connect(menuitem, "activate", - G_CALLBACK(ovirt_foreign_menu_activate_item_cb), - foreign_menu); -gtk_menu_shell_append(GTK_MENU_SHELL(gtk_menu), menuitem); -} -g_free(current_iso); - -return gtk_menu; -} - - static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu, const GList *files) { diff --git a/src/remote-viewer.c b/src/remote-viewer.c index 6d29bf2..95130dc 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -734,33 +734,11 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth, static void ovirt_foreign_menu_update(GtkApplication *gtkapp, GtkWindow *gtkwin, G_GNUC_UNUSED gpointer data) { -RemoteViewer *app = REMOTE_VIEWER(gtkapp); +RemoteViewer *self = REMOTE_VIEWER(gtkapp); VirtViewerWindow *win = g_object_get_data(G_OBJECT(gtkwin), "virt-viewer-window"); -GtkWidget *menu = g_object_get_data(G_OBJECT(win), "foreign-menu"); -GtkWidget *submenu; - -if (app->priv->ovirt_foreign_menu == NULL) { -/* nothing to do */ -return; -} - -submenu = ovirt_foreign_menu_get_gtk_menu(app->priv->ovirt_foreign_menu); -if (submenu == NULL) { -/* No items to show, no point in showing the menu */ -if (menu != NULL) - gtk_widget_set_visible(menu,
[virt-tools-list] [PATCH virt-viewer v4 10/12] iso-dialog: Use header bar for buttons
It seems to give more modern look to the dialog, but it requires Gtk+ 3.12, thus I will am keeping this commit separated. On the glade UI file, we get rid of the GtkAlignment object that was used to put some space between the tree view and dialog buttons. The "Select ISO" label is gone too. Signed-off-by: Eduardo Lima (Etrunko) --- configure.ac | 4 +- src/remote-viewer-iso-list-dialog.c| 31 +-- src/resources/ui/remote-viewer-iso-list.ui | 87 +++--- 3 files changed, 60 insertions(+), 62 deletions(-) diff --git a/configure.ac b/configure.ac index 89e7641..7387be5 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38" GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" # Keep these two definitions in agreement. -GTK_REQUIRED="3.10" -GTK_ENCODED_VERSION="GDK_VERSION_3_10" +GTK_REQUIRED="3.12" +GTK_ENCODED_VERSION="GDK_VERSION_3_12" LIBXML2_REQUIRED="2.6.0" LIBVIRT_REQUIRED="0.10.0" diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index 4a1cf44..dd652d7 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -34,6 +34,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkHeaderBar *header_bar; GtkListStore *list_store; GtkWidget *stack; GtkWidget *tree_view; @@ -83,6 +84,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) } static void +remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *subtitle = NULL; + +if (iso_name && strlen(iso_name) != 0) +subtitle = g_strdup_printf(_("Current: %s"), iso_name); + +gtk_header_bar_set_subtitle(priv->header_bar, subtitle); +g_free(subtitle); +} + +static void remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) { RemoteViewerISOListDialogPrivate *priv = self->priv; @@ -102,6 +116,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); } free(current_iso); @@ -136,6 +151,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, if (response_id != GTK_RESPONSE_NONE) return; +remote_viewer_iso_list_dialog_set_subtitle(self, NULL); gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); @@ -187,9 +203,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); GtkCellRendererToggle *cell_renderer; +GtkWidget *button, *image; gtk_builder_connect_signals(builder, self); +priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self))); +gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE); + priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack")); gtk_box_pack_start(GTK_BOX(content), priv->stack, TRUE, TRUE, 0); @@ -201,12 +221,11 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) g_object_unref(builder); -gtk_dialog_add_buttons(GTK_DIALOG(self), - _("Refresh"), GTK_RESPONSE_NONE, - _("Close"), GTK_RESPONSE_CLOSE, - NULL); +button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE); +image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON); +gtk_button_set_image(GTK_BUTTON(button), image); +gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE); -gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL); } @@ -246,6 +265,7 @@ ovirt_foreign_menu_notify_file(OvirtForeignMenu *foreign_menu, g_free(name); } while (gtk_tree_model_iter_next(model, &iter)); +remote_viewer_iso_list_dialog_set_subtitle(self,
Re: [virt-tools-list] [PATCH virt-viewer v4 00/12] Replace oVirt foreign menu with dedicated dialog
On 11/02/2016 03:20 PM, Christophe Fergeau wrote: > On Wed, Nov 02, 2016 at 06:15:45PM +0100, Christophe Fergeau wrote: >> This does not seem to apply on top of git master. > > Ah, just minor merge conflict in src/Makefile.am, easy to fix locally ;) > The file transfer dialog has been merged after I sent the series, and caused this conflict. I fixed it locally too. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer v4 11/12] ovirt-foreign-menu: Set new ISO name using GTask API
On 11/01/2016 06:33 PM, Eduardo Lima (Etrunko) wrote: > From: Christophe Fergeau > > This is done with the new ovirt_foreign_menu_set_current_iso_name_async > function. Also, an error dialog will be shown in case anything goes > wrong with the async method. > > Signed-off-by: Eduardo Lima (Etrunko) > --- > src/ovirt-foreign-menu.c| 40 > +++-- > src/ovirt-foreign-menu.h| 9 - > src/remote-viewer-iso-list-dialog.c | 40 > + > 3 files changed, 70 insertions(+), 19 deletions(-) > > diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c > index 8320552..288a812 100644 > --- a/src/ovirt-foreign-menu.c > +++ b/src/ovirt-foreign-menu.c [snip] > @@ -382,7 +399,11 @@ static void updated_cdrom_cb(GObject *source_object, > * 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_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, > +"failed to update cdrom resource"); > } The block above should be placed after resetting the file back to the original, because in the case of error, on the dialog we will get the outdated name. I will send the updated patch soon. Regards, Eduardo -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Set new ISO name using GTask API
From: Christophe Fergeau This is done with the new ovirt_foreign_menu_set_current_iso_name_async function. Also, an error dialog will be shown in case anything goes wrong with the async method. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c| 53 ++--- src/ovirt-foreign-menu.h| 9 ++- src/remote-viewer-iso-list-dialog.c | 48 - 3 files changed, 81 insertions(+), 29 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 8320552..9979d37 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_return_if_fail(foreign_menu->priv->cdrom != NULL); g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); @@ -118,11 +124,20 @@ ovirt_foreign_menu_set_current_iso_name(OvirtForeignMenu *foreign_menu, char *na g_object_set(foreign_menu->priv->cdrom, "file", name, NULL); + +task = g_task_new(foreign_menu, cancellable, callback, user_data); 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,31 +374,27 @@ 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"); if (updated) { +g_debug("Finished updating cdrom content: '%s'", foreign_menu->priv->next_iso_name); 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; +g_task_return_boolean(task, TRUE); goto end; } -/* 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_debug("setting OvirtCdrom:file back to '%s'", foreign_menu->priv->current_iso_name); g_object_set(foreign_menu->priv->cdrom, @@ -391,11 +402,21 @@ static void updated_cdrom_cb(GObject *source_object, NULL); g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); +/* Reset old state back as we were not successful in switching to + * the new ISO */ +if (error != NUL
[virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer: Make ovirt-foreign-menu a property
The OvirtForeignMenu pointer is needed by the new ISO list dialog, and we make it acessible via property to avoid interdependency between objects. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer-iso-list-dialog.c | 31 +++ src/remote-viewer-iso-list-dialog.h | 2 +- src/remote-viewer.c | 37 + 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index 0fbea28..858719c 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -24,6 +24,7 @@ #include "remote-viewer-iso-list-dialog.h" #include "virt-viewer-util.h" +#include "ovirt-foreign-menu.h" G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) @@ -33,11 +34,16 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { GtkWidget *stack; +OvirtForeignMenu *foreign_menu; }; static void remote_viewer_iso_list_dialog_dispose(GObject *object) { +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); +RemoteViewerISOListDialogPrivate *priv = self->priv; + +g_clear_object(&priv->foreign_menu); G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); } @@ -94,13 +100,22 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) } GtkWidget * -remote_viewer_iso_list_dialog_new(GtkWindow *parent) +remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu) { -return g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, -"title", _("Change CD"), -"transient-for", parent, -"border-width", 18, -"default-width", 400, -"default-height", 300, -NULL); +GtkWidget *dialog; +RemoteViewerISOListDialog *self; + +g_return_val_if_fail(foreign_menu != NULL, NULL); + +dialog = g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, + "title", _("Change CD"), + "transient-for", parent, + "border-width", 18, + "default-width", 400, + "default-height", 300, + NULL); + +self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); +self->priv->foreign_menu = OVIRT_FOREIGN_MENU(g_object_ref(foreign_menu)); +return dialog; } diff --git a/src/remote-viewer-iso-list-dialog.h b/src/remote-viewer-iso-list-dialog.h index def841b..8b936f5 100644 --- a/src/remote-viewer-iso-list-dialog.h +++ b/src/remote-viewer-iso-list-dialog.h @@ -51,7 +51,7 @@ struct _RemoteViewerISOListDialogClass GType remote_viewer_iso_list_dialog_get_type(void) G_GNUC_CONST; -GtkWidget *remote_viewer_iso_list_dialog_new(GtkWindow *parent); +GtkWidget *remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu); G_END_DECLS diff --git a/src/remote-viewer.c b/src/remote-viewer.c index c84a35b..29d7db1 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP) #define GET_PRIVATE(o)\ (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate)) +enum RemoteViewerProperties { +PROP_0, +#ifdef HAVE_OVIRT +PROP_OVIRT_FOREIGN_MENU, +#endif +}; + #ifdef HAVE_OVIRT static OvirtVm * choose_vm(GtkWindow *main_window, char **vm_name, @@ -214,6 +221,25 @@ end: } static void +remote_viewer_get_property(GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ +RemoteViewer *self = REMOTE_VIEWER(object); +RemoteViewerPrivate *priv = self->priv; + +switch (property_id) { +#ifdef HAVE_OVIRT +case PROP_OVIRT_FOREIGN_MENU: +g_value_set_object(value, priv->ovirt_foreign_menu); +break; +#endif + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} +} + +static void remote_viewer_class_init (RemoteViewerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass) g_type_class_add_private (klass, sizeof (RemoteViewerPrivate)); +object_class->get_property = remote_viewer_get_property; object_class->dispose = remote_viewer_dispose; g_app_class->local_command_line = remote_viewer_local_command_line; @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClas
[virt-tools-list] [PATCH virt-viewer 06/10] ovirt-foreign-menu: Add accessors for current iso and iso list
Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 9 - src/ovirt-foreign-menu.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 6892f0d..e244719 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -85,7 +85,7 @@ enum { }; -static char * +char * ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) { char *name; @@ -100,6 +100,13 @@ ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) } +GList* +ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *foreign_menu) +{ +return foreign_menu->priv->iso_names; +} + + static void ovirt_foreign_menu_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) diff --git a/src/ovirt-foreign-menu.h b/src/ovirt-foreign-menu.h index a864a60..31a88ca 100644 --- a/src/ovirt-foreign-menu.h +++ b/src/ovirt-foreign-menu.h @@ -88,6 +88,8 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu); +char *ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *menu); +GList *ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *menu); G_END_DECLS -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 03/10] ovirt-foreign-menu: Fetch ISO names using GTask API
Similar to the previous commit, the ISO dialog will fetch the result asynchronously, rather than relying on the "notify::files" signal from OvirtForeignMenu object. It also enables error to be shown if anything goes wrong. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 159 +-- src/ovirt-foreign-menu.h | 9 ++- src/remote-viewer.c | 45 -- 3 files changed, 135 insertions(+), 78 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 366259a..6892f0d 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -40,13 +40,13 @@ typedef enum { STATE_ISOS } OvirtForeignMenuState; -static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, OvirtForeignMenuState state); -static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu); -static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu); -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 gboolean ovirt_foreign_menu_refresh_iso_list(gpointer user_data); +static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, GTask *task, OvirtForeignMenuState state); +static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, GTask *task); G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT) @@ -273,11 +273,9 @@ OvirtForeignMenu* ovirt_foreign_menu_new(OvirtProxy *proxy) static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, + GTask *task, OvirtForeignMenuState current_state) { -g_return_if_fail(current_state >= STATE_0); -g_return_if_fail(current_state < STATE_ISOS); - /* Each state will check if the member is initialized, falling directly to * the next one if so. If not, the callback for the asynchronous call will * be responsible for calling is function again with the next state as @@ -286,26 +284,26 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, switch (current_state + 1) { case STATE_API: if (menu->priv->api == NULL) { -ovirt_foreign_menu_fetch_api_async(menu); +ovirt_foreign_menu_fetch_api_async(menu, task); break; } case STATE_VM: if (menu->priv->vm == NULL) { -ovirt_foreign_menu_fetch_vm_async(menu); +ovirt_foreign_menu_fetch_vm_async(menu, task); break; } case STATE_STORAGE_DOMAIN: if (menu->priv->files == NULL) { -ovirt_foreign_menu_fetch_storage_domain_async(menu); +ovirt_foreign_menu_fetch_storage_domain_async(menu, task); break; } case STATE_VM_CDROM: if (menu->priv->cdrom == NULL) { -ovirt_foreign_menu_fetch_vm_cdrom_async(menu); +ovirt_foreign_menu_fetch_vm_cdrom_async(menu, task); break; } case STATE_CDROM_FILE: -ovirt_foreign_menu_refresh_cdrom_file_async(menu); +ovirt_foreign_menu_refresh_cdrom_file_async(menu, task); break; case STATE_ISOS: g_warn_if_fail(menu->priv->api != NULL); @@ -313,18 +311,35 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, g_warn_if_fail(menu->priv->files != NULL); g_warn_if_fail(menu->priv->cdrom != NULL); -ovirt_foreign_menu_refresh_iso_list(menu); +ovirt_foreign_menu_fetch_iso_list_async(menu, task); break; default: g_warn_if_reached(); +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, +"Invalid state: %d", current_state); +g_object_unref(task); } } void -ovirt_foreign_menu_start(OvirtForeignMenu *menu) +ovirt_foreign_menu_fetch_iso_names_async(OvirtForeignMenu *menu, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { -ovirt_foreign_menu_next_async_step(menu, STATE_0); +GTask *task = g_task_new(menu, cancellable, callback, user_data); +ov
[virt-tools-list] [PATCH virt-viewer 10/10] ovirt-foreign-menu: Remove GtkMenu related functions
With this commit, we finish cleaning up ovirt foreign menu code, which only deals with data, leaving the UI bits to be handled properly in the new ISO list dialog. This patch also updates remote-viewer to reflect the change. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 98 src/remote-viewer.c | 87 +++--- 2 files changed, 6 insertions(+), 179 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index e244719..232286c 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -350,22 +350,6 @@ ovirt_foreign_menu_fetch_iso_names_finish(OvirtForeignMenu *foreign_menu, } -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data); - - -static void -menu_item_set_active_no_signal(GtkMenuItem *menuitem, - gboolean active, - GCallback callback, - gpointer user_data) -{ -g_signal_handlers_block_by_func(menuitem, callback, user_data); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); -g_signal_handlers_unblock_by_func(menuitem, callback, user_data); -} - - static void iso_name_set_cb(GObject *source_object, GAsyncResult *result, gpointer user_data) @@ -447,88 +431,6 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig } -static void -ovirt_foreign_menu_iso_name_changed(GObject *source_object, -GAsyncResult *result, -gpointer user_data G_GNUC_UNUSED) -{ -OvirtForeignMenu *foreign_menu = OVIRT_FOREIGN_MENU(source_object); -GError *error = NULL; - -if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -g_warning(error ? error->message : "Failed to change CD"); -g_clear_error(&error); -return; -} - -g_object_notify(G_OBJECT(foreign_menu), "file"); -} - - -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data) -{ -OvirtForeignMenu *foreign_menu; -const char *iso_name = NULL; -gboolean checked; - -checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)); -foreign_menu = OVIRT_FOREIGN_MENU(user_data); -g_return_if_fail(foreign_menu->priv->cdrom != NULL); -g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); - -g_debug("'%s' clicked", gtk_menu_item_get_label(menuitem)); - -/* We only want to move the check mark for the currently selected ISO - * when ovirt_cdrom_update_async() is successful, so for now we move - * the check mark back to where it was before - */ -menu_item_set_active_no_signal(menuitem, !checked, - (GCallback)ovirt_foreign_menu_activate_item_cb, - foreign_menu); - -if (checked) { -iso_name = gtk_menu_item_get_label(menuitem); -} -ovirt_foreign_menu_set_current_iso_name_async(foreign_menu, iso_name, NULL, - ovirt_foreign_menu_iso_name_changed, - menuitem); -} - - -GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu) -{ -GtkWidget *gtk_menu; -GList *it; -char *current_iso; - -if (foreign_menu->priv->iso_names == NULL) { -g_debug("ISO list is empty, no menu to show"); -return NULL; -} -g_debug("Creating GtkMenu for foreign menu"); -current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu); -gtk_menu = gtk_menu_new(); -for (it = foreign_menu->priv->iso_names; it != NULL; it = it->next) { -GtkWidget *menuitem; - -menuitem = gtk_check_menu_item_new_with_label((char *)it->data); -if (g_strcmp0((char *)it->data, current_iso) == 0) { -g_warn_if_fail(g_strcmp0(current_iso, foreign_menu->priv->current_iso_name) == 0); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), - TRUE); -} -g_signal_connect(menuitem, "activate", - G_CALLBACK(ovirt_foreign_menu_activate_item_cb), - foreign_menu); -gtk_menu_shell_append(GTK_MENU_SHELL(gtk_menu), menuitem); -} -g_free(current_iso); - -return gtk_menu; -} - - static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu, const GList *files) { diff --git a/src/remote-viewer.c b/src/remote-viewer.c index 29d7db1..d04dbb5 100644 --- a/src/remote-viewer.c +++ b/src/remote-
[virt-tools-list] [PATCH virt-viewer 01/10] remote-viewer: Extend #ifdef HAVE_OVIRT block
The #endif is closing a #ifdef HAVE_OVIRT block, while another one is opened right next, so there is no need to have those lines. Also, due to the large amount of source code in between, add a small comment on the last #endif to identify what it refers to. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/remote-viewer.c b/src/remote-viewer.c index 6d29bf2..13c6e7c 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -1005,9 +1005,6 @@ error: return success; } -#endif - -#ifdef HAVE_OVIRT static OvirtVm * choose_vm(GtkWindow *main_window, char **vm_name, @@ -1047,7 +1044,7 @@ choose_vm(GtkWindow *main_window, return vm; } -#endif +#endif /* HAVE_OVIRT */ static void remote_viewer_recent_add(gchar *uri, const gchar *mime_type) -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 07/10] iso-dialog: Implement functionality provided by oVirt foreign menu
Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer-iso-list-dialog.c| 205 - src/resources/ui/remote-viewer-iso-list.ui | 5 +- 2 files changed, 206 insertions(+), 4 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index 858719c..00371ff 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -20,12 +20,16 @@ #include +#include #include #include "remote-viewer-iso-list-dialog.h" #include "virt-viewer-util.h" #include "ovirt-foreign-menu.h" +static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self); +static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, gchar *message); + G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) #define DIALOG_PRIVATE(o) \ @@ -33,17 +37,32 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkListStore *list_store; GtkWidget *stack; +GtkWidget *tree_view; OvirtForeignMenu *foreign_menu; }; +enum RemoteViewerISOListDialogModel +{ +ISO_IS_ACTIVE = 0, +ISO_NAME, +FONT_WEIGHT, +}; + +void remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data); +void remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data); + static void remote_viewer_iso_list_dialog_dispose(GObject *object) { RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); RemoteViewerISOListDialogPrivate *priv = self->priv; -g_clear_object(&priv->foreign_menu); +if (priv->foreign_menu) { +g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); +g_clear_object(&priv->foreign_menu); +} G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); } @@ -58,6 +77,74 @@ remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass) } static void +remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); +gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "iso-list", + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE); +} + +static void +remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +char * current_iso = ovirt_foreign_menu_get_current_iso_name(self->priv->foreign_menu); +gboolean active = g_strcmp0(current_iso, name) == 0; +gint weight = active ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL; +GtkTreeIter iter; + +gtk_list_store_append(priv->list_store, &iter); +gtk_list_store_set(priv->list_store, &iter, + ISO_IS_ACTIVE, active, + ISO_NAME, name, + FONT_WEIGHT, weight, -1); + +if (active) { +GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(priv->list_store), &iter); +gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); +gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); +gtk_tree_path_free(path); +} + +free(current_iso); +} + +static void +fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, + GAsyncResult *result, + RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +GError *error = NULL; +GList *iso_list; + +iso_list = ovirt_foreign_menu_fetch_iso_names_finish(foreign_menu, result, &error); + +if (!iso_list) { +remote_viewer_iso_list_dialog_show_error(self, error ? error->message : _("Failed to fetch CD names")); +g_clear_error(&error); +return; +} + +iso_list = ovirt_foreign_menu_get_iso_names(priv->foreign_menu); +g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, self); +remote_viewer_iso_list_dialog_show_files(self); +} + + +static void +remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; + +gtk_list_store_clear(priv->list_store); +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, + (GAsyncReadyCallback) fetch_iso_names_cb, +
[virt-tools-list] [PATCH virt-viewer 08/10] iso-dialog: Use header bar for buttons
It seems to give more modern look to the dialog, but it requires Gtk+ 3.12, thus I will am keeping this commit separated. On the glade UI file, we get rid of the GtkAlignment object that was used to put some space between the tree view and dialog buttons. The "Select ISO" label is gone too. Signed-off-by: Eduardo Lima (Etrunko) --- configure.ac | 4 +- src/remote-viewer-iso-list-dialog.c| 31 +-- src/resources/ui/remote-viewer-iso-list.ui | 87 +++--- 3 files changed, 60 insertions(+), 62 deletions(-) diff --git a/configure.ac b/configure.ac index c611d70..ce71349 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38" GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" # Keep these two definitions in agreement. -GTK_REQUIRED="3.10" -GTK_ENCODED_VERSION="GDK_VERSION_3_10" +GTK_REQUIRED="3.12" +GTK_ENCODED_VERSION="GDK_VERSION_3_12" LIBXML2_REQUIRED="2.6.0" LIBVIRT_REQUIRED="0.10.0" diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index 00371ff..5aa7831 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -37,6 +37,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkHeaderBar *header_bar; GtkListStore *list_store; GtkWidget *stack; GtkWidget *tree_view; @@ -86,6 +87,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) } static void +remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *subtitle = NULL; + +if (iso_name && strlen(iso_name) != 0) +subtitle = g_strdup_printf(_("Current: %s"), iso_name); + +gtk_header_bar_set_subtitle(priv->header_bar, subtitle); +g_free(subtitle); +} + +static void remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) { RemoteViewerISOListDialogPrivate *priv = self->priv; @@ -105,6 +119,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); } free(current_iso); @@ -155,6 +170,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, if (response_id != GTK_RESPONSE_NONE) return; +remote_viewer_iso_list_dialog_set_subtitle(self, NULL); gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); @@ -208,9 +224,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); GtkCellRendererToggle *cell_renderer; +GtkWidget *button, *image; gtk_builder_connect_signals(builder, self); +priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self))); +gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE); + priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack")); gtk_box_pack_start(GTK_BOX(content), priv->stack, TRUE, TRUE, 0); @@ -222,12 +242,11 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) g_object_unref(builder); -gtk_dialog_add_buttons(GTK_DIALOG(self), - _("Refresh"), GTK_RESPONSE_NONE, - _("Close"), GTK_RESPONSE_CLOSE, - NULL); +button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE); +image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON); +gtk_button_set_image(GTK_BUTTON(button), image); +gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE); -gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL); } @@ -292,6 +311,7 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, g_free(name); } while (gtk_tree_model_iter_next(model, &iter)); +remote_viewer_iso_list_dialog_set_subtitle(self, curr
[virt-tools-list] [PATCH virt-viewer 09/10] Run iso-dialog when 'Change CD' menu is activated
Also makes 'Change CD' menu item a submenu under 'File' toplevel menu Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer.ui | 19 ++- src/virt-viewer-window.c| 37 + 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui index 6e3c5ad..e9609ec 100644 --- a/src/resources/ui/virt-viewer.ui +++ b/src/resources/ui/virt-viewer.ui @@ -1,6 +1,7 @@ + - + False @@ -73,6 +74,14 @@ + +False +_Change CD +True + + + + True False @@ -247,14 +256,6 @@ - - -False -False -_Change CD -True - - False diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 99fd102..a4f531e 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -43,6 +43,8 @@ #include "virt-viewer-util.h" #include "virt-viewer-timed-revealer.h" +#include "remote-viewer-iso-list-dialog.h" + #define ZOOM_STEP 10 /* Signal handlers for main window (move in a VirtViewerMainWindow?) */ @@ -62,6 +64,7 @@ void virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, VirtViewerWindow *self); +void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, VirtViewerWindow *self); /* Internal methods */ @@ -1056,6 +1059,40 @@ virt_viewer_window_menu_help_about(GtkWidget *menu G_GNUC_UNUSED, g_object_unref(G_OBJECT(about)); } +static void +iso_dialog_response(GtkDialog *dialog, +gint response_id, +gpointer user_data G_GNUC_UNUSED) +{ +if (response_id == GTK_RESPONSE_NONE) +return; + +gtk_widget_destroy(GTK_WIDGET(dialog)); +} + +void +virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED, + VirtViewerWindow *self) +{ +VirtViewerWindowPrivate *priv = self->priv; +GtkWidget *dialog; +GObject *foreign_menu; + +g_object_get(G_OBJECT(priv->app), "ovirt-foreign-menu", &foreign_menu, NULL); +dialog = remote_viewer_iso_list_dialog_new(GTK_WINDOW(priv->window), foreign_menu); +g_object_unref(foreign_menu); + +if (!dialog) +dialog = gtk_message_dialog_new(GTK_WINDOW(priv->window), +GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, +GTK_MESSAGE_ERROR, +GTK_BUTTONS_CLOSE, +_("Unable do connnect to oVirt")); + +g_signal_connect(dialog, "response", G_CALLBACK(iso_dialog_response), NULL); +gtk_widget_show_all(dialog); +gtk_dialog_run(GTK_DIALOG(dialog)); +} static void virt_viewer_window_toolbar_setup(VirtViewerWindow *self) -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 02/10] ovirt-foreign-menu: Set new ISO name using GTask API
This is done with the new ovirt_foreign_menu_set_current_iso_name_async function. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 117 ++- src/ovirt-foreign-menu.h | 10 2 files changed, 96 insertions(+), 31 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index a51f2c9..366259a 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -344,38 +344,102 @@ menu_item_set_active_no_signal(GtkMenuItem *menuitem, } -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; +GTask *task = G_TASK(user_data); +OvirtForeignMenu *foreign_menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task)); gboolean updated; -foreign_menu = OVIRT_FOREIGN_MENU(user_data); updated = ovirt_cdrom_update_finish(OVIRT_CDROM(source_object), result, &error); -g_debug("Finished updating cdrom content"); if (updated) { +g_debug("Finished updating cdrom content: %s", foreign_menu->priv->next_iso_name); 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; -g_object_notify(G_OBJECT(foreign_menu), "file"); +g_task_return_boolean(task, TRUE); +goto end; +} + +/* Reset old state back as we were not successful in switching to + * the new ISO */ +g_debug("setting OvirtCdrom:file back to '%s'", +foreign_menu->priv->current_iso_name); +g_object_set(foreign_menu->priv->cdrom, "file", + foreign_menu->priv->current_iso_name, NULL); +g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); + +if (error != NULL) { +g_warning("failed to update cdrom resource: %s", error->message); +g_task_return_error(task, error); } else { -/* Reset old state back as we were not successful in switching to - * the new ISO */ -const char *current_file = foreign_menu->priv->current_iso_name; +g_warn_if_reached(); +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, +"failed to update cdrom resource"); +} -if (error != NULL) { -g_warning("failed to update cdrom resource: %s", error->message); -g_clear_error(&error); -} -g_debug("setting OvirtCdrom:file back to '%s'", -current_file?current_file:NULL); -g_object_set(foreign_menu->priv->cdrom, "file", current_file, NULL); +end: +g_object_unref(task); +} + + +void ovirt_foreign_menu_set_current_iso_name_async(OvirtForeignMenu *foreign_menu, + const char *name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ +GTask *task; + +g_return_if_fail(foreign_menu->priv->cdrom != NULL); +g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); + +if (name) { +g_debug("Updating VM cdrom image to '%s'", name); +foreign_menu->priv->next_iso_name = g_strdup(name); +} else { +g_debug("Removing current cdrom image"); +foreign_menu->priv->next_iso_name = NULL; } -g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); +g_object_set(foreign_menu->priv->cdrom, + "file", name, + NULL); + +task = g_task_new(foreign_menu, cancellable, callback, user_data); +ovirt_cdrom_update_async(foreign_menu->priv->cdrom, TRUE, + foreign_menu->priv->proxy, NULL, + 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); +} + + +static void +ovirt_foreign_menu_iso_name_changed(GObject *source_object, +
[virt-tools-list] [PATCH virt-viewer 04/10] Introduce ISO List dialog
Signed-off-by: Eduardo Lima (Etrunko) --- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/remote-viewer-iso-list-dialog.c| 106 src/remote-viewer-iso-list-dialog.h| 58 +++ src/resources/ui/remote-viewer-iso-list.ui | 155 + src/resources/virt-viewer.gresource.xml| 1 + 6 files changed, 325 insertions(+) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 69d9fef..371c242 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,9 +1,11 @@ data/remote-viewer.appdata.xml.in data/remote-viewer.desktop.in data/virt-viewer-mime.xml.in +src/remote-viewer-iso-list-dialog.c src/remote-viewer-main.c src/remote-viewer.c [type: gettext/glade] src/resources/ui/remote-viewer-connect.ui +[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui [type: gettext/glade] src/resources/ui/virt-viewer-about.ui src/virt-viewer-app.c src/virt-viewer-auth.c diff --git a/src/Makefile.am b/src/Makefile.am index 272c4ff..9748277 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ noinst_DATA = \ resources/ui/virt-viewer-vm-connection.ui \ resources/ui/virt-viewer-preferences.ui \ resources/ui/remote-viewer-connect.ui \ + resources/ui/remote-viewer-iso-list.ui \ resources/ui/virt-viewer-file-transfer-dialog.ui \ $(NULL) @@ -97,6 +98,8 @@ if HAVE_OVIRT libvirt_viewer_la_SOURCES += \ ovirt-foreign-menu.h \ ovirt-foreign-menu.c \ + remote-viewer-iso-list-dialog.c \ + remote-viewer-iso-list-dialog.h \ $(NULL) endif diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c new file mode 100644 index 000..0fbea28 --- /dev/null +++ b/src/remote-viewer-iso-list-dialog.c @@ -0,0 +1,106 @@ +/* + * Virt Viewer: A virtual machine console viewer + * + * Copyright (C) 2016 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include + +#include "remote-viewer-iso-list-dialog.h" +#include "virt-viewer-util.h" + +G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) + +#define DIALOG_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate)) + +struct _RemoteViewerISOListDialogPrivate +{ +GtkWidget *stack; +}; + +static void +remote_viewer_iso_list_dialog_dispose(GObject *object) +{ + G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); +} + +static void +remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass) +{ +GObjectClass *object_class = G_OBJECT_CLASS(klass); + +g_type_class_add_private(klass, sizeof(RemoteViewerISOListDialogPrivate)); + +object_class->dispose = remote_viewer_iso_list_dialog_dispose; +} + +static void +remote_viewer_iso_list_dialog_response(GtkDialog *dialog, + gint response_id, + gpointer user_data G_GNUC_UNUSED) +{ +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); +RemoteViewerISOListDialogPrivate *priv = self->priv; + +if (response_id != GTK_RESPONSE_NONE) +return; + +gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_CLOSE, FALSE); +} + +static void +remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) +{ +GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(self)); +RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); +GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); + +gtk_builder_connect_signals(builder, self); + +priv->stack = GTK_WIDGET(gtk_builder_get_object(builder,
[virt-tools-list] [PATCH virt-viewer 00/10] Replace oVirt foreign menu with dedicated dialog
Final version of this series, this time I changed the order of the patches so that the set/get ISO names port to GTask API will come first, and only after that the dialog is introduced. Finally, the last patch will remove the old code. Eduardo Lima (Etrunko) (10): remote-viewer: Extend #ifdef HAVE_OVIRT block ovirt-foreign-menu: Set new ISO name using GTask API ovirt-foreign-menu: Fetch ISO names using GTask API Introduce ISO List dialog remote-viewer: Make ovirt-foreign-menu a property ovirt-foreign-menu: Add accessors for current iso and iso list iso-dialog: Implement functionality provided by oVirt foreign menu iso-dialog: Use header bar for buttons Run iso-dialog when 'Change CD' menu is activated ovirt-foreign-menu: Remove GtkMenu related functions configure.ac | 4 +- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/ovirt-foreign-menu.c | 293 - src/ovirt-foreign-menu.h | 21 +- src/remote-viewer-iso-list-dialog.c| 341 + src/remote-viewer-iso-list-dialog.h| 58 + src/remote-viewer.c| 92 src/resources/ui/remote-viewer-iso-list.ui | 135 src/resources/ui/virt-viewer.ui| 19 +- src/resources/virt-viewer.gresource.xml| 1 + src/virt-viewer-window.c | 37 12 files changed, 788 insertions(+), 218 deletions(-) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 03/10] ovirt-foreign-menu: Fetch ISO names using GTask API
On 17/01/17 13:57, Christophe Fergeau wrote: > On Fri, Jan 13, 2017 at 07:11:05PM -0200, Eduardo Lima (Etrunko) wrote: >> Similar to the previous commit, the ISO dialog will fetch the result >> asynchronously, rather than relying on the "notify::files" signal from >> OvirtForeignMenu object. It also enables error to be shown if anything >> goes wrong. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/ovirt-foreign-menu.c | 159 >> +-- >> src/ovirt-foreign-menu.h | 9 ++- >> src/remote-viewer.c | 45 -- >> 3 files changed, 135 insertions(+), 78 deletions(-) >> >> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c >> index 366259a..6892f0d 100644 >> --- a/src/ovirt-foreign-menu.c >> +++ b/src/ovirt-foreign-menu.c >> @@ -40,13 +40,13 @@ typedef enum { >> STATE_ISOS >> } OvirtForeignMenuState; >> >> -static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, >> OvirtForeignMenuState state); >> -static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu); >> -static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu); >> -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 gboolean ovirt_foreign_menu_refresh_iso_list(gpointer user_data); >> +static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, >> GTask *task, OvirtForeignMenuState state); >> +static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, >> GTask *task); >> +static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask >> *task); >> +static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu >> *menu, GTask *task); >> +static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, >> GTask *task); >> +static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu >> *menu, GTask *task); >> +static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, >> GTask *task); > > Wondering if it would make sense to pass the GTask around as an > OvirtForeignMenu member? > Not really sure, I don't know if there can be more than one task running at the same time, such as one for fetching and another for setting, so in this case it would get overwritten. >> >> G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT) >> >> @@ -273,11 +273,9 @@ OvirtForeignMenu* ovirt_foreign_menu_new(OvirtProxy >> *proxy) >> >> static void >> ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, >> + GTask *task, >> OvirtForeignMenuState current_state) >> { >> -g_return_if_fail(current_state >= STATE_0); >> -g_return_if_fail(current_state < STATE_ISOS); >> - > > Why drop this? At this point we are already in the async task and the error case will be dealt in default below. > >> /* Each state will check if the member is initialized, falling directly >> to >> * the next one if so. If not, the callback for the asynchronous call >> will >> * be responsible for calling is function again with the next state as >> @@ -286,26 +284,26 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu >> *menu, >> switch (current_state + 1) { >> case STATE_API: >> if (menu->priv->api == NULL) { >> -ovirt_foreign_menu_fetch_api_async(menu); >> +ovirt_foreign_menu_fetch_api_async(menu, task); >> break; >> } >> case STATE_VM: >> if (menu->priv->vm == NULL) { >> -ovirt_foreign_menu_fetch_vm_async(menu); >> +ovirt_foreign_menu_fetch_vm_async(menu, task); >> break; >> } >> case STATE_STORAGE_DOMAIN: >> if (menu->priv->files == NULL) { >> -ovirt_foreign_menu_fetch_storage_domain_async(menu); >> +ovirt_foreign_menu_fetch_storage_domain_async(menu, task); >> break; >> } >> case STATE_VM_CDROM: >> if (menu->priv->cdrom == NULL) { >> -ovirt_foreign_menu_fetch_vm_cdrom_async(menu); >> +ov
[virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Fetch ISO names using GTask API
Similar to the previous commit, the ISO dialog will fetch the result asynchronously, rather than relying on the "notify::files" signal from OvirtForeignMenu object. It also enables error to be shown if anything goes wrong. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 170 +++ src/ovirt-foreign-menu.h | 9 ++- src/remote-viewer.c | 45 +++-- 3 files changed, 147 insertions(+), 77 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 366259a..50a8ea6 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -40,13 +40,13 @@ typedef enum { STATE_ISOS } OvirtForeignMenuState; -static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, OvirtForeignMenuState state); -static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu); -static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu); -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 gboolean ovirt_foreign_menu_refresh_iso_list(gpointer user_data); +static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, GTask *task, OvirtForeignMenuState state); +static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, GTask *task); G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT) @@ -273,11 +273,9 @@ OvirtForeignMenu* ovirt_foreign_menu_new(OvirtProxy *proxy) static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, + GTask *task, OvirtForeignMenuState current_state) { -g_return_if_fail(current_state >= STATE_0); -g_return_if_fail(current_state < STATE_ISOS); - /* Each state will check if the member is initialized, falling directly to * the next one if so. If not, the callback for the asynchronous call will * be responsible for calling is function again with the next state as @@ -286,26 +284,26 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, switch (current_state + 1) { case STATE_API: if (menu->priv->api == NULL) { -ovirt_foreign_menu_fetch_api_async(menu); +ovirt_foreign_menu_fetch_api_async(menu, task); break; } case STATE_VM: if (menu->priv->vm == NULL) { -ovirt_foreign_menu_fetch_vm_async(menu); +ovirt_foreign_menu_fetch_vm_async(menu, task); break; } case STATE_STORAGE_DOMAIN: if (menu->priv->files == NULL) { -ovirt_foreign_menu_fetch_storage_domain_async(menu); +ovirt_foreign_menu_fetch_storage_domain_async(menu, task); break; } case STATE_VM_CDROM: if (menu->priv->cdrom == NULL) { -ovirt_foreign_menu_fetch_vm_cdrom_async(menu); +ovirt_foreign_menu_fetch_vm_cdrom_async(menu, task); break; } case STATE_CDROM_FILE: -ovirt_foreign_menu_refresh_cdrom_file_async(menu); +ovirt_foreign_menu_refresh_cdrom_file_async(menu, task); break; case STATE_ISOS: g_warn_if_fail(menu->priv->api != NULL); @@ -313,18 +311,35 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, g_warn_if_fail(menu->priv->files != NULL); g_warn_if_fail(menu->priv->cdrom != NULL); -ovirt_foreign_menu_refresh_iso_list(menu); +ovirt_foreign_menu_fetch_iso_list_async(menu, task); break; default: g_warn_if_reached(); +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, +"Invalid state: %d", current_state); +g_object_unref(task); } } void -ovirt_foreign_menu_start(OvirtForeignMenu *menu) +ovirt_foreign_menu_fetch_iso_names_async(OvirtForeignMenu *menu, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ +GTask *task = g_task_new(menu, cancellable, callback, user_data); +ovirt_foreign_menu_next_async_step(menu, task, STATE_0); +} + + +GList * +ovir
Re: [virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer: Make ovirt-foreign-menu a property
On 17/01/17 14:00, Christophe Fergeau wrote: > On Fri, Jan 13, 2017 at 07:11:07PM -0200, Eduardo Lima (Etrunko) wrote: >> The OvirtForeignMenu pointer is needed by the new ISO list dialog, and >> we make it acessible via property to avoid interdependency between >> objects. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer-iso-list-dialog.c | 31 +++ >> src/remote-viewer-iso-list-dialog.h | 2 +- >> src/remote-viewer.c | 37 >> + >> 3 files changed, 61 insertions(+), 9 deletions(-) >> >> diff --git a/src/remote-viewer-iso-list-dialog.c >> b/src/remote-viewer-iso-list-dialog.c >> index 0fbea28..858719c 100644 >> --- a/src/remote-viewer-iso-list-dialog.c >> +++ b/src/remote-viewer-iso-list-dialog.c >> @@ -24,6 +24,7 @@ >> >> #include "remote-viewer-iso-list-dialog.h" >> #include "virt-viewer-util.h" >> +#include "ovirt-foreign-menu.h" >> >> G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, >> GTK_TYPE_DIALOG) >> >> @@ -33,11 +34,16 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, >> remote_viewer_iso_list_dialog, GTK_TYPE >> struct _RemoteViewerISOListDialogPrivate >> { >> GtkWidget *stack; >> +OvirtForeignMenu *foreign_menu; >> }; >> >> static void >> remote_viewer_iso_list_dialog_dispose(GObject *object) >> { >> +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); >> +RemoteViewerISOListDialogPrivate *priv = self->priv; >> + >> +g_clear_object(&priv->foreign_menu); >> >> G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); >> } >> >> @@ -94,13 +100,22 @@ >> remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) >> } >> >> GtkWidget * >> -remote_viewer_iso_list_dialog_new(GtkWindow *parent) >> +remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu) >> { >> -return g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >> -"title", _("Change CD"), >> -"transient-for", parent, >> -"border-width", 18, >> -"default-width", 400, >> -"default-height", 300, >> -NULL); >> +GtkWidget *dialog; >> +RemoteViewerISOListDialog *self; >> + >> +g_return_val_if_fail(foreign_menu != NULL, NULL); >> + >> +dialog = g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >> + "title", _("Change CD"), >> + "transient-for", parent, >> + "border-width", 18, >> + "default-width", 400, >> + "default-height", 300, >> + NULL); >> + >> +self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); >> +self->priv->foreign_menu = >> OVIRT_FOREIGN_MENU(g_object_ref(foreign_menu)); > > Fwiw, a construct-only GObject property would be more expected (but you > can keep it this way i f you think it's better). No objections, I will change it. > >> +return dialog; >> } >> diff --git a/src/remote-viewer-iso-list-dialog.h >> b/src/remote-viewer-iso-list-dialog.h >> index def841b..8b936f5 100644 >> --- a/src/remote-viewer-iso-list-dialog.h >> +++ b/src/remote-viewer-iso-list-dialog.h >> @@ -51,7 +51,7 @@ struct _RemoteViewerISOListDialogClass >> >> GType remote_viewer_iso_list_dialog_get_type(void) G_GNUC_CONST; >> >> -GtkWidget *remote_viewer_iso_list_dialog_new(GtkWindow *parent); >> +GtkWidget *remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject >> *foreign_menu); >> >> G_END_DECLS >> > > The remote-viewer-iso-list-dialog.[ch] changes are odd in this patch, > they don't have much to do with the added > RemoteViewer::ovirt-foreign-menu property at this point. > I think this part of the patch can probably be merged with the previous > one, the property addition can be done before that. > Thanks for the review. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer: Make ovirt-foreign-menu a property
On 18/01/17 09:53, Eduardo Lima (Etrunko) wrote: > On 17/01/17 14:00, Christophe Fergeau wrote: >> On Fri, Jan 13, 2017 at 07:11:07PM -0200, Eduardo Lima (Etrunko) wrote: >>> The OvirtForeignMenu pointer is needed by the new ISO list dialog, and >>> we make it acessible via property to avoid interdependency between >>> objects. >>> >>> Signed-off-by: Eduardo Lima (Etrunko) >>> --- >>> src/remote-viewer-iso-list-dialog.c | 31 +++ >>> src/remote-viewer-iso-list-dialog.h | 2 +- >>> src/remote-viewer.c | 37 >>> + >>> 3 files changed, 61 insertions(+), 9 deletions(-) >>> >>> diff --git a/src/remote-viewer-iso-list-dialog.c >>> b/src/remote-viewer-iso-list-dialog.c >>> index 0fbea28..858719c 100644 >>> --- a/src/remote-viewer-iso-list-dialog.c >>> +++ b/src/remote-viewer-iso-list-dialog.c >>> @@ -24,6 +24,7 @@ >>> >>> #include "remote-viewer-iso-list-dialog.h" >>> #include "virt-viewer-util.h" >>> +#include "ovirt-foreign-menu.h" >>> >>> G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, >>> GTK_TYPE_DIALOG) >>> >>> @@ -33,11 +34,16 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, >>> remote_viewer_iso_list_dialog, GTK_TYPE >>> struct _RemoteViewerISOListDialogPrivate >>> { >>> GtkWidget *stack; >>> +OvirtForeignMenu *foreign_menu; >>> }; >>> >>> static void >>> remote_viewer_iso_list_dialog_dispose(GObject *object) >>> { >>> +RemoteViewerISOListDialog *self = >>> REMOTE_VIEWER_ISO_LIST_DIALOG(object); >>> +RemoteViewerISOListDialogPrivate *priv = self->priv; >>> + >>> +g_clear_object(&priv->foreign_menu); >>> >>> G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); >>> } >>> >>> @@ -94,13 +100,22 @@ >>> remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) >>> } >>> >>> GtkWidget * >>> -remote_viewer_iso_list_dialog_new(GtkWindow *parent) >>> +remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu) >>> { >>> -return g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >>> -"title", _("Change CD"), >>> -"transient-for", parent, >>> -"border-width", 18, >>> -"default-width", 400, >>> -"default-height", 300, >>> -NULL); >>> +GtkWidget *dialog; >>> +RemoteViewerISOListDialog *self; >>> + >>> +g_return_val_if_fail(foreign_menu != NULL, NULL); >>> + >>> +dialog = g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >>> + "title", _("Change CD"), >>> + "transient-for", parent, >>> + "border-width", 18, >>> + "default-width", 400, >>> + "default-height", 300, >>> + NULL); >>> + >>> +self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); >>> +self->priv->foreign_menu = >>> OVIRT_FOREIGN_MENU(g_object_ref(foreign_menu)); >> >> Fwiw, a construct-only GObject property would be more expected (but you >> can keep it this way i f you think it's better). > > > No objections, I will change it. Thinking better about this, it is not possible to make it a construct only, because the ovirt object is created later on the process, when remote-viewer has already started. Also, there is the possibility of the pointer being set or not, depending on how the application was invoked. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 07/10] iso-dialog: Implement functionality provided by oVirt foreign menu
On 17/01/17 14:01, Christophe Fergeau wrote: > On Fri, Jan 13, 2017 at 07:11:09PM -0200, Eduardo Lima (Etrunko) wrote: >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer-iso-list-dialog.c| 205 >> - >> src/resources/ui/remote-viewer-iso-list.ui | 5 +- >> 2 files changed, 206 insertions(+), 4 deletions(-) >> >> diff --git a/src/remote-viewer-iso-list-dialog.c >> b/src/remote-viewer-iso-list-dialog.c >> index 858719c..00371ff 100644 >> --- a/src/remote-viewer-iso-list-dialog.c >> +++ b/src/remote-viewer-iso-list-dialog.c >> @@ -20,12 +20,16 @@ >> >> #include >> >> +#include > > This is added because you call free() in a few places, but why are you > not using g_free() in these places? As a matter of consistency, because in ovirt-foreign-menu, we return a char *, not a gchar *, although I know there is no difference. I can change that function to return a gchar and then use g_free all around. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer: Make ovirt-foreign-menu a property
On 18/01/17 10:53, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 10:08:42AM -0200, Eduardo Lima (Etrunko) wrote: >> On 18/01/17 09:53, Eduardo Lima (Etrunko) wrote: >>> On 17/01/17 14:00, Christophe Fergeau wrote: >>>> On Fri, Jan 13, 2017 at 07:11:07PM -0200, Eduardo Lima (Etrunko) wrote: >>>>> The OvirtForeignMenu pointer is needed by the new ISO list dialog, and >>>>> we make it acessible via property to avoid interdependency between >>>>> objects. >>>>> >>>>> Signed-off-by: Eduardo Lima (Etrunko) >>>>> --- >>>>> src/remote-viewer-iso-list-dialog.c | 31 +++ >>>>> src/remote-viewer-iso-list-dialog.h | 2 +- >>>>> src/remote-viewer.c | 37 >>>>> + >>>>> 3 files changed, 61 insertions(+), 9 deletions(-) >>>>> >>>>> diff --git a/src/remote-viewer-iso-list-dialog.c >>>>> b/src/remote-viewer-iso-list-dialog.c >>>>> index 0fbea28..858719c 100644 >>>>> --- a/src/remote-viewer-iso-list-dialog.c >>>>> +++ b/src/remote-viewer-iso-list-dialog.c >>>>> @@ -24,6 +24,7 @@ >>>>> >>>>> #include "remote-viewer-iso-list-dialog.h" >>>>> #include "virt-viewer-util.h" >>>>> +#include "ovirt-foreign-menu.h" >>>>> >>>>> G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, >>>>> GTK_TYPE_DIALOG) >>>>> >>>>> @@ -33,11 +34,16 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, >>>>> remote_viewer_iso_list_dialog, GTK_TYPE >>>>> struct _RemoteViewerISOListDialogPrivate >>>>> { >>>>> GtkWidget *stack; >>>>> +OvirtForeignMenu *foreign_menu; >>>>> }; >>>>> >>>>> static void >>>>> remote_viewer_iso_list_dialog_dispose(GObject *object) >>>>> { >>>>> +RemoteViewerISOListDialog *self = >>>>> REMOTE_VIEWER_ISO_LIST_DIALOG(object); >>>>> +RemoteViewerISOListDialogPrivate *priv = self->priv; >>>>> + >>>>> +g_clear_object(&priv->foreign_menu); >>>>> >>>>> G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); >>>>> } >>>>> >>>>> @@ -94,13 +100,22 @@ >>>>> remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) >>>>> } >>>>> >>>>> GtkWidget * >>>>> -remote_viewer_iso_list_dialog_new(GtkWindow *parent) >>>>> +remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject >>>>> *foreign_menu) >>>>> { >>>>> -return g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >>>>> -"title", _("Change CD"), >>>>> -"transient-for", parent, >>>>> -"border-width", 18, >>>>> -"default-width", 400, >>>>> -"default-height", 300, >>>>> -NULL); >>>>> +GtkWidget *dialog; >>>>> +RemoteViewerISOListDialog *self; >>>>> + >>>>> +g_return_val_if_fail(foreign_menu != NULL, NULL); >>>>> + >>>>> +dialog = g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >>>>> + "title", _("Change CD"), >>>>> + "transient-for", parent, >>>>> + "border-width", 18, >>>>> + "default-width", 400, >>>>> + "default-height", 300, >>>>> + NULL); >>>>> + >>>>> +self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); >>>>> +self->priv->foreign_menu = >>>>> OVIRT_FOREIGN_MENU(g_object_ref(foreign_menu)); >>>> >>>> Fwiw, a construct-only GObject property would be more expected (but you >>>> can keep it this way i f you think it's better). >>> >>> >>> No objections, I will change it. >> >> >> Thinking better about this, it is not possible to make it a construct >> only, because the ovirt object is created later on the process, when >> remote-viewer has already started. Also, there is the possibility of the >> pointer being set or not, depending on how the application was invoked. > > I don't understand what you mean here. In the part of the code quoted > above, a RemoteViewerISOListDialog instance is created, and right after > that, we set self->priv->foreign_menu on that instance, so in this case, > a CONSTRUCT_ONLY property would be fine. The ovirt-foreign-menu property is installed as a member of RemoteViewer object, not RemoteViewerISODialog. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer: Make ovirt-foreign-menu a property
On 18/01/17 11:06, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 10:56:59AM -0200, Eduardo Lima (Etrunko) wrote: >> On 18/01/17 10:53, Christophe Fergeau wrote: >>> On Wed, Jan 18, 2017 at 10:08:42AM -0200, Eduardo Lima (Etrunko) wrote: >>>> On 18/01/17 09:53, Eduardo Lima (Etrunko) wrote: >>>>> On 17/01/17 14:00, Christophe Fergeau wrote: >>>>>> On Fri, Jan 13, 2017 at 07:11:07PM -0200, Eduardo Lima (Etrunko) wrote: >>>>>>> The OvirtForeignMenu pointer is needed by the new ISO list dialog, and >>>>>>> we make it acessible via property to avoid interdependency between >>>>>>> objects. >>>>>>> >>>>>>> Signed-off-by: Eduardo Lima (Etrunko) >>>>>>> --- >>>>>>> src/remote-viewer-iso-list-dialog.c | 31 >>>>>>> +++ >>>>>>> src/remote-viewer-iso-list-dialog.h | 2 +- >>>>>>> src/remote-viewer.c | 37 >>>>>>> + >>>>>>> 3 files changed, 61 insertions(+), 9 deletions(-) >>>>>>> >>>>>>> diff --git a/src/remote-viewer-iso-list-dialog.c >>>>>>> b/src/remote-viewer-iso-list-dialog.c >>>>>>> index 0fbea28..858719c 100644 >>>>>>> --- a/src/remote-viewer-iso-list-dialog.c >>>>>>> +++ b/src/remote-viewer-iso-list-dialog.c >>>>>>> @@ -24,6 +24,7 @@ >>>>>>> >>>>>>> #include "remote-viewer-iso-list-dialog.h" >>>>>>> #include "virt-viewer-util.h" >>>>>>> +#include "ovirt-foreign-menu.h" >>>>>>> >>>>>>> G_DEFINE_TYPE(RemoteViewerISOListDialog, >>>>>>> remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) >>>>>>> >>>>>>> @@ -33,11 +34,16 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, >>>>>>> remote_viewer_iso_list_dialog, GTK_TYPE >>>>>>> struct _RemoteViewerISOListDialogPrivate >>>>>>> { >>>>>>> GtkWidget *stack; >>>>>>> +OvirtForeignMenu *foreign_menu; >>>>>>> }; >>>>>>> >>>>>>> static void >>>>>>> remote_viewer_iso_list_dialog_dispose(GObject *object) >>>>>>> { >>>>>>> +RemoteViewerISOListDialog *self = >>>>>>> REMOTE_VIEWER_ISO_LIST_DIALOG(object); >>>>>>> +RemoteViewerISOListDialogPrivate *priv = self->priv; >>>>>>> + >>>>>>> +g_clear_object(&priv->foreign_menu); >>>>>>> >>>>>>> G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); >>>>>>> } >>>>>>> >>>>>>> @@ -94,13 +100,22 @@ >>>>>>> remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) >>>>>>> } >>>>>>> >>>>>>> GtkWidget * >>>>>>> -remote_viewer_iso_list_dialog_new(GtkWindow *parent) >>>>>>> +remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject >>>>>>> *foreign_menu) >>>>>>> { >>>>>>> -return g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >>>>>>> -"title", _("Change CD"), >>>>>>> -"transient-for", parent, >>>>>>> -"border-width", 18, >>>>>>> -"default-width", 400, >>>>>>> -"default-height", 300, >>>>>>> -NULL); >>>>>>> +GtkWidget *dialog; >>>>>>> +RemoteViewerISOListDialog *self; >>>>>>> + >>>>>>> +g_return_val_if_fail(foreign_menu != NULL, NULL); >>>>>>> + >>>>>>> +dialog = g_object_new(REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, >>>>>>> + "title", _("Change CD"), >>>>>>> + "transient-for", parent, >&
Re: [virt-tools-list] [PATCH virt-viewer 01/10] remote-viewer: Extend #ifdef HAVE_OVIRT block
On 17/01/17 13:51, Christophe Fergeau wrote: > Acked-by: Christophe Fergeau Pushed, thanks > > On Fri, Jan 13, 2017 at 07:11:03PM -0200, Eduardo Lima (Etrunko) wrote: >> The #endif is closing a #ifdef HAVE_OVIRT block, while another one is >> opened right next, so there is no need to have those lines. Also, due to >> the large amount of source code in between, add a small comment on the >> last #endif to identify what it refers to. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer.c | 5 + >> 1 file changed, 1 insertion(+), 4 deletions(-) >> >> diff --git a/src/remote-viewer.c b/src/remote-viewer.c >> index 6d29bf2..13c6e7c 100644 >> --- a/src/remote-viewer.c >> +++ b/src/remote-viewer.c >> @@ -1005,9 +1005,6 @@ error: >> return success; >> } >> >> -#endif >> - >> -#ifdef HAVE_OVIRT >> static OvirtVm * >> choose_vm(GtkWindow *main_window, >>char **vm_name, >> @@ -1047,7 +1044,7 @@ choose_vm(GtkWindow *main_window, >> >> return vm; >> } >> -#endif >> +#endif /* HAVE_OVIRT */ >> >> static void >> remote_viewer_recent_add(gchar *uri, const gchar *mime_type) >> -- >> 2.9.3 >> >> ___ >> virt-tools-list mailing list >> virt-tools-list@redhat.com >> https://www.redhat.com/mailman/listinfo/virt-tools-list -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 4/9] Introduce ISO List dialog
Signed-off-by: Eduardo Lima (Etrunko) --- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/remote-viewer-iso-list-dialog.c| 121 ++ src/remote-viewer-iso-list-dialog.h| 58 +++ src/resources/ui/remote-viewer-iso-list.ui | 155 + src/resources/virt-viewer.gresource.xml| 1 + 6 files changed, 340 insertions(+) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 69d9fef..371c242 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,9 +1,11 @@ data/remote-viewer.appdata.xml.in data/remote-viewer.desktop.in data/virt-viewer-mime.xml.in +src/remote-viewer-iso-list-dialog.c src/remote-viewer-main.c src/remote-viewer.c [type: gettext/glade] src/resources/ui/remote-viewer-connect.ui +[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui [type: gettext/glade] src/resources/ui/virt-viewer-about.ui src/virt-viewer-app.c src/virt-viewer-auth.c diff --git a/src/Makefile.am b/src/Makefile.am index 272c4ff..9748277 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ noinst_DATA = \ resources/ui/virt-viewer-vm-connection.ui \ resources/ui/virt-viewer-preferences.ui \ resources/ui/remote-viewer-connect.ui \ + resources/ui/remote-viewer-iso-list.ui \ resources/ui/virt-viewer-file-transfer-dialog.ui \ $(NULL) @@ -97,6 +98,8 @@ if HAVE_OVIRT libvirt_viewer_la_SOURCES += \ ovirt-foreign-menu.h \ ovirt-foreign-menu.c \ + remote-viewer-iso-list-dialog.c \ + remote-viewer-iso-list-dialog.h \ $(NULL) endif diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c new file mode 100644 index 000..858719c --- /dev/null +++ b/src/remote-viewer-iso-list-dialog.c @@ -0,0 +1,121 @@ +/* + * Virt Viewer: A virtual machine console viewer + * + * Copyright (C) 2016 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include + +#include "remote-viewer-iso-list-dialog.h" +#include "virt-viewer-util.h" +#include "ovirt-foreign-menu.h" + +G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) + +#define DIALOG_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate)) + +struct _RemoteViewerISOListDialogPrivate +{ +GtkWidget *stack; +OvirtForeignMenu *foreign_menu; +}; + +static void +remote_viewer_iso_list_dialog_dispose(GObject *object) +{ +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); +RemoteViewerISOListDialogPrivate *priv = self->priv; + +g_clear_object(&priv->foreign_menu); + G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); +} + +static void +remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass) +{ +GObjectClass *object_class = G_OBJECT_CLASS(klass); + +g_type_class_add_private(klass, sizeof(RemoteViewerISOListDialogPrivate)); + +object_class->dispose = remote_viewer_iso_list_dialog_dispose; +} + +static void +remote_viewer_iso_list_dialog_response(GtkDialog *dialog, + gint response_id, + gpointer user_data G_GNUC_UNUSED) +{ +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); +RemoteViewerISOListDialogPrivate *priv = self->priv; + +if (response_id != GTK_RESPONSE_NONE) +return; + +gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_CLOSE, FALSE); +} + +static void +remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) +{ +GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(self)); +RemoteViewe
[virt-tools-list] [PATCH virt-viewer 3/9] remote-viewer: Make ovirt-foreign-menu a property
The OvirtForeignMenu pointer is needed by the new ISO list dialog, and we make it acessible via property to avoid interdependency between objects. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer.c | 37 + 1 file changed, 37 insertions(+) diff --git a/src/remote-viewer.c b/src/remote-viewer.c index c84a35b..29d7db1 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP) #define GET_PRIVATE(o)\ (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate)) +enum RemoteViewerProperties { +PROP_0, +#ifdef HAVE_OVIRT +PROP_OVIRT_FOREIGN_MENU, +#endif +}; + #ifdef HAVE_OVIRT static OvirtVm * choose_vm(GtkWindow *main_window, char **vm_name, @@ -214,6 +221,25 @@ end: } static void +remote_viewer_get_property(GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ +RemoteViewer *self = REMOTE_VIEWER(object); +RemoteViewerPrivate *priv = self->priv; + +switch (property_id) { +#ifdef HAVE_OVIRT +case PROP_OVIRT_FOREIGN_MENU: +g_value_set_object(value, priv->ovirt_foreign_menu); +break; +#endif + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} +} + +static void remote_viewer_class_init (RemoteViewerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass) g_type_class_add_private (klass, sizeof (RemoteViewerPrivate)); +object_class->get_property = remote_viewer_get_property; object_class->dispose = remote_viewer_dispose; g_app_class->local_command_line = remote_viewer_local_command_line; @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClass *klass) #else (void) gtk_app_class; #endif + +#ifdef HAVE_OVIRT +g_object_class_install_property(object_class, +PROP_OVIRT_FOREIGN_MENU, +g_param_spec_object("ovirt-foreign-menu", +"oVirt Foreign Menu", +"Object which is used as interface to oVirt", + OVIRT_TYPE_FOREIGN_MENU, +G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); +#endif } static void -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 1/9] ovirt-foreign-menu: Set new ISO name using GTask API
This is done with the new ovirt_foreign_menu_set_current_iso_name_async function. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 117 ++- src/ovirt-foreign-menu.h | 10 2 files changed, 96 insertions(+), 31 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index a51f2c9..366259a 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -344,38 +344,102 @@ menu_item_set_active_no_signal(GtkMenuItem *menuitem, } -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; +GTask *task = G_TASK(user_data); +OvirtForeignMenu *foreign_menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task)); gboolean updated; -foreign_menu = OVIRT_FOREIGN_MENU(user_data); updated = ovirt_cdrom_update_finish(OVIRT_CDROM(source_object), result, &error); -g_debug("Finished updating cdrom content"); if (updated) { +g_debug("Finished updating cdrom content: %s", foreign_menu->priv->next_iso_name); 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; -g_object_notify(G_OBJECT(foreign_menu), "file"); +g_task_return_boolean(task, TRUE); +goto end; +} + +/* Reset old state back as we were not successful in switching to + * the new ISO */ +g_debug("setting OvirtCdrom:file back to '%s'", +foreign_menu->priv->current_iso_name); +g_object_set(foreign_menu->priv->cdrom, "file", + foreign_menu->priv->current_iso_name, NULL); +g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); + +if (error != NULL) { +g_warning("failed to update cdrom resource: %s", error->message); +g_task_return_error(task, error); } else { -/* Reset old state back as we were not successful in switching to - * the new ISO */ -const char *current_file = foreign_menu->priv->current_iso_name; +g_warn_if_reached(); +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, +"failed to update cdrom resource"); +} -if (error != NULL) { -g_warning("failed to update cdrom resource: %s", error->message); -g_clear_error(&error); -} -g_debug("setting OvirtCdrom:file back to '%s'", -current_file?current_file:NULL); -g_object_set(foreign_menu->priv->cdrom, "file", current_file, NULL); +end: +g_object_unref(task); +} + + +void ovirt_foreign_menu_set_current_iso_name_async(OvirtForeignMenu *foreign_menu, + const char *name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ +GTask *task; + +g_return_if_fail(foreign_menu->priv->cdrom != NULL); +g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); + +if (name) { +g_debug("Updating VM cdrom image to '%s'", name); +foreign_menu->priv->next_iso_name = g_strdup(name); +} else { +g_debug("Removing current cdrom image"); +foreign_menu->priv->next_iso_name = NULL; } -g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); +g_object_set(foreign_menu->priv->cdrom, + "file", name, + NULL); + +task = g_task_new(foreign_menu, cancellable, callback, user_data); +ovirt_cdrom_update_async(foreign_menu->priv->cdrom, TRUE, + foreign_menu->priv->proxy, NULL, + 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); +} + + +static void +ovirt_foreign_menu_iso_name_changed(GObject *source_object, +
[virt-tools-list] [PATCH virt-viewer 6/9] iso-dialog: Implement functionality provided by oVirt foreign menu
Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer-iso-list-dialog.c| 204 - src/resources/ui/remote-viewer-iso-list.ui | 5 +- 2 files changed, 205 insertions(+), 4 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index 858719c..ef60854 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -26,6 +26,9 @@ #include "virt-viewer-util.h" #include "ovirt-foreign-menu.h" +static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self); +static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, gchar *message); + G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) #define DIALOG_PRIVATE(o) \ @@ -33,17 +36,32 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkListStore *list_store; GtkWidget *stack; +GtkWidget *tree_view; OvirtForeignMenu *foreign_menu; }; +enum RemoteViewerISOListDialogModel +{ +ISO_IS_ACTIVE = 0, +ISO_NAME, +FONT_WEIGHT, +}; + +void remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data); +void remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data); + static void remote_viewer_iso_list_dialog_dispose(GObject *object) { RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); RemoteViewerISOListDialogPrivate *priv = self->priv; -g_clear_object(&priv->foreign_menu); +if (priv->foreign_menu) { +g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); +g_clear_object(&priv->foreign_menu); +} G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); } @@ -58,6 +76,74 @@ remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass) } static void +remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); +gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "iso-list", + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE); +} + +static void +remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *current_iso = ovirt_foreign_menu_get_current_iso_name(self->priv->foreign_menu); +gboolean active = g_strcmp0(current_iso, name) == 0; +gint weight = active ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL; +GtkTreeIter iter; + +gtk_list_store_append(priv->list_store, &iter); +gtk_list_store_set(priv->list_store, &iter, + ISO_IS_ACTIVE, active, + ISO_NAME, name, + FONT_WEIGHT, weight, -1); + +if (active) { +GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(priv->list_store), &iter); +gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); +gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); +gtk_tree_path_free(path); +} + +g_free(current_iso); +} + +static void +fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, + GAsyncResult *result, + RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +GError *error = NULL; +GList *iso_list; + +iso_list = ovirt_foreign_menu_fetch_iso_names_finish(foreign_menu, result, &error); + +if (!iso_list) { +remote_viewer_iso_list_dialog_show_error(self, error ? error->message : _("Failed to fetch CD names")); +g_clear_error(&error); +return; +} + +iso_list = ovirt_foreign_menu_get_iso_names(priv->foreign_menu); +g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, self); +remote_viewer_iso_list_dialog_show_files(self); +} + + +static void +remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog *self) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; + +gtk_list_store_clear(priv->list_store); +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, + (GAsyncReadyCallback) fetch_iso_names_cb, + self); +} + +static void remote_viewer_iso_list_dialog_response(GtkDialog *dialog,
[virt-tools-list] [PATCH virt-viewer 2/9] ovirt-foreign-menu: Fetch ISO names using GTask API
Similar to the previous commit, the ISO dialog will fetch the result asynchronously, rather than relying on the "notify::files" signal from OvirtForeignMenu object. It also enables error to be shown if anything goes wrong. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 170 +++ src/ovirt-foreign-menu.h | 9 ++- src/remote-viewer.c | 45 +++-- 3 files changed, 147 insertions(+), 77 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 366259a..50a8ea6 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -40,13 +40,13 @@ typedef enum { STATE_ISOS } OvirtForeignMenuState; -static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, OvirtForeignMenuState state); -static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu); -static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu); -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 gboolean ovirt_foreign_menu_refresh_iso_list(gpointer user_data); +static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, GTask *task, OvirtForeignMenuState state); +static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu *menu, GTask *task); +static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, GTask *task); G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT) @@ -273,11 +273,9 @@ OvirtForeignMenu* ovirt_foreign_menu_new(OvirtProxy *proxy) static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, + GTask *task, OvirtForeignMenuState current_state) { -g_return_if_fail(current_state >= STATE_0); -g_return_if_fail(current_state < STATE_ISOS); - /* Each state will check if the member is initialized, falling directly to * the next one if so. If not, the callback for the asynchronous call will * be responsible for calling is function again with the next state as @@ -286,26 +284,26 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, switch (current_state + 1) { case STATE_API: if (menu->priv->api == NULL) { -ovirt_foreign_menu_fetch_api_async(menu); +ovirt_foreign_menu_fetch_api_async(menu, task); break; } case STATE_VM: if (menu->priv->vm == NULL) { -ovirt_foreign_menu_fetch_vm_async(menu); +ovirt_foreign_menu_fetch_vm_async(menu, task); break; } case STATE_STORAGE_DOMAIN: if (menu->priv->files == NULL) { -ovirt_foreign_menu_fetch_storage_domain_async(menu); +ovirt_foreign_menu_fetch_storage_domain_async(menu, task); break; } case STATE_VM_CDROM: if (menu->priv->cdrom == NULL) { -ovirt_foreign_menu_fetch_vm_cdrom_async(menu); +ovirt_foreign_menu_fetch_vm_cdrom_async(menu, task); break; } case STATE_CDROM_FILE: -ovirt_foreign_menu_refresh_cdrom_file_async(menu); +ovirt_foreign_menu_refresh_cdrom_file_async(menu, task); break; case STATE_ISOS: g_warn_if_fail(menu->priv->api != NULL); @@ -313,18 +311,35 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, g_warn_if_fail(menu->priv->files != NULL); g_warn_if_fail(menu->priv->cdrom != NULL); -ovirt_foreign_menu_refresh_iso_list(menu); +ovirt_foreign_menu_fetch_iso_list_async(menu, task); break; default: g_warn_if_reached(); +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, +"Invalid state: %d", current_state); +g_object_unref(task); } } void -ovirt_foreign_menu_start(OvirtForeignMenu *menu) +ovirt_foreign_menu_fetch_iso_names_async(OvirtForeignMenu *menu, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ +GTask *task = g_task_new(menu, cancellable, callback, user_data); +ovirt_foreign_menu_next_async_step(menu, task, STATE_0); +} + + +GList * +ovir
[virt-tools-list] [PATCH virt-viewer 7/9] iso-dialog: Use header bar for buttons
It seems to give more modern look to the dialog, but it requires Gtk+ 3.12, thus I will am keeping this commit separated. On the glade UI file, we get rid of the GtkAlignment object that was used to put some space between the tree view and dialog buttons. The "Select ISO" label is gone too. Signed-off-by: Eduardo Lima (Etrunko) --- configure.ac | 4 +- src/remote-viewer-iso-list-dialog.c| 31 +-- src/resources/ui/remote-viewer-iso-list.ui | 87 +++--- 3 files changed, 60 insertions(+), 62 deletions(-) diff --git a/configure.ac b/configure.ac index c611d70..ce71349 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38" GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" # Keep these two definitions in agreement. -GTK_REQUIRED="3.10" -GTK_ENCODED_VERSION="GDK_VERSION_3_10" +GTK_REQUIRED="3.12" +GTK_ENCODED_VERSION="GDK_VERSION_3_12" LIBXML2_REQUIRED="2.6.0" LIBVIRT_REQUIRED="0.10.0" diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index ef60854..a937262 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -36,6 +36,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkHeaderBar *header_bar; GtkListStore *list_store; GtkWidget *stack; GtkWidget *tree_view; @@ -85,6 +86,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) } static void +remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *subtitle = NULL; + +if (iso_name && strlen(iso_name) != 0) +subtitle = g_strdup_printf(_("Current: %s"), iso_name); + +gtk_header_bar_set_subtitle(priv->header_bar, subtitle); +g_free(subtitle); +} + +static void remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) { RemoteViewerISOListDialogPrivate *priv = self->priv; @@ -104,6 +118,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); } g_free(current_iso); @@ -154,6 +169,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, if (response_id != GTK_RESPONSE_NONE) return; +remote_viewer_iso_list_dialog_set_subtitle(self, NULL); gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); @@ -207,9 +223,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); GtkCellRendererToggle *cell_renderer; +GtkWidget *button, *image; gtk_builder_connect_signals(builder, self); +priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self))); +gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE); + priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack")); gtk_box_pack_start(GTK_BOX(content), priv->stack, TRUE, TRUE, 0); @@ -221,12 +241,11 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) g_object_unref(builder); -gtk_dialog_add_buttons(GTK_DIALOG(self), - _("Refresh"), GTK_RESPONSE_NONE, - _("Close"), GTK_RESPONSE_CLOSE, - NULL); +button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE); +image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON); +gtk_button_set_image(GTK_BUTTON(button), image); +gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE); -gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL); } @@ -291,6 +310,7 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, g_free(name); } while (gtk_tree_model_iter_next(model, &iter)); +remote_viewer_iso_
[virt-tools-list] [PATCH virt-viewer 5/9] ovirt-foreign-menu: Add accessors for current iso and iso list
Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 11 +-- src/ovirt-foreign-menu.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 50a8ea6..e2216a2 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -85,10 +85,10 @@ enum { }; -static char * +gchar * ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) { -char *name; +gchar *name; if (foreign_menu->priv->cdrom == NULL) { return NULL; @@ -100,6 +100,13 @@ ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) } +GList* +ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *foreign_menu) +{ +return foreign_menu->priv->iso_names; +} + + static void ovirt_foreign_menu_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) diff --git a/src/ovirt-foreign-menu.h b/src/ovirt-foreign-menu.h index a864a60..340201f 100644 --- a/src/ovirt-foreign-menu.h +++ b/src/ovirt-foreign-menu.h @@ -88,6 +88,8 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu); +gchar *ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *menu); +GList *ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *menu); G_END_DECLS -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 8/9] Run iso-dialog when 'Change CD' menu is activated
Also makes 'Change CD' menu item a submenu under 'File' toplevel menu Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer.ui | 19 ++- src/virt-viewer-window.c| 37 + 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui index 6e3c5ad..e9609ec 100644 --- a/src/resources/ui/virt-viewer.ui +++ b/src/resources/ui/virt-viewer.ui @@ -1,6 +1,7 @@ + - + False @@ -73,6 +74,14 @@ + +False +_Change CD +True + + + + True False @@ -247,14 +256,6 @@ - - -False -False -_Change CD -True - - False diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 99fd102..a4f531e 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -43,6 +43,8 @@ #include "virt-viewer-util.h" #include "virt-viewer-timed-revealer.h" +#include "remote-viewer-iso-list-dialog.h" + #define ZOOM_STEP 10 /* Signal handlers for main window (move in a VirtViewerMainWindow?) */ @@ -62,6 +64,7 @@ void virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, VirtViewerWindow *self); +void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, VirtViewerWindow *self); /* Internal methods */ @@ -1056,6 +1059,40 @@ virt_viewer_window_menu_help_about(GtkWidget *menu G_GNUC_UNUSED, g_object_unref(G_OBJECT(about)); } +static void +iso_dialog_response(GtkDialog *dialog, +gint response_id, +gpointer user_data G_GNUC_UNUSED) +{ +if (response_id == GTK_RESPONSE_NONE) +return; + +gtk_widget_destroy(GTK_WIDGET(dialog)); +} + +void +virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED, + VirtViewerWindow *self) +{ +VirtViewerWindowPrivate *priv = self->priv; +GtkWidget *dialog; +GObject *foreign_menu; + +g_object_get(G_OBJECT(priv->app), "ovirt-foreign-menu", &foreign_menu, NULL); +dialog = remote_viewer_iso_list_dialog_new(GTK_WINDOW(priv->window), foreign_menu); +g_object_unref(foreign_menu); + +if (!dialog) +dialog = gtk_message_dialog_new(GTK_WINDOW(priv->window), +GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, +GTK_MESSAGE_ERROR, +GTK_BUTTONS_CLOSE, +_("Unable do connnect to oVirt")); + +g_signal_connect(dialog, "response", G_CALLBACK(iso_dialog_response), NULL); +gtk_widget_show_all(dialog); +gtk_dialog_run(GTK_DIALOG(dialog)); +} static void virt_viewer_window_toolbar_setup(VirtViewerWindow *self) -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 9/9] ovirt-foreign-menu: Remove GtkMenu related functions
With this commit, we finish cleaning up ovirt foreign menu code, which only deals with data, leaving the UI bits to be handled properly in the new ISO list dialog. This patch also updates remote-viewer to reflect the change. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 99 src/remote-viewer.c | 87 +++--- 2 files changed, 6 insertions(+), 180 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index e2216a2..fc933d3 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -350,22 +350,6 @@ ovirt_foreign_menu_fetch_iso_names_finish(OvirtForeignMenu *foreign_menu, } -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data); - - -static void -menu_item_set_active_no_signal(GtkMenuItem *menuitem, - gboolean active, - GCallback callback, - gpointer user_data) -{ -g_signal_handlers_block_by_func(menuitem, callback, user_data); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); -g_signal_handlers_unblock_by_func(menuitem, callback, user_data); -} - - static void iso_name_set_cb(GObject *source_object, GAsyncResult *result, gpointer user_data) @@ -447,88 +431,6 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig } -static void -ovirt_foreign_menu_iso_name_changed(GObject *source_object, -GAsyncResult *result, -gpointer user_data G_GNUC_UNUSED) -{ -OvirtForeignMenu *foreign_menu = OVIRT_FOREIGN_MENU(source_object); -GError *error = NULL; - -if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -g_warning(error ? error->message : "Failed to change CD"); -g_clear_error(&error); -return; -} - -g_object_notify(G_OBJECT(foreign_menu), "file"); -} - - -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data) -{ -OvirtForeignMenu *foreign_menu; -const char *iso_name = NULL; -gboolean checked; - -checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)); -foreign_menu = OVIRT_FOREIGN_MENU(user_data); -g_return_if_fail(foreign_menu->priv->cdrom != NULL); -g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); - -g_debug("'%s' clicked", gtk_menu_item_get_label(menuitem)); - -/* We only want to move the check mark for the currently selected ISO - * when ovirt_cdrom_update_async() is successful, so for now we move - * the check mark back to where it was before - */ -menu_item_set_active_no_signal(menuitem, !checked, - (GCallback)ovirt_foreign_menu_activate_item_cb, - foreign_menu); - -if (checked) { -iso_name = gtk_menu_item_get_label(menuitem); -} -ovirt_foreign_menu_set_current_iso_name_async(foreign_menu, iso_name, NULL, - ovirt_foreign_menu_iso_name_changed, - menuitem); -} - - -GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu) -{ -GtkWidget *gtk_menu; -GList *it; -char *current_iso; - -if (foreign_menu->priv->iso_names == NULL) { -g_debug("ISO list is empty, no menu to show"); -return NULL; -} -g_debug("Creating GtkMenu for foreign menu"); -current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu); -gtk_menu = gtk_menu_new(); -for (it = foreign_menu->priv->iso_names; it != NULL; it = it->next) { -GtkWidget *menuitem; - -menuitem = gtk_check_menu_item_new_with_label((char *)it->data); -if (g_strcmp0((char *)it->data, current_iso) == 0) { -g_warn_if_fail(g_strcmp0(current_iso, foreign_menu->priv->current_iso_name) == 0); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), - TRUE); -} -g_signal_connect(menuitem, "activate", - G_CALLBACK(ovirt_foreign_menu_activate_item_cb), - foreign_menu); -gtk_menu_shell_append(GTK_MENU_SHELL(gtk_menu), menuitem); -} -g_free(current_iso); - -return gtk_menu; -} - - static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu, const GList *files) { @@ -594,7 +496,6 @@ static void cdrom_file_refreshed_cb(GObject *source_object, "file", &menu->pri
[virt-tools-list] [PATCH virt-viewer 0/9 v6] Replace oVirt foreign menu with dedicated dialog
In this version, I address comments from Christophe in patch number 2 "Fetch ISO names using GTask API", basically adding more error handling. In "Add accessors for current iso and iso list" I changed the return type from char * to gchar * and changed users of the code accordingly. Finally, I split the code in "Make ovirt-foreign-menu a property" and moved that one patch before the "Introduce ISO List dialog". Regards, Eduardo. Eduardo Lima (Etrunko) (9): ovirt-foreign-menu: Set new ISO name using GTask API ovirt-foreign-menu: Fetch ISO names using GTask API remote-viewer: Make ovirt-foreign-menu a property Introduce ISO List dialog ovirt-foreign-menu: Add accessors for current iso and iso list iso-dialog: Implement functionality provided by oVirt foreign menu iso-dialog: Use header bar for buttons Run iso-dialog when 'Change CD' menu is activated ovirt-foreign-menu: Remove GtkMenu related functions configure.ac | 4 +- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/ovirt-foreign-menu.c | 307 +- src/ovirt-foreign-menu.h | 21 +- src/remote-viewer-iso-list-dialog.c| 340 + src/remote-viewer-iso-list-dialog.h| 58 + src/remote-viewer.c| 87 src/resources/ui/remote-viewer-iso-list.ui | 135 src/resources/ui/virt-viewer.ui| 19 +- src/resources/virt-viewer.gresource.xml| 1 + src/virt-viewer-window.c | 37 12 files changed, 799 insertions(+), 215 deletions(-) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 2/9] ovirt-foreign-menu: Fetch ISO names using GTask API
On 18/01/17 15:45, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 12:16:53PM -0200, Eduardo Lima (Etrunko) wrote: >> Similar to the previous commit, the ISO dialog will fetch the result >> asynchronously, rather than relying on the "notify::files" signal from >> OvirtForeignMenu object. It also enables error to be shown if anything >> goes wrong. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/ovirt-foreign-menu.c | 170 >> +++ >> src/ovirt-foreign-menu.h | 9 ++- >> src/remote-viewer.c | 45 +++-- >> 3 files changed, 147 insertions(+), 77 deletions(-) >> >> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c >> index 366259a..50a8ea6 100644 >> --- a/src/ovirt-foreign-menu.c >> +++ b/src/ovirt-foreign-menu.c >> -static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu >> *menu) >> +static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu >> *menu, >> +GTask *task) >> { >> g_return_if_fail(OVIRT_IS_RESOURCE(menu->priv->cdrom)); >> >> ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cdrom), >> menu->priv->proxy, NULL, >> - cdrom_file_refreshed_cb, menu); >> + cdrom_file_refreshed_cb, task); > > Since we have a GTask, we could pass the GCancellable it contains when > we make ovirt_*_async() calls. Since we don't use the GCancellable > functionality, that's probably not worth it ;) You're right, for the sake of completeness, if some day we get to implement the functionality, the change will be slightly easier. I have replaced the NULL parameters with calls to g_task_get_cancellable(task). -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 5/9] ovirt-foreign-menu: Add accessors for current iso and iso list
On 19/01/17 10:55, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 12:16:56PM -0200, Eduardo Lima (Etrunko) wrote: >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/ovirt-foreign-menu.c | 11 +-- >> src/ovirt-foreign-menu.h | 2 ++ >> 2 files changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c >> index 50a8ea6..e2216a2 100644 >> --- a/src/ovirt-foreign-menu.c >> +++ b/src/ovirt-foreign-menu.c >> @@ -85,10 +85,10 @@ enum { >> }; >> >> >> -static char * >> +gchar * >> ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) >> { >> -char *name; >> +gchar *name; >> >> if (foreign_menu->priv->cdrom == NULL) { >> return NULL; > > Note that before we were returning a char * and using g_free on the > string. The rest of the codebase seems to be using gchar * consistently > as a return value though. Might be better to have that as a separate > commit? On the one hand, it's so small that it's overkill, on the other > hand, the hunk is odd when squashed with a different commit. I guess it could be documented on the the commit message, to explain the change. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 6/9] iso-dialog: Implement functionality provided by oVirt foreign menu
On 19/01/17 10:48, Christophe Fergeau wrote: > The issues pointed out in > https://www.redhat.com/archives/virt-tools-list/2017-January/msg00039.html > do not seem to have been addressed? > True, I did overlook that message, thanks for the reminder. I changed the code so the spinner stops and set the reload button sensitive. This way the user can try refreshing the list again in case of error. Also it was not necessary to get the iso_list twice, as you pointed. > Did you try merging the patches from "Introduce ISO List dialog" to "Run > iso-dialog when 'Change CD' menu is activated" (without the headerbar > change)? I think they would make more sense together, did not check if > that would make the diff far too big or not. > I split those two because I thought the xml would be big enough for itself, but I can merge the patches without problems. > Christophe > > On Wed, Jan 18, 2017 at 12:16:57PM -0200, Eduardo Lima (Etrunko) wrote: >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer-iso-list-dialog.c| 204 >> - >> src/resources/ui/remote-viewer-iso-list.ui | 5 +- >> 2 files changed, 205 insertions(+), 4 deletions(-) >> >> diff --git a/src/remote-viewer-iso-list-dialog.c >> b/src/remote-viewer-iso-list-dialog.c >> index 858719c..ef60854 100644 >> --- a/src/remote-viewer-iso-list-dialog.c >> +++ b/src/remote-viewer-iso-list-dialog.c >> @@ -26,6 +26,9 @@ >> #include "virt-viewer-util.h" >> #include "ovirt-foreign-menu.h" >> >> +static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu >> *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self); >> +static void >> remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, >> gchar *message); >> + >> G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, >> GTK_TYPE_DIALOG) >> >> #define DIALOG_PRIVATE(o) \ >> @@ -33,17 +36,32 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, >> remote_viewer_iso_list_dialog, GTK_TYPE >> >> struct _RemoteViewerISOListDialogPrivate >> { >> +GtkListStore *list_store; >> GtkWidget *stack; >> +GtkWidget *tree_view; >> OvirtForeignMenu *foreign_menu; >> }; >> >> +enum RemoteViewerISOListDialogModel >> +{ >> +ISO_IS_ACTIVE = 0, >> +ISO_NAME, >> +FONT_WEIGHT, >> +}; >> + >> +void remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle >> *cell_renderer, gchar *path, gpointer user_data); >> +void remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view, >> GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data); >> + >> static void >> remote_viewer_iso_list_dialog_dispose(GObject *object) >> { >> RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); >> RemoteViewerISOListDialogPrivate *priv = self->priv; >> >> -g_clear_object(&priv->foreign_menu); >> +if (priv->foreign_menu) { >> +g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); >> +g_clear_object(&priv->foreign_menu); >> +} >> >> G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); >> } >> >> @@ -58,6 +76,74 @@ >> remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass >> *klass) >> } >> >> static void >> +remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) >> +{ >> +RemoteViewerISOListDialogPrivate *priv = self->priv = >> DIALOG_PRIVATE(self); >> +gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "iso-list", >> + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); > > I don't think I'd use animations here, I'd just switch from spinner to > iso list, I find the animation distracting. I liked them, but anyway, using GTK_STACK_TRANSITION_TYPE_NONE from now on. > >> +gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, >> TRUE); >> +} >> + >> +static void >> +remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog >> *self) >> +{ >> +RemoteViewerISOListDialogPrivate *priv = self->priv; >> +gchar *current_iso = >> ovirt_foreign_menu_get_current_iso_name(self->priv->foreign_menu); >> +gboolean active = g_strcmp0(current_iso, name) == 0; >> +gint weight =
Re: [virt-tools-list] [PATCH virt-viewer 3/9] remote-viewer: Make ovirt-foreign-menu a property
On 19/01/17 10:56, Christophe Fergeau wrote: > Looks good, but maybe better to squash this with later commits? (see my > comment in one of the subsequent commits) This one could go well with patch 8/9: "Run iso-dialog when..." > > Christophe > > > On Wed, Jan 18, 2017 at 12:16:54PM -0200, Eduardo Lima (Etrunko) wrote: >> The OvirtForeignMenu pointer is needed by the new ISO list dialog, and >> we make it acessible via property to avoid interdependency between >> objects. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer.c | 37 + >> 1 file changed, 37 insertions(+) >> >> diff --git a/src/remote-viewer.c b/src/remote-viewer.c >> index c84a35b..29d7db1 100644 >> --- a/src/remote-viewer.c >> +++ b/src/remote-viewer.c >> @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, >> VIRT_VIEWER_TYPE_APP) >> #define GET_PRIVATE(o) >> \ >> (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, >> RemoteViewerPrivate)) >> >> +enum RemoteViewerProperties { >> +PROP_0, >> +#ifdef HAVE_OVIRT >> +PROP_OVIRT_FOREIGN_MENU, >> +#endif >> +}; >> + >> #ifdef HAVE_OVIRT >> static OvirtVm * choose_vm(GtkWindow *main_window, >> char **vm_name, >> @@ -214,6 +221,25 @@ end: >> } >> >> static void >> +remote_viewer_get_property(GObject *object, guint property_id, >> + GValue *value, GParamSpec *pspec) >> +{ >> +RemoteViewer *self = REMOTE_VIEWER(object); >> +RemoteViewerPrivate *priv = self->priv; >> + >> +switch (property_id) { >> +#ifdef HAVE_OVIRT >> +case PROP_OVIRT_FOREIGN_MENU: >> +g_value_set_object(value, priv->ovirt_foreign_menu); >> +break; >> +#endif >> + >> +default: >> +G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); >> +} >> +} >> + >> +static void >> remote_viewer_class_init (RemoteViewerClass *klass) >> { >> GObjectClass *object_class = G_OBJECT_CLASS (klass); >> @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass) >> >> g_type_class_add_private (klass, sizeof (RemoteViewerPrivate)); >> >> +object_class->get_property = remote_viewer_get_property; >> object_class->dispose = remote_viewer_dispose; >> >> g_app_class->local_command_line = remote_viewer_local_command_line; >> @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClass *klass) >> #else >> (void) gtk_app_class; >> #endif >> + >> +#ifdef HAVE_OVIRT >> +g_object_class_install_property(object_class, >> +PROP_OVIRT_FOREIGN_MENU, >> + >> g_param_spec_object("ovirt-foreign-menu", >> +"oVirt Foreign >> Menu", >> +"Object which is >> used as interface to oVirt", >> + >> OVIRT_TYPE_FOREIGN_MENU, >> +G_PARAM_READABLE | >> G_PARAM_STATIC_STRINGS)); >> +#endif >> } >> >> static void >> -- >> 2.9.3 >> >> ___ >> virt-tools-list mailing list >> virt-tools-list@redhat.com >> https://www.redhat.com/mailman/listinfo/virt-tools-list -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 8/9] Run iso-dialog when 'Change CD' menu is activated
On 19/01/17 11:06, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 12:16:59PM -0200, Eduardo Lima (Etrunko) wrote: >> Also makes 'Change CD' menu item a submenu under 'File' toplevel menu >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/resources/ui/virt-viewer.ui | 19 ++- >> src/virt-viewer-window.c| 37 + >> 2 files changed, 47 insertions(+), 9 deletions(-) >> >> diff --git a/src/resources/ui/virt-viewer.ui >> b/src/resources/ui/virt-viewer.ui >> index 6e3c5ad..e9609ec 100644 >> --- a/src/resources/ui/virt-viewer.ui >> +++ b/src/resources/ui/virt-viewer.ui >> @@ -1,6 +1,7 @@ >> >> + >> >> - >> + >> >> >> False >> @@ -73,6 +74,14 @@ >> >> >> >> + >> +False >> +> translatable="yes">_Change CD >> +True >> +> handler="virt_viewer_window_menu_change_cd_activate" swapped="no"/> >> + >> + >> + >> >> True >> False >> @@ -247,14 +256,6 @@ >> >> >> >> - >> - >> -False >> -False >> -_Change >> CD >> -True >> - >> - >> >> >> False >> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c >> index 99fd102..a4f531e 100644 >> --- a/src/virt-viewer-window.c >> +++ b/src/virt-viewer-window.c >> @@ -43,6 +43,8 @@ >> #include "virt-viewer-util.h" >> #include "virt-viewer-timed-revealer.h" >> >> +#include "remote-viewer-iso-list-dialog.h" >> + >> #define ZOOM_STEP 10 >> >> /* Signal handlers for main window (move in a VirtViewerMainWindow?) */ >> @@ -62,6 +64,7 @@ void >> virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi >> void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, >> VirtViewerWindow *self); >> void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, >> VirtViewerWindow *self); >> void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, >> VirtViewerWindow *self); >> +void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, >> VirtViewerWindow *self); >> >> >> /* Internal methods */ >> @@ -1056,6 +1059,40 @@ virt_viewer_window_menu_help_about(GtkWidget *menu >> G_GNUC_UNUSED, >> g_object_unref(G_OBJECT(about)); >> } >> >> +static void >> +iso_dialog_response(GtkDialog *dialog, >> +gint response_id, >> +gpointer user_data G_GNUC_UNUSED) >> +{ >> +if (response_id == GTK_RESPONSE_NONE) >> +return; >> + >> +gtk_widget_destroy(GTK_WIDGET(dialog)); >> +} >> + >> +void >> +virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED, >> + VirtViewerWindow *self) >> +{ >> +VirtViewerWindowPrivate *priv = self->priv; >> +GtkWidget *dialog; >> +GObject *foreign_menu; >> + >> +g_object_get(G_OBJECT(priv->app), "ovirt-foreign-menu", &foreign_menu, >> NULL); >> +dialog = remote_viewer_iso_list_dialog_new(GTK_WINDOW(priv->window), >> foreign_menu); >> +g_object_unref(foreign_menu); >> + >> +if (!dialog) >> +dialog = gtk_message_dialog_new(GTK_WINDOW(priv->window), >> +GTK_DIALOG_MODAL | >> GTK_DIALOG_DESTROY_WITH_PARENT, >> +GTK_MESSAGE_ERROR, >> +GTK_BUTTONS_CLOSE, >> +_("Unable do connnect to oVirt")); > > I don't think remote_viewer_iso_list_dialog_new can return NULL, so this > could be dropped. If it's needed, s/"Unable do"/"Unable to" > In practice it won't, but there is a g_return_val_if_fail() if the foreign_menu pointer is null, so I added this failsafe here. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 1/9] ovirt-foreign-menu: Set new ISO name using GTask API
On 18/01/17 14:31, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 12:16:52PM -0200, Eduardo Lima (Etrunko) wrote: >> This is done with the new ovirt_foreign_menu_set_current_iso_name_async >> function. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/ovirt-foreign-menu.c | 117 >> ++- >> src/ovirt-foreign-menu.h | 10 >> 2 files changed, 96 insertions(+), 31 deletions(-) >> >> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c >> index a51f2c9..366259a 100644 >> --- a/src/ovirt-foreign-menu.c >> +++ b/src/ovirt-foreign-menu.c >> @@ -344,38 +344,102 @@ menu_item_set_active_no_signal(GtkMenuItem *menuitem, >> } >> >> >> -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; >> +GTask *task = G_TASK(user_data); >> +OvirtForeignMenu *foreign_menu = >> OVIRT_FOREIGN_MENU(g_task_get_source_object(task)); >> gboolean updated; >> >> -foreign_menu = OVIRT_FOREIGN_MENU(user_data); >> updated = ovirt_cdrom_update_finish(OVIRT_CDROM(source_object), >> result, &error); >> -g_debug("Finished updating cdrom content"); >> if (updated) { >> +g_debug("Finished updating cdrom content: %s", >> foreign_menu->priv->next_iso_name); >> 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; >> -g_object_notify(G_OBJECT(foreign_menu), "file"); >> +g_task_return_boolean(task, TRUE); >> +goto end; >> +} >> + >> +/* Reset old state back as we were not successful in switching to >> + * the new ISO */ >> +g_debug("setting OvirtCdrom:file back to '%s'", >> +foreign_menu->priv->current_iso_name); >> +g_object_set(foreign_menu->priv->cdrom, "file", >> + foreign_menu->priv->current_iso_name, NULL); >> +g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free); >> + >> +if (error != NULL) { >> +g_warning("failed to update cdrom resource: %s", error->message); >> +g_task_return_error(task, error); >> } else { >> -/* Reset old state back as we were not successful in switching to >> - * the new ISO */ >> -const char *current_file = foreign_menu->priv->current_iso_name; >> +g_warn_if_reached(); >> +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, >> +"failed to update cdrom resource"); >> +} >> >> -if (error != NULL) { >> -g_warning("failed to update cdrom resource: %s", >> error->message); >> -g_clear_error(&error); >> -} >> -g_debug("setting OvirtCdrom:file back to '%s'", >> -current_file?current_file:NULL); >> -g_object_set(foreign_menu->priv->cdrom, "file", current_file, NULL); >> +end: >> +g_object_unref(task); >> +} >> + >> + >> +void ovirt_foreign_menu_set_current_iso_name_async(OvirtForeignMenu >> *foreign_menu, >> + const char *name, >> + GCancellable >> *cancellable, >> + GAsyncReadyCallback >> callback, >> + gpointer user_data) >> +{ >> +GTask *task; >> + >> +g_return_if_fail(foreign_menu->priv->cdrom != NULL); >> +g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); >> + >> +if (name) { >> +g_debug("Updating VM cdrom image to '%s'", name); >> +foreign_menu->priv->next_iso_name = g_strdup(name); >> +} else { >> +g_debug("Removing c
Re: [virt-tools-list] [PATCH virt-viewer 2/9] ovirt-foreign-menu: Fetch ISO names using GTask API
On 18/01/17 15:45, Christophe Fergeau wrote: > On Wed, Jan 18, 2017 at 12:16:53PM -0200, Eduardo Lima (Etrunko) wrote: >> Similar to the previous commit, the ISO dialog will fetch the result >> asynchronously, rather than relying on the "notify::files" signal from >> OvirtForeignMenu object. It also enables error to be shown if anything >> goes wrong. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/ovirt-foreign-menu.c | 170 >> +++ >> src/ovirt-foreign-menu.h | 9 ++- >> src/remote-viewer.c | 45 +++-- >> 3 files changed, 147 insertions(+), 77 deletions(-) >> >> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c >> index 366259a..50a8ea6 100644 >> --- a/src/ovirt-foreign-menu.c >> +++ b/src/ovirt-foreign-menu.c >> -static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu >> *menu) >> +static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu >> *menu, >> +GTask *task) >> { >> g_return_if_fail(OVIRT_IS_RESOURCE(menu->priv->cdrom)); >> >> ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cdrom), >> menu->priv->proxy, NULL, >> - cdrom_file_refreshed_cb, menu); >> + cdrom_file_refreshed_cb, task); > > Since we have a GTask, we could pass the GCancellable it contains when > we make ovirt_*_async() calls. Since we don't use the GCancellable > functionality, that's probably not worth it ;) > > >> @@ -794,6 +832,8 @@ static void iso_list_fetched_cb(GObject *source_object, >> GAsyncResult *result, >> gpointer user_data) >> { >> +GTask *task = G_TASK(user_data); >> +OvirtForeignMenu *menu = >> OVIRT_FOREIGN_MENU(g_task_get_source_object(task)); >> OvirtCollection *collection = OVIRT_COLLECTION(source_object); >> GError *error = NULL; >> GList *files; >> @@ -802,42 +842,28 @@ static void iso_list_fetched_cb(GObject *source_object, >> if (error != NULL) { >> g_warning("failed to fetch files for ISO storage domain: %s", >> error->message); >> -g_clear_error(&error); >> +g_task_return_error(task, error); >> +g_object_unref(task); >> return; >> } >> >> files = >> g_hash_table_get_values(ovirt_collection_get_resources(collection)); >> -ovirt_foreign_menu_set_files(OVIRT_FOREIGN_MENU(user_data), files); >> +ovirt_foreign_menu_set_files(menu, files); >> g_list_free(files); >> - >> -g_timeout_add_seconds(300, ovirt_foreign_menu_refresh_iso_list, >> user_data); >> +g_task_return_pointer(task, menu->priv->iso_names, NULL); > > Fwiw, there are probably some corner cases where this could be racy, > with ovirt_foreign_menu_set_files() invalidating menu->priv->iso_names > while this GTask still contains a pointer to it. I don't think this can > occur with the way we use that API though, so probably not worth making > a deep copy of it. > > Acked-by: Christophe Fergeau Pushed, thanks -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 2/5] Introduce ISO List dialog
Signed-off-by: Eduardo Lima (Etrunko) --- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/remote-viewer-iso-list-dialog.c| 365 + src/remote-viewer-iso-list-dialog.h| 58 + src/resources/ui/remote-viewer-iso-list.ui | 158 + src/resources/virt-viewer.gresource.xml| 1 + 6 files changed, 587 insertions(+) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 69d9fef..371c242 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,9 +1,11 @@ data/remote-viewer.appdata.xml.in data/remote-viewer.desktop.in data/virt-viewer-mime.xml.in +src/remote-viewer-iso-list-dialog.c src/remote-viewer-main.c src/remote-viewer.c [type: gettext/glade] src/resources/ui/remote-viewer-connect.ui +[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui [type: gettext/glade] src/resources/ui/virt-viewer-about.ui src/virt-viewer-app.c src/virt-viewer-auth.c diff --git a/src/Makefile.am b/src/Makefile.am index 272c4ff..9748277 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ noinst_DATA = \ resources/ui/virt-viewer-vm-connection.ui \ resources/ui/virt-viewer-preferences.ui \ resources/ui/remote-viewer-connect.ui \ + resources/ui/remote-viewer-iso-list.ui \ resources/ui/virt-viewer-file-transfer-dialog.ui \ $(NULL) @@ -97,6 +98,8 @@ if HAVE_OVIRT libvirt_viewer_la_SOURCES += \ ovirt-foreign-menu.h \ ovirt-foreign-menu.c \ + remote-viewer-iso-list-dialog.c \ + remote-viewer-iso-list-dialog.h \ $(NULL) endif diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c new file mode 100644 index 000..bf7c6c7 --- /dev/null +++ b/src/remote-viewer-iso-list-dialog.c @@ -0,0 +1,365 @@ +/* + * Virt Viewer: A virtual machine console viewer + * + * Copyright (C) 2016 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include + +#include "remote-viewer-iso-list-dialog.h" +#include "virt-viewer-util.h" +#include "ovirt-foreign-menu.h" + +static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self); +static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, const gchar *message); + +G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) + +#define DIALOG_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate)) + +struct _RemoteViewerISOListDialogPrivate +{ +GtkListStore *list_store; +GtkWidget *status; +GtkWidget *spinner; +GtkWidget *stack; +GtkWidget *tree_view; +OvirtForeignMenu *foreign_menu; +}; + +enum RemoteViewerISOListDialogModel +{ +ISO_IS_ACTIVE = 0, +ISO_NAME, +FONT_WEIGHT, +}; + +enum RemoteViewerISOListDialogProperties { +PROP_0, +PROP_FOREIGN_MENU, +}; + + +void remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data); +void remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data); + +static void +remote_viewer_iso_list_dialog_dispose(GObject *object) +{ +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); +RemoteViewerISOListDialogPrivate *priv = self->priv; + +if (priv->foreign_menu) { +g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); +g_clear_object(&priv->foreign_menu); +} + G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); +} + +static void +remote_viewer_iso_list_dialog_set_property(GObject *object, guint property_id, + const GValue *value, GParamSpec *pspec) +{ +RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); +RemoteViewerISOListDialogPrivate *priv = self->priv; + +
[virt-tools-list] [PATCH virt-viewer 3/5] iso-dialog: Use header bar for buttons
It seems to give more modern look to the dialog, but it requires Gtk+ 3.12, thus I will am keeping this commit separated. On the glade UI file, we get rid of the GtkAlignment object that was used to put some space between the tree view and dialog buttons. The "Select ISO" label is gone too. Signed-off-by: Eduardo Lima (Etrunko) --- configure.ac | 4 +- src/remote-viewer-iso-list-dialog.c| 31 +-- src/resources/ui/remote-viewer-iso-list.ui | 87 +++--- 3 files changed, 60 insertions(+), 62 deletions(-) diff --git a/configure.ac b/configure.ac index c611d70..ce71349 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38" GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" # Keep these two definitions in agreement. -GTK_REQUIRED="3.10" -GTK_ENCODED_VERSION="GDK_VERSION_3_10" +GTK_REQUIRED="3.12" +GTK_ENCODED_VERSION="GDK_VERSION_3_12" LIBXML2_REQUIRED="2.6.0" LIBVIRT_REQUIRED="0.10.0" diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index bf7c6c7..3751c9b 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -36,6 +36,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkHeaderBar *header_bar; GtkListStore *list_store; GtkWidget *status; GtkWidget *spinner; @@ -118,6 +119,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) } static void +remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *subtitle = NULL; + +if (iso_name && strlen(iso_name) != 0) +subtitle = g_strdup_printf(_("Current: %s"), iso_name); + +gtk_header_bar_set_subtitle(priv->header_bar, subtitle); +g_free(subtitle); +} + +static void remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) { RemoteViewerISOListDialogPrivate *priv = self->priv; @@ -137,6 +151,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); } g_free(current_iso); @@ -195,6 +210,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, gtk_spinner_start(GTK_SPINNER(priv->spinner)); gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); +remote_viewer_iso_list_dialog_set_subtitle(self, NULL); gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", GTK_STACK_TRANSITION_TYPE_NONE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); @@ -248,9 +264,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); GtkCellRendererToggle *cell_renderer; +GtkWidget *button, *image; gtk_builder_connect_signals(builder, self); +priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self))); +gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE); + priv->status = GTK_WIDGET(gtk_builder_get_object(builder, "status")); priv->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner")); priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack")); @@ -264,12 +284,11 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) g_object_unref(builder); -gtk_dialog_add_buttons(GTK_DIALOG(self), - _("Refresh"), GTK_RESPONSE_NONE, - _("Close"), GTK_RESPONSE_CLOSE, - NULL); +button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE); +image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON); +gtk_button_set_image(GTK_BUTTON(button), image); +gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE); -gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL); } @@ -337,6 +356,7 @@ ovirt_foreign_menu_iso_name_cha
[virt-tools-list] [PATCH virt-viewer 0/5 v7] Replace oVirt foreign menu with dedicated dialog
In this version I merged the "Introduce ISO dialog" and "Implement functionality provided by oVirt foreign menu" patches. The same was done with "Make ovirt-foreign-menu a property" and "Run iso-dialog when 'Change CD' menu is activated". Also addressed some comments, in special better UI behavior when there is error fetching the ISO list. Eduardo Lima (Etrunko) (5): ovirt-foreign-menu: Add accessors for current iso and iso list Introduce ISO List dialog iso-dialog: Use header bar for buttons Run ISO dialog when 'Change CD' menu is activated ovirt-foreign-menu: Remove GtkMenu related functions configure.ac | 4 +- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/ovirt-foreign-menu.c | 110 +--- src/ovirt-foreign-menu.h | 2 + src/remote-viewer-iso-list-dialog.c| 386 + src/remote-viewer-iso-list-dialog.h| 58 + src/remote-viewer.c| 124 - src/resources/ui/remote-viewer-iso-list.ui | 135 ++ src/resources/ui/virt-viewer.ui| 19 +- src/resources/virt-viewer.gresource.xml| 1 + src/virt-viewer-window.c | 37 +++ 12 files changed, 688 insertions(+), 193 deletions(-) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 1/5] ovirt-foreign-menu: Add accessors for current iso and iso list
Also, to keep consistency around the codebase, changed the return value of ovirt_foreign_menu_get_current_iso_name() from char * to gchar *. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 11 +-- src/ovirt-foreign-menu.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index 8a99665..ef3ddd9 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -85,10 +85,10 @@ enum { }; -static char * +gchar * ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) { -char *name; +gchar *name; if (foreign_menu->priv->cdrom == NULL) { return NULL; @@ -100,6 +100,13 @@ ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) } +GList* +ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *foreign_menu) +{ +return foreign_menu->priv->iso_names; +} + + static void ovirt_foreign_menu_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) diff --git a/src/ovirt-foreign-menu.h b/src/ovirt-foreign-menu.h index a864a60..340201f 100644 --- a/src/ovirt-foreign-menu.h +++ b/src/ovirt-foreign-menu.h @@ -88,6 +88,8 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu); +gchar *ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *menu); +GList *ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *menu); G_END_DECLS -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 4/5] Run ISO dialog when 'Change CD' menu is activated
Also moves 'Change CD' menu item from the toplevel menu to a subitem under 'File' toplevel menu. In order to avoid object interdependency, it is necessary to make the ovirt foreign-menu pointer from RemoteViewer, acessible via property, so it can be passed to the dialog as an opaque GObject. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer.c | 37 + src/resources/ui/virt-viewer.ui | 19 ++- src/virt-viewer-window.c| 37 + 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/remote-viewer.c b/src/remote-viewer.c index c84a35b..29d7db1 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP) #define GET_PRIVATE(o)\ (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate)) +enum RemoteViewerProperties { +PROP_0, +#ifdef HAVE_OVIRT +PROP_OVIRT_FOREIGN_MENU, +#endif +}; + #ifdef HAVE_OVIRT static OvirtVm * choose_vm(GtkWindow *main_window, char **vm_name, @@ -214,6 +221,25 @@ end: } static void +remote_viewer_get_property(GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ +RemoteViewer *self = REMOTE_VIEWER(object); +RemoteViewerPrivate *priv = self->priv; + +switch (property_id) { +#ifdef HAVE_OVIRT +case PROP_OVIRT_FOREIGN_MENU: +g_value_set_object(value, priv->ovirt_foreign_menu); +break; +#endif + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} +} + +static void remote_viewer_class_init (RemoteViewerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass) g_type_class_add_private (klass, sizeof (RemoteViewerPrivate)); +object_class->get_property = remote_viewer_get_property; object_class->dispose = remote_viewer_dispose; g_app_class->local_command_line = remote_viewer_local_command_line; @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClass *klass) #else (void) gtk_app_class; #endif + +#ifdef HAVE_OVIRT +g_object_class_install_property(object_class, +PROP_OVIRT_FOREIGN_MENU, +g_param_spec_object("ovirt-foreign-menu", +"oVirt Foreign Menu", +"Object which is used as interface to oVirt", + OVIRT_TYPE_FOREIGN_MENU, +G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); +#endif } static void diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui index 6e3c5ad..e9609ec 100644 --- a/src/resources/ui/virt-viewer.ui +++ b/src/resources/ui/virt-viewer.ui @@ -1,6 +1,7 @@ + - + False @@ -73,6 +74,14 @@ + +False +_Change CD +True + + + + True False @@ -247,14 +256,6 @@ - - -False -False -_Change CD -True - - False diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 99fd102..8eda12e 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -43,6 +43,8 @@ #include "virt-viewer-util.h" #include "virt-viewer-timed-revealer.h" +#include "remote-viewer-iso-list-dialog.h" + #define ZOOM_STEP 10 /* Signal handlers for main window (move in a VirtViewerMainWindow?) */ @@ -62,6 +64,7 @@ void virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, VirtViewerWindow *self); +void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, VirtViewerWindow *self); /* Internal methods */ @@ -1056,6 +1059,40 @@ virt_viewer_window_menu_help_about(GtkWidget *me
[virt-tools-list] [PATCH virt-viewer 5/5] ovirt-foreign-menu: Remove GtkMenu related functions
With this commit, we finish cleaning up ovirt foreign menu code, which only deals with data, leaving the UI bits to be handled properly in the new ISO list dialog. This patch also updates remote-viewer to reflect the change. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 99 src/remote-viewer.c | 87 +++--- 2 files changed, 6 insertions(+), 180 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index ef3ddd9..2939ae5 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -350,22 +350,6 @@ ovirt_foreign_menu_fetch_iso_names_finish(OvirtForeignMenu *foreign_menu, } -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data); - - -static void -menu_item_set_active_no_signal(GtkMenuItem *menuitem, - gboolean active, - GCallback callback, - gpointer user_data) -{ -g_signal_handlers_block_by_func(menuitem, callback, user_data); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); -g_signal_handlers_unblock_by_func(menuitem, callback, user_data); -} - - static void iso_name_set_cb(GObject *source_object, GAsyncResult *result, gpointer user_data) @@ -447,88 +431,6 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig } -static void -ovirt_foreign_menu_iso_name_changed(GObject *source_object, -GAsyncResult *result, -gpointer user_data G_GNUC_UNUSED) -{ -OvirtForeignMenu *foreign_menu = OVIRT_FOREIGN_MENU(source_object); -GError *error = NULL; - -if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -g_warning(error ? error->message : "Failed to change CD"); -g_clear_error(&error); -return; -} - -g_object_notify(G_OBJECT(foreign_menu), "file"); -} - - -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data) -{ -OvirtForeignMenu *foreign_menu; -const char *iso_name = NULL; -gboolean checked; - -checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)); -foreign_menu = OVIRT_FOREIGN_MENU(user_data); -g_return_if_fail(foreign_menu->priv->cdrom != NULL); -g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); - -g_debug("'%s' clicked", gtk_menu_item_get_label(menuitem)); - -/* We only want to move the check mark for the currently selected ISO - * when ovirt_cdrom_update_async() is successful, so for now we move - * the check mark back to where it was before - */ -menu_item_set_active_no_signal(menuitem, !checked, - (GCallback)ovirt_foreign_menu_activate_item_cb, - foreign_menu); - -if (checked) { -iso_name = gtk_menu_item_get_label(menuitem); -} -ovirt_foreign_menu_set_current_iso_name_async(foreign_menu, iso_name, NULL, - ovirt_foreign_menu_iso_name_changed, - menuitem); -} - - -GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu) -{ -GtkWidget *gtk_menu; -GList *it; -char *current_iso; - -if (foreign_menu->priv->iso_names == NULL) { -g_debug("ISO list is empty, no menu to show"); -return NULL; -} -g_debug("Creating GtkMenu for foreign menu"); -current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu); -gtk_menu = gtk_menu_new(); -for (it = foreign_menu->priv->iso_names; it != NULL; it = it->next) { -GtkWidget *menuitem; - -menuitem = gtk_check_menu_item_new_with_label((char *)it->data); -if (g_strcmp0((char *)it->data, current_iso) == 0) { -g_warn_if_fail(g_strcmp0(current_iso, foreign_menu->priv->current_iso_name) == 0); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), - TRUE); -} -g_signal_connect(menuitem, "activate", - G_CALLBACK(ovirt_foreign_menu_activate_item_cb), - foreign_menu); -gtk_menu_shell_append(GTK_MENU_SHELL(gtk_menu), menuitem); -} -g_free(current_iso); - -return gtk_menu; -} - - static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu, const GList *files) { @@ -594,7 +496,6 @@ static void cdrom_file_refreshed_cb(GObject *source_object, "file", &menu->pri
Re: [virt-tools-list] [PATCH virt-viewer 1/5] ovirt-foreign-menu: Add accessors for current iso and iso list
On 20/01/17 13:16, Christophe Fergeau wrote: > > Acked-by: Christophe Fergeau Pushed, thanks. > > On Thu, Jan 19, 2017 at 01:42:10PM -0200, Eduardo Lima (Etrunko) wrote: >> Also, to keep consistency around the codebase, changed the return value >> of ovirt_foreign_menu_get_current_iso_name() from char * to gchar *. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/ovirt-foreign-menu.c | 11 +-- >> src/ovirt-foreign-menu.h | 2 ++ >> 2 files changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c >> index 8a99665..ef3ddd9 100644 >> --- a/src/ovirt-foreign-menu.c >> +++ b/src/ovirt-foreign-menu.c >> @@ -85,10 +85,10 @@ enum { >> }; >> >> >> -static char * >> +gchar * >> ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) >> { >> -char *name; >> +gchar *name; >> >> if (foreign_menu->priv->cdrom == NULL) { >> return NULL; >> @@ -100,6 +100,13 @@ >> ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu) >> } >> >> >> +GList* >> +ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *foreign_menu) >> +{ >> +return foreign_menu->priv->iso_names; >> +} >> + >> + >> static void >> ovirt_foreign_menu_get_property(GObject *object, guint property_id, >> GValue *value, GParamSpec *pspec) >> diff --git a/src/ovirt-foreign-menu.h b/src/ovirt-foreign-menu.h >> index a864a60..340201f 100644 >> --- a/src/ovirt-foreign-menu.h >> +++ b/src/ovirt-foreign-menu.h >> @@ -88,6 +88,8 @@ gboolean >> ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig >> >> >> GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu); >> +gchar *ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *menu); >> +GList *ovirt_foreign_menu_get_iso_names(OvirtForeignMenu *menu); >> >> G_END_DECLS >> >> -- >> 2.9.3 >> >> ___ >> virt-tools-list mailing list >> virt-tools-list@redhat.com >> https://www.redhat.com/mailman/listinfo/virt-tools-list -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 2/5] Introduce ISO List dialog
On 20/01/17 13:20, Christophe Fergeau wrote: > Can you expand a bit in the commit log about what this iso dialog is, > what is your goal for introducing it, .. ? Huge commit with shortlog > does not look good ;) > Alright, it will be done for the next version. > On Thu, Jan 19, 2017 at 01:42:11PM -0200, Eduardo Lima (Etrunko) wrote: >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> po/POTFILES.in | 2 + >> src/Makefile.am| 3 + >> src/remote-viewer-iso-list-dialog.c| 365 >> + >> src/remote-viewer-iso-list-dialog.h| 58 + >> src/resources/ui/remote-viewer-iso-list.ui | 158 + >> src/resources/virt-viewer.gresource.xml| 1 + >> 6 files changed, 587 insertions(+) >> create mode 100644 src/remote-viewer-iso-list-dialog.c >> create mode 100644 src/remote-viewer-iso-list-dialog.h >> create mode 100644 src/resources/ui/remote-viewer-iso-list.ui >> >> diff --git a/po/POTFILES.in b/po/POTFILES.in >> index 69d9fef..371c242 100644 >> --- a/po/POTFILES.in >> +++ b/po/POTFILES.in >> @@ -1,9 +1,11 @@ >> data/remote-viewer.appdata.xml.in >> data/remote-viewer.desktop.in >> data/virt-viewer-mime.xml.in >> +src/remote-viewer-iso-list-dialog.c >> src/remote-viewer-main.c >> src/remote-viewer.c >> [type: gettext/glade] src/resources/ui/remote-viewer-connect.ui >> +[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui >> [type: gettext/glade] src/resources/ui/virt-viewer-about.ui >> src/virt-viewer-app.c >> src/virt-viewer-auth.c >> diff --git a/src/Makefile.am b/src/Makefile.am >> index 272c4ff..9748277 100644 >> --- a/src/Makefile.am >> +++ b/src/Makefile.am >> @@ -13,6 +13,7 @@ noinst_DATA = \ >> resources/ui/virt-viewer-vm-connection.ui \ >> resources/ui/virt-viewer-preferences.ui \ >> resources/ui/remote-viewer-connect.ui \ >> +resources/ui/remote-viewer-iso-list.ui \ >> resources/ui/virt-viewer-file-transfer-dialog.ui \ >> $(NULL) >> >> @@ -97,6 +98,8 @@ if HAVE_OVIRT >> libvirt_viewer_la_SOURCES += \ >> ovirt-foreign-menu.h \ >> ovirt-foreign-menu.c \ >> +remote-viewer-iso-list-dialog.c \ >> +remote-viewer-iso-list-dialog.h \ >> $(NULL) >> endif >> >> diff --git a/src/remote-viewer-iso-list-dialog.c >> b/src/remote-viewer-iso-list-dialog.c >> new file mode 100644 >> index 000..bf7c6c7 >> --- /dev/null >> +++ b/src/remote-viewer-iso-list-dialog.c >> @@ -0,0 +1,365 @@ >> +/* >> + * Virt Viewer: A virtual machine console viewer >> + * >> + * Copyright (C) 2016 Red Hat, Inc. >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + * GNU General Public License for more details. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program; if not, write to the Free Software >> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >> + */ >> + >> +#include >> + >> +#include >> + >> +#include "remote-viewer-iso-list-dialog.h" >> +#include "virt-viewer-util.h" >> +#include "ovirt-foreign-menu.h" >> + >> +static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu >> *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self); >> +static void >> remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, >> const gchar *message); >> + >> +G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, >> GTK_TYPE_DIALOG) >> + >> +#define DIALOG_PRIVATE(o) \ >> +(G_TYPE_INSTANCE_GET_PRIVATE((o), >> REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate)) >> + >> +struct _RemoteViewerISOListDialogPrivate >> +{ >> +GtkListStore *list_store; >> +GtkWidget *status; >> +GtkWidget *spinner; >> +GtkWidget *stack; >> +GtkWidget *tree_view; >> +OvirtFor
Re: [virt-tools-list] [PATCH virt-viewer 3/5] iso-dialog: Use header bar for buttons
On 20/01/17 13:26, Fabiano Fidêncio wrote: > On Fri, Jan 20, 2017 at 4:21 PM, Christophe Fergeau > wrote: >> I haven't looked at this patch at all, as I don't know what the plan is >> for virt-viewer regarding gtk+ versions. It's easy to move last in the >> series though. Would be nice if someone more informed about that chimed >> in on this patch ;) > > All big distros (including the enterprise ones) have a newer version. > So that's not a problem at all. > > I just want to know Daniel's opinion on how it looks on his TWM testing VM :-) > I have some patches locally changing other dialogs to this new look, I will soon publish them on a separate branch so it can be tested easier. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 0/4 v8] Replace oVirt foreign menu with dedicated dialog
In this version, I have addressed the comments on the ISO dialog code, also providing a better message for that commit. Also, put the headerbar patch at the end, as others were already acked and should be ready to merge. Eduardo Lima (Etrunko) (4): Introduce ISO List dialog Run ISO dialog when 'Change CD' menu is activated ovirt-foreign-menu: Remove GtkMenu related functions iso-dialog: Use header bar for buttons configure.ac | 4 +- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/ovirt-foreign-menu.c | 99 src/remote-viewer-iso-list-dialog.c| 386 + src/remote-viewer-iso-list-dialog.h| 58 + src/remote-viewer.c| 124 - src/resources/ui/remote-viewer-iso-list.ui | 135 ++ src/resources/ui/virt-viewer.ui| 19 +- src/resources/virt-viewer.gresource.xml| 1 + src/virt-viewer-window.c | 37 +++ 11 files changed, 677 insertions(+), 191 deletions(-) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 1/4] Introduce ISO List dialog
The motivation for this dialog started with rhbz #1310624, where it was reported that foreign menu was causing too many debug messages to be printed to the console, because remote viewer had a timeout of 5 seconds to refresh the ISO list automatically. As a workaround, the timeout was adjusted for 5 minutes, but it could cause more problems, such as inconsistencies between what was shown by remote viewer and what the server had configured. Another issue caused by displaying the ISO files as a menu item was that if the list was too long, it would take all the available space on the screen. In the end, a menu item was not the correct choice of UI component for this use case. In order to solve both problems, we now present the ISO list as a dedicated dialog, where the refresh of ISO list is triggered manually by the user and the list is contained within the dialog, by displaying de files in a treeview. Signed-off-by: Eduardo Lima (Etrunko) --- po/POTFILES.in | 2 + src/Makefile.am| 3 + src/remote-viewer-iso-list-dialog.c| 365 + src/remote-viewer-iso-list-dialog.h| 58 + src/resources/ui/remote-viewer-iso-list.ui | 158 + src/resources/virt-viewer.gresource.xml| 1 + 6 files changed, 587 insertions(+) create mode 100644 src/remote-viewer-iso-list-dialog.c create mode 100644 src/remote-viewer-iso-list-dialog.h create mode 100644 src/resources/ui/remote-viewer-iso-list.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 69d9fef..371c242 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,9 +1,11 @@ data/remote-viewer.appdata.xml.in data/remote-viewer.desktop.in data/virt-viewer-mime.xml.in +src/remote-viewer-iso-list-dialog.c src/remote-viewer-main.c src/remote-viewer.c [type: gettext/glade] src/resources/ui/remote-viewer-connect.ui +[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui [type: gettext/glade] src/resources/ui/virt-viewer-about.ui src/virt-viewer-app.c src/virt-viewer-auth.c diff --git a/src/Makefile.am b/src/Makefile.am index 272c4ff..9748277 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ noinst_DATA = \ resources/ui/virt-viewer-vm-connection.ui \ resources/ui/virt-viewer-preferences.ui \ resources/ui/remote-viewer-connect.ui \ + resources/ui/remote-viewer-iso-list.ui \ resources/ui/virt-viewer-file-transfer-dialog.ui \ $(NULL) @@ -97,6 +98,8 @@ if HAVE_OVIRT libvirt_viewer_la_SOURCES += \ ovirt-foreign-menu.h \ ovirt-foreign-menu.c \ + remote-viewer-iso-list-dialog.c \ + remote-viewer-iso-list-dialog.h \ $(NULL) endif diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c new file mode 100644 index 000..e27e5fc --- /dev/null +++ b/src/remote-viewer-iso-list-dialog.c @@ -0,0 +1,365 @@ +/* + * Virt Viewer: A virtual machine console viewer + * + * Copyright (C) 2016 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include + +#include "remote-viewer-iso-list-dialog.h" +#include "virt-viewer-util.h" +#include "ovirt-foreign-menu.h" + +static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self); +static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, const gchar *message); + +G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG) + +#define DIALOG_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, RemoteViewerISOListDialogPrivate)) + +struct _RemoteViewerISOListDialogPrivate +{ +GtkListStore *list_store; +GtkWidget *status; +GtkWidget *spinner; +GtkWidget *stack; +GtkWidget *tree_view; +OvirtForeignMenu *foreign_menu; +}; + +enum RemoteViewerISOListDialogModel +{ +ISO_IS_ACTIVE = 0, +ISO_NAME, +FONT_WEIGHT, +}; + +enum RemoteViewerISOListDialogProperties { +PROP_0, +PROP_FOREIGN_MENU, +}; + + +void remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data); +void remote_viewer
[virt-tools-list] [PATCH virt-viewer 3/4] ovirt-foreign-menu: Remove GtkMenu related functions
With this commit, we finish cleaning up ovirt foreign menu code, which only deals with data, leaving the UI bits to be handled properly in the new ISO list dialog. This patch also updates remote-viewer to reflect the change. Signed-off-by: Eduardo Lima (Etrunko) --- src/ovirt-foreign-menu.c | 99 src/remote-viewer.c | 87 +++--- 2 files changed, 6 insertions(+), 180 deletions(-) diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c index ef3ddd9..2939ae5 100644 --- a/src/ovirt-foreign-menu.c +++ b/src/ovirt-foreign-menu.c @@ -350,22 +350,6 @@ ovirt_foreign_menu_fetch_iso_names_finish(OvirtForeignMenu *foreign_menu, } -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data); - - -static void -menu_item_set_active_no_signal(GtkMenuItem *menuitem, - gboolean active, - GCallback callback, - gpointer user_data) -{ -g_signal_handlers_block_by_func(menuitem, callback, user_data); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); -g_signal_handlers_unblock_by_func(menuitem, callback, user_data); -} - - static void iso_name_set_cb(GObject *source_object, GAsyncResult *result, gpointer user_data) @@ -447,88 +431,6 @@ gboolean ovirt_foreign_menu_set_current_iso_name_finish(OvirtForeignMenu *foreig } -static void -ovirt_foreign_menu_iso_name_changed(GObject *source_object, -GAsyncResult *result, -gpointer user_data G_GNUC_UNUSED) -{ -OvirtForeignMenu *foreign_menu = OVIRT_FOREIGN_MENU(source_object); -GError *error = NULL; - -if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -g_warning(error ? error->message : "Failed to change CD"); -g_clear_error(&error); -return; -} - -g_object_notify(G_OBJECT(foreign_menu), "file"); -} - - -static void -ovirt_foreign_menu_activate_item_cb(GtkMenuItem *menuitem, gpointer user_data) -{ -OvirtForeignMenu *foreign_menu; -const char *iso_name = NULL; -gboolean checked; - -checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)); -foreign_menu = OVIRT_FOREIGN_MENU(user_data); -g_return_if_fail(foreign_menu->priv->cdrom != NULL); -g_return_if_fail(foreign_menu->priv->next_iso_name == NULL); - -g_debug("'%s' clicked", gtk_menu_item_get_label(menuitem)); - -/* We only want to move the check mark for the currently selected ISO - * when ovirt_cdrom_update_async() is successful, so for now we move - * the check mark back to where it was before - */ -menu_item_set_active_no_signal(menuitem, !checked, - (GCallback)ovirt_foreign_menu_activate_item_cb, - foreign_menu); - -if (checked) { -iso_name = gtk_menu_item_get_label(menuitem); -} -ovirt_foreign_menu_set_current_iso_name_async(foreign_menu, iso_name, NULL, - ovirt_foreign_menu_iso_name_changed, - menuitem); -} - - -GtkWidget *ovirt_foreign_menu_get_gtk_menu(OvirtForeignMenu *foreign_menu) -{ -GtkWidget *gtk_menu; -GList *it; -char *current_iso; - -if (foreign_menu->priv->iso_names == NULL) { -g_debug("ISO list is empty, no menu to show"); -return NULL; -} -g_debug("Creating GtkMenu for foreign menu"); -current_iso = ovirt_foreign_menu_get_current_iso_name(foreign_menu); -gtk_menu = gtk_menu_new(); -for (it = foreign_menu->priv->iso_names; it != NULL; it = it->next) { -GtkWidget *menuitem; - -menuitem = gtk_check_menu_item_new_with_label((char *)it->data); -if (g_strcmp0((char *)it->data, current_iso) == 0) { -g_warn_if_fail(g_strcmp0(current_iso, foreign_menu->priv->current_iso_name) == 0); -gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), - TRUE); -} -g_signal_connect(menuitem, "activate", - G_CALLBACK(ovirt_foreign_menu_activate_item_cb), - foreign_menu); -gtk_menu_shell_append(GTK_MENU_SHELL(gtk_menu), menuitem); -} -g_free(current_iso); - -return gtk_menu; -} - - static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu, const GList *files) { @@ -594,7 +496,6 @@ static void cdrom_file_refreshed_cb(GObject *source_object, "file", &menu->pri
[virt-tools-list] [PATCH virt-viewer 4/4] iso-dialog: Use header bar for buttons
It seems to give more modern look to the dialog, but it requires Gtk+ 3.12, thus I will am keeping this commit separated. On the glade UI file, we get rid of the GtkAlignment object that was used to put some space between the tree view and dialog buttons. The "Select ISO" label is gone too. Signed-off-by: Eduardo Lima (Etrunko) --- configure.ac | 4 +- src/remote-viewer-iso-list-dialog.c| 31 +-- src/resources/ui/remote-viewer-iso-list.ui | 87 +++--- 3 files changed, 60 insertions(+), 62 deletions(-) diff --git a/configure.ac b/configure.ac index c611d70..ce71349 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38" GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" # Keep these two definitions in agreement. -GTK_REQUIRED="3.10" -GTK_ENCODED_VERSION="GDK_VERSION_3_10" +GTK_REQUIRED="3.12" +GTK_ENCODED_VERSION="GDK_VERSION_3_12" LIBXML2_REQUIRED="2.6.0" LIBVIRT_REQUIRED="0.10.0" diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index e27e5fc..b788262 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -36,6 +36,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkHeaderBar *header_bar; GtkListStore *list_store; GtkWidget *status; GtkWidget *spinner; @@ -118,6 +119,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) } static void +remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *subtitle = NULL; + +if (iso_name && strlen(iso_name) != 0) +subtitle = g_strdup_printf(_("Current: %s"), iso_name); + +gtk_header_bar_set_subtitle(priv->header_bar, subtitle); +g_free(subtitle); +} + +static void remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) { RemoteViewerISOListDialogPrivate *priv = self->priv; @@ -137,6 +151,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); } g_free(current_iso); @@ -195,6 +210,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, gtk_spinner_start(GTK_SPINNER(priv->spinner)); gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); +remote_viewer_iso_list_dialog_set_subtitle(self, NULL); gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", GTK_STACK_TRANSITION_TYPE_NONE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); @@ -248,9 +264,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); GtkCellRendererToggle *cell_renderer; +GtkWidget *button, *image; gtk_builder_connect_signals(builder, self); +priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self))); +gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE); + priv->status = GTK_WIDGET(gtk_builder_get_object(builder, "status")); priv->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner")); priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack")); @@ -264,12 +284,11 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) g_object_unref(builder); -gtk_dialog_add_buttons(GTK_DIALOG(self), - _("Refresh"), GTK_RESPONSE_NONE, - _("Close"), GTK_RESPONSE_CLOSE, - NULL); +button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE); +image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON); +gtk_button_set_image(GTK_BUTTON(button), image); +gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE); -gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL); } @@ -337,6 +356,7 @@ ovirt_foreign_menu_iso_name_cha
[virt-tools-list] [PATCH virt-viewer 2/4] Run ISO dialog when 'Change CD' menu is activated
Also moves 'Change CD' menu item from the toplevel menu to a subitem under 'File' toplevel menu. In order to avoid object interdependency, it is necessary to make the ovirt foreign-menu pointer from RemoteViewer, acessible via property, so it can be passed to the dialog as an opaque GObject. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer.c | 37 + src/resources/ui/virt-viewer.ui | 19 ++- src/virt-viewer-window.c| 37 + 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/remote-viewer.c b/src/remote-viewer.c index c84a35b..29d7db1 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP) #define GET_PRIVATE(o)\ (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate)) +enum RemoteViewerProperties { +PROP_0, +#ifdef HAVE_OVIRT +PROP_OVIRT_FOREIGN_MENU, +#endif +}; + #ifdef HAVE_OVIRT static OvirtVm * choose_vm(GtkWindow *main_window, char **vm_name, @@ -214,6 +221,25 @@ end: } static void +remote_viewer_get_property(GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ +RemoteViewer *self = REMOTE_VIEWER(object); +RemoteViewerPrivate *priv = self->priv; + +switch (property_id) { +#ifdef HAVE_OVIRT +case PROP_OVIRT_FOREIGN_MENU: +g_value_set_object(value, priv->ovirt_foreign_menu); +break; +#endif + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} +} + +static void remote_viewer_class_init (RemoteViewerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass) g_type_class_add_private (klass, sizeof (RemoteViewerPrivate)); +object_class->get_property = remote_viewer_get_property; object_class->dispose = remote_viewer_dispose; g_app_class->local_command_line = remote_viewer_local_command_line; @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClass *klass) #else (void) gtk_app_class; #endif + +#ifdef HAVE_OVIRT +g_object_class_install_property(object_class, +PROP_OVIRT_FOREIGN_MENU, +g_param_spec_object("ovirt-foreign-menu", +"oVirt Foreign Menu", +"Object which is used as interface to oVirt", + OVIRT_TYPE_FOREIGN_MENU, +G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); +#endif } static void diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui index 6e3c5ad..e9609ec 100644 --- a/src/resources/ui/virt-viewer.ui +++ b/src/resources/ui/virt-viewer.ui @@ -1,6 +1,7 @@ + - + False @@ -73,6 +74,14 @@ + +False +_Change CD +True + + + + True False @@ -247,14 +256,6 @@ - - -False -False -_Change CD -True - - False diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 99fd102..8eda12e 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -43,6 +43,8 @@ #include "virt-viewer-util.h" #include "virt-viewer-timed-revealer.h" +#include "remote-viewer-iso-list-dialog.h" + #define ZOOM_STEP 10 /* Signal handlers for main window (move in a VirtViewerMainWindow?) */ @@ -62,6 +64,7 @@ void virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, VirtViewerWindow *self); void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, VirtViewerWindow *self); +void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, VirtViewerWindow *self); /* Internal methods */ @@ -1056,6 +1059,40 @@ virt_viewer_window_menu_help_about(GtkWidget *me
Re: [virt-tools-list] [PATCH virt-viewer 2/4] Run ISO dialog when 'Change CD' menu is activated
On 24/01/17 09:11, Christophe Fergeau wrote: > On Mon, Jan 23, 2017 at 05:28:14PM -0200, Eduardo Lima (Etrunko) wrote: >> Also moves 'Change CD' menu item from the toplevel menu to a subitem >> under 'File' toplevel menu. >> >> In order to avoid object interdependency, it is necessary to make the >> ovirt foreign-menu pointer from RemoteViewer, acessible via property, so > > 'accessible'. Behaviour of the menu with this patch is quite odd, maybe > a few bits from the next patch belong in here? However, I think I'd just > merge both patches (?). I think it is a good idea, indeed, will do it, and also "merge" de commit messages. > > Apart from this, > Acked-by: Christophe Fergeau > > Christophe > >> it can be passed to the dialog as an opaque GObject. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer.c | 37 + >> src/resources/ui/virt-viewer.ui | 19 ++- >> src/virt-viewer-window.c| 37 + >> 3 files changed, 84 insertions(+), 9 deletions(-) >> >> diff --git a/src/remote-viewer.c b/src/remote-viewer.c >> index c84a35b..29d7db1 100644 >> --- a/src/remote-viewer.c >> +++ b/src/remote-viewer.c >> @@ -67,6 +67,13 @@ G_DEFINE_TYPE (RemoteViewer, remote_viewer, >> VIRT_VIEWER_TYPE_APP) >> #define GET_PRIVATE(o) >> \ >> (G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, >> RemoteViewerPrivate)) >> >> +enum RemoteViewerProperties { >> +PROP_0, >> +#ifdef HAVE_OVIRT >> +PROP_OVIRT_FOREIGN_MENU, >> +#endif >> +}; >> + >> #ifdef HAVE_OVIRT >> static OvirtVm * choose_vm(GtkWindow *main_window, >> char **vm_name, >> @@ -214,6 +221,25 @@ end: >> } >> >> static void >> +remote_viewer_get_property(GObject *object, guint property_id, >> + GValue *value, GParamSpec *pspec) >> +{ >> +RemoteViewer *self = REMOTE_VIEWER(object); >> +RemoteViewerPrivate *priv = self->priv; >> + >> +switch (property_id) { >> +#ifdef HAVE_OVIRT >> +case PROP_OVIRT_FOREIGN_MENU: >> +g_value_set_object(value, priv->ovirt_foreign_menu); >> +break; >> +#endif >> + >> +default: >> +G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); >> +} >> +} >> + >> +static void >> remote_viewer_class_init (RemoteViewerClass *klass) >> { >> GObjectClass *object_class = G_OBJECT_CLASS (klass); >> @@ -223,6 +249,7 @@ remote_viewer_class_init (RemoteViewerClass *klass) >> >> g_type_class_add_private (klass, sizeof (RemoteViewerPrivate)); >> >> +object_class->get_property = remote_viewer_get_property; >> object_class->dispose = remote_viewer_dispose; >> >> g_app_class->local_command_line = remote_viewer_local_command_line; >> @@ -236,6 +263,16 @@ remote_viewer_class_init (RemoteViewerClass *klass) >> #else >> (void) gtk_app_class; >> #endif >> + >> +#ifdef HAVE_OVIRT >> +g_object_class_install_property(object_class, >> +PROP_OVIRT_FOREIGN_MENU, >> + >> g_param_spec_object("ovirt-foreign-menu", >> +"oVirt Foreign >> Menu", >> +"Object which is >> used as interface to oVirt", >> + >> OVIRT_TYPE_FOREIGN_MENU, >> +G_PARAM_READABLE | >> G_PARAM_STATIC_STRINGS)); >> +#endif >> } >> >> static void >> diff --git a/src/resources/ui/virt-viewer.ui >> b/src/resources/ui/virt-viewer.ui >> index 6e3c5ad..e9609ec 100644 >> --- a/src/resources/ui/virt-viewer.ui >> +++ b/src/resources/ui/virt-viewer.ui >> @@ -1,6 +1,7 @@ >> >> + >> >> - >> + >> >> >> False >> @@ -73,6 +74,14 @@ >> >> >> >> + >> +False >> +> translatable="yes">_Change
[virt-tools-list] [PATCH virt-viewer] iso-dialog: Avoid crash when closing dialog early
We must take into account that users can close the dialog at anytime, even during an operation of fetch or set ISO has not been finished. This will cause the callbacks for those operations to be invoked with an invalid object, crashing the application. To fix this issue we need to pass a GCancellable to the asynchronous operations, so they can be cancelled if the dialog happens to get closed before they complete. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer-iso-list-dialog.c | 30 +++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index f23ddb2..a7ac98a 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate GtkWidget *stack; GtkWidget *tree_view; OvirtForeignMenu *foreign_menu; +GCancellable *cancellable; }; enum RemoteViewerISOListDialogModel @@ -66,10 +67,16 @@ remote_viewer_iso_list_dialog_dispose(GObject *object) RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); RemoteViewerISOListDialogPrivate *priv = self->priv; +if (priv->cancellable) { +g_cancellable_cancel(priv->cancellable); +g_clear_object(&priv->cancellable); +} + if (priv->foreign_menu) { g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); g_clear_object(&priv->foreign_menu); } + G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); } @@ -157,6 +164,10 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, const gchar *msg = error ? error->message : _("Failed to fetch CD names"); gchar *markup = g_strdup_printf("%s", msg); +g_debug("Error fetching ISO names: %s", msg); +if (error && error->code == G_IO_ERROR_CANCELLED) +return; + gtk_label_set_markup(GTK_LABEL(priv->status), markup); gtk_spinner_stop(GTK_SPINNER(priv->spinner)); remote_viewer_iso_list_dialog_show_error(self, msg); @@ -166,6 +177,7 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, return; } +g_clear_object(&priv->cancellable); g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, self); remote_viewer_iso_list_dialog_show_files(self); } @@ -177,7 +189,10 @@ remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv; gtk_list_store_clear(priv->list_store); -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, + +priv->cancellable = g_cancellable_new(); +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, + priv->cancellable, (GAsyncReadyCallback) fetch_iso_names_cb, self); } @@ -223,7 +238,9 @@ remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer G_GNU gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); gtk_widget_set_sensitive(priv->tree_view, FALSE); -ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, NULL, +priv->cancellable = g_cancellable_new(); +ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, + priv->cancellable, (GAsyncReadyCallback)ovirt_foreign_menu_iso_name_changed, self); gtk_tree_path_free(tree_path); @@ -308,10 +325,17 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, * change the ISO back to the original, avoiding a possible inconsistency. */ if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -remote_viewer_iso_list_dialog_show_error(self, error ? error->message : _("Failed to change CD")); +gchar *msg = error ? error->message : _("Failed to change CD"); +g_debug("Error changing ISO: %s", msg); + +if (error && error->code == G_IO_ERROR_CANCELLED) +return; + +remote_viewer_iso_list_dialog_show_error(self, msg); g_clear_error(&error); } +g_clear_object(&priv->cancellable); if (!gtk_tree_model_get_iter_first(model, &iter)) return; -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] iso-dialog: Avoid crash when closing dialog early
On 03/02/17 14:34, Christophe Fergeau wrote: > Hey, > > On Thu, Jan 26, 2017 at 06:01:23PM -0200, Eduardo Lima (Etrunko) wrote: >> We must take into account that users can close the dialog at anytime, >> even during an operation of fetch or set ISO has not been finished. This >> will cause the callbacks for those operations to be invoked with an >> invalid object, crashing the application. >> >> To fix this issue we need to pass a GCancellable to the asynchronous >> operations, so they can be cancelled if the dialog happens to get closed >> before they complete. >> > > This is going to depend on libgovirt bug > https://bugzilla.gnome.org/show_bug.cgi?id=777808 being fixed, otherwise > we'd be getting a deadlock, is that correct? > Yes, this patch depends on the fix in libgovirt. >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> src/remote-viewer-iso-list-dialog.c | 30 +++--- >> 1 file changed, 27 insertions(+), 3 deletions(-) >> >> diff --git a/src/remote-viewer-iso-list-dialog.c >> b/src/remote-viewer-iso-list-dialog.c >> index f23ddb2..a7ac98a 100644 >> --- a/src/remote-viewer-iso-list-dialog.c >> +++ b/src/remote-viewer-iso-list-dialog.c >> @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate >> GtkWidget *stack; >> GtkWidget *tree_view; >> OvirtForeignMenu *foreign_menu; >> +GCancellable *cancellable; >> }; >> >> enum RemoteViewerISOListDialogModel >> @@ -66,10 +67,16 @@ remote_viewer_iso_list_dialog_dispose(GObject *object) >> RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); >> RemoteViewerISOListDialogPrivate *priv = self->priv; >> >> +if (priv->cancellable) { >> +g_cancellable_cancel(priv->cancellable); >> +g_clear_object(&priv->cancellable); >> +} >> + > > g_cancellable_cancel() can be async, and at this point, the iso dialog > is already dead, are you sure it's safe to cancel here? I am not sure, thinking better about it, it may be safer to cancel on the response signal, or maybe by the close signal. > >> if (priv->foreign_menu) { >> g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); >> g_clear_object(&priv->foreign_menu); >> } >> + > > I'd drop this added blank line Oops, slipped in. > >> >> G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object); >> } >> >> @@ -157,6 +164,10 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, >> const gchar *msg = error ? error->message : _("Failed to fetch CD >> names"); >> gchar *markup = g_strdup_printf("%s", msg); >> >> +g_debug("Error fetching ISO names: %s", msg); >> +if (error && error->code == G_IO_ERROR_CANCELLED) >> +return; >> + > > 'error' is leaked. Fixed. > >> gtk_label_set_markup(GTK_LABEL(priv->status), markup); >> gtk_spinner_stop(GTK_SPINNER(priv->spinner)); >> remote_viewer_iso_list_dialog_show_error(self, msg); >> @@ -166,6 +177,7 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, >> return; >> } >> >> +g_clear_object(&priv->cancellable); >> g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, >> self); >> remote_viewer_iso_list_dialog_show_files(self); >> } >> @@ -177,7 +189,10 @@ >> remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog >> *self) >> RemoteViewerISOListDialogPrivate *priv = self->priv; >> >> gtk_list_store_clear(priv->list_store); >> -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, >> + >> +priv->cancellable = g_cancellable_new(); >> +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, >> + priv->cancellable, >> (GAsyncReadyCallback) >> fetch_iso_names_cb, >> self); >> } >> @@ -223,7 +238,9 @@ >> remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer >> G_GNU >> gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, >> FALSE); >> gtk_widget_set_sensitive(priv->tree_view, FALSE); >> >> -ovirt_foreign_menu_
[virt-tools-list] [PATCH virt-viewer] iso-dialog: Avoid crash when closing dialog early
We must take into account that users can close the dialog at anytime, even during an operation of fetch or set ISO has not been finished. This will cause the callbacks for those operations to be invoked with an invalid object, crashing the application. To fix this issue we need to pass a GCancellable to the asynchronous operations, so they can be cancelled if the dialog happens to get closed before they complete. Signed-off-by: Eduardo Lima (Etrunko) --- v2: * Move call to g_cancellable_cancel() to response handler. * Don't leak error objects if operation is cancelled. --- src/remote-viewer-iso-list-dialog.c | 42 ++--- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index f23ddb2..aa0ebbb 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate GtkWidget *stack; GtkWidget *tree_view; OvirtForeignMenu *foreign_menu; +GCancellable *cancellable; }; enum RemoteViewerISOListDialogModel @@ -66,6 +67,8 @@ remote_viewer_iso_list_dialog_dispose(GObject *object) RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); RemoteViewerISOListDialogPrivate *priv = self->priv; +g_clear_object(&priv->cancellable); + if (priv->foreign_menu) { g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); g_clear_object(&priv->foreign_menu); @@ -157,17 +160,24 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, const gchar *msg = error ? error->message : _("Failed to fetch CD names"); gchar *markup = g_strdup_printf("%s", msg); +g_debug("Error fetching ISO names: %s", msg); +if (error && error->code == G_IO_ERROR_CANCELLED) +goto end; + gtk_label_set_markup(GTK_LABEL(priv->status), markup); gtk_spinner_stop(GTK_SPINNER(priv->spinner)); remote_viewer_iso_list_dialog_show_error(self, msg); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE); g_free(markup); -g_clear_error(&error); -return; +goto end; } +g_clear_object(&priv->cancellable); g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, self); remote_viewer_iso_list_dialog_show_files(self); + +end: +g_clear_error(&error); } @@ -177,7 +187,10 @@ remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv; gtk_list_store_clear(priv->list_store); -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, + +priv->cancellable = g_cancellable_new(); +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, + priv->cancellable, (GAsyncReadyCallback) fetch_iso_names_cb, self); } @@ -190,8 +203,10 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); RemoteViewerISOListDialogPrivate *priv = self->priv; -if (response_id != GTK_RESPONSE_NONE) +if (response_id != GTK_RESPONSE_NONE) { +g_cancellable_cancel(priv->cancellable); return; +} gtk_spinner_start(GTK_SPINNER(priv->spinner)); gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); @@ -223,7 +238,9 @@ remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer G_GNU gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); gtk_widget_set_sensitive(priv->tree_view, FALSE); -ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, NULL, +priv->cancellable = g_cancellable_new(); +ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, + priv->cancellable, (GAsyncReadyCallback)ovirt_foreign_menu_iso_name_changed, self); gtk_tree_path_free(tree_path); @@ -308,12 +325,18 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, * change the ISO back to the original, avoiding a possible inconsistency. */ if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -remote_viewer_iso_list_dialog_show_error(self, error ? error->message : _("Failed to change CD")); -g_clear_error(&error); +gchar *msg = error ? error
[virt-tools-list] [PATCH virt-viewer] session-spice: Pass hostname to authentication dialog
With this patch the dialog now shows the host we are trying to connect to. Signed-off-by: Eduardo Lima (Etrunko) --- src/virt-viewer-session-spice.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c index c3fce48..bbdc680 100644 --- a/src/virt-viewer-session-spice.c +++ b/src/virt-viewer-session-spice.c @@ -667,7 +667,7 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, VirtViewerSession *session) { VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session); -gchar *password = NULL, *user = NULL; +gchar *password = NULL, *user = NULL, *host = NULL; gboolean ret; static gboolean username_required = FALSE; @@ -717,9 +717,10 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, user = g_strdup(g_get_user_name()); } +g_object_get(self->priv->session, "host", &host, NULL); ret = virt_viewer_auth_collect_credentials(self->priv->main_window, "SPICE", - NULL, + host, username_required ? &user : NULL, &password); if (!ret) { @@ -749,8 +750,9 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, SpiceURI *proxy = spice_session_get_proxy_uri(self->priv->session); g_warn_if_fail(proxy != NULL); +g_object_get(self->priv->session, "host", &host, NULL); ret = virt_viewer_auth_collect_credentials(self->priv->main_window, - "proxy", NULL, + "proxy", host, &user, &password); if (!ret) { g_signal_emit_by_name(session, "session-cancelled"); @@ -776,6 +778,7 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, g_free(password); g_free(user); +g_free(host); } static void remove_cb(GtkContainer *container G_GNUC_UNUSED, -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] iso-dialog: Do not use string directly
Acked-by: Eduardo Lima (Etrunko) On 06/02/17 10:02, Pavel Grunt wrote: > Fixes -Werror=format-security used when creating the rpm > --- > see: > https://copr-be.cloud.fedoraproject.org/results/pgrunt/spice-upstream/fedora-25-x86_64/00507878-virt-viewer/build.log.gz > --- > src/remote-viewer-iso-list-dialog.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/remote-viewer-iso-list-dialog.c > b/src/remote-viewer-iso-list-dialog.c > index f23ddb2..2ab5435 100644 > --- a/src/remote-viewer-iso-list-dialog.c > +++ b/src/remote-viewer-iso-list-dialog.c > @@ -286,7 +286,7 @@ > remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog *self, > GTK_DIALOG_DESTROY_WITH_PARENT, > GTK_MESSAGE_ERROR, > GTK_BUTTONS_CLOSE, > -message ? message : _("Unspecified > error")); > +"%s", message ? message : _("Unspecified > error")); > gtk_dialog_run(GTK_DIALOG(dialog)); > gtk_widget_destroy(dialog); > } > -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] session-spice: Pass hostname to authentication dialog
On 06/02/17 09:20, Pavel Grunt wrote: > On Fri, 2017-02-03 at 16:11 -0200, Eduardo Lima (Etrunko) wrote: >> With this patch the dialog now shows the host we are trying to >> connect to. > > I would mention that we use the "host" property of SpiceSession Okay, will do. > >> >> Signed-off-by: Eduardo Lima (Etrunko) > > --- >> src/virt-viewer-session-spice.c | 9 ++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) >> >> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer- >> session-spice.c >> index c3fce48..bbdc680 100644 >> --- a/src/virt-viewer-session-spice.c >> +++ b/src/virt-viewer-session-spice.c >> @@ -667,7 +667,7 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> VirtViewerSession >> *session) >> { >> VirtViewerSessionSpice *self = >> VIRT_VIEWER_SESSION_SPICE(session); >> -gchar *password = NULL, *user = NULL; >> +gchar *password = NULL, *user = NULL, *host = NULL; >> gboolean ret; >> static gboolean username_required = FALSE; >> >> @@ -717,9 +717,10 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> user = g_strdup(g_get_user_name()); >> } >> >> +g_object_get(self->priv->session, "host", &host, NULL); >> ret = virt_viewer_auth_collect_credentials(self->priv- >>> main_window, >> "SPICE", >> - NULL, >> + host, >> username_require >> d ? &user : NULL, >> &password); >> if (!ret) { >> @@ -749,8 +750,9 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> SpiceURI *proxy = spice_session_get_proxy_uri(self- >>> priv->session); >> g_warn_if_fail(proxy != NULL); >> >> +g_object_get(self->priv->session, "host", &host, NULL); >> ret = virt_viewer_auth_collect_credentials(self->priv- >>> main_window, >> - "proxy", >> NULL, >> + "proxy", >> host, > > Should it be the "host" or the proxy uri (spice_uri_get_hostname()) ? > I am really not sure, but I as it is a connection to the proxy, I think it would make sense to use the proxy uri. Any suggestion? -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] session-spice: Pass hostname to authentication dialog
On 07/02/17 17:06, Pavel Grunt wrote: > On Tue, 2017-02-07 at 16:29 -0200, Eduardo Lima (Etrunko) wrote: >> On 06/02/17 09:20, Pavel Grunt wrote: >>> On Fri, 2017-02-03 at 16:11 -0200, Eduardo Lima (Etrunko) wrote: >>>> With this patch the dialog now shows the host we are trying to >>>> connect to. >>> >>> I would mention that we use the "host" property of SpiceSession >> >> Okay, will do. >> >>> >>>> >>>> Signed-off-by: Eduardo Lima (Etrunko) >>> >>> --- >>>> src/virt-viewer-session-spice.c | 9 ++--- >>>> 1 file changed, 6 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer- >>>> session-spice.c >>>> index c3fce48..bbdc680 100644 >>>> --- a/src/virt-viewer-session-spice.c >>>> +++ b/src/virt-viewer-session-spice.c >>>> @@ -667,7 +667,7 @@ >>>> virt_viewer_session_spice_main_channel_event(SpiceChannel >>>> *channel, >>>> VirtViewerSession >>>> *session) >>>> { >>>> VirtViewerSessionSpice *self = >>>> VIRT_VIEWER_SESSION_SPICE(session); >>>> -gchar *password = NULL, *user = NULL; >>>> +gchar *password = NULL, *user = NULL, *host = NULL; >>>> gboolean ret; >>>> static gboolean username_required = FALSE; >>>> >>>> @@ -717,9 +717,10 @@ >>>> virt_viewer_session_spice_main_channel_event(SpiceChannel >>>> *channel, >>>> user = g_strdup(g_get_user_name()); >>>> } >>>> >>>> +g_object_get(self->priv->session, "host", &host, NULL); >>>> ret = virt_viewer_auth_collect_credentials(self->priv- >>>>> main_window, >>>> >>>> "SPICE", >>>> - NULL, >>>> + host, >>>> username_req >>>> uire >>>> d ? &user : NULL, >>>> &password); >>>> if (!ret) { >>>> @@ -749,8 +750,9 @@ >>>> virt_viewer_session_spice_main_channel_event(SpiceChannel >>>> *channel, >>>> SpiceURI *proxy = spice_session_get_proxy_uri(self- >>>>> priv->session); >>>> >>>> g_warn_if_fail(proxy != NULL); >>>> >>>> +g_object_get(self->priv->session, "host", &host, >>>> NULL); >>>> ret = virt_viewer_auth_collect_credentials(self- >>>>> priv- >>>>> main_window, >>>> >>>> - "proxy", >>>> NULL, >>>> + "proxy", >>>> host, >>> >>> Should it be the "host" or the proxy uri >>> (spice_uri_get_hostname()) ? >>> >> >> I am really not sure, but I as it is a connection to the proxy, I >> think >> it would make sense to use the proxy uri. Any suggestion? > > I agree, but in this version it is not the proxy uri, no ? > No, it is not, I just got the same property. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer PATCH] Show errors generated by connection dialog
On 08/02/17 14:48, Christophe de Dinechin wrote: > When running 'remote-viewer' without arguments, > and selecting a non-supported protocol, e.g. ssh://foo, > the generated error was silently swallowed by the retry loop. > This was introduced in 06b2c382468876a19600374bd59475e66d488af8. > --- > src/remote-viewer.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/remote-viewer.c b/src/remote-viewer.c > index 13c6e7c..c9ef4bb 100644 > --- a/src/remote-viewer.c > +++ b/src/remote-viewer.c > @@ -1196,6 +1196,9 @@ cleanup: > type = NULL; > > if (!ret && priv->open_recent_dialog) { > +if (error) { > +virt_viewer_app_simple_message_dialog(&self->parent, "%s", > error->message); > +} Patch looks good, I personally also like to check for error->message before dereferencing it, but I don't really know what others think about it. Reviewed-by: Eduardo Lima (Etrunko) -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] iso-dialog: Avoid crash when closing dialog early
Looks like this v2 never made to the list? I am sending it again. On 03/02/17 15:28, Eduardo Lima (Etrunko) wrote: > We must take into account that users can close the dialog at anytime, > even during an operation of fetch or set ISO has not been finished. This > will cause the callbacks for those operations to be invoked with an > invalid object, crashing the application. > > To fix this issue we need to pass a GCancellable to the asynchronous > operations, so they can be cancelled if the dialog happens to get closed > before they complete. > > Signed-off-by: Eduardo Lima (Etrunko) > --- > v2: > * Move call to g_cancellable_cancel() to response handler. > * Don't leak error objects if operation is cancelled. > > --- > src/remote-viewer-iso-list-dialog.c | 42 > ++--- > 1 file changed, 34 insertions(+), 8 deletions(-) > > diff --git a/src/remote-viewer-iso-list-dialog.c > b/src/remote-viewer-iso-list-dialog.c > index f23ddb2..aa0ebbb 100644 > --- a/src/remote-viewer-iso-list-dialog.c > +++ b/src/remote-viewer-iso-list-dialog.c > @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate > GtkWidget *stack; > GtkWidget *tree_view; > OvirtForeignMenu *foreign_menu; > +GCancellable *cancellable; > }; > > enum RemoteViewerISOListDialogModel > @@ -66,6 +67,8 @@ remote_viewer_iso_list_dialog_dispose(GObject *object) > RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); > RemoteViewerISOListDialogPrivate *priv = self->priv; > > +g_clear_object(&priv->cancellable); > + > if (priv->foreign_menu) { > g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); > g_clear_object(&priv->foreign_menu); > @@ -157,17 +160,24 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, > const gchar *msg = error ? error->message : _("Failed to fetch CD > names"); > gchar *markup = g_strdup_printf("%s", msg); > > +g_debug("Error fetching ISO names: %s", msg); > +if (error && error->code == G_IO_ERROR_CANCELLED) > +goto end; > + > gtk_label_set_markup(GTK_LABEL(priv->status), markup); > gtk_spinner_stop(GTK_SPINNER(priv->spinner)); > remote_viewer_iso_list_dialog_show_error(self, msg); > gtk_dialog_set_response_sensitive(GTK_DIALOG(self), > GTK_RESPONSE_NONE, TRUE); > g_free(markup); > -g_clear_error(&error); > -return; > +goto end; > } > > +g_clear_object(&priv->cancellable); > g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, > self); > remote_viewer_iso_list_dialog_show_files(self); > + > +end: > +g_clear_error(&error); > } > > > @@ -177,7 +187,10 @@ > remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog > *self) > RemoteViewerISOListDialogPrivate *priv = self->priv; > > gtk_list_store_clear(priv->list_store); > -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, > + > +priv->cancellable = g_cancellable_new(); > +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, > + priv->cancellable, > (GAsyncReadyCallback) > fetch_iso_names_cb, > self); > } > @@ -190,8 +203,10 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, > RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); > RemoteViewerISOListDialogPrivate *priv = self->priv; > > -if (response_id != GTK_RESPONSE_NONE) > +if (response_id != GTK_RESPONSE_NONE) { > +g_cancellable_cancel(priv->cancellable); > return; > +} > > gtk_spinner_start(GTK_SPINNER(priv->spinner)); > gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); > @@ -223,7 +238,9 @@ > remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer > G_GNU > gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, > FALSE); > gtk_widget_set_sensitive(priv->tree_view, FALSE); > > -ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active > ? NULL : name, NULL, > +priv->cancellable = g_cancellable_new(); > +ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active > ? NULL : name, > + priv->cancellable, >
[virt-tools-list] [PATCH virt-viewer v2] iso-dialog: Avoid crash when closing dialog early
We must take into account that users can close the dialog at anytime, even during an operation of fetch or set ISO has not been finished. This will cause the callbacks for those operations to be invoked with an invalid object, crashing the application. To fix this issue we need to pass a GCancellable to the asynchronous operations, so they can be cancelled if the dialog happens to get closed before they complete. Signed-off-by: Eduardo Lima (Etrunko) --- v2: * Move call to g_cancellable_cancel() to response handler. * Don't leak error objects if operation is cancelled. --- src/remote-viewer-iso-list-dialog.c | 42 ++--- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index 2ab5435..ed51ffa 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate GtkWidget *stack; GtkWidget *tree_view; OvirtForeignMenu *foreign_menu; +GCancellable *cancellable; }; enum RemoteViewerISOListDialogModel @@ -66,6 +67,8 @@ remote_viewer_iso_list_dialog_dispose(GObject *object) RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); RemoteViewerISOListDialogPrivate *priv = self->priv; +g_clear_object(&priv->cancellable); + if (priv->foreign_menu) { g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); g_clear_object(&priv->foreign_menu); @@ -157,17 +160,24 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, const gchar *msg = error ? error->message : _("Failed to fetch CD names"); gchar *markup = g_strdup_printf("%s", msg); +g_debug("Error fetching ISO names: %s", msg); +if (error && error->code == G_IO_ERROR_CANCELLED) +goto end; + gtk_label_set_markup(GTK_LABEL(priv->status), markup); gtk_spinner_stop(GTK_SPINNER(priv->spinner)); remote_viewer_iso_list_dialog_show_error(self, msg); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE); g_free(markup); -g_clear_error(&error); -return; +goto end; } +g_clear_object(&priv->cancellable); g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, self); remote_viewer_iso_list_dialog_show_files(self); + +end: +g_clear_error(&error); } @@ -177,7 +187,10 @@ remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv; gtk_list_store_clear(priv->list_store); -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, + +priv->cancellable = g_cancellable_new(); +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, + priv->cancellable, (GAsyncReadyCallback) fetch_iso_names_cb, self); } @@ -190,8 +203,10 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); RemoteViewerISOListDialogPrivate *priv = self->priv; -if (response_id != GTK_RESPONSE_NONE) +if (response_id != GTK_RESPONSE_NONE) { +g_cancellable_cancel(priv->cancellable); return; +} gtk_spinner_start(GTK_SPINNER(priv->spinner)); gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); @@ -223,7 +238,9 @@ remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer G_GNU gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); gtk_widget_set_sensitive(priv->tree_view, FALSE); -ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, NULL, +priv->cancellable = g_cancellable_new(); +ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active ? NULL : name, + priv->cancellable, (GAsyncReadyCallback)ovirt_foreign_menu_iso_name_changed, self); gtk_tree_path_free(tree_path); @@ -308,12 +325,18 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, * change the ISO back to the original, avoiding a possible inconsistency. */ if (!ovirt_foreign_menu_set_current_iso_name_finish(foreign_menu, result, &error)) { -remote_viewer_iso_list_dialog_show_error(self, error ? error->message : _("Failed to change CD")); -g_clear_error(&error); +const gchar *msg = error ? error
Re: [virt-tools-list] [PATCH virt-viewer v2] iso-dialog: Avoid crash when closing dialog early
On 09/02/17 15:13, Eduardo Lima (Etrunko) wrote: > We must take into account that users can close the dialog at anytime, > even during an operation of fetch or set ISO has not been finished. This > will cause the callbacks for those operations to be invoked with an > invalid object, crashing the application. > > To fix this issue we need to pass a GCancellable to the asynchronous > operations, so they can be cancelled if the dialog happens to get closed > before they complete. I have modified this commit message with a link to the libgovirt bug: NOTE: This patch triggers a deadlock in libgovirt when the dialog is closed before the operation completes. Bug reported in https://bugzilla.gnome.org/show_bug.cgi?id=777808. We will need to bump libgovirt dependency whenever it has a new release. > > Signed-off-by: Eduardo Lima (Etrunko) > --- > v2: > * Move call to g_cancellable_cancel() to response handler. > * Don't leak error objects if operation is cancelled. > --- > src/remote-viewer-iso-list-dialog.c | 42 > ++--- > 1 file changed, 34 insertions(+), 8 deletions(-) > > diff --git a/src/remote-viewer-iso-list-dialog.c > b/src/remote-viewer-iso-list-dialog.c > index 2ab5435..ed51ffa 100644 > --- a/src/remote-viewer-iso-list-dialog.c > +++ b/src/remote-viewer-iso-list-dialog.c > @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate > GtkWidget *stack; > GtkWidget *tree_view; > OvirtForeignMenu *foreign_menu; > +GCancellable *cancellable; > }; > > enum RemoteViewerISOListDialogModel > @@ -66,6 +67,8 @@ remote_viewer_iso_list_dialog_dispose(GObject *object) > RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object); > RemoteViewerISOListDialogPrivate *priv = self->priv; > > +g_clear_object(&priv->cancellable); > + > if (priv->foreign_menu) { > g_signal_handlers_disconnect_by_data(priv->foreign_menu, object); > g_clear_object(&priv->foreign_menu); > @@ -157,17 +160,24 @@ fetch_iso_names_cb(OvirtForeignMenu *foreign_menu, > const gchar *msg = error ? error->message : _("Failed to fetch CD > names"); > gchar *markup = g_strdup_printf("%s", msg); > > +g_debug("Error fetching ISO names: %s", msg); > +if (error && error->code == G_IO_ERROR_CANCELLED) > +goto end; > + > gtk_label_set_markup(GTK_LABEL(priv->status), markup); > gtk_spinner_stop(GTK_SPINNER(priv->spinner)); > remote_viewer_iso_list_dialog_show_error(self, msg); > gtk_dialog_set_response_sensitive(GTK_DIALOG(self), > GTK_RESPONSE_NONE, TRUE); > g_free(markup); > -g_clear_error(&error); > -return; > +goto end; > } > > +g_clear_object(&priv->cancellable); > g_list_foreach(iso_list, (GFunc) remote_viewer_iso_list_dialog_foreach, > self); > remote_viewer_iso_list_dialog_show_files(self); > + > +end: > +g_clear_error(&error); > } > > > @@ -177,7 +187,10 @@ > remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDialog > *self) > RemoteViewerISOListDialogPrivate *priv = self->priv; > > gtk_list_store_clear(priv->list_store); > -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, NULL, > + > +priv->cancellable = g_cancellable_new(); > +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, > + priv->cancellable, > (GAsyncReadyCallback) > fetch_iso_names_cb, > self); > } > @@ -190,8 +203,10 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, > RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); > RemoteViewerISOListDialogPrivate *priv = self->priv; > > -if (response_id != GTK_RESPONSE_NONE) > +if (response_id != GTK_RESPONSE_NONE) { > +g_cancellable_cancel(priv->cancellable); > return; > +} > > gtk_spinner_start(GTK_SPINNER(priv->spinner)); > gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); > @@ -223,7 +238,9 @@ > remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer > G_GNU > gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, > FALSE); > gtk_widget_set_sensitive(priv->tree_view, FALSE); > > -ovirt_foreign_menu_set_current_iso_name_async(priv->foreign_menu, active > ? NULL : na
[virt-tools-list] [PATCH virt-viewer v2] session-spice: Pass hostname to authentication dialog
With this patch the dialog now shows the host we are connecting to. Signed-off-by: Eduardo Lima (Etrunko) --- v2: Use proper uri if connecting via proxy. --- src/virt-viewer-session-spice.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c index c3fce48..9b52ec0 100644 --- a/src/virt-viewer-session-spice.c +++ b/src/virt-viewer-session-spice.c @@ -691,6 +691,7 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, case SPICE_CHANNEL_ERROR_AUTH: { const GError *error = NULL; +gchar *host = NULL; g_debug("main channel: auth failure (wrong username/password?)"); { @@ -717,11 +718,13 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, user = g_strdup(g_get_user_name()); } +g_object_get(self->priv->session, "host", &host, NULL); ret = virt_viewer_auth_collect_credentials(self->priv->main_window, "SPICE", - NULL, + host, username_required ? &user : NULL, &password); +g_free(host); if (!ret) { g_signal_emit_by_name(session, "session-cancelled"); } else { @@ -750,7 +753,7 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, g_warn_if_fail(proxy != NULL); ret = virt_viewer_auth_collect_credentials(self->priv->main_window, - "proxy", NULL, + "proxy", spice_uri_get_hostname(proxy), &user, &password); if (!ret) { g_signal_emit_by_name(session, "session-cancelled"); -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 07/10] about-dialog: Use GtkHeaderBar
For this one, we use the application version as the subtitle. Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer-about.ui | 20 ++-- src/virt-viewer-window.c | 9 ++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/resources/ui/virt-viewer-about.ui b/src/resources/ui/virt-viewer-about.ui index 28e38c8..a742ba8 100644 --- a/src/resources/ui/virt-viewer-about.ui +++ b/src/resources/ui/virt-viewer-about.ui @@ -1,10 +1,10 @@ + - + False -5 -About Virt-Viewer +6 False True center-on-parent @@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Marc-André Lureau The Fedora Translation Team +image-missing @@ -57,10 +58,17 @@ Marc-André Lureau 0 - - - + +True +False +About Virtual Machine Viewer +True +:close + + + + diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index c75e75b..f7a7560 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -1034,14 +1034,17 @@ virt_viewer_window_menu_help_about(GtkWidget *menu G_GNUC_UNUSED, VirtViewerWindow *self) { GtkBuilder *about; -GtkWidget *dialog; +GtkWidget *dialog, *headerbar; GdkPixbuf *icon; +gchar *version = g_strdup_printf("%s %s %s", _("Version"), VERSION, BUILDID); about = virt_viewer_util_load_ui("virt-viewer-about.ui"); dialog = GTK_WIDGET(gtk_builder_get_object(about, "about")); - -gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), VERSION BUILDID); +headerbar = GTK_WIDGET(gtk_builder_get_object(about, "headerbar")); +gtk_window_set_titlebar(GTK_WINDOW(dialog), headerbar); +gtk_header_bar_set_subtitle(GTK_HEADER_BAR(headerbar), version); +g_free(version); icon = gdk_pixbuf_new_from_resource(VIRT_VIEWER_RESOURCE_PREFIX"/icons/48x48/virt-viewer.png", NULL); if (icon != NULL) { -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 00/10] Make dialogs use GtkHeaderBar
This whole series is the result of the initial idea of having the new iso-dialog to use this widget. Having it done only for the iso-dialog would not make much sense, so I went on and ported all other dialogs. The widget requires Gtk version 3.12, which should not be a problem for any recent distro. Using GtkHeaderBar makes dialogs look cleaner and more 'modern', also follow the style used by GNOME applications. In the near future, virt-viewer main window could also make use of it, as we recently saw in a series sent to this mailing list. Eduardo Lima (Etrunko) (10): Update Gtk+ requirements to 3.12 iso-dialog: Use GtkHeaderBar guest-details-dialog: Use GtkHeaderBar virt-viewer-vm-connection: Use GtkHeaderBar remote-viewer-connect: Use GtkHeaderBar virt-viewer-preferences: Use GtkHeaderBar about-dialog: Use GtkHeaderBar virt-viewer-auth: Use GtkHeaderBar file-transfer-dialog: Use GtkHeaderBar usb_device_selection: Use GtkHeaderBar configure.ac | 4 +- src/remote-viewer-connect.c| 20 +-- src/remote-viewer-iso-list-dialog.c| 32 +++- src/resources/ui/remote-viewer-connect.ui | 173 ++--- src/resources/ui/remote-viewer-iso-list.ui | 87 --- src/resources/ui/virt-viewer-about.ui | 20 ++- src/resources/ui/virt-viewer-auth.ui | 148 -- .../ui/virt-viewer-file-transfer-dialog.ui | 72 +++-- src/resources/ui/virt-viewer-guest-details.ui | 64 src/resources/ui/virt-viewer-preferences.ui| 103 ++-- src/resources/ui/virt-viewer-vm-connection.ui | 83 -- src/virt-viewer-app.c | 38 +++-- src/virt-viewer-auth.c | 35 +++-- src/virt-viewer-file-transfer-dialog.c | 59 +++ src/virt-viewer-session-spice.c| 20 ++- src/virt-viewer-vm-connection.c| 15 +- src/virt-viewer-window.c | 21 ++- 17 files changed, 437 insertions(+), 557 deletions(-) -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 03/10] guest-details-dialog: Use GtkHeaderBar
This is the simplest dialog on the application, there was not much to change here. In order to not leave a big amount of unused space on the HeaderBar, we set the guest name as the subtitle. Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer-guest-details.ui | 64 +++ src/virt-viewer-window.c | 12 ++--- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/resources/ui/virt-viewer-guest-details.ui b/src/resources/ui/virt-viewer-guest-details.ui index 209272f..7522049 100644 --- a/src/resources/ui/virt-viewer-guest-details.ui +++ b/src/resources/ui/virt-viewer-guest-details.ui @@ -1,11 +1,11 @@ - + - + False +12 Guest Details -True 400 dialog @@ -13,24 +13,13 @@ False vertical -2 +6 False end - -_Close -True -True -True -True - - -False -True -0 - + @@ -41,80 +30,81 @@ - + True False -6 6 6 -2 True False +<b>Name:</b> +True 1 -Name: -GTK_SHRINK | GTK_FILL -GTK_FILL +0 +0 True False +<b>GUID:</b> +True 1 -GUID: +0 1 -2 -GTK_SHRINK | GTK_FILL -GTK_FILL True False -0 label True +0 1 -2 -GTK_FILL +0 True False -0 label True +0 1 -2 1 -2 -GTK_FILL False True -1 +0 - - button1 - + + +True +False +Guest Details +True +:close + + + diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 8eda12e..c75e75b 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -986,16 +986,17 @@ virt_viewer_window_menu_help_guest_details(GtkWidget *menu G_GNUC_UNUSED, VirtViewerWindow *self) { GtkBuilder *ui = virt_viewer_util_load_ui("virt-viewer-guest-details.ui"); +GtkWidget *dialog, *headerbar, *namelabel, *guidlabel; char *name = NULL; char *uuid = NULL; g_return_if_fail(ui != NULL); -GtkWidget *dialog = GTK_WIDGET(gtk_builder_get_object(ui, "guestdetailsdialog")); -GtkWidget *namelabel = GTK_WIDGET(gtk_builder_get_object(ui, "namevaluelabel")); -GtkWidget *guidlabel = GTK_WIDGET(gtk_builder_get_object(ui, "guidvaluelabel")); - -g_return_if_fail(dialog && namelabel && guidlabel); +dialog = GTK_WIDGET(gtk_builder_get_object(ui, "guestdetailsdialog")); +headerbar = GTK_WIDGET(gtk_builder_get_object(ui, "headerbar")); +gtk_window_set_titlebar(GTK_WINDOW(dialog), headerbar); +namelabel = GTK_WIDGET(gtk_builder_get_object(ui, "namevaluelabel")); +guidlabel = GTK_WIDGET(gtk_builder_get_object(ui, "guidvaluelabel")); g_object_get(self->priv->app, "guest-name", &name, "uuid", &uuid, NULL); @@ -1003,6 +1004,7 @@ virt_viewer_window_menu_help_guest_details(GtkWidget *menu G_GNUC_UNUSED, name = g_strdup(_("Unknown")); if (!uuid || *uuid == '\0') uuid = g_strdup(_("Unknown")); +gtk_header_bar_set_subtitle(GTK_HEADER_BAR(headerbar), name); gtk_label_set_text(GTK_LABEL(namelabel), name); gtk_label_set_text(GTK_LABEL(guidlabel), uuid); g_free(name); -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer-connect: Use GtkHeaderBar
Just like the virt-viewer-connect dialog, the connect button has been moved to the header bar. Additionally, the example text is now presented as the subtitle. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer-connect.c | 20 +--- src/resources/ui/remote-viewer-connect.ui | 173 +- 2 files changed, 54 insertions(+), 139 deletions(-) diff --git a/src/remote-viewer-connect.c b/src/remote-viewer-connect.c index 2fbc5ff..f3ac468 100644 --- a/src/remote-viewer-connect.c +++ b/src/remote-viewer-connect.c @@ -152,15 +152,6 @@ recent_item_activated_dialog_cb(GtkRecentChooser *chooser G_GNUC_UNUSED, gpointe shutdown_loop(ci->loop); } -static void -make_label_small(GtkLabel* label) -{ -PangoAttrList* attributes = pango_attr_list_new(); -pango_attr_list_insert(attributes, pango_attr_scale_new(0.9)); -gtk_label_set_attributes(label, attributes); -pango_attr_list_unref(attributes); -} - /** * remote_viewer_connect_dialog * @@ -174,7 +165,7 @@ make_label_small(GtkLabel* label) gboolean remote_viewer_connect_dialog(gchar **uri) { -GtkWidget *window, *label, *entry, *recent, *connect_button, *cancel_button; +GtkWidget *window, *header, *entry, *recent, *connect_button; GtkRecentFilter *rfilter; GtkBuilder *builder; gboolean active; @@ -192,13 +183,11 @@ remote_viewer_connect_dialog(gchar **uri) g_return_val_if_fail(builder != NULL, GTK_RESPONSE_NONE); window = GTK_WIDGET(gtk_builder_get_object(builder, "remote-viewer-connection-window")); +header = GTK_WIDGET(gtk_builder_get_object(builder, "headerbar")); +gtk_window_set_titlebar(GTK_WINDOW(window), header); connect_button = GTK_WIDGET(gtk_builder_get_object(builder, "connect-button")); -cancel_button = GTK_WIDGET(gtk_builder_get_object(builder, "cancel-button")); -label = GTK_WIDGET(gtk_builder_get_object(builder, "example-label")); entry = ci.entry = GTK_WIDGET(gtk_builder_get_object(builder, "connection-address-entry")); -make_label_small(GTK_LABEL(label)); - active = (gtk_entry_get_text_length(GTK_ENTRY(ci.entry)) > 0); gtk_widget_set_sensitive(GTK_WIDGET(connect_button), active); @@ -216,9 +205,6 @@ remote_viewer_connect_dialog(gchar **uri) g_signal_connect(connect_button, "clicked", G_CALLBACK(connect_button_clicked_cb), &ci); -/* make sure that user_data is passed as first parameter */ -g_signal_connect_swapped(cancel_button, "clicked", - G_CALLBACK(window_deleted_cb), &ci); g_signal_connect_swapped(window, "delete-event", G_CALLBACK(window_deleted_cb), &ci); diff --git a/src/resources/ui/remote-viewer-connect.ui b/src/resources/ui/remote-viewer-connect.ui index 308d121..89d17fd 100644 --- a/src/resources/ui/remote-viewer-connect.ui +++ b/src/resources/ui/remote-viewer-connect.ui @@ -1,63 +1,48 @@ - + + + +True +False +gtk-connect + + +True +False +Connection Details +For example, spice://foo.example.org:5900 +True +menu:close + + +True +True +True +Connect +image1 +True + + +end + + + +12 False -Connection details +12 +remote-viewer - + True False -10 -20 +vertical +6 - + True -False -6 - - -True -False -0 -Connection _Address -True -connection-address-entry - - - - - -False -True -0 - - - - -True -True - - -False -True -1 - - - - -True -False -0 -False -For example, spice://foo.example.org:5900 - - -False -True -2 - - +True False @@ -66,88 +51,32 @@ - + True False -6 - - -True -False -Recent connections -0 - - - - - -False -
[virt-tools-list] [PATCH virt-viewer 04/10] virt-viewer-vm-connection: Use GtkHeaderBar
Here we moved the connect button to the header bar. Unfortunately, I could not find a "connect-symbolic" icon to be used here, so I ended up with the stock icon. Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer-vm-connection.ui | 83 +-- src/virt-viewer-vm-connection.c | 15 - 2 files changed, 40 insertions(+), 58 deletions(-) diff --git a/src/resources/ui/virt-viewer-vm-connection.ui b/src/resources/ui/virt-viewer-vm-connection.ui index f190c92..cb58701 100644 --- a/src/resources/ui/virt-viewer-vm-connection.ui +++ b/src/resources/ui/virt-viewer-vm-connection.ui @@ -1,6 +1,32 @@ - + + + +True +False +gtk-connect + + +True +False +Choose a virtual machine +True +menu:close + + +True +True +True +Connect +image1 +True + + +end + + + False 5 @@ -19,36 +45,6 @@ False end - - - _Cancel -True -True -True -True - - -False -True -0 - - - - -C_onnect -True -True -True -True -True -True - - -False -True -1 - - False @@ -86,32 +82,7 @@ 1 - - -True -False -0 -0 -4 -Available virtual machines -end -26 - - - - - -False -True -end -2 - - - - button-cancel - button-connect - diff --git a/src/virt-viewer-vm-connection.c b/src/virt-viewer-vm-connection.c index ebaa92b..0363b84 100644 --- a/src/virt-viewer-vm-connection.c +++ b/src/virt-viewer-vm-connection.c @@ -32,7 +32,7 @@ treeview_row_activated_cb(GtkTreeView *treeview G_GNUC_UNUSED, GtkTreeViewColumn *col G_GNUC_UNUSED, gpointer userdata) { -gtk_widget_activate(GTK_WIDGET(userdata)); +gtk_button_clicked(GTK_BUTTON(userdata)); } static void @@ -42,13 +42,20 @@ treeselection_changed_cb(GtkTreeSelection *selection, gpointer userdata) gtk_tree_selection_count_selected_rows(selection) == 1); } +static void +button_connect_clicked_cb(GtkButton *button G_GNUC_UNUSED, + GtkDialog *dialog) +{ +gtk_dialog_response(dialog, GTK_RESPONSE_ACCEPT); +} + gchar* virt_viewer_vm_connection_choose_name_dialog(GtkWindow *main_window, GtkTreeModel *model, GError **error) { GtkBuilder *vm_connection; -GtkWidget *dialog; +GtkWidget *dialog, *headerbar; GtkButton *button_connect; GtkTreeView *treeview; GtkTreeSelection *selection; @@ -69,12 +76,16 @@ virt_viewer_vm_connection_choose_name_dialog(GtkWindow *main_window, g_return_val_if_fail(vm_connection != NULL, NULL); dialog = GTK_WIDGET(gtk_builder_get_object(vm_connection, "vm-connection-dialog")); +headerbar = GTK_WIDGET(gtk_builder_get_object(vm_connection, "headerbar")); +gtk_window_set_titlebar(GTK_WINDOW(dialog), headerbar); gtk_window_set_transient_for(GTK_WINDOW(dialog), main_window); button_connect = GTK_BUTTON(gtk_builder_get_object(vm_connection, "button-connect")); treeview = GTK_TREE_VIEW(gtk_builder_get_object(vm_connection, "treeview")); selection = GTK_TREE_SELECTION(gtk_builder_get_object(vm_connection, "treeview-selection")); gtk_tree_view_set_model(treeview, model); +g_signal_connect(button_connect, "clicked", + G_CALLBACK(button_connect_clicked_cb), dialog); g_signal_connect(treeview, "row-activated", G_CALLBACK(treeview_row_activated_cb), button_connect); g_signal_connect(selection, "changed", -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 01/10] Update Gtk+ requirements to 3.12
This is new version ships with GtkHeaderBar code, which we will require for the dialogs on the application. In the future the main window could also make use of this widget, following the style of other applications. Signed-off-by: Eduardo Lima (Etrunko) --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 69e3708..d5eb258 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38" GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" # Keep these two definitions in agreement. -GTK_REQUIRED="3.10" -GTK_ENCODED_VERSION="GDK_VERSION_3_10" +GTK_REQUIRED="3.12" +GTK_ENCODED_VERSION="GDK_VERSION_3_12" LIBXML2_REQUIRED="2.6.0" LIBVIRT_REQUIRED="0.10.0" -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 02/10] iso-dialog: Use GtkHeaderBar
We now display the current ISO as subtitle on the HeaderBar. On the glade UI file, we get rid of the GtkAlignment object that was used to put some space between the tree view and dialog buttons. The "Select ISO" label is gone too. Signed-off-by: Eduardo Lima (Etrunko) --- src/remote-viewer-iso-list-dialog.c| 32 +-- src/resources/ui/remote-viewer-iso-list.ui | 87 +++--- 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c index ed51ffa..2110d70 100644 --- a/src/remote-viewer-iso-list-dialog.c +++ b/src/remote-viewer-iso-list-dialog.c @@ -36,6 +36,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE struct _RemoteViewerISOListDialogPrivate { +GtkHeaderBar *header_bar; GtkListStore *list_store; GtkWidget *status; GtkWidget *spinner; @@ -121,6 +122,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self) } static void +remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name) +{ +RemoteViewerISOListDialogPrivate *priv = self->priv; +gchar *subtitle = NULL; + +if (iso_name && strlen(iso_name) != 0) +subtitle = g_strdup_printf(_("Current: %s"), iso_name); + +gtk_header_bar_set_subtitle(priv->header_bar, subtitle); +g_free(subtitle); +} + +static void remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self) { RemoteViewerISOListDialogPrivate *priv = self->priv; @@ -140,6 +154,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); } g_free(current_iso); @@ -210,6 +225,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog, gtk_spinner_start(GTK_SPINNER(priv->spinner)); gtk_label_set_markup(GTK_LABEL(priv->status), _("Loading...")); +remote_viewer_iso_list_dialog_set_subtitle(self, NULL); gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status", GTK_STACK_TRANSITION_TYPE_NONE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); @@ -265,9 +281,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self); GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui"); GtkCellRendererToggle *cell_renderer; +GtkWidget *button, *image; gtk_builder_connect_signals(builder, self); +priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self))); +gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE); + priv->status = GTK_WIDGET(gtk_builder_get_object(builder, "status")); priv->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner")); priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack")); @@ -281,12 +301,12 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self) g_object_unref(builder); -gtk_dialog_add_buttons(GTK_DIALOG(self), - _("Refresh"), GTK_RESPONSE_NONE, - _("Close"), GTK_RESPONSE_CLOSE, - NULL); +button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE); +image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON); +gtk_button_set_image(GTK_BUTTON(button), image); +gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE); +gtk_widget_set_tooltip_text(button, _("Refresh")); -gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE); g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL); } @@ -360,6 +380,7 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu, g_free(name); } while (gtk_tree_model_iter_next(model, &iter)); +remote_viewer_iso_list_dialog_set_subtitle(self, current_iso); gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE); gtk_widget_set_sensitive(priv->tree_view, TRUE); g_free(current_iso); @@ -382,6 +403,7 @@ remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu) "border-width", 18, &quo
[virt-tools-list] [PATCH virt-viewer 06/10] virt-viewer-preferences: Use GtkHeaderBar
This dialog changed very little when compared to the old version. I did change the way widgets are organized within the dialog, as it now groups the file selector together with the read-only checkbox. Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer-preferences.ui | 103 src/virt-viewer-app.c | 38 ++ 2 files changed, 82 insertions(+), 59 deletions(-) diff --git a/src/resources/ui/virt-viewer-preferences.ui b/src/resources/ui/virt-viewer-preferences.ui index f9738c5..c110335 100644 --- a/src/resources/ui/virt-viewer-preferences.ui +++ b/src/resources/ui/virt-viewer-preferences.ui @@ -1,28 +1,33 @@ + - - + + +True +False +Preferences +True +:close + + + + False -5 +6 Preferences normal - + True False +vertical - + True False end - - - - - - True @@ -31,88 +36,96 @@ - + True True +0 - + True False -18 +12 +vertical 6 True False -0 -Folder sharing - - - +start +<b>Folder sharing</b> +True +True False -False +True 0 - + True False -6 -2 -2 -12 6 - - -Share folder -True -True -False -True - - - - - +6 Read-only True True False +start True -2 +1 1 -2 True False +4 +True select-folder 1 -2 +0 + + +Share Folder: +True +True +False +start +True + + +0 +0 + + + + + -False -False -1 +True +True +3 + +True + - + True False Spice @@ -125,7 +138,7 @@ True True -1 +0 diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index 2e7e193..0d2d33b 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -2475,43 +2475,53 @@ static GtkWidget * virt_viewer_app_get_preferences(VirtViewerApp *self) { VirtViewerSession *session = virt_viewer_app_get_session(self); -GtkBuilder *builder = virt_viewer_util_load_ui("virt-viewer-preferences.ui"); gboolean can_share_folder = virt_viewer_session_can_share_folder(session); -GtkWidget *preferences = self->priv->preferences; +GtkWidget *headerbar, *check, *chooser, *readonly
[virt-tools-list] [PATCH virt-viewer 10/10] usb_device_selection: Use GtkHeaderBar
We could get rid of the auxiliary text and present it as the subtitle of the dialog, but this is handled by the widget itself. In this case, all we have to do is to set the "use-headerbar" property, and like other dialogs, the close button is not necessary anymore. Signed-off-by: Eduardo Lima (Etrunko) --- src/virt-viewer-session-spice.c | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c index 9b52ec0..8177bcb 100644 --- a/src/virt-viewer-session-spice.c +++ b/src/virt-viewer-session-spice.c @@ -794,16 +794,20 @@ virt_viewer_session_spice_usb_device_selection(VirtViewerSession *session, { VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session); VirtViewerSessionSpicePrivate *priv = self->priv; -GtkWidget *dialog, *area, *usb_device_widget; +GtkWidget *dialog, *area, *usb_device_widget, *headerbar; /* Create the widgets */ -dialog = gtk_dialog_new_with_buttons(_("Select USB devices for redirection"), parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - _("_Close"), GTK_RESPONSE_ACCEPT, - NULL); -gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); -gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); -gtk_box_set_spacing(GTK_BOX(gtk_bin_get_child(GTK_BIN(dialog))), 12); +dialog = g_object_new(GTK_TYPE_DIALOG, + "title", _("Select USB devices for redirection"), + "transient-for", parent, + "use-header-bar", TRUE, + "border-width", 12, + "content-area-spacing", 12, + NULL); + +headerbar = gtk_dialog_get_header_bar(GTK_DIALOG(dialog)); +gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(headerbar), TRUE); +gtk_header_bar_set_decoration_layout(GTK_HEADER_BAR(headerbar), ":close"); area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); -- 2.9.3 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 09/10] file-transfer-dialog: Use GtkHeaderBar
This dialog now presents the progress as a level bar, and also shows the percentage as on the text. The cancel button is not necessary anymore, because the all transfers are cancelled automatically when the dialog is closed before they finish. Signed-off-by: Eduardo Lima (Etrunko) --- .../ui/virt-viewer-file-transfer-dialog.ui | 72 +++--- src/virt-viewer-file-transfer-dialog.c | 59 -- 2 files changed, 48 insertions(+), 83 deletions(-) diff --git a/src/resources/ui/virt-viewer-file-transfer-dialog.ui b/src/resources/ui/virt-viewer-file-transfer-dialog.ui index 5e761c8..db46aea 100644 --- a/src/resources/ui/virt-viewer-file-transfer-dialog.ui +++ b/src/resources/ui/virt-viewer-file-transfer-dialog.ui @@ -1,22 +1,20 @@ + - - + -400 False -5 +12 +400 dialog -vertical True False -12 -12 +vertical +6 -horizontal True False end @@ -24,55 +22,34 @@ - -gtk-cancel -True -True -True -True - - -False -False -1 - + True True +3 + + + + +True +False +label +True + + +True +True 0 - -vertical + +20 True False -12 - - -True -False -label - - -True -True -0 - - - - -True -False - - -True -True -1 - - +0.149997764826 True @@ -82,8 +59,5 @@ - - button1 - diff --git a/src/virt-viewer-file-transfer-dialog.c b/src/virt-viewer-file-transfer-dialog.c index 07d25a7..62141c1 100644 --- a/src/virt-viewer-file-transfer-dialog.c +++ b/src/virt-viewer-file-transfer-dialog.c @@ -31,7 +31,7 @@ struct _VirtViewerFileTransferDialogPrivate guint timer_show_src; guint timer_hide_src; GtkWidget *transfer_summary; -GtkWidget *progressbar; +GtkWidget *levelbar; }; G_DEFINE_TYPE_WITH_PRIVATE(VirtViewerFileTransferDialog, virt_viewer_file_transfer_dialog, GTK_TYPE_DIALOG) @@ -66,52 +66,40 @@ virt_viewer_file_transfer_dialog_class_init(VirtViewerFileTransferDialogClass *k transfer_summary); gtk_widget_class_bind_template_child_private(widget_class, VirtViewerFileTransferDialog, - progressbar); + levelbar); object_class->dispose = virt_viewer_file_transfer_dialog_dispose; } -static void -dialog_response(GtkDialog *dialog, -gint response_id, -gpointer user_data G_GNUC_UNUSED) -{ -VirtViewerFileTransferDialog *self = VIRT_VIEWER_FILE_TRANSFER_DIALOG(dialog); -GSList *slist; - -switch (response_id) { -case GTK_RESPONSE_CANCEL: -/* cancel all current tasks */ -for (slist = self->priv->file_transfers; slist != NULL; slist = g_slist_next(slist)) { - spice_file_transfer_task_cancel(SPICE_FILE_TRANSFER_TASK(slist->data)); -} -break; -case GTK_RESPONSE_DELETE_EVENT: -/* silently ignore */ -break; -default: -g_warn_if_reached(); -} -} - static gboolean delete_event(GtkWidget *widget, GdkEvent *event G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED) { -/* don't allow window to be deleted, just process the response signal, - * which may result in the window being hidden */ -gtk_dialog_response(GTK_DIALOG(widget), GTK_RESPONSE_CANCEL); +VirtViewerFileTransferDialog *self = VIRT_VIEWER_FILE_TRANSFER_DIALOG(widget); +GSList *slist; +for (slist = self->priv->file_transfers; slist != NULL; slist = g_slist_next(slist)) { +spice_file_transfer_task_cancel(SPICE_FILE_TRANSFER_TASK(slist->data)); +} return TRUE; } static void virt_viewer_file_transfer_dialog_init(VirtViewerFileTransferDialog *self) {
[virt-tools-list] [PATCH virt-viewer 08/10] virt-viewer-auth: Use GtkHeaderBar
The auxiliary text is now presented as the subtitle of the dialog Signed-off-by: Eduardo Lima (Etrunko) --- src/resources/ui/virt-viewer-auth.ui | 148 --- src/virt-viewer-auth.c | 35 + 2 files changed, 86 insertions(+), 97 deletions(-) diff --git a/src/resources/ui/virt-viewer-auth.ui b/src/resources/ui/virt-viewer-auth.ui index 2920780..367678d 100644 --- a/src/resources/ui/virt-viewer-auth.ui +++ b/src/resources/ui/virt-viewer-auth.ui @@ -1,160 +1,146 @@ + - + +350 +1 False -5 -Authentication required -True -center-on-parent -True +12 dialog -True -True - -True + False vertical 2 - -True + False end - -_Cancel -True -True -True -False -True - - -False -False -0 - + - -_OK -True -True -True -True -True -False -True - - -False -False -3 - + False -True -end -0 - - - - -True -False -0 -0 -label -True - - -False -True +False 1 - + True False -2 -2 -6 +True 6 +6 - + True False -1 -Password: +end +Username: -1 -2 +0 +0 - + True False -1 -Username: +end +Password: + +0 +1 + True True +4 +True + 1 -2 +0 True True +4 +True False True + 1 -2 1 -2 +Show password True True -False -Show password +False +True + 1 -2 2 -3 + + + False True -2 +0 - - button-cancel - button-ok - + + +True +False +emblem-ok-symbolic + + +True +False +Authentication required +True +:close + + +True +True +True +True +True +image1 +True + + + +end + + diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c index 67c770c..73cc707 100644 --- a/src/virt-viewer-auth.c +++ b/src/virt-viewer-auth.c @@ -33,13 +33,23 @@ #include "virt-viewer-auth.h" #include "virt-viewer-util.h" -static void +void show_password(GtkCheckButton *check_button G_GNUC_UNUSED, GtkEntry *entry); +void button_ok_clicked(GtkButton *button G_GNUC_UNUSED, GtkDialog *dialog); + +void show_password(GtkCheckButton *check_button G_GNUC_UNUSED, GtkEntry *entry) { gtk_entry_set_visibility(entry, !gtk_entry_get_visibility(entry)); } +void +button_ok_clicked(GtkButton *button G_GNUC_UNUSED, + GtkDialog *dialog) +{ +gtk_dialog_response(dialog, GTK_RESPONSE_OK); +} + /* NOTE: if username is provided, and *username is non-NULL, the user input * field will be pre-filled with this value. The existing
Re: [virt-tools-list] [PATCH virt-viewer v2] iso-dialog: Avoid crash when closing dialog early
On 09/02/17 17:19, Pavel Grunt wrote: > Hi Eduardo, > > On Thu, 2017-02-09 at 15:13 -0200, Eduardo Lima (Etrunko) wrote: >> We must take into account that users can close the dialog at >> anytime, >> even during an operation of fetch or set ISO has not been finished. >> This >> will cause the callbacks for those operations to be invoked with an >> invalid object, crashing the application. >> >> To fix this issue we need to pass a GCancellable to the asynchronous >> operations, so they can be cancelled if the dialog happens to get >> closed >> before they complete. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> --- >> v2: >> * Move call to g_cancellable_cancel() to response handler. >> * Don't leak error objects if operation is cancelled. >> --- >> src/remote-viewer-iso-list-dialog.c | 42 >> ++--- >> 1 file changed, 34 insertions(+), 8 deletions(-) >> >> diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote- >> viewer-iso-list-dialog.c >> index 2ab5435..ed51ffa 100644 >> --- a/src/remote-viewer-iso-list-dialog.c >> +++ b/src/remote-viewer-iso-list-dialog.c >> @@ -42,6 +42,7 @@ struct _RemoteViewerISOListDialogPrivate >> GtkWidget *stack; >> GtkWidget *tree_view; >> OvirtForeignMenu *foreign_menu; >> +GCancellable *cancellable; >> }; >> >> enum RemoteViewerISOListDialogModel >> @@ -66,6 +67,8 @@ remote_viewer_iso_list_dialog_dispose(GObject >> *object) >> RemoteViewerISOListDialog *self = >> REMOTE_VIEWER_ISO_LIST_DIALOG(object); >> RemoteViewerISOListDialogPrivate *priv = self->priv; >> >> +g_clear_object(&priv->cancellable); >> + >> if (priv->foreign_menu) { >> g_signal_handlers_disconnect_by_data(priv->foreign_menu, >> object); >> g_clear_object(&priv->foreign_menu); >> @@ -157,17 +160,24 @@ fetch_iso_names_cb(OvirtForeignMenu >> *foreign_menu, >> const gchar *msg = error ? error->message : _("Failed to >> fetch CD names"); >> gchar *markup = g_strdup_printf("%s", msg); >> >> +g_debug("Error fetching ISO names: %s", msg); >> +if (error && error->code == G_IO_ERROR_CANCELLED) > use g_error_matches if possible > >> +goto end; >> + >> gtk_label_set_markup(GTK_LABEL(priv->status), markup); >> gtk_spinner_stop(GTK_SPINNER(priv->spinner)); >> remote_viewer_iso_list_dialog_show_error(self, msg); >> gtk_dialog_set_response_sensitive(GTK_DIALOG(self), >> GTK_RESPONSE_NONE, TRUE); >> g_free(markup); >> -g_clear_error(&error); >> -return; >> +goto end; >> } >> >> +g_clear_object(&priv->cancellable); >> g_list_foreach(iso_list, (GFunc) >> remote_viewer_iso_list_dialog_foreach, self); >> remote_viewer_iso_list_dialog_show_files(self); >> + >> +end: >> +g_clear_error(&error); >> } >> >> >> @@ -177,7 +187,10 @@ >> remote_viewer_iso_list_dialog_refresh_iso_list(RemoteViewerISOListDi >> alog *self) >> RemoteViewerISOListDialogPrivate *priv = self->priv; >> >> gtk_list_store_clear(priv->list_store); >> -ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, >> NULL, >> + >> +priv->cancellable = g_cancellable_new(); >> +ovirt_foreign_menu_fetch_iso_names_async(priv->foreign_menu, >> + priv->cancellable, >> (GAsyncReadyCallback) >> fetch_iso_names_cb, >> self); >> } >> @@ -190,8 +203,10 @@ >> remote_viewer_iso_list_dialog_response(GtkDialog *dialog, >> RemoteViewerISOListDialog *self = >> REMOTE_VIEWER_ISO_LIST_DIALOG(dialog); >> RemoteViewerISOListDialogPrivate *priv = self->priv; >> >> -if (response_id != GTK_RESPONSE_NONE) >> +if (response_id != GTK_RESPONSE_NONE) { >> +g_cancellable_cancel(priv->cancellable); >> return; >> +} >> >> gtk_spinner_start(GTK_SPINNER(priv->spinner)); >> gtk_label_set_markup(GTK_LABEL(priv->status), >> _("Loading...")); >> @@ -223,7 +238,9 @@ >> remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle >> *cell_renderer
Re: [virt-tools-list] [PATCH virt-viewer v2] session-spice: Pass hostname to authentication dialog
On 09/02/17 17:22, Pavel Grunt wrote: > On Thu, 2017-02-09 at 15:32 -0200, Eduardo Lima (Etrunko) wrote: >> With this patch the dialog now shows the host we are connecting to. >> >> Signed-off-by: Eduardo Lima (Etrunko) > Acked-by: Pavel Grunt Thanks, pushed. >> --- >> v2: Use proper uri if connecting via proxy. >> --- >> src/virt-viewer-session-spice.c | 7 +-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer- >> session-spice.c >> index c3fce48..9b52ec0 100644 >> --- a/src/virt-viewer-session-spice.c >> +++ b/src/virt-viewer-session-spice.c >> @@ -691,6 +691,7 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> case SPICE_CHANNEL_ERROR_AUTH: >> { >> const GError *error = NULL; >> +gchar *host = NULL; >> g_debug("main channel: auth failure (wrong >> username/password?)"); >> >> { >> @@ -717,11 +718,13 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> user = g_strdup(g_get_user_name()); >> } >> >> +g_object_get(self->priv->session, "host", &host, NULL); >> ret = virt_viewer_auth_collect_credentials(self->priv- >>> main_window, >> "SPICE", >> - NULL, >> + host, >> username_require >> d ? &user : NULL, >> &password); >> +g_free(host); >> if (!ret) { >> g_signal_emit_by_name(session, "session-cancelled"); >> } else { >> @@ -750,7 +753,7 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> g_warn_if_fail(proxy != NULL); >> >> ret = virt_viewer_auth_collect_credentials(self->priv- >>> main_window, >> - "proxy", >> NULL, >> + "proxy", >> spice_uri_get_hostname(proxy), >> &user, >> &password); >> if (!ret) { >> g_signal_emit_by_name(session, "session- >> cancelled"); -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer updated PATCH] Show errors generated by connection dialog
On 09/02/17 10:00, Christophe de Dinechin wrote: > When running 'remote-viewer' without arguments, > and selecting a non-supported protocol, e.g. ssh://foo, > the generated error was silently swallowed by the retry loop. > This was introduced in 06b2c382468876a19600374bd59475e66d488af8. > --- > src/remote-viewer.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/remote-viewer.c b/src/remote-viewer.c > index 13c6e7c..e4b0909 100644 > --- a/src/remote-viewer.c > +++ b/src/remote-viewer.c > @@ -1196,6 +1196,9 @@ cleanup: > type = NULL; > > if (!ret && priv->open_recent_dialog) { > +if (error != NULL) { > +virt_viewer_app_simple_message_dialog(app, _("Unable to connect: > %s"), error->message); > +} > g_clear_error(&error); > goto retry_dialog; > } > Sorry for starting this endless discussion about checking for error->message, it has been shown that it is not necessary (TIL). As this version addresses the comments of explicit checking, from Pavel, it's an Ack. Acked-by: Eduardo Lima (Etrunko) -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 00/10] Make dialogs use GtkHeaderBar
On 16/02/17 10:06, Pavel Grunt wrote: > Hi, > > On Thu, 2017-02-09 at 17:22 -0200, Eduardo Lima (Etrunko) wrote: >> This whole series is the result of the initial idea of having the >> new >> iso-dialog to use this widget. Having it done only for the iso- >> dialog >> would not make much sense, so I went on and ported all other >> dialogs. >> The widget requires Gtk version 3.12, which should not be a problem >> for >> any recent distro. >> >> Using GtkHeaderBar makes dialogs look cleaner and more 'modern', >> also >> follow the style used by GNOME applications. In the near future, >> virt-viewer main window could also make use of it, as we recently >> saw in >> a series sent to this mailing list. > > so are we going for the GNOME style for all desktop envs ? In my > opinion it does not look nice in Windows and Xfce - simply does not > fit it in. iirc it was mentioned that there is a way to have both the > classic and the GNOME look in the discussion about Sagar's patches few > weeks ago.. I have no idea of what it looks like in Windows, but it indeed looks good in Linux environments. I tested in both GNOME and Enlightenment, not sure about other DEs out there. As far as I remember, the discussion on that other series was about the classic menu versus the buttons on the header bar. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 00/10] Make dialogs use GtkHeaderBar
On 16/02/17 20:57, Daniel P. Berrange wrote: > On Thu, Feb 16, 2017 at 11:05:13AM -0200, Eduardo Lima (Etrunko) wrote: >> On 16/02/17 10:06, Pavel Grunt wrote: >>> Hi, >>> >>> On Thu, 2017-02-09 at 17:22 -0200, Eduardo Lima (Etrunko) wrote: >>>> This whole series is the result of the initial idea of having the >>>> new >>>> iso-dialog to use this widget. Having it done only for the iso- >>>> dialog >>>> would not make much sense, so I went on and ported all other >>>> dialogs. >>>> The widget requires Gtk version 3.12, which should not be a problem >>>> for >>>> any recent distro. >>>> >>>> Using GtkHeaderBar makes dialogs look cleaner and more 'modern', >>>> also >>>> follow the style used by GNOME applications. In the near future, >>>> virt-viewer main window could also make use of it, as we recently >>>> saw in >>>> a series sent to this mailing list. >>> >>> so are we going for the GNOME style for all desktop envs ? In my >>> opinion it does not look nice in Windows and Xfce - simply does not >>> fit it in. iirc it was mentioned that there is a way to have both the >>> classic and the GNOME look in the discussion about Sagar's patches few >>> weeks ago.. >> >> I have no idea of what it looks like in Windows, but it indeed looks >> good in Linux environments. I tested in both GNOME and Enlightenment, >> not sure about other DEs out there. As far as I remember, the discussion >> on that other series was about the classic menu versus the buttons on >> the header bar. > > Please post some screenshots showing the before & after state of this > on GNOME, Linux non-GNOME and Windows, so we can accurately evaluate > what the change is. > > Also, I tried to apply this series to test it myself, but it fails to > apply to git master for some reason You can try my github remote, branch dialogs git remote add etrunko git://github.com/etrunko/virt-viewer -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 00/10] Make dialogs use GtkHeaderBar
On 16/02/17 20:57, Daniel P. Berrange wrote: > On Thu, Feb 16, 2017 at 11:05:13AM -0200, Eduardo Lima (Etrunko) wrote: >> On 16/02/17 10:06, Pavel Grunt wrote: >>> Hi, >>> >>> On Thu, 2017-02-09 at 17:22 -0200, Eduardo Lima (Etrunko) wrote: >>>> This whole series is the result of the initial idea of having the >>>> new >>>> iso-dialog to use this widget. Having it done only for the iso- >>>> dialog >>>> would not make much sense, so I went on and ported all other >>>> dialogs. >>>> The widget requires Gtk version 3.12, which should not be a problem >>>> for >>>> any recent distro. >>>> >>>> Using GtkHeaderBar makes dialogs look cleaner and more 'modern', >>>> also >>>> follow the style used by GNOME applications. In the near future, >>>> virt-viewer main window could also make use of it, as we recently >>>> saw in >>>> a series sent to this mailing list. >>> >>> so are we going for the GNOME style for all desktop envs ? In my >>> opinion it does not look nice in Windows and Xfce - simply does not >>> fit it in. iirc it was mentioned that there is a way to have both the >>> classic and the GNOME look in the discussion about Sagar's patches few >>> weeks ago.. >> >> I have no idea of what it looks like in Windows, but it indeed looks >> good in Linux environments. I tested in both GNOME and Enlightenment, >> not sure about other DEs out there. As far as I remember, the discussion >> on that other series was about the classic menu versus the buttons on >> the header bar. > > Please post some screenshots showing the before & after state of this > on GNOME, Linux non-GNOME and Windows, so we can accurately evaluate > what the change is. Okay, I have uploaded the screenshots of the dialogs to the following url: http://imgur.com/a/WHt8R I ran both before-series and after-series in GNOME and Enlightenment, all dialogs look exactly the same, except for the about dialog. By the way, I realized I should not mess with the About dialog, it does its own magic automatically. That one patch should be dropped. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 00/10] Make dialogs use GtkHeaderBar
On 22/02/17 08:15, Daniel P. Berrange wrote: > On Thu, Feb 16, 2017 at 10:57:52PM +, Daniel P. Berrange wrote: >> On Thu, Feb 16, 2017 at 11:05:13AM -0200, Eduardo Lima (Etrunko) wrote: >>> On 16/02/17 10:06, Pavel Grunt wrote: >>>> Hi, >>>> >>>> On Thu, 2017-02-09 at 17:22 -0200, Eduardo Lima (Etrunko) wrote: >>>>> This whole series is the result of the initial idea of having the >>>>> new >>>>> iso-dialog to use this widget. Having it done only for the iso- >>>>> dialog >>>>> would not make much sense, so I went on and ported all other >>>>> dialogs. >>>>> The widget requires Gtk version 3.12, which should not be a problem >>>>> for >>>>> any recent distro. >>>>> >>>>> Using GtkHeaderBar makes dialogs look cleaner and more 'modern', >>>>> also >>>>> follow the style used by GNOME applications. In the near future, >>>>> virt-viewer main window could also make use of it, as we recently >>>>> saw in >>>>> a series sent to this mailing list. >>>> >>>> so are we going for the GNOME style for all desktop envs ? In my >>>> opinion it does not look nice in Windows and Xfce - simply does not >>>> fit it in. iirc it was mentioned that there is a way to have both the >>>> classic and the GNOME look in the discussion about Sagar's patches few >>>> weeks ago.. >>> >>> I have no idea of what it looks like in Windows, but it indeed looks >>> good in Linux environments. I tested in both GNOME and Enlightenment, >>> not sure about other DEs out there. As far as I remember, the discussion >>> on that other series was about the classic menu versus the buttons on >>> the header bar. >> >> Please post some screenshots showing the before & after state of this >> on GNOME, Linux non-GNOME and Windows, so we can accurately evaluate >> what the change is. > > So I've just done some tests on TWM and Windows against > > https://github.com/etrunko/virt-viewer/tree/headerbar Ah, this branch does not have all the dialogs that are changed in this series. In fact this branch was one of the motivations of changing the dialogs in the first place. With the changes in the main application window, it would make sense to have the dialogs ported as well. If you want to try only this series, the branch is dialogs, on that same repository. > > The results are here: > > https://berrange.fedorapeople.org/virt-viewer-gtk-headerbar/win32/ > https://berrange.fedorapeople.org/virt-viewer-gtk-headerbar/twm/ > > On Win32 the key things are > > - The about & prefs dialog use the Win32 native style header > - The connect dialog & main window use the GNOME headerbar style > > > On TWM the key things are > > - The about & prefs dialog use the TWM native style header > - The connect dialog & main window use the TWM native style header >*and* the GNOME headerbar style at the same time. > > > Some things... > > GTK is smart with the About dialog - it is obviously dynamically > choosing whether to use a header bar or not and avoids it on both > TWM & Windows, but uses it on GNOME. I checked the about dialog code, and it checks for "gtk-dialogs-use-header" GtkSettings to decide whether it should use the GtkHeaderBar widget or not. This is probably set by the desktop environment. https://git.gnome.org/browse/gtk+/tree/gtk/gtkaboutdialog.c#n800 https://git.gnome.org/browse/gtk+/tree/gtk/gtkdialog.c#n254 > > I'm not seriously expecting anyone to run with TWM. I picked it > simply as an example of a "dumb" window manager that won't understand > hints required to turn off headers when client side decorations are > used > > I'm open to being convinced that this is a complete non-issue, if > all commonly used modern window managers support client side > decorations. I suspect this is probably the case, but it'd be good > to validate this with demos across all the common desktop envs on > Linux (GNOME, KDE, XFCE, Mate, Cinnamon, etc), so we know what to > expect for users. > > This does still leave a question of themeing under non-GNOME. eg > running under say KDE, virt-viewer would previously have a KDE > theme header bar, whereas it now (might) have a GNOME style theme. > Again we can possibly declare this is a non-issue as it just requires > someone to write some GTK CSS to make it fit with KDE theme, and people > may well have already dealt with this since there's
Re: [virt-tools-list] [PATCH 1/2] Add missing ifdef HAVE_OVIRT (virt-viewer-window.c)
Hi Uri, Victor has already sent and merged patches fixing those warnings. Can you try with latest upstream if you still have warnings? By the way, I like some parts of your patches a bit better than his, but as the patches are already in, I am not sure if it is worth to change the code once again. Regards, Eduardo. On 07/03/17 07:18, Uri Lublin wrote: > Currently the build fails when configured without-ovirt (snipped a bit): > make[3]: Entering directory 'virt-viewer/src' > CCLD remote-viewer > ./.libs/libvirt-viewer.a(libvirt_viewer_la-virt-viewer-window.o): > In function `virt_viewer_window_menu_change_cd_activate': > src/virt-viewer-window.c:1082: undefined reference to > `remote_viewer_iso_list_dialog_new' > > The missing function, remote_viewer_iso_list_dialog_new, is called > from src/virt-viewer-window.c:virt_viewer_window_menu_change_cd_activate > and is defined in src/remote-viewer-iso-list-dialog.c > > src/remote-viewer-iso-list-dialog.c is only built when HAVE_OVIRT > is defined. > > This patch adds HAVE_OVIRT ifdefs in src/virt-viewer-window.c. > > Signed-off-by: Uri Lublin > --- > src/virt-viewer-window.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c > index 8eda12e..ff7b102 100644 > --- a/src/virt-viewer-window.c > +++ b/src/virt-viewer-window.c > @@ -43,7 +43,9 @@ > #include "virt-viewer-util.h" > #include "virt-viewer-timed-revealer.h" > > +#ifdef HAVE_OVIRT > #include "remote-viewer-iso-list-dialog.h" > +#endif > > #define ZOOM_STEP 10 > > @@ -64,7 +66,9 @@ void > virt_viewer_window_menu_file_smartcard_insert(GtkWidget *menu, VirtViewerWi > void virt_viewer_window_menu_file_smartcard_remove(GtkWidget *menu, > VirtViewerWindow *self); > void virt_viewer_window_menu_view_release_cursor(GtkWidget *menu, > VirtViewerWindow *self); > void virt_viewer_window_menu_preferences_cb(GtkWidget *menu, > VirtViewerWindow *self); > +#ifdef HAVE_OVIRT > void virt_viewer_window_menu_change_cd_activate(GtkWidget *menu, > VirtViewerWindow *self); > +#endif > > > /* Internal methods */ > @@ -1059,6 +1063,7 @@ virt_viewer_window_menu_help_about(GtkWidget *menu > G_GNUC_UNUSED, > g_object_unref(G_OBJECT(about)); > } > > +#ifdef HAVE_OVIRT > static void > iso_dialog_response(GtkDialog *dialog, > gint response_id, > @@ -1093,6 +1098,7 @@ virt_viewer_window_menu_change_cd_activate(GtkWidget > *menu G_GNUC_UNUSED, > gtk_widget_show_all(dialog); > gtk_dialog_run(GTK_DIALOG(dialog)); > } > +#endif > > static void > virt_viewer_window_toolbar_setup(VirtViewerWindow *self) > -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] virt-viewer: Fix comparison in domain selection
https://twitter.com/codinghorror/status/506010907021828096 Acked-by: Eduardo Lima (Etrunko) On 15/03/17 14:12, Pavel Grunt wrote: > Related: rhbz#1399077 > --- > src/virt-viewer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/virt-viewer.c b/src/virt-viewer.c > index 65c0546..b50db16 100644 > --- a/src/virt-viewer.c > +++ b/src/virt-viewer.c > @@ -110,7 +110,7 @@ opt_domain_selection_cb(const gchar *option_name, > return FALSE; > } > > -for (i = DOMAIN_SELECTION_ID; i <= > G_N_ELEMENTS(domain_selection_to_opt); i++) { > +for (i = DOMAIN_SELECTION_ID; i < G_N_ELEMENTS(domain_selection_to_opt); > i++) { > if (g_strcmp0(option_name, domain_selection_to_opt[i]) == 0) { > domain_selection_type = i; > return TRUE; > -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] vnc: Set display as enabled on init
On 29/03/17 07:36, Pavel Grunt wrote: > It will enable some functionality, like zoom. > You could maybe elaborate a bit better, as you are also setting enabled to FALSE it when the session gets disconnected. Acked-by: Eduardo Lima (Etrunko) > Regression since 9c77a78af2ef85f3fcdce21b42d89566a9f7ee17 > > Resolves: rhbz#1436991 > --- > src/virt-viewer-display-vnc.c | 1 + > src/virt-viewer-session-vnc.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/src/virt-viewer-display-vnc.c b/src/virt-viewer-display-vnc.c > index cb45c23..c200ac2 100644 > --- a/src/virt-viewer-display-vnc.c > +++ b/src/virt-viewer-display-vnc.c > @@ -134,6 +134,7 @@ virt_viewer_display_vnc_initialized(VncDisplay *vnc > G_GNUC_UNUSED, > g_object_set(app, "uuid", _("VNC does not provide GUID"), NULL); > } > > +virt_viewer_display_set_enabled(display, TRUE); > virt_viewer_display_set_show_hint(display, >VIRT_VIEWER_DISPLAY_SHOW_HINT_READY, > TRUE); > > diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c > index 231f22f..26fb405 100644 > --- a/src/virt-viewer-session-vnc.c > +++ b/src/virt-viewer-session-vnc.c > @@ -122,6 +122,7 @@ virt_viewer_session_vnc_disconnected(VncDisplay *vnc > G_GNUC_UNUSED, > display = virt_viewer_display_vnc_new(session, session->priv->vnc); > g_debug("Disconnected"); > g_signal_emit_by_name(session, "session-disconnected", NULL); > +virt_viewer_display_set_enabled(VIRT_VIEWER_DISPLAY(display), FALSE); > virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display), >VIRT_VIEWER_DISPLAY_SHOW_HINT_READY, > FALSE); > } > -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] Remove unused virt_viewer_app_set_zoom_level
On 29/03/17 07:36, Pavel Grunt wrote: > --- > src/virt-viewer-app.h | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h > index 8381631..16b1c8c 100644 > --- a/src/virt-viewer-app.h > +++ b/src/virt-viewer-app.h > @@ -68,7 +68,6 @@ void virt_viewer_app_free_connect_info(VirtViewerApp *self); > gboolean virt_viewer_app_create_session(VirtViewerApp *self, const gchar > *type, GError **error); > gboolean virt_viewer_app_activate(VirtViewerApp *self, GError **error); > gboolean virt_viewer_app_initial_connect(VirtViewerApp *self, GError > **error); > -void virt_viewer_app_set_zoom_level(VirtViewerApp *self, gint zoom_level); > gboolean virt_viewer_app_get_direct(VirtViewerApp *self); > void virt_viewer_app_set_direct(VirtViewerApp *self, gboolean direct); > void virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys); > Acked-by: Eduardo Lima (Etrunko) -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer] vnc: Set display as enabled on init
On 04/04/17 08:55, Pavel Grunt wrote: > On Wed, 2017-03-29 at 14:39 -0300, Eduardo Lima (Etrunko) wrote: >> On 29/03/17 07:36, Pavel Grunt wrote: >>> It will enable some functionality, like zoom. >>> >> >> You could maybe elaborate a bit better, as you are also setting >> enabled >> to FALSE it when the session gets disconnected. > > ok, let's change it to: > > Since 9c77a78af2ef85f3fcdce21b42d89566a9f7ee17 the vnc display has > stopped setting the show hint and started to ignore the initial zoom > setting. Let's handle it in a similar way as the spice display and set > the hint when the display is initialized and unset it on disconnect. > Excelent, thanks :) >> >> Acked-by: Eduardo Lima (Etrunko) >> >>> Regression since 9c77a78af2ef85f3fcdce21b42d89566a9f7ee17 >>> >>> Resolves: rhbz#1436991 >>> --- >>> src/virt-viewer-display-vnc.c | 1 + >>> src/virt-viewer-session-vnc.c | 1 + >>> 2 files changed, 2 insertions(+) >>> >>> diff --git a/src/virt-viewer-display-vnc.c b/src/virt-viewer- >>> display-vnc.c >>> index cb45c23..c200ac2 100644 >>> --- a/src/virt-viewer-display-vnc.c >>> +++ b/src/virt-viewer-display-vnc.c >>> @@ -134,6 +134,7 @@ virt_viewer_display_vnc_initialized(VncDisplay >>> *vnc G_GNUC_UNUSED, >>> g_object_set(app, "uuid", _("VNC does not provide GUID"), >>> NULL); >>> } >>> >>> +virt_viewer_display_set_enabled(display, TRUE); >>> virt_viewer_display_set_show_hint(display, >>>VIRT_VIEWER_DISPLAY_SHOW_HI >>> NT_READY, TRUE); >>> >>> diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer- >>> session-vnc.c >>> index 231f22f..26fb405 100644 >>> --- a/src/virt-viewer-session-vnc.c >>> +++ b/src/virt-viewer-session-vnc.c >>> @@ -122,6 +122,7 @@ >>> virt_viewer_session_vnc_disconnected(VncDisplay *vnc >>> G_GNUC_UNUSED, >>> display = virt_viewer_display_vnc_new(session, session->priv- >>>> vnc); >>> g_debug("Disconnected"); >>> g_signal_emit_by_name(session, "session-disconnected", NULL); >>> +virt_viewer_display_set_enabled(VIRT_VIEWER_DISPLAY(display), >>> FALSE); >>> virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display >>> ), >>>VIRT_VIEWER_DISPLAY_SHOW_HI >>> NT_READY, FALSE); >>> } >>> >> >> >> >> -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer v1] Fix implicit fallthrough warning on new gcc
On 18/04/17 10:39, Victor Toso wrote: > From: Victor Toso > > The option -Wimplicit-fallthrough was added to -Wall recently which > generates a few warnings. Based on the comment above the switch, the > fallthrough is on purpose so let's add a comment to avoid the following > warnings. Meh, it seems that babysitting compilers are the rule nowadays. :/ Acked-by: Eduardo Lima (Etrunko) > > ovirt-foreign-menu.c: In function 'ovirt_foreign_menu_next_async_step': > ovirt-foreign-menu.c:293:12: warning: this statement may fall through > if (menu->priv->api == NULL) { > ^ > ovirt-foreign-menu.c:297:5: note: here > case STATE_VM: >^~~~ > ovirt-foreign-menu.c:298:12: warning: this statement may fall through > if (menu->priv->vm == NULL) { > ^ > ovirt-foreign-menu.c:302:5: note: here > case STATE_STORAGE_DOMAIN: > ^~~~ > ovirt-foreign-menu.c:303:12: warning: this statement may fall through > if (menu->priv->files == NULL) { > ^ > ovirt-foreign-menu.c:307:5: note: here > case STATE_VM_CDROM: > ^~~~ > > ovirt-foreign-menu.c:308:12: warning: this statement may fall through > if (menu->priv->cdrom == NULL) { > ^ > ovirt-foreign-menu.c:312:5: note: here >case STATE_CDROM_FILE: > ^~~~ > > Signed-off-by: Victor Toso > --- > src/ovirt-foreign-menu.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c > index 2939ae5..fdfd327 100644 > --- a/src/ovirt-foreign-menu.c > +++ b/src/ovirt-foreign-menu.c > @@ -294,21 +294,25 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu > *menu, > ovirt_foreign_menu_fetch_api_async(menu, task); > break; > } > +/* fall through */ > case STATE_VM: > if (menu->priv->vm == NULL) { > ovirt_foreign_menu_fetch_vm_async(menu, task); > break; > } > +/* fall through */ > case STATE_STORAGE_DOMAIN: > if (menu->priv->files == NULL) { > ovirt_foreign_menu_fetch_storage_domain_async(menu, task); > break; > } > +/* fall through */ > case STATE_VM_CDROM: > if (menu->priv->cdrom == NULL) { > ovirt_foreign_menu_fetch_vm_cdrom_async(menu, task); > break; > } > +/* fall through */ > case STATE_CDROM_FILE: > ovirt_foreign_menu_refresh_cdrom_file_async(menu, task); > break; > -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 1/2] window: Do not show fullscreen toolbar if in kiosk mode
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 Signed-off-by: Eduardo Lima (Etrunko) --- src/virt-viewer-window.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 867a7b0..ff22ded 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -518,8 +518,11 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor) virt_viewer_window_menu_fullscreen_set_active(self, TRUE); gtk_widget_hide(menu); -gtk_widget_show(priv->toolbar); -virt_viewer_timed_revealer_force_reveal(priv->revealer, TRUE); + +if (!priv->kiosk) { +gtk_widget_show(priv->toolbar); +virt_viewer_timed_revealer_force_reveal(priv->revealer, TRUE); +} if (priv->display) { virt_viewer_display_set_monitor(priv->display, monitor); -- 2.9.4 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer 2/2] Quit application if in kiosk mode and authentication has been cancelled
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 Signed-off-by: Eduardo Lima (Etrunko) --- src/virt-viewer-app.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index f0fcf21..1975af0 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -1441,6 +1441,8 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch if (!priv->kiosk) virt_viewer_app_hide_all_windows(self); +else if (priv->cancelled) +priv->quitting = TRUE; if (priv->quitting) g_application_quit(G_APPLICATION(self)); -- 2.9.4 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer 2/2] Quit application if in kiosk mode and authentication has been cancelled
On 21/05/17 04:23, Xiaodai Wang wrote: > > - Original Message - >> From: "Victor Toso" >> To: "Eduardo Lima (Etrunko)" >> Cc: virt-tools-list@redhat.com >> Sent: Saturday, May 20, 2017 5:26:29 AM >> Subject: Re: [virt-tools-list] [PATCH virt-viewer 2/2] Quit application if >> in kiosk mode and authentication has been >> cancelled >> >> Hi, >> >> On Fri, May 19, 2017 at 05:16:53PM -0300, Eduardo Lima (Etrunko) wrote: >>> Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 >>> >>> Signed-off-by: Eduardo Lima (Etrunko) >> >> I'm not 100% sure that this would be the desirable behavior. If one runs >> the app in -k, isn't it the point that the user would not have access to >> the desktop? >> >> AFAICT, the available options are: >> >> 1) Click cancel, close virt-viewer (this patch) >> 2) Click cancel, open dialog again (your suggestion on bz#1446161) >> 3) Remove cancel button as (2) shows that it is useless > >-k, --kiosk >Start in kiosk mode. In this mode, the application will start in > fullscreen with minimal UI. >It will prevent the user from quitting or performing any interaction > outside of usage of the remote desktop session. > > From the man page of virt-viewer, i think 2) or 3) is better than 1). Hiding/blocking cancel button is, IMO, useless in this case. We will only add unnecessary complexity to the dialog code for this specific use. I will rather go with option 2 then. By the way, it would be nice to have some documentation about what are the goals with this feature. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer v2 2/2] kiosk: Show authentication dialog again if cancelled
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 Signed-off-by: Eduardo Lima (Etrunko) --- v2: Retry authentication dialog if cancelled instead of quitting the application. --- src/virt-viewer-app.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index f0fcf21..2a2 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -1441,6 +1441,8 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch if (!priv->kiosk) virt_viewer_app_hide_all_windows(self); +else if (priv->cancelled) +priv->authretry = TRUE; if (priv->quitting) g_application_quit(G_APPLICATION(self)); -- 2.9.4 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH virt-viewer v2 1/2] window: Do not show fullscreen toolbar if in kiosk mode
Regression since commit cc455b7f916110d7cfae6b7af753349e070c9494. Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 Signed-off-by: Eduardo Lima (Etrunko) --- src/virt-viewer-window.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index f5448c6..3ba4e2c 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -518,8 +518,11 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor) virt_viewer_window_menu_fullscreen_set_active(self, TRUE); gtk_widget_hide(menu); -gtk_widget_show(priv->toolbar); -virt_viewer_timed_revealer_force_reveal(priv->revealer, TRUE); + +if (!priv->kiosk) { +gtk_widget_show(priv->toolbar); +virt_viewer_timed_revealer_force_reveal(priv->revealer, TRUE); +} if (priv->display) { virt_viewer_display_set_monitor(priv->display, monitor); -- 2.9.4 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer v2 2/2] kiosk: Show authentication dialog again if cancelled
Pushed, thanks On 31/05/17 10:40, Victor Toso wrote: > Hi, > > On Wed, May 31, 2017 at 10:23:16AM -0300, Eduardo Lima (Etrunko) wrote: >> Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 >> >> Signed-off-by: Eduardo Lima (Etrunko) > > Works fine, > Acked-by: Victor Toso > >> --- >> v2: Retry authentication dialog if cancelled instead of quitting the >> application. >> --- >> src/virt-viewer-app.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c >> index f0fcf21..2a2 100644 >> --- a/src/virt-viewer-app.c >> +++ b/src/virt-viewer-app.c >> @@ -1441,6 +1441,8 @@ virt_viewer_app_disconnected(VirtViewerSession >> *session G_GNUC_UNUSED, const gch >> >> if (!priv->kiosk) >> virt_viewer_app_hide_all_windows(self); >> +else if (priv->cancelled) >> +priv->authretry = TRUE; >> >> if (priv->quitting) >> g_application_quit(G_APPLICATION(self)); >> -- >> 2.9.4 >> >> ___ >> virt-tools-list mailing list >> virt-tools-list@redhat.com >> https://www.redhat.com/mailman/listinfo/virt-tools-list -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH virt-viewer v2 1/2] window: Do not show fullscreen toolbar if in kiosk mode
Pushed, thanks. On 31/05/17 10:27, Victor Toso wrote: > On Wed, May 31, 2017 at 10:23:15AM -0300, Eduardo Lima (Etrunko) wrote: >> Regression since commit cc455b7f916110d7cfae6b7af753349e070c9494. >> >> Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 >> >> Signed-off-by: Eduardo Lima (Etrunko) > Acked-by: Victor Toso >> --- >> src/virt-viewer-window.c | 7 +-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c >> index f5448c6..3ba4e2c 100644 >> --- a/src/virt-viewer-window.c >> +++ b/src/virt-viewer-window.c >> @@ -518,8 +518,11 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow >> *self, gint monitor) >> >> virt_viewer_window_menu_fullscreen_set_active(self, TRUE); >> gtk_widget_hide(menu); >> -gtk_widget_show(priv->toolbar); >> -virt_viewer_timed_revealer_force_reveal(priv->revealer, TRUE); >> + >> +if (!priv->kiosk) { >> +gtk_widget_show(priv->toolbar); >> +virt_viewer_timed_revealer_force_reveal(priv->revealer, TRUE); >> +} >> >> if (priv->display) { >> virt_viewer_display_set_monitor(priv->display, monitor); >> -- >> 2.9.4 >> >> ___ >> virt-tools-list mailing list >> virt-tools-list@redhat.com >> https://www.redhat.com/mailman/listinfo/virt-tools-list -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com signature.asc Description: OpenPGP digital signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer v3] spice: do not show error on cancel/close of auth dialog
On 02/06/17 09:57, Pavel Grunt wrote: > On Fri, 2017-06-02 at 14:05 +0200, Victor Toso wrote: >> From: Victor Toso >> >> Mainly an issue for kiosk mode. >> >> Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161 >> Signed-off-by: Victor Toso >> --- >> src/virt-viewer-session-spice.c | 4 >> 1 file changed, 4 insertions(+) >> >> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer- >> session-spice.c >> index 5f326aa..106abd1 100644 >> --- a/src/virt-viewer-session-spice.c >> +++ b/src/virt-viewer-session-spice.c >> @@ -725,6 +725,10 @@ >> virt_viewer_session_spice_main_channel_event(SpiceChannel *channel, >> g_free(host); >> if (!ret) { >> g_signal_emit_by_name(session, "session-cancelled"); >> +/* ret is false when dialog did not return >> GTK_RESPONSE_OK. We >> + * should ignore auth error dialog if user has >> cancelled or closed >> + * the dialog */ >> +self->priv->pass_try = 0; > > I'd first change the value and after that emit the signal. > > Acked-by: Pavel Grunt > The patch per se is 'ok-ish' for me, but I don't really understand why would we not want to show the message dialog before the authentication dialog again? I think this could be explained with more details on the commit message. Other than that, I also think the case described in the bug is trying a little bit too hard to be considered a valid use case. -- Eduardo de Barros Lima (Etrunko) Software Engineer - RedHat etru...@redhat.com ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list