Exemplo n.º 1
0
JNIEXPORT jdouble JNICALL
Java_org_gnome_gtk_GtkPageSetup_gtk_1page_1setup_1get_1page_1width
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jint _unit
)
{
	gdouble result;
	jdouble _result;
	GtkPageSetup* self;
	GtkUnit unit;

	// convert parameter self
	self = (GtkPageSetup*) _self;

	// convert parameter unit
	unit = (GtkUnit) _unit;

	// call function
	result = gtk_page_setup_get_page_width(self, unit);

	// cleanup parameter self

	// cleanup parameter unit

	// translate return value to JNI type
	_result = (jdouble) result;

	// and finally
	return _result;
}
Exemplo n.º 2
0
static gdouble
photos_print_setup_get_max_percentage (PhotosPrintSetup *self)
{
    PhotosPrintSetupPrivate *priv = self->priv;
    GeglRectangle bbox;
    gdouble height;
    gdouble page_height;
    gdouble page_width;
    gdouble width;
    gdouble perc;

    page_width = gtk_page_setup_get_page_width (priv->page_setup, GTK_UNIT_INCH);
    page_height = gtk_page_setup_get_page_height (priv->page_setup, GTK_UNIT_INCH);
    bbox = gegl_node_get_bounding_box (priv->node);

    width  = (gdouble) bbox.width / FACTOR_INCH_TO_PIXEL;
    height = (gdouble) bbox.height / FACTOR_INCH_TO_PIXEL;

    if (page_width > width && page_height > height)
        perc = 1.0;
    else
        perc = MIN (page_width / width, page_height / height);

    return perc;
}
Exemplo n.º 3
0
static void
photos_print_setup_set_initial_values (PhotosPrintSetup *self)
{
    PhotosPrintSetupPrivate *priv = self->priv;
    GeglRectangle bbox;
    gdouble page_height;
    gdouble page_width;
    gdouble factor;
    gdouble height;
    gdouble max_perc;
    gdouble width;

    factor = get_scale_to_px_factor (self);

    bbox = gegl_node_get_bounding_box (priv->node);
    width = (gdouble) bbox.width/factor;
    height = (gdouble) bbox.height/factor;

    max_perc = photos_print_setup_get_max_percentage (self);

    width *= max_perc;
    height *= max_perc;

    gtk_range_set_range (GTK_RANGE (priv->scaling), 1, 100 * max_perc);
    gtk_range_set_increments (GTK_RANGE (priv->scaling), max_perc, 10 * max_perc);
    gtk_range_set_value (GTK_RANGE (priv->scaling), 100 * max_perc);

    photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (priv->preview), max_perc);
    gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->width), 0, width);
    gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->height), 0, height);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->width), width);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->height), height);

    gtk_combo_box_set_active (GTK_COMBO_BOX (priv->center), CENTER_BOTH);

    photos_print_setup_center (gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit),
                               gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->width)),
                               GTK_SPIN_BUTTON (priv->left), GTK_SPIN_BUTTON (priv->right));
    photos_print_setup_center (gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit),
                               gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->height)),
                               GTK_SPIN_BUTTON (priv->top), GTK_SPIN_BUTTON (priv->bottom));

    page_width = gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit);
    page_height = gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit);

    update_image_pos_ranges (self, page_width, page_height, width, height);
}
Exemplo n.º 4
0
static void
on_center_changed (GtkComboBox *combobox, gpointer user_data)
{
    PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
    PhotosPrintSetupPrivate *priv = self->priv;
    gint active;

    active = gtk_combo_box_get_active (combobox);

    switch (active)
    {
    case CENTER_HORIZONTAL:
        photos_print_setup_center (gtk_page_setup_get_page_width (priv->page_setup,
                                   priv->current_unit),
                                   gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->width)),
                                   GTK_SPIN_BUTTON (priv->left),
                                   GTK_SPIN_BUTTON (priv->right));
        break;
    case CENTER_VERTICAL:
        photos_print_setup_center (gtk_page_setup_get_page_height (priv->page_setup,
                                   priv->current_unit),
                                   gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->height)),
                                   GTK_SPIN_BUTTON (priv->top),
                                   GTK_SPIN_BUTTON (priv->bottom));
        break;
    case CENTER_BOTH:
        photos_print_setup_center (gtk_page_setup_get_page_width (priv->page_setup,
                                   priv->current_unit),
                                   gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->width)),
                                   GTK_SPIN_BUTTON (priv->left),
                                   GTK_SPIN_BUTTON (priv->right));
        photos_print_setup_center (gtk_page_setup_get_page_height (priv->page_setup,
                                   priv->current_unit),
                                   gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->height)),
                                   GTK_SPIN_BUTTON (priv->top),
                                   GTK_SPIN_BUTTON (priv->bottom));
        break;
    case CENTER_NONE:
    default:
        break;
    }

    gtk_combo_box_set_active (combobox, active);
}
Exemplo n.º 5
0
/*! \brief Export a print-style PDF file of the current page.
 * \par Function Description
 * Exports the current page as a PDF file to \a filename. The
 * export is carried out using a normal paper size and margins, as if
 * printing.
 *
 * \param w_current A #GschemToplevel structure.
 * \param filename  The filename for generated PDF.
 *
 * \returns TRUE if the operation was successful.
 */
