]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Fixes assertion fail on selecting text. See bug #561393.
[evince.git] / shell / ev-window.c
index e6b0903f1adea9c8baec2653958490c0bd54f6e8..99dece092ffec12f8ecdabf2b65d1bd74c0499bc 100644 (file)
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <gtk/gtk.h>
+#if GTK_CHECK_VERSION (2, 14, 0)
+#include <gtk/gtkunixprint.h>
+#else
 #include <gtk/gtkprintunixdialog.h>
+#endif
 #include <gconf/gconf-client.h>
 
 #include "egg-editable-toolbar.h"
@@ -77,6 +81,7 @@
 #include "ev-sidebar-links.h"
 #include "ev-sidebar-page.h"
 #include "ev-sidebar-thumbnails.h"
+#include "ev-sidebar-layers.h"
 #include "ev-stock-icons.h"
 #include "ev-utils.h"
 #include "ev-view.h"
@@ -125,6 +130,7 @@ struct _EvWindowPrivate {
        GtkWidget *sidebar_thumbs;
        GtkWidget *sidebar_links;
        GtkWidget *sidebar_attachments;
+       GtkWidget *sidebar_layers;
 
        /* Dialogs */
        GtkWidget *properties;
@@ -207,6 +213,7 @@ struct _EvWindowPrivate {
 #define LINKS_SIDEBAR_ID "links"
 #define THUMBNAILS_SIDEBAR_ID "thumbnails"
 #define ATTACHMENTS_SIDEBAR_ID "attachments"
+#define LAYERS_SIDEBAR_ID "layers"
 
 static const gchar *document_print_settings[] = {
        GTK_PRINT_SETTINGS_N_COPIES,
@@ -654,46 +661,66 @@ ev_window_message_area_response_cb (EvMessageArea *area,
 }
 
 static void
-ev_window_error_message (GtkWindow *window, const gchar *msg, GError *error)
+ev_window_error_message (EvWindow    *window,
+                        GError      *error,
+                        const gchar *format,
+                        ...)
 {
        GtkWidget *area;
+       va_list    args;
+       gchar     *msg = NULL;
 
-       if (EV_WINDOW (window)->priv->message_area)
+       if (window->priv->message_area)
                return;
 
+       va_start (args, format);
+       msg = g_strdup_vprintf (format, args);
+       va_end (args);
+       
        area = ev_message_area_new (GTK_MESSAGE_ERROR,
                                    msg,
                                    GTK_STOCK_CLOSE,
                                    GTK_RESPONSE_CANCEL,
                                    NULL);
+       g_free (msg);
+       
        if (error)
                ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message);
        g_signal_connect (area, "response",
                          G_CALLBACK (ev_window_message_area_response_cb),
                          window);
        gtk_widget_show (area);
-       ev_window_set_message_area (EV_WINDOW (window), area);
+       ev_window_set_message_area (window, area);
 }
 
 static void
-ev_window_warning_message (GtkWindow *window, const gchar *msg)
+ev_window_warning_message (EvWindow    *window,
+                          const gchar *format,
+                          ...)
 {
        GtkWidget *area;
+       va_list    args;
+       gchar     *msg = NULL;
 
-       if (EV_WINDOW (window)->priv->message_area)
+       if (window->priv->message_area)
                return;
 
+       va_start (args, format);
+       msg = g_strdup_vprintf (format, args);
+       va_end (args);
+
        area = ev_message_area_new (GTK_MESSAGE_WARNING,
                                    msg,
                                    GTK_STOCK_CLOSE,
                                    GTK_RESPONSE_CANCEL,
                                    NULL);
+       g_free (msg);
        
        g_signal_connect (area, "response",
                          G_CALLBACK (ev_window_message_area_response_cb),
                          window);
        gtk_widget_show (area);
-       ev_window_set_message_area (EV_WINDOW (window), area);
+       ev_window_set_message_area (window, area);
 }
 
 static void
@@ -882,6 +909,7 @@ setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
        GtkWidget *links = window->priv->sidebar_links;
        GtkWidget *thumbs = window->priv->sidebar_thumbs;
        GtkWidget *attachments = window->priv->sidebar_attachments;
+       GtkWidget *layers = window->priv->sidebar_layers;
        GValue sidebar_size = { 0, };
        GValue sidebar_page = { 0, };
        GValue sidebar_visibility = { 0, };
@@ -892,19 +920,29 @@ setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
                g_value_unset(&sidebar_size);
        }
        
-       if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
+       if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, TRUE)) {
                const char *page_id = g_value_get_string (&sidebar_page);
-               
+
                if (strcmp (page_id, LINKS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
                        ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
-               } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+               } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
                        ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
-               } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
+               } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
                        ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
