+/* Would be nice to have this in gdk-pixbuf */
+static gboolean
+mime_type_supported_by_gdk_pixbuf (const gchar *mime_type)
+{
+ GSList *formats, *list;
+ gboolean retval = FALSE;
+
+ formats = gdk_pixbuf_get_formats ();
+
+ list = formats;
+ while (list) {
+ GdkPixbufFormat *format = list->data;
+ int i;
+ gchar **mime_types;
+
+ if (gdk_pixbuf_format_is_disabled (format))
+ continue;
+
+ mime_types = gdk_pixbuf_format_get_mime_types (format);
+
+ for (i = 0; mime_types[i] != NULL; i++) {
+ if (strcmp (mime_types[i], mime_type) == 0) {
+ retval = TRUE;
+ break;
+ }
+ }
+
+ if (retval)
+ break;
+
+ list = list->next;
+ }
+
+ g_slist_free (formats);
+
+ return retval;
+}
+
+static void
+update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_window)
+{
+ char *title = NULL;
+
+ if (document == NULL) {
+ title = g_strdup (_("Document Viewer"));
+ } else {
+ title = ev_document_get_title (document);
+
+ if (title == NULL) {
+ title = g_path_get_basename (ev_window->priv->uri);
+ }
+ }
+
+ gtk_window_set_title (GTK_WINDOW (ev_window), title);
+
+ g_free (title);
+}
+
+static void
+update_total_pages (EvWindow *ev_window)
+{
+ GtkAction *action;
+ int pages;
+
+ pages = ev_document_get_n_pages (ev_window->priv->document);
+ action = gtk_action_group_get_action
+ (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
+ ev_page_action_set_total_pages (EV_PAGE_ACTION (action), pages);
+}
+
+/* This function assumes that ev_window just had ev_window->document set.
+ */
+static void
+ev_window_setup_document (EvWindow *ev_window)
+{
+ EvDocument *document;
+ EvHistory *history;
+ EvView *view = EV_VIEW (ev_window->priv->view);
+ EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
+ GtkAction *action;
+
+ document = ev_window->priv->document;
+
+ ev_sidebar_set_document (sidebar, document);
+ ev_view_set_document (view, document);
+
+ history = ev_history_new ();
+ ev_view_set_history (view, history);
+ g_object_unref (history);
+
+ action = gtk_action_group_get_action
+ (ev_window->priv->action_group, NAVIGATION_BACK_ACTION);
+ ev_navigation_action_set_history
+ (EV_NAVIGATION_ACTION (action), history);
+
+ action = gtk_action_group_get_action
+ (ev_window->priv->action_group, NAVIGATION_FORWARD_ACTION);
+ ev_navigation_action_set_history
+ (EV_NAVIGATION_ACTION (action), history);
+
+ update_total_pages (ev_window);
+ update_action_sensitivity (ev_window);
+}
+
+
+static gchar *
+ev_window_get_password (GtkWidget *password_dialog)
+{
+ gchar *password = NULL;
+
+ if (gtk_dialog_run (GTK_DIALOG (password_dialog)) == GTK_RESPONSE_OK)
+ password = ev_password_dialog_get_password (password_dialog);
+
+ return password;
+}
+