From ac6e61a0860b741e22072696e0ac6a78e386db0d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 20 Jan 2005 12:16:53 +0000 Subject: [PATCH] Show a wait cursor while the page is rendering 2005-01-20 Marco Pesenti Gritti * pdf/xpdf/pdf-document.cc: * shell/ev-view.c: (ev_view_set_cursor), (ev_view_motion_notify_event), (document_changed_callback), (set_document_page): Show a wait cursor while the page is rendering --- ChangeLog | 9 +++++++ pdf/xpdf/pdf-document.cc | 4 +-- shell/ev-view.c | 55 ++++++++++++++++++++++++++-------------- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32ad1e15..4a54e63a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-01-20 Marco Pesenti Gritti + + * pdf/xpdf/pdf-document.cc: + * shell/ev-view.c: (ev_view_set_cursor), + (ev_view_motion_notify_event), (document_changed_callback), + (set_document_page): + + Show a wait cursor while the page is rendering + 2005-01-20 Marco Pesenti Gritti * shell/ev-sidebar-thumbnails.c: diff --git a/pdf/xpdf/pdf-document.cc b/pdf/xpdf/pdf-document.cc index 0a70edbd..2ec9d5e2 100644 --- a/pdf/xpdf/pdf-document.cc +++ b/pdf/xpdf/pdf-document.cc @@ -149,6 +149,8 @@ document_validate_page (PdfDocument *pdf_document) pdf_document->page_valid = TRUE; + ev_document_changed (EV_DOCUMENT (pdf_document)); + /* Update the search results available to the app since * we only provide full results on the current page */ @@ -274,8 +276,6 @@ pdf_document_set_page (EvDocument *document, pdf_document->page = page; pdf_document->page_valid = FALSE; } - - ev_document_changed (document); } static int diff --git a/shell/ev-view.c b/shell/ev-view.c index 2033962a..e76f5b81 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -57,7 +57,8 @@ static const GtkTargetEntry targets[] = { typedef enum { EV_VIEW_CURSOR_NORMAL, - EV_VIEW_CURSOR_HAND + EV_VIEW_CURSOR_LINK, + EV_VIEW_CURSOR_WAIT } EvViewCursor; struct _EvView { @@ -595,26 +596,35 @@ ev_view_set_find_status (EvView *view, const char *message) static void ev_view_set_cursor (EvView *view, EvViewCursor new_cursor) { - GdkCursor *cursor; - GtkWidget *widget = GTK_WIDGET (view); + GdkCursor *cursor = NULL; + GdkDisplay *display; + GtkWidget *widget; if (view->cursor == new_cursor) { return; } + widget = gtk_widget_get_toplevel (GTK_WIDGET (view)); + display = gtk_widget_get_display (widget); + view->cursor = new_cursor; + switch (new_cursor) { case EV_VIEW_CURSOR_NORMAL: gdk_window_set_cursor (widget->window, NULL); break; - case EV_VIEW_CURSOR_HAND: - cursor = gdk_cursor_new_for_display - (gdk_display_get_default(), GDK_HAND2); - gdk_window_set_cursor (widget->window, cursor); - gdk_cursor_unref (cursor); + case EV_VIEW_CURSOR_LINK: + cursor = gdk_cursor_new_for_display (display, GDK_HAND2); + break; + case EV_VIEW_CURSOR_WAIT: + cursor = gdk_cursor_new_for_display (display, GDK_WATCH); break; } - view->cursor = new_cursor; + if (cursor) { + gdk_window_set_cursor (widget->window, cursor); + gdk_cursor_unref (cursor); + gdk_flush(); + } } static gboolean @@ -638,13 +648,15 @@ ev_view_motion_notify_event (GtkWidget *widget, msg = status_message_from_link (link); ev_view_set_status (view, msg); - ev_view_set_cursor (view, EV_VIEW_CURSOR_HAND); + ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK); g_free (msg); g_object_unref (link); } else { ev_view_set_status (view, NULL); - ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); + if (view->cursor == EV_VIEW_CURSOR_LINK) { + ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); + } } } @@ -1038,6 +1050,14 @@ found_results_callback (EvDocument *document, gtk_widget_queue_draw (GTK_WIDGET (view)); } +static void +document_changed_callback (EvDocument *document, + EvView *view) +{ + gtk_widget_queue_draw (GTK_WIDGET (view)); + ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); +} + /*** Public API ***/ GtkWidget* @@ -1046,13 +1066,6 @@ ev_view_new (void) return g_object_new (EV_TYPE_VIEW, NULL); } -static void -document_changed_callback (EvDocument *document, - EvView *view) -{ - gtk_widget_queue_draw (GTK_WIDGET (view)); -} - void ev_view_set_document (EvView *view, EvDocument *document) @@ -1100,8 +1113,12 @@ set_document_page (EvView *view, int page) { if (view->document) { int old_page = ev_document_get_page (view->document); - if (old_page != page) + + if (old_page != page) { + ev_view_set_cursor (view, EV_VIEW_CURSOR_WAIT); ev_document_set_page (view->document, page); + } + if (old_page != ev_document_get_page (view->document)) { g_signal_emit (view, page_changed_signal, 0); -- 2.43.5