Back to index

lightning-sunbird  0.9+nobinonly
nsPrintdGTK.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Modified: syd@netscape.com 10/18/99 wired in margins
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 /* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
00040 
00041 #include <string.h>
00042 #include <gtk/gtk.h>
00043 
00044 #include "nspr.h"
00045 
00046 #include "nsPrintdGTK.h"
00047 
00048 /* A structure to hold widgets that need to be referenced in callbacks. We
00049    declare this statically in the caller entry point (as a field of 
00050    UnixPrOps, below), and pass a pointer to the structure to Gtk+ for each 
00051    signal handler registered. This avoids use of globals. */
00052 
00053 typedef struct prwidgets {
00054        GtkWidget *toplevel;        /* should be set to toplevel window */
00055        GtkWidget *prDialog;        
00056        GtkWidget *cmdEntry;
00057        GtkWidget *pathEntry;
00058        GtkWidget *browseButton;
00059        GtkWidget *fpfToggle;
00060        GtkWidget *greyToggle;
00061        GtkWidget *letterToggle;
00062        GtkWidget *legalToggle;
00063        GtkWidget *execToggle;
00064        GtkWidget *topSpinner;
00065        GtkWidget *bottomSpinner;
00066        GtkWidget *leftSpinner;
00067        GtkWidget *rightSpinner;
00068        GtkFileSelection *fsWidget;
00069 } PrWidgets;
00070 
00071 typedef struct unixprops {
00072        UnixPrData *prData;  /* pointer to caller struct */
00073        PrWidgets widgets;    
00074 } UnixPrOps;
00075 
00076 /* user clicked cancel. tear things down, and set cancel field in 
00077    caller data to PR_TRUE so printing will not happen */
00078 
00079 static void
00080 CancelPrint (GtkWidget *widget, UnixPrOps *prOps)
00081 {
00082        gtk_main_quit();
00083        gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
00084        prOps->prData->cancel = PR_TRUE;
00085 }
00086 
00087 /* user selected the Print button. Collect any remaining data from the
00088    widgets, and set cancel field in caller data to PR_FALSE so printing
00089    will be performed. Also, tear down dialog and exit inner main loop */
00090  
00091 static void
00092 DoPrint (GtkWidget *widget, UnixPrOps *prOps)
00093 {
00094        strcpy( prOps->prData->command, 
00095               gtk_entry_get_text( GTK_ENTRY( prOps->widgets.cmdEntry ) ) );
00096        strcpy( prOps->prData->path, 
00097               gtk_entry_get_text( GTK_ENTRY( prOps->widgets.pathEntry ) ) );
00098 
00099        if ( GTK_TOGGLE_BUTTON( prOps->widgets.fpfToggle )->active == PR_TRUE )
00100               prOps->prData->fpf = PR_TRUE;
00101        else
00102               prOps->prData->fpf = PR_FALSE;
00103 
00104        if ( GTK_TOGGLE_BUTTON( prOps->widgets.greyToggle )->active == PR_TRUE )
00105               prOps->prData->grayscale = PR_TRUE;
00106        else
00107               prOps->prData->grayscale = PR_FALSE;
00108        if ( GTK_TOGGLE_BUTTON( prOps->widgets.letterToggle )->active == PR_TRUE )
00109               prOps->prData->size = NS_LETTER_SIZE;
00110        else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
00111               prOps->prData->size = NS_LEGAL_SIZE;
00112        else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
00113               prOps->prData->size = NS_EXECUTIVE_SIZE;
00114        else
00115               prOps->prData->size = NS_A4_SIZE;
00116 
00117        /* margins */
00118 
00119        prOps->prData->top = gtk_spin_button_get_value_as_float( 
00120               GTK_SPIN_BUTTON(prOps->widgets.topSpinner) );
00121        prOps->prData->bottom = gtk_spin_button_get_value_as_float( 
00122               GTK_SPIN_BUTTON(prOps->widgets.bottomSpinner) );
00123        prOps->prData->left = gtk_spin_button_get_value_as_float( 
00124               GTK_SPIN_BUTTON(prOps->widgets.leftSpinner) );
00125        prOps->prData->right = gtk_spin_button_get_value_as_float( 
00126               GTK_SPIN_BUTTON(prOps->widgets.rightSpinner) );
00127 
00128        /* we got everything... bring down the dialog and tell caller
00129           it's o.k. to print */
00130 
00131        gtk_main_quit();
00132        gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
00133        prOps->prData->cancel = PR_FALSE;
00134 }
00135 
00136 /* User hit ok in file selection widget brought up by the browse button.
00137    snarf the selected file, stuff it in caller data */
00138 
00139 static void
00140 ModifyPrPath (GtkWidget *widget, UnixPrOps *prOps)
00141 {
00142        strcpy( prOps->prData->path, 
00143               gtk_file_selection_get_filename(prOps->widgets.fsWidget) );
00144        gtk_entry_set_text (GTK_ENTRY (prOps->widgets.pathEntry), 
00145               prOps->prData->path);
00146        gtk_widget_destroy( GTK_WIDGET(prOps->widgets.fsWidget) );
00147 }
00148 
00149 /* user selected print to printer. de-sensitize print to file fields */
00150 
00151 static void
00152 SwitchToPrinter (GtkWidget *widget, UnixPrOps *prOps)
00153 {
00154        gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_TRUE );
00155        gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_FALSE );
00156        gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_FALSE );
00157        prOps->prData->toPrinter = PR_TRUE;
00158 }
00159 
00160 /* user selected print to file. de-sensitize print to printer fields */
00161 
00162 static void
00163 SwitchToFile (GtkWidget *widget, UnixPrOps *prOps)
00164 {
00165        gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_FALSE );
00166        gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_TRUE );
00167        gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_TRUE );
00168        prOps->prData->toPrinter = PR_FALSE;
00169 }
00170 
00171 /* user hit the browse button. Pop up a file selection widget and grab
00172    result */
00173 
00174 static void
00175 GetPrPath (GtkWidget *widget, UnixPrOps *prOps)
00176 {
00177     GtkWidget *fs;
00178 
00179     fs = gtk_file_selection_new("File Browser");
00180 
00181     gtk_file_selection_set_filename( GTK_FILE_SELECTION(fs), 
00182        prOps->prData->path );
00183 
00184     gtk_window_set_modal (GTK_WINDOW(fs),PR_TRUE);
00185 
00186 #if 0
00187     /* XXX not sure what the toplevel window should be. */
00188 
00189     gtk_window_set_transient_for (GTK_WINDOW (fs), 
00190        GTK_WINDOW (prOps->widgets.toplevel));
00191 #endif
00192 
00193     prOps->widgets.fsWidget = GTK_FILE_SELECTION(fs);
00194 
00195     gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), 
00196        "clicked", GTK_SIGNAL_FUNC(ModifyPrPath), prOps);
00197 
00198     gtk_signal_connect_object (GTK_OBJECT(
00199        GTK_FILE_SELECTION(fs)->cancel_button), "clicked",
00200        GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (fs));
00201 
00202     gtk_widget_show(fs);
00203 }
00204 
00205 /* create file data dialog. XXX widget should be NULL */
00206 
00207 static void
00208 DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
00209 {
00210        GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox, 
00211               *button, *fileButton, *prButton, *table, *spinner1;
00212         GtkAdjustment *adj;
00213 
00214        prOps->widgets.prDialog = dialog = 
00215               gtk_window_new( GTK_WINDOW_TOPLEVEL );
00216        gtk_window_set_modal( GTK_WINDOW(dialog), PR_TRUE );
00217 #if 0
00218        /* not yet sure what the toplevel window should be */
00219 
00220         gtk_window_set_transient_for (GTK_WINDOW (dialog), 
00221               GTK_WINDOW (prOps->widgets.toplevel));
00222 #endif
00223        gtk_window_set_title( GTK_WINDOW(dialog), "Print" );
00224 
00225        vbox = gtk_vbox_new (PR_FALSE, 0);
00226         gtk_container_add (GTK_CONTAINER (dialog), vbox);
00227 
00228        table = gtk_table_new (3, 3, PR_FALSE);
00229        gtk_table_set_row_spacings (GTK_TABLE (table), 5);
00230         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
00231         gtk_container_set_border_width (GTK_CONTAINER (table), 10);
00232         gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_TRUE, 5);
00233        label = gtk_label_new( "Print To:" );
00234        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
00235               0, GTK_EXPAND | GTK_FILL, 0, 0);
00236        button = prButton = gtk_radio_button_new_with_label (NULL, "Printer");
00237         if ( prOps->prData->toPrinter == PR_TRUE ) 
00238               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00239               PR_TRUE);
00240        gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
00241               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00242 
00243        button = fileButton = gtk_radio_button_new_with_label (
00244               gtk_radio_button_group (GTK_RADIO_BUTTON (button)), "File");
00245        gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
00246               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00247         if ( prOps->prData->toPrinter == PR_FALSE ) 
00248               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00249               PR_TRUE);
00250 
00251        label = gtk_label_new( "Print Command:" );
00252        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
00253               0, GTK_EXPAND | GTK_FILL, 0, 0);
00254        entry = gtk_entry_new ();
00255        gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->command);
00256        gtk_table_attach (GTK_TABLE (table), entry, 1, 3, 1, 2,
00257               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00258        if ( prOps->prData->toPrinter == PR_FALSE )
00259               gtk_widget_set_sensitive( entry, PR_FALSE );
00260        prOps->widgets.cmdEntry = entry;
00261 
00262        label = gtk_label_new( "File Name:" );
00263        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
00264               0, GTK_EXPAND | GTK_FILL, 0, 0);
00265        entry = gtk_entry_new ();
00266        gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
00267               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00268        gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->path);
00269        if ( prOps->prData->toPrinter == PR_TRUE )
00270               gtk_widget_set_sensitive( entry, PR_FALSE );
00271        prOps->widgets.pathEntry = entry;
00272 
00273        button = gtk_button_new_with_label ("Browse...");
00274        gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
00275               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00276        gtk_signal_connect (GTK_OBJECT (button), "clicked",
00277               GTK_SIGNAL_FUNC (GetPrPath), prOps);
00278        if ( prOps->prData->toPrinter == PR_TRUE )
00279               gtk_widget_set_sensitive( entry, PR_FALSE );
00280        prOps->widgets.browseButton = button;
00281 
00282        separator = gtk_hseparator_new ();
00283        gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
00284 
00285        table = gtk_table_new (2, 4, PR_FALSE);
00286        gtk_table_set_row_spacings (GTK_TABLE (table), 5);
00287         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
00288         gtk_container_set_border_width (GTK_CONTAINER (table), 10);
00289        gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
00290 
00291        label = gtk_label_new( "Print: " );
00292        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
00293               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00294        button = gtk_radio_button_new_with_label (NULL, "First Page First");
00295         if ( prOps->prData->fpf == PR_TRUE ) 
00296               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00297               PR_TRUE);
00298        prOps->widgets.fpfToggle = button;
00299        gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
00300               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00301        button = gtk_radio_button_new_with_label (
00302               gtk_radio_button_group (GTK_RADIO_BUTTON (button)), 
00303               "Last Page First");
00304         if ( prOps->prData->fpf == PR_FALSE ) 
00305               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00306               PR_TRUE);
00307        gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
00308               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00309 
00310        label = gtk_label_new( "Print: " );
00311        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
00312               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00313        button = gtk_radio_button_new_with_label (NULL, "Greyscale");
00314        prOps->widgets.greyToggle = button;
00315         if ( prOps->prData->grayscale == PR_TRUE ) 
00316               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00317               PR_TRUE);
00318        gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3,
00319               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00320        button = gtk_radio_button_new_with_label (
00321               gtk_radio_button_group (GTK_RADIO_BUTTON (button)), 
00322               "Color");
00323         if ( prOps->prData->grayscale == PR_FALSE ) 
00324               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00325               PR_TRUE);
00326        gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
00327               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00328 
00329        label = gtk_label_new( "Paper Size: " );
00330        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
00331               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00332        button = gtk_radio_button_new_with_label (NULL, 
00333               "Letter (8 1/2 x 11 in.)");
00334        prOps->widgets.letterToggle = button;
00335         if ( prOps->prData->size == NS_LETTER_SIZE ) 
00336               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00337               PR_TRUE);
00338        gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4,
00339               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00340        button = gtk_radio_button_new_with_label (
00341               gtk_radio_button_group (GTK_RADIO_BUTTON (button)), 
00342               "Legal (8 1/2 x 14 in.)");
00343        prOps->widgets.legalToggle = button;
00344         if ( prOps->prData->size == NS_LEGAL_SIZE ) 
00345               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00346               PR_TRUE);
00347        gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
00348               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00349 
00350        button = gtk_radio_button_new_with_label (
00351               gtk_radio_button_group (GTK_RADIO_BUTTON (button)), 
00352               "Executive (7 1/2 x 10 in.)");
00353        prOps->widgets.execToggle = button;
00354         if ( prOps->prData->size == NS_EXECUTIVE_SIZE ) 
00355               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00356               PR_TRUE);
00357        gtk_table_attach (GTK_TABLE (table), button, 1, 2, 4, 5,
00358               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00359        button = gtk_radio_button_new_with_label (
00360               gtk_radio_button_group (GTK_RADIO_BUTTON (button)), 
00361               "A4 (210 x 297 mm)");
00362         if ( prOps->prData->size == NS_A4_SIZE ) 
00363               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
00364               PR_TRUE);
00365        gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
00366               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00367 
00368        /* margins */
00369 
00370        separator = gtk_hseparator_new ();
00371        gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
00372 
00373        hbox = gtk_hbox_new (PR_FALSE, 0);
00374        gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_FALSE, PR_FALSE, 5);
00375        label = gtk_label_new( "Margins (inches):" );
00376        gtk_box_pack_start (GTK_BOX (hbox), label, PR_FALSE, PR_FALSE, 10);
00377 
00378        table = gtk_table_new (1, 2, PR_FALSE);
00379        gtk_table_set_row_spacings (GTK_TABLE (table), 5);
00380         gtk_table_set_col_spacings (GTK_TABLE (table), 5);
00381         gtk_container_set_border_width (GTK_CONTAINER (table), 10);
00382        gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
00383        hbox = gtk_hbox_new (PR_FALSE, 0);
00384        gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 0, 1,
00385               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00386        label = gtk_label_new( "Top: " );
00387        gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
00388         adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->top, 0.0, 999.0,
00389               0.25, 1.0, 0.0);
00390         prOps->widgets.topSpinner = spinner1 = 
00391               gtk_spin_button_new (adj, 1.0, 2);
00392         gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
00393         gtk_widget_set_usize (spinner1, 60, 0);
00394         gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
00395 
00396        label = gtk_label_new( "Bottom: " );
00397        gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
00398         adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->bottom, 0.0, 999.0,
00399               0.25, 1.0, 0.0);
00400         prOps->widgets.bottomSpinner = spinner1 = 
00401               gtk_spin_button_new (adj, 1.0, 2);
00402         gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
00403         gtk_widget_set_usize (spinner1, 60, 0);
00404         gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
00405        
00406        hbox = gtk_hbox_new (PR_FALSE, 0);
00407        gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
00408               GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
00409 
00410        label = gtk_label_new( "Left: " );
00411        gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
00412         adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->left, 0.0, 999.0,
00413               0.25, 1.0, 0.0);
00414         prOps->widgets.leftSpinner = spinner1 = 
00415               gtk_spin_button_new (adj, 1.0, 2);
00416         gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
00417         gtk_widget_set_usize (spinner1, 60, 0);
00418         gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
00419 
00420        label = gtk_label_new( "Right: " );
00421        gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
00422         adj = (GtkAdjustment *) gtk_adjustment_new ( prOps->prData->right, 0.0, 999.0,
00423               0.25, 1.0, 0.0);
00424         prOps->widgets.rightSpinner = spinner1 = 
00425               gtk_spin_button_new (adj, 1.0, 2);
00426         gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
00427         gtk_widget_set_usize (spinner1, 60, 0);
00428         gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
00429 
00430        separator = gtk_hseparator_new ();
00431        gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
00432 
00433         hbox = gtk_hbox_new (PR_FALSE, 0);
00434         gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_TRUE, PR_FALSE, 5);
00435        button = gtk_button_new_with_label ("Print");
00436        gtk_signal_connect (GTK_OBJECT (button), "clicked",
00437               GTK_SIGNAL_FUNC (DoPrint), prOps );
00438         gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
00439 
00440        GTK_WIDGET_FLAGS (button) |= GTK_CAN_DEFAULT;
00441        gtk_widget_grab_default (button);
00442 
00443        button = gtk_button_new_with_label ("Cancel");
00444        gtk_signal_connect (GTK_OBJECT (button), "clicked",
00445               GTK_SIGNAL_FUNC ( CancelPrint ), prOps);
00446         gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
00447 
00448        /* Do this here, otherwise, upon creation the callbacks will be
00449            triggered and the widgets these callbacks set sensitivity on
00450           do not exist yet */
00451 
00452        gtk_signal_connect (GTK_OBJECT (prButton), "clicked",
00453               GTK_SIGNAL_FUNC (SwitchToPrinter), prOps);
00454        gtk_signal_connect (GTK_OBJECT (fileButton), "clicked",
00455               GTK_SIGNAL_FUNC (SwitchToFile), prOps);
00456 
00457        gtk_widget_show_all( dialog );
00458        gtk_main ();
00459 }
00460 
00461 /* public interface to print dialog. Caller passes in preferences using
00462    argument, we return any changes and indication of whether to print
00463    or cancel. */
00464 
00465 void
00466 UnixPrDialog( UnixPrData *prData )
00467 {
00468        static UnixPrOps prOps;
00469 
00470        prOps.prData = prData;
00471        DoPrintGTK( (GtkWidget *) NULL, &prOps );
00472 }
00473