Re: gtk_print_operation_run hang



I'm still trying to get this working.

Given this basic code:

static void begin_print(GtkPrintOperation *operation, GtkPrintContext
*context,    gpointer data)
{
    gtk_print_operation_set_n_pages(operation, 1);
    printf("begin_print\n");
}


static void draw_page(GtkPrintOperation *operation, GtkPrintContext
*context, gint page_num, gpointer data)
{
    printf("draw_page\n");
}


static void end_print(GtkPrintOperation *operation, GtkPrintContext
*context, gpointer data)
{
    printf("end_print\n");
}

GtkPrintOperationResult res;
    GtkPrintOperation *operation = gtk_print_operation_new();
    if (operation)
    {
        GError *error = NULL;

        g_signal_connect(G_OBJECT(operation), "begin-print",
G_CALLBACK(begin_print), NULL);
        g_signal_connect(G_OBJECT(operation), "draw-page",
G_CALLBACK(draw_page), NULL);
        g_signal_connect(G_OBJECT(operation), "end-print",
G_CALLBACK(end_print), NULL);
        gtk_print_operation_set_show_progress(operation, true);

        res = gtk_print_operation_run(operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, &error);

        g_object_unref(operation);
    }

    return res != GTK_PRINT_OPERATION_RESULT_ERROR;


In practice when I call gtk_print_operation_run a printer selection
dialog appears, where I select a printer that I know works and then
when I click ok the "preparing" dialog appears. But none of my
callbacks are called. The code halts in print_pages at the call to
g_main_loop_run. Which is what it's supposed to do.

Is there some way forward to debug why it just stops there and doesn't
do anything?

Btw I've tried both the underscore and hypen versions of the signal
names. Some source examples use like "begin-print" and some use
"begin_print". But the docs say '-' so I'll stick with that for the
moment.

I wish I could trace all the signals... is there a way to print them
out to the console as they happen?


On 4 February 2016 at 22:43, Matthew Allen <memecode gmail com> wrote:
So I'm working on this code: GPrinter.cpp (and it's header).

And GPrinter::Print when I call gtk_print_operation_run I get a printer
selection dialog (on Ubuntu Linux), where I select a valid printer and click
OK. At which point I'm expecting it to call the begin-print signal so I can
calculate the number of pages. But instead nothing happens... at all.. it
just kinds waits forever.


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