]> git.donarmstrong.com Git - xournal.git/blobdiff - src/xo-misc.c
Add internationalization support.
[xournal.git] / src / xo-misc.c
index 619ab17ca1eac3811b11a6f378b88986c89e6552..0d4abc2e01fbec3358b5641ff319d040eb020b29 100644 (file)
@@ -15,6 +15,7 @@
 #include "xo-misc.h"
 #include "xo-file.h"
 #include "xo-paint.h"
+#include "xo-shapes.h"
 
 // some global constants
 
@@ -95,6 +96,13 @@ void realloc_cur_path(int n)
   ui.cur_path.coords = g_realloc(ui.cur_path.coords, 2*(n+10)*sizeof(double));
 }
 
+void realloc_cur_widths(int n)
+{
+  if (n <= ui.cur_widths_storage_alloc) return;
+  ui.cur_widths_storage_alloc = n+10;
+  ui.cur_widths = g_realloc(ui.cur_widths, (n+10)*sizeof(double));
+}
+
 // undo utility functions
 
 void prepare_new_undo(void)
@@ -124,6 +132,7 @@ void clear_redo_stack(void)
   while (redo!=NULL) {
     if (redo->type == ITEM_STROKE) {
       gnome_canvas_points_free(redo->item->path);
+      if (redo->item->brush.variable_width) g_free(redo->item->widths);
       g_free(redo->item);
       /* the strokes are unmapped, so there are no associated canvas items */
     }
@@ -132,12 +141,13 @@ void clear_redo_stack(void)
       g_free(redo->item->font_name);
       g_free(redo->item);
     }
