]> git.saurik.com Git - wxWidgets.git/commitdiff
Added support for native print preview (GNOME)
authorRobert Roebling <robert@roebling.de>
Thu, 18 Nov 2004 14:45:40 +0000 (14:45 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 18 Nov 2004 14:45:40 +0000 (14:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/gnome/gprint.h
include/wx/gtk1/gnome/gprint.h
src/gtk/gnome/gprint.cpp
src/gtk1/gnome/gprint.cpp

index aa407654187a12d71fb34a97d5810ee337c4632c..77e924d71134dc456f9b4e5c5a93c58a42bd58cd 100644 (file)
@@ -150,6 +150,7 @@ public:
     
 private:
     GnomePrintContext *m_gpc;
     
 private:
     GnomePrintContext *m_gpc;
+    bool               m_native_preview;
 
 private:
     DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
 
 private:
     DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
index aa407654187a12d71fb34a97d5810ee337c4632c..77e924d71134dc456f9b4e5c5a93c58a42bd58cd 100644 (file)
@@ -150,6 +150,7 @@ public:
     
 private:
     GnomePrintContext *m_gpc;
     
 private:
     GnomePrintContext *m_gpc;
+    bool               m_native_preview;
 
 private:
     DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
 
 private:
     DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
index c79170f630fd138526fa46ce25ec76e428b35c3c..2f35e4398735d24736014b3ee21ccca98bbe7cd6 100644 (file)
@@ -31,6 +31,7 @@
 #include <libgnomeprint/gnome-print.h>
 #include <libgnomeprint/gnome-print-pango.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 #include <libgnomeprint/gnome-print.h>
 #include <libgnomeprint/gnome-print-pango.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
+#include <libgnomeprintui/gnome-print-job-preview.h>
 
 //----------------------------------------------------------------------------
 // wxGnomePrintNativeData
 
 //----------------------------------------------------------------------------
 // wxGnomePrintNativeData
@@ -242,6 +243,9 @@ int wxGnomePrintDialog::ShowModal()
     gtk_widget_destroy(m_widget);
     m_widget = NULL;
     
     gtk_widget_destroy(m_widget);
     m_widget = NULL;
     
+    if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW)
+        return wxID_PREVIEW;
+    
     return wxID_OK;
 }
 
     return wxID_OK;
 }
 
@@ -276,6 +280,7 @@ wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) :
     wxPrinterBase( data )
 {
     m_gpc = NULL;
     wxPrinterBase( data )
 {
     m_gpc = NULL;
+    m_native_preview = false;
 }
 
 wxGnomePrinter::~wxGnomePrinter()
 }
 
 wxGnomePrinter::~wxGnomePrinter()
@@ -313,6 +318,9 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
     else
         dc = new wxGnomePrintDC( this );
     
     else
         dc = new wxGnomePrintDC( this );
     
+    if (m_native_preview)
+        printout->SetIsPreview(true);
+    
     if (!dc)
     {
         gnome_print_job_close( job );
     if (!dc)
     {
         gnome_print_job_close( job );
@@ -387,7 +395,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
     }
     
     gnome_print_job_close( job );
     }
     
     gnome_print_job_close( job );
-    gnome_print_job_print( job );
+    if (m_native_preview)
+    {
+        wxString title( _("Print preview") );
+        gtk_widget_show( gnome_print_job_preview_new( job, (const guchar*)(const char*)wxGTK_CONV(title) ));
+    }
+    else
+    {
+        gnome_print_job_print( job );
+    }
     
     delete dc;
     
     
     delete dc;
     
@@ -397,12 +413,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
 wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
 {
     wxGnomePrintDialog dialog( parent, &m_printDialogData );
 wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
 {
     wxGnomePrintDialog dialog( parent, &m_printDialogData );
-    if (dialog.ShowModal() == wxID_CANCEL)
+    int ret = dialog.ShowModal();
+    if (ret == wxID_CANCEL)
     {
         sm_lastError = wxPRINTER_ERROR;
         return NULL;
     }
     
     {
         sm_lastError = wxPRINTER_ERROR;
         return NULL;
     }
     
+    m_native_preview = ret == wxID_PREVIEW;
+    
     m_printDialogData = dialog.GetPrintDialogData();
     return new wxGnomePrintDC( this );
 }
     m_printDialogData = dialog.GetPrintDialogData();
     return new wxGnomePrintDC( this );
 }
index c79170f630fd138526fa46ce25ec76e428b35c3c..2f35e4398735d24736014b3ee21ccca98bbe7cd6 100644 (file)
@@ -31,6 +31,7 @@
 #include <libgnomeprint/gnome-print.h>
 #include <libgnomeprint/gnome-print-pango.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 #include <libgnomeprint/gnome-print.h>
 #include <libgnomeprint/gnome-print-pango.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
+#include <libgnomeprintui/gnome-print-job-preview.h>
 
 //----------------------------------------------------------------------------
 // wxGnomePrintNativeData
 
 //----------------------------------------------------------------------------
 // wxGnomePrintNativeData
@@ -242,6 +243,9 @@ int wxGnomePrintDialog::ShowModal()
     gtk_widget_destroy(m_widget);
     m_widget = NULL;
     
     gtk_widget_destroy(m_widget);
     m_widget = NULL;
     
+    if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW)
+        return wxID_PREVIEW;
+    
     return wxID_OK;
 }
 
     return wxID_OK;
 }
 
@@ -276,6 +280,7 @@ wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) :
     wxPrinterBase( data )
 {
     m_gpc = NULL;
     wxPrinterBase( data )
 {
     m_gpc = NULL;
+    m_native_preview = false;
 }
 
 wxGnomePrinter::~wxGnomePrinter()
 }
 
 wxGnomePrinter::~wxGnomePrinter()
@@ -313,6 +318,9 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
     else
         dc = new wxGnomePrintDC( this );
     
     else
         dc = new wxGnomePrintDC( this );
     
+    if (m_native_preview)
+        printout->SetIsPreview(true);
+    
     if (!dc)
     {
         gnome_print_job_close( job );
     if (!dc)
     {
         gnome_print_job_close( job );
@@ -387,7 +395,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
     }
     
     gnome_print_job_close( job );
     }
     
     gnome_print_job_close( job );
-    gnome_print_job_print( job );
+    if (m_native_preview)
+    {
+        wxString title( _("Print preview") );
+        gtk_widget_show( gnome_print_job_preview_new( job, (const guchar*)(const char*)wxGTK_CONV(title) ));
+    }
+    else
+    {
+        gnome_print_job_print( job );
+    }
     
     delete dc;
     
     
     delete dc;
     
@@ -397,12 +413,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
 wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
 {
     wxGnomePrintDialog dialog( parent, &m_printDialogData );
 wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
 {
     wxGnomePrintDialog dialog( parent, &m_printDialogData );
-    if (dialog.ShowModal() == wxID_CANCEL)
+    int ret = dialog.ShowModal();
+    if (ret == wxID_CANCEL)
     {
         sm_lastError = wxPRINTER_ERROR;
         return NULL;
     }
     
     {
         sm_lastError = wxPRINTER_ERROR;
         return NULL;
     }
     
+    m_native_preview = ret == wxID_PREVIEW;
+    
     m_printDialogData = dialog.GetPrintDialogData();
     return new wxGnomePrintDC( this );
 }
     m_printDialogData = dialog.GetPrintDialogData();
     return new wxGnomePrintDC( this );
 }