]> git.donarmstrong.com Git - xournal.git/commitdiff
Release 0.3.2.
authorauroux <auroux>
Sat, 25 Nov 2006 17:49:46 +0000 (17:49 +0000)
committerauroux <auroux>
Sat, 25 Nov 2006 17:49:46 +0000 (17:49 +0000)
16 files changed:
ChangeLog
NEWS
README
configure.in
html-doc/manual.html
src/TODO
src/main.c
src/xo-callbacks.c
src/xo-callbacks.h
src/xo-file.c
src/xo-file.h
src/xo-interface.c
src/xo-misc.c
src/xo-print.c
src/xournal.h
xournal.glade

index 058262183a9f1c39ca34a97731a7182bd2ab9b0c..7eb69120786aedabf6c98ac0081b65b0aa16ee3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
-Version ?:
+Version 0.3.2 (Nov 25, 2006):
+  - preferences file and Save Preferences command
+  - extra customization (via preferences file)
   - minor UI changes (patch contributed by Eduardo de Barros Lima)
   - hand tool (partially contributed by Vincenzo Ciancia)
+  - a few bugfixes in rendering of bitmap backgrounds
 
 Version 0.3.1 (Aug 3, 2006):
   - fixed a file format bug on systems with non-standard numeric locale
diff --git a/NEWS b/NEWS
index 59b1c495c05490bf236980d49b8cd07e8de6631e..24c081a97f626b2ac6c616e6c8125641bdc28b05 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Version 0.3.1 (August 3, 2006)
+Version 0.3.2 (November 25, 2006)
 
 Installation:  see INSTALL
 User's manual: see html-doc/manual.html
diff --git a/README b/README
index 59b1c495c05490bf236980d49b8cd07e8de6631e..24c081a97f626b2ac6c616e6c8125641bdc28b05 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Version 0.3.1 (August 3, 2006)
+Version 0.3.2 (November 25, 2006)
 
 Installation:  see INSTALL
 User's manual: see html-doc/manual.html
index fc25bacd06caf2d426d14c53055a86a8c9a5b640..29093ca2fe0e3b842a2820438dcc64fe98c0a673 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(xournal, 0.3.1-CVS)
+AM_INIT_AUTOMAKE(xournal, 0.3.2)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
index fd272309a320a72435815ca825aa5bacfbb86541..7ff525516258f2fc64e45ce36f448f33092156d3 100644 (file)
@@ -24,7 +24,7 @@
   Xournal User's Manual
 </h2>
 <p style="font-size: 0.95em; text-align: center; color: rgb(0,0,0)">
- Version 0.3.1
+ Version 0.3.2
 </p>
 <hr />
 <p>
@@ -53,6 +53,7 @@ Xournal can be downloaded at
   <li> <a href="manual.html#tools">The drawing and selection tools</a> </li>
   <li> <a href="manual.html#pages-layers">Pages, layers, and backgrounds</a> </li>
   <li> <a href="manual.html#printing">Printing</a> </li>
+  <li> <a href="manual.html#configuration">Configuration</a> </li>
   <li> <a href="manual.html#author">Author information, license, bug-reports</a> </li>
   <li> <a href="manual.html#changelog">Version history</a> </li>
   <li> <a href="manual.html#file-format">The file format</a> </li>
@@ -190,6 +191,11 @@ the Tools menu):
   cursor above the top of the page so that the entire block being moved
   becomes invisible results in the items being moved to the previous page.
 </p>
+<h3 class="subsub"><img src="pixmaps/hand.png"> Hand tool</h3>
+<p>
+  This tool lets you browse the journal; dragging the cursor scrolls the
+  view.
+</p>
 <h3 class="subsub">Undo and redo</h3>
 <p>
   All operations performed on the currently open journal (drawing, erasing,
@@ -477,6 +483,29 @@ file, the backgrounds are converted to (compressed) bitmaps and a new
 PDF file is generated from scratch.
 </p>
 <hr />
+<a name="configuration"></a>
+<h2 class="subtitle">Configuration</h2>
+<p>
+Starting with version 0.3.2, Xournal's configuration settings can be
+saved to a file (<tt>~user/.xournal/config</tt>) by using the "Save
+Preferences" command in the Options menu. The settings saved in the
+configuration file include in particular:
+<ul>
+<li>general display preferences: zoom level, window size, ...</li>
+<li>default paper settings (as set by the "Set As Default" command in
+the Journal menu)</li>
+<li>default tool settings for the pen, eraser, and highlighter
+(as set by the "Set As Default" command in the Tools menu)</li>
+<li>mappings for buttons 2 and 3</li>
+<li>the various preferences set in the Options menu</li>
+</ul>
+The configuration file also gives access to additional customization
+options which cannot be set from the user interface, such as: the
+display resolution in pixels per inch, the step increment in zoom factors,
+the tool selected at startup, the thickness of the various drawing tools,
+...
+</p>
+<hr />
 <a name="author"></a>
 <h2 class="subtitle">Author information, license, bug-reports</h2>
 <p>
@@ -499,6 +528,15 @@ Bug reports and suggestions can also be submitted on Xournal's
 <a name="changelog"></a>
 <h2 class="subtitle">Version history</h2>
 <p>
+Version 0.3.2 (November 25, 2006):
+<ul>
+ <li>preferences file and Save Preferences command</li>
+ <li>extra customization (via preferences file)</li>
+ <li>minor UI changes (patch contributed by Eduardo de Barros Lima)</li>
+ <li>hand tool (partially contributed by Vincenzo Ciancia)</li>
+ <li>a few bugfixes in rendering of bitmap backgrounds</li>
+</ul>
+<p>
 Version 0.3.1 (August 3, 2006):
 <ul>
  <li>fixed a file format bug on systems with non-standard numeric locale
@@ -569,14 +607,6 @@ Version 0.1.1 (January 5, 2006):
 <p>
 Version 0.1 (January 2, 2006): initial release.
 </p>
-<p>
-Features yet to be implemented:
-<ul>
- <li>freeform selection tool</li>
- <li>preferences file; persistent printer settings</li>
- <li>various functionalities (flatten layers, ...)</li>
-</ul>
-</p>
 <hr />
 <a name="file-format"></a>
 <h2 class="subtitle">The file format</h2>
@@ -892,19 +922,20 @@ Do not add a list of xsetwacom commands to your startup files).
 </p>
 <h3 class="subsub">Strokes aren't drawn under the cursor...</h3>
 <p>
-This is due to misfeatures in the linuxwacom driver. Typically, this
-will happen in all of the following cases:
+This is due to misfeatures in the linuxwacom driver in versions prior
+to 0.7.6. Typically, this will happen in all of the following cases:
 <ul>
 <li> the calibration settings have been changed after the X server was
 started (using xsetwacom) </li>
 <li> the calibration TopX or TopY values are not 0 </li>
 <li> the display has been rotated </li>
 </ul>
-Future versions of the driver may fix these issues. Meanwhile, you can
+Most of these issues should have been fixed in version 0.7.6 of the
+wacom driver. Otherwise, you can
 either disable XInput support in Xournal (in the Options menu), at a
 price of a severe loss of resolution (and the eraser tip won't be detected
 anymore), or apply this <a href="manual.html#wacompatch">patch</a>
-to the wacom driver.
+to version 0.7.0 of the wacom driver.
 </p>
 <p>
 I have also had a report that one of the workarounds used by Xournal to
@@ -920,8 +951,8 @@ contact me.
 <h3 class="subsub">On-the-fly display rotation</h3>
 <p> 
 You need an X server that supports the RANDR extension, and a
