[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Printing a .png using GtkPrint
From:       Richard Shann <richard.shann () virgin ! net>
Date:       2009-11-17 16:51:58
Message-ID: 1258476718.3588.49.camel () debianrts ! home
[Download RAW message or body]

I am trying to use GtkPrint* to print a .png file, the code I have tried
pops up the print dialog but nothing arrives in the printer queue. The
draw page signal is being received when I ok the print dialog.

The function I am using for the draw-page signal to try and print is
this:

static void
draw_page (GtkPrintOperation *operation,
           GtkPrintContext   *context,
           gint               page_nr,
           gpointer           user_data) {
  if(page_nr==0){
    g_print("printing page 0");
  //gtk_print_operation_set_use_full_page() and gtk_print_operation_set_unit()
  cairo_t * cr = gtk_print_context_get_cairo_context (context);
  cairo_surface_t *surface = cairo_image_surface_create_from_png ("denemoprint_.png");
  cairo_status_t  status = cairo_surface_status(surface);
  if(status != CAIRO_STATUS_SUCCESS)
    g_print("An error %d\n", status);
  cairo_set_source_surface (cr, surface, 0, 0);
  cairo_paint (cr);
  cairo_surface_destroy (surface);
  } else
    gtk_print_operation_cancel (operation);
  g_print("returning from draw\n");
}

Which has been assembled from the gtk docs and the cairo samples at
http://www.cairographics.org/samples/
The draw_page function is being called for page_nr 0 and the png load is
ok but as I say, nothing more transpires.

The bits of code that I have invented here are the calls to
cairo_surface_destroy (surface); 
and 
gtk_print_operation_cancel (operation);

The first of these can be left out, but the second prevents draw_page
being called ad infinitum.

Anyone have a working example? I am using Debian Lenny standard standard
packages.

Richard Shann


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic