#include "ev-document-links.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
+#include "ev-job-queue.h"
#include "eggfindbar.h"
-#include "pdf-document.h"
+#include "ev-poppler.h"
#include "pixbuf-document.h"
#include "ps-document.h"
char *uri;
EvDocument *document;
+ EvPageCache *page_cache;
EvWindowPageMode page_mode;
/* These members are used temporarily when in PAGE_MODE_PASSWORD */
document = ev_window->priv->document;
page_mode = ev_window->priv->page_mode;
-
view = EV_VIEW (ev_window->priv->view);
/* File menu */
if (document) {
int n_pages;
int page;
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+ n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
- page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
- n_pages = ev_document_get_n_pages (document);
-
- set_action_sensitive (ev_window, "GoPreviousPage", page > 1);
- set_action_sensitive (ev_window, "GoNextPage", page < n_pages);
- set_action_sensitive (ev_window, "GoFirstPage", page > 1);
- set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
+ set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
+ set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
+ set_action_sensitive (ev_window, "GoFirstPage", page > 0);
+ set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
} else {
set_action_sensitive (ev_window, "GoFirstPage", FALSE);
set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
void
ev_window_open_page (EvWindow *ev_window, int page)
{
- ev_view_set_page (EV_VIEW (ev_window->priv->view), page);
+ if (ev_window->priv->page_cache)
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
}
void
gboolean password_needed;
password_needed = (ev_window->priv->password_document != NULL);
-
if (document) {
- doc_title = ev_document_get_title (document);
+ doc_title = ev_page_cache_get_title (ev_window->priv->page_cache);
/* Make sure we get a valid title back */
if (doc_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 gboolean
document_supports_sidebar (EvDocument *document)
{
- return (EV_IS_DOCUMENT_THUMBNAILS (document) && EV_IS_DOCUMENT_LINKS (document));
+ return (EV_IS_DOCUMENT_THUMBNAILS (document) && (EV_IS_DOCUMENT_LINKS (document)));
}
static void
}
+static void
+page_changed_cb (EvPageCache *page_cache,
+ gint page,
+ EvWindow *ev_window)
+{
+ update_action_sensitivity (ev_window);
+}
+
+
static void
ev_window_setup_document (EvWindow *ev_window)
{
EvDocument *document;
EvView *view = EV_VIEW (ev_window->priv->view);
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
+ GtkAction *action;
document = ev_window->priv->document;
+ ev_window->priv->page_cache = ev_document_get_page_cache (ev_window->priv->document);
+ g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
g_signal_connect_object (G_OBJECT (document),
"notify::title",
ev_sidebar_set_document (sidebar, document);
else
hide_sidebar_and_actions (ev_window);
+
ev_view_set_document (view, document);
update_window_title (document, NULL, ev_window);
- update_total_pages (ev_window);
+ action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
+ ev_page_action_set_document (EV_PAGE_ACTION (action), document);
update_action_sensitivity (ev_window);
}
gchar *uri;
password = ev_password_dialog_get_password (password_dialog);
- if (password)
+ if (password) {
+ g_mutex_lock (EV_DOC_MUTEX);
ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->password_document),
password);
+ g_mutex_unlock (EV_DOC_MUTEX);
+ }
g_free (password);
document = ev_window->priv->password_document;
GtkWidget *fc;
GtkFileFilter *pdf_filter, *all_filter;
gchar *uri = NULL;
+ gboolean success;
fc = gtk_file_chooser_dialog_new (
_("Save a Copy"),
!overwrite_existing_file (GTK_WINDOW (fc), uri))
continue;
*/
+
+ g_mutex_lock (EV_DOC_MUTEX);
+ success = ev_document_save (ev_window->priv->document, uri, NULL);
+ g_mutex_unlock (EV_DOC_MUTEX);
- if (ev_document_save (ev_window->priv->document, uri, NULL))
+ if (success)
break;
else
save_error_dialog (GTK_WINDOW (fc), uri);
config = gnome_print_config_default ();
job = gnome_print_job_new (config);
- print_dialog = gnome_print_dialog_new (job, _("Print"),
+ print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
(GNOME_PRINT_DIALOG_RANGE |
GNOME_PRINT_DIALOG_COPIES));
gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
GTK_MESSAGE_DIALOG (dialog),
_("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
gnome_print_config_get (
- config, "Settings.Engine.Backend.Driver"));
+ config, (guchar *)"Settings.Engine.Backend.Driver"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
} else {
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
- egg_find_bar_grab_focus (EGG_FIND_BAR (ev_window->priv->find_bar));
+ gtk_widget_grab_focus (ev_window->priv->find_bar);
}
}
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view),
- ev_view_get_page (EV_VIEW (ev_window->priv->view)) - 1);
+ ev_page_cache_prev_page (ev_window->priv->page_cache);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view),
- ev_view_get_page (EV_VIEW (ev_window->priv->view)) + 1);
+ ev_page_cache_next_page (ev_window->priv->page_cache);
}
static void
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view), 1);
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, 0);
}
static void
ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
{
+ int n_pages;
+
g_return_if_fail (EV_IS_WINDOW (ev_window));
- ev_view_set_page (EV_VIEW (ev_window->priv->view), G_MAXINT);
+ n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, n_pages - 1);
}
static void
g_return_if_fail (EV_IS_WINDOW (ev_window));
- page = ev_document_get_page (ev_window->priv->document);
+#if 0
+ /* FIXME: uncomment when this is written.*/
+ page = ev_page_cache_get_page (ev_window->priv->page_cache);
+#else
+ page = 1;
+#endif
uri = g_strdup (ev_window->priv->uri);
ev_window_open (ev_window, uri);
}
}
-static void
-update_current_page (EvWindow *ev_window,
- EvView *view)
-{
- int page;
- GtkAction *action;
- EvSidebarThumbnails *thumbs;
-
- thumbs = EV_SIDEBAR_THUMBNAILS (ev_window->priv->thumbs_sidebar);
- ev_sidebar_thumbnails_select_page (thumbs, ev_view_get_page (view));
-
- action = gtk_action_group_get_action
- (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
-
- page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
- ev_page_action_set_current_page (EV_PAGE_ACTION (action), page);
-}
-
-static void
-view_page_changed_cb (EvView *view,
- EvWindow *ev_window)
-{
- update_current_page (ev_window, view);
- update_action_sensitivity (ev_window);
-}
-
static void
view_status_changed_cb (EvView *view,
GParamSpec *pspec,
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- if (visible && search_string) {
- ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document), search_string, case_sensitive);
+ if (visible && search_string && search_string[0]) {
+ g_mutex_lock (EV_DOC_MUTEX);
+ ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
+ ev_view_get_page (EV_VIEW (ev_window->priv->view)),
+ search_string,
+ case_sensitive);
+ g_mutex_unlock (EV_DOC_MUTEX);
} else {
+ g_mutex_lock (EV_DOC_MUTEX);
ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
+ g_mutex_unlock (EV_DOC_MUTEX);
+
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
NULL);
gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
priv->password_uri = NULL;
}
+ if (priv->find_bar) {
+ g_signal_handlers_disconnect_by_func
+ (window->priv->find_bar,
+ G_CALLBACK (find_bar_close_cb),
+ window);
+ priv->find_bar = NULL;
+ }
+
destroy_fullscreen_popup (window);
G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
G_CALLBACK (ev_window_cmd_go_last_page) },
/* Help menu */
- { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), NULL,
+ { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
N_("Display help for the viewer application"),
G_CALLBACK (ev_window_cmd_help_contents) },
PAGE_MODE_CONTINUOUS_PAGE }
};
-static void
-goto_page_cb (GtkAction *action, int page_number, EvWindow *ev_window)
-{
- EvView *view = EV_VIEW (ev_window->priv->view);
-
- if (ev_view_get_page (view) != page_number) {
- ev_view_set_page (view, page_number);
- }
-}
-
static void
drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
gint x, gint y, GtkSelectionData *selection_data,
"label", _("Page"),
"tooltip", _("Select Page"),
NULL);
- g_signal_connect (action, "goto_page",
- G_CALLBACK (goto_page_cb), window);
gtk_action_group_add_action (group, action);
g_object_unref (action);
}
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->view);
- g_signal_connect (ev_window->priv->view,
- "page-changed",
- G_CALLBACK (view_page_changed_cb),
- ev_window);
g_signal_connect (ev_window->priv->view,
"notify::find-status",
G_CALLBACK (view_find_status_changed_cb),