-<a href="manual.html#wacompatch">patched</a> version of the linuxwacom
-driver to support on-the-fly rotation.
+recent (0.7.6 or later) or <a href="manual.html#wacompatch">patched</a> 
+version of the linuxwacom driver to support on-the-fly rotation.
 </p>
 <p>
 To set the tablet in portrait mode:
@@ -951,6 +982,8 @@ distribution).</li>
 <li>The <a href="http://math.mit.edu/~auroux/software/xournal/linuxwacom-rotate-patch.tar.gz">patched
 binaries</a> for the X.org X server.</li>
 </ul>
+This patch has been included in version 0.7.6 of the linuxwacom driver,
+and should now be obsolete.
 </p>
 </body>
 </html>
index c41a6a4e483faf551cfae6dd631e8f8115e0fc18..9baaeaa22f147f0ddb47d12a7e77195ac3a98907 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -1,9 +1,11 @@
 List of features to be implemented (not in any particular order)
 ----------------------------------------------------------------
-
+- xoj2pdf on command line
+- load images as bg if given on command-line (as with PDF on commandline)
+- load PDF pages only on demand (create empty pixmaps at first if can
+   parse PDF geometry ourselves, else try pdfinfo ??)
 - de-map space key from button bar
 - lasso selection tool
-- prefs file, save prefs
 - flatten (incl undo/redo...) - enabled only if nlayers>1
 - resize selection
 - text tool, font chooser, default font
@@ -19,5 +21,8 @@ List of features to be implemented (not in any particular order)
 - recalibration upon screen resize / compensation for miscalibration
 - find a better behavior for vertical space tool across page boundaries ?
 - key mappings (pgup/dn for full page, up/dn for scroll)
-- zoom increments more flexible (1% instead of 5% ?)
 - copy/paste of an entire page (beware if PDF bg is not compatible!)
+- simple drawing tools: rectangles, ellipses
+- option to save all annotated files within the .xoj
+- non-antialiased version for handhelds
+- customize autogenerated save file names 
index 188d1ea352aca86b277c10ac075b6f2a6be4a5c5..05693868fb5db9ed6493b456eea3d1ec32e84771 100644 (file)
@@ -26,6 +26,8 @@ struct BgPdf bgpdf;  // the PDF loader stuff
 struct UIData ui;   // the user interface data
 struct UndoItem *undo, *redo; // the undo and redo stacks
 
+double DEFAULT_ZOOM;
+
 void hide_unimplemented(void)
 {
   gtk_widget_hide(GET_COMPONENT("filePrintOptions"));
@@ -42,7 +44,6 @@ void hide_unimplemented(void)
   gtk_widget_hide(GET_COMPONENT("colorOther"));
   gtk_widget_hide(GET_COMPONENT("toolsTextFont"));
   gtk_widget_hide(GET_COMPONENT("toolsDefaultText"));
-  gtk_widget_hide(GET_COMPONENT("optionsSavePreferences"));
   gtk_widget_hide(GET_COMPONENT("helpIndex"));
 }
 
@@ -57,32 +58,25 @@ void init_stuff (int argc, char *argv[])
   gboolean can_xinput, success;
   gchar *tmppath, *tmpfn;
 
-  // we need an empty canvas prior to creating the journal structures
-  canvas = GNOME_CANVAS (gnome_canvas_new_aa ());
+  // create some data structures needed to populate the preferences
+  ui.default_page.bg = g_new(struct Background, 1);
 
   // initialize config file names
   tmppath = g_build_filename(g_get_home_dir(), CONFIG_DIR, NULL);
-  g_mkdir(tmppath, 0700); // safer (MRU data may be confidential)
+  mkdir(tmppath, 0700); // safer (MRU data may be confidential)
   ui.mrufile = g_build_filename(tmppath, MRU_FILE, NULL);
+  ui.configfile = g_build_filename(tmppath, CONFIG_FILE, NULL);
   g_free(tmppath);
 
-  // initialize data
-  // TODO: load this from a preferences file
+  // initialize preferences
+  init_config_default();
+  load_config_from_file();
 
-  ui.default_page.height = 792.0;
-  ui.default_page.width = 612.0;
-  ui.default_page.bg = g_new(struct Background, 1);
-  ui.default_page.bg->type = BG_SOLID;
-  ui.default_page.bg->color_no = COLOR_WHITE;
-  ui.default_page.bg->color_rgba = predef_bgcolors_rgba[COLOR_WHITE];
-  ui.default_page.bg->ruling = RULING_LINED;
+  // we need an empty canvas prior to creating the journal structures
+  canvas = GNOME_CANVAS (gnome_canvas_new_aa ());
+
+  // initialize data
   ui.default_page.bg->canvas_item = NULL;
-  
-  ui.zoom = DEFAULT_ZOOM;
-  ui.view_continuous = TRUE;
-  ui.fullscreen = FALSE;
-  
-  ui.allow_xinput = TRUE;
   ui.layerbox_length = 0;
 
   if (argc > 2 || (argc == 2 && argv[1][0] == '-')) {
@@ -105,40 +99,42 @@ void init_stuff (int argc, char *argv[])
 
   ui.selection = NULL;
   ui.cursor = NULL;
-  ui.bg_apply_all_pages = FALSE;
-
-  ui.cur_brush = &(ui.brushes[0][TOOL_PEN]);
-  ui.toolno[0] = TOOL_PEN;
-  for (i=1; i<=NUM_BUTTONS; i++) ui.toolno[i] = TOOL_ERASER;
-  for (i=0; i<=NUM_BUTTONS; i++) {
-    ui.ruler[i] = FALSE;
-    ui.linked_brush[i] = BRUSH_LINKED;
-  }
-  ui.brushes[0][TOOL_PEN].color_no = COLOR_BLACK;
-  ui.brushes[0][TOOL_ERASER].color_no = COLOR_WHITE;
-  ui.brushes[0][TOOL_HIGHLIGHTER].color_no = COLOR_YELLOW;
-  for (i=0; i < NUM_STROKE_TOOLS; i++) {
-    b = &(ui.brushes[0][i]);
-    b->tool_type = i;
-    b->color_rgba = predef_colors_rgba[b->color_no];
-    if (i == TOOL_HIGHLIGHTER) {
-      b->color_rgba &= HILITER_ALPHA_MASK;
+
+  ui.cur_brush = &(ui.brushes[0][ui.toolno[0]]);
+  for (j=0; j<=NUM_BUTTONS; j++)
+    for (i=0; i < NUM_STROKE_TOOLS; i++) {
+      b = &(ui.brushes[j][i]);
+      b->tool_type = i;
+      b->color_rgba = predef_colors_rgba[b->color_no];
+      if (i == TOOL_HIGHLIGHTER) {
+        b->color_rgba &= HILITER_ALPHA_MASK;
+      }
+      b->thickness = predef_thickness[i][b->thickness_no];
     }
-    b->thickness_no = THICKNESS_MEDIUM;
-    b->thickness = predef_thickness[i][b->thickness_no];
-    b->tool_options = 0;
-    g_memmove(ui.default_brushes+i, b, sizeof(struct Brush));
-    for (j=1; j<=NUM_BUTTONS; j++) 
-      g_memmove(&(ui.brushes[j][i]), b, sizeof(struct Brush));
-  }
+  for (i=0; i<NUM_STROKE_TOOLS; i++)
+    g_memmove(ui.default_brushes+i, &(ui.brushes[0][i]), sizeof(struct Brush));
+
   ui.cur_mapping = 0;
-  ui.use_erasertip = FALSE;
 
   // initialize various interface elements
   
-  gtk_window_set_default_size(GTK_WINDOW (winMain), 720, 480);
+  gtk_window_set_default_size(GTK_WINDOW (winMain), ui.window_default_width, ui.window_default_height);
+  if (ui.maximize_at_start) gtk_window_maximize(GTK_WINDOW (winMain));
   update_toolbar_and_menu();
 
+  gtk_check_menu_item_set_active(
+    GTK_CHECK_MENU_ITEM(GET_COMPONENT("journalApplyAllPages")), ui.bg_apply_all_pages);
+  if (ui.fullscreen) {
+    gtk_check_menu_item_set_active(
+      GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), TRUE);
+    gtk_toggle_tool_button_set_active(
+      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), TRUE);
+    gtk_window_fullscreen(GTK_WINDOW(winMain));
+    gtk_widget_hide(GET_COMPONENT("menubar"));
+    gtk_widget_hide(GET_COMPONENT("hbox1"));
+  }
+
+
   // set up and initialize the canvas
 
   gtk_widget_show (GTK_WIDGET (canvas));
