diff --git a/src/main.c b/src/main.c
index 20d48fd..6ad515f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -349,7 +349,6 @@ main (int argc, char *argv[])
   
   if (bgpdf.status != STATUS_NOT_INIT) shutdown_bgpdf();
 
-  save_mru_list();
   if (ui.auto_save_prefs) save_config_to_file();
   
   return 0;
diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c
index 50672f6..d3c2c46 100644
--- a/src/xo-callbacks.c
+++ b/src/xo-callbacks.c
@@ -1111,7 +1111,7 @@ on_journalNewPageAfter_activate        (GtkMenuItem     *menuitem,
   pg = new_page(ui.cur_page);
   journal.pages = g_list_insert(journal.pages, pg, ui.pageno+1);
   journal.npages++;
-  do_switch_page(ui.pageno+1, TRUE, TRUE);
+  do_switch_page_and_scroll(ui.pageno+1, TRUE, TRUE, -1/2.);
 
   prepare_new_undo();
   undo->type = ITEM_NEW_PAGE;
@@ -1131,7 +1131,7 @@ on_journalNewPageEnd_activate          (GtkMenuItem     *menuitem,
   pg = new_page((struct Page *)g_list_last(journal.pages)->data);
   journal.pages = g_list_append(journal.pages, pg);
   journal.npages++;
-  do_switch_page(journal.npages-1, TRUE, TRUE);
+  do_switch_page_and_scroll(journal.npages-1, TRUE, TRUE, -1/2.);
 
   prepare_new_undo();
   undo->type = ITEM_NEW_PAGE;
@@ -1257,7 +1257,6 @@ on_journalFlatten_activate             (GtkMenuItem     *menuitem,
 
 }
 
-
 // the paper sizes dialog
 
 GtkWidget *papersize_dialog;
@@ -3197,32 +3196,36 @@ on_optionsProgressiveBG_activate       (GtkMenuItem     *menuitem,
 
 
 void
-on_mru_activate                        (GtkMenuItem     *menuitem,
+on_mru_activate                        (GtkRecentChooser *recentChooser,
                                         gpointer         user_data)
 {
-  int which;
   gboolean success;
+  gchar *uri, *name;
   GtkWidget *dialog;
   
   end_text();
   if (!ok_to_close()) return; // user aborted on save confirmation
   
-  for (which = 0 ; which < MRU_SIZE; which++) {
-    if (ui.mrumenu[which] == GTK_WIDGET(menuitem)) break;
-  }
-  if (which == MRU_SIZE || ui.mru[which] == NULL) return; // not found...
-
+  uri = gtk_recent_chooser_get_current_uri (recentChooser);
+  name = g_filename_from_uri (uri, NULL, NULL);
   set_cursor_busy(TRUE);
-  success = open_journal(ui.mru[which]);
+  success = open_journal(name);
   set_cursor_busy(FALSE);
-  if (success) return;
+  if (success) {
+    g_free(uri);
+    g_free(name);
+    return;
+  }
 
   /* open failed */
   dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
-    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), ui.mru[which]);
+    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), name);
   gtk_dialog_run(GTK_DIALOG(dialog));
   gtk_widget_destroy(dialog);
-  delete_mru_entry(which);
+
+  delete_mru_entry(name);
+  g_free(uri);
+  g_free(name);
 }
 
 
@@ -3677,3 +3680,273 @@ on_optionsButtonsSwitchMappings_activate(GtkMenuItem    *menuitem,
 }
 
 
+
+// the ruling parameters dialog
+void
+on_journalRulingParams_activate        (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  GtkWidget *ruling_dialog;
+  GtkEntry *rd_margin_color, *rd_ruling_color;
+  GtkSpinButton *rd_left_margin, *rd_top_margin, *rd_bottom_margin;
+  GtkSpinButton *rd_thickness, *rd_spacing, *rd_graph_spacing;
+  int response;
+  char entry_text[9];
+
+  struct Background *bg = ui.cur_page->bg;
+
+  end_text();
+  ruling_dialog = create_rulingDialog();
+
+  // Set values in widgets to be those from current page.
+  rd_margin_color = GTK_ENTRY(lookup_widget (ruling_dialog, "rd_margin_color"));
+  snprintf (entry_text, 9, "%08x", bg->ruling_margin_color);
+  gtk_entry_set_text (rd_margin_color, entry_text);
+
+  rd_ruling_color = GTK_ENTRY(lookup_widget (ruling_dialog, "rd_ruling_color"));
+  snprintf (entry_text, 9, "%08x", bg->ruling_color);
+  gtk_entry_set_text (rd_ruling_color, entry_text);
+
+  rd_thickness = GTK_SPIN_BUTTON(lookup_widget (ruling_dialog, "rd_thickness" ));
+  gtk_spin_button_set_value (rd_thickness, bg->ruling_thickness);
+  gtk_spin_button_set_range (rd_thickness, RULING_THICKNESS_MIN, RULING_THICKNESS_MAX);
+
+  rd_left_margin = GTK_SPIN_BUTTON(lookup_widget (ruling_dialog, "rd_left_margin" ));
+  gtk_spin_button_set_value (rd_left_margin, bg->ruling_leftmargin);
+  gtk_spin_button_set_range (rd_left_margin, RULING_MARGIN_MIN, RULING_MARGIN_MAX);
+
+  rd_top_margin = GTK_SPIN_BUTTON(lookup_widget (ruling_dialog, "rd_top_margin" ));
+  gtk_spin_button_set_value (rd_top_margin, bg->ruling_topmargin);
+  gtk_spin_button_set_range (rd_top_margin, RULING_MARGIN_MIN, RULING_MARGIN_MAX);
+
+  rd_spacing = GTK_SPIN_BUTTON(lookup_widget (ruling_dialog, "rd_spacing" ));
+  gtk_spin_button_set_value (rd_spacing, bg->ruling_spacing);
+  gtk_spin_button_set_range (rd_spacing, RULING_SPACING_MIN, RULING_SPACING_MAX);
+
+  rd_bottom_margin = GTK_SPIN_BUTTON(lookup_widget (ruling_dialog, "rd_bottom_margin" ));
+  gtk_spin_button_set_value (rd_bottom_margin, bg->ruling_bottommargin);
+  gtk_spin_button_set_range (rd_bottom_margin, RULING_MARGIN_MIN, RULING_MARGIN_MAX);
+
+  rd_graph_spacing = GTK_SPIN_BUTTON(lookup_widget (ruling_dialog, "rd_graph_spacing" ));
+  gtk_spin_button_set_value (rd_graph_spacing, bg->ruling_graphspacing);
+  gtk_spin_button_set_range (rd_graph_spacing, RULING_SPACING_MIN, RULING_SPACING_MAX);
+
+  // Run the dialog
+  gtk_dialog_set_default_response(GTK_DIALOG(ruling_dialog), GTK_RESPONSE_OK);
+  gtk_widget_show(ruling_dialog);
+  response = gtk_dialog_run(GTK_DIALOG(ruling_dialog));
+
+  if (response == GTK_RESPONSE_OK) {
+    struct Page *pg;
+    GList *pglist;
+    guint val;
+    gchar *ptr;
+
+    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_ONE;
+      undo->page = pg;
+      undo->bg = (struct Background *)g_memdup(pg->bg, sizeof(struct Background));
+      undo->bg->canvas_item = NULL;
+
+      // Set values here
+      val = strtoul( gtk_entry_get_text (rd_margin_color), &ptr, 16);
+      if( *ptr == 0 ) pg->bg->ruling_margin_color = val;
+      val = strtoul( gtk_entry_get_text (rd_ruling_color), &ptr, 16);
+      if( *ptr == 0 ) pg->bg->ruling_color = val;
+      pg->bg->ruling_thickness = gtk_spin_button_get_value (rd_thickness);
+      pg->bg->ruling_leftmargin = gtk_spin_button_get_value (rd_left_margin);
+      pg->bg->ruling_topmargin = gtk_spin_button_get_value (rd_top_margin);
+      pg->bg->ruling_spacing = gtk_spin_button_get_value (rd_spacing);
+      pg->bg->ruling_bottommargin = gtk_spin_button_get_value (rd_bottom_margin);
+      pg->bg->ruling_graphspacing = gtk_spin_button_get_value (rd_graph_spacing);
+      
+      update_canvas_bg(pg);
+      if (!ui.bg_apply_all_pages) break;
+    }
+    do_switch_page(ui.pageno, TRUE, TRUE);
+  }
+  gtk_widget_destroy(ruling_dialog);
+}
+
+
+/*
+ * Simple color inversion, without preserving hue.
+ */
+//#define INVERT_COLOR( c ) c = ((c) ^ 0xffffff00)
+
+/*
+ * HLS color inversion. This preserves the nature of the color, and only tries
+ * to invert the brightness. The next few functions are helper functions to
+ * do this.
+ *
+ * NOTE: In theory inverting twice should get back the original. However there
+ * are round off errors that might change the colors slightly. I've tested for
+ * 1,000,000 randomly generated colors that inverting twice is the identity.
+ *
+ * -- gi1242 2010-02-13.
+ */
+#define INVERT_COLOR( c ) c = rgba_invert_color(c)
+
+#define intcolor( f ) ((f) >= 1.0 ? 255 : (guint) ((f) * 256) & 0xff)
+
+static double
+hue_to_rgb(const double m1, const double m2, double h )
+{
+  if (h<0) h+=1.0;
+  if (h>1) h-=1.0;
+  if (6.0*h < 1  ) return (m1+(m2-m1)*h*6.0);
+  if (2.0*h < 1  ) return m2;
+  if (3.0*h < 2.0) return (m1+(m2-m1)*((2.0/3.0)-h)*6.0);
+  return m1;
+}
+
+guint
+hls_to_rgb(const double H, const double L, const double S )
+{
+  double r,g,b;
+  double m1, m2;
+
+  if (S==0) r=g=b=L;
+  else {
+    if (L <=0.5) m2 = L*(1.0+S);
+    else         m2 = L+S-L*S;
+    m1 = 2.0*L-m2;
+    r = hue_to_rgb(m1,m2,H+1.0/3.0);
+    g = hue_to_rgb(m1,m2,H);
+    b = hue_to_rgb(m1,m2,H-1.0/3.0);
+  }
+  return ( intcolor(r) << 16 ) | (intcolor(g) << 8) | (intcolor(b));
+}
+
+void
+rgba_to_hls( const guint rgba, double *H, double *L, double *S )
+{
+  double delta;
+  double r = ( ( ( rgba >> 24 ) & 0xff ) + .5 ) / 256.0;
+  double g = ( ( ( rgba >> 16 ) & 0xff ) + .5 ) / 256.0;
+  double b = ( ( ( rgba >>  8 ) & 0xff ) + .5 ) / 256.0;
+  double cmax;
+  double cmin;
+
+  cmax = (r > g) ? r : g; if( b > cmax ) cmax = b;
+  cmin = (r < g) ? r : g; if( b < cmin ) cmin = b;
+
+  *L=(cmax+cmin)/2.0;
+  if(cmax==cmin) *S = *H = 0; // it's really undefined
+  else {
+    if(*L < 0.5)	*S = (cmax-cmin)/(cmax+cmin);
+    else			*S = (cmax-cmin)/(2.0-cmax-cmin);
+    delta = cmax - cmin;
+    if (r==cmax) *H = (g-b)/delta;
+    else 
+      if(g==cmax) *H = 2.0 +(b-r)/delta;
+      else        *H = 4.0+(r-g)/delta;
+    *H /= 6.0;
+    if (*H < 0.0) *H += 1;
+  }
+}
+
+guint
+rgba_invert_color( guint c )
+{
+  double h, l, s;
+  guint inv;
+
+  rgba_to_hls( c, &h, &l, &s );
+  inv = (hls_to_rgb( h, 1.0-l, s ) << 8) | (c & 0xff);
+
+  return inv;
+}
+
+void
+on_invert_colors_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  GList *pagelist, *layerlist, *itemlist;
+  struct Page *pg;
+  struct Layer *layer;
+  struct Item *item;
+
+  // NOTE: If it wasn't for color_no of all colors, we could simply store undo
+  // info by "redoing" an invert journal. Unfortunately, info on color_no
+  // (necessarily) gets lost when inverting colors, so we can't do this (or risk
+  // possible side effects).
+  for (pagelist = journal.pages; pagelist!=NULL; pagelist = pagelist->next) {
+    pg = (struct Page *)pagelist->data;
+
+    // First set MULTIOP_CONT_REDO if the undo info was generated by this
+    // function.
+    if (pagelist->prev!=NULL) undo->multiop |= MULTIOP_CONT_REDO;
+
+    // Now prepare undo info for page background.
+    prepare_new_undo();
+    if (pagelist->prev!=NULL) undo->multiop |= MULTIOP_CONT_UNDO;
+    undo->type = ITEM_NEW_BG_ONE;
+    undo->page = pg;
+    undo->bg = (struct Background *)g_memdup(pg->bg, sizeof(struct Background));
+    undo->bg->canvas_item = NULL;
+
+    // Invert page/ruling colors. NOTE: Color names are lost when inverting. We
+    // can search against predef_bgcolors_rgba etc., but that only wastes CPU
+    // cycles.
+    INVERT_COLOR (pg->bg->color_rgba);
+    pg->bg->color_no = -1;
+    INVERT_COLOR (pg->bg->ruling_margin_color);
+    INVERT_COLOR (pg->bg->ruling_color);
+
+    update_canvas_bg(pg);
+
+    for (layerlist = pg->layers; layerlist!=NULL; layerlist = layerlist->next) {
+      layer = (struct Layer *)layerlist->data;
+
+      if (layer->items!=NULL) {
+	// Current undo item is necessarily generated by this function. Set
+	// MULTIOP_CONT_REDO.
+	undo->multiop |= MULTIOP_CONT_REDO;
+
+	// Now prepare undo information for items on this page.
+	prepare_new_undo();
+	undo->multiop |= MULTIOP_CONT_UNDO;
+	undo->type = ITEM_REPAINTSEL;
+	undo->itemlist = NULL;
+	undo->auxlist = NULL;
+
+	for (itemlist = layer->items; itemlist!=NULL; itemlist = itemlist->next)
+	{
+	  struct Brush *brush;
+
+	  item = (struct Item *)itemlist->data;
+
+	  // Store undo info for this stroke (as in recolor_selection())
+	  undo->itemlist = g_list_append(undo->itemlist, item);
+	  brush = (struct Brush *)g_malloc(sizeof(struct Brush));
+	  g_memmove(brush, &(item->brush), sizeof(struct Brush));
+	  undo->auxlist = g_list_append(undo->auxlist, brush);
+
+	  // Invert colors for this stroke.
+	  INVERT_COLOR( item->brush.color_rgba );
+	  item->brush.color_no = -1;
+	  if (item->canvas_item!=NULL) {
+	    if (!item->brush.variable_width)
+	      gnome_canvas_item_set(item->canvas_item, 
+		  "fill-color-rgba", item->brush.color_rgba, NULL);
+	    else {
+	      GnomeCanvasGroup *group;
+
+	      group = (GnomeCanvasGroup *) item->canvas_item->parent;
+	      gtk_object_destroy(GTK_OBJECT(item->canvas_item));
+	      make_canvas_item_one(group, item);
+	    }
+	  } /* if (item->canvas_item...) */
+	} /* for (itemlist...) */
+      } /* if (layer->items!=NULL) */
+    } /* for (layerlist...) */
+  } /* for (pagelist...) */
+}
diff --git a/src/xo-callbacks.h b/src/xo-callbacks.h
index bce8b48..03aae06 100644
--- a/src/xo-callbacks.h
+++ b/src/xo-callbacks.h
@@ -497,7 +497,7 @@ on_optionsProgressiveBG_activate       (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
 
 void
-on_mru_activate                        (GtkMenuItem     *menuitem,
+on_mru_activate                        (GtkRecentChooser *recentChooser,
                                         gpointer         user_data);
 
 void
@@ -660,3 +660,11 @@ on_button2Image_activate               (GtkMenuItem     *menuitem,
 void
 on_button3Image_activate               (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
+
+void
+on_journalRulingParams_activate        (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_invert_colors_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
diff --git a/src/xo-file.c b/src/xo-file.c
index 082d399..88baf4a 100644
--- a/src/xo-file.c
+++ b/src/xo-file.c
@@ -225,6 +225,7 @@ gboolean save_journal(const char *filename)
       gzprintf(f, "pageno=\"%d\" ", pg->bg->file_page_seq);
     }
     gzprintf(f, "/>\n");
+    gzprintf(f, "<rulingstyle margin_color=\"#%08x\" color=\"#%08x\" thickness=\"%f\" leftmargin=\"%f\" topmargin=\"%f\" spacing=\"%f\" bottommargin=\"%f\" graphspacing=\"%f\" />\n", pg->bg->ruling_margin_color, pg->bg->ruling_color, pg->bg->ruling_thickness, pg->bg->ruling_leftmargin, pg->bg->ruling_topmargin, pg->bg->ruling_spacing, pg->bg->ruling_bottommargin, pg->bg->ruling_graphspacing);
     for (layerlist = pg->layers; layerlist!=NULL; layerlist = layerlist->next) {
       layer = (struct Layer *)layerlist->data;
       gzprintf(f, "<layer>\n");
@@ -358,6 +359,19 @@ void xoj_parser_start_element(GMarkupParseContext *context,
     tmpPage->bg->canvas_item = NULL;
     tmpPage->bg->pixbuf = NULL;
     tmpPage->bg->filename = NULL;
+
+    // When loading journals which don't have the <rulingstyle ...> tag, we
+    // should use the compiled in defaults from xournal-0.4.5 for backward
+    // compatibility.
+    tmpPage->bg->ruling_margin_color = RULING_MARGIN_COLOR;
+    tmpPage->bg->ruling_color = RULING_COLOR;
+    tmpPage->bg->ruling_thickness = RULING_THICKNESS;
+    tmpPage->bg->ruling_leftmargin = RULING_LEFTMARGIN;
+    tmpPage->bg->ruling_topmargin = RULING_TOPMARGIN;
+    tmpPage->bg->ruling_spacing = RULING_SPACING;
+    tmpPage->bg->ruling_bottommargin = RULING_BOTTOMMARGIN;
+    tmpPage->bg->ruling_graphspacing = RULING_GRAPHSPACING;
+
     tmpJournal.pages = g_list_append(tmpJournal.pages, tmpPage);
     tmpJournal.npages++;
     // scan for height and width attributes
@@ -501,6 +515,62 @@ void xoj_parser_start_element(GMarkupParseContext *context,
     if (tmpPage->bg->type == BG_PIXMAP && has_attr != 25) *error = xoj_invalid();
     if (tmpPage->bg->type == BG_PDF && has_attr != 57) *error = xoj_invalid();
   }
+  else if (!strcmp(element_name, "rulingstyle")) {
+    // TODO: Check if we're inside a background element.
+    if (tmpPage == NULL || tmpLayer !=NULL) {
+      *error = xoj_invalid();
+      return;
+    }
+    while (*attribute_names!=NULL) {
+      if (!strcmp(*attribute_names, "margin_color")) {
+        if (**attribute_values == '#') {
+          tmpPage->bg->ruling_margin_color = strtoul(*attribute_values + 1, &ptr, 16);
+          if (*ptr!=0) *error = xoj_invalid();
+        }
+	else *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "color")) {
+        if (**attribute_values == '#') {
+          tmpPage->bg->ruling_color = strtoul(*attribute_values + 1, &ptr, 16);
+          if (*ptr!=0) *error = xoj_invalid();
+        }
+	else *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "thickness")) {
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->bg->ruling_thickness = g_ascii_strtod(*attribute_values, &ptr);
+        if (ptr == *attribute_values) *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "leftmargin")) {
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->bg->ruling_leftmargin = g_ascii_strtod(*attribute_values, &ptr);
+        if (ptr == *attribute_values) *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "topmargin")) {
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->bg->ruling_topmargin = g_ascii_strtod(*attribute_values, &ptr);
+        if (ptr == *attribute_values) *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "spacing")) {
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->bg->ruling_spacing = g_ascii_strtod(*attribute_values, &ptr);
+        if (ptr == *attribute_values) *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "bottommargin")) {
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->bg->ruling_bottommargin = g_ascii_strtod(*attribute_values, &ptr);
+        if (ptr == *attribute_values) *error = xoj_invalid();
+      }
+      else if (!strcmp(*attribute_names, "graphspacing")) {
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->bg->ruling_graphspacing = g_ascii_strtod(*attribute_values, &ptr);
+        if (ptr == *attribute_values) *error = xoj_invalid();
+      }
+      else *error = xoj_invalid();
+      attribute_names++;
+      attribute_values++;
+    }
+  }
   else if (!strcmp(element_name, "layer")) { // start of a layer
     if (tmpPage == NULL || tmpLayer != NULL) {
       *error = xoj_invalid();
@@ -1367,109 +1437,66 @@ void bgpdf_update_bg(int pageno, struct BgPdfPage *bgpg)
   }
 }
 
