problem with the new printing API ...



I downloaded the example test from the source code.  It prints to a file correctly and I also assume it outputs to a printer.  The example uses settings directly from the command line, so I tried to configure it using a PrintDialog.  I tried several ways to achieve this.  In every case I used the test_print example from the source code.

* First I tried to configure it directly when I run gtk_print_operation_run() with the option GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG.  The program compiles and it shows the dialog but when I preview or try to print, the dialog exits and the program hangs.  My CPU goes up.  When I cancel it though it works correctly.

* The other test was using gtk_print_run_page_setup_dialog() and gtk_print_unix_dialog_new().  The program compiles, shows the dialog but it doesn't cancel nor apply the new settings.

Neither of these programs produce any warnings or errors and I'm using libgtk2 version 2.10.  I use Debian.  Here is the code from the two examples.  I ommited the implementation of the callbacks as they are the ones from the test_print example in the gtk source code ...

First program:

int main (int argc, char **argv)
{
  GtkPrintOperation *print;
  GtkPrintSettings* print_settings;
  gtk_init (&argc, &argv);

  /* Test some random drawing, with per-page paper settings */
  print = gtk_print_operation_new ();

  g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
  g_signal_connect (print, "request_page_setup", G_CALLBACK (request_page_setup), NULL);
  gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL);

/* Test subclassing of GtkPrintOperation */
  gtk_print_operation_run (GTK_PRINT_OPERATION (print_file), GTK_PRINT_OPERATION_PRINT_DIALOG, NULL, NULL);

  return 0;
}

Second Program:

int main (int argc, char **argv)
{
  GtkPrintOperation *print;
  GtkPageSetup* page_setup = gtk_page_setup_new();
  GtkPrintSettings* print_settings;
  gtk_init (&argc, &argv);

  GtkWidget* dialog = gtk_page_setup_unix_dialog_new( "Printer", NULL );
  gtk_widget_show( dialog );
  print_settings = gtk_page_setup_unix_dialog_get_print_settings( dialog );

  /* Test some random drawing, with per-page paper settings */
  print = gtk_print_operation_new ();

  gtk_print_operation_set_print_settings( print, print_settings );
  g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
  g_signal_connect (print, "request_page_setup", G_CALLBACK (request_page_setup), NULL);
  gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT, NULL, NULL);
  gtk_main(); 

  return 0;
}


Thanks !!!
--
teratux

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]