#include <libgnomecanvas/libgnomecanvas.h>
#include <zlib.h>
#include <math.h>
-#include <gdk/gdkx.h>
-#include <X11/Xlib.h>
#include <locale.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <poppler/glib/poppler.h>
+#ifndef WIN32
+ #include <gdk/gdkx.h>
+ #include <X11/Xlib.h>
+#endif
+
#include "xournal.h"
#include "xo-interface.h"
#include "xo-support.h"
GList *pagelist, *layerlist, *itemlist, *list;
GtkWidget *dialog;
- f = gzopen(filename, "w");
+ f = gzopen(filename, "wb");
if (f==NULL) return FALSE;
chk_attach_names();
success = FALSE;
if (bgpdf.status != STATUS_NOT_INIT && bgpdf.file_contents != NULL)
{
- tmpf = fopen(tmpfn, "w");
+ tmpf = fopen(tmpfn, "wb");
if (tmpf != NULL && fwrite(bgpdf.file_contents, 1, bgpdf.file_length, tmpf) == bgpdf.file_length)
success = TRUE;
fclose(tmpf);
}
g_free(tmpfn);
- f = gzopen(filename, "r");
+ f = gzopen(filename, "rb");
if (f==NULL) return FALSE;
if (filename[0]=='/') {
if (ui.default_path != NULL) g_free(ui.default_path);
char *pipename;
int buflen, remnlen, file_pageno;
- f = fopen(filename, "r");
+ f = fopen(filename, "rb");
if (f == NULL) return NULL;
buf = g_malloc(BUFSIZE); // a reasonable buffer size
if (fread(buf, 1, 4, f) !=4 ||
fclose(f);
pipename = g_strdup_printf(GS_CMDLINE, (double)GS_BITMAP_DPI, filename);
- gs_pipe = popen(pipename, "r");
+ gs_pipe = popen(pipename, "rb");
g_free(pipename);
bg_list = NULL;
struct Background *attempt_screenshot_bg(void)
{
+#ifndef WIN32
struct Background *bg;
GdkPixbuf *pix;
XEvent x_event;
bg->filename = new_refstring(NULL);
bg->file_domain = DOMAIN_ATTACH;
return bg;
+#else
+ // not implemented under WIN32
+ return FALSE;
+#endif
}
/************** pdf annotation ***************/
struct Page *pg;
PopplerPage *pdfpage;
gdouble width, height;
+ gchar *uri;
if (bgpdf.status != STATUS_NOT_INIT) return FALSE;
bgpdf.pid = 0;
bgpdf.has_failed = FALSE;
- bgpdf.document = poppler_document_new_from_data(bgpdf.file_contents, bgpdf.file_length, NULL, NULL);
- if (bgpdf.document == NULL) shutdown_bgpdf();
+/* poppler_document_new_from_data() starts at 0.6.1, but we want to
+ be compatible with poppler 0.5.4 = latest in CentOS as of sept 2009 */
+ uri = g_filename_to_uri(pdfname, NULL, NULL);
+ if (!uri) uri = g_strdup_printf("file://%s", pdfname);
+ bgpdf.document = poppler_document_new_from_file(uri, NULL, NULL);
+ g_free(uri);
+/* with poppler 0.6.1 or later, can replace the above 4 lines by:
+ bgpdf.document = poppler_document_new_from_data(bgpdf.file_contents,
+ bgpdf.file_length, NULL, NULL);
+*/
+ if (bgpdf.document == NULL) { shutdown_bgpdf(); return FALSE; }
if (pdfname[0]=='/' && ui.filename == NULL) {
if (ui.default_path!=NULL) g_free(ui.default_path);