-// initialize the recent files list
+// initialize GtkRecentManager. Also backwards compatibility: import recent files into GtkRecentManager
 void init_mru(void)
 {
-  int i;
+  GtkRecentFilter *recentFilter = gtk_recent_filter_new ();
+  gtk_recent_filter_add_application ( recentFilter, "xournal");
+  gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (GET_COMPONENT("fileRecentFiles_menu")), recentFilter);
+
   gsize lfptr;
-  char s[5];
   GIOChannel *f;
-  gchar *str;
+  gchar *str, *uri;
   GIOStatus status;
+  GtkRecentManager *recentManager = gtk_recent_manager_get_default ();
   
-  g_strlcpy(s, "mru0", 5);
-  for (s[3]='0', i=0; i<MRU_SIZE; s[3]++, i++) {
-    ui.mrumenu[i] = GET_COMPONENT(s);
-    ui.mru[i] = NULL;
-  }
   f = g_io_channel_new_file(ui.mrufile, "r", NULL);
   if (f) status = G_IO_STATUS_NORMAL;
   else status = G_IO_STATUS_ERROR;
-  i = 0;
-  while (status == G_IO_STATUS_NORMAL && i<MRU_SIZE) {
+  while (status == G_IO_STATUS_NORMAL) {
     lfptr = 0;
     status = g_io_channel_read_line(f, &str, NULL, &lfptr, NULL);
     if (status == G_IO_STATUS_NORMAL && lfptr>0) {
       str[lfptr] = 0;
-      ui.mru[i] = str;
-      i++;
+      uri = g_filename_to_uri (str, NULL, NULL);
+      gtk_recent_manager_add_item (recentManager, uri);
+      g_free(uri);
+      g_free(str);
     }
   }
   if (f) {
     g_io_channel_shutdown(f, FALSE, NULL);
     g_io_channel_unref(f);
   }
-  update_mru_menu();
-}
-
-void update_mru_menu(void)
-{
-  int i;
-  gboolean anyone = FALSE;
-  gchar *tmp;
   
-  for (i=0; i<MRU_SIZE; i++) {
-    if (ui.mru[i]!=NULL) {
-      tmp = g_strdup_printf("_%d %s", i+1,
-               g_strjoinv("__", g_strsplit_set(g_basename(ui.mru[i]),"_",-1)));
-      gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(ui.mrumenu[i]))),
-          tmp);
-      g_free(tmp);
-      gtk_widget_show(ui.mrumenu[i]);
-      anyone = TRUE;
-    }
-    else gtk_widget_hide(ui.mrumenu[i]);
-  }
-  gtk_widget_set_sensitive(GET_COMPONENT("fileRecentFiles"), anyone);
+  g_unlink (ui.mrufile);
 }
 
 void new_mru_entry(char *name)
 {
-  int i, j;
-  
-  for (i=0;i<MRU_SIZE;i++) 
-    if (ui.mru[i]!=NULL && !strcmp(ui.mru[i], name)) {
-      g_free(ui.mru[i]);
-      for (j=i+1; j<MRU_SIZE; j++) ui.mru[j-1] = ui.mru[j];
-      ui.mru[MRU_SIZE-1]=NULL;
-    }
-  if (ui.mru[MRU_SIZE-1]!=NULL) g_free(ui.mru[MRU_SIZE-1]);
-  for (j=MRU_SIZE-1; j>=1; j--) ui.mru[j] = ui.mru[j-1];
-  ui.mru[0] = g_strdup(name);
-  update_mru_menu();
-}
-
-void delete_mru_entry(int which)
-{
-  int i;
-  
-  if (ui.mru[which]!=NULL) g_free(ui.mru[which]);
-  for (i=which+1;i<MRU_SIZE;i++) 
-    ui.mru[i-1] = ui.mru[i];
-  ui.mru[MRU_SIZE-1] = NULL;
-  update_mru_menu();
+  gchar *uri = g_filename_to_uri (name, NULL, NULL);
+  gtk_recent_manager_add_item (gtk_recent_manager_get_default(), uri);
+  g_free(uri);
 }
 
-void save_mru_list(void)
+void delete_mru_entry(char *name)
 {
-  FILE *f;
-  int i;
-  
-  f = fopen(ui.mrufile, "w");
-  if (f==NULL) return;
-  for (i=0; i<MRU_SIZE; i++)
-    if (ui.mru[i]!=NULL) fprintf(f, "%s\n", ui.mru[i]);
-  fclose(f);
+  gchar *uri = g_filename_to_uri(name, NULL, NULL);
+  gtk_recent_manager_remove_item(gtk_recent_manager_get_default(), uri, NULL);
+  g_free(uri);
 }
 
 void init_config_default(void)
 {
   int i, j;
-
+  GtkPaperSize *size;
   DEFAULT_ZOOM = DISPLAY_DPI_DEFAULT/72.0;
   ui.zoom = ui.startup_zoom = 1.0*DEFAULT_ZOOM;
-  ui.default_page.height = 792.0;
-  ui.default_page.width = 612.0;
+  // passing NULL gives system's default paper size
+  size = gtk_paper_size_new (NULL);
+  ui.default_page.height = gtk_paper_size_get_height (size,GTK_UNIT_POINTS);
+  ui.default_page.width = gtk_paper_size_get_width (size,GTK_UNIT_POINTS);
+  gtk_paper_size_free(size);
   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];
@@ -1492,6 +1519,14 @@ void init_config_default(void)
   ui.zoom_step_factor = 1.5;
   ui.progressive_bg = TRUE;
   ui.print_ruling = TRUE;
+  ui.default_page.bg->ruling_margin_color = RULING_MARGIN_COLOR;
+  ui.default_page.bg->ruling_color = RULING_COLOR;
+  ui.default_page.bg->ruling_thickness = RULING_THICKNESS;
+  ui.default_page.bg->ruling_leftmargin = RULING_LEFTMARGIN;
+  ui.default_page.bg->ruling_topmargin = RULING_TOPMARGIN;
+  ui.default_page.bg->ruling_spacing = RULING_SPACING;
+  ui.default_page.bg->ruling_bottommargin = RULING_SPACING;
+  ui.default_page.bg->ruling_graphspacing = RULING_GRAPHSPACING;
   ui.default_unit = UNIT_CM;
   ui.default_path = NULL;
   ui.default_image = NULL;
@@ -1689,6 +1724,30 @@ void save_config_to_file(void)
   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", "ruling_margin_color",
+    _(" default ruling margin color"),
+    g_strdup_printf("#%08x", ui.default_page.bg->ruling_margin_color));
+  update_keyval("paper", "ruling_color",
+    _(" default ruling color"),
+    g_strdup_printf("#%08x", ui.default_page.bg->ruling_color));
+  update_keyval("paper", "ruling_thickness",
+    _(" default ruling thickness"),
+    g_strdup_printf("%.3f", ui.default_page.bg->ruling_thickness));
+  update_keyval("paper", "ruling_leftmargin",
+    _(" default ruling left margin"),
+    g_strdup_printf("%.3f", ui.default_page.bg->ruling_leftmargin));
+  update_keyval("paper", "ruling_topmargin",
+    _(" default ruling top margin"),
+    g_strdup_printf("%.3f", ui.default_page.bg->ruling_topmargin));
+  update_keyval("paper", "ruling_spacing",
+    _(" default ruling spacing"),
+    g_strdup_printf("%.3f", ui.default_page.bg->ruling_spacing));
+  update_keyval("paper", "ruling_bottommargin",
+    _(" default ruling bottom margin"),
+    g_strdup_printf("%.3f", ui.default_page.bg->ruling_bottommargin));
+  update_keyval("paper", "ruling_graphspacing",
+    _(" default ruling graph spacing"),
+    g_strdup_printf("%.3f", ui.default_page.bg->ruling_graphspacing));
   update_keyval("paper", "apply_all",
     _(" apply paper style changes to all pages (true/false)"),
     g_strdup(ui.bg_apply_all_pages?"true":"false"));
@@ -1990,6 +2049,7 @@ void load_config_from_file(void)
   gboolean b;
   int i, j;
   gchar *str;
