Fix for compile libgnomeprint2.2 (2.0 compat)
Tony Watts
tjawatts at totalise.co.uk
Thu Aug 21 13:34:50 CDT 2003
Hi
Here is a fix which should check for the version of libgnomeprint (2.0
or 2.2) in configure. It then puts in the appropriate code in the
gnome-utils/print-session.h and gnome-utils/print-session.c
Note that it just replaces the 2.0 functions with 2.2 functions. I
haven't actually got anything to print, but then I dont know if anyone
has got it to print on 2.0 either. Let me know if you are aware of the
status of printing in the g2 branch.
Anyway, can people with 2.0 and 2.2 test the patch to see if it is ok.
At least it will let you compile even if the printing doesnt work!!
When I have one or two confirmations from users of each version (and any
constructive critisism!) I will submit the patch for the g2 branch.
Best wishes
Tony
-------------- next part --------------
Index: gnucash/configure.in
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/configure.in,v
retrieving revision 1.359.2.17
diff -u -r1.359.2.17 configure.in
--- gnucash/configure.in 8 Aug 2003 23:22:00 -0000 1.359.2.17
+++ gnucash/configure.in 21 Aug 2003 08:21:28 -0000
@@ -820,8 +820,22 @@
AC_SUBST(GDK_PIXBUF_LIBS)
# Gnome-Print -- some people already have/need libgnomeprint-2.2
- #PKG_CHECK_MODULES(GNOME_PRINT, libgnomeprint-2.2)
- PKG_CHECK_MODULES(GNOME_PRINT, libgnomeprint-2.0 libgnomeprintui-2.0)
+ # Yep, so lets test to see if it is 2.0 or 2.2,
+ # Anyone know why gnome has versions in the package config?
+ # Why cant I just ask for the version of 'libgnomeprint'
+
+ # If 2.2 doesnt exist set gpv to 0
+ PKG_CHECK_MODULES(GNOME_PRINT, libgnomeprint-2.2 libgnomeprintui-2.2,,gpv=0)
+ if test $gpv
+ then
+ #If no 2.2 check for 2.0
+ PKG_CHECK_MODULES(GNOME_PRINT, libgnomeprint-2.0 libgnomeprintui-2.0)
+ AC_DEFINE_UNQUOTED(GNOME_PRINT_VER,0,[gnome print version])
+ else
+ #if 2.2 set header variable
+ AC_DEFINE_UNQUOTED(GNOME_PRINT_VER,2,[gnome print version])
+ fi
+
AS_SCRUB_INCLUDE(GNOME_PRINT_CFLAGS)
AC_SUBST(GNOME_PRINT_CFLAGS)
AC_SUBST(GNOME_PRINT_LIBS)
Index: gnucash/src/gnome-utils/print-session.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/print-session.c,v
retrieving revision 1.2.4.5
diff -u -r1.2.4.5 print-session.c
--- gnucash/src/gnome-utils/print-session.c 9 Aug 2003 02:04:26 -0000 1.2.4.5
+++ gnucash/src/gnome-utils/print-session.c 21 Aug 2003 08:21:54 -0000
@@ -26,7 +26,11 @@
#include <gnome.h>
#include <libgnomeprint/gnome-font.h>
+#if GNOME_PRINT_VER == 2
+#include <libgnomeprintui/gnome-print-job-preview.h>
+#else
#include <libgnomeprintui/gnome-print-master-preview.h>
+#endif
#include <stdio.h>
#include "gnc-ui.h"
@@ -40,9 +44,14 @@
PrintSession * ps = g_new0(PrintSession, 1);
GnomePrintConfig *config;
- /* this is about the most basic we can get */
+ /* this is about the most basic we can get */
+ #if GNOME_PRINT_VER==2
+ ps->master = gnome_print_job_new(config);
+ config = gnome_print_job_get_config(ps->master);
+ #else
ps->master = gnome_print_master_new();
config = gnome_print_master_get_config(ps->master);
+ #endif
ps->meta = gnome_print_context_new(config);
ps->default_font = gnome_font_find("Courier", 12);
@@ -112,8 +121,13 @@
void
gnc_print_session_print(PrintSession * ps) {
+ #if GNOME_PRINT_VER==2
+ GtkWidget * dialog =
+ gnome_print_dialog_new(ps->master,_("Print GnuCash Document"), 0);
+ #else
GtkWidget * dialog =
gnome_print_dialog_new(_("Print GnuCash Document"), 0);
+ #endif
int button = gnome_dialog_run(GNOME_DIALOG(dialog));
GnomePrintConfig *config;
@@ -125,7 +139,11 @@
ps->master = NULL;
}
config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (dialog));
- ps->master = gnome_print_master_new_from_config (config);
+ #if GNOME_PRINT_VER==2
+ ps->master = gnome_print_job_new(config);
+ #else
+ ps->master = gnome_print_master_new_from_config(config);
+ #endif
gnome_dialog_close(GNOME_DIALOG(dialog));
gnc_print_session_render(ps);
break;
@@ -136,7 +154,11 @@
ps->master = NULL;
}
config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (dialog));
- ps->master = gnome_print_master_new_from_config (config);
+ #if GNOME_PRINT_VER==2
+ ps->master = gnome_print_job_new(config);
+ #else
+ ps->master = gnome_print_master_new_from_config(config);
+ #endif
gnome_dialog_close(GNOME_DIALOG(dialog));
gnc_print_session_preview(ps);
break;
@@ -150,17 +172,28 @@
void
gnc_print_session_render(PrintSession * ps) {
+ #if GNOME_PRINT_VER==2
+ gnome_print_job_render (ps->master, ps->meta);
+ gnome_print_job_close (ps->master);
+ gnome_print_job_print(ps->master);
+ #else
gnome_print_master_render (ps->master, ps->meta);
gnome_print_master_close (ps->master);
gnome_print_master_print(ps->master);
+ #endif
}
void
gnc_print_session_preview(PrintSession * ps) {
GtkWidget * preview;
-
+ #if GNOME_PRINT_VER==2
+ gnome_print_job_render (ps->master, ps->meta);
+ gnome_print_job_close (ps->master);
+ preview = gnome_print_job_preview_new(ps->master, _("Print Preview"));
+ #else
gnome_print_master_render (ps->master, ps->meta);
gnome_print_master_close (ps->master);
preview = gnome_print_master_preview_new(ps->master, _("Print Preview"));
+ #endif
gtk_widget_show_all(preview);
}
Index: gnucash/src/gnome-utils/print-session.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/print-session.h,v
retrieving revision 1.3.4.3
diff -u -r1.3.4.3 print-session.h
--- gnucash/src/gnome-utils/print-session.h 17 Jul 2003 07:58:40 -0000 1.3.4.3
+++ gnucash/src/gnome-utils/print-session.h 21 Aug 2003 08:21:54 -0000
@@ -28,13 +28,22 @@
#include <gnome.h>
#include <libgnomeprint/gnome-print.h>
+
+#if GNOME_PRINT_VER==2
+#include <libgnomeprint/gnome-print-job.h>
+#else
#include <libgnomeprint/gnome-print-master.h>
+#endif
#include <libgnomeprintui/gnome-print-dialog.h>
#include <libgnomeprintui/gnome-print-preview.h>
typedef struct {
+#if GNOME_PRINT_VER==2
+ GnomePrintJob * master;
+#else
GnomePrintMaster * master;
+#endif
GnomePrintContext * meta;
GnomeFont * default_font;
GnomePrintPaper * paper;
More information about the gnucash-devel
mailing list