mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2025-08-24 17:49:22 +03:00
Set a transient parent for GtkDialogs
Silence the Gtk 3.14 message: "GtkDialog mapped without a transient parent. This is discouraged."
This commit is contained in:
committed by
Fabiano Fidêncio
parent
7e4921f161
commit
c3d24f8bb6
@ -76,7 +76,10 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_OVIRT
|
#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
|
#endif
|
||||||
|
|
||||||
static gboolean remote_viewer_start(VirtViewerApp *self);
|
static gboolean remote_viewer_start(VirtViewerApp *self);
|
||||||
@ -84,7 +87,7 @@ static gboolean remote_viewer_start(VirtViewerApp *self);
|
|||||||
static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
|
static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
|
||||||
static void remote_viewer_window_added(VirtViewerApp *self, VirtViewerWindow *win);
|
static void remote_viewer_window_added(VirtViewerApp *self, VirtViewerWindow *win);
|
||||||
static void spice_foreign_menu_updated(RemoteViewer *self);
|
static void spice_foreign_menu_updated(RemoteViewer *self);
|
||||||
static gint connect_dialog(gchar **uri);
|
static gint connect_dialog(GtkWindow *main_window, gchar **uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -865,7 +868,11 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
|
|||||||
}
|
}
|
||||||
if (vm_name == NULL ||
|
if (vm_name == NULL ||
|
||||||
(vm = OVIRT_VM(ovirt_collection_lookup_resource(vms, 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);
|
||||||
|
vm = choose_vm(virt_viewer_window_get_window(main_window),
|
||||||
|
&vm_name,
|
||||||
|
vms,
|
||||||
|
&error);
|
||||||
if (vm == NULL) {
|
if (vm == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1048,7 +1055,7 @@ static void make_label_bold(GtkLabel* label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
connect_dialog(gchar **uri)
|
connect_dialog(GtkWindow *main_window, gchar **uri)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog, *area, *box, *label, *entry, *recent;
|
GtkWidget *dialog, *area, *box, *label, *entry, *recent;
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
@ -1059,7 +1066,7 @@ connect_dialog(gchar **uri)
|
|||||||
|
|
||||||
/* Create the widgets */
|
/* Create the widgets */
|
||||||
dialog = gtk_dialog_new_with_buttons(_("Connection details"),
|
dialog = gtk_dialog_new_with_buttons(_("Connection details"),
|
||||||
NULL,
|
main_window,
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_STOCK_CANCEL,
|
GTK_STOCK_CANCEL,
|
||||||
GTK_RESPONSE_REJECT,
|
GTK_RESPONSE_REJECT,
|
||||||
@ -1138,7 +1145,10 @@ connect_dialog(gchar **uri)
|
|||||||
|
|
||||||
#ifdef HAVE_OVIRT
|
#ifdef HAVE_OVIRT
|
||||||
static OvirtVm *
|
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;
|
GtkListStore *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
@ -1162,7 +1172,9 @@ 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);
|
||||||
g_object_unref(model);
|
g_object_unref(model);
|
||||||
if (*vm_name == NULL)
|
if (*vm_name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1180,6 +1192,7 @@ remote_viewer_start(VirtViewerApp *app)
|
|||||||
|
|
||||||
RemoteViewer *self = REMOTE_VIEWER(app);
|
RemoteViewer *self = REMOTE_VIEWER(app);
|
||||||
RemoteViewerPrivate *priv = self->priv;
|
RemoteViewerPrivate *priv = self->priv;
|
||||||
|
VirtViewerWindow *main_window;
|
||||||
GFile *file = NULL;
|
GFile *file = NULL;
|
||||||
VirtViewerFile *vvfile = NULL;
|
VirtViewerFile *vvfile = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
@ -1210,8 +1223,9 @@ remote_viewer_start(VirtViewerApp *app)
|
|||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
retry_dialog:
|
retry_dialog:
|
||||||
|
main_window = virt_viewer_app_get_main_window(app);
|
||||||
if (priv->open_recent_dialog) {
|
if (priv->open_recent_dialog) {
|
||||||
if (connect_dialog(&guri) != 0)
|
if (connect_dialog(virt_viewer_window_get_window(main_window), &guri) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
g_object_set(app, "guri", guri, NULL);
|
g_object_set(app, "guri", guri, NULL);
|
||||||
} else
|
} else
|
||||||
|
@ -43,7 +43,9 @@ treeselection_changed_cb(GtkTreeSelection *selection, gpointer userdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
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)
|
||||||
{
|
{
|
||||||
GtkBuilder *vm_connection;
|
GtkBuilder *vm_connection;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
@ -67,6 +69,7 @@ virt_viewer_vm_connection_choose_name_dialog(GtkTreeModel *model, GError **error
|
|||||||
g_return_val_if_fail(vm_connection != NULL, NULL);
|
g_return_val_if_fail(vm_connection != NULL, NULL);
|
||||||
|
|
||||||
dialog = GTK_WIDGET(gtk_builder_get_object(vm_connection, "vm-connection-dialog"));
|
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"));
|
button_connect = GTK_BUTTON(gtk_builder_get_object(vm_connection, "button-connect"));
|
||||||
treeview = GTK_TREE_VIEW(gtk_builder_get_object(vm_connection, "treeview"));
|
treeview = GTK_TREE_VIEW(gtk_builder_get_object(vm_connection, "treeview"));
|
||||||
selection = GTK_TREE_SELECTION(gtk_builder_get_object(vm_connection, "treeview-selection"));
|
selection = GTK_TREE_SELECTION(gtk_builder_get_object(vm_connection, "treeview-selection"));
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtk/gtk.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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
|
@ -590,7 +590,10 @@ virt_viewer_dispose (GObject *object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static virDomainPtr
|
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;
|
GtkListStore *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
@ -611,7 +614,9 @@ choose_vm(char **vm_name, virConnectPtr conn, GError **error)
|
|||||||
}
|
}
|
||||||
free(domains);
|
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);
|
||||||
g_object_unref(G_OBJECT(model));
|
g_object_unref(G_OBJECT(model));
|
||||||
if (*vm_name == NULL)
|
if (*vm_name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -661,7 +666,11 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
|
|||||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to be created"));
|
virt_viewer_app_show_status(app, _("Waiting for guest domain to be created"));
|
||||||
goto wait;
|
goto wait;
|
||||||
} else {
|
} else {
|
||||||
dom = choose_vm(&priv->domkey, priv->conn, &err);
|
VirtViewerWindow *main_window = virt_viewer_app_get_main_window(app);
|
||||||
|
dom = choose_vm(virt_viewer_window_get_window(main_window),
|
||||||
|
&priv->domkey,
|
||||||
|
priv->conn,
|
||||||
|
&err);
|
||||||
if (dom == NULL && err != NULL) {
|
if (dom == NULL && err != NULL) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user