GtkPrintOperation problem

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

 



I'm running into a problem where the second print operation is  
failing.  The first print operation presents a dialog, and prints  
successfully, but the second print operation calls straight through  
without bringing up the dialog (this is what I want, bringing up the  
dialog again seems to work, but I'm trying to avoid that), but this  
second print operation fails with RESULT_CANCEL.  Perhaps there's a  
simple setting I forgot to  set on the second print operation?  Any  
help would be appreciated, thanks.

~William

static GtkPrintOperationResult DoPrint( GtkPrintOperation *operation,  
GtkPrintOperationAction action, GError **error )
{
	g_signal_connect (operation, "begin-print",
			  G_CALLBACK (print_operation_begin), NULL);
	g_signal_connect (operation, "draw-page",
			  G_CALLBACK (print_operation_draw), NULL);

	GtkPrintOperationResult res = gtk_print_operation_run (operation,
				 action,
				 NULL,
				 error);

	return res;
}

gint main (gint argc, gchar *argv[])
{
	GtkPrintOperation *operation;
	GError            *error = NULL;
	GtkPrintOperationResult res;

	gtk_init (&argc, &argv);

	operation = gtk_print_operation_new ();
	
	res = DoPrint( operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,  
&error );

	// Succeeds
	printf("res = %d\n", res);
	if (error) {
		printf("error = %s\n", error->message);
		g_error_free (error);
		error = NULL;
	}

	GtkPrintSettings *settings = gtk_print_operation_get_print_settings 
( operation );
	g_object_ref(settings);

	g_object_unref(operation);

	// Again fails
	operation = gtk_print_operation_new ();

	res = DoPrint( operation, GTK_PRINT_OPERATION_ACTION_PRINT, &error );

	// Returns GTK_PRINT_OPERATION_RESULT_CANCEL
	printf("res = %d\n", res);
	if (error) {
		printf("error = %s\n", error->message);
		g_error_free (error);
	}

	g_object_unref(operation);

	return 0;
}
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux