]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
[libdocument] Do not require GAppInfo to support uris when opening an attachment
[evince.git] / shell / ev-window.c
index c55c9f80650f7e479cf832abdd2d21e9f8dcdb62..02a3087784f0d5975d1093288943ac0e32084b5f 100644 (file)
@@ -206,6 +206,9 @@ struct _EvWindowPrivate {
        GtkPrintSettings *print_settings;
        GtkPageSetup     *print_page_setup;
        gboolean          close_after_print;
        GtkPrintSettings *print_settings;
        GtkPageSetup     *print_page_setup;
        gboolean          close_after_print;
+#ifdef WITH_GCONF
+       GConfClient *gconf_client;
+#endif
 };
 
 #define EV_WINDOW_GET_PRIVATE(object) \
 };
 
 #define EV_WINDOW_GET_PRIVATE(object) \
@@ -215,9 +218,11 @@ struct _EvWindowPrivate {
 #define ZOOM_CONTROL_ACTION    "ViewZoom"
 #define NAVIGATION_ACTION      "Navigation"
 
 #define ZOOM_CONTROL_ACTION    "ViewZoom"
 #define NAVIGATION_ACTION      "Navigation"
 
+#define GCONF_LOCKDOWN_DIR          "/desktop/gnome/lockdown"
 #define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
 #define GCONF_LOCKDOWN_SAVE         "/desktop/gnome/lockdown/disable_save_to_disk"
 #define GCONF_LOCKDOWN_PRINT        "/desktop/gnome/lockdown/disable_printing"
 #define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
 #define GCONF_LOCKDOWN_SAVE         "/desktop/gnome/lockdown/disable_save_to_disk"
 #define GCONF_LOCKDOWN_PRINT        "/desktop/gnome/lockdown/disable_printing"
+#define GCONF_LOCKDOWN_PRINT_SETUP  "/desktop/gnome/lockdown/disable_print_setup"
 
 #define PRESENTATION_TIMEOUT 5
 
 
 #define PRESENTATION_TIMEOUT 5
 
@@ -335,18 +340,15 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
 {
        EvDocument *document = ev_window->priv->document;
        const EvDocumentInfo *info = NULL;
 {
        EvDocument *document = ev_window->priv->document;
        const EvDocumentInfo *info = NULL;
-
        gboolean has_document = FALSE;
        gboolean ok_to_print = TRUE;
        gboolean has_document = FALSE;
        gboolean ok_to_print = TRUE;
+       gboolean ok_to_print_setup = TRUE;
        gboolean ok_to_copy = TRUE;
        gboolean has_properties = TRUE;
        gboolean override_restrictions = TRUE;
        gboolean can_get_text = FALSE;
        gboolean has_pages = FALSE;
        gboolean can_find = FALSE;
        gboolean ok_to_copy = TRUE;
        gboolean has_properties = TRUE;
        gboolean override_restrictions = TRUE;
        gboolean can_get_text = FALSE;
        gboolean has_pages = FALSE;
        gboolean can_find = FALSE;
-#ifdef WITH_GCONF
-       GConfClient *client;
-#endif
 
        if (document) {
                has_document = TRUE;
 
        if (document) {
                has_document = TRUE;
@@ -367,10 +369,10 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
        }
 
 #ifdef WITH_GCONF
        }
 
 #ifdef WITH_GCONF
-       client = gconf_client_get_default ();
-       override_restrictions = gconf_client_get_bool (client, 
-                                                      GCONF_OVERRIDE_RESTRICTIONS, 
-                                                      NULL);
+       if (has_document)
+               override_restrictions = gconf_client_get_bool (ev_window->priv->gconf_client,
+                                                              GCONF_OVERRIDE_RESTRICTIONS,
+                                                              NULL);
 #endif
        if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
                ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
 #endif
        if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
                ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
@@ -381,21 +383,28 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
                ok_to_print = FALSE;
 
 #ifdef WITH_GCONF
                ok_to_print = FALSE;
 
 #ifdef WITH_GCONF
-       if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) {
+       if (has_document &&
+           gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_SAVE, NULL)) {
                ok_to_copy = FALSE;
        }
 
                ok_to_copy = FALSE;
        }
 
-       if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) {
+       if (has_document &&
+           gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT, NULL)) {
                ok_to_print = FALSE;
        }
 
                ok_to_print = FALSE;
        }
 
