+ priv->n_pages = ev_document_get_n_pages (document);
+ priv->rotation = ev_document_model_get_rotation (model);
+ priv->inverted_colors = ev_document_model_get_inverted_colors (model);
+ priv->loading_icons = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)g_object_unref);
+
+ ev_sidebar_thumbnails_clear_model (sidebar_thumbnails);
+ ev_sidebar_thumbnails_fill_model (sidebar_thumbnails);
+
+ /* Create the view widget, and remove the old one, if needed */
+ if (ev_sidebar_thumbnails_use_icon_view (sidebar_thumbnails)) {
+ if (priv->tree_view) {
+ gtk_container_remove (GTK_CONTAINER (priv->swindow), priv->tree_view);
+ priv->tree_view = NULL;
+ }
+
+ if (! priv->icon_view) {
+ ev_sidebar_init_icon_view (sidebar_thumbnails);
+ g_object_notify (G_OBJECT (sidebar_thumbnails), "main_widget");
+ } else {
+ gtk_widget_queue_resize (priv->icon_view);
+ }
+ } else {
+ if (priv->icon_view) {
+ gtk_container_remove (GTK_CONTAINER (priv->swindow), priv->icon_view);
+ priv->icon_view = NULL;
+ }
+
+ if (! priv->tree_view) {
+ ev_sidebar_init_tree_view (sidebar_thumbnails);
+ g_object_notify (G_OBJECT (sidebar_thumbnails), "main_widget");
+ }
+ }
+
+ /* Connect to the signal and trigger a fake callback */
+ g_signal_connect_swapped (priv->model, "page-changed",
+ G_CALLBACK (page_changed_cb),
+ sidebar_thumbnails);
+ g_signal_connect (priv->model, "notify::rotation",
+ G_CALLBACK (ev_sidebar_thumbnails_rotation_changed_cb),
+ sidebar_thumbnails);
+ g_signal_connect (priv->model, "notify::inverted-colors",
+ G_CALLBACK (ev_sidebar_thumbnails_inverted_colors_changed_cb),
+ sidebar_thumbnails);
+ sidebar_thumbnails->priv->start_page = -1;
+ sidebar_thumbnails->priv->end_page = -1;
+ ev_sidebar_thumbnails_set_current_page (sidebar_thumbnails,
+ ev_document_model_get_page (model));
+ adjustment_changed_cb (sidebar_thumbnails);
+}
+
+static void
+ev_sidebar_thumbnails_set_model (EvSidebarPage *sidebar_page,
+ EvDocumentModel *model)
+{
+ EvSidebarThumbnails *sidebar_thumbnails = EV_SIDEBAR_THUMBNAILS (sidebar_page);
+ EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv;
+
+ if (priv->model == model)
+ return;
+
+ priv->model = model;
+ g_signal_connect (model, "notify::document",
+ G_CALLBACK (ev_sidebar_thumbnails_document_changed_cb),
+ sidebar_page);
+}
+
+static gboolean
+ev_sidebar_thumbnails_clear_job (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ EvJob *job;
+
+ gtk_tree_model_get (model, iter, COLUMN_JOB, &job, -1);
+
+ if (job != NULL) {
+ ev_job_cancel (job);
+ g_signal_handlers_disconnect_by_func (job, thumbnail_job_completed_callback, data);
+ g_object_unref (job);
+ }
+
+ return FALSE;
+}
+
+static void
+ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar_thumbnails)
+{
+ EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv;
+
+ gtk_tree_model_foreach (GTK_TREE_MODEL (priv->list_store), ev_sidebar_thumbnails_clear_job, sidebar_thumbnails);
+ gtk_list_store_clear (priv->list_store);
+}
+
+static gboolean
+ev_sidebar_thumbnails_support_document (EvSidebarPage *sidebar_page,
+ EvDocument *document)
+{
+ return TRUE;