source: trunk/third/libgnomeprintui/examples/example_06.c @ 20964

Revision 20964, 2.2 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20963, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 *  example_06.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#define GNOME_PRINT_UNSTABLE_API
31
32#include <libgnomeprint/gnome-print.h>
33#include <libgnomeprint/gnome-print-job.h>
34#include <libgnomeprintui/gnome-print-dialog.h>
35#include <gtk/gtkwidget.h>
36#include <gtk/gtkdialog.h>
37#include <gtk/gtkmain.h>
38
39static void
40my_draw (GnomePrintContext *gpc)
41{
42        gnome_print_beginpage (gpc, "1");
43
44        gnome_print_moveto (gpc, 100, 100);
45        gnome_print_lineto (gpc, 200, 200);
46        gnome_print_stroke (gpc);
47       
48        gnome_print_showpage (gpc);
49}
50
51static void
52my_print (void)
53{
54        GnomePrintContext *gpc;
55        GnomePrintJob *job;
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
64        /* Run the dialog */
65        response = gnome_print_dialog_run (GNOME_PRINT_DIALOG (dialog));
66        if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL) {
67                g_print ("Printing was canceled\n");
68                return;
69        }
70
71        /* Draw & print */
72        g_print ("Printing ...\n");
73        my_draw (gpc);
74        gnome_print_job_close (job);
75        gnome_print_job_print (job);
76
77        g_object_unref (G_OBJECT (gpc));
78        g_object_unref (G_OBJECT (job));
79}
80
81int
82main (int argc, char * argv[])
83{
84        gtk_init (&argc, &argv);
85       
86        my_print ();
87
88        g_print ("Done...\n");
89
90        return 0;
91}
Note: See TracBrowser for help on using the repository browser.