+  int discard_colorno;
   
 #if GLIB_CHECK_VERSION(2,6,0)
   // no support for keyval files before Glib 2.6.0
@@ -2046,6 +2106,14 @@ void load_config_from_file(void)
      &(ui.default_page.bg->color_no), &(ui.default_page.bg->color_rgba), 
      bgcolor_names, predef_bgcolors_rgba, COLOR_MAX);
   parse_keyval_enum("paper", "style", &(ui.default_page.bg->ruling), bgstyle_names, 4);
+  parse_keyval_enum_color("paper", "ruling_margin_color", &discard_colorno, &ui.default_page.bg->ruling_margin_color, color_names, predef_colors_rgba, COLOR_MAX);
+  parse_keyval_enum_color("paper", "ruling_color", &discard_colorno, &ui.default_page.bg->ruling_color, color_names, predef_colors_rgba, COLOR_MAX);
+  parse_keyval_float("paper", "ruling_thickness", &ui.default_page.bg->ruling_thickness, RULING_THICKNESS_MIN, RULING_THICKNESS_MAX );
+  parse_keyval_float("paper", "ruling_leftmargin", &ui.default_page.bg->ruling_leftmargin, RULING_MARGIN_MIN, RULING_MARGIN_MAX );
+  parse_keyval_float("paper", "ruling_topmargin", &ui.default_page.bg->ruling_topmargin, RULING_MARGIN_MIN, RULING_MARGIN_MAX );
+  parse_keyval_float("paper", "ruling_spacing", &ui.default_page.bg->ruling_spacing, RULING_SPACING_MIN, RULING_SPACING_MAX );
+  parse_keyval_float("paper", "ruling_bottommargin", &ui.default_page.bg->ruling_bottommargin, RULING_MARGIN_MIN, RULING_MARGIN_MAX );
+  parse_keyval_float("paper", "ruling_graphspacing", &ui.default_page.bg->ruling_graphspacing, RULING_SPACING_MIN, RULING_SPACING_MAX );
   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", "progressive_bg", &ui.progressive_bg);
diff --git a/src/xo-file.h b/src/xo-file.h
index 01f7116..fac10db 100644
--- a/src/xo-file.h
+++ b/src/xo-file.h
@@ -43,10 +43,8 @@ void bgpdf_create_page_with_bg(int pageno, struct BgPdfPage *bgpg);
 void bgpdf_update_bg(int pageno, struct BgPdfPage *bgpg);
 
 void init_mru(void);
-void update_mru_menu(void);
 void new_mru_entry(char *name);
-void delete_mru_entry(int which);
-void save_mru_list(void);
+void delete_mru_entry(char *name);
 
 void init_config_default(void);
 void load_config_from_file(void);
diff --git a/src/xo-interface.c b/src/xo-interface.c
index b4d71e8..5530a85 100644
--- a/src/xo-interface.c
+++ b/src/xo-interface.c
@@ -43,14 +43,6 @@ create_winMain (void)
   GtkWidget *separator1;
   GtkWidget *fileRecentFiles;
   GtkWidget *fileRecentFiles_menu;
-  GtkWidget *mru0;
-  GtkWidget *mru1;
-  GtkWidget *mru2;
-  GtkWidget *mru3;
-  GtkWidget *mru4;
-  GtkWidget *mru5;
-  GtkWidget *mru6;
-  GtkWidget *mru7;
   GtkWidget *separator22;
   GtkWidget *filePrintOptions;
   GtkWidget *image624;
@@ -108,6 +100,8 @@ create_winMain (void)
   GtkWidget *journalDeleteLayer;
   GtkWidget *journalFlatten;
   GtkWidget *separator8;
+  GtkWidget *journalRulingParams;
+  GtkWidget *invert_colors;
   GtkWidget *journalPaperSize;
   GtkWidget *journalPaperColor;
   GtkWidget *journalPaperColor_menu;
@@ -401,41 +395,9 @@ create_winMain (void)
   gtk_widget_show (fileRecentFiles);
   gtk_container_add (GTK_CONTAINER (menuFile_menu), fileRecentFiles);
 
-  fileRecentFiles_menu = gtk_menu_new ();
+  fileRecentFiles_menu = gtk_recent_chooser_menu_new_for_manager (gtk_recent_manager_get_default ());
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (fileRecentFiles), fileRecentFiles_menu);
-
-  mru0 = gtk_menu_item_new_with_mnemonic (_("0"));
-  gtk_widget_show (mru0);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru0);
-
-  mru1 = gtk_menu_item_new_with_mnemonic (_("1"));
-  gtk_widget_show (mru1);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru1);
-
-  mru2 = gtk_menu_item_new_with_mnemonic (_("2"));
-  gtk_widget_show (mru2);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru2);
-
-  mru3 = gtk_menu_item_new_with_mnemonic (_("3"));
-  gtk_widget_show (mru3);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru3);
-
-  mru4 = gtk_menu_item_new_with_mnemonic (_("4"));
-  gtk_widget_show (mru4);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru4);
-
-  mru5 = gtk_menu_item_new_with_mnemonic (_("5"));
-  gtk_widget_show (mru5);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru5);
-
-  mru6 = gtk_menu_item_new_with_mnemonic (_("6"));
-  gtk_widget_show (mru6);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru6);
-
-  mru7 = gtk_menu_item_new_with_mnemonic (_("7"));
-  gtk_widget_show (mru7);
-  gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru7);
-
+    
   separator22 = gtk_separator_menu_item_new ();
   gtk_widget_show (separator22);
   gtk_container_add (GTK_CONTAINER (menuFile_menu), separator22);
@@ -711,6 +673,17 @@ create_winMain (void)
   gtk_container_add (GTK_CONTAINER (menuJournal_menu), separator8);
   gtk_widget_set_sensitive (separator8, FALSE);
 
+  journalRulingParams = gtk_menu_item_new_with_mnemonic (_("_Ruling Parameters"));
+  gtk_widget_show (journalRulingParams);
+  gtk_container_add (GTK_CONTAINER (menuJournal_menu), journalRulingParams);
+
+  invert_colors = gtk_menu_item_new_with_mnemonic (_("_Invert Colors (all pages)"));
+  gtk_widget_show (invert_colors);
+  gtk_container_add (GTK_CONTAINER (menuJournal_menu), invert_colors);
+  gtk_widget_add_accelerator (invert_colors, "activate", accel_group,
+                              GDK_I, (GdkModifierType) GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+                              GTK_ACCEL_VISIBLE);
+
   journalPaperSize = gtk_menu_item_new_with_mnemonic (_("Paper Si_ze"));
   gtk_widget_show (journalPaperSize);
   gtk_container_add (GTK_CONTAINER (menuJournal_menu), journalPaperSize);
@@ -947,6 +920,7 @@ create_winMain (void)
   gtk_widget_add_accelerator (toolsHand, "activate", accel_group,
                               GDK_A, (GdkModifierType) GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                               GTK_ACCEL_VISIBLE);
+  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (toolsHand), TRUE);
 
   separator16 = gtk_separator_menu_item_new ();
   gtk_widget_show (separator16);
@@ -1268,6 +1242,7 @@ create_winMain (void)
   button2Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button2Hand));
   gtk_widget_show (button2Hand);
   gtk_container_add (GTK_CONTAINER (button2_mapping_menu), button2Hand);
+  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button2Hand), TRUE);
 
   separator24 = gtk_separator_menu_item_new ();
   gtk_widget_show (separator24);
@@ -1350,6 +1325,7 @@ create_winMain (void)
   button3Pen_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (button3Hand));
   gtk_widget_show (button3Hand);
   gtk_container_add (GTK_CONTAINER (button3_mapping_menu), button3Hand);
+  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (button3Hand), TRUE);
 
   separator25 = gtk_separator_menu_item_new ();
   gtk_widget_show (separator25);
@@ -2003,28 +1979,7 @@ create_winMain (void)
   g_signal_connect ((gpointer) fileSaveAs, "activate",
                     G_CALLBACK (on_fileSaveAs_activate),
                     NULL);
