[gtk+/portal2] print portal: Send the parent window along
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/portal2] print portal: Send the parent window along
- Date: Thu, 7 Jul 2016 18:04:14 +0000 (UTC)
commit 3a46c75345c325216a9338519545e747ba58d995
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 7 14:03:45 2016 -0400
print portal: Send the parent window along
This lets gnome-shell attach the dialog to the application window.
gtk/gtkprintoperation-portal.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkprintoperation-portal.c b/gtk/gtkprintoperation-portal.c
index ac12112..20857cc 100644
--- a/gtk/gtkprintoperation-portal.c
+++ b/gtk/gtkprintoperation-portal.c
@@ -37,6 +37,10 @@
#include "gtkshow.h"
#include "gtkintl.h"
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
typedef struct {
GtkPrintOperation *op;
GDBusProxy *proxy;
@@ -517,6 +521,7 @@ call_prepare_print (GtkPrintOperation *op,
GVariant *setup;
GVariantBuilder opt_builder;
GVariant *options;
+ char *parent_window_str = NULL;
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
options = g_variant_builder_end (&opt_builder);
@@ -539,10 +544,19 @@ call_prepare_print (GtkPrintOperation *op,
g_object_unref (page_setup);
}
+ if (portal->parent != NULL && gtk_widget_is_visible (GTK_WIDGET (portal->parent)))
+ {
+ GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (portal->parent));
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_WINDOW (window))
+ parent_window_str = g_strdup_printf ("x11:%x", (guint32)gdk_x11_window_get_xid (window));
+#endif
+ }
+
g_dbus_proxy_call (portal->proxy,
"PreparePrint",
g_variant_new ("(ss@a{sv}@a{sv}@a{sv})",
- "", /* window */
+ parent_window_str ? parent_window_str : "",
_("Print"), /* title */
settings,
setup,
@@ -552,6 +566,8 @@ call_prepare_print (GtkPrintOperation *op,
NULL,
prepare_print_called,
portal);
+
+ g_free (parent_window_str);
}
GtkPrintOperationResult
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]