summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdocument/ev-attachment.c17
-rw-r--r--shell/ev-window.c32
2 files changed, 49 insertions, 0 deletions
diff --git a/libdocument/ev-attachment.c b/libdocument/ev-attachment.c
index 6e7942ee..59af21ab 100644
--- a/libdocument/ev-attachment.c
+++ b/libdocument/ev-attachment.c
@@ -347,7 +347,12 @@ ev_attachment_launch_app (EvAttachment *attachment,
{
gboolean result;
GList *files = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkAppLaunchContext *context;
+ GdkDisplay *display;
+#else
GAppLaunchContext *context = NULL;
+#endif
GError *ioerror = NULL;
g_assert (G_IS_FILE (attachment->priv->tmp_file));
@@ -355,6 +360,17 @@ ev_attachment_launch_app (EvAttachment *attachment,
files = g_list_prepend (files, attachment->priv->tmp_file);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ display = screen ? gdk_screen_get_display (screen) : gdk_display_get_default ();
+ context = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, timestamp);
+
+ result = g_app_info_launch (attachment->priv->app, files,
+ G_APP_LAUNCH_CONTEXT (context),
+ &ioerror);
+ g_object_unref (context);
+#else
context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context), screen);
gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), timestamp);
@@ -364,6 +380,7 @@ ev_attachment_launch_app (EvAttachment *attachment,
if (context)
g_object_unref (context);
+#endif
if (!result) {
g_set_error (error,
diff --git a/shell/ev-window.c b/shell/ev-window.c
index b282062c..382f4c97 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -6581,7 +6581,12 @@ launch_action (EvWindow *window, EvLinkAction *action)
GAppInfo *app_info;
GFile *file;
GList file_list = {NULL};
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkAppLaunchContext *context;
+ GdkScreen *screen;
+#else
GAppLaunchContext *context;
+#endif
GError *error = NULL;
if (filename == NULL)
@@ -6612,6 +6617,15 @@ launch_action (EvWindow *window, EvLinkAction *action)
return;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
+
+ file_list.data = file;
+ if (!g_app_info_launch (app_info, &file_list, G_APP_LAUNCH_CONTEXT (context), &error)) {
+#else
context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
gtk_window_get_screen (GTK_WINDOW (window)));
@@ -6620,6 +6634,7 @@ launch_action (EvWindow *window, EvLinkAction *action)
file_list.data = file;
if (!g_app_info_launch (app_info, &file_list, context, &error)) {
+#endif
ev_window_error_message (window, error,
"%s",
_("Unable to launch external application."));
@@ -6640,6 +6655,15 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
const gchar *uri = ev_link_action_get_uri (action);
GError *error = NULL;
gboolean ret;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkAppLaunchContext *context;
+ GdkScreen *screen;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
+#else
GAppLaunchContext *context;
context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
@@ -6647,6 +6671,7 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
gtk_window_get_screen (GTK_WINDOW (window)));
gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
gtk_get_current_event_time ());
+#endif
if (!g_strstr_len (uri, strlen (uri), "://") &&
!g_str_has_prefix (uri, "mailto:")) {
@@ -6671,10 +6696,17 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
new_uri = g_strdup_printf ("file:///%s", uri);
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ ret = g_app_info_launch_default_for_uri (new_uri, G_APP_LAUNCH_CONTEXT (context), &error);
+ g_free (new_uri);
+ } else {
+ ret = g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (context), &error);
+#else
ret = g_app_info_launch_default_for_uri (new_uri, context, &error);
g_free (new_uri);
} else {
ret = g_app_info_launch_default_for_uri (uri, context, &error);
+#endif
}
if (ret == FALSE) {