gtk_print_operation_new & g_signal_connect_data is not calling the Closure function
- From: "Rodrigo Miguel" <rodrmigu gmail com>
- To: gtk-app-devel-list gnome org
- Subject: gtk_print_operation_new & g_signal_connect_data is not calling the Closure function
- Date: Thu, 27 Nov 2008 12:55:36 -0200
Hello All,
I don't know if that is the normal behavior, but some reason the
GClosureNotify function is not being called when used with
gtk_print_operation pointer.
Here is the sample that I used:
#include <math.h>
#include <pango/pangocairo.h>
#include <gtk/gtk.h>
#include <gtk/gtkprintoperation.h>
void test(gpointer data)
{
g_print("Not through here!\n");
}
static void
draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
int page_nr)
{
cairo_t *cr;
PangoLayout *layout;
PangoFontDescription *desc;
cr = gtk_print_context_get_cairo_context (context);
cairo_set_source_rgb (cr, 1.0, 0, 0);
cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), 50);
cairo_fill (cr);
cairo_move_to (cr, 20, 10);
cairo_line_to (cr, 40, 20);
cairo_arc (cr, 60, 60, 20, 0, G_PI);
cairo_line_to (cr, 80, 20);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width (cr, 5);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_stroke (cr);
layout = gtk_print_context_create_pango_layout (context);
pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
desc = pango_font_description_from_string ("sans 28");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
cairo_move_to (cr, 30, 20);
pango_cairo_layout_path (cr, layout);
cairo_set_source_rgb (cr, 0.93, 1.0, 0.47);
cairo_set_line_width (cr, 0.5);
cairo_stroke_preserve (cr);
cairo_set_source_rgb (cr, 0, 0.0, 1.0);
cairo_fill (cr);
g_object_unref (layout);
}
int
main (int argc, char **argv)
{
GtkPrintOperation *print;
GtkPrintOperationResult res;
gtk_init (&argc, &argv);
print = gtk_print_operation_new ();
gtk_print_operation_set_n_pages (print, 1);
gtk_print_operation_set_export_filename (print, "test.pdf");
/************************/
g_signal_connect_data(print, "draw_page", G_CALLBACK (draw_page),
NULL, (GClosureNotify) test, (GConnectFlags) 0);
/************************/
res = gtk_print_operation_run (print,
GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, NULL);
return 0;
}
Any Ideas or comments?
Thanks in advance
Rodrigo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]