1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* |
---|
3 | * example_03.c: sample gnome-print code |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or |
---|
6 | * modify it under the terms of the GNU Library General Public License |
---|
7 | * as published by the Free Software Foundation; either version 2 of |
---|
8 | * the License, or (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU Library General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU Library General Public |
---|
16 | * License along with this program; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
18 | * |
---|
19 | * Authors: |
---|
20 | * Chema Celorio <chema@ximian.com> |
---|
21 | * |
---|
22 | * Copyright (C) 2002 Ximian Inc. and authors |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | /* |
---|
27 | * See README |
---|
28 | */ |
---|
29 | |
---|
30 | #include <libgnomeprint/gnome-print.h> |
---|
31 | #include <libgnomeprint/gnome-print-job.h> |
---|
32 | |
---|
33 | static void |
---|
34 | my_draw (GnomePrintContext *gpc) |
---|
35 | { |
---|
36 | GnomeFont *font; |
---|
37 | gint i; |
---|
38 | |
---|
39 | font = gnome_font_find_closest ("Helvetica", 12); |
---|
40 | |
---|
41 | gnome_print_beginpage (gpc, "1"); |
---|
42 | gnome_print_setfont (gpc, font); |
---|
43 | |
---|
44 | for (i = 0; i < 100; i++) { |
---|
45 | gnome_print_moveto (gpc, 100, 100); |
---|
46 | gnome_print_show (gpc, "This is example_03.c which uses GnomeFont\n"); |
---|
47 | } |
---|
48 | |
---|
49 | gnome_print_showpage (gpc); |
---|
50 | |
---|
51 | g_object_unref (G_OBJECT (font)); |
---|
52 | } |
---|
53 | |
---|
54 | static void |
---|
55 | my_print (void) |
---|
56 | { |
---|
57 | GnomePrintJob *job; |
---|
58 | GnomePrintContext *gpc; |
---|
59 | |
---|
60 | job = gnome_print_job_new (NULL); |
---|
61 | gpc = gnome_print_job_get_context (job); |
---|
62 | |
---|
63 | my_draw (gpc); |
---|
64 | |
---|
65 | gnome_print_job_close (job); |
---|
66 | gnome_print_job_print (job); |
---|
67 | |
---|
68 | g_object_unref (G_OBJECT (gpc)); |
---|
69 | g_object_unref (G_OBJECT (job)); |
---|
70 | } |
---|
71 | |
---|
72 | int |
---|
73 | main (int argc, char * argv[]) |
---|
74 | { |
---|
75 | g_type_init (); |
---|
76 | |
---|
77 | my_print (); |
---|
78 | |
---|
79 | g_print ("Done...\n"); |
---|
80 | |
---|
81 | return 0; |
---|
82 | } |
---|