~ubuntu-branches/ubuntu/quantal/gimp/quantal-updates

« back to all changes in this revision

Viewing changes to plug-ins/print/print-preview.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-05-20 19:21:01 UTC
  • mfrom: (1.1.26) (0.4.16 sid)
  • Revision ID: package-import@ubuntu.com-20120520192101-bs7zetx8ffoq2nfv
Tags: 2.8.0-2ubuntu1
* Merge from Debian unstable (LP: #908472). Remaining Changes:
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    + Update some strings for Ubuntu
  - debian/control:
    + Update description
  - debian/rules:
    + Set gettext domain and update translation templates
* Drop the following patches that were applied upstream:
  - debian/patches/ghost-cursor.patch: fix Wacom tablet cursor events
  - debian/patches/embed-page-setup-dialog.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
259
258
  PrintPreview *preview = PRINT_PREVIEW (widget);
260
259
  gdouble       paper_width;
261
260
  gdouble       paper_height;
262
 
  gint          border  = GTK_CONTAINER (widget)->border_width + 1;
 
261
  gint          border;
 
262
 
 
263
  border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1;
263
264
 
264
265
  print_preview_get_page_size (preview, &paper_width, &paper_height);
265
266
 
406
407
print_preview_expose_event (GtkWidget      *widget,
407
408
                            GdkEventExpose *event)
408
409
{
409
 
  PrintPreview *preview = PRINT_PREVIEW (widget);
410
 
  GtkStyle     *style   = gtk_widget_get_style (widget);
411
 
  cairo_t      *cr;
412
 
  gdouble       paper_width;
413
 
  gdouble       paper_height;
414
 
  gdouble       left_margin;
415
 
  gdouble       right_margin;
416
 
  gdouble       top_margin;
417
 
  gdouble       bottom_margin;
418
 
  gdouble       scale;
419
 
  gint          border = GTK_CONTAINER (widget)->border_width + 1;
 
410
  PrintPreview  *preview = PRINT_PREVIEW (widget);
 
411
  GtkStyle      *style   = gtk_widget_get_style (widget);
 
412
  GtkAllocation  allocation;
 
413
  cairo_t       *cr;
 
414
  gdouble        paper_width;
 
415
  gdouble        paper_height;
 
416
  gdouble        left_margin;
 
417
  gdouble        right_margin;
 
418
  gdouble        top_margin;
 
419
  gdouble        bottom_margin;
 
420
  gdouble        scale;
 
421
  gint           border;
 
422
 
 
423
  gtk_widget_get_allocation (widget, &allocation);
 
424
 
 
425
  border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1;
420
426
 
421
427
  print_preview_get_page_size (preview, &paper_width, &paper_height);
422
428
  print_preview_get_page_margins (preview,
425
431
 
426
432
  scale = print_preview_get_scale (preview);
427
433
 
428
 
  cr = gdk_cairo_create (widget->window);
 
434
  cr = gdk_cairo_create (gtk_widget_get_window (widget));
429
435
 
430
436
  cairo_translate (cr,
431
 
                   widget->allocation.x + border,
432
 
                   widget->allocation.y + border);
 
437
                   allocation.x + border,
 
438
                   allocation.y + border);
433
439
 
434
440
  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
435
441
    {
436
 
      gint width = widget->allocation.width - 2 * border;
 
442
      gint width = allocation.width - 2 * border;
437
443
 
438
444
      cairo_translate (cr, width - scale * paper_width, 0);
439
445
    }
456
462
                   scale * (paper_width - left_margin - right_margin),
457
463
                   scale * (paper_height - top_margin - bottom_margin));
458
464
 
459
 
  gdk_cairo_set_source_color (cr, &style->mid[widget->state]);
 
465
  gdk_cairo_set_source_color (cr, &style->mid[gtk_widget_get_state (widget)]);
460
466
  cairo_stroke (cr);
461
467
 
462
468
  cairo_translate (cr,
475
481
    }
476
482
 
477
483
  if (preview->thumbnail == NULL &&
478
 
      gimp_drawable_is_valid (preview->drawable->drawable_id))
 
484
      gimp_item_is_valid (preview->drawable->drawable_id))