@@ -149,8 +145,8 @@ void init_stuff (int argc, char *argv[])
   gtk_widget_set_extension_events(GTK_WIDGET (canvas), GDK_EXTENSION_EVENTS_ALL);
   gnome_canvas_set_pixels_per_unit (canvas, ui.zoom);
   gnome_canvas_set_center_scroll_region (canvas, TRUE);
-  gtk_layout_get_hadjustment(GTK_LAYOUT (canvas))->step_increment = 30;
-  gtk_layout_get_vadjustment(GTK_LAYOUT (canvas))->step_increment = 30;
+  gtk_layout_get_hadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment;
+  gtk_layout_get_vadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment;
 
   // set up the page size and canvas size
   update_page_stuff();
@@ -202,8 +198,6 @@ void init_stuff (int argc, char *argv[])
     gtk_widget_set_sensitive(GET_COMPONENT("optionsUseXInput"), FALSE);
 
   ui.use_xinput = ui.allow_xinput && can_xinput;
-  ui.antialias_bg = TRUE;
-  ui.progressive_bg = TRUE;
 
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsUseXInput")), ui.use_xinput);
@@ -211,8 +205,15 @@ void init_stuff (int argc, char *argv[])
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAntialiasBG")), ui.antialias_bg);
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsProgressiveBG")), ui.progressive_bg);
+  gtk_check_menu_item_set_active(
+    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPrintRuling")), ui.print_ruling);
 
   hide_unimplemented();
+  
+  /* config file only works with glib 2.6 */
+  if (glib_minor_version<6) {
+    gtk_widget_hide(GET_COMPONENT("optionsSavePreferences"));
+  }
     
   update_undo_redo_enabled();
   update_copy_paste_enabled();
index 4980035cd66b4ffd21e227d1a478aac8d036d307..a11ce65390f4f2da300b755d285abbbab99f99d7 100644 (file)
@@ -889,7 +889,7 @@ on_viewZoomIn_activate                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
   if (ui.zoom > MAX_ZOOM) return;
-  ui.zoom *= 1.5;
+  ui.zoom *= ui.zoom_step_factor;
   gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
   rescale_bg_pixmaps();
 }
@@ -900,7 +900,7 @@ on_viewZoomOut_activate                (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
   if (ui.zoom < MIN_ZOOM) return;
-  ui.zoom /= 1.5;
+  ui.zoom /= ui.zoom_step_factor;
   gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
   rescale_bg_pixmaps();
 }
@@ -1178,12 +1178,7 @@ gboolean papersize_need_init, papersize_width_valid, papersize_height_valid;
 #define STD_SIZE_LETTER_R 3
 #define STD_SIZE_CUSTOM 4
 
-#define UNIT_CM 0
-#define UNIT_IN 1
-#define UNIT_PX 2
-#define UNIT_PT 3
-
-double unit_sizes[4] = {28.346, 72., 1/DEFAULT_ZOOM, 1.};
+double unit_sizes[4] = {28.346, 72., 72./DISPLAY_DPI_DEFAULT, 1.};
 double std_widths[STD_SIZE_CUSTOM] =  {595.27, 841.89, 612., 792.};
 double std_heights[STD_SIZE_CUSTOM] = {841.89, 595.27, 792., 612.};
 double std_units[STD_SIZE_CUSTOM] = {UNIT_CM, UNIT_CM, UNIT_IN, UNIT_IN};
@@ -1199,7 +1194,8 @@ on_journalPaperSize_activate           (GtkMenuItem     *menuitem,
   papersize_dialog = create_papersizeDialog();
   papersize_width = ui.cur_page->width;
   papersize_height = ui.cur_page->height;
-  papersize_unit = UNIT_CM;
+  papersize_unit = ui.default_unit;
+  unit_sizes[UNIT_PX] = 1./DEFAULT_ZOOM;
 //  if (ui.cur_page->bg->type == BG_PIXMAP) papersize_unit = UNIT_PX;
   papersize_std = STD_SIZE_CUSTOM;
   for (i=0;i<STD_SIZE_CUSTOM;i++)
@@ -2009,7 +2005,7 @@ void
 on_optionsSavePreferences_activate     (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-
+  save_config_to_file();
 }
 
 
@@ -2413,22 +2409,34 @@ void
 on_journalDefaultBackground_activate   (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
+  struct Page *pg;
+  GList *pglist;
+  
   reset_selection();
-  prepare_new_undo();
-  undo->type = ITEM_NEW_BG_RESIZE;
-  undo->page = ui.cur_page;
-  undo->bg = ui.cur_page->bg;
-  undo->val_x = ui.cur_page->width;
-  undo->val_y = ui.cur_page->height; 
   
-  ui.cur_page->bg = (struct Background *)g_memdup(ui.default_page.bg, sizeof(struct Background));
-  ui.cur_page->width = ui.default_page.width;
-  ui.cur_page->height = ui.default_page.height;
-  ui.cur_page->bg->canvas_item = undo->bg->canvas_item;
-  undo->bg->canvas_item = NULL;
+  pg = ui.cur_page;
+  for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) {
+    if (ui.bg_apply_all_pages) pg = (struct Page *)pglist->data;
+    prepare_new_undo();
+    if (ui.bg_apply_all_pages) {
+      if (pglist->next!=NULL) undo->multiop |= MULTIOP_CONT_REDO;
+      if (pglist->prev!=NULL) undo->multiop |= MULTIOP_CONT_UNDO;
+    }
+    undo->type = ITEM_NEW_BG_RESIZE;
+    undo->page = pg;
+    undo->bg = pg->bg;
+    undo->val_x = pg->width;
+    undo->val_y = pg->height; 
+    pg->bg = (struct Background *)g_memdup(ui.default_page.bg, sizeof(struct Background));
+    pg->width = ui.default_page.width;
+    pg->height = ui.default_page.height;
+    pg->bg->canvas_item = undo->bg->canvas_item;
+    undo->bg->canvas_item = NULL;
   
-  make_page_clipbox(ui.cur_page);
-  update_canvas_bg(ui.cur_page);
+    make_page_clipbox(pg);
+    update_canvas_bg(pg);
+    if (!ui.bg_apply_all_pages) break;
+  }
   do_switch_page(ui.pageno, TRUE, TRUE);
 }
 
