+#include <libgnomeprintui/gnome-print-job-preview.h>
+#include <libgnomeprintui/gnome-print-paper-selector.h>
+
+#include "wx/link.h"
+wxFORCE_LINK_THIS_MODULE(gnome_print)
+
+//----------------------------------------------------------------------------
+// wxGnomePrintLibrary
+//----------------------------------------------------------------------------
+
+class wxGnomePrintLibrary
+{
+public:
+ wxGnomePrintLibrary();
+ ~wxGnomePrintLibrary();
+
+ bool IsOk();
+private:
+ bool InitializeMethods();
+
+ wxDynamicLibrary m_libGnomePrint;
+ wxDynamicLibrary m_libGnomePrintUI;
+
+ // only true if we successfully loaded both libraries
+ //
+ // don't rename this field, it's used by wxDL_XXX macros internally
+ bool m_ok;
+
+public:
+ wxDL_METHOD_DEFINE( gint, gnome_print_newpath,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_moveto,
+ (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_lineto,
+ (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_arcto,
+ (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction ), (pc, x, y, radius, angle1, angle2, direction), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_curveto,
+ (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_closepath,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_stroke,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_fill,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_setrgbcolor,
+ (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b), (pc, r, g, b), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_setlinewidth,
+ (GnomePrintContext *pc, gdouble width), (pc, width), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_setdash,
+ (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset), (pc, n_values, values, offset), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_rgbimage,
+ (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_rgbaimage,
+ (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_concat,
+ (GnomePrintContext *pc, const gdouble *matrix), (pc, matrix), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_scale,
+ (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_rotate,
+ (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_translate,
+ (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_gsave,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_grestore,
+ (GnomePrintContext *pc), (pc), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_clip,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_eoclip,
+ (GnomePrintContext *pc), (pc), 0 )
+
+ wxDL_METHOD_DEFINE( gint, gnome_print_beginpage,
+ (GnomePrintContext *pc, const guchar* name), (pc, name), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_showpage,
+ (GnomePrintContext *pc), (pc), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_end_doc,
+ (GnomePrintContext *pc), (pc), 0 )
+
+ wxDL_METHOD_DEFINE( PangoLayout*, gnome_print_pango_create_layout,
+ (GnomePrintContext *gpc), (gpc), NULL )
+ wxDL_VOIDMETHOD_DEFINE( gnome_print_pango_layout,
+ (GnomePrintContext *gpc, PangoLayout *layout), (gpc, layout) )
+
+ wxDL_METHOD_DEFINE( GnomePrintJob*, gnome_print_job_new,
+ (GnomePrintConfig *config), (config), NULL )
+ wxDL_METHOD_DEFINE( GnomePrintContext*, gnome_print_job_get_context,
+ (GnomePrintJob *job), (job), NULL )
+ wxDL_METHOD_DEFINE( gint, gnome_print_job_close,
+ (GnomePrintJob *job), (job), 0 )
+ wxDL_METHOD_DEFINE( gint, gnome_print_job_print,
+ (GnomePrintJob *job), (job), 0 )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_job_get_page_size,
+ (GnomePrintJob *job, gdouble *width, gdouble *height), (job, width, height), 0 )
+
+ wxDL_METHOD_DEFINE( GnomePrintUnit*, gnome_print_unit_get_by_abbreviation,
+ (const guchar *abbreviation), (abbreviation), NULL )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_convert_distance,
+ (gdouble *distance, const GnomePrintUnit *from, const GnomePrintUnit *to), (distance, from, to), false )
+
+ wxDL_METHOD_DEFINE( GnomePrintConfig*, gnome_print_config_default,
+ (void), (), NULL )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set,
+ (GnomePrintConfig *config, const guchar *key, const guchar *value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_double,
+ (GnomePrintConfig *config, const guchar *key, gdouble value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_int,
+ (GnomePrintConfig *config, const guchar *key, gint value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_boolean,
+ (GnomePrintConfig *config, const guchar *key, gboolean value), (config, key, value), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_length,
+ (GnomePrintConfig *config, const guchar *key, gdouble value, const GnomePrintUnit *unit), (config, key, value, unit), false )
+
+ wxDL_METHOD_DEFINE( guchar*, gnome_print_config_get,
+ (GnomePrintConfig *config, const guchar *key), (config, key), NULL )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_length,
+ (GnomePrintConfig *config, const guchar *key, gdouble *val, const GnomePrintUnit **unit), (config, key, val, unit), false )
+ wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_boolean,
+ (GnomePrintConfig *config, const guchar *key, gboolean *val), (config, key, val), false )
+
+ wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_dialog_new,
+ (GnomePrintJob *gpj, const guchar *title, gint flags), (gpj, title, flags), NULL )
+ wxDL_VOIDMETHOD_DEFINE( gnome_print_dialog_construct_range_page,
+ (GnomePrintDialog *gpd, gint flags, gint start, gint end,
+ const guchar *currentlabel, const guchar *rangelabel),
+ (gpd, flags, start, end, currentlabel, rangelabel) )
+ wxDL_VOIDMETHOD_DEFINE( gnome_print_dialog_get_copies,
+ (GnomePrintDialog *gpd, gint *copies, gboolean *collate), (gpd, copies, collate) )
+ wxDL_VOIDMETHOD_DEFINE( gnome_print_dialog_set_copies,
+ (GnomePrintDialog *gpd, gint copies, gint collate), (gpd, copies, collate) )
+ wxDL_METHOD_DEFINE( GnomePrintRangeType, gnome_print_dialog_get_range,
+ (GnomePrintDialog *gpd), (gpd), GNOME_PRINT_RANGETYPE_NONE )
+ wxDL_METHOD_DEFINE( int, gnome_print_dialog_get_range_page,
+ (GnomePrintDialog *gpd, gint *start, gint *end), (gpd, start, end), 0 )
+
+ wxDL_METHOD_DEFINE( GtkWidget*, gnome_paper_selector_new_with_flags,
+ (GnomePrintConfig *config, gint flags), (config, flags), NULL )
+
+ wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_job_preview_new,
+ (GnomePrintJob *gpm, const guchar *title), (gpm, title), NULL )
+
+ DECLARE_NO_COPY_CLASS(wxGnomePrintLibrary)
+};
+
+wxGnomePrintLibrary::wxGnomePrintLibrary()
+{
+ wxLogNull log;
+
+ m_libGnomePrint.Load("libgnomeprint-2-2.so.0");
+ m_ok = m_libGnomePrint.IsLoaded();
+ if ( !m_ok )
+ return;
+
+ m_libGnomePrintUI.Load("libgnomeprintui-2-2.so.0");
+ m_ok = m_libGnomePrintUI.IsLoaded();
+ if ( !m_ok )
+ {
+ m_libGnomePrint.Unload();
+ return;
+ }
+
+ m_ok = InitializeMethods();
+}
+
+wxGnomePrintLibrary::~wxGnomePrintLibrary()
+{
+}
+
+bool wxGnomePrintLibrary::IsOk()
+{
+ return m_ok;
+}
+
+bool wxGnomePrintLibrary::InitializeMethods()
+{
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_newpath );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_moveto );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_lineto );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_curveto );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_arcto );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_closepath );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_stroke );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_fill );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_setrgbcolor );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_setlinewidth );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_setdash );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_rgbimage );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_rgbaimage );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_concat );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_scale );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_rotate );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_translate );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_gsave );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_grestore );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_clip );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_eoclip );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_beginpage );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_showpage );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_end_doc );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_pango_create_layout );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_pango_layout );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_new );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_get_context );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_close );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_print );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_get_page_size );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_unit_get_by_abbreviation );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_convert_distance );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_default );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_boolean );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_double );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_int );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_length );
+
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_get );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_get_length );
+ wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_get_boolean );
+
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_new );
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_construct_range_page );
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_get_copies );
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_set_copies );
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_get_range );
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_get_range_page );
+
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_paper_selector_new_with_flags );
+
+ wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_job_preview_new );
+
+ return true;
+}
+
+static wxGnomePrintLibrary* gs_libGnomePrint = NULL;