[virt-tools-list] [PATCH virt-viewer] Set a transient parent for GtkDialogs

Fabiano Fidêncio fabiano at fidencio.org
Fri Dec 19 16:06:45 UTC 2014


Hey Pavel,

On Fri, Dec 19, 2014 at 4:45 PM, Pavel Grunt <pgrunt at redhat.com> wrote:
> Hey,
>
> Thank you - I will realign it. Btw the declaration cannot be in the if/else block?

Yes, it must be in the if/else block. But the declarations should come
as the first thing on these blocks.
In the code I could see something like:
if () {
   foo = bar;
   FooBar *foobar = barfoo;
   ...
}

and it should be:

if () {
   Foobar *foobar = barfoo;
   foo = bar;
   ....
}


>
> Pavel
>
>>
>> On Fri, Dec 19, 2014 at 3:46 PM, Pavel Grunt <pgrunt at redhat.com>
>> wrote:
>> > Silence the Gtk 3.14 message:
>> > "GtkDialog mapped without a transient parent. This is discouraged."
>> > ---
>> > The message shows up in Fedora 21 when running remote-viewer
>> > without arguments.
>> > ---
>> >  src/remote-viewer.c             | 21 +++++++++++++--------
>> >  src/virt-viewer-vm-connection.c |  4 +++-
>> >  src/virt-viewer-vm-connection.h |  3 ++-
>> >  src/virt-viewer.c               |  8 +++++---
>> >  4 files changed, 23 insertions(+), 13 deletions(-)
>> >
>> > diff --git a/src/remote-viewer.c b/src/remote-viewer.c
>> > index 818c421..4564e28 100644
>> > --- a/src/remote-viewer.c
>> > +++ b/src/remote-viewer.c
>> > @@ -76,7 +76,8 @@ enum {
>> >  };
>> >
>> >  #ifdef HAVE_OVIRT
>> > -static OvirtVm * choose_vm(char **vm_name, OvirtCollection *vms,
>> > GError **error);
>> > +static OvirtVm * choose_vm(GtkWindow *main_window, char **vm_name,
>> > OvirtCollection *vms,
>> > +                           GError **error);
>> >  #endif
>> >
>> >  static gboolean remote_viewer_start(VirtViewerApp *self);
>> > @@ -84,7 +85,7 @@ static gboolean remote_viewer_start(VirtViewerApp
>> > *self);
>> >  static gboolean remote_viewer_activate(VirtViewerApp *self, GError
>> >  **error);
>> >  static void remote_viewer_window_added(VirtViewerApp *self,
>> >  VirtViewerWindow *win);
>> >  static void spice_foreign_menu_updated(RemoteViewer *self);
>> > -static gint connect_dialog(gchar **uri);
>> > +static gint connect_dialog(GtkWindow *main_window, gchar **uri);
>> >  #endif
>> >
>> >  static void
>> > @@ -865,7 +866,8 @@ create_ovirt_session(VirtViewerApp *app, const
>> > char *uri, GError **err)
>> >      }
>> >      if (vm_name == NULL ||
>> >          (vm = OVIRT_VM(ovirt_collection_lookup_resource(vms,
>> >          vm_name))) == NULL) {
>> > -        vm = choose_vm(&vm_name, vms, &error);
>> > +        VirtViewerWindow *main_window =
>> > virt_viewer_app_get_main_window(app);
>>
>> Please, declare VirtViewerWindow as the first thing in the block.
>>
>> > +        vm = choose_vm(virt_viewer_window_get_window(main_window),
>> > &vm_name, vms, &error);
>> >          if (vm == NULL) {
>> >              goto error;
>> >          }
>> > @@ -1048,7 +1050,7 @@ static void make_label_bold(GtkLabel* label)
>> >  }
>> >
>> >  static gint
>> > -connect_dialog(gchar **uri)
>> > +connect_dialog(GtkWindow *main_window, gchar **uri)
>> >  {
>> >      GtkWidget *dialog, *area, *box, *label, *entry, *recent;
>> >  #if !GTK_CHECK_VERSION(3, 0, 0)
>> > @@ -1059,7 +1061,7 @@ connect_dialog(gchar **uri)
>> >
>> >      /* Create the widgets */
>> >      dialog = gtk_dialog_new_with_buttons(_("Connection details"),
>> > -                                         NULL,
>> > +                                         main_window,
>> >                                           GTK_DIALOG_DESTROY_WITH_PARENT,
>> >                                           GTK_STOCK_CANCEL,
>> >                                           GTK_RESPONSE_REJECT,
>> > @@ -1138,7 +1140,7 @@ connect_dialog(gchar **uri)
>> >
>> >  #ifdef HAVE_OVIRT
>> >  static OvirtVm *
>> > -choose_vm(char **vm_name, OvirtCollection *vms_collection, GError
>> > **error)
>> > +choose_vm(GtkWindow *main_window, char **vm_name, OvirtCollection
>> > *vms_collection, GError **error)
>> >  {
>> >      GtkListStore *model;
>> >      GtkTreeIter iter;
>> > @@ -1162,7 +1164,8 @@ choose_vm(char **vm_name, OvirtCollection
>> > *vms_collection, GError **error)
>> >         }
>> >      }
>> >
>> > -    *vm_name =
>> > virt_viewer_vm_connection_choose_name_dialog(GTK_TREE_MODEL(model),
>> > error);
>> > +    *vm_name =
>> > virt_viewer_vm_connection_choose_name_dialog(main_window,
>> > GTK_TREE_MODEL(model),
>> > +
>> >                                                            error);
>>
>> Hmm. Please, if the error doesn't fit in the same line, align
>> GTK_TREE_MODEL and error to main_window (in a new line for each).
>>
>> >      g_object_unref(model);
>> >      if (*vm_name == NULL)
>> >          return NULL;
>> > @@ -1180,6 +1183,7 @@ remote_viewer_start(VirtViewerApp *app)
>> >
>> >      RemoteViewer *self = REMOTE_VIEWER(app);
>> >      RemoteViewerPrivate *priv = self->priv;
>> > +    VirtViewerWindow *main_window;
>> >      GFile *file = NULL;
>> >      VirtViewerFile *vvfile = NULL;
>> >      gboolean ret = FALSE;
>> > @@ -1210,8 +1214,9 @@ remote_viewer_start(VirtViewerApp *app)
>> >      } else {
>> >  #endif
>> >  retry_dialog:
>> > +        main_window = virt_viewer_app_get_main_window(app);
>> >          if (priv->open_recent_dialog) {
>> > -            if (connect_dialog(&guri) != 0)
>> > +            if
>> > (connect_dialog(virt_viewer_window_get_window(main_window), &guri)
>> > != 0)
>> >                  return FALSE;
>> >              g_object_set(app, "guri", guri, NULL);
>> >          } else
>> > diff --git a/src/virt-viewer-vm-connection.c
>> > b/src/virt-viewer-vm-connection.c
>> > index 4a3feba..222c738 100644
>> > --- a/src/virt-viewer-vm-connection.c
>> > +++ b/src/virt-viewer-vm-connection.c
>> > @@ -43,7 +43,8 @@ treeselection_changed_cb(GtkTreeSelection
>> > *selection, gpointer userdata)
>> >  }
>> >
>> >  gchar*
>> > -virt_viewer_vm_connection_choose_name_dialog(GtkTreeModel *model,
>> > GError **error)
>> > +virt_viewer_vm_connection_choose_name_dialog(GtkWindow
>> > *main_window, GtkTreeModel *model,
>> > +                                             GError **error)
>>
>> Same here ...
>>
>> >  {
>> >      GtkBuilder *vm_connection;
>> >      GtkWidget *dialog;
>> > @@ -67,6 +68,7 @@
>> > virt_viewer_vm_connection_choose_name_dialog(GtkTreeModel *model,
>> > GError **error
>> >      g_return_val_if_fail(vm_connection != NULL, NULL);
>> >
>> >      dialog = GTK_WIDGET(gtk_builder_get_object(vm_connection,
>> >      "vm-connection-dialog"));
>> > +    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"));
>> > diff --git a/src/virt-viewer-vm-connection.h
>> > b/src/virt-viewer-vm-connection.h
>> > index d198c89..78e03b6 100644
>> > --- a/src/virt-viewer-vm-connection.h
>> > +++ b/src/virt-viewer-vm-connection.h
>> > @@ -24,7 +24,8 @@
>> >  #include <glib.h>
>> >  #include <gtk/gtk.h>
>> >
>> > -gchar* virt_viewer_vm_connection_choose_name_dialog(GtkTreeModel
>> > *model, GError **error);
>> > +gchar* virt_viewer_vm_connection_choose_name_dialog(GtkWindow
>> > *main_window, GtkTreeModel *model,
>> > +                                                    GError
>> > **error);
>>
>> Same here ...
>>
>> >
>> >  #endif
>> >  /*
>> > diff --git a/src/virt-viewer.c b/src/virt-viewer.c
>> > index 193ef3a..04a91cc 100644
>> > --- a/src/virt-viewer.c
>> > +++ b/src/virt-viewer.c
>> > @@ -590,7 +590,7 @@ virt_viewer_dispose (GObject *object)
>> >  }
>> >
>> >  static virDomainPtr
>> > -choose_vm(char **vm_name, virConnectPtr conn, GError **error)
>> > +choose_vm(GtkWindow *main_window, char **vm_name, virConnectPtr
>> > conn, GError **error)
>> >  {
>> >      GtkListStore *model;
>> >      GtkTreeIter iter;
>> > @@ -611,7 +611,8 @@ choose_vm(char **vm_name, virConnectPtr conn,
>> > GError **error)
>> >      }
>> >      free(domains);
>> >
>> > -    *vm_name =
>> > virt_viewer_vm_connection_choose_name_dialog(GTK_TREE_MODEL(model),
>> > error);
>> > +    *vm_name =
>> > virt_viewer_vm_connection_choose_name_dialog(main_window,
>> > GTK_TREE_MODEL(model),
>> > +
>> >                                                            error);
>>
>> Same here ...
>>
>> >      g_object_unref(G_OBJECT(model));
>> >      if (*vm_name == NULL)
>> >          return NULL;
>> > @@ -661,7 +662,8 @@ virt_viewer_initial_connect(VirtViewerApp *app,
>> > GError **error)
>> >              virt_viewer_app_show_status(app, _("Waiting for guest
>> >              domain to be created"));
>> >              goto wait;
>> >          } else {
>> > -            dom = choose_vm(&priv->domkey, priv->conn, &err);
>> > +            VirtViewerWindow *main_window =
>> > virt_viewer_app_get_main_window(app);
>>
>> Please declare VirtViewerWindow as the first thing in the block.
>>
>> > +            dom =
>> > choose_vm(virt_viewer_window_get_window(main_window),
>> > &priv->domkey, priv->conn, &err);
>> >              if (dom == NULL && err != NULL) {
>> >                  goto cleanup;
>> >              }
>> > --
>> > 1.9.3
>> >
>> > _______________________________________________
>> > virt-tools-list mailing list
>> > virt-tools-list at redhat.com
>> > https://www.redhat.com/mailman/listinfo/virt-tools-list
>>
>>
>> Best Regards,
>> --
>> Fabiano Fidêncio
>>


Best Regards,
-- 
Fabiano Fidêncio




More information about the virt-tools-list mailing list