~ubuntu-branches/ubuntu/oneiric/evince/oneiric-updates

« back to all changes in this revision

Viewing changes to backend/dvi/dvi-document.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya, Josselin Mouette, Rodrigo Moya
  • Date: 2011-05-19 12:12:42 UTC
  • mfrom: (1.1.65 upstream) (1.3.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110519121242-967hbn2nh2hunp4y
Tags: 3.0.0-4ubuntu1
[ Josselin Mouette ]
* bug-presubj: please document where to report rendering bugs.
* evince.mime: dropped. We have desktop files to handle MIME 
  associations, no need to maintain an alternate system by hand.
  Closes: #619564, #627027, #551734, #581441.

[ Rodrigo Moya ]
* Rebase from Debian and GNOME3 PPA (thanks to Rico Tzschichholz).
  Remaining Ubuntu changes:
* debian/apparmor-profile:
* debian/apparmor-profile.abstraction:
* debian/evince.apport:
* debian/evince-common.dirs:
* debian/evince-common.postinst:
* debian/evince-common.postrm:
  - Add apparmor profile
* debian/control:
  - Build-Depend on debhelper (>= 7.4.20ubuntu5), gnome-common,
    hardening-includes and liblaunchpad-integration-3.0-dev
  - Standards-Version is 3.9.1
  - Depend on apparmor
* debian/rules:
  - Include hardening.make
  - Add rule to install apparmor files
* debian/watch:
  - Watch unstable series
* debian/patches/01_lpi.patch:
  - Launchpad integration patch
* debian/patches/04_gold.patch:
  - Link against libz
* debian/patches/05_library-path.patch:
  - Fix library path for g-ir-scanner

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "dvi-document.h"
23
23
#include "texmfcnf.h"
24
 
#include "ev-document-thumbnails.h"
25
24
#include "ev-document-misc.h"
26
25
#include "ev-file-exporter.h"
27
26
#include "ev-file-helpers.h"
74
73
 
75
74
typedef struct _DviDocumentClass DviDocumentClass;
76
75
 
77
 
static void dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
78
 
static void dvi_document_file_exporter_iface_init       (EvFileExporterInterface       *iface);
79
 
static void dvi_document_do_color_special               (DviContext                    *dvi,
80
 
                                                         const char                    *prefix,
81
 
                                                         const char                    *arg);
 
76
static void dvi_document_file_exporter_iface_init (EvFileExporterInterface       *iface);
 
77
static void dvi_document_do_color_special         (DviContext                    *dvi,
 
78
                                                   const char                    *prefix,
 
79
                                                   const char                    *arg);
82
80
 
83
81
EV_BACKEND_REGISTER_WITH_CODE (DviDocument, dvi_document,
84
82
     {
85
 
      EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS, dvi_document_document_thumbnails_iface_init);
86
83
      EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER, dvi_document_file_exporter_iface_init);
87
84
     });
88
85
 
267
264
        ev_document_class->support_synctex = dvi_document_support_synctex;
268
265
}
269
266
 
270
 
static void
271
 
dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
272
 
                                        EvRenderContext      *rc, 
273
 
                                        gint                 *width,
274
 
                                        gint                 *height)
275
 
{       
276
 
        DviDocument *dvi_document = DVI_DOCUMENT (document);
277
 
        gdouble page_width = dvi_document->base_width;
278
 
        gdouble page_height = dvi_document->base_height;
279
 
 
280
 
        if (rc->rotation == 90 || rc->rotation == 270) {
281
 
                *width = (gint) (page_height * rc->scale);
282
 
                *height = (gint) (page_width * rc->scale);
283
 
        } else {
284
 
                *width = (gint) (page_width * rc->scale);
285
 
                *height = (gint) (page_height * rc->scale);
286
 
        }
287
 
}
288
 
 
289
 
static GdkPixbuf *
290
 
dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
291
 
                                       EvRenderContext      *rc,   
292
 
                                       gboolean              border)
293
 
{
294
 
        DviDocument *dvi_document = DVI_DOCUMENT (document);
295
 
        GdkPixbuf *pixbuf;
296
 
        GdkPixbuf *rotated_pixbuf;
297
 
        cairo_surface_t *surface;
298
 
        gint thumb_width, thumb_height;
299
 
        gint proposed_width, proposed_height;
300
 
 
301
 
        thumb_width = (gint) (dvi_document->base_width * rc->scale);
302
 
        thumb_height = (gint) (dvi_document->base_height * rc->scale);
303
 
 
304
 
        g_mutex_lock (dvi_context_mutex);
305
 
        
306
 
        mdvi_setpage (dvi_document->context, rc->page->index);
307
 
 
308
 
        mdvi_set_shrink (dvi_document->context, 
309
 
                          (int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width,
310
 
                          (int)dvi_document->base_height * dvi_document->params->vshrink / thumb_height);
311
 
 
312
 
        proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
313
 
        proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
314
 
                          
315
 
        if (border) {
316
 
                mdvi_cairo_device_set_margins (&dvi_document->context->device, 
317
 
                                               MAX (thumb_width - proposed_width, 0) / 2,
318
 
                                               MAX (thumb_height - proposed_height, 0) / 2);    
319
 
        } else {
320
 
                mdvi_cairo_device_set_margins (&dvi_document->context->device, 
321
 
                                               MAX (thumb_width - proposed_width - 2, 0) / 2,
322
 
                                               MAX (thumb_height - proposed_height - 2, 0) / 2);        
323
 
        }
324
 
 
325
 
        mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale);
326
 
        mdvi_cairo_device_render (dvi_document->context);
327
 
        surface = mdvi_cairo_device_get_surface (&dvi_document->context->device);
328
 
        g_mutex_unlock (dvi_context_mutex);
329
 
 
330
 
        pixbuf = ev_document_misc_pixbuf_from_surface (surface);
331
 
        cairo_surface_destroy (surface);
332
 
 
333
 
        rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
334
 
        g_object_unref (pixbuf);
335
 
 
336
 
        if (border) {
337
 
                GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
338
 
 
339
 
                rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
340
 
                g_object_unref (tmp_pixbuf);
341
 
        }
342
 
 
343
 
        return rotated_pixbuf;
344
 
}
345
 
 
346
 
static void
347
 
dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
348
 
{
349
 
        iface->get_thumbnail = dvi_document_thumbnails_get_thumbnail;
350
 
        iface->get_dimensions = dvi_document_thumbnails_get_dimensions;
351
 
}
352
 
 
353
267
/* EvFileExporterIface */
354
268
static void
355
269
dvi_document_file_exporter_begin (EvFileExporter        *exporter,