+               } else if (strcmp (page_id, LAYERS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (layers), document)) {
+                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
                }
                g_value_unset (&sidebar_page);
-       } else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
-               ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+       } else if (document) {
+               if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
+                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+               } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+               } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
+                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
+               } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (layers), document)) {
+                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
+               }
        }
 
        if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
@@ -1200,7 +1238,7 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
        if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
                ev_view_set_document (view, document);
        } else {
-               ev_window_warning_message (GTK_WINDOW (ev_window),
+               ev_window_warning_message (ev_window, "%s",
                                           _("The document contains no pages"));
        }
 
@@ -1424,9 +1462,8 @@ ev_window_load_job_cb (EvJob *job,
                
                ev_window_popup_password_dialog (ev_window);
        } else {
-               ev_window_error_message (GTK_WINDOW (ev_window), 
-                                        _("Unable to open document"),
-                                        job->error);
+               ev_window_error_message (ev_window, job->error, 
+                                        "%s", _("Unable to open document"));
                ev_window_clear_load_job (ev_window);
        }       
 }
@@ -1499,9 +1536,8 @@ ev_window_load_remote_failed (EvWindow *ev_window,
 {
        ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
        ev_window->priv->in_reload = FALSE;
-       ev_window_error_message (GTK_WINDOW (ev_window),
-                                _("Unable to open document"),
-                                error);
+       ev_window_error_message (ev_window, error, 
+                                "%s", _("Unable to open document"));
        g_free (ev_window->priv->local_uri);
        ev_window->priv->local_uri = NULL;
 }
@@ -1786,10 +1822,8 @@ ev_window_cmd_file_open_copy_at_dest (EvWindow *window, EvLinkDest *dest)
        new_filename = ev_window_create_tmp_symlink (old_filename, &error);
 
        if (error) {
-               ev_window_error_message (GTK_WINDOW (window),
-                                        _("Cannot open a copy."),
-                                        error);
-
+               ev_window_error_message (window, error, 
+                                        "%s", _("Cannot open a copy."));
                g_error_free (error);
                g_free (old_filename);
                g_free (new_filename);
@@ -2016,7 +2050,6 @@ window_save_file_copy_ready_cb (GFile        *src,
                                GFile        *dst)
 {
        EvWindow  *window;
-       GtkWidget *dialog;
        gchar     *name;
        GError    *error = NULL;
 
@@ -2025,22 +2058,12 @@ window_save_file_copy_ready_cb (GFile        *src,
                return;
        }
 
-       window = g_object_get_data (G_OBJECT (dst), "ev-window");
+       window = EV_WINDOW (g_object_get_data (G_OBJECT (dst), "ev-window"));
        name = g_file_get_basename (dst);
-       dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                        GTK_MESSAGE_ERROR,
-                                        GTK_BUTTONS_CLOSE,
-                                        _("The file could not be saved as “%s”."),
-                                        name);
-       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                 "%s", error->message);
-       g_signal_connect (dialog, "response",
-                         G_CALLBACK (gtk_widget_destroy),
-                         NULL);
-       gtk_widget_show (dialog);
+       ev_window_error_message (window, error,
+                                _("The file could not be saved as “%s”."),
+                                name);
        ev_tmp_file_unlink (src);
-
        g_free (name);
        g_error_free (error);
 }
