mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2025-01-22 22:03:44 +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:
parent
7e4921f161
commit
c3d24f8bb6
@ -76,7 +76,10 @@ 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 +87,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 +868,11 @@ 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);
|
||||
vm = choose_vm(virt_viewer_window_get_window(main_window),
|
||||
&vm_name,
|
||||
vms,
|
||||
&error);
|
||||
if (vm == NULL) {
|
||||
goto error;
|
||||
}
|
||||
@ -1048,7 +1055,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 +1066,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 +1145,10 @@ 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 +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);
|
||||
if (*vm_name == NULL)
|
||||
return NULL;
|
||||
@ -1180,6 +1192,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 +1223,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
|
||||
|
@ -43,7 +43,9 @@ 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)
|
||||
{
|
||||
GtkBuilder *vm_connection;
|
||||
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);
|
||||
|
||||
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"));
|
||||
|
@ -24,7 +24,9 @@
|
||||
#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);
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
@ -590,7 +590,10 @@ 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 +614,9 @@ 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);
|
||||
g_object_unref(G_OBJECT(model));
|
||||
if (*vm_name == 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"));
|
||||
goto wait;
|
||||
} 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) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user