-  g_signal_connect ((gpointer) mru0, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru1, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru2, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru3, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru4, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru5, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru6, "activate",
-                    G_CALLBACK (on_mru_activate),
-                    NULL);
-  g_signal_connect ((gpointer) mru7, "activate",
+  g_signal_connect ((gpointer) fileRecentFiles_menu, "item-activated",
                     G_CALLBACK (on_mru_activate),
                     NULL);
   g_signal_connect ((gpointer) filePrintOptions, "activate",
@@ -2120,6 +2075,12 @@ create_winMain (void)
   g_signal_connect ((gpointer) journalFlatten, "activate",
                     G_CALLBACK (on_journalFlatten_activate),
                     NULL);
+  g_signal_connect ((gpointer) journalRulingParams, "activate",
+                    G_CALLBACK (on_journalRulingParams_activate),
+                    NULL);
+  g_signal_connect ((gpointer) invert_colors, "activate",
+                    G_CALLBACK (on_invert_colors_activate),
+                    NULL);
   g_signal_connect ((gpointer) journalPaperSize, "activate",
                     G_CALLBACK (on_journalPaperSize_activate),
                     NULL);
@@ -2568,14 +2529,6 @@ create_winMain (void)
   GLADE_HOOKUP_OBJECT (winMain, separator1, "separator1");
   GLADE_HOOKUP_OBJECT (winMain, fileRecentFiles, "fileRecentFiles");
   GLADE_HOOKUP_OBJECT (winMain, fileRecentFiles_menu, "fileRecentFiles_menu");
-  GLADE_HOOKUP_OBJECT (winMain, mru0, "mru0");
-  GLADE_HOOKUP_OBJECT (winMain, mru1, "mru1");
-  GLADE_HOOKUP_OBJECT (winMain, mru2, "mru2");
-  GLADE_HOOKUP_OBJECT (winMain, mru3, "mru3");
-  GLADE_HOOKUP_OBJECT (winMain, mru4, "mru4");
-  GLADE_HOOKUP_OBJECT (winMain, mru5, "mru5");
-  GLADE_HOOKUP_OBJECT (winMain, mru6, "mru6");
-  GLADE_HOOKUP_OBJECT (winMain, mru7, "mru7");
   GLADE_HOOKUP_OBJECT (winMain, separator22, "separator22");
   GLADE_HOOKUP_OBJECT (winMain, filePrintOptions, "filePrintOptions");
   GLADE_HOOKUP_OBJECT (winMain, image624, "image624");
@@ -2632,6 +2585,8 @@ create_winMain (void)
   GLADE_HOOKUP_OBJECT (winMain, journalDeleteLayer, "journalDeleteLayer");
   GLADE_HOOKUP_OBJECT (winMain, journalFlatten, "journalFlatten");
   GLADE_HOOKUP_OBJECT (winMain, separator8, "separator8");
+  GLADE_HOOKUP_OBJECT (winMain, journalRulingParams, "journalRulingParams");
+  GLADE_HOOKUP_OBJECT (winMain, invert_colors, "invert_colors");
   GLADE_HOOKUP_OBJECT (winMain, journalPaperSize, "journalPaperSize");
   GLADE_HOOKUP_OBJECT (winMain, journalPaperColor, "journalPaperColor");
   GLADE_HOOKUP_OBJECT (winMain, journalPaperColor_menu, "journalPaperColor_menu");
@@ -3162,3 +3117,227 @@ create_zoomDialog (void)
   return zoomDialog;
 }
 
+GtkWidget*
+create_rulingDialog (void)
+{
+  GtkWidget *rulingDialog;
+  GtkWidget *dialog_vbox4;
+  GtkWidget *hbox5;
+  GtkWidget *table1;
+  GtkWidget *rd_margin_color;
+  GtkWidget *rd_ruling_color;
+  GtkObject *rd_thickness_adj;
+  GtkWidget *rd_thickness;
+  GtkObject *rd_left_margin_adj;
+  GtkWidget *rd_left_margin;
+  GtkObject *rd_top_margin_adj;
+  GtkWidget *rd_top_margin;
+  GtkObject *rd_spacing_adj;
+  GtkWidget *rd_spacing;
+  GtkObject *rd_bottom_margin_adj;
+  GtkWidget *rd_bottom_margin;
+  GtkObject *rd_graph_spacing_adj;
+  GtkWidget *rd_graph_spacing;
+  GtkWidget *label2;
+  GtkWidget *label3;
+  GtkWidget *label4;
+  GtkWidget *label5;
+  GtkWidget *label6;
+  GtkWidget *label7;
+  GtkWidget *label8;
+  GtkWidget *label9;
+  GtkWidget *dialog_action_area4;
+  GtkWidget *cancelbutton3;
+  GtkWidget *okbutton2;
+  GtkTooltips *tooltips;
+
+  tooltips = gtk_tooltips_new ();
+
+  rulingDialog = gtk_dialog_new ();
+  gtk_window_set_title (GTK_WINDOW (rulingDialog), _("Set ruling parameters"));
+  gtk_window_set_type_hint (GTK_WINDOW (rulingDialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+  dialog_vbox4 = GTK_DIALOG (rulingDialog)->vbox;
+  gtk_widget_show (dialog_vbox4);
+
+  hbox5 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox5);
+  gtk_box_pack_start (GTK_BOX (dialog_vbox4), hbox5, TRUE, FALSE, 10);
+
+  table1 = gtk_table_new (8, 2, FALSE);
+  gtk_widget_show (table1);
+  gtk_box_pack_start (GTK_BOX (hbox5), table1, TRUE, FALSE, 10);
+  gtk_table_set_row_spacings (GTK_TABLE (table1), 5);
+  gtk_table_set_col_spacings (GTK_TABLE (table1), 6);
+
+  rd_margin_color = gtk_entry_new ();
+  gtk_widget_show (rd_margin_color);
+  gtk_table_attach (GTK_TABLE (table1), rd_margin_color, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_margin_color, _("RGBA color of the left margin"), NULL);
+  gtk_entry_set_max_length (GTK_ENTRY (rd_margin_color), 8);
+  gtk_entry_set_width_chars (GTK_ENTRY (rd_margin_color), 8);
+
+  rd_ruling_color = gtk_entry_new ();
+  gtk_widget_show (rd_ruling_color);
+  gtk_table_attach (GTK_TABLE (table1), rd_ruling_color, 1, 2, 1, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_ruling_color, _("RGBA color of ruling lines"), NULL);
+  gtk_entry_set_max_length (GTK_ENTRY (rd_ruling_color), 8);
+  gtk_entry_set_width_chars (GTK_ENTRY (rd_ruling_color), 8);
+
+  rd_thickness_adj = gtk_adjustment_new (1, 0, 100, 0.10000000149, 10, 0);
+  rd_thickness = gtk_spin_button_new (GTK_ADJUSTMENT (rd_thickness_adj), 1, 3);
+  gtk_widget_show (rd_thickness);
+  gtk_table_attach (GTK_TABLE (table1), rd_thickness, 1, 2, 2, 3,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_thickness, _("Thickness (points) of ruling lines"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rd_thickness), TRUE);
+
+  rd_left_margin_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 0);
+  rd_left_margin = gtk_spin_button_new (GTK_ADJUSTMENT (rd_left_margin_adj), 1, 3);
+  gtk_widget_show (rd_left_margin);
+  gtk_table_attach (GTK_TABLE (table1), rd_left_margin, 1, 2, 3, 4,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_left_margin, _("Thickness (points) of left margin"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rd_left_margin), TRUE);
+
+  rd_top_margin_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 0);
+  rd_top_margin = gtk_spin_button_new (GTK_ADJUSTMENT (rd_top_margin_adj), 1, 3);
+  gtk_widget_show (rd_top_margin);
+  gtk_table_attach (GTK_TABLE (table1), rd_top_margin, 1, 2, 4, 5,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_top_margin, _("Thickness (points) of top margin"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rd_top_margin), TRUE);
+
+  rd_spacing_adj = gtk_adjustment_new (1, 0, 100, 0.5, 10, 0);
+  rd_spacing = gtk_spin_button_new (GTK_ADJUSTMENT (rd_spacing_adj), 1, 3);
+  gtk_widget_show (rd_spacing);
+  gtk_table_attach (GTK_TABLE (table1), rd_spacing, 1, 2, 5, 6,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_spacing, _("Spacing (points) between lines"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rd_spacing), TRUE);
+
+  rd_bottom_margin_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 0);
+  rd_bottom_margin = gtk_spin_button_new (GTK_ADJUSTMENT (rd_bottom_margin_adj), 1, 3);
+  gtk_widget_show (rd_bottom_margin);
+  gtk_table_attach (GTK_TABLE (table1), rd_bottom_margin, 1, 2, 6, 7,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_bottom_margin, _("Bottom margin (points)"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rd_bottom_margin), TRUE);
+
+  rd_graph_spacing_adj = gtk_adjustment_new (1, 0, 100, 0.10000000149, 10, 0);
+  rd_graph_spacing = gtk_spin_button_new (GTK_ADJUSTMENT (rd_graph_spacing_adj), 1, 3);
+  gtk_widget_show (rd_graph_spacing);
+  gtk_table_attach (GTK_TABLE (table1), rd_graph_spacing, 1, 2, 7, 8,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_tooltips_set_tip (tooltips, rd_graph_spacing, _("Size of graph squares (points). Divide paper dimensions by the number of squares to get this"), NULL);
+  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rd_graph_spacing), TRUE);
+
+  label2 = gtk_label_new (_("Margin color"));
+  gtk_widget_show (label2);
+  gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
+
+  label3 = gtk_label_new (_("Ruling color"));
+  gtk_widget_show (label3);
+  gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 1, 2,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
+
+  label4 = gtk_label_new (_("Thickness"));
+  gtk_widget_show (label4);
+  gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 2, 3,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
+
+  label5 = gtk_label_new (_("Left margin"));
+  gtk_widget_show (label5);
+  gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 3, 4,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5);
+
+  label6 = gtk_label_new (_("Top margin"));
+  gtk_widget_show (label6);
+  gtk_table_attach (GTK_TABLE (table1), label6, 0, 1, 4, 5,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5);
+
+  label7 = gtk_label_new (_("Spacing"));
+  gtk_widget_show (label7);
+  gtk_table_attach (GTK_TABLE (table1), label7, 0, 1, 5, 6,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5);
+
+  label8 = gtk_label_new (_("Bottom margin"));
+  gtk_widget_show (label8);
+  gtk_table_attach (GTK_TABLE (table1), label8, 0, 1, 6, 7,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5);
+
+  label9 = gtk_label_new (_("Graph spacing"));
+  gtk_widget_show (label9);
+  gtk_table_attach (GTK_TABLE (table1), label9, 0, 1, 7, 8,
+                    (GtkAttachOptions) (GTK_EXPAND),
+                    (GtkAttachOptions) (0), 0, 0);
+  gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5);
+
+  dialog_action_area4 = GTK_DIALOG (rulingDialog)->action_area;
+  gtk_widget_show (dialog_action_area4);
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area4), GTK_BUTTONBOX_END);
+
+  cancelbutton3 = gtk_button_new_from_stock ("gtk-cancel");
+  gtk_widget_show (cancelbutton3);
+  gtk_dialog_add_action_widget (GTK_DIALOG (rulingDialog), cancelbutton3, GTK_RESPONSE_CANCEL);
+  GTK_WIDGET_SET_FLAGS (cancelbutton3, GTK_CAN_DEFAULT);
+
+  okbutton2 = gtk_button_new_from_stock ("gtk-ok");
+  gtk_widget_show (okbutton2);
+  gtk_dialog_add_action_widget (GTK_DIALOG (rulingDialog), okbutton2, GTK_RESPONSE_OK);
+  GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT);
+
+  /* Store pointers to all widgets, for use by lookup_widget(). */
+  GLADE_HOOKUP_OBJECT_NO_REF (rulingDialog, rulingDialog, "rulingDialog");
+  GLADE_HOOKUP_OBJECT_NO_REF (rulingDialog, dialog_vbox4, "dialog_vbox4");
+  GLADE_HOOKUP_OBJECT (rulingDialog, hbox5, "hbox5");
+  GLADE_HOOKUP_OBJECT (rulingDialog, table1, "table1");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_margin_color, "rd_margin_color");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_ruling_color, "rd_ruling_color");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_thickness, "rd_thickness");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_left_margin, "rd_left_margin");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_top_margin, "rd_top_margin");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_spacing, "rd_spacing");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_bottom_margin, "rd_bottom_margin");
+  GLADE_HOOKUP_OBJECT (rulingDialog, rd_graph_spacing, "rd_graph_spacing");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label2, "label2");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label3, "label3");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label4, "label4");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label5, "label5");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label6, "label6");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label7, "label7");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label8, "label8");
+  GLADE_HOOKUP_OBJECT (rulingDialog, label9, "label9");
+  GLADE_HOOKUP_OBJECT_NO_REF (rulingDialog, dialog_action_area4, "dialog_action_area4");
+  GLADE_HOOKUP_OBJECT (rulingDialog, cancelbutton3, "cancelbutton3");
+  GLADE_HOOKUP_OBJECT (rulingDialog, okbutton2, "okbutton2");
+  GLADE_HOOKUP_OBJECT_NO_REF (rulingDialog, tooltips, "tooltips");
+
+  return rulingDialog;
+}
+
diff --git a/src/xo-interface.h b/src/xo-interface.h
index 1e86792..d0e04b4 100644
--- a/src/xo-interface.h
+++ b/src/xo-interface.h
@@ -6,3 +6,4 @@ GtkWidget* create_winMain (void);
 GtkWidget* create_papersizeDialog (void);
 GtkWidget* create_aboutDialog (void);
 GtkWidget* create_zoomDialog (void);