@@ -2079,12 +2102,9 @@ ev_window_save_job_cb (EvJob     *job,
                       EvWindow  *window)
 {
        if (ev_job_is_failed (job)) {
-               gchar *msg;
-               
-               msg = g_strdup_printf (_("The file could not be saved as “%s”."),
-                                      EV_JOB_SAVE (job)->uri);
-               ev_window_error_message (GTK_WINDOW (window), msg, job->error);
-               g_free (msg);
+               ev_window_error_message (window, job->error,
+                                        _("The file could not be saved as “%s”."),
+                                        EV_JOB_SAVE (job)->uri);
        }
 
        ev_window_clear_save_job (window);
@@ -2241,18 +2261,8 @@ ev_window_print_finished (GtkPrintJob *print_job,
        ev_window_clear_print_job (window);
        
        if (error) {
-               GtkWidget *dialog;
-               
-               dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                                GTK_DIALOG_MODAL,
-                                                GTK_MESSAGE_ERROR,
-                                                GTK_BUTTONS_OK,
-                                                _("Failed to print document"));
-               gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                         "%s", error->message);
-
-               gtk_dialog_run (GTK_DIALOG (dialog));
-               gtk_widget_destroy (dialog);
+               ev_window_error_message (window, error,
+                                        "%s", _("Failed to print document"));
        } else {
                /* If printed successfully, save print settings */
                ev_application_set_print_settings (EV_APP,
@@ -2301,10 +2311,9 @@ ev_window_print_send (EvWindow    *window,
                ev_application_set_print_settings (EV_APP,
                                                   window->priv->print_settings);
                
-#if GTK_CHECK_VERSION (2, 11, 0)
                print_settings_file = ev_tmp_filename ("print-settings");
                gtk_print_settings_to_file (settings, print_settings_file, NULL);
-#endif
+
                uri = g_filename_to_uri (filename, NULL, NULL);
                ev_application_open_uri_at_dest (EV_APP,
                                                 uri, 
@@ -2406,17 +2415,8 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog,
                                              GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
        
        if (!gtk_printer_accepts_ps (window->priv->printer)) {
-               GtkWidget *msgdialog;
-
-               msgdialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
-                                                   GTK_DIALOG_MODAL,
-                                                   GTK_MESSAGE_ERROR,
-                                                   GTK_BUTTONS_OK,
-                                                   _("Printing is not supported on this printer."));
-               
-               gtk_dialog_run (GTK_DIALOG (msgdialog));
-               gtk_widget_destroy (msgdialog);
-
+               ev_window_error_message (window, NULL, "%s",
+                                        _("Printing is not supported on this printer."));
                return FALSE;
        }
 
@@ -3053,8 +3053,6 @@ ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window)
        presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
        if (presentation) {
                ev_window_run_presentation (window);
-       } else {
-               ev_window_stop_presentation (window, TRUE);
        }
 }
 
@@ -3085,11 +3083,7 @@ ev_window_run_preview (EvWindow *window)
        
        action = gtk_action_group_get_action (window->priv->action_group,
                                              "PreviewPrint");
-#if GTK_CHECK_VERSION (2, 11, 0)
        gtk_action_set_visible (action, TRUE);
-#else
-       gtk_action_set_visible (action, FALSE);
-#endif
 
        update_chrome_visibility (window);
 }
@@ -3325,6 +3319,23 @@ ev_window_cmd_view_autoscroll (GtkAction *action, EvWindow *ev_window)
        ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view));
 }
 
+#if GTK_CHECK_VERSION (2, 14, 0)
+static void
+ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
+{
+       GError  *error = NULL;
+
+       gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
+                     "ghelp:evince",
+                     GDK_CURRENT_TIME,
+                     &error);
+       if (error) {
+               ev_window_error_message (ev_window, error, 
+                                        "%s", _("There was an error displaying help"));
+               g_error_free (error);
+       }
+}
+#else /* !GTK_CHECK_VERSION (2, 14, 0) */
 static void
 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
 {
@@ -3373,6 +3384,7 @@ ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
        }
        g_free (command);
 }
+#endif /* GTK_CHECK_VERSION (2, 14, 0) */
 
 static void
 ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
@@ -3416,18 +3428,8 @@ ev_window_preview_print_finished (GtkPrintJob *print_job,
                                  GError      *error)
 {
        if (error) {
-               GtkWidget *dialog;
-
-               dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                                GTK_DIALOG_MODAL,
-                                                GTK_MESSAGE_ERROR,
-                                                GTK_BUTTONS_OK,
-                                                _("Failed to print document"));
-               gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                         "%s", error->message);
-
-               gtk_dialog_run (GTK_DIALOG (dialog));
-               gtk_widget_destroy (dialog);
+               ev_window_error_message (window, error,
+                                        "%s", _("Failed to print document"));
        }
 
        g_object_unref (print_job);