-    else if (redo->type == ITEM_ERASURE) {
+    else if (redo->type == ITEM_ERASURE || redo->type == ITEM_RECOGNIZER) {
       for (list = redo->erasurelist; list!=NULL; list=list->next) {
         erasure = (struct UndoErasureData *)list->data;
         for (repl = erasure->replacement_items; repl!=NULL; repl=repl->next) {
           it = (struct Item *)repl->data;
           gnome_canvas_points_free(it->path);
+          if (it->brush.variable_width) g_free(it->widths);
           g_free(it);
         }
         g_list_free(erasure->replacement_items);
@@ -160,10 +170,16 @@ void clear_redo_stack(void)
     else if (redo->type == ITEM_MOVESEL || redo->type == ITEM_REPAINTSEL) {
       g_list_free(redo->itemlist); g_list_free(redo->auxlist);
     }
+    else if (redo->type == ITEM_RESIZESEL) {
+      g_list_free(redo->itemlist);
+    }
     else if (redo->type == ITEM_PASTE) {
       for (list = redo->itemlist; list!=NULL; list=list->next) {
         it = (struct Item *)list->data;
-        if (it->type == ITEM_STROKE) gnome_canvas_points_free(it->path);
+        if (it->type == ITEM_STROKE) {
+          gnome_canvas_points_free(it->path);
+          if (it->brush.variable_width) g_free(it->widths);
+        }
         g_free(it);
       }
       g_list_free(redo->itemlist);
@@ -192,11 +208,13 @@ void clear_undo_stack(void)
   while (undo!=NULL) {
     // for strokes, items are already in the journal, so we don't free them
     // for erasures, we need to free the dead items
-    if (undo->type == ITEM_ERASURE) {
+    if (undo->type == ITEM_ERASURE || undo->type == ITEM_RECOGNIZER) {
       for (list = undo->erasurelist; list!=NULL; list=list->next) {
         erasure = (struct UndoErasureData *)list->data;
-        if (erasure->item->type == ITEM_STROKE)
+        if (erasure->item->type == ITEM_STROKE) {
           gnome_canvas_points_free(erasure->item->path);
+          if (erasure->item->brush.variable_width) g_free(erasure->item->widths);
+        }
         if (erasure->item->type == ITEM_TEXT)
           { g_free(erasure->item->text); g_free(erasure->item->font_name); }
         g_free(erasure->item);
@@ -216,6 +234,9 @@ void clear_undo_stack(void)
     else if (undo->type == ITEM_MOVESEL || undo->type == ITEM_REPAINTSEL) {
       g_list_free(undo->itemlist); g_list_free(undo->auxlist);
     }
+    else if (undo->type == ITEM_RESIZESEL) {
+      g_list_free(undo->itemlist);
+    }
     else if (undo->type == ITEM_PASTE) {
       g_list_free(undo->itemlist);
     }
@@ -330,10 +351,9 @@ void get_pointer_coords(GdkEvent *event, gdouble *ret)
 
 void fix_xinput_coords(GdkEvent *event)
 {
-#ifdef ENABLE_XINPUT_BUGFIX
   double *axes, *px, *py, axis_width;
   GdkDevice *device;
-  int wx, wy, sx, sy;
+  int wx, wy, sx, sy, ix, iy;
 
   if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) {
     axes = event->button.axes;
@@ -348,22 +368,41 @@ void fix_xinput_coords(GdkEvent *event)
     device = event->motion.device;
   }
   else return; // nothing we know how to do
-  
-  gdk_window_get_origin(event->any.window, &wx, &wy);
-  // somehow, behavior changed starting with GTK+ 2.11.0
-  if (!gtk_check_version(2, 11, 0)) sx = sy = 0;
-  else gnome_canvas_get_scroll_offsets(canvas, &sx, &sy);
-  
-  axis_width = device->axes[0].max - device->axes[0].min;
-  if (axis_width>EPSILON)
-    *px = (axes[0]/axis_width)*ui.screen_width + sx - wx;
 
-  axis_width = device->axes[1].max - device->axes[1].min;
-  if (axis_width>EPSILON)
-    *py = (axes[1]/axis_width)*ui.screen_height + sy - wy;
+  // use canvas window, not event window (else get GTK+ 2.11 bugs!)            
+  gdk_window_get_origin(GTK_WIDGET(canvas)->window, &wx, &wy);  
+  gnome_canvas_get_scroll_offsets(canvas, &sx, &sy);
+
+#ifdef ENABLE_XINPUT_BUGFIX
+  // fix broken events with the core pointer's location
+  if (!finite(axes[0]) || !finite(axes[1]) || (axes[0]==0. && axes[1]==0.)) {
+    gdk_window_get_pointer(GTK_WIDGET(canvas)->window, &ix, &iy, NULL);
+    *px = ix + sx; 
+    *py = iy + sy;
+  }
+  else {
+    axis_width = device->axes[0].max - device->axes[0].min;
+    if (axis_width>EPSILON)
+      *px = (axes[0]/axis_width)*ui.screen_width + sx - wx;
+    axis_width = device->axes[1].max - device->axes[1].min;
+    if (axis_width>EPSILON)
+      *py = (axes[1]/axis_width)*ui.screen_height + sy - wy;
+  }
 #endif
 }
 
+double get_pressure_multiplier(GdkEvent *event)
+{
+  double rawpressure;
+  
+  if (event->button.device == gdk_device_get_core_pointer()
+      || event->button.device->num_axes <= 2) return 1.0;
+
+  rawpressure = event->button.axes[2]/(event->button.device->axes[2].max - event->button.device->axes[2].min);
+
+  return ((1-rawpressure)*ui.width_minimum_multiplier + rawpressure*ui.width_maximum_multiplier);
+}
+
 void update_item_bbox(struct Item *item)
 {
   int i;
@@ -404,15 +443,32 @@ void make_page_clipbox(struct Page *pg)
 
 void make_canvas_item_one(GnomeCanvasGroup *group, struct Item *item)
 {
-  GnomeCanvasItem *i;
   PangoFontDescription *font_desc;
+  GnomeCanvasPoints points;
+  int j;
 
-  if (item->type == ITEM_STROKE)
-    item->canvas_item = gnome_canvas_item_new(group,
-          gnome_canvas_line_get_type(), "points", item->path,   
-          "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND,
-          "fill-color-rgba", item->brush.color_rgba,  
-          "width-units", item->brush.thickness, NULL);
+  if (item->type == ITEM_STROKE) {
+    if (!item->brush.variable_width)
+      item->canvas_item = gnome_canvas_item_new(group,
+            gnome_canvas_line_get_type(), "points", item->path,   
+            "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND,
+            "fill-color-rgba", item->brush.color_rgba,  
+            "width-units", item->brush.thickness, NULL);
+    else {
+      item->canvas_item = gnome_canvas_item_new(group,
+            gnome_canvas_group_get_type(), NULL);
+      points.num_points = 2;
+      points.ref_count = 1;
+      for (j = 0; j < item->path->num_points-1; j++) {
+        points.coords = item->path->coords+2*j;
+        gnome_canvas_item_new((GnomeCanvasGroup *) item->canvas_item,
+              gnome_canvas_line_get_type(), "points", &points, 
+              "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND, 
+              "fill-color-rgba", item->brush.color_rgba,
+              "width-units", item->widths[j], NULL);
+      }
+    }
+  }
   if (item->type == ITEM_TEXT) {
     font_desc = pango_font_description_from_string(item->font_name);
     pango_font_description_set_absolute_size(font_desc, 
@@ -463,6 +519,7 @@ void update_canvas_bg(struct Page *pg)
   double *pt;
   double x, y;
   int w, h;
+  gboolean is_well_scaled;
   
   if (pg->bg->canvas_item != NULL)
     gtk_object_destroy(GTK_OBJECT(pg->bg->canvas_item));
@@ -547,15 +604,23 @@ void update_canvas_bg(struct Page *pg)
   if (pg->bg->type == BG_PDF)
   {
     if (pg->bg->pixbuf == NULL) return;
-    pg->bg->canvas_item = gnome_canvas_item_new(pg->group, 
-        gnome_canvas_pixbuf_get_type(), 
-        "pixbuf", pg->bg->pixbuf,
-        "width", pg->width, "height", pg->height, 
-        "width-set", TRUE, "height-set", TRUE, 
-        NULL);
+    is_well_scaled = (fabs(pg->bg->pixel_width - pg->width*ui.zoom) < 2.
+                   && fabs(pg->bg->pixel_height - pg->height*ui.zoom) < 2.);
+    if (is_well_scaled)
+      pg->bg->canvas_item = gnome_canvas_item_new(pg->group, 
+          gnome_canvas_pixbuf_get_type(), 
+          "pixbuf", pg->bg->pixbuf,
+          "width-in-pixels", TRUE, "height-in-pixels", TRUE, 
+          NULL);
+    else
+      pg->bg->canvas_item = gnome_canvas_item_new(pg->group, 
+          gnome_canvas_pixbuf_get_type(), 
+          "pixbuf", pg->bg->pixbuf,
+          "width", pg->width, "height", pg->height, 
+          "width-set", TRUE, "height-set", TRUE, 
+          NULL);
     lower_canvas_item_to(pg->group, pg->bg->canvas_item, NULL);
   }
-
 }
 
 gboolean is_visible(struct Page *pg)
@@ -575,6 +640,8 @@ void rescale_bg_pixmaps(void)
   GList *pglist;
   struct Page *pg;
   GdkPixbuf *pix;
+  gboolean is_well_scaled;
+  gdouble zoom_to_request;
   
   for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) {
     pg = (struct Page *)pglist->data;
@@ -600,10 +667,24 @@ void rescale_bg_pixmaps(void)
         pg->bg->pixbuf_scale = 0;
       }
     }
-    if (pg->bg->type == BG_PDF) { // request an asynchronous update
-      if (pg->bg->pixbuf_scale == ui.zoom) continue;
-      add_bgpdf_request(pg->bg->file_page_seq, ui.zoom, FALSE);
-      pg->bg->pixbuf_scale = ui.zoom;
+    if (pg->bg->type == BG_PDF) { 
+      // make pixmap scale to correct size if current one is wrong
+      is_well_scaled = (fabs(pg->bg->pixel_width - pg->width*ui.zoom) < 2.
+                     && fabs(pg->bg->pixel_height - pg->height*ui.zoom) < 2.);
+      if (pg->bg->canvas_item != NULL && !is_well_scaled) {
+        g_object_get(pg->bg->canvas_item, "width-in-pixels", &is_well_scaled, NULL);
+        if (is_well_scaled)
+          gnome_canvas_item_set(pg->bg->canvas_item,
+            "width", pg->width, "height", pg->height, 
+            "width-in-pixels", FALSE, "height-in-pixels", FALSE, 
+            "width-set", TRUE, "height-set", TRUE, 
+            NULL);
+      }
+      // request an asynchronous update to a better pixmap if needed
+      zoom_to_request = MIN(ui.zoom, MAX_SAFE_RENDER_DPI/72.0);
+      if (pg->bg->pixbuf_scale == zoom_to_request) continue;
+      add_bgpdf_request(pg->bg->file_page_seq, zoom_to_request);
+      pg->bg->pixbuf_scale = zoom_to_request;
     }
   }
 }
@@ -766,7 +847,12 @@ void update_tool_buttons(void)
   }
     
   gtk_toggle_tool_button_set_active(
-    GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonRuler")), ui.ruler[ui.cur_mapping]);
+      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonRuler")), 
+      ui.toolno[ui.cur_mapping]<NUM_STROKE_TOOLS && ui.cur_brush->ruler);
+  gtk_toggle_tool_button_set_active(
+      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonReco")), 
+      ui.toolno[ui.cur_mapping]<NUM_STROKE_TOOLS && ui.cur_brush->recognizer);
+
   update_thickness_buttons();
   update_color_buttons();
 }
@@ -809,15 +895,27 @@ void update_tool_menu(void)
   }
 
   gtk_check_menu_item_set_active(
-    GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsRuler")), ui.ruler[0]);
+      GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsRuler")), 
+      ui.toolno[0]<NUM_STROKE_TOOLS && ui.brushes[0][ui.toolno[0]].ruler);
+  gtk_check_menu_item_set_active(
+      GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsReco")), 
+      ui.toolno[0]<NUM_STROKE_TOOLS && ui.brushes[0][ui.toolno[0]].recognizer);
 }
 
 void update_ruler_indicator(void)
 {
   gtk_toggle_tool_button_set_active(
-    GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonRuler")), ui.ruler[ui.cur_mapping]);
+      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonRuler")), 
+      ui.toolno[ui.cur_mapping]<NUM_STROKE_TOOLS && ui.cur_brush->ruler);
+  gtk_toggle_tool_button_set_active(
+      GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonReco")), 
+      ui.toolno[ui.cur_mapping]<NUM_STROKE_TOOLS && ui.cur_brush->recognizer);
   gtk_check_menu_item_set_active(
-    GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsRuler")), ui.ruler[0]);
+      GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsRuler")), 
+      ui.toolno[0]<NUM_STROKE_TOOLS && ui.brushes[0][ui.toolno[0]].ruler);
+  gtk_check_menu_item_set_active(
+      GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsReco")), 
+      ui.toolno[0]<NUM_STROKE_TOOLS && ui.brushes[0][ui.toolno[0]].recognizer);
 }
 
 void update_color_menu(void)
@@ -985,12 +1083,14 @@ void update_mappings_menu_linkings(void)
 void update_mappings_menu(void)
 {
   gtk_widget_set_sensitive(GET_COMPONENT("optionsButtonMappings"), ui.use_xinput);
-  gtk_widget_set_sensitive(GET_COMPONENT("optionsDiscardCoreEvents"), 
-    ui.use_xinput && (gtk_check_version(2, 11, 0)!=NULL));
+  gtk_widget_set_sensitive(GET_COMPONENT("optionsDiscardCoreEvents"), ui.use_xinput);
+  gtk_widget_set_sensitive(GET_COMPONENT("optionsPressureSensitive"), ui.use_xinput);
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsButtonMappings")), ui.use_erasertip);
   gtk_check_menu_item_set_active(
     GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsDiscardCoreEvents")), ui.discard_corepointer);
+  gtk_check_menu_item_set_active(
+    GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPressureSensitive")), ui.pressure_sensitivity);
 
   switch(ui.toolno[1]) {
     case TOOL_PEN:
@@ -1101,8 +1201,6 @@ void update_page_stuff(void)
   GtkSpinButton *spin;
   struct Page *pg;
   double vertpos, maxwidth;
-  struct Layer *layer;
-  int relscroll;
 
   // move the page groups to their rightful locations or hide them
   if (ui.view_continuous) {
@@ -1143,12 +1241,12 @@ 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);
+  g_snprintf(tmp, 10, _(" of %d"), journal.npages);
   gtk_label_set_text(GTK_LABEL(GET_COMPONENT("labelNumpages")), tmp);
 
   layerbox = GTK_COMBO_BOX(GET_COMPONENT("comboLayer"));
   if (ui.layerbox_length == 0) {
-    gtk_combo_box_prepend_text(layerbox, "Background");
+    gtk_combo_box_prepend_text(layerbox, _("Background"));
     ui.layerbox_length++;
   }
   while (ui.layerbox_length > ui.cur_page->nlayers+1) {
@@ -1156,7 +1254,7 @@ 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++);
+    g_snprintf(tmp, 10, _("Layer %d"), ui.layerbox_length++);
     gtk_combo_box_prepend_text(layerbox, tmp);
   }
   gtk_combo_box_set_active(layerbox, ui.cur_page->nlayers-1-ui.layerno);
@@ -1272,13 +1370,13 @@ void update_file_name(char *filename)
   if (ui.filename != NULL) g_free(ui.filename);
   ui.filename = filename;
   if (filename == NULL) {
-    gtk_window_set_title(GTK_WINDOW (winMain), "Xournal");
+    gtk_window_set_title(GTK_WINDOW (winMain), _("Xournal"));
     return;
   }
   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);
+  g_snprintf(tmp, 100, _("Xournal - %s"), p);
   gtk_window_set_title(GTK_WINDOW (winMain), tmp);
   new_mru_entry(filename);
 }
@@ -1310,9 +1408,6 @@ void update_mapping_linkings(int toolno)
     if (ui.linked_brush[i] == BRUSH_LINKED) {
       if (toolno >= 0 && toolno < NUM_STROKE_TOOLS)
         g_memmove(&(ui.brushes[i][toolno]), &(ui.brushes[0][toolno]), sizeof(struct Brush));
-      ui.ruler[i] = ui.ruler[0];
-      if (ui.toolno[i]!=TOOL_PEN && ui.toolno[i]!=TOOL_HIGHLIGHTER)
-        ui.ruler[i] = FALSE;
     }
     if (ui.linked_brush[i] == BRUSH_COPIED && toolno == ui.toolno[i]) {
       ui.linked_brush[i] = BRUSH_STATIC;
@@ -1511,12 +1606,11 @@ gboolean ok_to_close(void)
 {
   GtkWidget *dialog;
   GtkResponseType response;
-  GList *pagelist;
 
   if (ui.saved) return TRUE;
   dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
-    GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, "Save changes to '%s'?",
-    (ui.filename!=NULL) ? ui.filename:"Untitled");
+    GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, _("Save changes to '%s'?"),
+    (ui.filename!=NULL) ? ui.filename:_("Untitled"));
   gtk_dialog_add_button(GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
   response = gtk_dialog_run(GTK_DIALOG (dialog));
   gtk_widget_destroy(dialog);
@@ -1529,12 +1623,6 @@ gboolean ok_to_close(void)
   return TRUE;
 }
 
-// test if we're still busy loading a PDF background file
-gboolean page_ops_forbidden(void)
-{
-  return (bgpdf.status != STATUS_NOT_INIT && bgpdf.create_pages);
-}
-
 // send the focus back to the appropriate widget
 void reset_focus(void)
 {
@@ -1542,6 +1630,7 @@ void reset_focus(void)
     gtk_widget_grab_focus(ui.cur_item->widget);
   else
     gtk_widget_grab_focus(GTK_WIDGET(canvas));
+  reset_recognizer();
 }
 
 // selection / clipboard stuff
@@ -1559,6 +1648,7 @@ void reset_selection(void)
   update_thickness_buttons();
   update_color_buttons();
   update_font_button();
+  update_cursor();
 }
 
 void move_journal_items_by(GList *itemlist, double dx, double dy,
@@ -1609,6 +1699,64 @@ void move_journal_items_by(GList *itemlist, double dx, double dy,
   }
 }
 
+void resize_journal_items_by(GList *itemlist, double scaling_x, double scaling_y,
+                             double offset_x, double offset_y)
+{
+  struct Item *item;
+  GList *list;
+  double mean_scaling, temp;
+  double *pt, *wid;
+  GnomeCanvasGroup *group;
+  int i; 
+  
+  /* geometric mean of x and y scalings = rescaling for stroke widths
+     and for text font sizes */
+  mean_scaling = sqrt(fabs(scaling_x * scaling_y));
+
+  for (list = itemlist; list != NULL; list = list->next) {
+    item = (struct Item *)list->data;
+    if (item->type == ITEM_STROKE) {
+      item->brush.thickness = item->brush.thickness * mean_scaling;
+      for (i=0, pt=item->path->coords; i<item->path->num_points; i++, pt+=2) {
+        pt[0] = pt[0]*scaling_x + offset_x;
+        pt[1] = pt[1]*scaling_y + offset_y;
+      }
+      if (item->brush.variable_width)
+        for (i=0, wid=item->widths; i<item->path->num_points-1; i++, wid++)
+          *wid = *wid * mean_scaling;
+
+      item->bbox.left = item->bbox.left*scaling_x + offset_x;
+      item->bbox.right = item->bbox.right*scaling_x + offset_x;
+      item->bbox.top = item->bbox.top*scaling_y + offset_y;
+      item->bbox.bottom = item->bbox.bottom*scaling_y + offset_y;
+      if (item->bbox.left > item->bbox.right) {
+        temp = item->bbox.left;
+        item->bbox.left = item->bbox.right;
+        item->bbox.right = temp;
+      }
+      if (item->bbox.top > item->bbox.bottom) {
+        temp = item->bbox.top;
+        item->bbox.top = item->bbox.bottom;
+        item->bbox.bottom = temp;
+      }
+    }
+    if (item->type == ITEM_TEXT) {
+      /* must scale about NW corner -- all other points of the text box
+         are font- and zoom-dependent, so scaling about center of text box
+         couldn't be undone properly. FIXME? */
+      item->font_size *= mean_scaling;
+      item->bbox.left = item->bbox.left*scaling_x + offset_x;
+      item->bbox.top = item->bbox.top*scaling_y + offset_y;
+    }
+    // redraw the item
+    if (item->canvas_item!=NULL) {
+      group = (GnomeCanvasGroup *) item->canvas_item->parent;
+      gtk_object_destroy(GTK_OBJECT(item->canvas_item));
+      make_canvas_item_one(group, item);
+    }
+  }
+}
+
 // Switch between button mappings
 
 /* NOTE ABOUT BUTTON MAPPINGS: ui.cur_mapping is 0 except while a canvas
@@ -1637,10 +1785,6 @@ void process_mapping_activate(GtkMenuItem *menuitem, int m, int tool)
   reset_focus();
     
   ui.toolno[m] = tool;
-  ui.ruler[m] = FALSE;
-  if (ui.linked_brush[m] == BRUSH_LINKED 
-       && (tool==TOOL_PEN || tool==TOOL_HIGHLIGHTER))
-    ui.ruler[m] = ui.ruler[0];
   if (ui.linked_brush[m] == BRUSH_COPIED) {
     ui.linked_brush[m] = BRUSH_STATIC;
     update_mappings_menu_linkings();
@@ -1766,6 +1910,8 @@ void allow_all_accels(void)
       "can-activate-accel", G_CALLBACK(can_accel), NULL);
   g_signal_connect((gpointer) GET_COMPONENT("toolsRuler"),
       "can-activate-accel", G_CALLBACK(can_accel), NULL);
+  g_signal_connect((gpointer) GET_COMPONENT("toolsReco"),
+      "can-activate-accel", G_CALLBACK(can_accel), NULL);
 }
 
 void add_scroll_bindings(void)
@@ -1810,3 +1956,22 @@ gboolean is_event_within_textview(GdkEventButton *event)
   if (pt[1]<ui.cur_item->bbox.top || pt[1]>ui.cur_item->bbox.bottom) return FALSE;
   return TRUE;
 }
+
+void hide_unimplemented(void)
+{
+  gtk_widget_hide(GET_COMPONENT("filePrintOptions"));
+  gtk_widget_hide(GET_COMPONENT("journalFlatten"));  
+  gtk_widget_hide(GET_COMPONENT("papercolorOther")); 
+  gtk_widget_hide(GET_COMPONENT("toolsSelectRegion"));
+  gtk_widget_hide(GET_COMPONENT("buttonSelectRegion"));
+  gtk_widget_hide(GET_COMPONENT("button2SelectRegion"));
+  gtk_widget_hide(GET_COMPONENT("button3SelectRegion"));
+  gtk_widget_hide(GET_COMPONENT("colorOther"));
+  gtk_widget_hide(GET_COMPONENT("helpIndex")); 
+
+  /* config file only works with glib 2.6 */
+  if (glib_minor_version<6) {
+    gtk_widget_hide(GET_COMPONENT("optionsAutoSavePrefs"));
+    gtk_widget_hide(GET_COMPONENT("optionsSavePreferences"));
+  }
+}