-       g_object_unref (client);
+       if (has_document &&
+           gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT_SETUP, NULL)) {
+               ok_to_print_setup = FALSE;
+       }
 #endif
 
        /* File menu */
        ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
        ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
 #endif
 
        /* File menu */
        ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
        ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
-       ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print);
+#if !GTK_CHECK_VERSION (2, 17, 4)
+       ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print && ok_to_print_setup);
+#endif
        ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
        ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
 
        ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
        ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
 
@@ -1156,6 +1165,17 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
        ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE);
 }
 
        ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE);
 }
 
+#ifdef WITH_GCONF
+static void
+lockdown_changed (GConfClient *client,
+                 guint        cnxn_id,
+                 GConfEntry  *entry,
+                 EvWindow    *ev_window)
+{
+       ev_window_setup_action_sensitivity (ev_window);
+}
+#endif /* WITH_GCONF */
+
 static gboolean
 ev_window_setup_document (EvWindow *ev_window)
 {
 static gboolean
 ev_window_setup_document (EvWindow *ev_window)
 {
@@ -1171,6 +1191,27 @@ ev_window_setup_document (EvWindow *ev_window)
        ev_window_title_set_document (ev_window->priv->title, document);
        ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
 
        ev_window_title_set_document (ev_window->priv->title, document);
        ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
 
+#ifdef WITH_GCONF
+       if (!ev_window->priv->gconf_client)
+               ev_window->priv->gconf_client = gconf_client_get_default ();
+       gconf_client_add_dir (ev_window->priv->gconf_client,
+                             GCONF_LOCKDOWN_DIR,
+                             GCONF_CLIENT_PRELOAD_ONELEVEL,
+                             NULL);
+       gconf_client_add_dir (ev_window->priv->gconf_client,
+                             GCONF_OVERRIDE_RESTRICTIONS,
+                             GCONF_CLIENT_PRELOAD_NONE,
+                             NULL);
+       gconf_client_notify_add (ev_window->priv->gconf_client,
+                                GCONF_LOCKDOWN_DIR,
+                                (GConfClientNotifyFunc)lockdown_changed,
+                                ev_window, NULL, NULL);
+       gconf_client_notify_add (ev_window->priv->gconf_client,
+                                GCONF_OVERRIDE_RESTRICTIONS,
+                                (GConfClientNotifyFunc)lockdown_changed,
+                                ev_window, NULL, NULL);
+#endif /* WITH_GCONF */
+
        ev_window_setup_action_sensitivity (ev_window);
 
        if (ev_window->priv->history)
        ev_window_setup_action_sensitivity (ev_window);
 
        if (ev_window->priv->history)
@@ -1708,26 +1749,39 @@ ev_window_load_file_remote (EvWindow *ev_window,
        GFile *target_file;
        
        if (!ev_window->priv->local_uri) {
        GFile *target_file;
        
        if (!ev_window->priv->local_uri) {
-               gchar *tmp_name;
-               gchar *base_name;
+               char *base_name, *template;
+                GFile *tmp_file;
+                GError *err = NULL;
 
                /* We'd like to keep extension of source uri since
 
                /* We'd like to keep extension of source uri since
-                * it helps to resolve some mime types, say cbz */
-               tmp_name = ev_tmp_filename (NULL);
+                * it helps to resolve some mime types, say cbz.
+                 */
                base_name = g_file_get_basename (source_file);
                base_name = g_file_get_basename (source_file);
-               ev_window->priv->local_uri = g_strconcat ("file:", tmp_name, "-",
-                                                         base_name, NULL);
+                template = g_strdup_printf ("document.XXXXXX-%s", base_name);
+                g_free (base_name);
+
+                tmp_file = ev_mkstemp_file (template, &err);
+               g_free (template);
+                if (tmp_file == NULL) {
+                        ev_window_error_message (ev_window, err,
+                                                 "%s", _("Failed to load remote file."));
+                        g_error_free (err);
+                        return;
+                }
+
+               ev_window->priv->local_uri = g_file_get_uri (tmp_file);
+               g_object_unref (tmp_file);
+
                ev_job_load_set_uri (EV_JOB_LOAD (ev_window->priv->load_job),
                                     ev_window->priv->local_uri);
                ev_job_load_set_uri (EV_JOB_LOAD (ev_window->priv->load_job),
                                     ev_window->priv->local_uri);
-               g_free (base_name);
-               g_free (tmp_name);
        }
 
        ev_window_reset_progress_cancellable (ev_window);
        
        target_file = g_file_new_for_uri (ev_window->priv->local_uri);
        g_file_copy_async (source_file, target_file,
        }
 
        ev_window_reset_progress_cancellable (ev_window);
        
        target_file = g_file_new_for_uri (ev_window->priv->local_uri);
        g_file_copy_async (source_file, target_file,
-                          0, G_PRIORITY_DEFAULT,
+                          G_FILE_COPY_OVERWRITE,
+                          G_PRIORITY_DEFAULT,
                           ev_window->priv->progress_cancellable,
                           (GFileProgressCallback)window_open_file_copy_progress_cb,
                           ev_window, 
                           ev_window->priv->progress_cancellable,
                           (GFileProgressCallback)window_open_file_copy_progress_cb,
                           ev_window, 
@@ -2064,7 +2118,7 @@ file_open_dialog_response_cb (GtkWidget *chooser,
 
                ev_application_open_uri_list (EV_APP, uris,
                                              gtk_window_get_screen (GTK_WINDOW (ev_window)),
 
                ev_application_open_uri_list (EV_APP, uris,
                                              gtk_window_get_screen (GTK_WINDOW (ev_window)),
-                                             GDK_CURRENT_TIME);
+                                             gtk_get_current_event_time ());
 
                g_slist_foreach (uris, (GFunc)g_free, NULL);
                g_slist_free (uris);
 
                g_slist_foreach (uris, (GFunc)g_free, NULL);
                g_slist_free (uris);
@@ -2166,7 +2220,7 @@ ev_window_cmd_recent_file_activate (GtkAction *action,
        
        ev_application_open_uri_at_dest (EV_APP, uri,
                                         gtk_window_get_screen (GTK_WINDOW (window)),
        
        ev_application_open_uri_at_dest (EV_APP, uri,
                                         gtk_window_get_screen (GTK_WINDOW (window)),
-                                        NULL, 0, NULL, GDK_CURRENT_TIME);
+                                        NULL, 0, NULL, gtk_get_current_event_time ());
 }
 
 static void
 }
 
 static void
@@ -2176,7 +2230,7 @@ ev_window_open_recent_action_item_activated (EvOpenRecentAction *action,
 {
        ev_application_open_uri_at_dest (EV_APP, uri,
                                         gtk_window_get_screen (GTK_WINDOW (window)),
 {
        ev_application_open_uri_at_dest (EV_APP, uri,
                                         gtk_window_get_screen (GTK_WINDOW (window)),
-                                        NULL, 0, NULL, GDK_CURRENT_TIME);
+                                        NULL, 0, NULL, gtk_get_current_event_time ());
 }
 
 static void
 }
 
 static void
@@ -2606,24 +2660,25 @@ get_print_settings_file (void)
 {
        GKeyFile *print_settings_file;
        gchar    *filename;
 {
        GKeyFile *print_settings_file;
        gchar    *filename;
+        GError *error = NULL;
 
        print_settings_file = g_key_file_new ();
 
 
        print_settings_file = g_key_file_new ();
 
-       filename = g_build_filename (ev_application_get_dot_dir (EV_APP),
-                                    EV_PRINT_SETTINGS_FILE, NULL);
-       if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
-               GError *error = NULL;
-
-               g_key_file_load_from_file (print_settings_file,
-                                          filename,
-                                          G_KEY_FILE_KEEP_COMMENTS |
-                                          G_KEY_FILE_KEEP_TRANSLATIONS,
-                                          &error);
-               if (error) {
+       filename = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE),
+                                     EV_PRINT_SETTINGS_FILE, NULL);
+        if (!g_key_file_load_from_file (print_settings_file,
+                                        filename,
+                                        G_KEY_FILE_KEEP_COMMENTS |
+                                        G_KEY_FILE_KEEP_TRANSLATIONS,
+                                        &error)) {
+
+                /* Don't warn if the file simply doesn't exist */
+                if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
                        g_warning ("%s", error->message);
                        g_warning ("%s", error->message);
-                       g_error_free (error);
-               }
+
+                g_error_free (error);
        }
        }
+
        g_free (filename);
 
        return print_settings_file;
        g_free (filename);
 
        return print_settings_file;
@@ -2634,15 +2689,15 @@ save_print_setting_file (GKeyFile *key_file)
 {
        gchar  *filename;
        gchar  *data;
 {
        gchar  *filename;
        gchar  *data;
-       gssize  data_length;
+       gsize  data_length;
        GError *error = NULL;
 
        GError *error = NULL;
 
-       filename = g_build_filename (ev_application_get_dot_dir (EV_APP),
+       filename = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE),
                                     EV_PRINT_SETTINGS_FILE, NULL);
                                     EV_PRINT_SETTINGS_FILE, NULL);
-       data = g_key_file_to_data (key_file, (gsize *)&data_length, NULL);
+       data = g_key_file_to_data (key_file, &data_length, NULL);
        g_file_set_contents (filename, data, data_length, &error);
        if (error) {
        g_file_set_contents (filename, data, data_length, &error);
        if (error) {
-               g_warning ("%s", error->message);
+               g_warning ("Failed to save print settings: %s", error->message);
                g_error_free (error);
        }
        g_free (data);
                g_error_free (error);
        }
        g_free (data);
@@ -2896,6 +2951,13 @@ ev_window_print_operation_done (EvPrintOperation       *op,
 
                print_settings = ev_print_operation_get_print_settings (op);
                ev_window_save_print_settings (ev_window, print_settings);
 
                print_settings = ev_print_operation_get_print_settings (op);
                ev_window_save_print_settings (ev_window, print_settings);
+
+               if (ev_print_operation_get_embed_page_setup (op)) {
+                       GtkPageSetup *page_setup;
+
+                       page_setup = ev_print_operation_get_default_page_setup (op);
+                       ev_window_save_print_page_setup (ev_window, page_setup);
+               }
        }
 
                break;
        }
 
                break;
@@ -3069,6 +3131,13 @@ ev_window_print_range (EvWindow *ev_window,
        ev_print_operation_set_current_page (op, current_page);
        ev_print_operation_set_print_settings (op, print_settings);
        ev_print_operation_set_default_page_setup (op, print_page_setup);
        ev_print_operation_set_current_page (op, current_page);
        ev_print_operation_set_print_settings (op, print_settings);
        ev_print_operation_set_default_page_setup (op, print_page_setup);
+#ifdef WITH_GCONF
+       ev_print_operation_set_embed_page_setup (op, !gconf_client_get_bool (ev_window->priv->gconf_client,
+                                                                            GCONF_LOCKDOWN_PRINT_SETUP,
+                                                                            NULL));
+#else
+       ev_print_operation_set_embed_page_setup (op, TRUE);
+#endif
 
        g_object_unref (print_settings);
        g_object_unref (print_page_setup);
 
        g_object_unref (print_settings);
        g_object_unref (print_page_setup);
@@ -3790,7 +3859,7 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog,
        toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar);
         egg_editable_toolbar_set_edit_mode (toolbar, FALSE);
 
        toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar);
         egg_editable_toolbar_set_edit_mode (toolbar, FALSE);
 
-       toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP),
+       toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE),
                                          "evince_toolbar.xml", NULL);
        egg_toolbars_model_save_toolbars (egg_editable_toolbar_get_model (toolbar),
                                          toolbars_file, "1.0");
                                          "evince_toolbar.xml", NULL);
        egg_toolbars_model_save_toolbars (egg_editable_toolbar_get_model (toolbar),
                                          toolbars_file, "1.0");
