]> www.fi.muni.cz Git - evince.git/commitdiff
Use GdkAppLaunchContext when available to open attachments.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Fri, 5 Sep 2008 09:47:48 +0000 (09:47 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Fri, 5 Sep 2008 09:47:48 +0000 (09:47 +0000)
2008-09-05  Carlos Garcia Campos  <carlosgc@gnome.org>

* libdocument/ev-attachment.[ch]: (ev_attachment_launch_app),
(ev_attachment_open):
* shell/ev-sidebar-attachments.c:
(ev_sidebar_attachments_button_press):
* shell/ev-window.c: (ev_attachment_popup_cmd_open_attachment):

Use GdkAppLaunchContext when available to open attachments.

svn path=/trunk/; revision=3152

ChangeLog
libdocument/ev-attachment.c
libdocument/ev-attachment.h
shell/ev-sidebar-attachments.c
shell/ev-window.c

index 98f2f3ba40ab23c0dc314ee29e10c181850e2c95..3d8d186480855e0c62adaa6ffc2a9e43b93ee853 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-09-05  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * libdocument/ev-attachment.[ch]: (ev_attachment_launch_app),
+       (ev_attachment_open):
+       * shell/ev-sidebar-attachments.c:
+       (ev_sidebar_attachments_button_press):
+       * shell/ev-window.c: (ev_attachment_popup_cmd_open_attachment):
+
+       Use GdkAppLaunchContext when available to open attachments.
+       
 2008-09-04  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-media-player-keys.c: (ev_media_player_keys_grab_keys):
index 02d5f3d22153143c07f636eefef723266f9b3fde..2eadadf4343aa16178735a70d193823cfdb2e02c 100644 (file)
@@ -20,6 +20,7 @@
 #include <config.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
+#include <gtk/gtk.h>
 #include "ev-file-helpers.h"
 #include "ev-attachment.h"
 
@@ -340,18 +341,30 @@ ev_attachment_save (EvAttachment *attachment,
 
 static gboolean
 ev_attachment_launch_app (EvAttachment *attachment,
+                         GdkScreen    *screen,
+                         guint32       timestamp,
                          GError      **error)
 {
-       gboolean result;
-       GList   *files = NULL;
-       GError  *ioerror = NULL;
+       gboolean           result;
+       GList             *files = NULL;
+       GAppLaunchContext *context = NULL;
+       GError            *ioerror = NULL;
 
        g_assert (G_IS_FILE (attachment->priv->tmp_file));
        g_assert (G_IS_APP_INFO (attachment->priv->app));
 
        files = g_list_prepend (files, attachment->priv->tmp_file);
+       
+#if GTK_CHECK_VERSION (2, 14, 0)
+       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);
+#endif
        result = g_app_info_launch (attachment->priv->app, files,
-                                   NULL, &ioerror);
+                                   context, &ioerror);
+       
+       if (context)
+               g_object_unref (context);
 
        if (!result) {
                g_set_error (error,
@@ -374,6 +387,8 @@ ev_attachment_launch_app (EvAttachment *attachment,
 
 gboolean
 ev_attachment_open (EvAttachment *attachment,
+                   GdkScreen    *screen,
+                   guint32       timestamp,
                    GError      **error)
 {
        GAppInfo *app_info;
@@ -398,7 +413,8 @@ ev_attachment_open (EvAttachment *attachment,
 
        if (attachment->priv->tmp_file &&
            g_file_query_exists (attachment->priv->tmp_file, NULL)) {
-               retval = ev_attachment_launch_app (attachment, error);
+               retval = ev_attachment_launch_app (attachment, screen,
+                                                  timestamp, error);
        } else {
                GFile *tmpdir;
                GFile *file;
@@ -411,7 +427,8 @@ ev_attachment_open (EvAttachment *attachment,
                                g_object_unref (attachment->priv->tmp_file);
                        attachment->priv->tmp_file = g_object_ref (file);
 
-                       retval = ev_attachment_launch_app (attachment, error);
+                       retval = ev_attachment_launch_app (attachment, screen,
+                                                          timestamp, error);
                }
 
                g_object_unref (file);
index 8403bee869f704e0fed3d695ce38cccef0217c5f..f163c0a3e839254846de57ddf392e284c1ceeddf 100644 (file)
@@ -66,6 +66,8 @@ gboolean     ev_attachment_save                  (EvAttachment *attachment,
                                                  GFile        *file,
                                                  GError      **error);
 gboolean     ev_attachment_open                  (EvAttachment *attachment,
+                                                 GdkScreen    *screen,
+                                                 guint32       timestamp,
                                                  GError      **error);
 
 G_END_DECLS
index fa64fbce9561b4835e0c7a4bd9036903953dca8c..44c027f5baa63bb22981fdefb900a9eea2c05623 100644 (file)
@@ -295,7 +295,10 @@ ev_sidebar_attachments_button_press (EvSidebarAttachments *ev_attachbar,
                                if (!attachment)
                                        return FALSE;
                                
-                               ev_attachment_open (attachment, &error);
+                               ev_attachment_open (attachment,
+                                                   gtk_widget_get_screen (GTK_WIDGET (ev_attachbar)),
+                                                   event->time,
+                                                   &error);
                                
                                if (error) {
                                        g_warning ("%s", error->message);
index 03f98cbbb93c1bf28d8bb5512a16d9fbf657e732..ed64145dcb807af3087e63028d9236390aeb196f 100644 (file)
@@ -5170,18 +5170,21 @@ ev_view_popup_cmd_copy_image (GtkAction *action, EvWindow *window)
 static void
 ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
 {
-       GList *l;
+       GList     *l;
+       GdkScreen *screen;
        
        if (!window->priv->attach_list)
                return;
 
+       screen = gtk_window_get_screen (GTK_WINDOW (window));
+
        for (l = window->priv->attach_list; l && l->data; l = g_list_next (l)) {
                EvAttachment *attachment;
                GError       *error = NULL;
                
                attachment = (EvAttachment *) l->data;
                
-               ev_attachment_open (attachment, &error);
+               ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
 
                if (error) {
                        ev_window_error_message (GTK_WINDOW (window),