1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* |
---|
3 | * example_08.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 | #define GNOME_PRINT_UNSTABLE_API |
---|
30 | |
---|
31 | #include <libgnomeprint/gnome-print.h> |
---|
32 | #include <libgnomeprint/gnome-print-job.h> |
---|
33 | #include <libgnomeprintui/gnome-print-dialog.h> |
---|
34 | #include <gtk/gtkwidget.h> |
---|
35 | #include <gtk/gtkdialog.h> |
---|
36 | #include <gtk/gtkmain.h> |
---|
37 | |
---|
38 | static void |
---|
39 | my_draw (GnomePrintContext *gpc) |
---|
40 | { |
---|
41 | gnome_print_beginpage (gpc, "1"); |
---|
42 | |
---|
43 | gnome_print_moveto (gpc, 100, 100); |
---|
44 | gnome_print_lineto (gpc, 200, 200); |
---|
45 | gnome_print_stroke (gpc); |
---|
46 | |
---|
47 | gnome_print_showpage (gpc); |
---|
48 | } |
---|
49 | |
---|
50 | static void |
---|
51 | my_print (void) |
---|
52 | { |
---|
53 | GnomePrintContext *gpc; |
---|
54 | GnomePrintJob *job; |
---|
55 | GnomePrintConfig *config; |
---|
56 | GtkWidget *dialog; |
---|
57 | gint response; |
---|
58 | |
---|
59 | /* Create the objects */ |
---|
60 | job = gnome_print_job_new (NULL); |
---|
61 | dialog = gnome_print_dialog_new (job, "Sample print dialog", 0); |
---|
62 | gpc = gnome_print_job_get_context (job); |
---|
63 | config = gnome_print_job_get_config (job); |
---|
64 | |
---|
65 | /* Run the dialog */ |
---|
66 | response = gnome_print_dialog_run (GNOME_PRINT_DIALOG (dialog)); |
---|
67 | if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT) { |
---|
68 | g_print ("Printing was canceled\n"); |
---|
69 | return; |
---|
70 | } |
---|
71 | |
---|
72 | /* We don't print, we only dump the info */ |
---|
73 | my_draw (gpc); |
---|
74 | gnome_print_config_dump (config); |
---|
75 | gnome_print_job_close (job); |
---|
76 | |
---|
77 | g_object_unref (gpc); |
---|
78 | g_object_unref (config); |
---|
79 | g_object_unref (job); |
---|
80 | } |
---|
81 | |
---|
82 | int |
---|
83 | main (int argc, char * argv[]) |
---|
84 | { |
---|
85 | gtk_init (&argc, &argv); |
---|
86 | |
---|
87 | my_print (); |
---|
88 | |
---|
89 | g_print ("Done...\n"); |
---|
90 | |
---|
91 | return 0; |
---|
92 | } |
---|