~ubuntu-branches/ubuntu/hardy/evince/hardy-security

« back to all changes in this revision

Viewing changes to shell/ev-pixbuf-cache.c

  • Committer: Bazaar Package Importer
  • Author(s): Aron Sisak
  • Date: 2007-07-30 22:47:24 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20070730224724-3jcs7t9t5ymuj6os
Tags: 0.9.3-0ubuntu1
* New upstream release:
  - New Features and UI Improvements:
    - Use new GTK+ tootlips 
    - Printing multiple pages per sheet
    - Added UNIX-like key bindings hjkl
  - Bug fixes:
    - Do not block while enumerating printers in preview mode
    - Show new pages as soon as they are rendered even if other page 
      elements like forms, images or links are not ready yet 
    - Provide different options in the print dialog depending on document 
      type backend capabilities 
  - Translations:
    - es, eu, fi, hu, mk, nl, zh_CN
* debian/patches/02_autoconf.patch:
  - configure update

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
{
12
12
        EvJob *job;
13
13
        EvRenderContext *rc;
 
14
        gboolean page_ready;
14
15
 
15
16
        /* Region of the page that needs to be drawn */
16
17
        GdkRegion *region; 
73
74
static void          ev_pixbuf_cache_class_init (EvPixbufCacheClass *pixbuf_cache);
74
75
static void          ev_pixbuf_cache_finalize   (GObject            *object);
75
76
static void          ev_pixbuf_cache_dispose    (GObject            *object);
 
77
static void          job_page_ready_cb          (EvJob              *job,
 
78
                                                 EvPixbufCache      *pixbuf_cache);
76
79
static void          job_finished_cb            (EvJob              *job,
77
80
                                                 EvPixbufCache      *pixbuf_cache);
78
81
static CacheJobInfo *find_job_cache             (EvPixbufCache      *pixbuf_cache,
80
83
static void          copy_job_to_job_info       (EvJobRender        *job_render,
81
84
                                                 CacheJobInfo       *job_info,
82
85
                                                 EvPixbufCache      *pixbuf_cache);
 
86
static void          copy_job_page_and_selection_to_job_info (EvJobRender        *job_render,
 
87
                                                              CacheJobInfo       *job_info,
 
88
                                                              EvPixbufCache      *pixbuf_cache);
83
89
static gboolean      new_selection_surface_needed(EvPixbufCache      *pixbuf_cache,
84
90
                                                  CacheJobInfo       *job_info,
85
91
                                                  gint                page,
151
157
                return;
152
158
        if (job_info->job) {
153
159
                g_signal_handlers_disconnect_by_func (job_info->job,
 
160
                                                      G_CALLBACK (job_page_ready_cb),
 
161
                                                      data);
 
162
                g_signal_handlers_disconnect_by_func (job_info->job,
154
163
                                                      G_CALLBACK (job_finished_cb),
155
164
                                                      data);
156
165
                ev_job_queue_remove_job (job_info->job);
233
242
}
234
243
 
235
244
static void
 
245
job_page_ready_cb (EvJob         *job,
 
246
                   EvPixbufCache *pixbuf_cache)
 
247
{
 
248
        CacheJobInfo *job_info;
 
249
        EvJobRender *job_render = EV_JOB_RENDER (job);
 
250
 
 
251
        /* If the job is outside of our interest, we silently discard it */
 
252
        if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
 
253
            (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
 
254
                g_object_unref (job);
 
255
                return;
 
256
        }
 
257
 
 
258
        job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
 
259
 
 
260
        copy_job_page_and_selection_to_job_info (job_render, job_info, pixbuf_cache);
 
261
        g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
 
262
}
 
263
 
 
264
static void
236
265
job_finished_cb (EvJob         *job,
237
266
                 EvPixbufCache *pixbuf_cache)
238
267
{
245
274
                g_object_unref (job);
246
275
                return;
247
276
        }
248
 
        
 
277
 
249
278
        job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
250
 
 
251
279
        copy_job_to_job_info (job_render, job_info, pixbuf_cache);
252
 
        g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
253
280
}
254
281
 
255
282
/* This checks a job to see if the job would generate the right sized pixbuf
419
446
}
420
447
 
421
448
static void
 
449
copy_job_page_and_selection_to_job_info (EvJobRender   *job_render,
 
450
                                         CacheJobInfo  *job_info,
 
451
                                         EvPixbufCache *pixbuf_cache)
 
452
{
 
453
        if (job_info->surface) {
 
454
                cairo_surface_destroy (job_info->surface);
 
455
        }
 
456
        job_info->surface = cairo_surface_reference (job_render->surface);
 
457
 
 
458
        if (job_info->rc) {
 
459
                g_object_unref (G_OBJECT (job_info->rc));
 
460
        }
 
461
        job_info->rc = g_object_ref (job_render->rc);
 
462
 
 
463
        job_info->points_set = FALSE;
 
464
        if (job_render->include_selection) {
 
465
                if (job_info->selection) {
 
466
                        cairo_surface_destroy (job_info->selection);
 
467
                        job_info->selection = NULL;
 
468
                }
 
469
                if (job_info->selection_region) {
 
470
                        gdk_region_destroy (job_info->selection_region);
 
471
                        job_info->selection_region = NULL;
 
472
                }
 
473
                
 
474
                job_info->selection_points = job_render->selection_points;
 
475
                job_info->selection_region = gdk_region_copy (job_render->selection_region);
 
476
                job_info->selection = cairo_surface_reference (job_render->selection);
 
477
                g_assert (job_info->selection_points.x1 >= 0);
 
478
                job_info->points_set = TRUE;
 
479
        }
 
480
 
 
481
        if (job_info->job) {
 
482
                g_signal_handlers_disconnect_by_func (job_info->job,
 
483
                                                      G_CALLBACK (job_page_ready_cb),
 
484
                                                      pixbuf_cache);
 
485
        }
 
486
 
 
487
        job_info->page_ready = TRUE;
 
488
}
 
489
 
 
490
static void
422
491
copy_job_to_job_info (EvJobRender   *job_render,
423
492
                      CacheJobInfo  *job_info,
424
493
                      EvPixbufCache *pixbuf_cache)
425
494
{
426
 
 
427
 
        job_info->points_set = FALSE;
428
 
 
429
 
        if (job_info->surface) {
430
 
                cairo_surface_destroy (job_info->surface);
431
 
        }
432
 
        job_info->surface = cairo_surface_reference (job_render->surface);
433
 
 
434
 
        if (job_info->rc) {
435
 
                g_object_unref (G_OBJECT (job_info->rc));
436
 
        }
437
 
        job_info->rc = g_object_ref (job_render->rc);
438
 
 
439
495
        if (job_render->include_links) {
440
496
                if (job_info->link_mapping)
441
497
                        ev_link_mapping_free (job_info->link_mapping);
460
516
                job_info->text_mapping = job_render->text_mapping;
461
517
        }
462
518
 
463
 
        if (job_render->include_selection) {
464
 
                if (job_info->selection) {
465
 
                        cairo_surface_destroy (job_info->selection);
466
 
                        job_info->selection = NULL;
467
 
                }
468
 
                if (job_info->selection_region) {
469
 
                        gdk_region_destroy (job_info->selection_region);
470
 
                        job_info->selection_region = NULL;
471
 
                }
472
 
                
473
 
                job_info->selection_points = job_render->selection_points;
474
 
                job_info->selection_region = gdk_region_copy (job_render->selection_region);
475
 
                job_info->selection = cairo_surface_reference (job_render->selection);
476
 
                g_assert (job_info->selection_points.x1 >= 0);
477
 
                job_info->points_set = TRUE;
478
 
        }
479
 
 
480
519
        if (job_info->job) {
481
520
                g_signal_handlers_disconnect_by_func (job_info->job,
482
521
                                                      G_CALLBACK (job_finished_cb),
571
610
        gboolean include_images = TRUE;
572
611
        gboolean include_forms = FALSE;
573
612
        GdkColor *text, *base;
 
613
 
 
614
        job_info->page_ready = FALSE;
574
615
        
575
616
        if (job_info->rc == NULL) {
576
617
                job_info->rc = ev_render_context_new (rotation, page, scale);
612
653
                                           include_text,
613
654
                                           include_selection);
614
655
        ev_job_queue_add_job (job_info->job, priority);
615
 
        g_signal_connect (job_info->job, "finished",
 
656
        g_signal_connect (G_OBJECT (job_info->job), "page-ready",
 
657
                          G_CALLBACK (job_page_ready_cb),
 
658
                          pixbuf_cache);
 
659
        g_signal_connect (G_OBJECT (job_info->job), "finished",
616
660
                          G_CALLBACK (job_finished_cb),
617
661
                          pixbuf_cache);
618
662
}
729
773
        if (job_info == NULL)
730
774
                return NULL;
731
775
 
 
776
        if (job_info->page_ready)
 
777
                return job_info->surface;
 
778
        
732
779
        /* We don't need to wait for the idle to handle the callback */
733
780
        if (job_info->job &&
734
 
            EV_JOB (job_info->job)->finished) {
735
 
                copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
 
781
            EV_JOB_RENDER (job_info->job)->page_ready) {
 
782
                copy_job_page_and_selection_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
736
783
                g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
737
784
        }
738
785
 
753
800
        if (job_info->job &&
754
801
            EV_JOB (job_info->job)->finished) {
755
802
                copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
756
 
                g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
757
803
        }
758
804
 
759
805
        return job_info->link_mapping;
776
822
        if (job_info->job &&
777
823
            EV_JOB (job_info->job)->finished) {
778
824
                copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
779
 
                g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
780
825
        }
781
826
 
782
827
        return job_info->image_mapping;
799
844
        if (job_info->job &&
800
845
           EV_JOB (job_info->job)->finished) {
801
846
                copy_job_to_job_info (EV_JOB_RENDER(job_info->job), job_info, pixbuf_cache);
802
 
                g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
803
847
        }
804
848
        
805
849
        return job_info->form_field_mapping;
863
907
        if (job_info->job &&
864
908
            EV_JOB (job_info->job)->finished) {
865
909
                copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
866
 
                g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
867
910
        }
868
911
        
869
912
        return job_info->text_mapping;