gboolean
x_print_export_pdf_page (GschemToplevel *w_current,
                         const gchar *filename)
{
  PAGE *page;
  cairo_surface_t *surface;
  cairo_status_t status;
  cairo_t *cr;
  GtkPageSetup *setup;
  double width, height;
  EdaConfig *cfg;
  gboolean is_color;

  page = w_current->toplevel->page_current;

  setup = x_print_default_page_setup (w_current->toplevel, page );
  width = gtk_page_setup_get_paper_width (setup, GTK_UNIT_POINTS);
  height = gtk_page_setup_get_paper_height (setup, GTK_UNIT_POINTS);

  surface = cairo_pdf_surface_create (filename, width, height);
  cr = cairo_create (surface);
  cairo_translate (cr, gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS),
                   gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS));

  width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS);
  height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS);

  /* Find out if colour printing is enabled */
  cfg = eda_config_get_context_for_path (s_page_get_filename (page));
  is_color = !eda_config_get_boolean (cfg, CFG_GROUP_PRINTING,
                                      CFG_KEY_PRINTING_MONOCHROME, NULL);

  x_print_draw_page (w_current->toplevel, page,
                     cr, NULL, width, height, is_color, FALSE);

  cairo_destroy (cr);
  cairo_surface_finish (surface);

  status = cairo_surface_status (surface);
  if (status != CAIRO_STATUS_SUCCESS) {
    g_warning (_("Failed to write PDF to '%s': %s\n"),
               filename,
               cairo_status_to_string (status));
    return FALSE;
  }

  g_object_unref (setup);
  cairo_surface_destroy (surface);
  return TRUE;
}
Exemplo n.º 6
0
static void
on_right_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
{
    PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
    PhotosPrintSetupPrivate *priv = self->priv;

    photos_print_setup_position_values_changed (self,
            priv->right,
            priv->left,
            priv->width,
            gtk_page_setup_get_page_width (priv->page_setup,
                                           priv->current_unit),
            CHANGE_HORIZ);
}
Exemplo n.º 7
0
static void
on_height_value_changed (GtkSpinButton *spinbutton,
                         gpointer       user_data)
{
    PhotosPrintSetupPrivate *priv = PHOTOS_PRINT_SETUP (user_data)->priv;

    photos_print_setup_size_changed (PHOTOS_PRINT_SETUP (user_data),
                                     priv->height, priv->width,
                                     priv->top, priv->bottom,
                                     priv->left, priv->right,
                                     gtk_page_setup_get_page_height (priv->page_setup,
                                             priv->current_unit),
                                     gtk_page_setup_get_page_width (priv->page_setup,
                                             priv->current_unit),
                                     CHANGE_VERT);
}
Exemplo n.º 8
0
/* contact_page_draw_footer inserts the
 * page number at the end of each page
 * while printing*/
