From: auroux
Date: Tue, 25 Jul 2006 09:03:02 +0000 (+0000)
Subject: Update to version 0.3.
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=59df9eb838b273295a6b86ce9f522dc4ad71dc4d;p=xournal.git
Update to version 0.3.
---
diff --git a/ChangeLog b/ChangeLog
index 363e2fe..b0cec9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Version 0.3 (Jul 23, 2006):
+ - new PDF rendering engine: export to PDF generates optimized files
+ (smaller and more accurate)
+ - export to PDF handles PDF backgrounds (up to PDF-1.4) natively
+ (without conversion to bitmap)
+ - default thickness of erasers and highlighters slightly increased
+ - zoom dialog box with input box and "fit to page height" option
+ - file format documentation added to the user's manual
+
Version 0.2.2 (Jun 5, 2006):
- mapping of tools to stylus buttons (the options menu has new entries
to allow the mapping of buttons 2 and 3 to arbitrary tools; the tools
diff --git a/NEWS b/NEWS
index 952d254..f48165a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Version 0.2.2 (June 5, 2006)
+Version 0.3 (July 23, 2006)
Installation: see INSTALL
User's manual: see html-doc/manual.html
diff --git a/README b/README
index 952d254..f48165a 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Version 0.2.2 (June 5, 2006)
+Version 0.3 (July 23, 2006)
Installation: see INSTALL
User's manual: see html-doc/manual.html
diff --git a/configure.in b/configure.in
index 852ec07..e16b40f 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(xournal, 0.2.2)
+AM_INIT_AUTOMAKE(xournal, 0.3)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
diff --git a/html-doc/manual.html b/html-doc/manual.html
index cf97892..5ed2718 100644
--- a/html-doc/manual.html
+++ b/html-doc/manual.html
@@ -24,7 +24,7 @@
Xournal User's Manual
- Version 0.2.2
+ Version 0.3
@@ -427,10 +427,10 @@ PDF files (for example pdfmerge).
Printing
Xournal uses the gnome-print architecture for printing. While it is very
-powerful, some aspects of the API leave to be desired,
-and future versions of Xournal will probably also include a native
-Postscript/PDF printing feature.
+powerful, some aspects of the API leave to be desired. As of version 0.3,
+Xournal also includes a native PDF printing feature.
+Printing via gnome-print
The "Printer" tab of the print dialog box lets you select a printer
(either one of the printers installed on your system, or the generic
@@ -448,18 +448,34 @@ attempts to pre-fill the output file name (for the Postscript driver
this often fails due to gnome-print API issues).
-The "Print to PDF" entry of the File menu directly generates a PDF file
-using the PDF virtual printer, without bringing up the dialog box
-(the page size is the default one for that printer, usually A4).
Note that the PDF virtual printer produces files that are very large
-and far from optimal, so in the current state of things it is better
-to generate a Postscript file and use a converter such as ps2pdf.
-
-
+and far from optimal, so its use is not recommended.
The gnome-print architecture also forces page backgrounds (bitmaps
and PDF) to be generated as uncompressed bitmaps, which leads to gigantic
-print job files. An alternative to gnome-print will be
-implemented in a future release of Xournal.
+print job files. A better alternative is to export a PDF file, and
+print the PDF file.
+
+Exporting to PDF
+
+Starting with version 0.3, Xournal provides its own PDF rendering
+engine. The "Export to PDF" command (in the File menu) produces a
+PDF-1.4 file from the currently loaded document. The resulting PDF
+file is much more compact than those produced via gnome-print, and
+its pages have the same size as in Xournal. Highlighter strokes
+are rendered in a partially transparent manner (note however that
+applications such as xpdf and ghostview do not always handle
+PDF transparency properly).
+
+
+Xournal also includes a PDF file parser compatible with PDF format
+version 1.4; the compression features of PDF 1.5 (Acrobat 6) are
+not supported. When exporting a document that uses PDF
+backgrounds, Xournal attempts to preserve most of the structure of
+the original PDF file (however, auxiliary data such as thumbnails, hyperlinks,
+and annotations are lost). If Xournal is unable to parse the PDF
+file, the backgrounds are converted to (compressed) bitmaps and a new
+PDF file is generated from scratch.
+
Author information, license, bug-reports
@@ -470,14 +486,7 @@ Xournal is written by Denis Auroux
Feel free to contact me with bug reports and suggestions; I apologize
in advance if I am unable to respond properly to some requests.
-List of known bugs/misfeatures (no need to report them again):
-
- - highlighter strokes become opaque on printouts (apparently a bug in
- libgnomeprint).
- - print settings are not saved from one print command to the next.
- - printing to PDF and/or printing page backgrounds generates large files.
- - preferences are not saved on disk.
-
+
If you find a sequence of operations which crashes Xournal in a reproducible
manner, please send detailed instructions on how to reproduce the crash.
A core file may also be helpful.
@@ -490,6 +499,18 @@ Bug reports and suggestions can also be submitted on Xournal's
Version history
+Version 0.3 (July 23, 2006):
+
+ - new PDF rendering engine: export to PDF generates optimized files
+ (smaller and more accurate)
+ - export to PDF handles PDF backgrounds (up to PDF-1.4) natively
+ (without conversion to bitmap)
+ - default thickness of erasers and highlighters slightly increased
+ - zoom dialog box with input box and "fit to page height" option
+ - file format documentation added to the user's manual
+
+
+
Version 0.2.2 (June 5, 2006):
- mapping of tools to stylus buttons (the options menu has new entries
@@ -546,18 +567,141 @@ Features yet to be implemented:
- freeform selection tool
- preferences file; persistent printer settings
- - native PDF print feature
- various functionalities (flatten layers, ...)
The file format
+Overall structure
-XOJ files are gzipped XML-like files. A more precise documentation of
-the file format will be added at a later date. Meanwhile, most of the
-format should be easy to figure out by trial-and-error or by looking
-at the source; if some details are unclear, feel free to ask.
+Xournal stores its data in gzipped XML-like files. The gzipped data consists
+of a succession of XML tags describing the document. By convention, the
+first few lines contain a header in the following format:
+
+<?xml version="1.0" standalone="no"?>
+<title>Xournal document - see http://math.mit.edu/~auroux/software/xournal/</title>
+<xournal version="..."/>
+
+The <title> and <xournal> tags may only appear within the file
+header (not within the pages of the document). The version attribute of
+the <xournal> tag indicates which version of Xournal was used to
+create the document; it is currently ignored, but may be used in a later
+release if the file format changes in an incompatible manner.
+
+
+The rest of the file is a sequence of pages, specified by a
+<page> tag, whose attributes width and height specify the
+physical size of the page in points (1/72 in). The width and height
+parameters are floating point values. The format of a page is therefore:
+
+<page width="..." height="...">
+... page contents ...
+</page>
+
+
+Page background
+
+The first entry within a page describes the page background.
+It consists of a <background> tag followed by several mandatory
+XML attributes. The first attribute is always type, which
+can take three possible values: "solid" for a solid background, "pixmap"
+for a bitmap background, and "pdf" if the background is a page of a PDF
+document. The rest of the attributes depends on the type of background.
+
+ Solid background: <background type="solid" color="..."
+style="..." />
The color attribute takes one of
+the standard values "white", "yellow", "pink", "orange", "blue", "green",
+or can specify a hexadecimal RGBA value in the format "#rrggbbaa". The
+style attribute takes one of the standard values "plain", "lined",
+"ruled", or "graph".
+
+ Bitmap background: <background type="pixmap" domain="..."
+filename="..." />
+The domain attribute takes one of the standard values "absolute",
+"attach", or "clone". A value of "absolute" indicates that the bitmap is
+found in the file specified by filename. The bitmap can be in any
+format recognized by the gdk-pixbuf library; this includes most of the
+common bitmap formats (JPEG, PNG, BMP, GIF, PCX, PNM, TIFF, ...).
+
A value
+of "attach" indicates that the bitmap is an attachment to the Xournal file.
+The bitmap is in PNG format, and resides in a file whose name is derived
+from that of the main Xournal file by appending to it a dot and the contents
+of the filename attribute. For example, if the Xournal file is in
+file.xoj and the filename attribute is "bg_1.png"
+then the bitmap file is file.xoj.bg_1.png (Xournal saves attached
+bitmaps sequentially in files ...bg_1.png, ...bg_2.png, etc.)
+
A value of "clone" indicates that the bitmap is identical to the
+background of a previous page of the journal; the filename attribute
+then specifies the page number, starting with 0 for the first page. For
+example, if a filename value of "1" indicates that the
+background bitmap is identical to that of the second page.
+
+
+ PDF background: <background type="pdf" domain="..."
+filename="..." pageno="..." /> or
+<background type="pdf" pageno="..." />
+
The domain and filename attributes must be specified
+for the first page of the journal that uses a PDF background, and must
+be omitted subsequently for every other page that uses a PDF background.
+The domain attribute takes one of the standard values
+"absolute" and "attach"; the PDF document is to be found in the file
+specified by filename (if domain is "absolute"), or in the
+file whose name is obtained by appending a dot and the contents of the
+filename attribute to the name of the main Xournal file (if
+domain is "attach"). The pageno attribute specifies which
+page of the PDF file is used as background, starting with 1 for the first
+page of the PDF file.
+
+
+
+
+Layers and strokes
+
+After the line specifying the background, the remainder of a <page>
+section is occupied by one or more layer sections
+
<layer> ... </layer>
+describing the various strokes within a layer. Every page must
+contain at least one layer; a layer may be empty. The successive layers
+are listed in their stacking order, from bottom to top.
+
+
+A layer consist of a collection of items, listed in the order in which
+they should be drawn
+(from bottom-most to top-most).
+As of the current version, the only legal contents within a layer are
+strokes. The format of a stroke is:
+
<stroke tool="..." color="..." width="...">
+... list of coordinates ...
+</stroke>
+
+The tool attribute can take the values "pen", "highlighter", or
+"eraser" depending on the tool used to create the stroke (pen, highlighter,
+or whiteout eraser); a value of "highlighter" indicates that the stroke
+should be painted in a partially transparent manner (Xournal uses an alpha
+coefficient of 0.5).
+The color attribute can take one of the standard values "black",
+"blue", "red", "green", "gray", "lightblue", "lightgreen", "magenta",
+"orange", "yellow", "white", or can specify a hexadecimal RGBA value in
+the format "#rrggbbaa". The width attribute is a floating-point
+number and specifies the width of the stroke in points (1/72 in).
+
+
+The list of coordinates is simply a succession of floating-point values,
+separated by whitespace.
+The number of given values must be even; consecutive pairs of values give
+the x and y coordinates of each point along the stroke.
+These values are expressed in points (1/72 in). The coordinates (0,0)
+represent the top-left corner of the page: hence x is measured from the left
+of the page, and y is measured from the top of the page.
+
+
+Every stroke must contain at least two points (four floating point values).
+Moreover, two consecutive points on the stroke should be spaced no more
+than 5 units apart or so; longer line segments should be subdivided as
+appropriate (otherwise the eraser tool will not interact properly with the
+stroke). The default precision used by Xournal for the x,y coordinates is
+0.01 unit (1/7200 in).
diff --git a/src/TODO b/src/TODO
index b821bf9..87329bd 100644
--- a/src/TODO
+++ b/src/TODO
@@ -7,11 +7,8 @@ List of features to be implemented (not in any particular order)
- resize selection
- text tool, font chooser, default font
- color chooser (papercolor, pen color); maybe more default colors
-- printing: print-to-PDF? (with & without pdf background to merge)
- opacity issue for highlighter strokes (maybe print them below ?)
- save gnome printer settings (throughout a session, and on disk)
- (maybe a separate config file .xournal/gnome-print-settings)
-- file print-options, own print-to-ps/pdf
+- printing: print-options, save printer settings (throughout a session,
+ and on disk) (maybe a separate config file .xournal/gnome-print-settings)
- help index
- pressure sensitivity
- insert images (screen capture or from file or from clipboard),
@@ -20,5 +17,4 @@ List of features to be implemented (not in any particular order)
- convert to/from Jarnal format; to/from MS Journal format???
- recalibration upon screen resize / compensation for miscalibration
- find a better behavior for vertical space tool across page boundaries ?
-- document the file format
-
+- key mappings (pgup/dn for full page, up/dn for scroll)
diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c
index 6fe75d9..06e30e5 100644
--- a/src/xo-callbacks.c
+++ b/src/xo-callbacks.c
@@ -355,16 +355,15 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog, *warning_dialog;
GtkFileFilter *filt_all, *filt_pdf;
char *filename, *in_fn;
char stime[30];
time_t curtime;
- GnomePrintJob *gpj;
- GnomePrintConfig *config;
-
+ int response;
+ gboolean warn;
- dialog = gtk_file_chooser_dialog_new("Print to PDF", GTK_WINDOW (winMain),
+ dialog = gtk_file_chooser_dialog_new("Export to PDF", GTK_WINDOW (winMain),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
@@ -392,27 +391,37 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem,
gtk_file_filter_add_pattern(filt_pdf, "*.pdf");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_pdf);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all);
-
- // somehow this doesn't seem to be set by default
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
-
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
- g_free(in_fn);
- gtk_widget_destroy(dialog);
- return;
- }
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
g_free(in_fn);
- gtk_widget_destroy(dialog);
- config = gnome_print_config_default();
- gnome_print_config_set(config, (guchar *)"Printer", (guchar *)"PDF");
- gpj = gnome_print_job_new(config);
- gnome_print_job_print_to_file(gpj, filename);
-
- print_job_render(gpj, 0, journal.npages-1);
- gnome_print_config_unref(config);
+ do {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy(dialog);
+ return;
+ }
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ warn = g_file_test(filename, G_FILE_TEST_EXISTS);
+ if (warn) {
+ warning_dialog = gtk_message_dialog_new(GTK_WINDOW(winMain),
+ GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+ "Should the file %s be overwritten?", filename);
+ if (gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES)
+ warn = FALSE;
+ gtk_widget_destroy(warning_dialog);
+ }
+ } while(warn);
+
+ gtk_widget_destroy(dialog);
+ set_cursor_busy(TRUE);
+ if (!print_to_pdf(filename)) {
+ set_cursor_busy(FALSE);
+ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error creating file '%s'", filename);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ }
+ set_cursor_busy(FALSE);
g_free(filename);
}
@@ -2554,6 +2563,10 @@ on_viewFullscreen_activate (GtkMenuItem *menuitem,
if (active == ui.fullscreen) return;
ui.fullscreen = active;
+ gtk_check_menu_item_set_active(
+ GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), ui.fullscreen);
+ gtk_toggle_tool_button_set_active(
+ GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), ui.fullscreen);
if (ui.fullscreen) {
gtk_window_fullscreen(GTK_WINDOW(winMain));
@@ -2804,3 +2817,105 @@ on_button3CopyBrush_activate (GtkMenuItem *menuitem,
ui.ruler[2] = FALSE;
}
+// the set zoom dialog
+
+GtkWidget *zoom_dialog;
+double zoom_percent;
+
+void
+on_viewSetZoom_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ int response;
+ double test_w, test_h;
+
+ zoom_dialog = create_zoomDialog();
+ zoom_percent = 100*ui.zoom / DEFAULT_ZOOM;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+ test_w = 100*(GTK_WIDGET(canvas))->allocation.width/ui.cur_page->width/DEFAULT_ZOOM;
+ test_h = 100*(GTK_WIDGET(canvas))->allocation.height/ui.cur_page->height/DEFAULT_ZOOM;
+ if (zoom_percent > 99.9 && zoom_percent < 100.1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoom100")), TRUE);
+ else if (zoom_percent > test_w-0.1 && zoom_percent < test_w+0.1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoomWidth")), TRUE);
+ else if (zoom_percent > test_h-0.1 && zoom_percent < test_h+0.1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoomHeight")), TRUE);
+ else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoom")), TRUE);
+ gtk_widget_show(zoom_dialog);
+
+ do {
+ response = gtk_dialog_run(GTK_DIALOG(zoom_dialog));
+ if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
+ ui.zoom = DEFAULT_ZOOM*zoom_percent/100;
+ gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
+ rescale_bg_pixmaps();
+ }
+ } while (response == GTK_RESPONSE_APPLY);
+
+ gtk_widget_destroy(zoom_dialog);
+}
+
+
+void
+on_spinZoom_value_changed (GtkSpinButton *spinbutton,
+ gpointer user_data)
+{
+ double val;
+
+ val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")));
+ if (val<1) return;
+ if (val<10) val=10.;
+ if (val>1500) val=1500.;
+ if (valzoom_percent+1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoom")), TRUE);
+ zoom_percent = val;
+}
+
+
+void
+on_radioZoom_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ // nothing to do
+}
+
+
+void
+on_radioZoom100_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ if (!gtk_toggle_button_get_active(togglebutton)) return;
+ zoom_percent = 100.;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+}
+
+
+void
+on_radioZoomWidth_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ if (!gtk_toggle_button_get_active(togglebutton)) return;
+ zoom_percent = 100*(GTK_WIDGET(canvas))->allocation.width/ui.cur_page->width/DEFAULT_ZOOM;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+}
+
+
+void
+on_radioZoomHeight_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ if (!gtk_toggle_button_get_active(togglebutton)) return;
+ zoom_percent = 100*(GTK_WIDGET(canvas))->allocation.height/ui.cur_page->height/DEFAULT_ZOOM;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+}
+
diff --git a/src/xo-callbacks.h b/src/xo-callbacks.h
index 4234703..5a0ccc6 100644
--- a/src/xo-callbacks.h
+++ b/src/xo-callbacks.h
@@ -556,3 +556,27 @@ void
on_button3CopyBrush_activate (GtkMenuItem *menuitem,
gpointer user_data);
+
+void
+on_viewSetZoom_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_spinZoom_value_changed (GtkSpinButton *spinbutton,
+ gpointer user_data);
+
+void
+on_radioZoom_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data);
+
+void
+on_radioZoom100_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data);
+
+void
+on_radioZoomWidth_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data);
+
+void
+on_radioZoomHeight_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data);
diff --git a/src/xo-file.c b/src/xo-file.c
index c180d61..1afcd18 100644
--- a/src/xo-file.c
+++ b/src/xo-file.c
@@ -138,6 +138,7 @@ gboolean save_journal(const char *filename)
tmpf = fopen(tmpfn, "w");
if (tmpf != NULL && fwrite(pdfbuf, 1, pdflen, tmpf) == pdflen)
success = TRUE;
+ g_free(pdfbuf);
fclose(tmpf);
}
if (!success) {
diff --git a/src/xo-interface.c b/src/xo-interface.c
index fbde53f..3f3e62c 100644
--- a/src/xo-interface.c
+++ b/src/xo-interface.c
@@ -36,7 +36,7 @@ create_winMain (void)
GtkWidget *menuFile_menu;
GtkWidget *fileNew;
GtkWidget *fileNewBackground;
- GtkWidget *image577;
+ GtkWidget *image599;
GtkWidget *fileOpen;
GtkWidget *fileSave;
GtkWidget *fileSaveAs;
@@ -53,7 +53,7 @@ create_winMain (void)
GtkWidget *mru7;
GtkWidget *separator22;
GtkWidget *filePrintOptions;
- GtkWidget *image578;
+ GtkWidget *image600;
GtkWidget *filePrint;
GtkWidget *filePrintPDF;
GtkWidget *separator2;
@@ -79,21 +79,22 @@ create_winMain (void)
GtkWidget *viewZoomOut;
GtkWidget *viewNormalSize;
GtkWidget *viewPageWidth;
- GtkWidget *image579;
+ GtkWidget *image601;
+ GtkWidget *viewSetZoom;
GtkWidget *separator5;
GtkWidget *viewFirstPage;
- GtkWidget *image580;
+ GtkWidget *image602;
GtkWidget *viewPreviousPage;
- GtkWidget *image581;
+ GtkWidget *image603;
GtkWidget *viewNextPage;
- GtkWidget *image582;
+ GtkWidget *image604;
GtkWidget *viewLastPage;
- GtkWidget *image583;
+ GtkWidget *image605;
GtkWidget *separator6;
GtkWidget *viewShowLayer;
- GtkWidget *image584;
+ GtkWidget *image606;
GtkWidget *viewHideLayer;
- GtkWidget *image585;
+ GtkWidget *image607;
GtkWidget *menuJournal;
GtkWidget *menuJournal_menu;
GtkWidget *journalNewPageBefore;
@@ -128,7 +129,7 @@ create_winMain (void)
GtkWidget *journalApplyAllPages;
GtkWidget *separator23;
GtkWidget *journalLoadBackground;
- GtkWidget *image586;
+ GtkWidget *image608;
GtkWidget *journalScreenshot;
GtkWidget *separator19;
GtkWidget *journalDefaultBackground;
@@ -146,7 +147,7 @@ create_winMain (void)
GtkWidget *toolsVerticalSpace;
GtkWidget *separator16;
GtkWidget *toolsColor;
- GtkWidget *image587;
+ GtkWidget *image609;
GtkWidget *toolsColor_menu;
GSList *colorBlack_group = NULL;
GtkWidget *colorBlack;
@@ -189,7 +190,7 @@ create_winMain (void)
GtkWidget *highlighterMedium;
GtkWidget *highlighterThick;
GtkWidget *toolsTextFont;
- GtkWidget *image588;
+ GtkWidget *image610;
GtkWidget *separator10;
GtkWidget *toolsDefaultPen;
GtkWidget *toolsDefaultEraser;
@@ -265,6 +266,7 @@ create_winMain (void)
GtkWidget *buttonPageWidth;
GtkWidget *buttonZoomIn;
GtkWidget *buttonNormalSize;
+ GtkWidget *buttonZoomSet;
GtkWidget *tmp_image;
GtkWidget *buttonFullscreen;
GtkWidget *toolbarPen;
@@ -348,9 +350,9 @@ create_winMain (void)
gtk_widget_show (fileNewBackground);
gtk_container_add (GTK_CONTAINER (menuFile_menu), fileNewBackground);
- image577 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image577);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (fileNewBackground), image577);
+ image599 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image599);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (fileNewBackground), image599);
fileOpen = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
gtk_widget_show (fileOpen);
@@ -417,15 +419,15 @@ create_winMain (void)
gtk_widget_show (filePrintOptions);
gtk_container_add (GTK_CONTAINER (menuFile_menu), filePrintOptions);
- image578 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image578);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (filePrintOptions), image578);
+ image600 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image600);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (filePrintOptions), image600);
filePrint = gtk_image_menu_item_new_from_stock ("gtk-print", accel_group);
gtk_widget_show (filePrint);
gtk_container_add (GTK_CONTAINER (menuFile_menu), filePrint);
- filePrintPDF = gtk_menu_item_new_with_mnemonic ("Print to PDF");
+ filePrintPDF = gtk_menu_item_new_with_mnemonic ("Export to PDF");
gtk_widget_show (filePrintPDF);
gtk_container_add (GTK_CONTAINER (menuFile_menu), filePrintPDF);
@@ -485,6 +487,7 @@ create_winMain (void)
viewContinuous_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (viewContinuous));
gtk_widget_show (viewContinuous);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewContinuous);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (viewContinuous), TRUE);
viewOnePage = gtk_radio_menu_item_new_with_mnemonic (viewContinuous_group, "One Page");
viewContinuous_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (viewOnePage));
@@ -522,9 +525,13 @@ create_winMain (void)
gtk_widget_show (viewPageWidth);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewPageWidth);
- image579 = gtk_image_new_from_stock ("gtk-zoom-fit", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image579);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewPageWidth), image579);
+ image601 = gtk_image_new_from_stock ("gtk-zoom-fit", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image601);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewPageWidth), image601);
+
+ viewSetZoom = gtk_menu_item_new_with_mnemonic ("Set Zoom");
+ gtk_widget_show (viewSetZoom);
+ gtk_container_add (GTK_CONTAINER (menuView_menu), viewSetZoom);
separator5 = gtk_separator_menu_item_new ();
gtk_widget_show (separator5);
@@ -535,33 +542,33 @@ create_winMain (void)
gtk_widget_show (viewFirstPage);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewFirstPage);
- image580 = gtk_image_new_from_stock ("gtk-goto-first", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image580);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewFirstPage), image580);
+ image602 = gtk_image_new_from_stock ("gtk-goto-first", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image602);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewFirstPage), image602);
viewPreviousPage = gtk_image_menu_item_new_with_mnemonic ("Previous Page");
gtk_widget_show (viewPreviousPage);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewPreviousPage);
- image581 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image581);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewPreviousPage), image581);
+ image603 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image603);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewPreviousPage), image603);
viewNextPage = gtk_image_menu_item_new_with_mnemonic ("Next Page");
gtk_widget_show (viewNextPage);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewNextPage);
- image582 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image582);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewNextPage), image582);
+ image604 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image604);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewNextPage), image604);
viewLastPage = gtk_image_menu_item_new_with_mnemonic ("Last Page");
gtk_widget_show (viewLastPage);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewLastPage);
- image583 = gtk_image_new_from_stock ("gtk-goto-last", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image583);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewLastPage), image583);
+ image605 = gtk_image_new_from_stock ("gtk-goto-last", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image605);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewLastPage), image605);
separator6 = gtk_separator_menu_item_new ();
gtk_widget_show (separator6);
@@ -572,17 +579,17 @@ create_winMain (void)
gtk_widget_show (viewShowLayer);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewShowLayer);
- image584 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image584);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewShowLayer), image584);
+ image606 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image606);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewShowLayer), image606);
viewHideLayer = gtk_image_menu_item_new_with_mnemonic ("Hide Layer");
gtk_widget_show (viewHideLayer);
gtk_container_add (GTK_CONTAINER (menuView_menu), viewHideLayer);
- image585 = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image585);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewHideLayer), image585);
+ image607 = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image607);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (viewHideLayer), image607);
menuJournal = gtk_menu_item_new_with_mnemonic ("_Journal");
gtk_widget_show (menuJournal);
@@ -644,36 +651,43 @@ create_winMain (void)
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorWhite));
gtk_widget_show (papercolorWhite);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorWhite);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorWhite), TRUE);
papercolorYellow = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "yellow paper");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorYellow));
gtk_widget_show (papercolorYellow);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorYellow);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorYellow), TRUE);
papercolorPink = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "pink paper");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorPink));
gtk_widget_show (papercolorPink);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorPink);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorPink), TRUE);
papercolorOrange = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "orange paper");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorOrange));
gtk_widget_show (papercolorOrange);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorOrange);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorOrange), TRUE);
papercolorBlue = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "blue paper");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorBlue));
gtk_widget_show (papercolorBlue);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorBlue);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorBlue), TRUE);
papercolorGreen = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "green paper");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorGreen));
gtk_widget_show (papercolorGreen);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorGreen);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorGreen), TRUE);
papercolorOther = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "other...");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorOther));
gtk_widget_show (papercolorOther);
gtk_container_add (GTK_CONTAINER (journalPaperColor_menu), papercolorOther);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (papercolorOther), TRUE);
papercolorNA = gtk_radio_menu_item_new_with_mnemonic (papercolorWhite_group, "NA");
papercolorWhite_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (papercolorNA));
@@ -691,21 +705,25 @@ create_winMain (void)
paperstylePlain_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (paperstylePlain));
gtk_widget_show (paperstylePlain);
gtk_container_add (GTK_CONTAINER (journalPaperStyle_menu), paperstylePlain);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (paperstylePlain), TRUE);
paperstyleLined = gtk_radio_menu_item_new_with_mnemonic (paperstylePlain_group, "lined");
paperstylePlain_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (paperstyleLined));
gtk_widget_show (paperstyleLined);
gtk_container_add (GTK_CONTAINER (journalPaperStyle_menu), paperstyleLined);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (paperstyleLined), TRUE);
paperstyleRuled = gtk_radio_menu_item_new_with_mnemonic (paperstylePlain_group, "ruled");
paperstylePlain_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (paperstyleRuled));
gtk_widget_show (paperstyleRuled);
gtk_container_add (GTK_CONTAINER (journalPaperStyle_menu), paperstyleRuled);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (paperstyleRuled), TRUE);
paperstyleGraph = gtk_radio_menu_item_new_with_mnemonic (paperstylePlain_group, "graph");
paperstylePlain_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (paperstyleGraph));
gtk_widget_show (paperstyleGraph);
gtk_container_add (GTK_CONTAINER (journalPaperStyle_menu), paperstyleGraph);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (paperstyleGraph), TRUE);
paperstyleNA = gtk_radio_menu_item_new_with_mnemonic (paperstylePlain_group, "NA");
paperstylePlain_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (paperstyleNA));
@@ -725,9 +743,9 @@ create_winMain (void)
gtk_widget_show (journalLoadBackground);
gtk_container_add (GTK_CONTAINER (menuJournal_menu), journalLoadBackground);
- image586 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image586);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (journalLoadBackground), image586);
+ image608 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image608);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (journalLoadBackground), image608);
journalScreenshot = gtk_menu_item_new_with_mnemonic ("Background Screenshot");
gtk_widget_show (journalScreenshot);
@@ -757,21 +775,25 @@ create_winMain (void)
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsPen));
gtk_widget_show (toolsPen);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsPen);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsPen), TRUE);
toolsEraser = gtk_radio_menu_item_new_with_mnemonic (toolsPen_group, "_Eraser");
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsEraser));
gtk_widget_show (toolsEraser);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsEraser);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsEraser), TRUE);
toolsHighlighter = gtk_radio_menu_item_new_with_mnemonic (toolsPen_group, "_Highlighter");
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsHighlighter));
gtk_widget_show (toolsHighlighter);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsHighlighter);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsHighlighter), TRUE);
toolsText = gtk_radio_menu_item_new_with_mnemonic (toolsPen_group, "_Text");
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsText));
gtk_widget_show (toolsText);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsText);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsText), TRUE);
separator9 = gtk_separator_menu_item_new ();
gtk_widget_show (separator9);
@@ -782,11 +804,13 @@ create_winMain (void)
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsSelectRegion));
gtk_widget_show (toolsSelectRegion);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsSelectRegion);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsSelectRegion), TRUE);
toolsSelectRectangle = gtk_radio_menu_item_new_with_mnemonic (toolsPen_group, "Select Rectangle");
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsSelectRectangle));
gtk_widget_show (toolsSelectRectangle);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsSelectRectangle);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsSelectRectangle), TRUE);
toolsVerticalSpace = gtk_radio_menu_item_new_with_mnemonic (toolsPen_group, "Vertical Space");
toolsPen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (toolsVerticalSpace));
@@ -803,9 +827,9 @@ create_winMain (void)
gtk_widget_show (toolsColor);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsColor);
- image587 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image587);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (toolsColor), image587);
+ image609 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image609);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (toolsColor), image609);
toolsColor_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (toolsColor), toolsColor_menu);
@@ -814,26 +838,31 @@ create_winMain (void)
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorBlack));
gtk_widget_show (colorBlack);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorBlack);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorBlack), TRUE);
colorBlue = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "blue");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorBlue));
gtk_widget_show (colorBlue);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorBlue);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorBlue), TRUE);
colorRed = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "red");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorRed));
gtk_widget_show (colorRed);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorRed);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorRed), TRUE);
colorGreen = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "green");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorGreen));
gtk_widget_show (colorGreen);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorGreen);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorGreen), TRUE);
colorGray = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "gray");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorGray));
gtk_widget_show (colorGray);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorGray);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorGray), TRUE);
separator17 = gtk_separator_menu_item_new ();
gtk_widget_show (separator17);
@@ -844,36 +873,43 @@ create_winMain (void)
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorLightBlue));
gtk_widget_show (colorLightBlue);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorLightBlue);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorLightBlue), TRUE);
colorLightGreen = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "light green");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorLightGreen));
gtk_widget_show (colorLightGreen);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorLightGreen);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorLightGreen), TRUE);
colorMagenta = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "magenta");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorMagenta));
gtk_widget_show (colorMagenta);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorMagenta);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorMagenta), TRUE);
colorOrange = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "orange");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorOrange));
gtk_widget_show (colorOrange);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorOrange);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorOrange), TRUE);
colorYellow = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "yellow");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorYellow));
gtk_widget_show (colorYellow);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorYellow);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorYellow), TRUE);
colorWhite = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "white");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorWhite));
gtk_widget_show (colorWhite);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorWhite);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorWhite), TRUE);
colorOther = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "other...");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorOther));
gtk_widget_show (colorOther);
gtk_container_add (GTK_CONTAINER (toolsColor_menu), colorOther);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (colorOther), TRUE);
colorNA = gtk_radio_menu_item_new_with_mnemonic (colorBlack_group, "NA");
colorBlack_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (colorNA));
@@ -891,21 +927,25 @@ create_winMain (void)
penthicknessVeryFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (penthicknessVeryFine));
gtk_widget_show (penthicknessVeryFine);
gtk_container_add (GTK_CONTAINER (toolsPenOptions_menu), penthicknessVeryFine);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (penthicknessVeryFine), TRUE);
penthicknessFine = gtk_radio_menu_item_new_with_mnemonic (penthicknessVeryFine_group, "fine");
penthicknessVeryFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (penthicknessFine));
gtk_widget_show (penthicknessFine);
gtk_container_add (GTK_CONTAINER (toolsPenOptions_menu), penthicknessFine);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (penthicknessFine), TRUE);
penthicknessMedium = gtk_radio_menu_item_new_with_mnemonic (penthicknessVeryFine_group, "medium");
penthicknessVeryFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (penthicknessMedium));
gtk_widget_show (penthicknessMedium);
gtk_container_add (GTK_CONTAINER (toolsPenOptions_menu), penthicknessMedium);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (penthicknessMedium), TRUE);
penthicknessThick = gtk_radio_menu_item_new_with_mnemonic (penthicknessVeryFine_group, "thick");
penthicknessVeryFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (penthicknessThick));
gtk_widget_show (penthicknessThick);
gtk_container_add (GTK_CONTAINER (toolsPenOptions_menu), penthicknessThick);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (penthicknessThick), TRUE);
penthicknessVeryThick = gtk_radio_menu_item_new_with_mnemonic (penthicknessVeryFine_group, "very thick");
penthicknessVeryFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (penthicknessVeryThick));
@@ -924,11 +964,13 @@ create_winMain (void)
eraserFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (eraserFine));
gtk_widget_show (eraserFine);
gtk_container_add (GTK_CONTAINER (toolsEraserOptions_menu), eraserFine);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (eraserFine), TRUE);
eraserMedium = gtk_radio_menu_item_new_with_mnemonic (eraserFine_group, "medium");
eraserFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (eraserMedium));
gtk_widget_show (eraserMedium);
gtk_container_add (GTK_CONTAINER (toolsEraserOptions_menu), eraserMedium);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (eraserMedium), TRUE);
eraserThick = gtk_radio_menu_item_new_with_mnemonic (eraserFine_group, "thick");
eraserFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (eraserThick));
@@ -945,11 +987,13 @@ create_winMain (void)
eraserStandard_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (eraserStandard));
gtk_widget_show (eraserStandard);
gtk_container_add (GTK_CONTAINER (toolsEraserOptions_menu), eraserStandard);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (eraserStandard), TRUE);
eraserWhiteout = gtk_radio_menu_item_new_with_mnemonic (eraserStandard_group, "whiteout");
eraserStandard_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (eraserWhiteout));
gtk_widget_show (eraserWhiteout);
gtk_container_add (GTK_CONTAINER (toolsEraserOptions_menu), eraserWhiteout);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (eraserWhiteout), TRUE);
eraserDeleteStrokes = gtk_radio_menu_item_new_with_mnemonic (eraserStandard_group, "delete strokes");
eraserStandard_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (eraserDeleteStrokes));
@@ -968,11 +1012,13 @@ create_winMain (void)
highlighterFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (highlighterFine));
gtk_widget_show (highlighterFine);
gtk_container_add (GTK_CONTAINER (toolsHighlighterOptions_menu), highlighterFine);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (highlighterFine), TRUE);
highlighterMedium = gtk_radio_menu_item_new_with_mnemonic (highlighterFine_group, "medium");
highlighterFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (highlighterMedium));
gtk_widget_show (highlighterMedium);
gtk_container_add (GTK_CONTAINER (toolsHighlighterOptions_menu), highlighterMedium);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (highlighterMedium), TRUE);
highlighterThick = gtk_radio_menu_item_new_with_mnemonic (highlighterFine_group, "thick");
highlighterFine_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (highlighterThick));
@@ -984,9 +1030,9 @@ create_winMain (void)
gtk_widget_show (toolsTextFont);
gtk_container_add (GTK_CONTAINER (menuTools_menu), toolsTextFont);
- image588 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU);
- gtk_widget_show (image588);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (toolsTextFont), image588);
+ image610 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image610);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (toolsTextFont), image610);
separator10 = gtk_separator_menu_item_new ();
gtk_widget_show (separator10);
@@ -1054,31 +1100,37 @@ create_winMain (void)
button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2Eraser));
gtk_widget_show (button2Eraser);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2Eraser);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2Eraser), TRUE);
button2Highlighter = gtk_radio_menu_item_new_with_mnemonic (button2Pen_group, "Highlighter");
button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2Highlighter));
gtk_widget_show (button2Highlighter);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2Highlighter);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2Highlighter), TRUE);
button2Text = gtk_radio_menu_item_new_with_mnemonic (button2Pen_group, "Text");
button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2Text));
gtk_widget_show (button2Text);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2Text);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2Text), TRUE);
button2SelectRegion = gtk_radio_menu_item_new_with_mnemonic (button2Pen_group, "Select Region");
button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2SelectRegion));
gtk_widget_show (button2SelectRegion);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2SelectRegion);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2SelectRegion), TRUE);
button2SelectRectangle = gtk_radio_menu_item_new_with_mnemonic (button2Pen_group, "Select Rectangle");
button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2SelectRectangle));
gtk_widget_show (button2SelectRectangle);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2SelectRectangle);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2SelectRectangle), TRUE);
button2VerticalSpace = gtk_radio_menu_item_new_with_mnemonic (button2Pen_group, "Vertical Space");
button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2VerticalSpace));
gtk_widget_show (button2VerticalSpace);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2VerticalSpace);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2VerticalSpace), TRUE);
separator24 = gtk_separator_menu_item_new ();
gtk_widget_show (separator24);
@@ -1089,15 +1141,18 @@ create_winMain (void)
button2LinkBrush_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2LinkBrush));
gtk_widget_show (button2LinkBrush);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2LinkBrush);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2LinkBrush), TRUE);
button2CopyBrush = gtk_radio_menu_item_new_with_mnemonic (button2LinkBrush_group, "Copy of Current Brush");
button2LinkBrush_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2CopyBrush));
gtk_widget_show (button2CopyBrush);
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2CopyBrush);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2CopyBrush), TRUE);
button2NABrush = gtk_radio_menu_item_new_with_mnemonic (button2LinkBrush_group, "NA");
button2LinkBrush_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2NABrush));
gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2NABrush);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2NABrush), TRUE);
button3_mapping = gtk_menu_item_new_with_mnemonic ("Button 3 Mapping");
gtk_widget_show (button3_mapping);
@@ -1116,31 +1171,37 @@ create_winMain (void)
button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3Eraser));
gtk_widget_show (button3Eraser);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3Eraser);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3Eraser), TRUE);
button3Highlighter = gtk_radio_menu_item_new_with_mnemonic (button3Pen_group, "Highlighter");
button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3Highlighter));
gtk_widget_show (button3Highlighter);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3Highlighter);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3Highlighter), TRUE);
button3Text = gtk_radio_menu_item_new_with_mnemonic (button3Pen_group, "Text");
button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3Text));
gtk_widget_show (button3Text);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3Text);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3Text), TRUE);
button3SelectRegion = gtk_radio_menu_item_new_with_mnemonic (button3Pen_group, "Select Region");
button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3SelectRegion));
gtk_widget_show (button3SelectRegion);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3SelectRegion);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3SelectRegion), TRUE);
button3SelectRectangle = gtk_radio_menu_item_new_with_mnemonic (button3Pen_group, "Select Rectangle");
button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3SelectRectangle));
gtk_widget_show (button3SelectRectangle);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3SelectRectangle);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3SelectRectangle), TRUE);
button3VerticalSpace = gtk_radio_menu_item_new_with_mnemonic (button3Pen_group, "Vertical Space");
button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3VerticalSpace));
gtk_widget_show (button3VerticalSpace);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3VerticalSpace);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3VerticalSpace), TRUE);
separator25 = gtk_separator_menu_item_new ();
gtk_widget_show (separator25);
@@ -1151,15 +1212,18 @@ create_winMain (void)
button3LinkBrush_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3LinkBrush));
gtk_widget_show (button3LinkBrush);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3LinkBrush);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3LinkBrush), TRUE);
button3CopyBrush = gtk_radio_menu_item_new_with_mnemonic (button3LinkBrush_group, "Copy of Current Brush");
button3LinkBrush_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3CopyBrush));
gtk_widget_show (button3CopyBrush);
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3CopyBrush);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3CopyBrush), TRUE);
button3NABrush = gtk_radio_menu_item_new_with_mnemonic (button3LinkBrush_group, "NA");
button3LinkBrush_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3NABrush));
gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3NABrush);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3NABrush), TRUE);
separator18 = gtk_separator_menu_item_new ();
gtk_widget_show (separator18);
@@ -1307,6 +1371,11 @@ create_winMain (void)
gtk_container_add (GTK_CONTAINER (toolbarMain), buttonNormalSize);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (buttonNormalSize), tooltips, "Normal Size", NULL);
+ buttonZoomSet = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-find");
+ gtk_widget_show (buttonZoomSet);
+ gtk_container_add (GTK_CONTAINER (toolbarMain), buttonZoomSet);
+ gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (buttonZoomSet), tooltips, "Set Zoom", NULL);
+
buttonFullscreen = (GtkWidget*) gtk_toggle_tool_button_new ();
gtk_tool_button_set_label (GTK_TOOL_BUTTON (buttonFullscreen), "");
tmp_image = create_pixmap (winMain, "fullscreen.png");
@@ -1772,6 +1841,9 @@ create_winMain (void)
g_signal_connect ((gpointer) viewPageWidth, "activate",
G_CALLBACK (on_viewPageWidth_activate),
NULL);
+ g_signal_connect ((gpointer) viewSetZoom, "activate",
+ G_CALLBACK (on_viewSetZoom_activate),
+ NULL);
g_signal_connect ((gpointer) viewFirstPage, "activate",
G_CALLBACK (on_viewFirstPage_activate),
NULL);
@@ -2099,6 +2171,9 @@ create_winMain (void)
g_signal_connect ((gpointer) buttonNormalSize, "clicked",
G_CALLBACK (on_viewNormalSize_activate),
NULL);
+ g_signal_connect ((gpointer) buttonZoomSet, "clicked",
+ G_CALLBACK (on_viewSetZoom_activate),
+ NULL);
g_signal_connect ((gpointer) buttonFullscreen, "toggled",
G_CALLBACK (on_viewFullscreen_activate),
NULL);
@@ -2189,7 +2264,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, menuFile_menu, "menuFile_menu");
GLADE_HOOKUP_OBJECT (winMain, fileNew, "fileNew");
GLADE_HOOKUP_OBJECT (winMain, fileNewBackground, "fileNewBackground");
- GLADE_HOOKUP_OBJECT (winMain, image577, "image577");
+ GLADE_HOOKUP_OBJECT (winMain, image599, "image599");
GLADE_HOOKUP_OBJECT (winMain, fileOpen, "fileOpen");
GLADE_HOOKUP_OBJECT (winMain, fileSave, "fileSave");
GLADE_HOOKUP_OBJECT (winMain, fileSaveAs, "fileSaveAs");
@@ -2206,7 +2281,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, mru7, "mru7");
GLADE_HOOKUP_OBJECT (winMain, separator22, "separator22");
GLADE_HOOKUP_OBJECT (winMain, filePrintOptions, "filePrintOptions");
- GLADE_HOOKUP_OBJECT (winMain, image578, "image578");
+ GLADE_HOOKUP_OBJECT (winMain, image600, "image600");
GLADE_HOOKUP_OBJECT (winMain, filePrint, "filePrint");
GLADE_HOOKUP_OBJECT (winMain, filePrintPDF, "filePrintPDF");
GLADE_HOOKUP_OBJECT (winMain, separator2, "separator2");
@@ -2231,21 +2306,22 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, viewZoomOut, "viewZoomOut");
GLADE_HOOKUP_OBJECT (winMain, viewNormalSize, "viewNormalSize");
GLADE_HOOKUP_OBJECT (winMain, viewPageWidth, "viewPageWidth");
- GLADE_HOOKUP_OBJECT (winMain, image579, "image579");
+ GLADE_HOOKUP_OBJECT (winMain, image601, "image601");
+ GLADE_HOOKUP_OBJECT (winMain, viewSetZoom, "viewSetZoom");
GLADE_HOOKUP_OBJECT (winMain, separator5, "separator5");
GLADE_HOOKUP_OBJECT (winMain, viewFirstPage, "viewFirstPage");
- GLADE_HOOKUP_OBJECT (winMain, image580, "image580");
+ GLADE_HOOKUP_OBJECT (winMain, image602, "image602");
GLADE_HOOKUP_OBJECT (winMain, viewPreviousPage, "viewPreviousPage");
- GLADE_HOOKUP_OBJECT (winMain, image581, "image581");
+ GLADE_HOOKUP_OBJECT (winMain, image603, "image603");
GLADE_HOOKUP_OBJECT (winMain, viewNextPage, "viewNextPage");
- GLADE_HOOKUP_OBJECT (winMain, image582, "image582");
+ GLADE_HOOKUP_OBJECT (winMain, image604, "image604");
GLADE_HOOKUP_OBJECT (winMain, viewLastPage, "viewLastPage");
- GLADE_HOOKUP_OBJECT (winMain, image583, "image583");
+ GLADE_HOOKUP_OBJECT (winMain, image605, "image605");
GLADE_HOOKUP_OBJECT (winMain, separator6, "separator6");
GLADE_HOOKUP_OBJECT (winMain, viewShowLayer, "viewShowLayer");
- GLADE_HOOKUP_OBJECT (winMain, image584, "image584");
+ GLADE_HOOKUP_OBJECT (winMain, image606, "image606");
GLADE_HOOKUP_OBJECT (winMain, viewHideLayer, "viewHideLayer");
- GLADE_HOOKUP_OBJECT (winMain, image585, "image585");
+ GLADE_HOOKUP_OBJECT (winMain, image607, "image607");
GLADE_HOOKUP_OBJECT (winMain, menuJournal, "menuJournal");
GLADE_HOOKUP_OBJECT (winMain, menuJournal_menu, "menuJournal_menu");
GLADE_HOOKUP_OBJECT (winMain, journalNewPageBefore, "journalNewPageBefore");
@@ -2278,7 +2354,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, journalApplyAllPages, "journalApplyAllPages");
GLADE_HOOKUP_OBJECT (winMain, separator23, "separator23");
GLADE_HOOKUP_OBJECT (winMain, journalLoadBackground, "journalLoadBackground");
- GLADE_HOOKUP_OBJECT (winMain, image586, "image586");
+ GLADE_HOOKUP_OBJECT (winMain, image608, "image608");
GLADE_HOOKUP_OBJECT (winMain, journalScreenshot, "journalScreenshot");
GLADE_HOOKUP_OBJECT (winMain, separator19, "separator19");
GLADE_HOOKUP_OBJECT (winMain, journalDefaultBackground, "journalDefaultBackground");
@@ -2295,7 +2371,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, toolsVerticalSpace, "toolsVerticalSpace");
GLADE_HOOKUP_OBJECT (winMain, separator16, "separator16");
GLADE_HOOKUP_OBJECT (winMain, toolsColor, "toolsColor");
- GLADE_HOOKUP_OBJECT (winMain, image587, "image587");
+ GLADE_HOOKUP_OBJECT (winMain, image609, "image609");
GLADE_HOOKUP_OBJECT (winMain, toolsColor_menu, "toolsColor_menu");
GLADE_HOOKUP_OBJECT (winMain, colorBlack, "colorBlack");
GLADE_HOOKUP_OBJECT (winMain, colorBlue, "colorBlue");
@@ -2333,7 +2409,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, highlighterMedium, "highlighterMedium");
GLADE_HOOKUP_OBJECT (winMain, highlighterThick, "highlighterThick");
GLADE_HOOKUP_OBJECT (winMain, toolsTextFont, "toolsTextFont");
- GLADE_HOOKUP_OBJECT (winMain, image588, "image588");
+ GLADE_HOOKUP_OBJECT (winMain, image610, "image610");
GLADE_HOOKUP_OBJECT (winMain, separator10, "separator10");
GLADE_HOOKUP_OBJECT (winMain, toolsDefaultPen, "toolsDefaultPen");
GLADE_HOOKUP_OBJECT (winMain, toolsDefaultEraser, "toolsDefaultEraser");
@@ -2404,6 +2480,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, buttonPageWidth, "buttonPageWidth");
GLADE_HOOKUP_OBJECT (winMain, buttonZoomIn, "buttonZoomIn");
GLADE_HOOKUP_OBJECT (winMain, buttonNormalSize, "buttonNormalSize");
+ GLADE_HOOKUP_OBJECT (winMain, buttonZoomSet, "buttonZoomSet");
GLADE_HOOKUP_OBJECT (winMain, buttonFullscreen, "buttonFullscreen");
GLADE_HOOKUP_OBJECT (winMain, toolbarPen, "toolbarPen");
GLADE_HOOKUP_OBJECT (winMain, buttonPen, "buttonPen");
@@ -2710,3 +2787,133 @@ create_aboutDialog (void)
return aboutDialog;
}
+GtkWidget*
+create_zoomDialog (void)
+{
+ GtkWidget *zoomDialog;
+ GtkWidget *dialog_vbox3;
+ GtkWidget *vbox1;
+ GtkWidget *hbox4;
+ GtkWidget *radioZoom;
+ GSList *radioZoom_group = NULL;
+ GtkObject *spinZoom_adj;
+ GtkWidget *spinZoom;
+ GtkWidget *label1;
+ GtkWidget *radioZoom100;
+ GtkWidget *radioZoomWidth;
+ GtkWidget *radioZoomHeight;
+ GtkWidget *dialog_action_area3;
+ GtkWidget *cancelbutton2;
+ GtkWidget *button1;
+ GtkWidget *button2;
+
+ zoomDialog = gtk_dialog_new ();
+ gtk_window_set_title (GTK_WINDOW (zoomDialog), "Set Zoom");
+ gtk_window_set_modal (GTK_WINDOW (zoomDialog), TRUE);
+ gtk_window_set_type_hint (GTK_WINDOW (zoomDialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ dialog_vbox3 = GTK_DIALOG (zoomDialog)->vbox;
+ gtk_widget_show (dialog_vbox3);
+
+ vbox1 = gtk_vbox_new (FALSE, 2);
+ gtk_widget_show (vbox1);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox3), vbox1, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox1), 8);
+
+ hbox4 = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox4);
+ gtk_box_pack_start (GTK_BOX (vbox1), hbox4, FALSE, FALSE, 0);
+
+ radioZoom = gtk_radio_button_new_with_mnemonic (NULL, "Zoom: ");
+ gtk_widget_show (radioZoom);
+ gtk_box_pack_start (GTK_BOX (hbox4), radioZoom, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (radioZoom), 4);
+ gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioZoom), radioZoom_group);
+ radioZoom_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioZoom));
+
+ spinZoom_adj = gtk_adjustment_new (100, 10, 1500, 5, 20, 20);
+ spinZoom = gtk_spin_button_new (GTK_ADJUSTMENT (spinZoom_adj), 1, 0);
+ gtk_widget_show (spinZoom);
+ gtk_box_pack_start (GTK_BOX (hbox4), spinZoom, FALSE, TRUE, 5);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinZoom), TRUE);
+
+ label1 = gtk_label_new ("%");
+ gtk_widget_show (label1);
+ gtk_box_pack_start (GTK_BOX (hbox4), label1, FALSE, TRUE, 0);
+ gtk_misc_set_alignment (GTK_MISC (label1), 0.48, 0.5);
+
+ radioZoom100 = gtk_radio_button_new_with_mnemonic (NULL, "Normal size (100%)");
+ gtk_widget_show (radioZoom100);
+ gtk_box_pack_start (GTK_BOX (vbox1), radioZoom100, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (radioZoom100), 4);
+ gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioZoom100), radioZoom_group);
+ radioZoom_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioZoom100));
+
+ radioZoomWidth = gtk_radio_button_new_with_mnemonic (NULL, "Page Width");
+ gtk_widget_show (radioZoomWidth);
+ gtk_box_pack_start (GTK_BOX (vbox1), radioZoomWidth, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (radioZoomWidth), 4);
+ gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioZoomWidth), radioZoom_group);
+ radioZoom_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioZoomWidth));
+
+ radioZoomHeight = gtk_radio_button_new_with_mnemonic (NULL, "Page Height");
+ gtk_widget_show (radioZoomHeight);
+ gtk_box_pack_start (GTK_BOX (vbox1), radioZoomHeight, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (radioZoomHeight), 4);
+ gtk_radio_button_set_group (GTK_RADIO_BUTTON (radioZoomHeight), radioZoom_group);
+ radioZoom_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radioZoomHeight));
+
+ dialog_action_area3 = GTK_DIALOG (zoomDialog)->action_area;
+ gtk_widget_show (dialog_action_area3);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area3), GTK_BUTTONBOX_END);
+
+ cancelbutton2 = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_widget_show (cancelbutton2);
+ gtk_dialog_add_action_widget (GTK_DIALOG (zoomDialog), cancelbutton2, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT);
+
+ button1 = gtk_button_new_from_stock ("gtk-apply");
+ gtk_widget_show (button1);
+ gtk_dialog_add_action_widget (GTK_DIALOG (zoomDialog), button1, GTK_RESPONSE_APPLY);
+ GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);
+
+ button2 = gtk_button_new_from_stock ("gtk-ok");
+ gtk_widget_show (button2);
+ gtk_dialog_add_action_widget (GTK_DIALOG (zoomDialog), button2, GTK_RESPONSE_OK);
+ GTK_WIDGET_SET_FLAGS (button2, GTK_CAN_DEFAULT);
+
+ g_signal_connect ((gpointer) radioZoom, "toggled",
+ G_CALLBACK (on_radioZoom_toggled),
+ NULL);
+ g_signal_connect ((gpointer) spinZoom, "value_changed",
+ G_CALLBACK (on_spinZoom_value_changed),
+ NULL);
+ g_signal_connect ((gpointer) radioZoom100, "toggled",
+ G_CALLBACK (on_radioZoom100_toggled),
+ NULL);
+ g_signal_connect ((gpointer) radioZoomWidth, "toggled",
+ G_CALLBACK (on_radioZoomWidth_toggled),
+ NULL);
+ g_signal_connect ((gpointer) radioZoomHeight, "toggled",
+ G_CALLBACK (on_radioZoomHeight_toggled),
+ NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (zoomDialog, zoomDialog, "zoomDialog");
+ GLADE_HOOKUP_OBJECT_NO_REF (zoomDialog, dialog_vbox3, "dialog_vbox3");
+ GLADE_HOOKUP_OBJECT (zoomDialog, vbox1, "vbox1");
+ GLADE_HOOKUP_OBJECT (zoomDialog, hbox4, "hbox4");
+ GLADE_HOOKUP_OBJECT (zoomDialog, radioZoom, "radioZoom");
+ GLADE_HOOKUP_OBJECT (zoomDialog, spinZoom, "spinZoom");
+ GLADE_HOOKUP_OBJECT (zoomDialog, label1, "label1");
+ GLADE_HOOKUP_OBJECT (zoomDialog, radioZoom100, "radioZoom100");
+ GLADE_HOOKUP_OBJECT (zoomDialog, radioZoomWidth, "radioZoomWidth");
+ GLADE_HOOKUP_OBJECT (zoomDialog, radioZoomHeight, "radioZoomHeight");
+ GLADE_HOOKUP_OBJECT_NO_REF (zoomDialog, dialog_action_area3, "dialog_action_area3");
+ GLADE_HOOKUP_OBJECT (zoomDialog, cancelbutton2, "cancelbutton2");
+ GLADE_HOOKUP_OBJECT (zoomDialog, button1, "button1");
+ GLADE_HOOKUP_OBJECT (zoomDialog, button2, "button2");
+
+ return zoomDialog;
+}
+
diff --git a/src/xo-interface.h b/src/xo-interface.h
index aeebce4..08921ca 100644
--- a/src/xo-interface.h
+++ b/src/xo-interface.h
@@ -7,3 +7,4 @@ GtkWidget* create_fontDialog (void);
GtkWidget* create_colorChooserDialog (void);
GtkWidget* create_papersizeDialog (void);
GtkWidget* create_aboutDialog (void);
+GtkWidget* create_zoomDialog (void);
diff --git a/src/xo-misc.c b/src/xo-misc.c
index b85c284..f6dab78 100644
--- a/src/xo-misc.c
+++ b/src/xo-misc.c
@@ -1,3 +1,6 @@
+// comment out the line below if you want the thickness settings of v 0.2
+#define NEW_THICKNESS
+
#ifdef HAVE_CONFIG_H
# include
#endif
@@ -27,11 +30,19 @@ guint predef_bgcolors_rgba[COLOR_MAX] = // meaningless ones set to white
0xffffffff, 0xa0e8ffff, 0x80ffc0ff, 0xffc0d4ff,
0xffc080ff, 0xffff80ff, 0xffffffff };
+#ifdef NEW_THICKNESS
+double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX] =
+ { { 0.42, 0.85, 1.41, 2.26, 5.67 }, // pen thicknesses = 0.15, 0.3, 0.5, 0.8, 2 mm
+ { 2.83, 2.83, 8.50, 19.84, 19.84 }, // eraser thicknesses = 1, 2.5, 5 mm
+ { 2.83, 2.83, 8.50, 19.84, 19.84 }, // highlighter thicknesses = 1, 2.5, 5 mm
+ };
+#else
double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX] =
{ { 0.42, 0.85, 1.41, 2.26, 5.67 }, // pen thicknesses = 0.15, 0.3, 0.5, 0.8, 2 mm
{ 2.83, 2.83, 7.08, 14.17, 14.17 }, // eraser thicknesses = 1, 2.5, 5 mm
{ 2.83, 2.83, 7.08, 14.17, 14.17 }, // highlighter thicknesses = 1, 2.5, 5 mm
};
+#endif
// some manipulation functions
diff --git a/src/xo-misc.h b/src/xo-misc.h
index a4bd9ce..636f5e6 100644
--- a/src/xo-misc.h
+++ b/src/xo-misc.h
@@ -76,8 +76,8 @@ void process_mapping_activate(GtkMenuItem *menuitem, int m, int tool);
#define RULING_MARGIN_COLOR 0xff0080ff
#define RULING_COLOR 0x40a0ffff
#define RULING_THICKNESS 0.5
-#define RULING_LEFTMARGIN 72
-#define RULING_TOPMARGIN 80
-#define RULING_SPACING 24
+#define RULING_LEFTMARGIN 72.0
+#define RULING_TOPMARGIN 80.0
+#define RULING_SPACING 24.0
#define RULING_BOTTOMMARGIN RULING_SPACING
#define RULING_GRAPHSPACING 14.17
diff --git a/src/xo-paint.c b/src/xo-paint.c
index 5d19c1b..798643c 100644
--- a/src/xo-paint.c
+++ b/src/xo-paint.c
@@ -61,12 +61,10 @@ void update_cursor(void)
gdk_cursor_unref(ui.cursor);
ui.cursor = NULL;
}
- if (ui.cur_item_type == ITEM_MOVESEL) {
- if (ui.toolno[ui.cur_mapping] == TOOL_VERTSPACE)
- ui.cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
- else
- ui.cursor = gdk_cursor_new(GDK_FLEUR);
- }
+ if (ui.cur_item_type == ITEM_MOVESEL_VERT)
+ ui.cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
+ else if (ui.cur_item_type == ITEM_MOVESEL)
+ ui.cursor = gdk_cursor_new(GDK_FLEUR);
else if (ui.toolno[ui.cur_mapping] == TOOL_PEN) {
fg.red = (ui.cur_brush->color_rgba >> 16) & 0xff00;
fg.green = (ui.cur_brush->color_rgba >> 8) & 0xff00;
diff --git a/src/xo-print.c b/src/xo-print.c
index 147fd2e..04493c9 100644
--- a/src/xo-print.c
+++ b/src/xo-print.c
@@ -5,6 +5,8 @@
#include
#include
#include
+#include
+#include
#include "xournal.h"
#include "xo-misc.h"
@@ -18,6 +20,993 @@
#define RGBA_ALPHA(rgba) (((rgba>>0)&0xff)/255.0)
#define RGBA_RGB(rgba) RGBA_RED(rgba), RGBA_GREEN(rgba), RGBA_BLUE(rgba)
+/*********** Printing to PDF ************/
+
+gboolean ispdfspace(char c)
+{
+ return (c==0 || c==9 || c==10 || c==12 || c==13 || c==' ');
+}
+
+gboolean ispdfdelim(char c)
+{
+ return (c=='(' || c==')' || c=='<' || c=='>' || c=='[' || c==']' ||
+ c=='{' || c=='}' || c=='/' || c=='%');
+}
+
+void skipspace(char **p, char *eof)
+{
+ while (ispdfspace(**p) || **p=='%') {
+ if (**p=='%') while (*p!=eof && **p!=10 && **p!=13) (*p)++;
+ if (*p==eof) return;
+ (*p)++;
+ }
+}
+
+void free_pdfobj(struct PdfObj *obj)
+{
+ int i;
+
+ if (obj==NULL) return;
+ if ((obj->type == PDFTYPE_STRING || obj->type == PDFTYPE_NAME ||
+ obj->type == PDFTYPE_STREAM) && obj->str!=NULL)
+ g_free(obj->str);
+ if ((obj->type == PDFTYPE_ARRAY || obj->type == PDFTYPE_DICT ||
+ obj->type == PDFTYPE_STREAM) && obj->num>0) {
+ for (i=0; inum; i++)
+ free_pdfobj(obj->elts[i]);
+ g_free(obj->elts);
+ }
+ if ((obj->type == PDFTYPE_DICT || obj->type == PDFTYPE_STREAM) && obj->num>0) {
+ for (i=0; inum; i++)
+ g_free(obj->names[i]);
+ g_free(obj->names);
+ }
+ g_free(obj);
+}
+
+struct PdfObj *dup_pdfobj(struct PdfObj *obj)
+{
+ struct PdfObj *dup;
+ int i;
+
+ if (obj==NULL) return NULL;
+ dup = g_memdup(obj, sizeof(struct PdfObj));
+ if ((obj->type == PDFTYPE_STRING || obj->type == PDFTYPE_NAME ||
+ obj->type == PDFTYPE_STREAM) && obj->str!=NULL) {
+ if (obj->type == PDFTYPE_NAME) obj->len = strlen(obj->str);
+ dup->str = g_memdup(obj->str, obj->len+1);
+ }
+ if ((obj->type == PDFTYPE_ARRAY || obj->type == PDFTYPE_DICT ||
+ obj->type == PDFTYPE_STREAM) && obj->num>0) {
+ dup->elts = g_malloc(obj->num*sizeof(struct PdfObj *));
+ for (i=0; inum; i++)
+ dup->elts[i] = dup_pdfobj(obj->elts[i]);
+ }
+ if ((obj->type == PDFTYPE_DICT || obj->type == PDFTYPE_STREAM) && obj->num>0) {
+ dup->names = g_malloc(obj->num*sizeof(char *));
+ for (i=0; inum; i++)
+ dup->names[i] = g_strdup(obj->names[i]);
+ }
+ return dup;
+}
+
+void show_pdfobj(struct PdfObj *obj, GString *str)
+{
+ int i;
+ if (obj==NULL) return;
+ switch(obj->type) {
+ case PDFTYPE_CST:
+ if (obj->intval==1) g_string_append(str, "true");
+ if (obj->intval==0) g_string_append(str, "false");
+ if (obj->intval==-1) g_string_append(str, "null");
+ break;
+ case PDFTYPE_INT:
+ g_string_append_printf(str, "%d", obj->intval);
+ break;
+ case PDFTYPE_REAL:
+ g_string_append_printf(str, "%f", obj->realval);
+ break;
+ case PDFTYPE_STRING:
+ g_string_append_len(str, obj->str, obj->len);
+ break;
+ case PDFTYPE_NAME:
+ g_string_append(str, obj->str);
+ break;
+ case PDFTYPE_ARRAY:
+ g_string_append_c(str, '[');
+ for (i=0;inum;i++) {
+ if (i) g_string_append_c(str, ' ');
+ show_pdfobj(obj->elts[i], str);
+ }
+ g_string_append_c(str, ']');
+ break;
+ case PDFTYPE_DICT:
+ g_string_append(str, "<<");
+ for (i=0;inum;i++) {
+ g_string_append_printf(str, " %s ", obj->names[i]);
+ show_pdfobj(obj->elts[i], str);
+ }
+ g_string_append(str, " >>");
+ break;
+ case PDFTYPE_REF:
+ g_string_append_printf(str, "%d %d R", obj->intval, obj->num);
+ break;
+ }
+}
+
+void DEBUG_PRINTOBJ(struct PdfObj *obj)
+{
+ GString *s = g_string_new("");
+ show_pdfobj(obj, s);
+ puts(s->str);
+ g_string_free(s, TRUE);
+}
+
+// parse a PDF object; returns NULL if fails
+// THIS PARSER DOES NOT RECOGNIZE STREAMS YET
+
+struct PdfObj *parse_pdf_object(char **ptr, char *eof)
+{
+ struct PdfObj *obj, *elt;
+ char *p, *q, *r, *eltname;
+ int stack;
+
+ obj = g_malloc(sizeof(struct PdfObj));
+ p = *ptr;
+ skipspace(&p, eof);
+ if (p==eof) { g_free(obj); return NULL; }
+
+ // maybe a constant
+ if (!strncmp(p, "true", 4)) {
+ obj->type = PDFTYPE_CST;
+ obj->intval = 1;
+ *ptr = p+4;
+ return obj;
+ }
+ if (!strncmp(p, "false", 5)) {
+ obj->type = PDFTYPE_CST;
+ obj->intval = 0;
+ *ptr = p+5;
+ return obj;
+ }
+ if (!strncmp(p, "null", 4)) {
+ obj->type = PDFTYPE_CST;
+ obj->intval = -1;
+ *ptr = p+4;
+ return obj;
+ }
+
+ // or a number ?
+ obj->intval = strtol(p, &q, 10);
+ *ptr = q;
+ if (q!=p) {
+ if (*q == '.') {
+ obj->type = PDFTYPE_REAL;
+ obj->realval = strtod(p, ptr);
+ return obj;
+ }
+ if (ispdfspace(*q)) {
+ // check for indirect reference
+ skipspace(&q, eof);
+ obj->num = strtol(q, &r, 10);
+ if (r!=q) {
+ skipspace(&r, eof);
+ if (*r=='R') {
+ *ptr = r+1;
+ obj->type = PDFTYPE_REF;
+ return obj;
+ }
+ }
+ }
+ obj->type = PDFTYPE_INT;
+ return obj;
+ }
+
+ // a string ?
+ if (*p=='(') {
+ q=p+1; stack=1;
+ while (stack>0 && q!=eof) {
+ if (*q=='(') stack++;
+ if (*q==')') stack--;
+ if (*q=='\\') q++;
+ if (q!=eof) q++;
+ }
+ if (q==eof) { g_free(obj); return NULL; }
+ obj->type = PDFTYPE_STRING;
+ obj->len = q-p;
+ obj->str = g_malloc(obj->len+1);
+ obj->str[obj->len] = 0;
+ g_memmove(obj->str, p, obj->len);
+ *ptr = q;
+ return obj;
+ }
+ if (*p=='<' && p[1]!='<') {
+ q=p+1;
+ while (*q!='>' && q!=eof) q++;
+ if (q==eof) { g_free(obj); return NULL; }
+ q++;
+ obj->type = PDFTYPE_STRING;
+ obj->len = q-p;
+ obj->str = g_malloc(obj->len+1);
+ obj->str[obj->len] = 0;
+ g_memmove(obj->str, p, obj->len);
+ *ptr = q;
+ return obj;
+ }
+
+ // a name ?
+ if (*p=='/') {
+ q=p+1;
+ while (!ispdfspace(*q) && !ispdfdelim(*q)) q++;
+ obj->type = PDFTYPE_NAME;
+ obj->str = g_strndup(p, q-p);
+ *ptr = q;
+ return obj;
+ }
+
+ // an array ?
+ if (*p=='[') {
+ obj->type = PDFTYPE_ARRAY;
+ obj->num = 0;
+ obj->elts = NULL;
+ q=p+1; skipspace(&q, eof);
+ while (*q!=']') {
+ elt = parse_pdf_object(&q, eof);
+ if (elt==NULL) { free_pdfobj(obj); return NULL; }
+ obj->num++;
+ obj->elts = g_realloc(obj->elts, obj->num*sizeof(struct PdfObj *));
+ obj->elts[obj->num-1] = elt;
+ skipspace(&q, eof);
+ }
+ *ptr = q+1;
+ return obj;
+ }
+
+ // a dictionary ?
+ if (*p=='<' && p[1]=='<') {
+ obj->type = PDFTYPE_DICT;
+ obj->num = 0;
+ obj->elts = NULL;
+ obj->names = NULL;
+ q=p+2; skipspace(&q, eof);
+ while (*q!='>' || q[1]!='>') {
+ if (*q!='/') { free_pdfobj(obj); return NULL; }
+ r=q+1;
+ while (!ispdfspace(*r) && !ispdfdelim(*r)) r++;
+ eltname = g_strndup(q, r-q);
+ q=r; skipspace(&q, eof);
+ elt = parse_pdf_object(&q, eof);
+ if (elt==NULL) { g_free(eltname); free_pdfobj(obj); return NULL; }
+ obj->num++;
+ obj->elts = g_realloc(obj->elts, obj->num*sizeof(struct PdfObj *));
+ obj->names = g_realloc(obj->names, obj->num*sizeof(char *));
+ obj->elts[obj->num-1] = elt;
+ obj->names[obj->num-1] = eltname;
+ skipspace(&q, eof);
+ }
+ *ptr = q+2;
+ return obj;
+ }
+
+ // DOES NOT RECOGNIZE STREAMS YET (handle as subcase of dictionary)
+
+ g_free(obj);
+ return NULL;
+}
+
+struct PdfObj *get_dict_entry(struct PdfObj *dict, char *name)
+{
+ int i;
+
+ if (dict==NULL) return NULL;
+ if (dict->type != PDFTYPE_DICT) return NULL;
+ for (i=0; inum; i++)
+ if (!strcmp(dict->names[i], name)) return dict->elts[i];
+ return NULL;
+}
+
+struct PdfObj *get_pdfobj(GString *pdfbuf, struct XrefTable *xref, struct PdfObj *obj)
+{
+ char *p, *eof;
+ int offs, n;
+
+ if (obj==NULL) return NULL;
+ if (obj->type!=PDFTYPE_REF) return dup_pdfobj(obj);
+ if (obj->intval>xref->last) return NULL;
+ offs = xref->data[obj->intval];
+ if (offs<=0 || offs >= pdfbuf->len) return NULL;
+
+ p = pdfbuf->str + offs;
+ eof = pdfbuf->str + pdfbuf->len;
+ n = strtol(p, &p, 10);
+ if (n!=obj->intval) return NULL;
+ skipspace(&p, eof);
+ n = strtol(p, &p, 10);
+ skipspace(&p, eof);
+ if (strncmp(p, "obj", 3)) return NULL;
+ p+=3;
+ return parse_pdf_object(&p, eof);
+}
+
+// read the xref table of a PDF file in memory, and return the trailerdict
+
+struct PdfObj *parse_xref_table(GString *pdfbuf, struct XrefTable *xref, int offs)
+{
+ char *p, *q, *eof;
+ struct PdfObj *trailerdict, *obj;
+ int start, len, i;
+
+ if (strncmp(pdfbuf->str+offs, "xref", 4)) return NULL;
+ p = strstr(pdfbuf->str+offs, "trailer");
+ eof = pdfbuf->str + pdfbuf->len;
+ if (p==NULL) return NULL;
+ p+=8;
+ trailerdict = parse_pdf_object(&p, eof);
+ obj = get_dict_entry(trailerdict, "/Size");
+ if (obj!=NULL && obj->type == PDFTYPE_INT && obj->intval-1>xref->last)
+ make_xref(xref, obj->intval-1, 0);
+ obj = get_dict_entry(trailerdict, "/Prev");
+ if (obj!=NULL && obj->type == PDFTYPE_INT && obj->intval>0 && obj->intval!=offs) {
+ // recurse into older xref table
+ obj = parse_xref_table(pdfbuf, xref, obj->intval);
+ free_pdfobj(obj);
+ }
+ p = pdfbuf->str+offs+4;
+ skipspace(&p, eof);
+ if (*p<'0' || *p>'9') { free_pdfobj(trailerdict); return NULL; }
+ while (*p>='0' && *p<='9') {
+ start = strtol(p, &p, 10);
+ skipspace(&p, eof);
+ len = strtol(p, &p, 10);
+ skipspace(&p, eof);
+ if (len <= 0 || 20*len > eof-p) break;
+ if (start+len-1 > xref->last) make_xref(xref, start+len-1, 0);
+ for (i=start; idata[i] = strtol(p, NULL, 10);
+ p+=20;
+ }
+ skipspace(&p, eof);
+ }
+ if (*p!='t') { free_pdfobj(trailerdict); return NULL; }
+ return trailerdict;
+}
+
+// parse the page tree
+
+int pdf_getpageinfo(GString *pdfbuf, struct XrefTable *xref,
+ struct PdfObj *pgtree, int nmax, struct PdfPageDesc *pages)
+{
+ struct PdfObj *obj, *kid;
+ int i, count, j;
+
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/Type"));
+ if (obj == NULL || obj->type != PDFTYPE_NAME)
+ return 0;
+ if (!strcmp(obj->str, "/Page")) {
+ free_pdfobj(obj);
+ pages->contents = dup_pdfobj(get_dict_entry(pgtree, "/Contents"));
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/Resources"));
+ if (obj!=NULL) {
+ free_pdfobj(pages->resources);
+ pages->resources = obj;
+ }
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/MediaBox"));
+ if (obj!=NULL) {
+ free_pdfobj(pages->mediabox);
+ pages->mediabox = obj;
+ }
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/Rotate"));
+ if (obj!=NULL && obj->type == PDFTYPE_INT)
+ pages->rotate = obj->intval;
+ free_pdfobj(obj);
+ return 1;
+ }
+ else if (!strcmp(obj->str, "/Pages")) {
+ free_pdfobj(obj);
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/Count"));
+ if (obj!=NULL && obj->type == PDFTYPE_INT &&
+ obj->intval>0 && obj->intval<=nmax) count = obj->intval;
+ else count = 0;
+ free_pdfobj(obj);
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/Resources"));
+ if (obj!=NULL)
+ for (i=0; itype == PDFTYPE_INT)
+ for (i=0; iintval;
+ free_pdfobj(obj);
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pgtree, "/Kids"));
+ if (obj!=NULL && obj->type == PDFTYPE_ARRAY) {
+ for (i=0; inum; i++) {
+ kid = get_pdfobj(pdfbuf, xref, obj->elts[i]);
+ if (kid!=NULL) {
+ j = pdf_getpageinfo(pdfbuf, xref, kid, nmax, pages);
+ nmax -= j;
+ pages += j;
+ free_pdfobj(kid);
+ }
+ }
+ }
+ free_pdfobj(obj);
+ return count;
+ }
+ return 0;
+}
+
+// parse a PDF file in memory
+
+gboolean pdf_parse_info(GString *pdfbuf, struct PdfInfo *pdfinfo, struct XrefTable *xref)
+{
+ char *p;
+ int i, offs;
+ struct PdfObj *obj, *pages;
+
+ xref->n_alloc = xref->last = 0;
+ xref->data = NULL;
+ p = pdfbuf->str + pdfbuf->len-1;
+
+ while (*p!='s' && p!=pdfbuf->str) p--;
+ if (strncmp(p, "startxref", 9)) return FALSE; // fail
+ p+=9;
+ while (ispdfspace(*p) && p!=pdfbuf->str+pdfbuf->len) p++;
+ offs = strtol(p, NULL, 10);
+ if (offs <= 0 || offs > pdfbuf->len) return FALSE; // fail
+ pdfinfo->startxref = offs;
+
+ pdfinfo->trailerdict = parse_xref_table(pdfbuf, xref, offs);
+ if (pdfinfo->trailerdict == NULL) return FALSE; // fail
+
+ obj = get_pdfobj(pdfbuf, xref,
+ get_dict_entry(pdfinfo->trailerdict, "/Root"));
+ if (obj == NULL)
+ { free_pdfobj(pdfinfo->trailerdict); return FALSE; }
+ pages = get_pdfobj(pdfbuf, xref, get_dict_entry(obj, "/Pages"));
+ free_pdfobj(obj);
+ if (pages == NULL)
+ { free_pdfobj(pdfinfo->trailerdict); return FALSE; }
+ obj = get_pdfobj(pdfbuf, xref, get_dict_entry(pages, "/Count"));
+ if (obj == NULL || obj->type != PDFTYPE_INT || obj->intval<=0)
+ { free_pdfobj(pdfinfo->trailerdict); free_pdfobj(pages);
+ free_pdfobj(obj); return FALSE; }
+ pdfinfo->npages = obj->intval;
+ free_pdfobj(obj);
+
+ pdfinfo->pages = g_malloc0(pdfinfo->npages*sizeof(struct PdfPageDesc));
+ pdf_getpageinfo(pdfbuf, xref, pages, pdfinfo->npages, pdfinfo->pages);
+ free_pdfobj(pages);
+
+ return TRUE;
+}
+
+// add an entry to the xref table
+
+void make_xref(struct XrefTable *xref, int nobj, int offset)
+{
+ if (xref->n_alloc <= nobj) {
+ xref->n_alloc = nobj + 10;
+ xref->data = g_realloc(xref->data, xref->n_alloc*sizeof(int));
+ }
+ if (xref->last < nobj) xref->last = nobj;
+ xref->data[nobj] = offset;
+}
+
+// a wrapper for deflate
+
+GString *do_deflate(char *in, int len)
+{
+ GString *out;
+ z_stream zs;
+
+ zs.zalloc = Z_NULL;
+ zs.zfree = Z_NULL;
+ deflateInit(&zs, Z_DEFAULT_COMPRESSION);
+ zs.next_in = (Bytef *)in;
+ zs.avail_in = len;
+ zs.avail_out = deflateBound(&zs, len);
+ out = g_string_sized_new(zs.avail_out);
+ zs.next_out = (Bytef *)out->str;
+ deflate(&zs, Z_FINISH);
+ out->len = zs.total_out;
+ deflateEnd(&zs);
+ return out;
+}
+
+// prefix to scale the original page
+
+GString *make_pdfprefix(struct PdfPageDesc *pgdesc, double width, double height)
+{
+ GString *str;
+ double v[4], t, xscl, yscl;
+ int i;
+
+ str = g_string_new("q ");
+ if (pgdesc->rotate == 90) {
+ g_string_append_printf(str, "0 -1 1 0 0 %.2f cm ", height);
+ t = height; height = width; width = t;
+ }
+ if (pgdesc->rotate == 270) {
+ g_string_append_printf(str, "0 1 -1 0 %.2f 0 cm ", width);
+ t = height; height = width; width = t;
+ }
+ if (pgdesc->rotate == 180) {
+ g_string_append_printf(str, "-1 0 0 -1 %.2f %.2f cm ", width, height);
+ }
+ if (pgdesc->mediabox==NULL || pgdesc->mediabox->type != PDFTYPE_ARRAY ||
+ pgdesc->mediabox->num != 4) return str;
+ for (i=0; i<4; i++) {
+ if (pgdesc->mediabox->elts[i]->type == PDFTYPE_INT)
+ v[i] = pgdesc->mediabox->elts[i]->intval;
+ else if (pgdesc->mediabox->elts[i]->type == PDFTYPE_REAL)
+ v[i] = pgdesc->mediabox->elts[i]->realval;
+ else return str;
+ }
+ if (v[0]>v[2]) { t = v[0]; v[0] = v[2]; v[2] = t; }
+ if (v[1]>v[3]) { t = v[1]; v[1] = v[3]; v[3] = t; }
+ if (v[2]-v[0] < 1. || v[3]-v[1] < 1.) return str;
+ xscl = width/(v[2]-v[0]);
+ yscl = height/(v[3]-v[1]);
+ g_string_append_printf(str, "%.4f 0 0 %.4f %.2f %.2f cm ",
+ xscl, yscl, -v[0]*xscl, -v[1]*yscl);
+ return str;
+}
+
+// add an entry to a subentry of a directory
+
+struct PdfObj *mk_pdfname(char *name)
+{
+ struct PdfObj *obj;
+
+ obj = g_malloc(sizeof(struct PdfObj));
+ obj->type = PDFTYPE_NAME;
+ obj->str = g_strdup(name);
+ return obj;
+}
+
+struct PdfObj *mk_pdfref(int num)
+{
+ struct PdfObj *obj;
+
+ obj = g_malloc(sizeof(struct PdfObj));
+ obj->type = PDFTYPE_REF;
+ obj->intval = num;
+ obj->num = 0;
+ return obj;
+}
+
+gboolean iseq_obj(struct PdfObj *a, struct PdfObj *b)
+{
+ if (a==NULL || b==NULL) return (a==b);
+ if (a->type!=b->type) return FALSE;
+ if (a->type == PDFTYPE_CST || a->type == PDFTYPE_INT)
+ return (a->intval == b->intval);
+ if (a->type == PDFTYPE_REAL)
+ return (a->realval == b->realval);
+ if (a->type == PDFTYPE_NAME)
+ return !strcmp(a->str, b->str);
+ if (a->type == PDFTYPE_REF)
+ return (a->intval == b->intval && a->num == b->num);
+ return FALSE;
+}
+
+void add_dict_subentry(GString *pdfbuf, struct XrefTable *xref,
+ struct PdfObj *obj, char *section, int type, char *name, struct PdfObj *entry)
+{
+ struct PdfObj *sec;
+ int i, subpos;
+
+ subpos = -1;
+ for (i=0; inum; i++)
+ if (!strcmp(obj->names[i], section)) subpos = i;
+ if (subpos == -1) {
+ subpos = obj->num;
+ obj->num++;
+ obj->elts = g_realloc(obj->elts, obj->num*sizeof(struct PdfObj*));
+ obj->names = g_realloc(obj->names, obj->num*sizeof(char *));
+ obj->names[subpos] = g_strdup(section);
+ obj->elts[subpos] = NULL;
+ }
+ if (obj->elts[subpos]!=NULL && obj->elts[subpos]->type==PDFTYPE_REF) {
+ sec = get_pdfobj(pdfbuf, xref, obj->elts[subpos]);
+ free_pdfobj(obj->elts[subpos]);
+ obj->elts[subpos] = sec;
+ }
+ if (obj->elts[subpos]!=NULL && obj->elts[subpos]->type!=type)
+ { free_pdfobj(obj->elts[subpos]); obj->elts[subpos] = NULL; }
+ if (obj->elts[subpos] == NULL) {
+ obj->elts[subpos] = sec = g_malloc(sizeof(struct PdfObj));
+ sec->type = type;
+ sec->num = 0;
+ sec->elts = NULL;
+ sec->names = NULL;
+ }
+ sec = obj->elts[subpos];
+
+ subpos = -1;
+ if (type==PDFTYPE_DICT) {
+ for (i=0; inum; i++)
+ if (!strcmp(sec->names[i], name)) subpos = i;
+ if (subpos == -1) {
+ subpos = sec->num;
+ sec->num++;
+ sec->elts = g_realloc(sec->elts, sec->num*sizeof(struct PdfObj*));
+ sec->names = g_realloc(sec->names, sec->num*sizeof(char *));
+ sec->names[subpos] = g_strdup(name);
+ sec->elts[subpos] = NULL;
+ }
+ free_pdfobj(sec->elts[subpos]);
+ sec->elts[subpos] = entry;
+ }
+ if (type==PDFTYPE_ARRAY) {
+ for (i=0; inum; i++)
+ if (iseq_obj(sec->elts[i], entry)) subpos = i;
+ if (subpos == -1) {
+ subpos = sec->num;
+ sec->num++;
+ sec->elts = g_realloc(sec->elts, sec->num*sizeof(struct PdfObj*));
+ sec->elts[subpos] = entry;
+ }
+ else free_pdfobj(entry);
+ }
+}
+
+// draw a page's background
+
+void pdf_draw_solid_background(struct Page *pg, GString *str)
+{
+ double x, y;
+
+ g_string_append_printf(str,
+ "%.2f %.2f %.2f rg 0 0 %.2f %.2f re f ",
+ RGBA_RGB(pg->bg->color_rgba), pg->width, pg->height);
+ if (pg->bg->ruling == RULING_NONE) return;
+ g_string_append_printf(str,
+ "%.2f %.2f %.2f RG %.2f w ",
+ RGBA_RGB(RULING_COLOR), RULING_THICKNESS);
+ if (pg->bg->ruling == RULING_GRAPH) {
+ for (x=RULING_GRAPHSPACING; xwidth-1; x+=RULING_GRAPHSPACING)
+ g_string_append_printf(str, "%.2f 0 m %.2f %.2f l S ",
+ x, x, pg->height);
+ for (y=RULING_GRAPHSPACING; yheight-1; y+=RULING_GRAPHSPACING)
+ g_string_append_printf(str, "0 %.2f m %.2f %.2f l S ",
+ y, pg->width, y);
+ return;
+ }
+ for (y=RULING_TOPMARGIN; yheight-1; y+=RULING_SPACING)
+ g_string_append_printf(str, "0 %.2f m %.2f %.2f l S ",
+ y, pg->width, y);
+ if (pg->bg->ruling == RULING_LINED)
+ g_string_append_printf(str,
+ "%.2f %.2f %.2f RG %.2f 0 m %.2f %.2f l S ",
+ RGBA_RGB(RULING_MARGIN_COLOR),
+ RULING_LEFTMARGIN, RULING_LEFTMARGIN, pg->height);
+}
+
+int pdf_draw_bitmap_background(struct Page *pg, GString *str,
+ struct XrefTable *xref, GString *pdfbuf)
+{
+ BgPdfPage *pgpdf;
+ GdkPixbuf *pix;
+ GString *zpix;
+ char *buf, *p1, *p2;
+ int height, width, stride, x, y, chan;
+
+ if (pg->bg->type == BG_PDF) {
+ pgpdf = (struct BgPdfPage *)g_list_nth_data(bgpdf.pages, pg->bg->file_page_seq-1);
+ if (pgpdf == NULL) return -1;
+ if (pgpdf->dpi != PDFTOPPM_PRINTING_DPI) {
+ add_bgpdf_request(pg->bg->file_page_seq, 0, TRUE);
+ while (pgpdf->dpi != PDFTOPPM_PRINTING_DPI && bgpdf.status == STATUS_RUNNING)
+ gtk_main_iteration();
+ }
+ pix = pgpdf->pixbuf;
+ }
+ else pix = pg->bg->pixbuf;
+
+ if (gdk_pixbuf_get_bits_per_sample(pix) != 8) return -1;
+ if (gdk_pixbuf_get_colorspace(pix) != GDK_COLORSPACE_RGB) return -1;
+
+ width = gdk_pixbuf_get_width(pix);
+ height = gdk_pixbuf_get_height(pix);
+ stride = gdk_pixbuf_get_rowstride(pix);
+ chan = gdk_pixbuf_get_n_channels(pix);
+ if (chan!=3 && chan!=4) return -1;
+
+ g_string_append_printf(str, "q %.2f 0 0 %.2f 0 %.2f cm /ImBg Do Q ",
+ pg->width, -pg->height, pg->height);
+
+ p2 = buf = (char *)g_malloc(3*width*height);
+ for (y=0; ylast+1, pdfbuf->len);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Length %d /Filter /FlateDecode /Type /Xobject "
+ "/Subtype /Image /Width %d /Height %d /ColorSpace /DeviceRGB "
+ "/BitsPerComponent 8 >> stream\n",
+ xref->last, zpix->len, width, height);
+ g_string_append_len(pdfbuf, zpix->str, zpix->len);
+ g_string_free(zpix, TRUE);
+ g_string_append(pdfbuf, "endstream\nendobj\n");
+
+ return xref->last;
+}
+
+// draw a page's graphics
+
+void pdf_draw_page(struct Page *pg, GString *str, gboolean *use_hiliter)
+{
+ GList *layerlist, *itemlist;
+ struct Layer *l;
+ struct Item *item;
+ guint old_rgba;
+ double old_thickness;
+ double *pt;
+ int i;
+
+ old_rgba = 0x12345678; // not any values we use, so we'll reset them
+ old_thickness = 0.0;
+
+ for (layerlist = pg->layers; layerlist!=NULL; layerlist = layerlist->next) {
+ l = (struct Layer *)layerlist->data;
+ for (itemlist = l->items; itemlist!=NULL; itemlist = itemlist->next) {
+ item = (struct Item *)itemlist->data;
+ if (item->type == ITEM_STROKE) {
+ if ((item->brush.color_rgba & ~0xff) != old_rgba)
+ g_string_append_printf(str, "%.2f %.2f %.2f RG ",
+ RGBA_RGB(item->brush.color_rgba));
+ if (item->brush.thickness != old_thickness)
+ g_string_append_printf(str, "%.2f w ", item->brush.thickness);
+ if ((item->brush.color_rgba & 0xf0) != 0xf0) { // transparent
+ g_string_append(str, "q /XoHi gs ");
+ *use_hiliter = TRUE;
+ }
+ old_rgba = item->brush.color_rgba & ~0xff;
+ old_thickness = item->brush.thickness;
+ pt = item->path->coords;
+ g_string_append_printf(str, "%.2f %.2f m ", pt[0], pt[1]);
+ for (i=1, pt+=2; ipath->num_points; i++, pt+=2)
+ g_string_append_printf(str, "%.2f %.2f l ", pt[0], pt[1]);
+ g_string_append_printf(str,"S\n");
+ if ((item->brush.color_rgba & 0xf0) != 0xf0) // undo transparent
+ g_string_append(str, "Q ");
+ }
+ }
+ }
+}
+
+// main printing function
+
+/* we use the following object numbers, starting with n_obj_catalog:
+ 0 the document catalog
+ 1 the page tree
+ 2 the GS for the hiliters
+ 3 ... the page objects
+*/
+
+gboolean print_to_pdf(char *filename)
+{
+ FILE *f;
+ GString *pdfbuf, *pgstrm, *zpgstrm, *tmpstr;
+ int n_obj_catalog, n_obj_pages_offs, n_page, n_obj_bgpix, n_obj_prefix;
+ int i, startxref;
+ struct XrefTable xref;
+ GList *pglist;
+ struct Page *pg;
+ char *buf;
+ unsigned int len;
+ gboolean annot, uses_pdf;
+ gboolean use_hiliter;
+ struct PdfInfo pdfinfo;
+ struct PdfObj *obj;
+
+ f = fopen(filename, "w");
+ if (f == NULL) return FALSE;
+ annot = FALSE;
+ xref.data = NULL;
+ uses_pdf = FALSE;
+ for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) {
+ pg = (struct Page *)pglist->data;
+ if (pg->bg->type == BG_PDF) uses_pdf = TRUE;
+ }
+
+ if (uses_pdf && bgpdf.status != STATUS_NOT_INIT &&
+ g_file_get_contents(bgpdf.tmpfile_copy, &buf, &len, NULL) &&
+ !strncmp(buf, "%PDF-1.", 7)) {
+ // parse the existing PDF file
+ pdfbuf = g_string_new_len(buf, len);
+ g_free(buf);
+ if (pdfbuf->str[7]<'4') pdfbuf->str[7] = '4'; // upgrade to 1.4
+ annot = pdf_parse_info(pdfbuf, &pdfinfo, &xref);
+ if (!annot) {
+ g_string_free(pdfbuf, TRUE);
+ if (xref.data != NULL) g_free(xref.data);
+ }
+ }
+
+ if (!annot) {
+ pdfbuf = g_string_new("%PDF-1.4\n%\370\357\365\362\n");
+ xref.n_alloc = xref.last = 0;
+ xref.data = NULL;
+ }
+
+ // catalog and page tree
+ n_obj_catalog = xref.last+1;
+ n_obj_pages_offs = xref.last+4;
+ make_xref(&xref, n_obj_catalog, pdfbuf->len);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Type /Catalog /Pages %d 0 R >> endobj\n",
+ n_obj_catalog, n_obj_catalog+1);
+ make_xref(&xref, n_obj_catalog+1, pdfbuf->len);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Type /Pages /Kids [", n_obj_catalog+1);
+ for (i=0;i> endobj\n", journal.npages);
+ make_xref(&xref, n_obj_catalog+2, pdfbuf->len);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Type /ExtGState /CA 0.5 >> endobj\n",
+ n_obj_catalog+2);
+ xref.last = n_obj_pages_offs + journal.npages-1;
+
+ for (pglist = journal.pages, n_page = 0; pglist!=NULL;
+ pglist = pglist->next, n_page++) {
+ pg = (struct Page *)pglist->data;
+
+ // draw the background and page into pgstrm
+ pgstrm = g_string_new("");
+ g_string_printf(pgstrm, "q 1 0 0 -1 0 %.2f cm 1 J 1 j ", pg->height);
+ n_obj_bgpix = -1;
+ n_obj_prefix = -1;
+ if (pg->bg->type == BG_SOLID)
+ pdf_draw_solid_background(pg, pgstrm);
+ else if (pg->bg->type == BG_PDF && annot &&
+ pdfinfo.pages[pg->bg->file_page_seq-1].contents!=NULL) {
+ make_xref(&xref, xref.last+1, pdfbuf->len);
+ n_obj_prefix = xref.last;
+ tmpstr = make_pdfprefix(pdfinfo.pages+(pg->bg->file_page_seq-1),
+ pg->width, pg->height);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Length %d >> stream\n%s\nendstream\nendobj\n",
+ n_obj_prefix, tmpstr->len, tmpstr->str);
+ g_string_free(tmpstr, TRUE);
+ g_string_prepend(pgstrm, "Q ");
+ }
+ else if (pg->bg->type == BG_PIXMAP || pg->bg->type == BG_PDF)
+ n_obj_bgpix = pdf_draw_bitmap_background(pg, pgstrm, &xref, pdfbuf);
+ // draw the page contents
+ use_hiliter = FALSE;
+ pdf_draw_page(pg, pgstrm, &use_hiliter);
+ g_string_append_printf(pgstrm, "Q\n");
+
+ // deflate pgstrm and write it
+ zpgstrm = do_deflate(pgstrm->str, pgstrm->len);
+ g_string_free(pgstrm, TRUE);
+
+ make_xref(&xref, xref.last+1, pdfbuf->len);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Length %d /Filter /FlateDecode>> stream\n",
+ xref.last, zpgstrm->len);
+ g_string_append_len(pdfbuf, zpgstrm->str, zpgstrm->len);
+ g_string_free(zpgstrm, TRUE);
+ g_string_append(pdfbuf, "endstream\nendobj\n");
+
+ // write the page object
+
+ make_xref(&xref, n_obj_pages_offs+n_page, pdfbuf->len);
+ g_string_append_printf(pdfbuf,
+ "%d 0 obj\n<< /Type /Page /Parent %d 0 R /MediaBox [0 0 %.2f %.2f] ",
+ n_obj_pages_offs+n_page, n_obj_catalog+1, pg->width, pg->height);
+ if (n_obj_prefix>0) {
+ obj = get_pdfobj(pdfbuf, &xref, pdfinfo.pages[pg->bg->file_page_seq-1].contents);
+ if (obj->type != PDFTYPE_ARRAY) {
+ free_pdfobj(obj);
+ obj = dup_pdfobj(pdfinfo.pages[pg->bg->file_page_seq-1].contents);
+ }
+ g_string_append_printf(pdfbuf, "/Contents [%d 0 R ", n_obj_prefix);
+ if (obj->type == PDFTYPE_REF)
+ g_string_append_printf(pdfbuf, "%d %d R ", obj->intval, obj->num);
+ if (obj->type == PDFTYPE_ARRAY) {
+ for (i=0; inum; i++) {
+ show_pdfobj(obj->elts[i], pdfbuf);
+ g_string_append_c(pdfbuf, ' ');
+ }
+ }
+ free_pdfobj(obj);
+ g_string_append_printf(pdfbuf, "%d 0 R] ", xref.last);
+ }
+ else g_string_append_printf(pdfbuf, "/Contents %d 0 R ", xref.last);
+ g_string_append(pdfbuf, "/Resources ");
+
+ if (n_obj_prefix>0)
+ obj = dup_pdfobj(pdfinfo.pages[pg->bg->file_page_seq-1].resources);
+ else obj = NULL;
+ if (obj!=NULL && obj->type!=PDFTYPE_DICT)
+ { free_pdfobj(obj); obj=NULL; }
+ if (obj==NULL) {
+ obj = g_malloc(sizeof(struct PdfObj));
+ obj->type = PDFTYPE_DICT;
+ obj->num = 0;
+ obj->elts = NULL;
+ obj->names = NULL;
+ }
+ add_dict_subentry(pdfbuf, &xref,
+ obj, "/ProcSet", PDFTYPE_ARRAY, NULL, mk_pdfname("/PDF"));
+ if (n_obj_bgpix>0)
+ add_dict_subentry(pdfbuf, &xref,
+ obj, "/ProcSet", PDFTYPE_ARRAY, NULL, mk_pdfname("/ImageC"));
+ if (use_hiliter)
+ add_dict_subentry(pdfbuf, &xref,
+ obj, "/ExtGState", PDFTYPE_DICT, "/XoHi", mk_pdfref(n_obj_catalog+2));
+ if (n_obj_bgpix>0)
+ add_dict_subentry(pdfbuf, &xref,
+ obj, "/XObject", PDFTYPE_DICT, "/ImBg", mk_pdfref(n_obj_bgpix));
+ show_pdfobj(obj, pdfbuf);
+ free_pdfobj(obj);
+ g_string_append(pdfbuf, " >> endobj\n");
+ }
+
+ // PDF trailer
+ startxref = pdfbuf->len;
+ if (annot) g_string_append_printf(pdfbuf,
+ "xref\n%d %d\n", n_obj_catalog, xref.last-n_obj_catalog+1);
+ else g_string_append_printf(pdfbuf,
+ "xref\n0 %d\n0000000000 65535 f \n", xref.last+1);
+ for (i=n_obj_catalog; i<=xref.last; i++)
+ g_string_append_printf(pdfbuf, "%010d 00000 n \n", xref.data[i]);
+ g_string_append_printf(pdfbuf,
+ "trailer\n<< /Size %d /Root %d 0 R ", xref.last+1, n_obj_catalog);
+ if (annot) {
+ g_string_append_printf(pdfbuf, "/Prev %d ", pdfinfo.startxref);
+ // keeping encryption info somehow doesn't work.
+ // xournal can't annotate encrypted PDFs anyway...
+/*
+ obj = get_dict_entry(pdfinfo.trailerdict, "/Encrypt");
+ if (obj!=NULL) {
+ g_string_append_printf(pdfbuf, "/Encrypt ");
+ show_pdfobj(obj, pdfbuf);
+ }
+*/
+ }
+ g_string_append_printf(pdfbuf,
+ ">>\nstartxref\n%d\n%%%%EOF\n", startxref);
+
+ g_free(xref.data);
+ if (annot) {
+ free_pdfobj(pdfinfo.trailerdict);
+ // ...
+ }
+
+ if (fwrite(pdfbuf->str, 1, pdfbuf->len, f) < pdfbuf->len) {
+ fclose(f);
+ g_string_free(pdfbuf, TRUE);
+ return FALSE;
+ }
+ fclose(f);
+ g_string_free(pdfbuf, TRUE);
+ return TRUE;
+}
+
+/*********** Printing via libgnomeprint **********/
+
// does the same job as update_canvas_bg(), but to a print context
void print_background(GnomePrintContext *gpc, struct Page *pg, gboolean *abort)
diff --git a/src/xo-print.h b/src/xo-print.h
index 96ab4be..1ad42d4 100644
--- a/src/xo-print.h
+++ b/src/xo-print.h
@@ -1 +1,51 @@
+typedef struct XrefTable {
+ int *data;
+ int last;
+ int n_alloc;
+} XrefTable;
+
+typedef struct PdfPageDesc {
+ struct PdfObj *resources, *mediabox, *contents;
+ int rotate;
+} PdfPageDesc;
+
+typedef struct PdfInfo {
+ int startxref;
+ struct PdfObj *trailerdict;
+ int npages;
+ struct PdfPageDesc *pages;
+} PdfInfo;
+
+typedef struct PdfObj {
+ int type;
+ int intval;
+ double realval;
+ char *str;
+ int len, num;
+ struct PdfObj **elts;
+ char **names;
+} PdfObj;
+
+#define PDFTYPE_CST 0 // intval: true=1, false=0, null=-1
+#define PDFTYPE_INT 1 // intval
+#define PDFTYPE_REAL 2 // realval
+#define PDFTYPE_STRING 3 // str, len
+#define PDFTYPE_NAME 4 // str
+#define PDFTYPE_ARRAY 5 // num, elts
+#define PDFTYPE_DICT 6 // num, elts, names
+#define PDFTYPE_STREAM 7 // dict: num, elts, names; data: str, len
+#define PDFTYPE_REF 8 // intval, num
+
+struct PdfObj *parse_pdf_object(char **ptr, char *eof);
+void free_pdfobj(struct PdfObj *obj);
+struct PdfObj *dup_pdfobj(struct PdfObj *obj);
+struct PdfObj *get_pdfobj(GString *pdfbuf, struct XrefTable *xref, struct PdfObj *obj);
+void make_xref(struct XrefTable *xref, int nobj, int offset);
+
+gboolean pdf_parse_info(GString *pdfbuf, struct PdfInfo *pdfinfo, struct XrefTable *xref);
+
+// main printing functions
+
+gboolean print_to_pdf(char *filename);
+
void print_job_render(GnomePrintJob *gpj, int fromPage, int toPage);
diff --git a/src/xournal.h b/src/xournal.h
index 236ff33..644fbd8 100644
--- a/src/xournal.h
+++ b/src/xournal.h
@@ -12,7 +12,7 @@
#define PIXEL_MOTION_THRESHOLD 0.3
#define MAX_AXES 12
#define EPSILON 1E-7
-#define MAX_ZOOM 20
+#define MAX_ZOOM 20.0
#define DEFAULT_ZOOM 1.3333333333
#define MIN_ZOOM 0.2
diff --git a/xournal.glade b/xournal.glade
index c73ca4d..af6c0d4 100644
--- a/xournal.glade
+++ b/xournal.glade
@@ -55,7 +55,7 @@
-
+
True
gtk-open
1
@@ -200,7 +200,7 @@
-
+
True
gtk-preferences
1
@@ -225,7 +225,7 @@
@@ -337,7 +337,7 @@
True
Continuous
True
- False
+ True
@@ -410,7 +410,7 @@
-
+
True
gtk-zoom-fit
1
@@ -423,6 +423,15 @@
+
+
+
+
@@ -845,7 +854,7 @@
-
+
True
gtk-open
1
@@ -909,7 +918,7 @@
True
_Pen
True
- False
+ True
@@ -919,7 +928,7 @@
True
_Eraser
True
- False
+ True
toolsPen
@@ -930,7 +939,7 @@
True
_Highlighter
True
- False
+ True
toolsPen
@@ -941,7 +950,7 @@
True
_Text
True
- False
+ True
toolsPen
@@ -958,7 +967,7 @@
True
_Select Region
True
- False
+ True
toolsPen
@@ -969,7 +978,7 @@
True
Select Rectangle
True
- False
+ True
toolsPen
@@ -999,7 +1008,7 @@
True
-
+
True
gtk-select-color
1
@@ -1018,7 +1027,7 @@
True
black
True
- False
+ True
@@ -1028,7 +1037,7 @@
True
blue
True
- False
+ True
colorBlack
@@ -1039,7 +1048,7 @@
True
red
True
- False
+ True
colorBlack
@@ -1050,7 +1059,7 @@
True
green
True
- False
+ True
colorBlack
@@ -1061,7 +1070,7 @@
True
gray
True
- False
+ True
colorBlack
@@ -1078,7 +1087,7 @@
True
light blue
True
- False
+ True
colorBlack
@@ -1089,7 +1098,7 @@
True
light green
True
- False
+ True
colorBlack
@@ -1100,7 +1109,7 @@
True
magenta
True
- False
+ True
colorBlack
@@ -1111,7 +1120,7 @@
True
orange
True
- False
+ True
colorBlack
@@ -1122,7 +1131,7 @@
True
yellow
True
- False
+ True
colorBlack
@@ -1133,7 +1142,7 @@
True
white
True
- False
+ True
colorBlack
@@ -1144,7 +1153,7 @@
True
other...
True
- False
+ True
colorBlack
@@ -1177,7 +1186,7 @@
True
very fine
True
- False
+ True
@@ -1187,7 +1196,7 @@
True
fine
True
- False
+ True
penthicknessVeryFine
@@ -1198,7 +1207,7 @@
True
medium
True
- False
+ True
penthicknessVeryFine
@@ -1209,7 +1218,7 @@
True
thick
True
- False
+ True
penthicknessVeryFine
@@ -1244,7 +1253,7 @@
True
fine
True
- False
+ True
@@ -1254,7 +1263,7 @@
True
medium
True
- False
+ True
eraserFine
@@ -1282,7 +1291,7 @@
True
standard
True
- False
+ True
@@ -1292,7 +1301,7 @@
True
whiteout
True
- False
+ True
eraserStandard
@@ -1327,7 +1336,7 @@
True
fine
True
- False
+ True
@@ -1337,7 +1346,7 @@
True
medium
True
- False
+ True
highlighterFine
@@ -1366,7 +1375,7 @@
-
+
True
gtk-select-font
1
@@ -1503,7 +1512,7 @@
True
Eraser
True
- False
+ True
button2Pen
@@ -1514,7 +1523,7 @@
True
Highlighter
True
- False
+ True
button2Pen
@@ -1525,7 +1534,7 @@
True
Text
True
- False
+ True
button2Pen
@@ -1536,7 +1545,7 @@
True
Select Region
True
- False
+ True
button2Pen
@@ -1547,7 +1556,7 @@
True
Select Rectangle
True
- False
+ True
button2Pen
@@ -1558,7 +1567,7 @@
True
Vertical Space
True
- False
+ True
button2Pen
@@ -1575,7 +1584,7 @@
True
Link to Primary Brush
True
- False
+ True
@@ -1585,7 +1594,7 @@
True
Copy of Current Brush
True
- False
+ True
button2LinkBrush
@@ -1595,7 +1604,7 @@
@@ -1628,7 +1637,7 @@
True
Eraser
True
- False
+ True
button3Pen
@@ -1639,7 +1648,7 @@
True
Highlighter
True
- False
+ True
button3Pen
@@ -1650,7 +1659,7 @@
True
Text
True
- False
+ True
button3Pen
@@ -1661,7 +1670,7 @@
True
Select Region
True
- False
+ True
button3Pen
@@ -1672,7 +1681,7 @@
True
Select Rectangle
True
- False
+ True
button3Pen
@@ -1683,7 +1692,7 @@
True
Vertical Space
True
- False
+ True
button3Pen
@@ -1700,7 +1709,7 @@
True
Link to Primary Brush
True
- False
+ True
@@ -1710,7 +1719,7 @@
True
Copy of Current Brush
True
- False
+ True
button3LinkBrush
@@ -1720,7 +1729,7 @@
@@ -2120,6 +2129,22 @@
+
+
+ True
+ Set Zoom
+ gtk-find
+ True
+ True
+ False
+
+
+
+ False
+ True
+
+
+
True
@@ -3390,4 +3415,240 @@ http://math.mit.edu/~auroux/software/xournal/
+
+ True
+ Set Zoom
+ GTK_WINDOW_TOPLEVEL
+ GTK_WIN_POS_NONE
+ True
+ True
+ False
+ True
+ False
+ False
+ GDK_WINDOW_TYPE_HINT_DIALOG
+ GDK_GRAVITY_NORTH_WEST
+ True
+ True
+
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ GTK_BUTTONBOX_END
+
+
+
+ True
+ True
+ True
+ gtk-cancel
+ True
+ GTK_RELIEF_NORMAL
+ True
+ -6
+
+
+
+
+
+ True
+ True
+ True
+ gtk-apply
+ True
+ GTK_RELIEF_NORMAL
+ True
+ -10
+
+
+
+
+
+ True
+ True
+ True
+ gtk-ok
+ True
+ GTK_RELIEF_NORMAL
+ True
+ -5
+
+
+
+
+ 0
+ False
+ True
+ GTK_PACK_END
+
+
+
+
+
+ 8
+ True
+ False
+ 2
+
+
+
+ True
+ False
+ 0
+
+
+
+ 4
+ True
+ True
+ Zoom:
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ 1
+ 0
+ True
+ GTK_UPDATE_ALWAYS
+ False
+ False
+ 100 10 1500 5 20 20
+
+
+
+ 5
+ False
+ True
+
+
+
+
+
+ True
+ %
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.479999989271
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 0
+ False
+ True
+
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ 4
+ True
+ True
+ Normal size (100%)
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+ radioZoom
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ 4
+ True
+ True
+ Page Width
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+ radioZoom
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ 4
+ True
+ True
+ Page Height
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+ radioZoom
+
+
+
+ 0
+ False
+ False
+
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+