~ubuntu-branches/ubuntu/quantal/gbonds/quantal

« back to all changes in this revision

Viewing changes to src/print-dialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Richard Laager
  • Date: 2007-03-14 23:50:34 UTC
  • Revision ID: james.westby@ubuntu.com-20070314235034-997qegw33jx0wb9r
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  (GBONDS) GNOME based Savings Bond Inventory Program
 
3
 *
 
4
 *  print-dialog.c:  Print dialog module
 
5
 *
 
6
 *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
 
7
 *
 
8
 *  This program is free software; you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU General Public License as published by
 
10
 *  the Free Software Foundation; either version 2 of the License, or
 
11
 *  (at your option) any later version.
 
12
 *
 
13
 *  This program is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with this program; if not, write to the Free Software
 
20
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
21
 */
 
22
#include <config.h>
 
23
 
 
24
#include <math.h>
 
25
#include <time.h>
 
26
#include <ctype.h>
 
27
#include <gtk/gtk.h>
 
28
#include <libgnomeprint/gnome-print-paper.h>
 
29
#include <libgnomeprintui/gnome-print-dialog.h>
 
30
#include <libgnomeprint/gnome-print-job.h>
 
31
#include <libgnomeprintui/gnome-print-job-preview.h>
 
32
 
 
33
#include "print-dialog.h"
 
34
#include "hig.h"
 
35
#include "print.h"
 
36
#include "doc.h"
 
37
 
 
38
#include "debug.h"
 
39
 
 
40
/*===========================================*/
 
41
/* Private types.                            */
 
42
/*===========================================*/
 
43
 
 
44
/*===========================================*/
 
45
/* Private globals.                          */
 
46
/*===========================================*/
 
47
 
 
48
/*===========================================*/
 
49
/* Private function prototypes.              */
 
50
/*===========================================*/
 
51
static void print_response (GtkDialog *dlg,
 
52
                            gint       response,
 
53
                            gbView    *view);
 
54
 
 
55
 
 
56
/*****************************************************************************/
 
57
/* "Print" dialog.                                                           */
 
58
/*****************************************************************************/
 
59
void
 
60
gb_print_dialog (gbView *view, BonoboWindow *win)
 
61
{
 
62
        GtkWidget *dlg;
 
63
 
 
64
        g_return_if_fail (view && GB_IS_VIEW(view));
 
65
        g_return_if_fail (win && BONOBO_IS_WINDOW(win));
 
66
 
 
67
        dlg = gnome_print_dialog_new (NULL, _("Print inventory"), 0);
 
68
 
 
69
        gtk_window_set_transient_for (GTK_WINDOW(dlg), GTK_WINDOW(win));
 
70
 
 
71
        g_signal_connect (G_OBJECT(dlg), "response",
 
72
                          G_CALLBACK (print_response), view);
 
73
 
 
74
        gtk_widget_show (dlg);
 
75
}
 
76
 
 
77
/*---------------------------------------------------------------------------*/
 
78
/* PRIVATE.  Print "response" callback.                                      */
 
79
/*---------------------------------------------------------------------------*/
 
80
static void
 
81
print_response (GtkDialog *dlg,
 
82
                gint       response,
 
83
                gbView     *view)
 
84
{
 
85
        GnomePrintConfig *config;
 
86
        GnomePrintJob    *job;
 
87
        GtkWidget        *preview;
 
88
 
 
89
        switch (response) {
 
90
 
 
91
        case GNOME_PRINT_DIALOG_RESPONSE_PRINT:
 
92
                config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG(dlg));
 
93
                job = gnome_print_job_new (config);
 
94
                gb_print (job, view);
 
95
                gnome_print_job_close (job);
 
96
                gnome_print_job_print (job);
 
97
                g_object_unref (G_OBJECT(job));
 
98
                break;
 
99
 
 
100
        case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW:
 
101
                config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG(dlg));
 
102
                job = gnome_print_job_new (config);
 
103
                gb_print (job, view);
 
104
                gnome_print_job_close (job);
 
105
                preview = gnome_print_job_preview_new (job, _("Print preview"));
 
106
                gtk_widget_show (preview);
 
107
                g_object_unref (G_OBJECT(job));
 
108
                break;
 
109
 
 
110
        default:
 
111
                break;
 
112
 
 
113
        }
 
114
 
 
115
        gtk_widget_destroy (GTK_WIDGET (dlg));
 
116
}
 
117