]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-view.c
updating for Punjabi
[evince.git] / shell / ev-view.c
index 9782d0b1a472c3682dc01e01b34d3a4ee29555b3..0fd2834aeb6b03f89004eaf6d90259012be76709 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
@@ -41,6 +42,7 @@
 #include "ev-job-queue.h"
 #include "ev-page-cache.h"
 #include "ev-pixbuf-cache.h"
 #include "ev-job-queue.h"
 #include "ev-page-cache.h"
 #include "ev-pixbuf-cache.h"
+#include "ev-transition-animation.h"
 #if !GTK_CHECK_VERSION (2, 11, 7)
 #include "ev-tooltip.h"
 #endif
 #if !GTK_CHECK_VERSION (2, 11, 7)
 #include "ev-tooltip.h"
 #endif
@@ -2478,6 +2480,24 @@ ev_view_expose_event (GtkWidget      *widget,
        cairo_t *cr;
        gint     i;
 
        cairo_t *cr;
        gint     i;
 
+       if (view->animation) {
+               GdkRectangle page_area;
+               GtkBorder    border;
+
+               if (get_page_extents (view, view->current_page, &page_area, &border)) {
+                       cr = gdk_cairo_create (view->layout.bin_window);
+
+                       /* normalize to x=0, y=0 */
+                       cairo_translate (cr, page_area.x, page_area.y);
+                       page_area.x = page_area.y = 0;
+
+                       ev_transition_animation_paint (view->animation, cr, page_area);
+                       cairo_destroy (cr);
+               }
+
+               return TRUE;
+       }
+
        if (view->presentation) {
                switch (view->presentation_state) {
                        case EV_PRESENTATION_END: {
        if (view->presentation) {
                switch (view->presentation_state) {
                        case EV_PRESENTATION_END: {
@@ -3600,12 +3620,6 @@ draw_loading_text (EvView       *view,
        cairo_t *cr;
        gint     width, height;
 
        cairo_t *cr;
        gint     width, height;
 
-       /* Don't annoy users with loading messages during presentations.
-        * FIXME: Temporary "workaround" for
-        * http://bugzilla.gnome.org/show_bug.cgi?id=320352 */
-       if (view->presentation)
-               return;
-
        if (!view->loading_text) {
                const gchar *loading_text = _("Loading...");
                PangoLayout *layout;
        if (!view->loading_text) {
                const gchar *loading_text = _("Loading...");
                PangoLayout *layout;
@@ -3724,7 +3738,7 @@ draw_one_page (EvView       *view,
 
                cairo_save (cr);
                cairo_translate (cr, overlap.x, overlap.y);
 
                cairo_save (cr);
                cairo_translate (cr, overlap.x, overlap.y);
-               
+
                if (width != page_width || height != page_height) {
                        cairo_pattern_set_filter (cairo_get_source (cr),
                                                  CAIRO_FILTER_FAST);
                if (width != page_width || height != page_height) {
                        cairo_pattern_set_filter (cairo_get_source (cr),
                                                  CAIRO_FILTER_FAST);
@@ -4203,11 +4217,76 @@ find_changed_cb (EvDocument *document, int page, EvView *view)
                gtk_widget_queue_draw (GTK_WIDGET (view));
 }
 
                gtk_widget_queue_draw (GTK_WIDGET (view));
 }
 
+static void
+ev_view_change_page (EvView *view,
+                    gint    new_page)
+{
+       gint x, y;
+
+       view->current_page = new_page;
+       view->pending_scroll = SCROLL_TO_PAGE_POSITION;
+
+       if (view->presentation)
+               ev_view_presentation_transition_start (view);
+
+       gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
+       ev_view_handle_cursor_over_xy (view, x, y);
+
+       gtk_widget_queue_resize (GTK_WIDGET (view));
+}
+
+static void
+ev_view_transition_animation_finish (EvTransitionAnimation *animation,
+                                    EvView                *view)
+{
+       g_object_unref (view->animation);
+       view->animation = NULL;
+       ev_view_change_page (view, view->current_page);
+}
+
+static void
+ev_view_transition_animation_frame (EvTransitionAnimation *animation,
+                                   gdouble                progress,
+                                   EvView                *view)
+{
+       gtk_widget_queue_draw (GTK_WIDGET (view));
+}
+
+static void
+ev_view_presentation_animation_start (EvView *view,
+                                      int     new_page)
+{
+       EvTransitionEffect *effect = NULL;
+       cairo_surface_t *surface;
+
+        if (EV_IS_DOCUMENT_TRANSITION (view->document))
+               effect = ev_document_transition_get_effect (EV_DOCUMENT_TRANSITION (view->document),
+                                                           view->current_page);
+       if (!effect)
+               return;
+
+       surface = ev_pixbuf_cache_get_surface (view->pixbuf_cache, view->current_page);
+       view->animation = ev_transition_animation_new (effect);
+       ev_transition_animation_set_origin_surface (view->animation, surface);
+               
+       g_signal_connect (view->animation, "frame",
+                         G_CALLBACK (ev_view_transition_animation_frame), view);
+       g_signal_connect (view->animation, "finished",
+                         G_CALLBACK (ev_view_transition_animation_finish), view);
+}
+
 static void
 job_finished_cb (EvPixbufCache *pixbuf_cache,
                 GdkRegion     *region,
                 EvView        *view)
 {
 static void
 job_finished_cb (EvPixbufCache *pixbuf_cache,
                 GdkRegion     *region,
                 EvView        *view)
 {
+       if (view->animation) {
+               cairo_surface_t *surface;
+
+               surface = ev_pixbuf_cache_get_surface (pixbuf_cache, view->current_page);
+               ev_transition_animation_set_dest_surface (view->animation, surface);
+       }
+
        if (region) {
                gdk_window_invalidate_region (view->layout.bin_window,
                                              region, TRUE);
        if (region) {
                gdk_window_invalidate_region (view->layout.bin_window,
                                              region, TRUE);
@@ -4222,18 +4301,10 @@ page_changed_cb (EvPageCache *page_cache,
                 EvView      *view)
 {
        if (view->current_page != new_page) {
                 EvView      *view)
 {
        if (view->current_page != new_page) {
-               gint x, y;
-               
-               view->current_page = new_page;
-               view->pending_scroll = SCROLL_TO_PAGE_POSITION;
-
                if (view->presentation)
                if (view->presentation)
-                       ev_view_presentation_transition_start (view);
-               
-               gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
-               ev_view_handle_cursor_over_xy (view, x, y);
-               
-               gtk_widget_queue_resize (GTK_WIDGET (view));
+                       ev_view_presentation_animation_start (view, new_page);
+
+               ev_view_change_page (view, new_page);
        } else {
                gtk_widget_queue_draw (GTK_WIDGET (view));
        }
        } else {
                gtk_widget_queue_draw (GTK_WIDGET (view));
        }
@@ -4578,9 +4649,15 @@ ev_view_set_presentation (EvView   *view,
 
        if (presentation)
                ev_view_presentation_transition_start (view);
 
        if (presentation)
                ev_view_presentation_transition_start (view);
-       else
+       else {
                ev_view_presentation_transition_stop (view);
 
                ev_view_presentation_transition_stop (view);
 
+               if (view->animation) {
+                       /* stop any running animation */
+                       ev_view_transition_animation_finish (view->animation, view);
+               }
+       }
+
        if (GTK_WIDGET_REALIZED (view)) {
                if (view->presentation)
                        gdk_window_set_background (view->layout.bin_window,
        if (GTK_WIDGET_REALIZED (view)) {
                if (view->presentation)
                        gdk_window_set_background (view->layout.bin_window,
@@ -5770,7 +5847,12 @@ ev_view_next_page (EvView *view)
             view->presentation_state == EV_PRESENTATION_WHITE)) {
                ev_view_reset_presentation_state (view);
                return FALSE; 
             view->presentation_state == EV_PRESENTATION_WHITE)) {
                ev_view_reset_presentation_state (view);
                return FALSE; 
-       }       
+       }
+
+       if (view->animation) {
+               ev_view_transition_animation_finish (view->animation, view);
+               return TRUE;
+       }
 
        ev_view_presentation_transition_stop (view);
        ev_view_reset_presentation_state (view);
 
        ev_view_presentation_transition_stop (view);
        ev_view_reset_presentation_state (view);
@@ -5821,6 +5903,11 @@ ev_view_previous_page (EvView *view)
                return FALSE; 
        }       
 
                return FALSE; 
        }       
 
+        if (view->animation) {
+               ev_view_transition_animation_finish (view->animation, view);
+               return TRUE;
+        }
+
        ev_view_reset_presentation_state (view);
 
        page = ev_page_cache_get_current_page (view->page_cache);
        ev_view_reset_presentation_state (view);
 
        page = ev_page_cache_get_current_page (view->page_cache);