@@ -3482,7 +3484,6 @@ ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
 {
        EvWindowPrivate *priv = window->priv;
        GtkPrintSettings *print_settings = NULL;
-#if GTK_CHECK_VERSION (2, 11, 0)
        const gchar      *print_settings_file = priv->print_settings_file;
 
        if (print_settings_file) {
@@ -3499,7 +3500,6 @@ ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
                        }
                }
        }
-#endif /* GTK 2.11.0 */
        
        if (!print_settings)
                print_settings = gtk_print_settings_new ();
@@ -3833,6 +3833,8 @@ ev_window_sidebar_current_page_changed_cb (EvSidebar  *ev_sidebar,
                id = THUMBNAILS_SIDEBAR_ID;
        } else if (current_page == ev_window->priv->sidebar_attachments) {
                id = ATTACHMENTS_SIDEBAR_ID;
+       } else if (current_page == ev_window->priv->sidebar_layers) {
+               id = LAYERS_SIDEBAR_ID;
        } else {
                g_assert_not_reached();
        }
@@ -4606,6 +4608,13 @@ navigation_action_activate_link_cb (EvNavigationAction *action, EvLink *link, Ev
        gtk_widget_grab_focus (window->priv->view);
 }
 
+static void
+sidebar_layers_visibility_changed (EvSidebarLayers *layers,
+                                  EvWindow        *window)
+{
+       ev_view_reload (EV_VIEW (window->priv->view));
+}
+
 static void
 register_custom_actions (EvWindow *window, GtkActionGroup *group)
 {
@@ -4833,12 +4842,12 @@ static void
 launch_action (EvWindow *window, EvLinkAction *action)
 {
        const char *filename = ev_link_action_get_filename (action);
-       const char *content_type;
        GAppInfo *app_info;
-       GFileInfo *file_info;
        GFile *file;
-       GList *file_list = NULL;
-       
+       GList file_list = {NULL};
+       GAppLaunchContext *context = NULL;
+       GError *error = NULL;
+
        if (filename == NULL)
                return;
 
@@ -4846,34 +4855,43 @@ launch_action (EvWindow *window, EvLinkAction *action)
                file = g_file_new_for_path (filename);
        } else {
                GFile *base_file;
+               gchar *dir;
+
+               dir = g_path_get_dirname (window->priv->uri);
+               base_file = g_file_new_for_uri (dir);
+               g_free (dir);
                
-               base_file = g_file_new_for_uri (window->priv->uri);
-               file = g_file_resolve_relative_path (base_file,
-                                                    filename);
-               
+               file = g_file_resolve_relative_path (base_file, filename);
                g_object_unref (base_file);
        }
-       
-       file_info = g_file_query_info (file,
-                                      G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-                                      0, NULL, NULL);
-       if (file_info == NULL) {
+
+       app_info = g_file_query_default_handler (file, NULL, &error);
+       if (!app_info) {
+               ev_window_error_message (window, error,
+                                        "%s",
+                                        _("Unable to launch external application."));
                g_object_unref (file);
+               g_error_free (error);
+
                return;
        }
-       
-       content_type = g_file_info_get_content_type (file_info);
-       app_info = g_app_info_get_default_for_type (content_type, TRUE);
-       
-       file_list = g_list_append (file_list, file);
 
-       /* FIXME: should we use a GAppLaunchContext? */
-       g_app_info_launch (app_info, file_list,
-                          NULL, NULL);
+#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),
+                                          gtk_window_get_screen (GTK_WINDOW (window)));
+       gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME);
+#endif
+       
+       file_list.data = file;
+       if (!g_app_info_launch (app_info, &file_list, context, &error)) {
+               ev_window_error_message (window, error,
+                                        "%s",
+                                        _("Unable to launch external application."));
+               g_error_free (error);
+       }
        
-       g_list_free (file_list);
        g_object_unref (app_info);