@@ -3934,7 +4003,7 @@ ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
 
        gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
                      "ghelp:evince",
 
        gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
                      "ghelp:evince",
-                     GDK_CURRENT_TIME,
+                     gtk_get_current_event_time (),
                      &error);
        if (error) {
                ev_window_error_message (ev_window, error, 
                      &error);
        if (error) {
                ev_window_error_message (ev_window, error, 
@@ -4648,13 +4717,13 @@ ev_window_drag_data_received (GtkWidget        *widget,
 static void
 ev_window_finalize (GObject *object)
 {
 static void
 ev_window_finalize (GObject *object)
 {
+       G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
+
        if (ev_window_n_copies == 0) {
                ev_application_shutdown (EV_APP);
        } else {
                ev_window_n_copies--;
        }
        if (ev_window_n_copies == 0) {
                ev_application_shutdown (EV_APP);
        } else {
                ev_window_n_copies--;
        }
-
-       G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
 }
 
 static void
 }
 
 static void
@@ -4679,7 +4748,14 @@ ev_window_dispose (GObject *object)
                g_source_remove (priv->setup_document_idle);
                priv->setup_document_idle = 0;
        }
                g_source_remove (priv->setup_document_idle);
                priv->setup_document_idle = 0;
        }
-       
+
+#ifdef WITH_GCONF
+       if (priv->gconf_client) {
+               g_object_unref (priv->gconf_client);
+               priv->gconf_client = NULL;
+       }
+#endif
+
        if (priv->monitor) {
                g_object_unref (priv->monitor);
                priv->monitor = NULL;
        if (priv->monitor) {
                g_object_unref (priv->monitor);
                priv->monitor = NULL;
@@ -5028,6 +5104,10 @@ static const GtkActionEntry entries[] = {
           G_CALLBACK (ev_window_cmd_scroll_forward) },
         { "ShiftReturn", NULL, "", "<shift>Return", NULL,
           G_CALLBACK (ev_window_cmd_scroll_backward) },
           G_CALLBACK (ev_window_cmd_scroll_forward) },
         { "ShiftReturn", NULL, "", "<shift>Return", NULL,
           G_CALLBACK (ev_window_cmd_scroll_backward) },
+       { "p", GTK_STOCK_GO_UP, "", "p", NULL,
+         G_CALLBACK (ev_window_cmd_go_previous_page) },
+       { "n", GTK_STOCK_GO_DOWN, "", "n", NULL,
+         G_CALLBACK (ev_window_cmd_go_next_page) },
         { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus", NULL,
           G_CALLBACK (ev_window_cmd_view_zoom_in) },
         { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal", NULL,
         { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus", NULL,
           G_CALLBACK (ev_window_cmd_view_zoom_in) },
         { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal", NULL,
@@ -5395,7 +5475,8 @@ launch_action (EvWindow *window, EvLinkAction *action)
        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)));
        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)));