479
485
    {
480
486
      preview->thumbnail =
481
487
        print_preview_get_thumbnail (preview->drawable,
482
 
                                     MIN (widget->allocation.width,  1024),
483
 
                                     MIN (widget->allocation.height, 1024));
 
488
                                     MIN (allocation.width,  1024),
 
489
                                     MIN (allocation.height, 1024));
484
490
    }
485
491
 
486
492
  if (preview->thumbnail != NULL)
654
660
                         gdouble       x,
655
661
                         gdouble       y)
656
662
{
657
 
  GtkWidget *widget = GTK_WIDGET (preview);
658
 
  gdouble    left_margin;
659
 
  gdouble    right_margin;
660
 
  gdouble    top_margin;
661
 
  gdouble    bottom_margin;
662
 
  gdouble    scale;
663
 
  gint       border = GTK_CONTAINER (widget)->border_width + 1;
 
663
  GtkWidget     *widget = GTK_WIDGET (preview);
 
664
  GtkAllocation  allocation;
 
665
  gdouble        left_margin;
 
666
  gdouble        right_margin;
 
667
  gdouble        top_margin;
 
668
  gdouble        bottom_margin;
 
669
  gdouble        scale;
 
670
  gint           border;
 
671
 
 
672
  gtk_widget_get_allocation (widget, &allocation);
 
673
 
 
674
  border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1;
664
675
 
665
676
  x -= border;
666
677
 
670
681
    {
671
682
      gdouble paper_width;
672
683
      gdouble paper_height;
673
 
      gint    width = widget->allocation.width - 2 * border;
 
684
      gint    width = allocation.width - 2 * border;
674
685
 
675
686
      print_preview_get_page_size (preview, &paper_width, &paper_height);
676
687
 
700
711
 
701
712
      preview->inside = inside;
702
713
 
703
 
      if (GTK_WIDGET_DRAWABLE (widget))
704
 
        gdk_window_set_cursor (widget->window,
 
714
      if (gtk_widget_is_drawable (widget))
 
715
        gdk_window_set_cursor (gtk_widget_get_window (widget),
705
716
                               inside ? preview->cursor : NULL);
706
717
 
707
718
      gtk_widget_queue_draw (widget);
711
722
static gdouble
712
723
print_preview_get_scale (PrintPreview *preview)
713
724
{
714
 
  GtkWidget *widget = GTK_WIDGET (preview);
715
 
  gdouble    paper_width;
716
 
  gdouble    paper_height;
717
 
  gdouble    scale_x;
718
 
  gdouble    scale_y;
719
 
  gint       border = GTK_CONTAINER (widget)->border_width + 1;
 
725
  GtkWidget     *widget = GTK_WIDGET (preview);
 
726
  GtkAllocation  allocation;
 
727
  gdouble        paper_width;
 
728
  gdouble        paper_height;
 
729
  gdouble        scale_x;
 
730
  gdouble        scale_y;
 
731
  gint           border;
 
732
 
 
733
  gtk_widget_get_allocation (widget, &allocation);
 
734
 
 
735
  border = gtk_container_get_border_width (GTK_CONTAINER (widget)) + 1;
720
736
 
721
737
  print_preview_get_page_size (preview, &paper_width, &paper_height);
722
738
 
723
 
  scale_x = (gdouble) (widget->allocation.width  - 2 * border) / paper_width;
724
 
  scale_y = (gdouble) (widget->allocation.height - 2 * border) / paper_height;
 
739
  scale_x = (gdouble) (allocation.width  - 2 * border) / paper_width;
 
740
  scale_y = (gdouble) (allocation.height - 2 * border) / paper_height;
725
741
 
726
742
  return MIN (scale_x, scale_y);
727
743
}