-       g_object_unref (file_info);
        g_object_unref (file);
 
        /* According to the PDF spec filename can be an executable. I'm not sure
@@ -4886,8 +4904,20 @@ 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 (2, 14, 0)
+       GAppLaunchContext *context = NULL;
+#endif
 
-       if (!g_strstr_len (uri, strlen (uri), "://")) {
+#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),
+                                          gtk_window_get_screen (GTK_WINDOW (window)));
+       gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
+                                             GDK_CURRENT_TIME);
+#endif
+
+       if (!g_strstr_len (uri, strlen (uri), "://") &&
+           !g_str_has_prefix (uri, "mailto:")) {
                gchar *http;
                
                /* Not a valid uri, assuming it's http */
@@ -4899,20 +4929,9 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
        }
        
        if (ret == FALSE) {
-               GtkWidget *dialog;
-       
-               dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                                GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                GTK_MESSAGE_ERROR,
-                                                GTK_BUTTONS_CLOSE,
-                                                _("Unable to open external link"));
-               gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                         error->message, uri);
-               g_signal_connect (dialog, "response",
-                                 G_CALLBACK (gtk_widget_destroy),
-                                 NULL);
-               gtk_widget_show (dialog);
-               g_error_free(error);
+               ev_window_error_message (window, error, 
+                                        "%s", _("Unable to open external link"));
+               g_error_free (error);
        }
 }
 
@@ -5065,9 +5084,9 @@ image_save_dialog_response_cb (GtkWidget *fc,
        }
 
        if (format == NULL) {
-               ev_window_error_message (GTK_WINDOW (ev_window),
-                                        _("Couldn't find appropriate format to save image"),
-                                        NULL);
+               ev_window_error_message (ev_window, NULL, 
+                                        "%s",
+                                        _("Couldn't find appropriate format to save image"));
                g_free (uri);
                gtk_widget_destroy (fc);
 
@@ -5105,9 +5124,8 @@ image_save_dialog_response_cb (GtkWidget *fc,
        g_object_unref (pixbuf);
        
        if (error) {
-               ev_window_error_message (GTK_WINDOW (ev_window),
-                                        _("The image could not be saved."),
-                                        error);
+               ev_window_error_message (ev_window, error, 
+                                        "%s", _("The image could not be saved."));
                g_error_free (error);
                g_free (filename);
                g_object_unref (target_file);
@@ -5199,9 +5217,8 @@ ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
                ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
 
                if (error) {
-                       ev_window_error_message (GTK_WINDOW (window),
-                                                _("Unable to open attachment"),
-                                                error);
+                       ev_window_error_message (window, error, 
+                                                "%s", _("Unable to open attachment"));
                        g_error_free (error);
                }
        }
@@ -5251,9 +5268,8 @@ attachment_save_dialog_response_cb (GtkWidget *fc,
                ev_attachment_save (attachment, save_to, &error);
                
                if (error) {
-                       ev_window_error_message (GTK_WINDOW (ev_window),
-                                                _("The attachment could not be saved."),
-                                                error);
+                       ev_window_error_message (ev_window, error, 
+                                                "%s", _("The attachment could not be saved."));
                        g_error_free (error);
                        g_object_unref (save_to);
 
@@ -5418,13 +5434,7 @@ ev_window_init (EvWindow *ev_window)
                g_error_free (error);
        }
        
-#if GTK_CHECK_VERSION(2,11,4)
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
-#else
-       /* It's fine to just use the one of the default screen here */
-       ev_window->priv->recent_manager = gtk_recent_manager_get_for_screen (
-               gdk_screen_get_default ());
-#endif
        ev_window->priv->recent_action_group = NULL;
        ev_window->priv->recent_ui_id = 0;
        g_signal_connect_swapped (ev_window->priv->recent_manager,
@@ -5508,6 +5518,16 @@ ev_window_init (EvWindow *ev_window)
        ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
                             sidebar_widget);
 
+       sidebar_widget = ev_sidebar_layers_new ();
+       ev_window->priv->sidebar_layers = sidebar_widget;
+       g_signal_connect (sidebar_widget,
+                         "layers_visibility_changed",
+                         G_CALLBACK (sidebar_layers_visibility_changed),
+                         ev_window);
+       gtk_widget_show (sidebar_widget);
+       ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
+                            sidebar_widget);
+
        ev_window->priv->view_box = gtk_vbox_new (FALSE, 0);
        ev_window->priv->scrolled_window =
                GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,