-       gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME);
+       gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
+                                              gtk_get_current_event_time ());
        
        file_list.data = file;
        if (!g_app_info_launch (app_info, &file_list, context, &error)) {
        
        file_list.data = file;
        if (!g_app_info_launch (app_info, &file_list, context, &error)) {
@@ -5407,6 +5488,7 @@ launch_action (EvWindow *window, EvLinkAction *action)
        
        g_object_unref (app_info);
        g_object_unref (file);
        
        g_object_unref (app_info);
        g_object_unref (file);
+        /* FIXMEchpe: unref launch context? */
 
        /* According to the PDF spec filename can be an executable. I'm not sure
           allowing to launch executables is a good idea though. -- marco */
 
        /* According to the PDF spec filename can be an executable. I'm not sure
           allowing to launch executables is a good idea though. -- marco */
@@ -5424,7 +5506,7 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
        gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
                                           gtk_window_get_screen (GTK_WINDOW (window)));
        gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
        gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
                                           gtk_window_get_screen (GTK_WINDOW (window)));
        gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
-                                             GDK_CURRENT_TIME);
+                                             gtk_get_current_event_time ());
 
        if (!g_strstr_len (uri, strlen (uri), "://") &&
            !g_str_has_prefix (uri, "mailto:")) {
 
        if (!g_strstr_len (uri, strlen (uri), "://") &&
            !g_str_has_prefix (uri, "mailto:")) {
@@ -5432,10 +5514,10 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
                
                /* Not a valid uri, assuming it's http */
                http = g_strdup_printf ("http://%s", uri);
                
                /* Not a valid uri, assuming it's http */
                http = g_strdup_printf ("http://%s", uri);
-               ret = g_app_info_launch_default_for_uri (http, NULL, &error);
+               ret = g_app_info_launch_default_for_uri (http, context, &error);
                g_free (http);
        } else {
                g_free (http);
        } else {
-               ret = g_app_info_launch_default_for_uri (uri, NULL, &error);
+               ret = g_app_info_launch_default_for_uri (uri, context, &error);
        }
        
        if (ret == FALSE) {
        }
        
        if (ret == FALSE) {
@@ -5443,6 +5525,8 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
                                         "%s", _("Unable to open external link"));
                g_error_free (error);
        }
                                         "%s", _("Unable to open external link"));
                g_error_free (error);
        }