@@ -2838,11 +2846,13 @@ on_viewSetZoom_activate                (GtkMenuItem     *menuitem,
 {
   int response;
   double test_w, test_h;
+  GtkSpinButton *spinZoom;
   
   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);
+  spinZoom = GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(zoom_dialog), "spinZoom"));
+  gtk_spin_button_set_increments(spinZoom, ui.zoom_step_increment, 5*ui.zoom_step_increment);
+  gtk_spin_button_set_value(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) 
@@ -2971,3 +2981,11 @@ on_button3Hand_activate                (GtkMenuItem     *menuitem,
   process_mapping_activate(menuitem, 2, TOOL_HAND);
 }
 
+
+void
+on_optionsPrintRuling_activate         (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  ui.print_ruling = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem));
+}
+
index 8513ec8d33d89739821ba0d990e89ac9e1f9e006..0b67562c6b89cdb8b174aced1735f1d6882fb1cc 100644 (file)
@@ -592,3 +592,7 @@ on_button2Hand_activate                (GtkMenuItem     *menuitem,
 void
 on_button3Hand_activate                (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
+
+void
+on_optionsPrintRuling_activate         (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
index a241df396e81d7f4819d473c2bfd507fc7d7a05b..bff53a1a206caf18dc2b979dd3923c8f914921dd 100644 (file)
@@ -22,7 +22,7 @@
 #include "xo-misc.h"
 #include "xo-file.h"
 
-const char *tool_names[NUM_STROKE_TOOLS] = {"pen", "eraser", "highlighter"};
+const char *tool_names[NUM_TOOLS] = {"pen", "eraser", "highlighter", "", "", "selectrect", "vertspace", "hand"};
 const char *color_names[COLOR_MAX] = {"black", "blue", "red", "green",
    "gray", "lightblue", "lightgreen", "magenta", "orange", "yellow", "white"};
 const char *bgtype_names[3] = {"solid", "pixmap", "pdf"};
@@ -30,6 +30,8 @@ const char *bgcolor_names[COLOR_MAX] = {"", "blue", "pink", "green",
    "", "", "", "", "orange", "yellow", "white"};
 const char *bgstyle_names[4] = {"plain", "lined", "ruled", "graph"};
 const char *file_domain_names[3] = {"absolute", "attach", "clone"};
+const char *unit_names[4] = {"cm", "in", "px", "pt"};
+int PDFTOPPM_PRINTING_DPI, GS_BITMAP_DPI;
 
 // creates a new empty journal
 
@@ -1214,3 +1216,435 @@ void save_mru_list(void)
     if (ui.mru[i]!=NULL) fprintf(f, "%s\n", ui.mru[i]);
   fclose(f);
 }
+
+void init_config_default(void)
+{
+  int i, j;
+
+  DEFAULT_ZOOM = DISPLAY_DPI_DEFAULT/72.0;
+  ui.zoom = 1.0*DEFAULT_ZOOM;
+  ui.default_page.height = 792.0;
+  ui.default_page.width = 612.0;
+  ui.default_page.bg->type = BG_SOLID;
+  ui.default_page.bg->color_no = COLOR_WHITE;
+  ui.default_page.bg->color_rgba = predef_bgcolors_rgba[COLOR_WHITE];
+  ui.default_page.bg->ruling = RULING_LINED;
+  ui.view_continuous = TRUE;
+  ui.allow_xinput = TRUE;
+  ui.bg_apply_all_pages = FALSE;
+  ui.use_erasertip = FALSE;
+  ui.window_default_width = 720;
+  ui.window_default_height = 480;
+  ui.maximize_at_start = FALSE;
+  ui.fullscreen = FALSE;
+  ui.scrollbar_step_increment = 30;
+  ui.zoom_step_increment = 1;
+  ui.zoom_step_factor = 1.5;
+  ui.antialias_bg = TRUE;
+  ui.progressive_bg = TRUE;
+  ui.print_ruling = TRUE;
+  ui.default_unit = UNIT_CM;
+
+  ui.toolno[0] = ui.startuptool = TOOL_PEN;
+  ui.ruler[0] = ui.startupruler = FALSE;
+  for (i=1; i<=NUM_BUTTONS; i++) {
+    ui.toolno[i] = TOOL_ERASER;
+    ui.ruler[i] = FALSE;
+  }
+  for (i=0; i<=NUM_BUTTONS; i++)
+    ui.linked_brush[i] = BRUSH_LINKED;
+  ui.brushes[0][TOOL_PEN].color_no = COLOR_BLACK;
+  ui.brushes[0][TOOL_ERASER].color_no = COLOR_WHITE;
+  ui.brushes[0][TOOL_HIGHLIGHTER].color_no = COLOR_YELLOW;
+  for (i=0; i < NUM_STROKE_TOOLS; i++) {
+    ui.brushes[0][i].thickness_no = THICKNESS_MEDIUM;
+    ui.brushes[0][i].tool_options = 0;
+  }
+  for (i=0; i< NUM_STROKE_TOOLS; i++)
+    for (j=1; j<=NUM_BUTTONS; j++)
+      g_memmove(&(ui.brushes[j][i]), &(ui.brushes[0][i]), sizeof(struct Brush));
+
+  // predef_thickness is already initialized as a global variable
+
+  GS_BITMAP_DPI = 144;
+  PDFTOPPM_PRINTING_DPI = 150;
+}
+
+#if GLIB_CHECK_VERSION(2,6,0)
+
+void update_keyval(const gchar *group_name, const gchar *key,
+                const gchar *comment, gchar *value)
+{
+  gboolean has_it = g_key_file_has_key(ui.config_data, group_name, key, NULL);
+  cleanup_numeric(value);
+  g_key_file_set_value(ui.config_data, group_name, key, value);
+  g_free(value);
+  if (!has_it) g_key_file_set_comment(ui.config_data, group_name, key, comment, NULL);
+}
+
+#endif
+
+void save_config_to_file(void)
+{
+  gchar *buf;
+  FILE *f;
+
+#if GLIB_CHECK_VERSION(2,6,0)
+  // no support for keyval files before Glib 2.6.0
+  if (glib_minor_version<6) return; 
+
+  // save some data...
+  ui.maximize_at_start = (gdk_window_get_state(winMain->window) & GDK_WINDOW_STATE_MAXIMIZED);
+  if (!ui.maximize_at_start && !ui.fullscreen)
+    gdk_drawable_get_size(winMain->window, 
+      &ui.window_default_width, &ui.window_default_height);
+
+  update_keyval("general", "display_dpi",
+    " the display resolution, in pixels per inch",
+    g_strdup_printf("%.2f", DEFAULT_ZOOM*72));
+  update_keyval("general", "initial_zoom",
+    " the initial zoom level, in percent",
+    g_strdup_printf("%.2f", 100*ui.zoom/DEFAULT_ZOOM));
+  update_keyval("general", "window_maximize",
+    " maximize the window at startup (true/false)",
+    g_strdup(ui.maximize_at_start?"true":"false"));
+  update_keyval("general", "window_fullscreen",
+    " start in full screen mode (true/false)",
+    g_strdup(ui.fullscreen?"true":"false"));
+  update_keyval("general", "window_width",
+    " the window width in pixels (when not maximized)",
+    g_strdup_printf("%d", ui.window_default_width));
+  update_keyval("general", "window_height",
+    " the window height in pixels",
+    g_strdup_printf("%d", ui.window_default_height));
+  update_keyval("general", "scrollbar_speed",
+    " scrollbar step increment (in pixels)",
+    g_strdup_printf("%d", ui.scrollbar_step_increment));
+  update_keyval("general", "zoom_dialog_increment",
+    " the step increment in the zoom dialog box",
+    g_strdup_printf("%d", ui.zoom_step_increment));
+  update_keyval("general", "zoom_step_factor",
+    " the multiplicative factor for zoom in/out",
+    g_strdup_printf("%.3f", ui.zoom_step_factor));
+  update_keyval("general", "view_continuous",
+    " document view (true = continuous, false = single page)",
+    g_strdup(ui.view_continuous?"true":"false"));
+  update_keyval("general", "use_xinput",
+    " use XInput extensions (true/false)",
+    g_strdup(ui.allow_xinput?"true":"false"));
+  update_keyval("general", "use_erasertip",
+    " always map eraser tip to eraser (true/false)",
+    g_strdup(ui.use_erasertip?"true":"false"));
+
+  update_keyval("paper", "width",
+    " the default page width, in points (1/72 in)",
+    g_strdup_printf("%.2f", ui.default_page.width));
+  update_keyval("paper", "height",
+    " the default page height, in points (1/72 in)",
+    g_strdup_printf("%.2f", ui.default_page.height));
+  update_keyval("paper", "color",
+    " the default paper color",
+    g_strdup(bgcolor_names[ui.default_page.bg->color_no]));
+  update_keyval("paper", "style",
+    " the default paper style (plain, lined, ruled, or graph)",
+    g_strdup(bgstyle_names[ui.default_page.bg->ruling]));
+  update_keyval("paper", "apply_all",
+    " apply paper style changes to all pages (true/false)",
+    g_strdup(ui.bg_apply_all_pages?"true":"false"));
+  update_keyval("paper", "default_unit",
+    " preferred unit (cm, in, px, pt)",
+    g_strdup(unit_names[ui.default_unit]));
+  update_keyval("paper", "print_ruling",
+    " include paper ruling when printing or exporting to PDF (true/false)",
+    g_strdup(ui.print_ruling?"true":"false"));
+  update_keyval("paper", "antialias_bg",
+    " antialiased bitmap backgrounds (true/false)",
+    g_strdup(ui.antialias_bg?"true":"false"));
+  update_keyval("paper", "progressive_bg",
+    " progressive scaling of bitmap backgrounds (true/false)",
+    g_strdup(ui.progressive_bg?"true":"false"));
+  update_keyval("paper", "gs_bitmap_dpi",
+    " bitmap resolution of PS/PDF backgrounds rendered using ghostscript (dpi)",
+    g_strdup_printf("%d", GS_BITMAP_DPI));
+  update_keyval("paper", "pdftoppm_printing_dpi",
+    " bitmap resolution of PDF backgrounds when printing with libgnomeprint (dpi)",
+    g_strdup_printf("%d", PDFTOPPM_PRINTING_DPI));
+
+  update_keyval("tools", "startup_tool",
+    " selected tool at startup (pen, eraser, highlighter, selectrect, vertspace, hand)",
+    g_strdup(tool_names[ui.startuptool]));
+  update_keyval("tools", "startup_ruler",
+    " ruler mode at startup (true/false) (for pen or highlighter only)",
+    g_strdup(ui.startupruler?"true":"false"));
+  update_keyval("tools", "pen_color",
+    " default pen color",
+    g_strdup(color_names[ui.default_brushes[TOOL_PEN].color_no]));
+  update_keyval("tools", "pen_thickness",
+    " default pen thickness (fine = 1, medium = 2, thick = 3)",
+    g_strdup_printf("%d", ui.default_brushes[TOOL_PEN].thickness_no));
+  update_keyval("tools", "eraser_thickness",
+    " default eraser thickness (fine = 1, medium = 2, thick = 3)",
+    g_strdup_printf("%d", ui.default_brushes[TOOL_ERASER].thickness_no));
+  update_keyval("tools", "eraser_mode",
+    " default eraser mode (standard = 0, whiteout = 1, strokes = 2)",
+    g_strdup_printf("%d", ui.default_brushes[TOOL_ERASER].tool_options));
+  update_keyval("tools", "highlighter_color",
+    " default highlighter color",
+    g_strdup(color_names[ui.default_brushes[TOOL_HIGHLIGHTER].color_no]));
+  update_keyval("tools", "highlighter_thickness",
+    " default highlighter thickness (fine = 1, medium = 2, thick = 3)",
+    g_strdup_printf("%d", ui.default_brushes[TOOL_HIGHLIGHTER].thickness_no));
+  update_keyval("tools", "btn2_tool",
+    " button 2 tool (pen, eraser, highlighter, selectrect, vertspace, hand)",
+    g_strdup(tool_names[ui.toolno[1]]));
+  update_keyval("tools", "btn2_linked",
+    " button 2 brush linked to primary brush (true/false) (overrides all other settings)",
+    g_strdup((ui.linked_brush[1]==BRUSH_LINKED)?"true":"false"));
+  update_keyval("tools", "btn2_ruler",
+    " button 2 ruler mode (true/false) (for pen or highlighter only)",
+    g_strdup(ui.ruler[1]?"true":"false"));
+  update_keyval("tools", "btn2_color",
+    " button 2 brush color (for pen or highlighter only)",
+    g_strdup((ui.toolno[1]<NUM_STROKE_TOOLS)?
+               color_names[ui.brushes[1][ui.toolno[1]].color_no]:"white"));
+  update_keyval("tools", "btn2_thickness",
+    " button 2 brush thickness (pen, eraser, or highlighter only)",
+    g_strdup_printf("%d", (ui.toolno[1]<NUM_STROKE_TOOLS)?
+                            ui.brushes[1][ui.toolno[1]].thickness_no:0));
+  update_keyval("tools", "btn2_erasermode",
+    " button 2 eraser mode (eraser only)",
+    g_strdup_printf("%d", ui.brushes[1][TOOL_ERASER].tool_options));
+  update_keyval("tools", "btn3_tool",
+    " button 3 tool (pen, eraser, highlighter, selectrect, vertspace, hand)",
+    g_strdup(tool_names[ui.toolno[2]]));
+  update_keyval("tools", "btn3_linked",
+    " button 3 brush linked to primary brush (true/false) (overrides all other settings)",
+    g_strdup((ui.linked_brush[2]==BRUSH_LINKED)?"true":"false"));
+  update_keyval("tools", "btn3_ruler",
+    " button 3 ruler mode (true/false) (for pen or highlighter only)",
+    g_strdup(ui.ruler[2]?"true":"false"));
+  update_keyval("tools", "btn3_color",
+    " button 3 brush color (for pen or highlighter only)",
+    g_strdup((ui.toolno[2]<NUM_STROKE_TOOLS)?
+               color_names[ui.brushes[2][ui.toolno[2]].color_no]:"white"));
+  update_keyval("tools", "btn3_thickness",
+    " button 3 brush thickness (pen, eraser, or highlighter only)",
+    g_strdup_printf("%d", (ui.toolno[2]<NUM_STROKE_TOOLS)?
+                            ui.brushes[2][ui.toolno[2]].thickness_no:0));
+  update_keyval("tools", "btn3_erasermode",
+    " button 3 eraser mode (eraser only)",
+    g_strdup_printf("%d", ui.brushes[2][TOOL_ERASER].tool_options));
+
+  update_keyval("tools", "pen_thicknesses",
+    " thickness of the various pens (in points, 1 pt = 1/72 in)",
+    g_strdup_printf("%.2f;%.2f;%.2f;%.2f;%.2f", 
+      predef_thickness[TOOL_PEN][0], predef_thickness[TOOL_PEN][1],
+      predef_thickness[TOOL_PEN][2], predef_thickness[TOOL_PEN][3],
+      predef_thickness[TOOL_PEN][4]));
+  update_keyval("tools", "eraser_thicknesses",
+    " thickness of the various erasers (in points, 1 pt = 1/72 in)",
+    g_strdup_printf("%.2f;%.2f;%.2f", 
+      predef_thickness[TOOL_ERASER][1], predef_thickness[TOOL_ERASER][2],
+      predef_thickness[TOOL_ERASER][3]));
+  update_keyval("tools", "highlighter_thicknesses",
+    " thickness of the various highlighters (in points, 1 pt = 1/72 in)",
+    g_strdup_printf("%.2f;%.2f;%.2f", 
+      predef_thickness[TOOL_HIGHLIGHTER][1], predef_thickness[TOOL_HIGHLIGHTER][2],
+      predef_thickness[TOOL_HIGHLIGHTER][3]));
+  // set comments for keys / groups that don't exist
+  // set keyvals to current options
+
+  buf = g_key_file_to_data(ui.config_data, NULL, NULL);
+  if (buf == NULL) return;
+  f = fopen(ui.configfile, "w");
+  if (f==NULL) { g_free(buf); return; }
+  fputs(buf, f);
+  fclose(f);
+  g_free(buf);
+#endif
+}
+
+#if GLIB_CHECK_VERSION(2,6,0)
+gboolean parse_keyval_float(const gchar *group, const gchar *key, double *val, double inf, double sup)
+{
+  gchar *ret, *end;
+  double conv;
+  
+  ret = g_key_file_get_value(ui.config_data, group, key, NULL);
+  if (ret==NULL) return FALSE;
+  conv = g_ascii_strtod(ret, &end);
+  if (*end!=0) { g_free(ret); return FALSE; }
+  g_free(ret);
+  if (conv < inf || conv > sup) return FALSE;
+  *val = conv;
+  return TRUE;
+}
+
+gboolean parse_keyval_floatlist(const gchar *group, const gchar *key, double *val, int n, double inf, double sup)
+{
+  gchar *ret, *end;
+  double conv[5];
+  int i;
+
+  if (n>5) return FALSE;
+  ret = g_key_file_get_value(ui.config_data, group, key, NULL);
+  if (ret==NULL) return FALSE;
+  end = ret;
+  for (i=0; i<n; i++) {
+    conv[i] = g_ascii_strtod(end, &end);
+    if ((i==n-1 && *end!=0) || (i<n-1 && *end!=';') ||
+        (conv[i] < inf) || (conv[i] > sup)) { g_free(ret); return FALSE; }
+    end++;
+  }
+  g_free(ret);
+  for (i=0; i<n; i++) val[i] = conv[i];
+  return TRUE;
+}
+
+gboolean parse_keyval_int(const gchar *group, const gchar *key, int *val, int inf, int sup)
+{
+  gchar *ret, *end;
+  int conv;
+  
+  ret = g_key_file_get_value(ui.config_data, group, key, NULL);
+  if (ret==NULL) return FALSE;
+  conv = strtol(ret, &end, 10);
+  if (*end!=0) { g_free(ret); return FALSE; }
+  g_free(ret);
+  if (conv < inf || conv > sup) return FALSE;
+  *val = conv;
+  return TRUE;
+}
+
+gboolean parse_keyval_enum(const gchar *group, const gchar *key, int *val, const char **names, int n)
+{
+  gchar *ret;
+  int i;
+  
+  ret = g_key_file_get_value(ui.config_data, group, key, NULL);
+  if (ret==NULL) return FALSE;
+  for (i=0; i<n; i++) {
+    if (!names[i][0]) continue; // "" is for invalid values
+    if (!g_ascii_strcasecmp(ret, names[i]))
+      { *val = i; g_free(ret); return TRUE; }
+  }
+  return FALSE;
+}
+
+gboolean parse_keyval_boolean(const gchar *group, const gchar *key, gboolean *val)
+{
+  gchar *ret;
+  
+  ret = g_key_file_get_value(ui.config_data, group, key, NULL);
+  if (ret==NULL) return FALSE;
+  if (!g_ascii_strcasecmp(ret, "true")) 
+    { *val = TRUE; g_free(ret); return TRUE; }
+  if (!g_ascii_strcasecmp(ret, "false")) 
+    { *val = FALSE; g_free(ret); return TRUE; }
+  g_free(ret);
+  return FALSE;
+}
+
+#endif
+
+void load_config_from_file(void)
+{
+  double f;
+  gboolean b;
+  int i, j;
+  
+#if GLIB_CHECK_VERSION(2,6,0)
+  // no support for keyval files before Glib 2.6.0
+  if (glib_minor_version<6) return; 
+  ui.config_data = g_key_file_new();
+  if (!g_key_file_load_from_file(ui.config_data, ui.configfile, 
+         G_KEY_FILE_KEEP_COMMENTS, NULL)) {
+    g_key_file_free(ui.config_data);
+    ui.config_data = g_key_file_new();
+    g_key_file_set_comment(ui.config_data, NULL, NULL, 
+           " Xournal configuration file.\n"
+           " This file is generated automatically upon saving preferences.\n"
+           " Use caution when editing this file manually.\n", NULL);
+    return;
+  }
+
+  // parse keys from the keyfile to set defaults
+  if (parse_keyval_float("general", "display_dpi", &f, 10., 500.))
+    DEFAULT_ZOOM = f/72.0;
+  if (parse_keyval_float("general", "initial_zoom", &f, 
+              MIN_ZOOM*100/DEFAULT_ZOOM, MAX_ZOOM*100/DEFAULT_ZOOM))
+    ui.zoom = DEFAULT_ZOOM*f/100.0;
+  parse_keyval_boolean("general", "window_maximize", &ui.maximize_at_start);
+  parse_keyval_boolean("general", "window_fullscreen", &ui.fullscreen);
+  parse_keyval_int("general", "window_width", &ui.window_default_width, 10, 5000);
+  parse_keyval_int("general", "window_height", &ui.window_default_height, 10, 5000);
+  parse_keyval_int("general", "scrollbar_speed", &ui.scrollbar_step_increment, 1, 5000);
+  parse_keyval_int("general", "zoom_dialog_increment", &ui.zoom_step_increment, 1, 500);
+  parse_keyval_float("general", "zoom_step_factor", &ui.zoom_step_factor, 1., 5.);
+  parse_keyval_boolean("general", "view_continuous", &ui.view_continuous);
+  parse_keyval_boolean("general", "use_xinput", &ui.allow_xinput);
+  parse_keyval_boolean("general", "use_erasertip", &ui.use_erasertip);
+
+  parse_keyval_float("paper", "width", &ui.default_page.width, 1., 5000.);
+  parse_keyval_float("paper", "height", &ui.default_page.height, 1., 5000.);
+  parse_keyval_enum("paper", "color", &(ui.default_page.bg->color_no), bgcolor_names, COLOR_MAX);
+  ui.default_page.bg->color_rgba = predef_bgcolors_rgba[ui.default_page.bg->color_no];
+  parse_keyval_enum("paper", "style", &(ui.default_page.bg->ruling), bgstyle_names, 4);
+  parse_keyval_boolean("paper", "apply_all", &ui.bg_apply_all_pages);
+  parse_keyval_enum("paper", "default_unit", &ui.default_unit, unit_names, 4);
+  parse_keyval_boolean("paper", "antialias_bg", &ui.antialias_bg);
+  parse_keyval_boolean("paper", "progressive_bg", &ui.progressive_bg);
+  parse_keyval_boolean("paper", "print_ruling", &ui.print_ruling);
+  parse_keyval_int("paper", "gs_bitmap_dpi", &GS_BITMAP_DPI, 1, 1200);
+  parse_keyval_int("paper", "pdftoppm_printing_dpi", &PDFTOPPM_PRINTING_DPI, 1, 1200);
+
+  parse_keyval_enum("tools", "startup_tool", &ui.startuptool, tool_names, NUM_TOOLS);
+  ui.toolno[0] = ui.startuptool;
+  if (ui.startuptool == TOOL_PEN || ui.startuptool == TOOL_HIGHLIGHTER) {
+    parse_keyval_boolean("tools", "startup_ruler", &ui.startupruler);
+    ui.ruler[0] = ui.startupruler;
+  }
+  parse_keyval_enum("tools", "pen_color", &(ui.brushes[0][TOOL_PEN].color_no), color_names, COLOR_MAX);
+  parse_keyval_int("tools", "pen_thickness", &(ui.brushes[0][TOOL_PEN].thickness_no), 0, 4);
+  parse_keyval_int("tools", "eraser_thickness", &(ui.brushes[0][TOOL_ERASER].thickness_no), 1, 3);
+  parse_keyval_int("tools", "eraser_mode", &(ui.brushes[0][TOOL_ERASER].tool_options), 0, 2);
+  parse_keyval_enum("tools", "highlighter_color", &(ui.brushes[0][TOOL_HIGHLIGHTER].color_no), color_names, COLOR_MAX);
+  parse_keyval_int("tools", "highlighter_thickness", &(ui.brushes[0][TOOL_HIGHLIGHTER].thickness_no), 0, 4);
+  for (i=0; i< NUM_STROKE_TOOLS; i++)
+    for (j=1; j<=NUM_BUTTONS; j++)
+      g_memmove(&(ui.brushes[j][i]), &(ui.brushes[0][i]), sizeof(struct Brush));
+
+  parse_keyval_enum("tools", "btn2_tool", &(ui.toolno[1]), tool_names, NUM_TOOLS);
+  if (parse_keyval_boolean("tools", "btn2_linked", &b))
+    ui.linked_brush[1] = b?BRUSH_LINKED:BRUSH_STATIC;
+  parse_keyval_enum("tools", "btn3_tool", &(ui.toolno[2]), tool_names, NUM_TOOLS);
+  if (parse_keyval_boolean("tools", "btn3_linked", &b))
+    ui.linked_brush[2] = b?BRUSH_LINKED:BRUSH_STATIC;
+  for (i=1; i<=NUM_BUTTONS; i++)
+    if (ui.toolno[i]==TOOL_PEN || ui.toolno[i]==TOOL_HIGHLIGHTER)
+      ui.ruler[i] = ui.ruler[0];
+  if (ui.linked_brush[1]!=BRUSH_LINKED) {
+    if (ui.toolno[1]==TOOL_PEN || ui.toolno[1]==TOOL_HIGHLIGHTER) {
+      parse_keyval_boolean("tools", "btn2_ruler", &(ui.ruler[1]));
+      parse_keyval_enum("tools", "btn2_color", &(ui.brushes[1][ui.toolno[1]].color_no), color_names, COLOR_MAX);
+    }
+    if (ui.toolno[1]<NUM_STROKE_TOOLS)
+      parse_keyval_int("tools", "btn2_thickness", &(ui.brushes[1][ui.toolno[1]].thickness_no), 0, 4);
+    if (ui.toolno[1]==TOOL_ERASER)
+      parse_keyval_int("tools", "btn2_erasermode", &(ui.brushes[1][TOOL_ERASER].tool_options), 0, 2);
+  }
+  if (ui.linked_brush[2]!=BRUSH_LINKED) {
+    if (ui.toolno[2]==TOOL_PEN || ui.toolno[2]==TOOL_HIGHLIGHTER) {
+      parse_keyval_boolean("tools", "btn3_ruler", &(ui.ruler[2]));
+      parse_keyval_enum("tools", "btn3_color", &(ui.brushes[2][ui.toolno[2]].color_no), color_names, COLOR_MAX);
+    }
+    if (ui.toolno[2]<NUM_STROKE_TOOLS)
+      parse_keyval_int("tools", "btn3_thickness", &(ui.brushes[2][ui.toolno[2]].thickness_no), 0, 4);
+    if (ui.toolno[2]==TOOL_ERASER)
+      parse_keyval_int("tools", "btn3_erasermode", &(ui.brushes[2][TOOL_ERASER].tool_options), 0, 2);
+  }
+  parse_keyval_floatlist("tools", "pen_thicknesses", predef_thickness[TOOL_PEN], 5, 0.01, 1000.0);
+  parse_keyval_floatlist("tools", "eraser_thicknesses", predef_thickness[TOOL_ERASER]+1, 3, 0.01, 1000.0);
+  parse_keyval_floatlist("tools", "highlighter_thicknesses", predef_thickness[TOOL_HIGHLIGHTER]+1, 3, 0.01, 1000.0);
+#endif
+}
index 8b34adc8e288db80b21ab713f1eed51f3d1f6f25..7ff1a03fe07a5ab542f8e36a1bc0cc64da885276 100644 (file)
@@ -1,8 +1,8 @@
 #define GS_CMDLINE \
   "gs -sDEVICE=bmp16m -r%f -q -sOutputFile=- " \
-  "-dNOPAUSE -dBATCH -dTextAlphaBits=4 -dGraphicsAlphaBits=4 %s"
+  "-dNOPAUSE -dBATCH -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 %s"
 
-#define GS_BITMAP_DPI 144   // was: (DEFAULT_ZOOM * 72)
+extern int GS_BITMAP_DPI, PDFTOPPM_PRINTING_DPI;
 
 #define TMPDIR_TEMPLATE "/tmp/xournalpdf.XXXXXX"
 
@@ -10,8 +10,6 @@
      { "pdftoppm", "-q", "-f", pageno_str, "-l", pageno_str, \
        "-r", dpi_str, pdf_filename, ppm_root, NULL }
 
-#define PDFTOPPM_PRINTING_DPI 150
-
 void new_journal(void);
 gboolean save_journal(const char *filename);
 gboolean close_journal(void);
@@ -35,3 +33,7 @@ void update_mru_menu(void);
 void new_mru_entry(char *name);
 void delete_mru_entry(int which);
 void save_mru_list(void);
+
+void init_config_default(void);
+void load_config_from_file(void);
+void save_config_to_file(void);
index 286894974623d40ae3ccf9a0cb62d74d9bf70207..dccb8993c0b65521bb5816617ac42ac59bb79b8a 100644 (file)
@@ -241,6 +241,7 @@ create_winMain (void)
   GtkWidget *separator18;
   GtkWidget *optionsAntialiasBG;
   GtkWidget *optionsProgressiveBG;
+  GtkWidget *optionsPrintRuling;
   GtkWidget *separator21;
   GtkWidget *optionsSavePreferences;
   GtkWidget *menuHelp;
@@ -1268,6 +1269,10 @@ create_winMain (void)
   gtk_widget_show (optionsProgressiveBG);
   gtk_container_add (GTK_CONTAINER (menuOptions_menu), optionsProgressiveBG);
 
+  optionsPrintRuling = gtk_check_menu_item_new_with_mnemonic ("Print Paper Ruling");
+  gtk_widget_show (optionsPrintRuling);
+  gtk_container_add (GTK_CONTAINER (menuOptions_menu), optionsPrintRuling);
+
   separator21 = gtk_separator_menu_item_new ();
   gtk_widget_show (separator21);
   gtk_container_add (GTK_CONTAINER (menuOptions_menu), separator21);
@@ -2179,6 +2184,9 @@ create_winMain (void)
   g_signal_connect ((gpointer) optionsProgressiveBG, "activate",
                     G_CALLBACK (on_optionsProgressiveBG_activate),
                     NULL);
+  g_signal_connect ((gpointer) optionsPrintRuling, "activate",
+                    G_CALLBACK (on_optionsPrintRuling_activate),
+                    NULL);
   g_signal_connect ((gpointer) optionsSavePreferences, "activate",
                     G_CALLBACK (on_optionsSavePreferences_activate),
                     NULL);
@@ -2524,6 +2532,7 @@ create_winMain (void)
   GLADE_HOOKUP_OBJECT (winMain, separator18, "separator18");
   GLADE_HOOKUP_OBJECT (winMain, optionsAntialiasBG, "optionsAntialiasBG");
   GLADE_HOOKUP_OBJECT (winMain, optionsProgressiveBG, "optionsProgressiveBG");
+  GLADE_HOOKUP_OBJECT (winMain, optionsPrintRuling, "optionsPrintRuling");
   GLADE_HOOKUP_OBJECT (winMain, separator21, "separator21");
   GLADE_HOOKUP_OBJECT (winMain, optionsSavePreferences, "optionsSavePreferences");
   GLADE_HOOKUP_OBJECT (winMain, menuHelp, "menuHelp");
index d1e546ecabea7a5b5f8edca3d955ad7792bb6dca..d9c4c18634dfd1c142ec18270fc4a23fb34115c2 100644 (file)
@@ -1,6 +1,3 @@
-// comment out the line below if you want the thickness settings of v 0.2
-#define NEW_THICKNESS
-
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
@@ -30,19 +27,11 @@ 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
+    { 2.83, 2.83, 8.50, 19.84, 19.84 }, // eraser thicknesses = 1, 3, 7 mm
+    { 2.83, 2.83, 8.50, 19.84, 19.84 }, // highlighter thicknesses = 1, 3, 7 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
 
@@ -556,7 +545,7 @@ void rescale_bg_pixmaps(void)
         set_cursor_busy(FALSE);
       } else
       {
-        pix = GDK_PIXBUF(g_object_get_data(G_OBJECT(pg->bg->canvas_item), "pixbuf"));
+        g_object_get(G_OBJECT(pg->bg->canvas_item), "pixbuf", &pix, NULL);
         if (pix!=pg->bg->pixbuf)
           gnome_canvas_item_set(pg->bg->canvas_item, "pixbuf", pg->bg->pixbuf, NULL);
         pg->bg->pixbuf_scale = 0;
index 2050f85badb4d983ba20b025577935e09f42a066..cc2d4c150643a12a2e93f3a1d1618d6821f24f05 100644 (file)
@@ -671,6 +671,7 @@ void pdf_draw_solid_background(struct Page *pg, GString *str)
   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 (!ui.print_ruling) return;
   if (pg->bg->ruling == RULING_NONE) return;
   g_string_append_printf(str,
     "%.2f %.2f %.2f RG %.2f w ",
@@ -1028,6 +1029,7 @@ void print_background(GnomePrintContext *gpc, struct Page *pg, gboolean *abort)
     gnome_print_setrgbcolor(gpc, RGBA_RGB(pg->bg->color_rgba));
     gnome_print_rect_filled(gpc, 0, 0, pg->width, pg->height);
 
+    if (!ui.print_ruling) return;
     if (pg->bg->ruling == RULING_NONE) return;
     gnome_print_setrgbcolor(gpc, RGBA_RGB(RULING_COLOR));
     gnome_print_setlinewidth(gpc, RULING_THICKNESS);
index 6ed265a2759a19ce5bd0fde5693ebdefa89fa884..62d3dc8efb3b14e7d4c26e5b53d9a38099e366d2 100644 (file)
@@ -6,6 +6,7 @@
 #define CONFIG_DIR ".xournal"
 #define MRU_FILE "recent-files"
 #define MRU_SIZE 8 
+#define CONFIG_FILE "config"
 
 // DATA STRUCTURES AND CONSTANTS
 
@@ -13,7 +14,7 @@
 #define MAX_AXES 12
 #define EPSILON 1E-7
 #define MAX_ZOOM 20.0
-#define DEFAULT_ZOOM 1.3333333333
+#define DISPLAY_DPI_DEFAULT 96.0
 #define MIN_ZOOM 0.2
 
 /* a string (+ aux data) that maintains a refcount */
@@ -99,6 +100,7 @@ extern guint predef_bgcolors_rgba[COLOR_MAX];
 #define TOOL_VERTSPACE    6
 #define TOOL_HAND         7
 #define NUM_STROKE_TOOLS  3
+#define NUM_TOOLS         8
 #define NUM_BUTTONS       3
 
 #define TOOLOPT_ERASER_STANDARD     0
@@ -204,16 +206,26 @@ typedef struct UIData {
   int screen_width, screen_height; // initial screen size, for XInput events
   double hand_refpt[2];
   char *filename;
-  gboolean view_continuous, fullscreen;
+  gboolean view_continuous, fullscreen, maximize_at_start;
   gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction
   struct Selection *selection;
   GdkCursor *cursor;
   gboolean antialias_bg; // bilinear interpolation on bg pixmaps
   gboolean progressive_bg; // rescale bg's one at a time
-  char *mrufile; // file for the MRU
+  char *mrufile, *configfile; // file names for MRU & config
   char *mru[MRU_SIZE]; // MRU data
   GtkWidget *mrumenu[MRU_SIZE];
   gboolean bg_apply_all_pages;
+  int window_default_width, window_default_height, scrollbar_step_increment;
+  gboolean print_ruling; // print the paper ruling ?
+  int default_unit; // the default unit for paper sizes
+  int startuptool; // the default tool at startup
+  gboolean startupruler;
+  int zoom_step_increment; // the increment in the zoom dialog box
+  double zoom_step_factor; // the multiplicative factor in zoom in/out
+#if GLIB_CHECK_VERSION(2,6,0)
+  GKeyFile *config_data;
+#endif
 } UIData;
 
 #define BRUSH_LINKED 0
@@ -301,3 +313,10 @@ extern struct Journal journal;
 extern struct UIData ui;
 extern struct BgPdf bgpdf;
 extern struct UndoItem *undo, *redo;
+
+extern double DEFAULT_ZOOM;
+
+#define UNIT_CM 0
+#define UNIT_IN 1
+#define UNIT_PX 2
+#define UNIT_PT 3
index ebfef27141dc04de4ffbd9e3a8ee80014123f9a4..c7ad3c817aa838130b0a03b5fc6a597946b40856 100644 (file)
                    </widget>
                  </child>
 
+                 <child>
+                   <widget class="GtkCheckMenuItem" id="optionsPrintRuling">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Print Paper Ruling</property>
+                     <property name="use_underline">True</property>
+                     <property name="active">False</property>
+                     <signal name="activate" handler="on_optionsPrintRuling_activate" last_modification_time="Sat, 25 Nov 2006 03:42:27 GMT"/>
+                   </widget>
+                 </child>
+
                  <child>
                    <widget class="GtkSeparatorMenuItem" id="separator21">
                      <property name="visible">True</property>