void
contact_page_draw_footer (GtkPrintOperation *operation,
                          GtkPrintContext *context,
                          gint page_nr)
{
	PangoFontDescription *desc;
	PangoLayout *layout;
	gdouble x, y, page_height, page_width, page_margin;
	/*gint n_pages;*/
	gchar *text;
	cairo_t *cr;
	GtkPageSetup *setup;

	/*Uncomment next if it is successful to get total number if pages in list view
	 * g_object_get (operation, "n-pages", &n_pages, NULL)*/
	text = g_strdup_printf (_("Page %d"), page_nr + 1);

	setup = gtk_print_context_get_page_setup ( context);
	page_height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS);
	page_width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS);
	page_margin = gtk_page_setup_get_bottom_margin (setup, GTK_UNIT_POINTS);

	desc = pango_font_description_from_string ("Sans Regular 8");
	layout = gtk_print_context_create_pango_layout (context);
	pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
	pango_layout_set_font_description (layout, desc);
	pango_layout_set_text (layout, text, -1);
	pango_layout_set_width (layout, -1);

	x = page_width / 2.0 - page_margin;
	y = page_height - page_margin / 2.0;

	cr = gtk_print_context_get_cairo_context (context);

	cairo_save (cr);
	cairo_set_source_rgb (cr, .0, .0, .0);
	cairo_move_to (cr, x, y);
	pango_cairo_show_layout (cr, layout);
	cairo_restore (cr);

	g_object_unref (layout);
	pango_font_description_free (desc);

	g_free (text);
}
Exemplo n.º 9
0
static void
biorhythm_print_draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data)
{
	cairo_t *cr;
	gdouble p_width, p_height;
	GtkPageSetup *page_setup;
	BiorhythmChart *chart;

	chart = (BiorhythmChart *) user_data;

	page_setup = gtk_print_context_get_page_setup (context);
	p_width =  gtk_page_setup_get_page_width (page_setup, GTK_UNIT_POINTS);
	p_height = gtk_page_setup_get_page_height (page_setup, GTK_UNIT_POINTS);

	cr = gtk_print_context_get_cairo_context (context);

  	biorhythm_chart_draw_cairo (chart, cr, p_height, p_width);
}
Exemplo n.º 10
0
static void
on_scale_changed (GtkRange *range, gpointer user_data)
{
    PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
    PhotosPrintSetupPrivate *priv = self->priv;
    GeglRectangle bbox;
    gdouble height;
    gdouble scale;
    gdouble width;
    gdouble left, right, top, bottom;
    gdouble page_width, page_height;
    gdouble factor;

    gtk_combo_box_set_active (GTK_COMBO_BOX (priv->center), CENTER_NONE);

    bbox = gegl_node_get_bounding_box (priv->node);
    factor = get_scale_to_px_factor (self);

    width = (gdouble) bbox.width / factor;
    height = (gdouble) bbox.height / factor;

    left = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->left));
    top = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->top));

    scale = CLAMP (0.01 * gtk_range_get_value (range), 0, photos_print_setup_get_max_percentage (self));

    photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (priv->preview), scale);

    width  *= scale;
    height *= scale;

    page_width = gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit);
    page_height = gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit);

    update_image_pos_ranges (self, page_width, page_height, width, height);

    right = page_width - left - width;
    bottom = page_height - top - height;

    gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->width), width);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->height), height);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->right), right);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->bottom), bottom);
}
Exemplo n.º 11
0
static void
contact_begin_print (GtkPrintOperation *operation,
                     GtkPrintContext *context,
                     EContactPrintContext *ctxt)
{
	GtkPageSetup *setup;
	gdouble page_width;

	e_contact_build_style (ctxt->style);

	setup = gtk_print_context_get_page_setup (context);
	page_width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS);

	ctxt->context = context;
	ctxt->x = ctxt->y = .0;
	ctxt->column = 0;
	ctxt->first_contact = TRUE;
	ctxt->first_section = TRUE;
	ctxt->section = NULL;

	ctxt->column_spacing = gtk_print_context_get_dpi_x (context) / 4;
	ctxt->column_width = (page_width + ctxt->column_spacing) /
		ctxt->style->num_columns - ctxt->column_spacing;

	ctxt->letter_heading_font = pango_font_description_new ();
	pango_font_description_set_family (
		ctxt->letter_heading_font,
		pango_font_description_get_family (
			ctxt->style->headings_font));
	pango_font_description_set_size (
		ctxt->letter_heading_font,
		pango_font_description_get_size (
			ctxt->style->headings_font) * 1.5);

	if (ctxt->contact_list != NULL) {
		ctxt->page_nr = -1;
		ctxt->pages = 1;
		g_slist_foreach (ctxt->contact_list, (GFunc) contact_draw, ctxt);
		gtk_print_operation_set_n_pages (operation, ctxt->pages);
	}
}
Exemplo n.º 12
0
static void
print_size_info_get_page_dimensions (PrintSizeInfo *info,
                                     gdouble       *page_width,
                                     gdouble       *page_height,
                                     GtkUnit        unit)
{
  GtkPageSetup *setup;

  setup = gtk_print_operation_get_default_page_setup (info->data->operation);

  if (info->data->use_full_page)
    {
      *page_width = gtk_page_setup_get_paper_width (setup, unit);
      *page_height = gtk_page_setup_get_paper_height (setup, unit);
    }
  else
    {
      *page_width = gtk_page_setup_get_page_width (setup, unit);
      *page_height = gtk_page_setup_get_page_height (setup, unit);
    }

}
Exemplo n.º 13
0
static void
xviewer_print_draw_page (GtkPrintOperation *operation,
                         GtkPrintContext   *context,
                         gint               page_nr,
                         gpointer           user_data)
{
    cairo_t *cr;
    gdouble dpi_x, dpi_y;
    gdouble x0, y0;
    gdouble scale_factor;
    gdouble p_width, p_height;
    gint width, height;
    XviewerPrintData *data;
    GtkPageSetup *page_setup;

    xviewer_debug (DEBUG_PRINTING);

    data = (XviewerPrintData *) user_data;

    scale_factor = data->scale_factor/100;

    dpi_x = gtk_print_context_get_dpi_x (context);
    dpi_y = gtk_print_context_get_dpi_y (context);

    switch (data->unit) {
    case GTK_UNIT_INCH:
        x0 = data->left_margin * dpi_x;
        y0 = data->top_margin  * dpi_y;
        break;
    case GTK_UNIT_MM:
        x0 = data->left_margin * dpi_x/25.4;
        y0 = data->top_margin  * dpi_y/25.4;
        break;
    default:
        g_assert_not_reached ();
    }

    cr = gtk_print_context_get_cairo_context (context);

    cairo_translate (cr, x0, y0);

    page_setup = gtk_print_context_get_page_setup (context);
    p_width =  gtk_page_setup_get_page_width (page_setup, GTK_UNIT_POINTS);
    p_height = gtk_page_setup_get_page_height (page_setup, GTK_UNIT_POINTS);

    xviewer_image_get_size (data->image, &width, &height);

    /* this is both a workaround for a bug in cairo's PDF backend, and
       a way to ensure we are not printing outside the page margins */
    cairo_rectangle (cr, 0, 0, MIN (width*scale_factor, p_width), MIN (height*scale_factor, p_height));
    cairo_clip (cr);

    cairo_scale (cr, scale_factor, scale_factor);

#ifdef HAVE_RSVG
    if (xviewer_image_is_svg (data->image))
    {
        RsvgHandle *svg = xviewer_image_get_svg (data->image);

        rsvg_handle_render_cairo (svg, cr);
        return;
    } else
#endif
        /* JPEGs can be attached to the cairo surface which simply embeds the JPEG file into the
         * destination PDF skipping (PNG-)recompression. This should reduce PDF sizes enormously. */
        if (xviewer_image_is_jpeg (data->image) && _cairo_ctx_supports_jpg_metadata (cr))
        {
            GFile *file;
            char *img_data;
            gsize data_len;
            cairo_surface_t *surface = NULL;

            xviewer_debug_message (DEBUG_PRINTING, "Attaching image to cairo surface");

            file = xviewer_image_get_file (data->image);
            if (g_file_load_contents (file, NULL, &img_data, &data_len, NULL, NULL))
            {
                XviewerTransform *tf = xviewer_image_get_transform (data->image);
                XviewerTransform *auto_tf = xviewer_image_get_autorotate_transform (data->image);
                cairo_matrix_t mx, mx2;

                if (!tf && auto_tf) {
                    /* If only autorotation data present,
                     * make it the normal rotation. */
                    tf = auto_tf;
                    auto_tf = NULL;
                }

                /* Care must be taken with height and width values. They are not the original
                 * values but were affected by the transformation. As the surface needs to be
                 * generated using the original dimensions they might need to be flipped. */
                if (tf) {
                    if (auto_tf) {
                        /* If we have an autorotation apply
                         * it before the others */
                        tf = xviewer_transform_compose (auto_tf, tf);
                    }

                    switch (xviewer_transform_get_transform_type (tf)) {
                    case XVIEWER_TRANSFORM_ROT_90:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, height, width);
                        cairo_rotate (cr, 90.0 * (G_PI/180.0));
                        cairo_translate (cr, 0.0, -width);
                        break;
                    case XVIEWER_TRANSFORM_ROT_180:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, width, height);
                        cairo_rotate (cr, 180.0 * (G_PI/180.0));
                        cairo_translate (cr, -width, -height);
                        break;
                    case XVIEWER_TRANSFORM_ROT_270:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, height, width);
                        cairo_rotate (cr, 270.0 * (G_PI/180.0));
                        cairo_translate (cr, -height, 0.0);
                        break;
                    case XVIEWER_TRANSFORM_FLIP_HORIZONTAL:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, width, height);
                        cairo_matrix_init_identity (&mx);
                        _xviewer_cairo_matrix_flip (&mx2, &mx, TRUE, FALSE);
                        cairo_transform (cr, &mx2);
                        cairo_translate (cr, -width, 0.0);
                        break;
                    case XVIEWER_TRANSFORM_FLIP_VERTICAL:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, width, height);
                        cairo_matrix_init_identity (&mx);
                        _xviewer_cairo_matrix_flip (&mx2, &mx, FALSE, TRUE);
                        cairo_transform (cr, &mx2);
                        cairo_translate (cr, 0.0, -height);
                        break;
                    case XVIEWER_TRANSFORM_TRANSPOSE:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, height, width);
                        cairo_matrix_init_rotate (&mx, 90.0 * (G_PI/180.0));
                        cairo_matrix_init_identity (&mx2);
                        _xviewer_cairo_matrix_flip (&mx2, &mx2, TRUE, FALSE);
                        cairo_matrix_multiply (&mx2, &mx, &mx2);
                        cairo_transform (cr, &mx2);
                        break;
                    case XVIEWER_TRANSFORM_TRANSVERSE:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, height, width);
                        cairo_matrix_init_rotate (&mx, 90.0 * (G_PI/180.0));
                        cairo_matrix_init_identity (&mx2);
                        _xviewer_cairo_matrix_flip (&mx2, &mx2, FALSE, TRUE);
                        cairo_matrix_multiply (&mx2, &mx, &mx2);
                        cairo_transform (cr, &mx2);
                        cairo_translate (cr, -height , -width);
                        break;
                    case XVIEWER_TRANSFORM_NONE:
                    default:
                        surface = cairo_image_surface_create (
                                      CAIRO_FORMAT_RGB24, width, height);
                        break;
                    }
                }

                if (!surface)
                    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
                                                          width, height);
                cairo_surface_set_mime_data (surface,
                                             CAIRO_MIME_TYPE_JPEG,
                                             (unsigned char*)img_data, data_len,
                                             g_free, img_data);
                cairo_set_source_surface (cr, surface, 0, 0);
                cairo_paint (cr);
                cairo_surface_destroy (surface);
                g_object_unref (file);
                return;
            }
            g_object_unref (file);

        }

    {
        GdkPixbuf *pixbuf;

        pixbuf = xviewer_image_get_pixbuf (data->image);
        gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
        cairo_paint (cr);
        g_object_unref (pixbuf);
    }
}
static void
photos_print_operation_draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr)
{
  PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (operation);
  GeglRectangle bbox;
  GdkPixbuf *pixbuf = NULL;
  GtkPageSetup *page_setup;
  cairo_t *cr;
  gdouble dpi_x;
  gdouble dpi_y;
  gdouble page_height;
  gdouble page_width;
  gdouble scale_factor_n;
  gdouble x0;
  gdouble y0;

  scale_factor_n = self->scale_factor / 100.0;
  bbox = gegl_node_get_bounding_box (self->node);

  dpi_x = gtk_print_context_get_dpi_x (context);
  dpi_y = gtk_print_context_get_dpi_x (context);

  switch (self->unit)
    {
    case GTK_UNIT_INCH:
      x0 = self->left_margin * dpi_x;
      y0 = self->top_margin  * dpi_y;
      break;
    case GTK_UNIT_MM:
      x0 = self->left_margin * dpi_x / 25.4;
      y0 = self->top_margin  * dpi_y / 25.4;
      break;
    case GTK_UNIT_NONE:
    case GTK_UNIT_POINTS:
    default:
      g_assert_not_reached ();
    }

  cr = gtk_print_context_get_cairo_context (context);
  cairo_translate (cr, x0, y0);

  page_setup = gtk_print_context_get_page_setup (context);
  page_width =  gtk_page_setup_get_page_width (page_setup, GTK_UNIT_POINTS);
  page_height = gtk_page_setup_get_page_height (page_setup, GTK_UNIT_POINTS);

  /* This is both a workaround for a bug in cairo's PDF backend, and
   * a way to ensure we are not printing outside the page margins.
   */
  cairo_rectangle (cr,
                   0,
                   0,
                   MIN (bbox.width * scale_factor_n, page_width),
                   MIN (bbox.height * scale_factor_n, page_height));
  cairo_clip (cr);
  cairo_scale (cr, scale_factor_n, scale_factor_n);

  pixbuf = photos_utils_create_pixbuf_from_node (self->node);
  if (pixbuf == NULL)
    goto out;

  gdk_cairo_set_source_pixbuf (cr, pixbuf, 0.0, 0.0);
  cairo_paint (cr);

 out:
  g_clear_object (&pixbuf);
}
Exemplo n.º 15
0
/* These take orientation, and margins into consideration */
static VALUE
rg_get_page_width(VALUE self, VALUE unit)
{
    return rb_float_new(gtk_page_setup_get_page_width(_SELF(self),
                                                      RVAL2GTKUNIT(unit)));
}