+GtkWidget* create_rulingDialog (void);
diff --git a/src/xo-misc.c b/src/xo-misc.c
index 3d866cf..469872a 100644
--- a/src/xo-misc.c
+++ b/src/xo-misc.c
@@ -652,35 +652,35 @@ void update_canvas_bg(struct Page *pg)
     pt = seg->coords;
     if (pg->bg->ruling == RULING_GRAPH) {
       pt[1] = 0; pt[3] = pg->height;
-      for (x=RULING_GRAPHSPACING; x<pg->width-1; x+=RULING_GRAPHSPACING) {
+      for (x=pg->bg->ruling_graphspacing; x<pg->width-1; x+=pg->bg->ruling_graphspacing) {
         pt[0] = pt[2] = x;
         gnome_canvas_item_new(group, gnome_canvas_line_get_type(),
-           "points", seg, "fill-color-rgba", RULING_COLOR,
-           "width-units", RULING_THICKNESS, NULL);
+           "points", seg, "fill-color-rgba", pg->bg->ruling_color,
+           "width-units", pg->bg->ruling_thickness, NULL);
       }      
       pt[0] = 0; pt[2] = pg->width;
-      for (y=RULING_GRAPHSPACING; y<pg->height-1; y+=RULING_GRAPHSPACING) {
+      for (y=pg->bg->ruling_graphspacing; y<pg->height-1; y+=pg->bg->ruling_graphspacing) {
         pt[1] = pt[3] = y;
         gnome_canvas_item_new(group, gnome_canvas_line_get_type(),
-           "points", seg, "fill-color-rgba", RULING_COLOR,
-           "width-units", RULING_THICKNESS, NULL);
+           "points", seg, "fill-color-rgba", pg->bg->ruling_color,
+           "width-units", pg->bg->ruling_thickness, NULL);
       }      
       gnome_canvas_points_free(seg);
       return;
     }
     pt[0] = 0; pt[2] = pg->width;
-    for (y=RULING_TOPMARGIN; y<pg->height-1; y+=RULING_SPACING) {
+    for (y=pg->bg->ruling_topmargin; y<pg->height-1; y+=pg->bg->ruling_spacing) {
       pt[1] = pt[3] = y;
       gnome_canvas_item_new(group, gnome_canvas_line_get_type(),
-         "points", seg, "fill-color-rgba", RULING_COLOR,
-         "width-units", RULING_THICKNESS, NULL);
+         "points", seg, "fill-color-rgba", pg->bg->ruling_color,
+         "width-units", pg->bg->ruling_thickness, NULL);
     }      
     if (pg->bg->ruling == RULING_LINED) {
-      pt[0] = pt[2] = RULING_LEFTMARGIN;
+      pt[0] = pt[2] = pg->bg->ruling_leftmargin;
       pt[1] = 0; pt[3] = pg->height;
       gnome_canvas_item_new(group, gnome_canvas_line_get_type(),
-         "points", seg, "fill-color-rgba", RULING_MARGIN_COLOR,
-         "width-units", RULING_THICKNESS, NULL);
+         "points", seg, "fill-color-rgba", pg->bg->ruling_margin_color,
+         "width-units", pg->bg->ruling_thickness, NULL);
     }
     gnome_canvas_points_free(seg);
     return;