+
+        /* FIXMEchpe: unref launch context? */
 }
 
 static void
 }
 
 static void
@@ -5462,7 +5546,7 @@ open_remote_link (EvWindow *window, EvLinkAction *action)
                                         ev_link_action_get_dest (action),
                                         0,
                                         NULL, 
                                         ev_link_action_get_dest (action),
                                         0,
                                         NULL, 
-                                        GDK_CURRENT_TIME);
+                                        gtk_get_current_event_time ());
 
        g_free (uri);
 }
 
        g_free (uri);
 }
@@ -5629,7 +5713,9 @@ image_save_dialog_response_cb (GtkWidget *fc,
        if (is_native) {
                filename = g_file_get_path (target_file);
        } else {
        if (is_native) {
                filename = g_file_get_path (target_file);
        } else {
-               filename = ev_tmp_filename ("saveimage");
+                /* Create a temporary local file to save to */
+                if (ev_mkstemp ("saveimage.XXXXXX", &filename, &error) == -1)
+                        goto has_error;
        }
 
        ev_document_doc_mutex_lock ();
        }
 
        ev_document_doc_mutex_lock ();
@@ -5642,6 +5728,7 @@ image_save_dialog_response_cb (GtkWidget *fc,
        g_free (file_format);
        g_object_unref (pixbuf);
        
        g_free (file_format);
        g_object_unref (pixbuf);
        
+    has_error:
        if (error) {
                ev_window_error_message (ev_window, error, 
                                         "%s", _("The image could not be saved."));
        if (error) {
                ev_window_error_message (ev_window, error, 
                                         "%s", _("The image could not be saved."));
@@ -5739,7 +5826,7 @@ ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
                
                attachment = (EvAttachment *) l->data;
                
                
                attachment = (EvAttachment *) l->data;
                
-               ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
+               ev_attachment_open (attachment, screen, gtk_get_current_event_time (), &error);
 
                if (error) {
                        ev_window_error_message (window, error, 
 
                if (error) {
                        ev_window_error_message (window, error, 
@@ -5774,7 +5861,7 @@ attachment_save_dialog_response_cb (GtkWidget *fc,
        
        for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
                EvAttachment *attachment;
        
        for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
                EvAttachment *attachment;
-               GFile        *save_to;
+               GFile        *save_to = NULL;
                GError       *error = NULL;
                
                attachment = (EvAttachment *) l->data;
                GError       *error = NULL;
                
                attachment = (EvAttachment *) l->data;
@@ -5782,15 +5869,17 @@ attachment_save_dialog_response_cb (GtkWidget *fc,
                if (is_native) {
                        if (is_dir) {
                                save_to = g_file_get_child (target_file,
                if (is_native) {
                        if (is_dir) {
                                save_to = g_file_get_child (target_file,
+                                    /* FIXMEchpe: file name encoding! */
                                                            ev_attachment_get_name (attachment));
                        } else {
                                save_to = g_object_ref (target_file);
                        }
                } else {
                                                            ev_attachment_get_name (attachment));
                        } else {
                                save_to = g_object_ref (target_file);
                        }
                } else {
-                       save_to = ev_tmp_file_get ("saveattachment");
+                       save_to = ev_mkstemp_file ("saveattachment.XXXXXX", &error);
                }
 
                }
 
-               ev_attachment_save (attachment, save_to, &error);
+                if (save_to)
+                        ev_attachment_save (attachment, save_to, &error);
                
                if (error) {
                        ev_window_error_message (ev_window, error, 
                
                if (error) {
                        ev_window_error_message (ev_window, error, 
@@ -5906,7 +5995,7 @@ get_toolbars_model (void)
 
        toolbars_model = egg_toolbars_model_new ();
 
 
        toolbars_model = egg_toolbars_model_new ();
 
-       toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP),
+       toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE),
                                          "evince_toolbar.xml", NULL);
        toolbars_path = g_build_filename (ev_application_get_data_dir (EV_APP),
                                         "evince-toolbar.xml", NULL);
                                          "evince_toolbar.xml", NULL);
        toolbars_path = g_build_filename (ev_application_get_data_dir (EV_APP),
                                         "evince-toolbar.xml", NULL);
@@ -5914,8 +6003,8 @@ get_toolbars_model (void)
 
        if (!egg_toolbars_model_load_toolbars (toolbars_model, toolbars_file)) {
                egg_toolbars_model_load_toolbars (toolbars_model, toolbars_path);
 
        if (!egg_toolbars_model_load_toolbars (toolbars_model, toolbars_file)) {
                egg_toolbars_model_load_toolbars (toolbars_model, toolbars_path);
+                goto skip_conversion;
        }
        }
-       g_free (toolbars_path);
 
        /* Open item doesn't exist anymore,
         * convert it to OpenRecent for compatibility
 
        /* Open item doesn't exist anymore,
         * convert it to OpenRecent for compatibility
@@ -5932,7 +6021,10 @@ get_toolbars_model (void)
                        break;
                }
        }
                        break;
                }
        }
+
+    skip_conversion:
        g_free (toolbars_file);
        g_free (toolbars_file);
+       g_free (toolbars_path);
 
        egg_toolbars_model_set_flags (toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE);
 
 
        egg_toolbars_model_set_flags (toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE);
 
@@ -6015,7 +6107,17 @@ ev_window_init (EvWindow *ev_window)
                g_error_free (error);
        }
        g_free (ui_path);
                g_error_free (error);
        }
        g_free (ui_path);
-       
+
+#if GTK_CHECK_VERSION (2, 17, 4)
+       {
+               GtkAction *action;
+
+               action = gtk_action_group_get_action (ev_window->priv->action_group,
+                                                     "FilePageSetup");
+               g_object_set (action, "visible", FALSE, "sensitive", FALSE, NULL);
+       }
+#endif
+
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
        ev_window->priv->recent_action_group = NULL;
        ev_window->priv->recent_ui_id = 0;
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
        ev_window->priv->recent_action_group = NULL;
        ev_window->priv->recent_ui_id = 0;