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

List:       gtk
Subject:    Problem with gtk_print_operation_run()
From:       Zoltan Boszormenyi <zboszor () freemail ! hu>
Date:       2012-10-05 11:38:56
Message-ID: 506EC6D0.5070708 () freemail ! hu
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

I have problems using the printing feature with this GTK 2.x code:

----8<--------8<--------8<--------8<--------8<----
         GtkPrintOperation *print;
         GtkPrintOperationResult res;

         print = gtk_print_operation_new ();

         if (settings != NULL)
                 gtk_print_operation_set_print_settings (print, settings);

         g_signal_connect (print, "status-changed", G_CALLBACK (print_status_changed), NULL);
         g_signal_connect (print, "begin-print", G_CALLBACK (begin_print), NULL);
         g_signal_connect (print, "request-page-setup", G_CALLBACK 
(print_request_page_setup), NULL);
         g_signal_connect (print, "done", G_CALLBACK (print_done), NULL);
         g_signal_connect (print, "end-print", G_CALLBACK (print_end), NULL);
         g_signal_connect (print, "paginate", G_CALLBACK (print_paginate), NULL);
         g_signal_connect (print, "draw-page", G_CALLBACK (draw_page), NULL);

         gtk_print_operation_set_allow_async(print, FALSE);
         gtk_print_operation_set_job_name(operation, "myprog");
         gtk_print_operation_set_n_pages(operation, n_pages);
         gtk_print_operation_set_use_full_page (operation, TRUE);
         gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);

         res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                                 GTK_WINDOW (main_window), NULL);

         printf("on_button5_clicked gtk_print_operation_run result: %d\n", res);
----8<--------8<--------8<--------8<--------8<----

The problem is that my code only receives the "status-changed" event twice,
once with |GTK_PRINT_STATUS_INITIAL |and then with |GTK_PRINT_STATUS_PREPARING|. At this 
point,
the printer dialog disappears but my code doesn't receive any other printing event
or the result of gtk_print_operation_run().

I have used
         gtk_print_operation_set_allow_async(print, FALSE);
since I want the printing to be synchronous, at least up to spooling the print job.
The same happens without gtk_print_operation_set_allow_async(), I guess this is
the default.

The printing events progress further only when I press Ctrl-C in the terminal
from where I started this program. Only then I receive these in order:
- begin-print
- paginate
- status-change with status = |GTK_PRINT_STATUS_GENERATING_DATA
|- request-page-setup with page_nr 0
- draw-page with page_nr 0
- end-print
- status-change with status = |GTK_PRINT_STATUS_SENDING_DATA|
- status-change with status = |GTK_PRINT_STATUS_PRINTING|
- done with result = GTK_PRINT_OPERATION_RESULT_APPLY

Do I have to do something special in the status-changed callback to drive the
printing further? I am on Fedora 17/x86_64 if that's interesting.

Thanks in advance,
Zoltán Böszörményi


[Attachment #5 (text/html)]

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-2">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    I have problems using the printing feature with this GTK 2.x code:<br>
    <br>
    ----8&lt;--------8&lt;--------8&lt;--------8&lt;--------8&lt;----<br>
            GtkPrintOperation *print;<br>
            GtkPrintOperationResult res; <br>
    <br>
            print = gtk_print_operation_new ();<br>
    <br>
            if (settings != NULL)  <br>
                    gtk_print_operation_set_print_settings (print,
    settings);<br>
    <br>
            g_signal_connect (print, "status-changed", G_CALLBACK
    (print_status_changed), NULL);<br>
            g_signal_connect (print, "begin-print", G_CALLBACK
    (begin_print), NULL);<br>
            g_signal_connect (print, "request-page-setup", G_CALLBACK
    (print_request_page_setup), NULL);<br>
            g_signal_connect (print, "done", G_CALLBACK (print_done),
    NULL);<br>
            g_signal_connect (print, "end-print", G_CALLBACK
    (print_end), NULL);<br>
            g_signal_connect (print, "paginate", G_CALLBACK
    (print_paginate), NULL);<br>
            g_signal_connect (print, "draw-page", G_CALLBACK
    (draw_page), NULL);<br>
    <br>
            gtk_print_operation_set_allow_async(print, FALSE);<br>
            gtk_print_operation_set_job_name(operation, "myprog");<br>
            gtk_print_operation_set_n_pages(operation, n_pages);<br>
            gtk_print_operation_set_use_full_page (operation, TRUE);<br>
            gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);<br>
    <br>
            res = gtk_print_operation_run (print,
    GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,<br>
                                                    GTK_WINDOW
    (main_window), NULL);<br>
    <br>
            printf("on_button5_clicked gtk_print_operation_run result:
    %d\n", res);<br>
    ----8&lt;--------8&lt;--------8&lt;--------8&lt;--------8&lt;----<br>
    <br>
    The problem is that my code only receives the "status-changed" event
    twice,<br>
    once with <span class="term"><code class="literal">GTK_PRINT_STATUS_INITIAL
      </code></span>and then with <span class="term"><code
        class="literal">GTK_PRINT_STATUS_PREPARING</code></span>. At
    this point,<br>
    the printer dialog disappears but my code doesn't receive any other
    printing event<br>
    or the result of gtk_print_operation_run().<br>
    <br>
    I have used<br>
            gtk_print_operation_set_allow_async(print, FALSE);<br>
    since I want the printing to be synchronous, at least up to spooling
    the print job.<br>
    The same happens without gtk_print_operation_set_allow_async(), I
    guess this is<br>
    the default.<br>
    <br>
    The printing events progress further only when I press Ctrl-C in the
    terminal<br>
    from where I started this program. Only then I receive these in
    order:<br>
    - begin-print<br>
    - paginate<br>
    - status-change with status = <span class="term"><code
        class="literal">GTK_PRINT_STATUS_GENERATING_DATA<br>
      </code></span>- request-page-setup with page_nr 0<br>
    - draw-page with page_nr 0<br>
    - end-print<br>
    - status-change with status = <span class="term"><code
        class="literal">GTK_PRINT_STATUS_SENDING_DATA</code></span><br>
    - status-change with status = <span class="term"><code
        class="literal">GTK_PRINT_STATUS_PRINTING</code></span><br>
    - done with result = GTK_PRINT_OPERATION_RESULT_APPLY<br>
    <br>
    Do I have to do something special in the status-changed callback to
    drive the<br>
    printing further? I am on Fedora 17/x86_64 if that's interesting.<br>
    <br>
    Thanks in advance,<br>
    Zoltán Böszörményi<br>
    <br>
  </body>
</html>


_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


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

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