@@ -1283,7 +1283,13 @@ void update_mappings_menu(void)
 
 void do_switch_page(int pg, gboolean rescroll, gboolean refresh_all)
 {
-  int i, cx, cy;
+  do_switch_page_and_scroll(pg, rescroll, refresh_all, 0.0);
+}
+
+void do_switch_page_and_scroll(int pg, gboolean rescroll, gboolean refresh_all, gdouble scroll_pagefraction)
+{
+  int i, cx, cy, visibleheight;
+  GtkAdjustment *adjust;
   struct Layer *layer;
   GList *list;
   
@@ -1308,7 +1314,9 @@ void do_switch_page(int pg, gboolean rescroll, gboolean refresh_all)
     gtk_adjustment_set_value(gtk_layout_get_vadjustment(GTK_LAYOUT(canvas)),
       ui.cur_page->voffset*ui.zoom);  */
     gnome_canvas_get_scroll_offsets(canvas, &cx, &cy);
-    cy = ui.cur_page->voffset*ui.zoom;
+    adjust = gtk_layout_get_vadjustment (GTK_LAYOUT(canvas));
+    visibleheight = gtk_adjustment_get_page_size (adjust);
+    cy = ui.cur_page->voffset*ui.zoom + visibleheight*scroll_pagefraction;
     gnome_canvas_scroll_to(canvas, cx, cy);
     
     if (refresh_all) 
@@ -1320,7 +1328,7 @@ void do_switch_page(int pg, gboolean rescroll, gboolean refresh_all)
 
 void update_page_stuff(void)
 {
-  gchar tmp[10];
+  gchar *tmp;
   GtkComboBox *layerbox;
   int i;
   GList *pglist;
@@ -1367,9 +1375,9 @@ void update_page_stuff(void)
   gtk_spin_button_set_range(spin, 1, journal.npages+1);
     /* npages+1 will be used to create a new page at end */
   gtk_spin_button_set_value(spin, ui.pageno+1);
-  g_snprintf(tmp, 10, _(" of %d"), journal.npages);
+  tmp = g_strdup_printf(_(" of %d"), journal.npages);
   gtk_label_set_text(GTK_LABEL(GET_COMPONENT("labelNumpages")), tmp);
-
+  g_free(tmp);
   layerbox = GTK_COMBO_BOX(GET_COMPONENT("comboLayer"));
   if (ui.layerbox_length == 0) {
     gtk_combo_box_prepend_text(layerbox, _("Background"));
@@ -1380,8 +1388,9 @@ void update_page_stuff(void)
     ui.layerbox_length--;
   }
   while (ui.layerbox_length < ui.cur_page->nlayers+1) {
-    g_snprintf(tmp, 10, _("Layer %d"), ui.layerbox_length++);
+    tmp = g_strdup_printf(_("Layer %d"), ui.layerbox_length++);
     gtk_combo_box_prepend_text(layerbox, tmp);
+    g_free(tmp);
   }
   gtk_combo_box_set_active(layerbox, ui.cur_page->nlayers-1-ui.layerno);
   ui.in_update_page_stuff = FALSE;
@@ -1494,7 +1503,7 @@ void update_toolbar_and_menu(void)
 
 void update_file_name(char *filename)
 {
-  gchar tmp[100], *p;
+  gchar *tmp, *p;
   if (ui.filename != NULL) g_free(ui.filename);
   ui.filename = filename;
   if (filename == NULL) {
@@ -1504,8 +1513,9 @@ void update_file_name(char *filename)
   p = g_utf8_strrchr(filename, -1, '/');
   if (p == NULL) p = filename; 
   else p = g_utf8_next_char(p);
-  g_snprintf(tmp, 100, _("Xournal - %s"), p);
+  tmp = g_strdup_printf( _("%s - Xournal"), p);
   gtk_window_set_title(GTK_WINDOW (winMain), tmp);
+  g_free(tmp);
   new_mru_entry(filename);
 
   if (filename[0]=='/') {
diff --git a/src/xo-misc.h b/src/xo-misc.h
index 617bbda..407df9e 100644
--- a/src/xo-misc.h
+++ b/src/xo-misc.h
@@ -78,7 +78,9 @@ gchar *make_cur_font_name(void);
 void update_font_button(void);
 
 void update_mapping_linkings(int toolno);
+void do_switch_page_and_scroll(int pg, gboolean rescroll, gboolean refresh_all, gdouble scroll_pagefraction);
 void do_switch_page(int pg, gboolean rescroll, gboolean refresh_all);
+
 void set_cur_color(int color_no, guint color_rgba);
 void recolor_temp_text(int color_no, guint color_rgba);
 void process_color_activate(GtkMenuItem *menuitem, int color_no, guint color_rgba);
@@ -134,8 +136,7 @@ wrapper_poppler_page_render_to_pixbuf (PopplerPage *page,
 			       int rotation,
 			       GdkPixbuf *pixbuf);
 
-// defines for paper rulings
-
+// Compiled in defaults for paper rulings
 #define RULING_MARGIN_COLOR 0xff0080ff
 #define RULING_COLOR 0x40a0ffff
 #define RULING_THICKNESS 0.5
@@ -144,3 +145,11 @@ wrapper_poppler_page_render_to_pixbuf (PopplerPage *page,
 #define RULING_SPACING 24.0
 #define RULING_BOTTOMMARGIN RULING_SPACING
 #define RULING_GRAPHSPACING 14.17
+
+// Bounds for page ruling
+#define RULING_THICKNESS_MIN (0.1)
+#define RULING_THICKNESS_MAX (2.0)
+#define RULING_MARGIN_MIN (0.0)
+#define RULING_MARGIN_MAX (216.0)
+#define RULING_SPACING_MIN (6.0)
+#define RULING_SPACING_MAX (96.0)
diff --git a/src/xo-paint.c b/src/xo-paint.c
index c52a97d..fb37964 100644
--- a/src/xo-paint.c
+++ b/src/xo-paint.c
@@ -536,7 +536,6 @@ void finalize_erasure(void)
      is traversed in the forward direction */
 }
 
-
 gboolean do_hand_scrollto(gpointer data)
 {
   ui.hand_scrollto_pending = FALSE;
diff --git a/src/xo-print.c b/src/xo-print.c
index 029500e..942716d 100644
--- a/src/xo-print.c
+++ b/src/xo-print.c
@@ -704,24 +704,24 @@ void pdf_draw_solid_background(struct Page *pg, GString *str)
   if (pg->bg->ruling == RULING_NONE) return;
   g_string_append_printf(str,
     "%.2f %.2f %.2f RG %.2f w ",
-    RGBA_RGB(RULING_COLOR), RULING_THICKNESS);
+    RGBA_RGB(pg->bg->ruling_color), pg->bg->ruling_thickness);
   if (pg->bg->ruling == RULING_GRAPH) {
-    for (x=RULING_GRAPHSPACING; x<pg->width-1; x+=RULING_GRAPHSPACING)
+    for (x=pg->bg->ruling_graphspacing; x<pg->width-1; x+=pg->bg->ruling_graphspacing)
       g_string_append_printf(str, "%.2f 0 m %.2f %.2f l S ",
         x, x, pg->height);
-    for (y=RULING_GRAPHSPACING; y<pg->height-1; y+=RULING_GRAPHSPACING)
+    for (y=pg->bg->ruling_graphspacing; y<pg->height-1; y+=pg->bg->ruling_graphspacing)
       g_string_append_printf(str, "0 %.2f m %.2f %.2f l S ",
         y, pg->width, y);
     return;
   }
-  for (y=RULING_TOPMARGIN; y<pg->height-1; y+=RULING_SPACING)
+  for (y=pg->bg->ruling_topmargin; y<pg->height-1; y+=pg->bg->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);
+      RGBA_RGB(pg->bg->ruling_margin_color), 
+      pg->bg->ruling_leftmargin, pg->bg->ruling_leftmargin, pg->height);
 }
 
 int pdf_draw_bitmap_background(struct Page *pg, GString *str, 
@@ -1571,25 +1571,25 @@ void print_background(cairo_t *cr, struct Page *pg)
     cairo_fill(cr);
     if (!ui.print_ruling) return;
     if (pg->bg->ruling == RULING_NONE) return;
-    cairo_set_source_rgb(cr, RGBA_RGB(RULING_COLOR));
-    cairo_set_line_width(cr, RULING_THICKNESS);
+    cairo_set_source_rgb(cr, RGBA_RGB(pg->bg->ruling_color));
+    cairo_set_line_width(cr, pg->bg->ruling_thickness);
 
     if (pg->bg->ruling == RULING_GRAPH) {
-      for (x=RULING_GRAPHSPACING; x<pg->width-1; x+=RULING_GRAPHSPACING)
+      for (x=pg->bg->ruling_graphspacing; x<pg->width-1; x+=pg->bg->ruling_graphspacing)
         { cairo_move_to(cr, x, 0); cairo_line_to(cr, x, pg->height); }
-      for (y=RULING_GRAPHSPACING; y<pg->height-1; y+=RULING_GRAPHSPACING)
+      for (y=pg->bg->ruling_graphspacing; y<pg->height-1; y+=pg->bg->ruling_graphspacing)
         { cairo_move_to(cr, 0, y); cairo_line_to(cr, pg->width, y); }
       cairo_stroke(cr);
       return;
     }
     
-    for (y=RULING_TOPMARGIN; y<pg->height-1; y+=RULING_SPACING)
+    for (y=pg->bg->ruling_topmargin; y<pg->height-1; y+=pg->bg->ruling_spacing)
       { cairo_move_to(cr, 0, y); cairo_line_to(cr, pg->width, y); }
     cairo_stroke(cr);
     if (pg->bg->ruling == RULING_LINED) {
-      cairo_set_source_rgb(cr, RGBA_RGB(RULING_MARGIN_COLOR));
-      cairo_move_to(cr, RULING_LEFTMARGIN, 0);
-      cairo_line_to(cr, RULING_LEFTMARGIN, pg->height);
+      cairo_set_source_rgb(cr, RGBA_RGB(pg->bg->ruling_margin_color));
+      cairo_move_to(cr, pg->bg->ruling_leftmargin, 0);
+      cairo_line_to(cr, pg->bg->ruling_leftmargin, pg->height);
       cairo_stroke(cr);
     }
     return;
diff --git a/src/xo-selection.c b/src/xo-selection.c
index 5816bb6..118b3bb 100644
--- a/src/xo-selection.c
+++ b/src/xo-selection.c
@@ -76,7 +76,7 @@ void finalize_selectrect(void)
   double x1, x2, y1, y2;
   GList *itemlist;
   struct Item *item;
-  
+
   ui.cur_item_type = ITEM_NONE;
 
   if (ui.selection->bbox.left > ui.selection->bbox.right) {
@@ -120,7 +120,6 @@ void finalize_selectrect(void)
   update_font_button();
 }
 
-
 void start_selectregion(GdkEvent *event)
 {
   double pt[2];
@@ -338,6 +337,12 @@ gboolean start_resizesel(GdkEvent *event)
     ui.selection->new_x2 = ui.selection->bbox.right;
     gnome_canvas_item_set(ui.selection->canvas_item, "dash", NULL, NULL);
     update_cursor_for_resize(pt);
+
+    // Check whether we should preserve the aspect ratio
+    if (event->button.button == 3)
+    	ui.cur_brush->tool_options |= TOOLOPT_SELECT_PRESERVE;
+    else
+    	ui.cur_brush->tool_options &= ~TOOLOPT_SELECT_PRESERVE;
     return TRUE;
   }
   return FALSE;
@@ -469,6 +474,38 @@ void continue_resizesel(GdkEvent *event)
   if (ui.selection->resizing_left) ui.selection->new_x1 = pt[0];
   if (ui.selection->resizing_right) ui.selection->new_x2 = pt[0];
 
+  if (ui.cur_brush->tool_options & TOOLOPT_SELECT_PRESERVE) {
+	  double aspectratio = (ui.selection->bbox.top - ui.selection->bbox.bottom)/(ui.selection->bbox.right - ui.selection->bbox.left);
+	  double newheight = ui.selection->new_y1 - ui.selection->new_y2;
+	  double newwidth = ui.selection->new_x2 - ui.selection->new_x1;
+	  gboolean boundheight;
+
+	  // Resizing from top or bottom only
+	  if ((ui.selection->resizing_top || ui.selection->resizing_bottom) && !(ui.selection->resizing_left || ui.selection->resizing_right))
+		  boundheight = 0;
+	  // Resizing from right or left only
+	  else if (!(ui.selection->resizing_top || ui.selection->resizing_bottom) && (ui.selection->resizing_left || ui.selection->resizing_right))
+		  boundheight = 1;
+	  // Resizing from a corner
+	  else if (newheight/aspectratio > newwidth)
+		  boundheight = 0;
+	  else
+		  boundheight = 1;
+
+	  if (boundheight) {
+		  // Bound the height
+		  newheight = newwidth*aspectratio;
+		  if (ui.selection->resizing_top) ui.selection->new_y1 = ui.selection->new_y2 + newheight;
+		  else ui.selection->new_y2 = ui.selection->new_y1 - newheight;
+	  }
+	  else {
+		  // Bound the width
+		  newwidth = newheight/aspectratio;
+		  if (ui.selection->resizing_left) ui.selection->new_x1 = ui.selection->new_x2 - newwidth;
+		  else ui.selection->new_x2 = ui.selection->new_x1 + newwidth;
+	  }
+  }
+
   gnome_canvas_item_set(ui.selection->canvas_item, 
     "x1", ui.selection->new_x1, "x2", ui.selection->new_x2,
     "y1", ui.selection->new_y1, "y2", ui.selection->new_y2, NULL);
diff --git a/src/xournal.h b/src/xournal.h
index 9d9064e..cad5468 100644
--- a/src/xournal.h
+++ b/src/xournal.h
@@ -86,6 +86,15 @@ typedef struct Background {
   double pixbuf_scale; // for PIXMAP, this is the *current* zoom value
                        // for PDF, this is the *requested* zoom value
   int pixel_height, pixel_width; // PDF only: pixel size of current pixbuf
+
+  guint ruling_margin_color;
+  guint ruling_color;
+  double ruling_thickness;
+  double ruling_leftmargin;
+  double ruling_topmargin;
+  double ruling_spacing;
+  double ruling_bottommargin;
+  double ruling_graphspacing;
 } Background;
 
 #define BG_SOLID 0
@@ -151,6 +160,7 @@ extern guint predef_bgcolors_rgba[COLOR_MAX];
 #define TOOLOPT_ERASER_STANDARD     0
 #define TOOLOPT_ERASER_WHITEOUT     1
 #define TOOLOPT_ERASER_STROKES      2
+#define TOOLOPT_SELECT_PRESERVE     1 // Preserve the aspect ratio of the selection when resizing
 
 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];
 
@@ -289,8 +299,6 @@ typedef struct UIData {
   GdkCursor *cursor;
   gboolean progressive_bg; // update PDF bg's one at a time
   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 ?
diff --git a/xournal.glade b/xournal.glade
index 1dacfe5..5bcf327 100644
--- a/xournal.glade
+++ b/xournal.glade
@@ -58,7 +58,7 @@
 		      <signal name="activate" handler="on_fileNewBackground_activate" last_modification_time="Wed, 30 Nov 2005 18:39:59 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image623">
+			<widget class="GtkImage" id="image656">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-open</property>
 			  <property name="icon_size">1</property>
@@ -203,7 +203,7 @@
 		      <signal name="activate" handler="on_filePrintOptions_activate" last_modification_time="Wed, 30 Nov 2005 18:44:18 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image624">
+			<widget class="GtkImage" id="image657">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-preferences</property>
 			  <property name="icon_size">1</property>
@@ -432,7 +432,7 @@
 			      <accelerator key="equal" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
 			      <child internal-child="image">
-				<widget class="GtkImage" id="image625">
+				<widget class="GtkImage" id="image658">
 				  <property name="visible">True</property>
 				  <property name="stock">gtk-zoom-fit</property>
 				  <property name="icon_size">1</property>
@@ -473,7 +473,7 @@
 		      <accelerator key="Home" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image626">
+			<widget class="GtkImage" id="image659">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-goto-first</property>
 			  <property name="icon_size">1</property>
@@ -495,7 +495,7 @@
 		      <accelerator key="Left" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image627">
+			<widget class="GtkImage" id="image660">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-go-back</property>
 			  <property name="icon_size">1</property>
@@ -517,7 +517,7 @@
 		      <accelerator key="Right" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image628">
+			<widget class="GtkImage" id="image661">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-go-forward</property>
 			  <property name="icon_size">1</property>
@@ -539,7 +539,7 @@
 		      <accelerator key="End" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image629">
+			<widget class="GtkImage" id="image662">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-goto-last</property>
 			  <property name="icon_size">1</property>
@@ -566,7 +566,7 @@
 		      <signal name="activate" handler="on_viewShowLayer_activate" last_modification_time="Wed, 30 Nov 2005 19:40:23 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image630">
+			<widget class="GtkImage" id="image663">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-add</property>
 			  <property name="icon_size">1</property>
@@ -587,7 +587,7 @@
 		      <signal name="activate" handler="on_viewHideLayer_activate" last_modification_time="Wed, 30 Nov 2005 19:40:23 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image631">
+			<widget class="GtkImage" id="image664">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-remove</property>
 			  <property name="icon_size">1</property>
@@ -689,6 +689,25 @@
 		  </child>
 
 		  <child>
+		    <widget class="GtkMenuItem" id="journalRulingParams">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_Ruling Parameters</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="on_journalRulingParams_activate" last_modification_time="Sun, 29 Nov 2009 06:11:08 GMT"/>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkMenuItem" id="invert_colors">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_Invert Colors (all pages)</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="on_invert_colors_activate" last_modification_time="Sat, 26 Dec 2009 23:44:59 GMT"/>
+		      <accelerator key="I" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
+		    </widget>
+		  </child>
+
+		  <child>
 		    <widget class="GtkMenuItem" id="journalPaperSize">
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes">Paper Si_ze</property>
@@ -882,7 +901,7 @@
 		      <signal name="activate" handler="on_journalLoadBackground_activate" last_modification_time="Wed, 30 Nov 2005 20:06:31 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image632">
+			<widget class="GtkImage" id="image665">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-open</property>
 			  <property name="icon_size">1</property>
@@ -1075,7 +1094,7 @@
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes">H_and Tool</property>
 		      <property name="use_underline">True</property>
-		      <property name="active">False</property>
+		      <property name="active">True</property>
 		      <property name="group">toolsPen</property>
 		      <signal name="activate" handler="on_toolsHand_activate" last_modification_time="Wed, 20 Sep 2006 02:20:48 GMT"/>
 		      <accelerator key="A" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
@@ -1095,7 +1114,7 @@
 		      <property name="use_underline">True</property>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image633">
+			<widget class="GtkImage" id="image666">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-select-color</property>
 			  <property name="icon_size">1</property>
@@ -1461,7 +1480,7 @@
 		      <accelerator key="F" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image634">
+			<widget class="GtkImage" id="image667">
 			  <property name="visible">True</property>
 			  <property name="stock">gtk-select-font</property>
 			  <property name="icon_size">1</property>
@@ -1669,7 +1688,7 @@
 			      <property name="visible">True</property>
 			      <property name="label" translatable="yes">H_and Tool</property>
 			      <property name="use_underline">True</property>
-			      <property name="active">False</property>
+			      <property name="active">True</property>
 			      <property name="group">button2Pen</property>
 			      <signal name="activate" handler="on_button2Hand_activate" last_modification_time="Wed, 20 Sep 2006 02:20:48 GMT"/>
 			    </widget>
@@ -1816,7 +1835,7 @@
 			      <property name="visible">True</property>
 			      <property name="label" translatable="yes">H_and Tool</property>
 			      <property name="use_underline">True</property>
-			      <property name="active">False</property>
+			      <property name="active">True</property>
 			      <property name="group">button3Pen</property>
 			      <signal name="activate" handler="on_button3Hand_activate" last_modification_time="Wed, 20 Sep 2006 02:20:48 GMT"/>
 			    </widget>
@@ -3874,4 +3893,508 @@ and other contributors
   </child>
 </widget>
 
+<widget class="GtkDialog" id="rulingDialog">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Set ruling parameters</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox4">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="dialog-action_area4">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="cancelbutton3">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-cancel</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-6</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="okbutton2">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-ok</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkHBox" id="hbox5">
+	  <property name="visible">True</property>
+	  <property name="homogeneous">False</property>
+	  <property name="spacing">0</property>
+
+	  <child>
+	    <widget class="GtkTable" id="table1">
+	      <property name="visible">True</property>
+	      <property name="n_rows">8</property>
+	      <property name="n_columns">2</property>
+	      <property name="homogeneous">False</property>
+	      <property name="row_spacing">5</property>
+	      <property name="column_spacing">6</property>
+
+	      <child>
+		<widget class="GtkEntry" id="rd_margin_color">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">RGBA color of the left margin</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">True</property>
+		  <property name="max_length">8</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</property>
+		  <property name="invisible_char">*</property>
+		  <property name="activates_default">False</property>
+		  <property name="width_chars">8</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkEntry" id="rd_ruling_color">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">RGBA color of ruling lines</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">True</property>
+		  <property name="max_length">8</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</property>
+		  <property name="invisible_char">*</property>
+		  <property name="activates_default">False</property>
+		  <property name="width_chars">8</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkSpinButton" id="rd_thickness">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Thickness (points) of ruling lines</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">3</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">False</property>
+		  <property name="adjustment">1 0 100 0.10000000149 10 0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkSpinButton" id="rd_left_margin">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Thickness (points) of left margin</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">3</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">False</property>
+		  <property name="adjustment">1 0 100 1 10 0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">3</property>
+		  <property name="bottom_attach">4</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkSpinButton" id="rd_top_margin">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Thickness (points) of top margin</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">3</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">False</property>
+		  <property name="adjustment">1 0 100 1 10 0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">4</property>
+		  <property name="bottom_attach">5</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkSpinButton" id="rd_spacing">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Spacing (points) between lines</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">3</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">False</property>
+		  <property name="adjustment">1 0 100 0.5 10 0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">5</property>
+		  <property name="bottom_attach">6</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkSpinButton" id="rd_bottom_margin">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Bottom margin (points)</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">3</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">False</property>
+		  <property name="adjustment">1 0 100 1 10 0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkSpinButton" id="rd_graph_spacing">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">Size of graph squares (points). Divide paper dimensions by the number of squares to get this</property>
+		  <property name="can_focus">True</property>
+		  <property name="climb_rate">1</property>
+		  <property name="digits">3</property>
+		  <property name="numeric">True</property>
+		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+		  <property name="snap_to_ticks">False</property>
+		  <property name="wrap">False</property>
+		  <property name="adjustment">1 0 100 0.10000000149 10 0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">7</property>
+		  <property name="bottom_attach">8</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label2">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Margin color</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label3">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Ruling color</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label4">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Thickness</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label5">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Left margin</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">3</property>
+		  <property name="bottom_attach">4</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label6">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Top margin</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">4</property>
+		  <property name="bottom_attach">5</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label7">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Spacing</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">5</property>
+		  <property name="bottom_attach">6</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label8">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Bottom margin</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label9">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Graph spacing</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">7</property>
+		  <property name="bottom_attach">8</property>
+		  <property name="x_options">expand</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">10</property>
+	      <property name="expand">True</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">10</property>
+	  <property name="expand">True</property>
+	  <property name="fill">False</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
