[dia] Reduce GUI coupling by passing DiaContext* down to lib/objects/plug-ins



commit 7be2dcff8e3faf18f65d0bc563c07f4b919266de
Author: Hans Breuer <hans breuer org>
Date:   Sun Jul 1 21:42:59 2012 +0200

    Reduce GUI coupling by passing DiaContext* down to lib/objects/plug-ins
    
    A lot of low level code was using message_warning() and friends.
    While convenient this had multiple issues:
     - message boxes were popped up asynchronous with the task
     - a single task could create multiple dialogs
     - the messages were loosing context (or did not gain it)
     - the classification had to be done by the callee
       (if it's an error, warning or info depends on the caller)
     - message_*() was also used for programmers errors
    
    ToDo:
     check all dia_context_release() to do sth useful with the content
      - decide between warning and error by return value of the
        function taking the context
      - maybe do some in display showing like gedit (for import & drop)
    
     convert also the save/export stuff to use DiaContext
      - finally activate autosave in thread
      - get rid of dia_message_filename()
      - get rid of strerror() use - it had utf-8 issues

 app/app_procs.c                         |   12 +-
 app/diagram.c                           |   12 ++-
 app/load_save.c                         |   84 +++++-----
 lib/arrows.c                            |   20 ++--
 lib/arrows.h                            |    3 +-
 lib/bezier_conn.c                       |   20 +--
 lib/bezier_conn.h                       |    2 +-
 lib/beziershape.c                       |   17 +-
 lib/beziershape.h                       |    2 +-
 lib/connection.c                        |   11 +-
 lib/connection.h                        |    2 +-
 lib/connpoint_line.c                    |    5 +-
 lib/connpoint_line.h                    |    3 +-
 lib/dia-enums.h                         |    5 +
 lib/dia_xml.c                           |  137 ++++++++++-------
 lib/dia_xml.h                           |   29 ++--
 lib/dia_xml_libxml.h                    |    3 -
 lib/diagdkrenderer.c                    |    3 +-
 lib/diasvgrenderer.c                    |    4 +-
 lib/element.c                           |   15 +-
 lib/element.h                           |    2 +-
 lib/filter.h                            |    7 +-
 lib/group.c                             |    3 +-
 lib/libdia.def                          |    9 +-
 lib/makefile.msc                        |   12 ++-
 lib/neworth_conn.c                      |   12 +-
 lib/neworth_conn.h                      |    2 +-
 lib/object-alias.c                      |    6 +-
 lib/object.c                            |   12 +-
 lib/object.h                            |   14 +-
 lib/object_defaults.c                   |   24 ++--
 lib/orth_conn.c                         |   13 +-
 lib/orth_conn.h                         |    2 +-
 lib/persistence.c                       |   60 ++++----
 lib/plug-ins.c                          |   11 +-
 lib/poly_conn.c                         |    9 +-
 lib/poly_conn.h                         |    2 +-
 lib/polyshape.c                         |    6 +-
 lib/polyshape.h                         |    2 +-
 lib/prop_attr.c                         |   24 ++--
 lib/prop_basic.c                        |   11 +-
 lib/prop_basic.h                        |    6 +-
 lib/prop_dict.c                         |    8 +-
 lib/prop_geomtypes.c                    |   44 +++---
 lib/prop_inttypes.c                     |   32 ++--
 lib/prop_matrix.c                       |    2 +-
 lib/prop_pixbuf.c                       |    2 +-
 lib/prop_sdarray.c                      |    8 +-
 lib/prop_text.c                         |   10 +-
 lib/properties.h                        |    3 +-
 lib/propinternals.h                     |    4 +-
 lib/proplist.c                          |   12 +-
 lib/propobject.c                        |    7 +-
 lib/text.c                              |   19 +--
 lib/text.h                              |    2 +-
 lib/widgets.h                           |    4 -
 objects/AADL/aadl.h                     |    2 +-
 objects/AADL/aadlbox.c                  |   12 +-
 objects/AADL/aadlbus.c                  |    4 +-
 objects/AADL/aadldata.c                 |    4 +-
 objects/AADL/aadldevice.c               |    5 +-
 objects/AADL/aadlmemory.c               |    5 +-
 objects/AADL/aadlpackage.c              |    5 +-
 objects/AADL/aadlprocess.c              |    5 +-
 objects/AADL/aadlprocessor.c            |    5 +-
 objects/AADL/aadlsubprogram.c           |    5 +-
 objects/AADL/aadlsystem.c               |    5 +-
 objects/AADL/aadlthread.c               |    5 +-
 objects/AADL/aadlthreadgroup.c          |    5 +-
 objects/Database/compound.c             |   14 +-
 objects/Database/reference.c            |    6 +-
 objects/Database/table.c                |    8 +-
 objects/ER/attribute.c                  |   37 ++---
 objects/ER/entity.c                     |   32 ++---
 objects/ER/participation.c              |    9 +-
 objects/ER/relationship.c               |   34 ++---
 objects/FS/flow-ortho.c                 |   11 +-
 objects/FS/flow.c                       |   11 +-
 objects/FS/function.c                   |   13 +-
 objects/GRAFCET/action.c                |    9 +-
 objects/GRAFCET/action_text_draw.c      |    1 -
 objects/GRAFCET/boolequation.c          |   24 ---
 objects/GRAFCET/boolequation.h          |    6 -
 objects/GRAFCET/condition.c             |   10 +-
 objects/GRAFCET/step.c                  |    9 +-
 objects/GRAFCET/transition.c            |   10 +-
 objects/GRAFCET/vector.c                |    9 +-
 objects/GRAFCET/vergent.c               |    9 +-
 objects/Istar/actor.c                   |    8 +-
 objects/Istar/goal.c                    |   10 +-
 objects/Istar/link.c                    |    7 +-
 objects/Istar/other.c                   |   10 +-
 objects/Jackson/domain.c                |   13 +-
 objects/Jackson/phenomenon.c            |    7 +-
 objects/Jackson/requirement.c           |    7 +-
 objects/KAOS/goal.c                     |   10 +-
 objects/KAOS/metaandorrel.c             |    7 +-
 objects/KAOS/metabinrel.c               |    7 +-
 objects/KAOS/other.c                    |   10 +-
 objects/Misc/analog_clock.c             |   10 +-
 objects/Misc/diagram_as_object.c        |   21 ++-
 objects/Misc/grid_object.c              |   10 +-
 objects/Misc/measure.c                  |    6 +-
 objects/Misc/tree.c                     |   11 +-
 objects/SADT/annotation.c               |    7 +-
 objects/SADT/arrow.c                    |   10 +-
 objects/SADT/box.c                      |   10 +-
 objects/UML/activity.c                  |    7 +-
 objects/UML/actor.c                     |    7 +-
 objects/UML/association.c               |   21 ++--
 objects/UML/branch.c                    |    7 +-
 objects/UML/class.c                     |   39 +++---
 objects/UML/class.h                     |    1 -
 objects/UML/class_dialog.h              |    1 +
 objects/UML/classicon.c                 |    7 +-
 objects/UML/component.c                 |    7 +-
 objects/UML/component_feature.c         |    7 +-
 objects/UML/constraint.c                |    7 +-
 objects/UML/dependency.c                |    7 +-
 objects/UML/fork.c                      |    7 +-
 objects/UML/generalization.c            |    8 +-
 objects/UML/implements.c                |    7 +-
 objects/UML/large_package.c             |    7 +-
 objects/UML/lifeline.c                  |    7 +-
 objects/UML/message.c                   |    7 +-
 objects/UML/node.c                      |    7 +-
 objects/UML/note.c                      |    7 +-
 objects/UML/object.c                    |    7 +-
 objects/UML/realizes.c                  |    7 +-
 objects/UML/small_package.c             |    7 +-
 objects/UML/state.c                     |    7 +-
 objects/UML/state_term.c                |    7 +-
 objects/UML/transition.c                |    8 +-
 objects/UML/usecase.c                   |    7 +-
 objects/chronogram/chronoline.c         |    8 +-
 objects/chronogram/chronoref.c          |    8 +-
 objects/custom/custom_object.c          |    8 +-
 objects/custom_lines/custom_linetypes.c |   22 ++--
 objects/flowchart/box.c                 |   29 ++--
 objects/flowchart/diamond.c             |   28 ++--
 objects/flowchart/ellipse.c             |   26 ++--
 objects/flowchart/parallelogram.c       |   28 ++--
 objects/network/basestation.c           |    8 +-
 objects/network/bus.c                   |   11 +-
 objects/network/radiocell.c             |    7 +-
 objects/network/wanlink.c               |   15 +-
 objects/standard/arc.c                  |   23 ++--
 objects/standard/bezier.c               |   29 ++--
 objects/standard/beziergon.c            |   23 ++--
 objects/standard/box.c                  |   24 ++--
 objects/standard/ellipse.c              |   22 ++--
 objects/standard/image.c                |   23 ++--
 objects/standard/line.c                 |   27 ++--
 objects/standard/outline.c              |    6 +-
 objects/standard/polygon.c              |   23 ++--
 objects/standard/polyline.c             |   32 ++---
 objects/standard/textobj.c              |   16 +-
 objects/standard/zigzagline.c           |   27 ++--
 plug-ins/drs/dia-render-script-import.c |   12 +-
 plug-ins/drs/dia-render-script.h        |    2 +-
 plug-ins/dxf/dxf-import.c               |   16 +-
 plug-ins/pixbuf/pixbuf.c                |   10 +-
 plug-ins/python/diamodule.c             |    4 +-
 plug-ins/svg/svg-import.c               |    8 +-
 plug-ins/vdx/vdx-import.c               |   15 +-
 plug-ins/wpg/wpg.c                      |   16 +-
 plug-ins/xfig/xfig-import.c             |  254 ++++++++++++++++++-------------
 167 files changed, 1148 insertions(+), 1192 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index e2b662b..a700cbd 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -326,6 +326,7 @@ do_convert(const char *infname,
 {
   DiaImportFilter *inf;
   DiagramData *diagdata = NULL;
+  DiaContext *ctx;
 
   inf = filter_guess_import_filter(infname);
   if (!inf) 
@@ -349,8 +350,9 @@ do_convert(const char *infname,
   }
   
   diagdata = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
+  ctx = dia_context_new(_("Import"));
 
-  if (!inf->import_func(infname,diagdata,inf->user_data)) {
+  if (!inf->import_func(infname, diagdata, ctx, inf->user_data)) {
     g_critical(_("%s error: need valid input file %s\n"),
             argv0, infname);
     exit(1);
@@ -382,6 +384,7 @@ do_convert(const char *infname,
                       _("%s --> %s\n"),
                         infname,outfname);
   g_object_unref(diagdata);
+  dia_context_release(ctx);
   return TRUE;
 }
 
@@ -913,8 +916,11 @@ app_init (int argc, char **argv)
   load_all_sheets();     /* new mechanism */
 
   dia_log_message ("object defaults");
-  dia_object_defaults_load (NULL, TRUE /* prefs.object_defaults_create_lazy */);
-
+  {
+    DiaContext *ctx = dia_context_new (_("Object Defaults"));
+    dia_object_defaults_load (NULL, TRUE /* prefs.object_defaults_create_lazy */, ctx);
+    dia_context_release (ctx);
+  }
   debug_break();
 
   if (object_get_type("Standard - Box") == NULL) {
diff --git a/app/diagram.c b/app/diagram.c
index e23217a..f2d3027 100644
--- a/app/diagram.c
+++ b/app/diagram.c
@@ -43,6 +43,7 @@
 #include "textedit.h"
 #include "lib/diamarshal.h"
 #include "parent.h"
+#include "diacontext.h"
 
 static GList *open_diagrams = NULL;
 
@@ -261,13 +262,17 @@ diagram_load_into(Diagram         *diagram,
 		  const char      *filename,
 		  DiaImportFilter *ifilter)
 {
+  /* ToDo: move context further up in the callstack and to sth useful with it's content */
+  DiaContext *ctx = dia_context_new(_("Load Into"));
+
   gboolean was_default = diagram->is_default;
   if (!ifilter)
     ifilter = filter_guess_import_filter(filename);
   if (!ifilter)  /* default to native format */
     ifilter = &dia_import_filter;
 
-  if (ifilter->import_func(filename, diagram->data, ifilter->user_data)) {
+  dia_context_set_filename (ctx, filename);
+  if (ifilter->import_func(filename, diagram->data, ctx, ifilter->user_data)) {
     if (ifilter != &dia_import_filter) {
       /* When loading non-Dia files, change filename to reflect that saving
        * will produce a Dia file. See bug #440093 */
@@ -296,9 +301,12 @@ diagram_load_into(Diagram         *diagram,
 	  strcmp(filename, diagram->filename) == 0 ? FALSE : was_default;
     }
     diagram_set_modified(diagram, TRUE);
+    dia_context_release(ctx);
     return TRUE;
-  } else
+  } else {
+    dia_context_release(ctx);
     return FALSE;
+  }
 }
 
 Diagram *
diff --git a/app/load_save.c b/app/load_save.c
index 02f6522..1f111d2 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -66,14 +66,15 @@ static void GHFuncUnknownObjects(gpointer key,
 				 gpointer user_data);
 static GList *read_objects(xmlNodePtr objects,
 			   GHashTable *objects_hash,
-			   const char *filename, DiaObject *parent,
+			   DiaContext *ctx, 
+			   DiaObject  *parent,
 			   GHashTable *unknown_objects_hash);
 static void hash_free_string(gpointer       key,
 			     gpointer       value,
 			     gpointer       user_data);
 static xmlNodePtr find_node_named (xmlNodePtr p, const char *name);
-static gboolean diagram_data_load(const char *filename, DiagramData *data,
-				  void* user_data);
+static gboolean diagram_data_load(const gchar *filename, DiagramData *data,
+				  DiaContext *ctx, void* user_data);
 static gboolean write_objects(GList *objects, xmlNodePtr objects_node,
 			      GHashTable *objects_hash, int *obj_nr, 
 			      const char *filename);
@@ -114,7 +115,9 @@ GHFuncUnknownObjects(gpointer key,
  */
 static GList *
 read_objects(xmlNodePtr objects, 
-             GHashTable *objects_hash,const char *filename, DiaObject *parent,
+             GHashTable *objects_hash,
+	     DiaContext *ctx, 
+	     DiaObject *parent,
 	     GHashTable *unknown_objects_hash)
 {
   GList *list;
@@ -159,7 +162,7 @@ read_objects(xmlNodePtr objects,
       }
       else
       {
-        obj = type->ops->load(obj_node, version, filename);
+        obj = type->ops->load(obj_node, version, ctx);
         list = g_list_append(list, obj);
 
         if (parent)
@@ -176,7 +179,7 @@ read_objects(xmlNodePtr objects,
         {
           if (xmlStrcmp(child_node->name, (const xmlChar *)"children") == 0)
           {
-	    GList *children_read = read_objects(child_node, objects_hash, filename, obj, unknown_objects_hash);
+	    GList *children_read = read_objects(child_node, objects_hash, ctx, obj, unknown_objects_hash);
             list = g_list_concat(list, children_read);
             break;
           }
@@ -188,11 +191,11 @@ read_objects(xmlNodePtr objects,
     } else if (xmlStrcmp(obj_node->name, (const xmlChar *)"group")==0
                && obj_node->children) {
       /* don't create empty groups */
-      GList *inner_objects = read_objects(obj_node, objects_hash, filename, NULL, unknown_objects_hash);
+      GList *inner_objects = read_objects(obj_node, objects_hash, ctx, NULL, unknown_objects_hash);
 
       if (inner_objects) {
         obj = group_create(inner_objects);
-	object_load_props(obj,obj_node);
+	object_load_props(obj, obj_node, ctx);
 	list = g_list_append(list, obj);
       }
     } else {
@@ -352,7 +355,7 @@ find_node_named (xmlNodePtr p, const char *name)
 }
 
 static gboolean
-diagram_data_load(const char *filename, DiagramData *data, void* user_data)
+diagram_data_load(const gchar *filename, DiagramData *data, DiaContext *ctx, void* user_data)
 {
   GHashTable *objects_hash;
   int fd;
@@ -372,15 +375,14 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
   g_return_val_if_fail(data!=NULL, FALSE);
 
   if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
-    message_error(_("You must specify a file, not a directory.\n"));
+    dia_context_add_message(ctx, _("You must specify a file, not a directory."));
     return FALSE;
   }
 
   fd = g_open(filename, O_RDONLY, 0);
 
   if (fd==-1) {
-    message_error(_("Couldn't open: '%s' for reading.\n"),
-		  dia_message_filename(filename));
+    dia_context_add_message(ctx, _("Couldn't open: '%s' for reading.\n"), filename);
     return FALSE;
   }
 
@@ -394,11 +396,11 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
   /* Note that this closing and opening means we can't read from a pipe */
   close(fd);
 
-  doc = xmlDiaParseFile(filename);
+  doc = diaXmlParseFile (filename, ctx, TRUE);
 
   if (doc == NULL){
-    message_error(_("Error loading diagram %s.\nUnknown file type."),
-		  dia_message_filename(filename));
+    /* this was talking about unknown file type but it could as well be broken XML */
+    dia_context_add_message(ctx, _("Error loading diagram %s."), filename);
     return FALSE;
   }
   
@@ -430,13 +432,13 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
   data->bg_color = prefs.new_diagram.bg_color;
   attr = composite_find_attribute(diagramdata, "background");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &data->bg_color);
+    data_color(attribute_first_data(attr), &data->bg_color, ctx);
 
   if (diagram) {
     diagram->pagebreak_color = prefs.new_diagram.pagebreak_color;
     attr = composite_find_attribute(diagramdata, "pagebreak");
     if (attr != NULL)
-      data_color(attribute_first_data(attr), &diagram->pagebreak_color);
+      data_color(attribute_first_data(attr), &diagram->pagebreak_color, ctx);
   }
   /* load paper information from diagramdata section */
   attr = composite_find_attribute(diagramdata, "paper");
@@ -446,7 +448,7 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
     attr = composite_find_attribute(paperinfo, "name");
     if (attr != NULL) {
       g_free(data->paper.name);
-      data->paper.name = data_string(attribute_first_data(attr));
+      data->paper.name = data_string(attribute_first_data(attr), ctx);
     }
     if (data->paper.name == NULL || data->paper.name[0] == '\0') {
       data->paper.name = g_strdup(prefs.new_diagram.papertype);
@@ -460,41 +462,41 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
     
     attr = composite_find_attribute(paperinfo, "tmargin");
     if (attr != NULL)
-      data->paper.tmargin = data_real(attribute_first_data(attr));
+      data->paper.tmargin = data_real(attribute_first_data(attr), ctx);
     attr = composite_find_attribute(paperinfo, "bmargin");
     if (attr != NULL)
-      data->paper.bmargin = data_real(attribute_first_data(attr));
+      data->paper.bmargin = data_real(attribute_first_data(attr), ctx);
     attr = composite_find_attribute(paperinfo, "lmargin");
     if (attr != NULL)
-      data->paper.lmargin = data_real(attribute_first_data(attr));
+      data->paper.lmargin = data_real(attribute_first_data(attr), ctx);
     attr = composite_find_attribute(paperinfo, "rmargin");
     if (attr != NULL)
-      data->paper.rmargin = data_real(attribute_first_data(attr));
+      data->paper.rmargin = data_real(attribute_first_data(attr), ctx);
 
     attr = composite_find_attribute(paperinfo, "is_portrait");
     data->paper.is_portrait = TRUE;
     if (attr != NULL)
-      data->paper.is_portrait = data_boolean(attribute_first_data(attr));
+      data->paper.is_portrait = data_boolean(attribute_first_data(attr), ctx);
 
     attr = composite_find_attribute(paperinfo, "scaling");
     data->paper.scaling = 1.0;
     if (attr != NULL)
-      data->paper.scaling = data_real(attribute_first_data(attr));
+      data->paper.scaling = data_real(attribute_first_data(attr), ctx);
 
     attr = composite_find_attribute(paperinfo, "fitto");
     data->paper.fitto = FALSE;
     if (attr != NULL)
-      data->paper.fitto = data_boolean(attribute_first_data(attr));
+      data->paper.fitto = data_boolean(attribute_first_data(attr), ctx);
 
     attr = composite_find_attribute(paperinfo, "fitwidth");
     data->paper.fitwidth = 1;
     if (attr != NULL)
-      data->paper.fitwidth = data_int(attribute_first_data(attr));
+      data->paper.fitwidth = data_int(attribute_first_data(attr), ctx);
 
     attr = composite_find_attribute(paperinfo, "fitheight");
     data->paper.fitheight = 1;
     if (attr != NULL)
-      data->paper.fitheight = data_int(attribute_first_data(attr));
+      data->paper.fitheight = data_int(attribute_first_data(attr), ctx);
 
     /* calculate effective width/height */
     dia_page_layout_get_paper_size(data->paper.name,
@@ -521,25 +523,25 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
 
       attr = composite_find_attribute(gridinfo, "dynamic");
       if (attr != NULL)
-         diagram->grid.dynamic = data_boolean(attribute_first_data(attr));
+         diagram->grid.dynamic = data_boolean(attribute_first_data(attr), ctx);
 
       attr = composite_find_attribute(gridinfo, "width_x");
       if (attr != NULL)
-        diagram->grid.width_x = data_real(attribute_first_data(attr));
+        diagram->grid.width_x = data_real(attribute_first_data(attr), ctx);
       attr = composite_find_attribute(gridinfo, "width_y");
       if (attr != NULL)
-        diagram->grid.width_y = data_real(attribute_first_data(attr));
+        diagram->grid.width_y = data_real(attribute_first_data(attr), ctx);
       attr = composite_find_attribute(gridinfo, "visible_x");
       if (attr != NULL)
-        diagram->grid.visible_x = data_int(attribute_first_data(attr));
+        diagram->grid.visible_x = data_int(attribute_first_data(attr), ctx);
       attr = composite_find_attribute(gridinfo, "visible_y");
       if (attr != NULL)
-        diagram->grid.visible_y = data_int(attribute_first_data(attr));
+        diagram->grid.visible_y = data_int(attribute_first_data(attr), ctx);
 
       diagram->grid.colour = prefs.new_diagram.grid_color;
       attr = composite_find_attribute(diagramdata, "color");
       if (attr != NULL)
-        data_color(attribute_first_data(attr), &diagram->grid.colour);
+        data_color(attribute_first_data(attr), &diagram->grid.colour, ctx);
     }
   }
   if (diagram) {
@@ -558,7 +560,7 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
     
         guide = attribute_first_data(attr);
         for (i = 0; i < diagram->guides.nhguides; i++, guide = data_next(guide))
-	  diagram->guides.hguides[i] = data_real(guide);
+	  diagram->guides.hguides[i] = data_real(guide, ctx);
       }
       attr = composite_find_attribute(guideinfo, "vguides");
       if (attr != NULL) {
@@ -568,7 +570,7 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
     
         guide = attribute_first_data(attr);
         for (i = 0; i < diagram->guides.nvguides; i++, guide = data_next(guide))
-	  diagram->guides.vguides[i] = data_real(guide);
+	  diagram->guides.vguides[i] = data_real(guide, ctx);
       }
     }
   }
@@ -585,27 +587,27 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
       attr = composite_find_attribute(dispinfo, "antialiased");
       if (attr != NULL)
 	g_object_set_data(G_OBJECT(diagram), 
-	  "antialiased", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+	  "antialiased", GINT_TO_POINTER (data_boolean(attribute_first_data(attr), ctx) ? 1 : -1));
 
       attr = composite_find_attribute(dispinfo, "snap-to-grid");
       if (attr != NULL)
 	g_object_set_data(G_OBJECT(diagram), 
-	  "snap-to-grid", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+	  "snap-to-grid", GINT_TO_POINTER (data_boolean(attribute_first_data(attr), ctx) ? 1 : -1));
 
       attr = composite_find_attribute(dispinfo, "snap-to-object");
       if (attr != NULL)
         g_object_set_data(G_OBJECT(diagram), 
-	  "snap-to-object", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+	  "snap-to-object", GINT_TO_POINTER (data_boolean(attribute_first_data(attr), ctx) ? 1 : -1));
 
       attr = composite_find_attribute(dispinfo, "show-grid");
       if (attr != NULL)
         g_object_set_data(G_OBJECT(diagram), 
-	  "show-grid", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+	  "show-grid", GINT_TO_POINTER (data_boolean(attribute_first_data(attr), ctx) ? 1 : -1));
 
       attr = composite_find_attribute(dispinfo, "show-connection-points");
       if (attr != NULL)
         g_object_set_data(G_OBJECT(diagram), 
-	  "show-connection-points", GINT_TO_POINTER (data_boolean(attribute_first_data(attr)) ? 1 : -1));
+	  "show-connection-points", GINT_TO_POINTER (data_boolean(attribute_first_data(attr), ctx) ? 1 : -1));
     }
   }
   /* Read in all layers: */
@@ -641,7 +643,7 @@ diagram_data_load(const char *filename, DiagramData *data, void* user_data)
     }
     /* Read in all objects: */
     
-    list = read_objects(layer_node, objects_hash, filename, NULL, unknown_objects_hash);
+    list = read_objects(layer_node, objects_hash, ctx, NULL, unknown_objects_hash);
     layer_add_objects (layer, list);
     read_connections( list, layer_node, objects_hash);
 
diff --git a/lib/arrows.c b/lib/arrows.c
index dfd2aa6..241122f 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include <glib.h>
-#include "message.h"
+#include "diacontext.h"
 #include "boundingbox.h"
 
 #ifdef G_OS_WIN32
@@ -2045,10 +2045,10 @@ arrow_draw(DiaRenderer *renderer, ArrowType type,
  * legal head type.
  */
 static void
-sanitize_arrow(Arrow *arrow)
+sanitize_arrow(Arrow *arrow, DiaContext *ctx)
 {
   if (arrow->type < 0 || arrow->type > MAX_ARROW_TYPE) {
-    message_warning(_("Arrow head of unknown type"));
+    dia_context_add_message(ctx, _("Arrow head of unknown type"));
     arrow->type = ARROW_NONE;
     arrow->width = DEFAULT_ARROW_WIDTH;
     arrow->length = DEFAULT_ARROW_LENGTH;
@@ -2056,8 +2056,8 @@ sanitize_arrow(Arrow *arrow)
 
   if (arrow->length < MIN_ARROW_DIMENSION ||
       arrow->width < MIN_ARROW_DIMENSION) {
-    message_warning(_("Arrow head of type %s has too small dimensions; removing.\n"),
-		    arrow_get_name_from_type(arrow->type));
+    dia_context_add_message(ctx, _("Arrow head of type %s has too small dimensions; removing.\n"),
+		            arrow_get_name_from_type(arrow->type));
     arrow->type = ARROW_NONE;
     arrow->width = DEFAULT_ARROW_WIDTH;
     arrow->length = DEFAULT_ARROW_LENGTH;
@@ -2092,7 +2092,7 @@ save_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
  */
 void
 load_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute, 
-	   gchar *length_attribute, gchar *width_attribute)
+	   gchar *length_attribute, gchar *width_attribute, DiaContext *ctx)
 {
   AttributeNode attr;
 
@@ -2101,15 +2101,15 @@ load_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
   arrow->width = DEFAULT_ARROW_WIDTH;
   attr = object_find_attribute(obj_node, type_attribute);
   if (attr != NULL)
-    arrow->type = data_enum(attribute_first_data(attr));
+    arrow->type = data_enum(attribute_first_data(attr),ctx);
   attr = object_find_attribute(obj_node, length_attribute);
   if (attr != NULL)
-    arrow->length = data_real(attribute_first_data(attr));
+    arrow->length = data_real(attribute_first_data(attr),ctx);
   attr = object_find_attribute(obj_node, width_attribute);
   if (attr != NULL)
-    arrow->width = data_real(attribute_first_data(attr));
+    arrow->width = data_real(attribute_first_data(attr),ctx);
 
-  sanitize_arrow(arrow);
+  sanitize_arrow(arrow, ctx);
 }
 
 /** Returns the arrow type that corresponds to a given name.
diff --git a/lib/arrows.h b/lib/arrows.h
index 2e820fb..f23f935 100644
--- a/lib/arrows.h
+++ b/lib/arrows.h
@@ -23,6 +23,7 @@
 #include "geometry.h"
 #include "color.h"
 #include "dia_xml.h"
+#include "diacontext.h"
 
 /* NOTE: Add new arrow types at the end, or the enums
    will change order leading to file incompatibilities. */
@@ -106,7 +107,7 @@ calculate_arrow_point(const Arrow *arrow, const Point *to, const Point *from,
 void save_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
 		gchar *length_attribute, gchar *width_attribute);
 void load_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute, 
-		gchar *length_attribute, gchar *width_attribute);
+		gchar *length_attribute, gchar *width_attribute, DiaContext *ctx);
 
 /** Returns the ArrowType for a given name of an arrow, or 0 if not found. */
 ArrowType arrow_type_from_name(const gchar *name);
diff --git a/lib/bezier_conn.c b/lib/bezier_conn.c
index 86bd2e4..156cc91 100644
--- a/lib/bezier_conn.c
+++ b/lib/bezier_conn.c
@@ -28,8 +28,6 @@
 #include <string.h> /* memcpy() */
 
 #include "bezier_conn.h"
-#include "intl.h"
-#include "message.h"
 #include "diarenderer.h"
 
 #define HANDLE_BEZMAJOR  (HANDLE_CUSTOM1)
@@ -222,7 +220,7 @@ bezierconn_move_handle(BezierConn *bez, Handle *handle,
     }
     break;
   default:
-    message_error("Internal error in bezierconn_move_handle.\n");
+    g_warning("Internal error in bezierconn_move_handle.\n");
     break;
   }
   return NULL;
@@ -635,7 +633,7 @@ bezierconn_set_corner_type(BezierConn *bez, Handle *handle,
     mid_handle = bez->object.handles[handle_nr];
     break;
   default:
-    message_warning(_("Internal error: Setting corner type of endpoint of bezier"));
+    g_warning("Internal error: Setting corner type of endpoint of bezier");
     return NULL;
   }
 
@@ -975,7 +973,7 @@ bezierconn_save(BezierConn *bez, ObjectNode obj_node)
  * @bug Couldn't this use the setup_handles function defined above?
  */
 void
-bezierconn_load(BezierConn *bez, ObjectNode obj_node)
+bezierconn_load(BezierConn *bez, ObjectNode obj_node, DiaContext *ctx)
 {
   int i;
   AttributeNode attr;
@@ -983,7 +981,7 @@ bezierconn_load(BezierConn *bez, ObjectNode obj_node)
   
   DiaObject *obj = &bez->object;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "bez_points");
 
@@ -998,16 +996,16 @@ bezierconn_load(BezierConn *bez, ObjectNode obj_node)
   if (bez->numpoints != 0) {
     bez->points = g_new(BezPoint, bez->numpoints);
     bez->points[0].type = BEZ_MOVE_TO;
-    data_point(data, &bez->points[0].p1);
+    data_point(data, &bez->points[0].p1, ctx);
     data = data_next(data);
 
     for (i = 1; i < bez->numpoints; i++) {
       bez->points[i].type = BEZ_CURVE_TO;
-      data_point(data, &bez->points[i].p1);
+      data_point(data, &bez->points[i].p1, ctx);
       data = data_next(data);
-      data_point(data, &bez->points[i].p2);
+      data_point(data, &bez->points[i].p2, ctx);
       data = data_next(data);
-      data_point(data, &bez->points[i].p3);
+      data_point(data, &bez->points[i].p3, ctx);
       data = data_next(data);
     }
   }
@@ -1023,7 +1021,7 @@ bezierconn_load(BezierConn *bez, ObjectNode obj_node)
   } else {
     data = attribute_first_data(attr);
     for (i = 0; i < bez->numpoints; i++) {
-      bez->corner_types[i] = data_enum(data);
+      bez->corner_types[i] = data_enum(data, ctx);
       data = data_next(data);
     }
   }
diff --git a/lib/bezier_conn.h b/lib/bezier_conn.h
index 7f79c6b..30d56d2 100644
--- a/lib/bezier_conn.h
+++ b/lib/bezier_conn.h
@@ -55,7 +55,7 @@ void bezierconn_set_points(BezierConn *poly, int num_points, BezPoint *points);
 void bezierconn_destroy(BezierConn *bez);
 void bezierconn_copy(BezierConn *from, BezierConn *to);
 void bezierconn_save(BezierConn *bez, ObjectNode obj_node);
-void bezierconn_load(BezierConn *bez, ObjectNode obj_node);  /* NOTE: Does object_init() */
+void bezierconn_load(BezierConn *bez, ObjectNode obj_node, DiaContext *ctx);  /* NOTE: Does object_init() */
 ObjectChange *bezierconn_add_segment(BezierConn *bez, int segment, Point *point);
 ObjectChange *bezierconn_remove_segment(BezierConn *bez, int point);
 ObjectChange *bezierconn_set_corner_type(BezierConn *bez,
diff --git a/lib/beziershape.c b/lib/beziershape.c
index 6ef4a17..ea4035e 100644
--- a/lib/beziershape.c
+++ b/lib/beziershape.c
@@ -27,7 +27,6 @@
 #include <string.h> /* memcpy() */
 
 #include "beziershape.h"
-#include "message.h"
 #include "diarenderer.h"
 
 #define HANDLE_BEZMAJOR  (HANDLE_CUSTOM1)
@@ -210,7 +209,7 @@ beziershape_move_handle(BezierShape *bezier, Handle *handle,
     }
     break;
   default:
-    message_error("Internal error in beziershape_move_handle.");
+    g_warning("Internal error in beziershape_move_handle.");
     break;
   }
   return NULL;
@@ -923,7 +922,7 @@ beziershape_save(BezierShape *bezier, ObjectNode obj_node)
 }
 
 void
-beziershape_load(BezierShape *bezier, ObjectNode obj_node)
+beziershape_load(BezierShape *bezier, ObjectNode obj_node, DiaContext *ctx)
 {
   int i;
   AttributeNode attr;
@@ -931,7 +930,7 @@ beziershape_load(BezierShape *bezier, ObjectNode obj_node)
   
   DiaObject *obj = &bezier->object;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "bez_points");
 
@@ -947,18 +946,18 @@ beziershape_load(BezierShape *bezier, ObjectNode obj_node)
   if (bezier->numpoints != 0) {
     bezier->points = g_new(BezPoint, bezier->numpoints);
     bezier->points[0].type = BEZ_MOVE_TO;
-    data_point(data, &bezier->points[0].p1);
+    data_point(data, &bezier->points[0].p1, ctx);
     bezier->points[0].p3 = bezier->points[0].p1;
     data = data_next(data);
 
     for (i = 1; i < bezier->numpoints; i++) {
       bezier->points[i].type = BEZ_CURVE_TO;
-      data_point(data, &bezier->points[i].p1);
+      data_point(data, &bezier->points[i].p1, ctx);
       data = data_next(data);
-      data_point(data, &bezier->points[i].p2);
+      data_point(data, &bezier->points[i].p2, ctx);
       data = data_next(data);
       if (i < bezier->numpoints - 1) {
-	data_point(data, &bezier->points[i].p3);
+	data_point(data, &bezier->points[i].p3, ctx);
 	data = data_next(data);
       } else
 	bezier->points[i].p3 = bezier->points[0].p1;
@@ -973,7 +972,7 @@ beziershape_load(BezierShape *bezier, ObjectNode obj_node)
   } else {
     data = attribute_first_data(attr);
     for (i = 0; i < bezier->numpoints; i++) {
-      bezier->corner_types[i] = data_enum(data);
+      bezier->corner_types[i] = data_enum(data, ctx);
       data = data_next(data);
     }
   }
diff --git a/lib/beziershape.h b/lib/beziershape.h
index b4977de..b159c9f 100644
--- a/lib/beziershape.h
+++ b/lib/beziershape.h
@@ -52,7 +52,7 @@ void beziershape_destroy(BezierShape *bezier);
 void beziershape_copy(BezierShape *from, BezierShape *to);
 void beziershape_save(BezierShape *bezier, ObjectNode obj_node);
 /* NOTE: Does object_init() */
-void beziershape_load(BezierShape *bezier, ObjectNode obj_node);
+void beziershape_load(BezierShape *bezier, ObjectNode obj_node, DiaContext *ctx);
 ObjectChange *beziershape_add_segment(BezierShape *bezier, int segment,
 				      Point *point);
 ObjectChange *beziershape_remove_segment(BezierShape *bezier, int point);
diff --git a/lib/connection.c b/lib/connection.c
index 095c9f1..d135383 100644
--- a/lib/connection.c
+++ b/lib/connection.c
@@ -24,7 +24,6 @@
 #include <assert.h>
 
 #include "connection.h"
-#include "message.h"
 
 /** Adjust connection endings for autogap.  This function actually moves the
  * ends of the connection, but only when the end is connected to 
@@ -97,7 +96,7 @@ connection_move_handle(Connection *conn, HandleId id,
     conn->endpoints[1] = *to;
     break;
   default:
-    message_error("Internal error in connection_move_handle.\n");
+    g_warning("Internal error in connection_move_handle.\n");
     break;
   }
   return NULL;
@@ -221,18 +220,18 @@ connection_save(Connection *conn, ObjectNode obj_node)
  * @param obj_node The XML node to load from.
  */
 void
-connection_load(Connection *conn, ObjectNode obj_node)
+connection_load(Connection *conn, ObjectNode obj_node, DiaContext *ctx)
 {
   AttributeNode attr;
   DataNode data;
 
-  object_load(&conn->object, obj_node);
+  object_load(&conn->object, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "conn_endpoints");
   if (attr != NULL) {
     data = attribute_first_data(attr);
-    data_point( data , &conn->endpoints[0] );
+    data_point(data, &conn->endpoints[0], ctx);
     data = data_next(data);
-    data_point( data , &conn->endpoints[1] );
+    data_point(data, &conn->endpoints[1], ctx);
   }
 }
diff --git a/lib/connection.h b/lib/connection.h
index f4f7476..0aad5fb 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -45,7 +45,7 @@ void connection_init(Connection *conn,
 void connection_destroy(Connection *conn);
 void connection_copy(Connection *from, Connection *to);
 void connection_save(Connection *conn, ObjectNode obj_node);
-void connection_load(Connection *conn, ObjectNode obj_node);
+void connection_load(Connection *conn, ObjectNode obj_node, DiaContext *ctx);
 ObjectChange* connection_move_handle(Connection *conn, HandleId id,
 				     Point *to, ConnectionPoint* cp,
 				     HandleMoveReason reason, 
diff --git a/lib/connpoint_line.c b/lib/connpoint_line.c
index 946a466..00d204a 100644
--- a/lib/connpoint_line.c
+++ b/lib/connpoint_line.c
@@ -160,7 +160,8 @@ cpl_inplacecreate(DiaObject *obj, int nc, int *realconncount)
 
 ConnPointLine *
 connpointline_load(DiaObject *obj,ObjectNode obj_node,
-		   const gchar *name, int default_nc,int *realconncount)
+		   const gchar *name, int default_nc,int *realconncount,
+		   DiaContext *ctx)
 {
   ConnPointLine *cpl;
   int nc = default_nc;
@@ -168,7 +169,7 @@ connpointline_load(DiaObject *obj,ObjectNode obj_node,
 
   attr = object_find_attribute(obj_node, name);
   if (attr != NULL)
-    nc = data_int(attribute_first_data(attr));
+    nc = data_int(attribute_first_data(attr), ctx);
   cpl = connpointline_create(obj,nc);
 
   if (realconncount) (*realconncount) += cpl->num_connections;
diff --git a/lib/connpoint_line.h b/lib/connpoint_line.h
index f79418f..9a6d962 100644
--- a/lib/connpoint_line.h
+++ b/lib/connpoint_line.h
@@ -61,7 +61,8 @@ ObjectChange *connpointline_remove_points(ConnPointLine *cpl,
 					  int count);
 ConnPointLine *connpointline_load(DiaObject *obj,ObjectNode obj_node,
 				  const gchar *name, int default_nc,
-				  int *realconncount);
+				  int *realconncount,
+				  DiaContext *ctx);
 void connpointline_save(ConnPointLine *cpl,ObjectNode obj_node,
 			const gchar *name);
 ConnPointLine *connpointline_copy(DiaObject *newobj,ConnPointLine *cpl,
diff --git a/lib/dia-enums.h b/lib/dia-enums.h
index 95837ac..7bd44ac 100644
--- a/lib/dia-enums.h
+++ b/lib/dia-enums.h
@@ -36,4 +36,9 @@ typedef enum {
   TEXTFIT_WHEN_NEEDED,
   TEXTFIT_ALWAYS
 } TextFitting;
+
+/* Used to be in widgets.h polluting a lot of object implementations */
+#define DEFAULT_LINESTYLE LINESTYLE_SOLID
+#define DEFAULT_LINESTYLE_DASHLEN 1.0
+
 #endif
diff --git a/lib/dia_xml.c b/lib/dia_xml.c
index fb137db..fabf7e1 100644
--- a/lib/dia_xml.c
+++ b/lib/dia_xml.c
@@ -102,7 +102,7 @@ static inline int isinf_ld (long double x) { return isnan (x - x); }
  *       better than this. I dont. --hb
  */
 static const gchar *
-xml_file_check_encoding(const gchar *filename, const gchar *default_enc)
+xml_file_check_encoding(const gchar *filename, const gchar *default_enc, DiaContext *ctx)
 {
   int fd = g_open (filename, O_RDONLY, 0);
   /* If the next call exits the program (without any message) check if
@@ -194,9 +194,10 @@ xml_file_check_encoding(const gchar *filename, const gchar *default_enc)
   }
 
   if (0 != strcmp(default_enc,"UTF-8")) {
-    message_warning(_("The file %s has no encoding specification;\n"
-                      "assuming it is encoded in %s"),
-		    dia_message_filename(filename), default_enc);
+    dia_context_add_message (ctx, 
+                             _("The file %s has no encoding specification;\n"
+			     "assuming it is encoded in %s"),
+			     dia_context_get_filename(ctx), default_enc);
   } else {
     gzclose(zf); /* we apply the standard here. */
     g_free(buf);
@@ -238,14 +239,14 @@ xml_file_check_encoding(const gchar *filename, const gchar *default_enc)
  * @see xmlParseFile() in the XML2 library for details on the return value.
  */
 xmlDocPtr
-xmlDiaParseFile(const char *filename)
+xmlDiaParseFile(const char *filename, DiaContext *ctx)
 {
   const char *local_charset = NULL;
   
   if (   !g_get_charset(&local_charset)
       && local_charset) {
     /* we're not in an UTF-8 environment. */ 
-    const gchar *fname = xml_file_check_encoding(filename,local_charset);
+    const gchar *fname = xml_file_check_encoding(filename,local_charset, ctx);
     if (fname != filename) {
       /* We've got a corrected file to parse. */
       xmlDocPtr ret = xmlDoParseFile(fname);
@@ -270,7 +271,36 @@ xmlDiaParseFile(const char *filename)
 xmlDocPtr
 xmlDoParseFile(const char *filename)
 {
-  return xmlParseFile(filename);
+  xmlDocPtr doc;
+  xmlErrorPtr err;
+
+  doc = xmlParseFile(filename);
+  if (!doc)
+    err = xmlGetLastError ();
+
+  return doc;
+}
+
+/** Parse an xml file from a filename given in Dia's/GLib's filename encoding 
+ * @param filename A file to parse. On win32 the filename encoding is utf-8 since GLib 2.6
+ * @param ctx If something goes wrong during parsing ctx will include according messages
+ * @return An XML document.
+ */
+xmlDocPtr 
+diaXmlParseFile(const char *filename, DiaContext *ctx, gboolean try_harder)
+{
+  xmlDocPtr doc;
+  xmlErrorPtr err;
+  
+  doc = xmlParseFile(filename);
+  if (!doc) {
+    err = xmlGetLastError ();
+
+    dia_context_add_message (ctx, "%s", err->message);
+    if (err->code == XML_ERR_INVALID_CHAR && try_harder) /* fallback to temporary file with encoding approach */
+      doc = xmlDiaParseFile (filename, ctx);
+  }
+  return doc;
 }
 
 /** Find a named attribute node in an XML object node.
@@ -406,7 +436,7 @@ data_next(DataNode data)
  *  (but profile first).
  */
 DataType
-data_type(DataNode data)
+data_type(DataNode data, DiaContext *ctx)
 {
   const char *name;
 
@@ -439,7 +469,7 @@ data_type(DataNode data)
     return DATATYPE_PIXBUF;
   }
 
-  message_error("Unknown type of DataNode");
+  dia_context_add_message (ctx, _("Unknown type of DataNode '%s'"), name);
   return 0;
 }
 
@@ -449,13 +479,13 @@ data_type(DataNode data)
  *  integer node, an error message is displayed and 0 is returned.
  */
 int
-data_int(DataNode data)
+data_int(DataNode data, DiaContext *ctx)
 {
   xmlChar *val;
   int res;
   
-  if (data_type(data)!=DATATYPE_INT) {
-    message_error("Taking int value of non-int node.");
+  if (data_type(data, ctx)!=DATATYPE_INT) {
+    dia_context_add_message (ctx, _("Taking int value of non-int node."));
     return 0;
   }
 
@@ -471,13 +501,14 @@ data_int(DataNode data)
  * @returns The enum value found in the node.  If the node is not an
  *  enum node, an error message is displayed and 0 is returned.
  */
-int data_enum(DataNode data)
+int
+data_enum(DataNode data, DiaContext *ctx)
 {
   xmlChar *val;
   int res;
   
-  if (data_type(data)!=DATATYPE_ENUM) {
-    message_error("Taking enum value of non-enum node.");
+  if (data_type(data, ctx)!=DATATYPE_ENUM) {
+    dia_context_add_message (ctx, "Taking enum value of non-enum node.");
     return 0;
   }
 
@@ -494,13 +525,13 @@ int data_enum(DataNode data)
  *  real-type node, an error message is displayed and 0.0 is returned.
  */
 real
-data_real(DataNode data)
+data_real(DataNode data, DiaContext *ctx)
 {
   xmlChar *val;
   real res;
 
-  if (data_type(data)!=DATATYPE_REAL) {
-    message_error("Taking real value of non-real node.");
+  if (data_type(data, ctx)!=DATATYPE_REAL) {
+    dia_context_add_message (ctx, "Taking real value of non-real node.");
     return 0;
   }
 
@@ -517,13 +548,13 @@ data_real(DataNode data)
  *  boolean node, an error message is displayed and FALSE is returned.
  */
 int
-data_boolean(DataNode data)
+data_boolean(DataNode data, DiaContext *ctx)
 {
   xmlChar *val;
   int res;
   
-  if (data_type(data)!=DATATYPE_BOOLEAN) {
-    message_error("Taking boolean value of non-boolean node.");
+  if (data_type(data, ctx)!=DATATYPE_BOOLEAN) {
+    dia_context_add_message (ctx, "Taking boolean value of non-boolean node.");
     return 0;
   }
 
@@ -544,8 +575,8 @@ data_boolean(DataNode data)
  * @returns The value of the digit, i.e. 0-15.  If a non-gex digit is given
  *  an error message is displayed to the user, and 0 is returned.
  */
-static int 
-hex_digit(char c)
+static int
+hex_digit(char c, DiaContext *ctx)
 {
   if ((c>='0') && (c<='9'))
     return c-'0';
@@ -553,7 +584,7 @@ hex_digit(char c)
     return (c-'a') + 10;
   if ((c>='A') && (c<='F'))
     return (c-'A') + 10;
-  message_error("wrong hex digit %c", c);
+  dia_context_add_message (ctx, "wrong hex digit %c", c);
   return 0;
 }
 
@@ -565,13 +596,13 @@ hex_digit(char c)
  * @note Could be cool to use RGBA data here, even if we can't display it yet.
  */
 void
-data_color(DataNode data, Color *col)
+data_color(DataNode data, Color *col, DiaContext *ctx)
 {
   xmlChar *val;
   int r=0, g=0, b=0, a=0;
   
-  if (data_type(data)!=DATATYPE_COLOR) {
-    message_error("Taking color value of non-color node.");
+  if (data_type(data, ctx)!=DATATYPE_COLOR) {
+    dia_context_add_message (ctx, "Taking color value of non-color node.");
     return;
   }
 
@@ -581,11 +612,11 @@ data_color(DataNode data, Color *col)
   /*        0123456 */
 
   if ((val) && (xmlStrlen(val)>=7)) {
-    r = hex_digit(val[1])*16 + hex_digit(val[2]);
-    g = hex_digit(val[3])*16 + hex_digit(val[4]);
-    b = hex_digit(val[5])*16 + hex_digit(val[6]);
+    r = hex_digit(val[1], ctx)*16 + hex_digit(val[2], ctx);
+    g = hex_digit(val[3], ctx)*16 + hex_digit(val[4], ctx);
+    b = hex_digit(val[5], ctx)*16 + hex_digit(val[6], ctx);
     if (xmlStrlen(val) >= 9) {
-      a = hex_digit(val[7])*16 + hex_digit(val[8]);
+      a = hex_digit(val[7], ctx)*16 + hex_digit(val[8], ctx);
     } else {
       a = 0xff;
     }
@@ -606,14 +637,14 @@ data_color(DataNode data, Color *col)
  *  user, and `point' is unchanged.
  */
 void
-data_point(DataNode data, Point *point)
+data_point(DataNode data, Point *point, DiaContext *ctx)
 {
   xmlChar *val;
   gchar *str;
   real ax,ay;
 
-  if (data_type(data)!=DATATYPE_POINT) {
-    message_error(_("Taking point value of non-point node."));
+  if (data_type(data, ctx)!=DATATYPE_POINT) {
+    dia_context_add_message (ctx, _("Taking point value of non-point node."));
     return;
   }
   
@@ -651,12 +682,12 @@ data_point(DataNode data, Point *point)
  *  not contain a valid bezpoint zero initialization is performed.
  */
 void 
-data_bezpoint(DataNode data, BezPoint *point)
+data_bezpoint(DataNode data, BezPoint *point, DiaContext *ctx)
 {
   xmlChar *val;
   gchar *str;
-  if (data_type(data)!=DATATYPE_BEZPOINT) {
-    message_error(_("Taking bezpoint value of non-point node."));
+  if (data_type(data, ctx)!=DATATYPE_BEZPOINT) {
+    dia_context_add_message (ctx, _("Taking bezpoint value of non-point node."));
     return;
   }
   val = xmlGetProp(data, (const xmlChar *)"type");
@@ -720,13 +751,13 @@ data_bezpoint(DataNode data, BezPoint *point)
  *  user, and `rect' is unchanged.
  */
 void
-data_rectangle(DataNode data, Rectangle *rect)
+data_rectangle(DataNode data, Rectangle *rect, DiaContext *ctx)
 {
   xmlChar *val;
   gchar *str;
   
-  if (data_type(data)!=DATATYPE_RECTANGLE) {
-    message_error("Taking rectangle value of non-rectangle node.");
+  if (data_type(data, ctx)!=DATATYPE_RECTANGLE) {
+    dia_context_add_message (ctx, _("Taking rectangle value of non-rectangle node."));
     return;
   }
   
@@ -738,7 +769,7 @@ data_rectangle(DataNode data, Rectangle *rect)
     str++;
 
   if (*str==0){
-    message_error("Error parsing rectangle.");
+    dia_context_add_message (ctx, _("Error parsing rectangle."));
     xmlFree(val);
     return;
   }
@@ -749,7 +780,7 @@ data_rectangle(DataNode data, Rectangle *rect)
     str++;
 
   if (*str==0){
-    message_error("Error parsing rectangle.");
+    dia_context_add_message (ctx, _("Error parsing rectangle."));
     xmlFree(val);
     return;
   }
@@ -760,7 +791,7 @@ data_rectangle(DataNode data, Rectangle *rect)
     str++;
 
   if (*str==0){
-    message_error("Error parsing rectangle.");
+    dia_context_add_message (ctx, _("Error parsing rectangle."));
     xmlFree(val);
     return;
   }
@@ -778,14 +809,14 @@ data_rectangle(DataNode data, Rectangle *rect)
  * @note For historical reasons, strings in Dia XML are surrounded by ##.
  */
 gchar *
-data_string(DataNode data)
+data_string(DataNode data, DiaContext *ctx)
 {
   xmlChar *val;
   gchar *str, *p,*str2;
   int len;
   
-  if (data_type(data)!=DATATYPE_STRING) {
-    message_error("Taking string value of non-string node.");
+  if (data_type(data, ctx)!=DATATYPE_STRING) {
+    dia_context_add_message (ctx, _("Taking string value of non-string node."));
     return NULL;
   }
 
@@ -811,7 +842,7 @@ data_string(DataNode data)
 	  *p++ = '\\';
 	  break;
 	default:
-	  message_error("Error in string tag.");
+	  dia_context_add_message (ctx, _("Error in string tag."));
 	}
       } else {
 	*p++ = *val;
@@ -829,7 +860,7 @@ data_string(DataNode data)
     p = (char *)xmlNodeListGetString(data->doc, data->xmlChildrenNode, TRUE);
     
     if (*p!='#')
-      message_error("Error in file, string not starting with #\n");
+      dia_context_add_message (ctx, _("Error in file, string not starting with #"));
     
     len = strlen(p)-1; /* Ignore first '#' */
       
@@ -855,9 +886,9 @@ data_string(DataNode data)
  * @bug data_string() can return NULL, what does g_filename_from_utf8 do then?
  */
 char *
-data_filename(DataNode data)
+data_filename(DataNode data, DiaContext *ctx)
 {
-  char *utf8 = data_string(data);
+  char *utf8 = data_string(data, ctx);
   char *filename = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL);
   g_free(utf8);
   return filename;
@@ -871,13 +902,13 @@ data_filename(DataNode data)
  *  resulting value should be freed after use.
  */
 DiaFont *
-data_font(DataNode data)
+data_font(DataNode data, DiaContext *ctx)
 {
   xmlChar *family;
   DiaFont *font;
   
-  if (data_type(data)!=DATATYPE_FONT) {
-    message_error("Taking font value of non-font node.");
+  if (data_type(data, ctx)!=DATATYPE_FONT) {
+    dia_context_add_message (ctx, _("Taking font value of non-font node."));
     return NULL;
   }
 
diff --git a/lib/dia_xml.h b/lib/dia_xml.h
index 8ba8135..d7a4b96 100644
--- a/lib/dia_xml.h
+++ b/lib/dia_xml.h
@@ -23,6 +23,7 @@
 #include "color.h"
 #include "font.h"
 #include "diavar.h"
+#include "diacontext.h"
 #include <libxml/tree.h>
 
 /*
@@ -69,18 +70,18 @@ AttributeNode composite_find_attribute(DataNode composite_node,
 int attribute_num_data(AttributeNode attribute);
 DataNode attribute_first_data(AttributeNode attribute);
 DataNode data_next(DataNode data);
-DataType data_type(DataNode data);
-int data_int(DataNode data);
-int data_enum(DataNode data);
-real data_real(DataNode data);
-int data_boolean(DataNode data);
-void data_color(DataNode data, Color *col);
-void data_point(DataNode data, Point *point);
-void data_bezpoint(DataNode data, BezPoint *point);
-void data_rectangle(DataNode data, Rectangle *rect);
-char *data_string(DataNode data);
-char *data_filename(DataNode data);
-DiaFont *data_font(DataNode data);
+DataType data_type(DataNode data, DiaContext *ctx);
+int data_int(DataNode data, DiaContext *ctx);
+int data_enum(DataNode data, DiaContext *ctx);
+real data_real(DataNode data, DiaContext *ctx);
+int data_boolean(DataNode data, DiaContext *ctx);
+void data_color(DataNode data, Color *col, DiaContext *ctx);
+void data_point(DataNode data, Point *point, DiaContext *ctx);
+void data_bezpoint(DataNode data, BezPoint *point, DiaContext *ctx);
+void data_rectangle(DataNode data, Rectangle *rect, DiaContext *ctx);
+char *data_string(DataNode data, DiaContext *ctx);
+char *data_filename(DataNode data, DiaContext *ctx);
+DiaFont *data_font(DataNode data, DiaContext *ctx);
 
 AttributeNode new_attribute(ObjectNode obj_node, const char *attrname);
 AttributeNode composite_add_attribute(DataNode composite_node,
@@ -99,7 +100,7 @@ void data_add_font(AttributeNode attr, const DiaFont *font);
 DataNode data_add_composite(AttributeNode attr, 
                             const char *type); /* can be NULL */
 
-GHashTable *data_dict (DataNode data);
+GHashTable *data_dict (DataNode data, DiaContext *ctx);
 void data_add_dict (AttributeNode attr, GHashTable *data);
 
 GdkPixbuf *data_pixbuf (DataNode data);
@@ -108,5 +109,7 @@ void data_add_pixbuf (AttributeNode attr, GdkPixbuf *pixbuf);
 DiaMatrix *data_matrix(DataNode data);
 void data_add_matrix(AttributeNode attr, DiaMatrix *matrix);
 
+xmlDocPtr diaXmlParseFile(const char *filename, DiaContext *ctx, gboolean try_harder);
+
 #endif /* DIA_XML_H */
 
diff --git a/lib/dia_xml_libxml.h b/lib/dia_xml_libxml.h
index 11c3f83..a43e4a9 100644
--- a/lib/dia_xml_libxml.h
+++ b/lib/dia_xml_libxml.h
@@ -24,9 +24,6 @@
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 
-/* for potentially broken files */
-xmlDocPtr xmlDiaParseFile(const char *filename); 
-
 /* use this one instead of xmlParseFile */
 xmlDocPtr xmlDoParseFile(const char *filename); 
 
diff --git a/lib/diagdkrenderer.c b/lib/diagdkrenderer.c
index c813dc8..87d7772 100644
--- a/lib/diagdkrenderer.c
+++ b/lib/diagdkrenderer.c
@@ -32,7 +32,6 @@
 
 #include "diagdkrenderer.h"
 #include "dia_image.h"
-#include "message.h"
 #include "color.h"
 #include "font.h"
 #include "text.h"
@@ -506,7 +505,7 @@ set_fillstyle (DiaRenderer *object, FillStyle mode)
   case FILLSTYLE_SOLID:
     break;
   default:
-    message_error("gdk_renderer: Unsupported fill mode specified!\n");
+    g_warning("gdk_renderer: Unsupported fill mode specified!\n");
   }
 }
 
diff --git a/lib/diasvgrenderer.c b/lib/diasvgrenderer.c
index dc0d453..4d8055d 100644
--- a/lib/diasvgrenderer.c
+++ b/lib/diasvgrenderer.c
@@ -40,8 +40,6 @@
 #include <libxml/xmlmemory.h>
 
 #include "geometry.h"
-#include "intl.h"
-#include "message.h"
 #include "dia_xml_libxml.h"
 #include "dia_image.h"
 #include "dia_dirs.h"
@@ -212,7 +210,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
   case FILLSTYLE_SOLID:
     break;
   default:
-    message_error("svg_renderer: Unsupported fill mode specified!\n");
+    g_warning("svg_renderer: Unsupported fill mode specified!\n");
   }
 }
 
diff --git a/lib/element.c b/lib/element.c
index bf408f6..887b262 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -30,7 +30,6 @@
 #include <string.h> /* memcpy() */
 
 #include "element.h"
-#include "message.h"
 #include "properties.h"
 
 #ifdef G_OS_WIN32
@@ -254,7 +253,7 @@ element_move_handle(Element *elem, HandleId id,
       elem->height = p.y;
     break;
   default:
-    message_error("Error, called element_move_handle() with wrong handle-id\n");
+    g_warning("element_move_handle() called with wrong handle-id\n");
   }
   return NULL;
 }
@@ -338,7 +337,7 @@ element_move_handle_aspect(Element *elem, HandleId id,
     move_y = 0.0;
     break;
   default:
-    message_error("Error, called element_move_handle() with wrong handle-id\n");
+    g_warning("element_move_handle() called with wrong handle-id\n");
   }
 
   /* Which of the two versions to use: */
@@ -447,27 +446,27 @@ element_save(Element *elem, ObjectNode obj_node)
 }
 
 void 
-element_load(Element *elem, ObjectNode obj_node)
+element_load(Element *elem, ObjectNode obj_node, DiaContext *ctx)
 {
   AttributeNode attr;
 
-  object_load(&elem->object, obj_node);
+  object_load(&elem->object, obj_node, ctx);
 
   elem->corner.x = 0.0;
   elem->corner.y = 0.0;
   attr = object_find_attribute(obj_node, "elem_corner");
   if (attr != NULL)
-    data_point( attribute_first_data(attr), &elem->corner );
+    data_point(attribute_first_data(attr), &elem->corner, ctx);
 
   elem->width = 1.0;
   attr = object_find_attribute(obj_node, "elem_width");
   if (attr != NULL)
-    elem->width = data_real( attribute_first_data(attr));
+    elem->width = data_real(attribute_first_data(attr), ctx);
 
   elem->height = 1.0;
   attr = object_find_attribute(obj_node, "elem_height");
   if (attr != NULL)
-    elem->height = data_real( attribute_first_data(attr));
+    elem->height = data_real( attribute_first_data(attr), ctx);
 
 }
 
diff --git a/lib/element.h b/lib/element.h
index 65d0f8f..3a9eda7 100644
--- a/lib/element.h
+++ b/lib/element.h
@@ -63,7 +63,7 @@ void element_move_handle_aspect(Element *elem, HandleId id,
 				Point *to, real aspect_ratio);
 
 void element_save(Element *elem, ObjectNode obj_node);
-void element_load(Element *elem, ObjectNode obj_node);
+void element_load(Element *elem, ObjectNode obj_node, DiaContext *ctx);
 
 ObjectChange *element_change_new (const Point *corner, 
 				  real width, real height,
diff --git a/lib/filter.h b/lib/filter.h
index 2d68691..a0d76e5 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -23,7 +23,8 @@
 
 #include "diatypes.h"
 #include <glib.h>
-#include <diagramdata.h>
+#include "diagramdata.h"
+#include "diacontext.h"
 
 G_BEGIN_DECLS
 
@@ -54,8 +55,8 @@ struct _DiaExportFilter {
 };
 
 /* returns FALSE on error loading diagram */
-typedef gboolean (* DiaImportFunc) (const gchar *filename, DiagramData *dia, 
-                                    void* user_data);
+typedef gboolean (* DiaImportFunc) (const gchar* filename, DiagramData *dia, 
+                                    DiaContext *ctx, void* user_data);
 
 struct _DiaImportFilter {
   const gchar *description;
diff --git a/lib/group.c b/lib/group.c
index 1ce6c7f..89a8050 100644
--- a/lib/group.c
+++ b/lib/group.c
@@ -25,7 +25,6 @@
 #include "group.h"
 #include "properties.h"
 #include "diarenderer.h"
-#include "message.h"
 
 struct _Group {
  /* DiaObject must be first because this is a 'subclass' of it. */
@@ -252,7 +251,7 @@ group_move_handle(Group *group, Handle *handle, Point *to, ConnectionPoint *cp,
     w1 = to->x - top_left.x;
     break;
   default:
-    message_error("Error, called group_move_handle() with wrong handle-id\n");
+    g_warning("group_move_handle() called with wrong handle-id\n");
   }
 
   if (also_move)
diff --git a/lib/libdia.def b/lib/libdia.def
index 663d196..b770c95 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -205,6 +205,13 @@ EXPORTS
  dia_color_selector_set_use_alpha
  dia_config_filename
 
+ dia_context_add_message
+ dia_context_get_filename
+ dia_context_new
+ dia_context_release
+ dia_context_set_errno
+ dia_context_set_filename
+
  dia_dynamic_menu_get_type
  dia_dynamic_menu_new
  dia_dynamic_menu_new_stringbased
@@ -739,7 +746,7 @@ EXPORTS
  text_line_get_descent
  text_line_get_alignment_adjustment
 
- xmlDiaParseFile
+ diaXmlParseFile
  xmlDiaSaveFile
  xmlDoParseFile
 
diff --git a/lib/makefile.msc b/lib/makefile.msc
index a6a8be3..13fa4bc 100644
--- a/lib/makefile.msc
+++ b/lib/makefile.msc
@@ -55,6 +55,7 @@ OBJECTS = \
 	diaarrowchooser.obj \
 	diaarrowselector.obj \
 	diacolorselector.obj \
+	diacontext.obj \
 	dialinechooser.obj \
 	dialinestyleselector.obj \
 	dialogs.obj \
@@ -173,5 +174,12 @@ font-height.exe : font-height.obj
 	$(PKG_LINK) $(LDFLAGS) gdi32.lib user32.lib $(LDFLAGS) /subsystem:console
 
 splint :
-	sp -weak $(CFLAGS) *.c >sp.log
-	
+	sp -weak -fcnuse $(CFLAGS) proplist.c >sp.log
+
+!IFDEF SCA
+#sca : $(OBJECTS)
+#	clang -analyze $(INCLUDES) $(DEFINES)
+# Not using $(CFLAGS) for msvc either
+.c.obj :
+	clang --analyze $(INCLUDES) $(DEFINES) $(PKG_CFLAGS) $<
+!ENDIF
\ No newline at end of file
diff --git a/lib/neworth_conn.c b/lib/neworth_conn.c
index 2ccce5c..c5dbdf4 100644
--- a/lib/neworth_conn.c
+++ b/lib/neworth_conn.c
@@ -28,7 +28,6 @@
 
 #include "neworth_conn.h"
 #include "connectionpoint.h"
-#include "message.h"
 #include "diamenu.h"
 #include "handle.h"
 #include "diarenderer.h"
@@ -202,7 +201,7 @@ neworthconn_move_handle(NewOrthConn *orth, Handle *handle,
     } 
     break;
   default:
-    message_error("Internal error in neworthconn_move_handle.\n");
+    g_warning("Internal error in neworthconn_move_handle.\n");
     break;
   }
 
@@ -601,7 +600,8 @@ neworthconn_save(NewOrthConn *orth, ObjectNode obj_node)
 }
 
 void
-neworthconn_load(NewOrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_init() */
+neworthconn_load(NewOrthConn *orth, ObjectNode obj_node,
+		 DiaContext *ctx) /* NOTE: Does object_init() */
 {
   int i;
   AttributeNode attr;
@@ -610,7 +610,7 @@ neworthconn_load(NewOrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_in
   
   DiaObject *obj = &orth->object;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "orth_points");
 
@@ -626,7 +626,7 @@ neworthconn_load(NewOrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_in
   data = attribute_first_data(attr);
   orth->points = g_malloc((orth->numpoints)*sizeof(Point));
   for (i=0;i<orth->numpoints;i++) {
-    data_point(data, &orth->points[i]);
+    data_point(data, &orth->points[i], ctx);
     data = data_next(data);
   }
 
@@ -635,7 +635,7 @@ neworthconn_load(NewOrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_in
   data = attribute_first_data(attr);
   orth->orientation = g_malloc((orth->numpoints-1)*sizeof(Orientation));
   for (i=0;i<orth->numpoints-1;i++) {
-    orth->orientation[i] = data_enum(data);
+    orth->orientation[i] = data_enum(data, ctx);
     data = data_next(data);
   }
 
diff --git a/lib/neworth_conn.h b/lib/neworth_conn.h
index 5a8506f..2d248f3 100644
--- a/lib/neworth_conn.h
+++ b/lib/neworth_conn.h
@@ -67,7 +67,7 @@ void neworthconn_init(NewOrthConn *orth, Point *startpoint);
 void neworthconn_destroy(NewOrthConn *orth);
 void neworthconn_copy(NewOrthConn *from, NewOrthConn *to);
 void neworthconn_save(NewOrthConn *orth, ObjectNode obj_node);
-void neworthconn_load(NewOrthConn *orth, ObjectNode obj_node);  /* NOTE: Does object_init() */
+void neworthconn_load(NewOrthConn *orth, ObjectNode obj_node, DiaContext *ctx);  /* NOTE: Does object_init() */
 ObjectChange* neworthconn_move_handle(NewOrthConn *orth, Handle *id,
 				      Point *to, ConnectionPoint *cp,
 				      HandleMoveReason reason,
diff --git a/lib/object-alias.c b/lib/object-alias.c
index 8d1b42e..faa0498 100644
--- a/lib/object-alias.c
+++ b/lib/object-alias.c
@@ -82,7 +82,7 @@ _alias_create (Point *startpoint,
 	       Handle **handle1,
 	       Handle **handle2);
 static DiaObject *
-_alias_load (ObjectNode obj_node, int version, const char *filename);
+_alias_load (ObjectNode obj_node, int version, const char *filename, DiaContext *ctx);
 static void
 _alias_save (DiaObject *obj, ObjectNode obj_node, const char *filename);
 
@@ -125,7 +125,7 @@ _alias_create (Point *startpoint,
 }
 
 static DiaObject *
-_alias_load (ObjectNode obj_node, int version, const char *filename)
+_alias_load (ObjectNode obj_node, int version, const char *filename, DiaContext *ctx)
 {
   DiaObject *obj = NULL;
   xmlChar *str;
@@ -140,7 +140,7 @@ _alias_load (ObjectNode obj_node, int version, const char *filename)
      * just another reason to pass in the exlplicit this-pointer in every method.
      */
     obj = real_type->ops->create (&apoint, real_type->default_user_data, &h1, &h2);
-    object_load_props (obj, obj_node);
+    object_load_props (obj, obj_node, ctx);
 #ifdef MODIFY_OBJECTS_TYPE
     /* now modify the object for some behavior change */
     obj->type = object_get_type ((char *)str); /* also changes the name */
diff --git a/lib/object.c b/lib/object.c
index a74d6a4..b815ffe 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -602,7 +602,7 @@ object_save(DiaObject *obj, ObjectNode obj_node)
  * @param obj_node An XML node to load the data from.
  */
 void 
-object_load(DiaObject *obj, ObjectNode obj_node)
+object_load(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx)
 {
   AttributeNode attr;
 
@@ -610,17 +610,17 @@ object_load(DiaObject *obj, ObjectNode obj_node)
   obj->position.y = 0.0;
   attr = object_find_attribute(obj_node, "obj_pos");
   if (attr != NULL)
-    data_point( attribute_first_data(attr), &obj->position );
+    data_point(attribute_first_data(attr), &obj->position, ctx);
 
   obj->bounding_box.left = obj->bounding_box.right = 0.0;
   obj->bounding_box.top = obj->bounding_box.bottom = 0.0;
   attr = object_find_attribute(obj_node, "obj_bb");
   if (attr != NULL)
-    data_rectangle( attribute_first_data(attr), &obj->bounding_box );
+    data_rectangle(attribute_first_data(attr), &obj->bounding_box, ctx);
 
   attr = object_find_attribute(obj_node, "meta");
   if (attr != NULL)
-    obj->meta = data_dict (attribute_first_data(attr));
+    obj->meta = data_dict (attribute_first_data(attr), ctx);
 }
 
 /** Returns the layer that the given object belongs to.
@@ -806,14 +806,14 @@ object_flags_set(DiaObject *obj, gint flags)
 DiaObject *
 object_load_using_properties(const DiaObjectType *type,
                              ObjectNode obj_node, int version,
-                             const char *filename)
+                             DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = type->ops->create(&startpoint,NULL, &handle1,&handle2);
-  object_load_props(obj,obj_node);
+  object_load_props(obj,obj_node,ctx);
   return obj;
 }
 
diff --git a/lib/object.h b/lib/object.h
index 0031cd5..d0b3509 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -32,6 +32,7 @@
 #include "objchange.h"
 #include "dia_xml.h"
 #include "text.h"
+#include "diacontext.h"
 
 G_BEGIN_DECLS
 
@@ -107,7 +108,7 @@ typedef DiaObject* (*CreateFunc) (Point *startpoint,
  *                 error messages.
  */
 typedef DiaObject* (*LoadFunc) (ObjectNode obj_node, int version,
-				const char *filename);
+				DiaContext *ctx);
 
 /** This function save the object's data to file fd. No header is required.
  *  The data should be written using the functions in lib/files.h
@@ -350,7 +351,7 @@ void object_destroy(DiaObject *obj); /* Unconnects handles, so don't
 void object_copy(DiaObject *from, DiaObject *to);
 
 void object_save(DiaObject *obj, ObjectNode obj_node);
-void object_load(DiaObject *obj, ObjectNode obj_node);
+void object_load(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx);
 
 GList *object_copy_list(GList *list);
 ObjectChange* object_list_move_delta_r(GList *objects, Point *delta, gboolean affected);
@@ -387,8 +388,8 @@ gboolean object_flags_set(DiaObject* obj, gint flags);
    can be completely described, loaded and saved through standard properties.
 */
 DiaObject *object_load_using_properties(const DiaObjectType *type,
-                                     ObjectNode obj_node, int version,
-                                     const char *filename);
+					ObjectNode obj_node, int version,
+					DiaContext *ctx);
 void object_save_using_properties(DiaObject *obj, ObjectNode obj_node, 
                                   const char *filename);
 DiaObject *object_copy_using_properties(DiaObject *obj);
@@ -548,7 +549,8 @@ struct _DiaObjectType {
 
 
 gboolean       dia_object_defaults_load (const gchar *filename,
-                                         gboolean create_lazy);
+                                         gboolean create_lazy,
+					 DiaContext *ctx);
 DiaObject  *dia_object_default_get  (const DiaObjectType *type, gpointer user_data);
 DiaObject  *dia_object_default_create (const DiaObjectType *type,
                                     Point *startpoint,
@@ -572,7 +574,7 @@ gchar *dia_object_get_meta (DiaObject *obj, const gchar *key);
 int dia_object_get_num_connections (DiaObject *obj);
 
 /* standard way to load/save properties of an object */
-void          object_load_props(DiaObject *obj, ObjectNode obj_node);
+void          object_load_props(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx);
 void          object_save_props(DiaObject *obj, ObjectNode obj_node);
 
 /* standard way to copy the properties of an object into another (of the
diff --git a/lib/object_defaults.c b/lib/object_defaults.c
index 1f5e004..20ad2b5 100644
--- a/lib/object_defaults.c
+++ b/lib/object_defaults.c
@@ -34,7 +34,7 @@
 #include "dia_xml_libxml.h"
 #include "dia_xml.h"
 #include "object.h"
-#include "message.h"
+#include "diacontext.h"
 #include "dia_dirs.h"
 #include "propinternals.h"
  
@@ -86,7 +86,7 @@ _obj_destroy (gpointer val)
  * Create all the default objects.
  */
 gboolean
-dia_object_defaults_load (const gchar *filename, gboolean create_lazy)
+dia_object_defaults_load (const gchar *filename, gboolean create_lazy, DiaContext *ctx)
 {
   xmlDocPtr doc;
   xmlNsPtr name_space;
@@ -109,14 +109,18 @@ dia_object_defaults_load (const gchar *filename, gboolean create_lazy)
     {
       gchar *default_filename = dia_config_filename("defaults.dia");
 
+      dia_context_set_filename(ctx, default_filename);
       if (g_file_test(default_filename, G_FILE_TEST_EXISTS))
-        doc = xmlDiaParseFile(default_filename);
+        doc = diaXmlParseFile (default_filename, ctx, FALSE);
       else
         doc = NULL;
       g_free (default_filename);
     } 
   else
-      doc = xmlDiaParseFile(filename);
+    {
+      dia_context_set_filename (ctx, filename);
+      doc = diaXmlParseFile (filename, ctx, FALSE);
+    }
 
   if (!doc)
       return FALSE;
@@ -125,9 +129,8 @@ dia_object_defaults_load (const gchar *filename, gboolean create_lazy)
   if (xmlStrcmp (doc->xmlRootNode->name, (const xmlChar *)"diagram") 
       || (name_space == NULL))
     {
-      message_error(_("Error loading defaults '%s'.\n"
-                      "Not a Dia diagram file."),
-		    dia_message_filename(filename));
+      dia_context_add_message(ctx, _("Error loading defaults '%s'.\n"
+				     "Not a Dia diagram file."), filename);
       xmlFreeDoc (doc);
       return FALSE;
     }
@@ -161,7 +164,7 @@ dia_object_defaults_load (const gchar *filename, gboolean create_lazy)
 			        obj = type->ops->load (
 					obj_node,
 					version ? atoi(version) : 0,
-					filename);
+					ctx);
 			      if (obj)
 			        g_hash_table_insert (defaults_hash,
 			                             obj->type->name, obj);
@@ -170,13 +173,13 @@ dia_object_defaults_load (const gchar *filename, gboolean create_lazy)
 		      else
 		        {
 #if 0 /* lots of complaining about missing attributes */
-			  object_load_props(obj, obj_node); /* leaks ?? */
+			  object_load_props(obj, obj_node, ctx); /* leaks ?? */
 #else
 			  DiaObject *def_obj;
 			  def_obj = obj->type->ops->load (
 					obj_node,
 			                version ? atoi(version) : 0,
-					filename);
+					ctx);
 			  if (def_obj->ops->set_props)
 			    { 
 			      object_copy_props (obj, def_obj, TRUE);
@@ -200,7 +203,6 @@ dia_object_defaults_load (const gchar *filename, gboolean create_lazy)
 	}
       layer_node = layer_node->next;
     }
-
   xmlFreeDoc(doc);
   return TRUE;
 }
diff --git a/lib/orth_conn.c b/lib/orth_conn.c
index dc95863..db04cbc 100644
--- a/lib/orth_conn.c
+++ b/lib/orth_conn.c
@@ -219,7 +219,7 @@ orthconn_move_handle(OrthConn *orth, Handle *handle,
     } 
     break;
   default:
-    message_error("Internal error in orthconn_move_handle.\n");
+    g_warning("Internal error in orthconn_move_handle.\n");
     break;
   }
 
@@ -629,7 +629,8 @@ orthconn_save(OrthConn *orth, ObjectNode obj_node)
 }
 
 void
-orthconn_load(OrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_init() */
+orthconn_load(OrthConn *orth, ObjectNode obj_node,
+	      DiaContext *ctx) /* NOTE: Does object_init() */
 {
   int i;
   AttributeNode attr;
@@ -639,7 +640,7 @@ orthconn_load(OrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_init() *
   
   DiaObject *obj = &orth->object;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "version");
   if (attr != NULL)
@@ -659,7 +660,7 @@ orthconn_load(OrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_init() *
   data = attribute_first_data(attr);
   orth->points = g_malloc0((orth->numpoints)*sizeof(Point));
   for (i=0;i<orth->numpoints;i++) {
-    data_point(data, &orth->points[i]);
+    data_point(data, &orth->points[i], ctx);
     data = data_next(data);
   }
 
@@ -668,14 +669,14 @@ orthconn_load(OrthConn *orth, ObjectNode obj_node) /* NOTE: Does object_init() *
   data = attribute_first_data(attr);
   orth->orientation = g_malloc0((orth->numpoints-1)*sizeof(Orientation));
   for (i=0;i<orth->numpoints-1;i++) {
-    orth->orientation[i] = data_enum(data);
+    orth->orientation[i] = data_enum(data, ctx);
     data = data_next(data);
   }
 
   orth->autorouting = TRUE;
   attr = object_find_attribute(obj_node, "autorouting");
   if (attr != NULL)
-    orth->autorouting = data_boolean(attribute_first_data(attr));
+    orth->autorouting = data_boolean(attribute_first_data(attr), ctx);
   else if (version == 0) {
     /* Version 0 orthconns have no autorouting. */
     orth->autorouting = FALSE;
diff --git a/lib/orth_conn.h b/lib/orth_conn.h
index f280a0c..ad93e36 100644
--- a/lib/orth_conn.h
+++ b/lib/orth_conn.h
@@ -65,7 +65,7 @@ void orthconn_destroy(OrthConn *orth);
 void orthconn_set_points(OrthConn *orth, int num_points, Point *points);
 void orthconn_copy(OrthConn *from, OrthConn *to);
 void orthconn_save(OrthConn *orth, ObjectNode obj_node);
-void orthconn_load(OrthConn *orth, ObjectNode obj_node);  /* NOTE: Does object_init() */
+void orthconn_load(OrthConn *orth, ObjectNode obj_node, DiaContext *ctx);  /* NOTE: Does object_init() */
 ObjectChange* orthconn_move_handle(OrthConn *orth, Handle *id,
 				   Point *to, ConnectionPoint *cp,
 				   HandleMoveReason reason,
diff --git a/lib/persistence.c b/lib/persistence.c
index 6081431..38f5f9a 100644
--- a/lib/persistence.c
+++ b/lib/persistence.c
@@ -34,7 +34,9 @@
 #include "dia_dirs.h"
 #include "dia_xml_libxml.h"
 #include "dia_xml.h"
-#include "message.h"
+#include "message.h" /* only for dia_log_message() */
+#include "diacontext.h"
+#include "intl.h"
 
 #include <gtk/gtk.h>
 #include <libxml/tree.h>
@@ -79,36 +81,36 @@ _dia_hash_table_str_any_new (void)
 
 /* *********************** LOADING FUNCTIONS *********************** */
 
-typedef void (*PersistenceLoadFunc)(gchar *role, xmlNodePtr node);
+typedef void (*PersistenceLoadFunc)(gchar *role, xmlNodePtr node, DiaContext *ctx);
 
 static void
-persistence_load_window(gchar *role, xmlNodePtr node)
+persistence_load_window(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
   PersistentWindow *wininfo = g_new0(PersistentWindow, 1);
 
   attr = composite_find_attribute(node, "xpos");
   if (attr != NULL)
-    wininfo->x = data_int(attribute_first_data(attr));
+    wininfo->x = data_int(attribute_first_data(attr), ctx);
   attr = composite_find_attribute(node, "ypos");
   if (attr != NULL)
-    wininfo->y = data_int(attribute_first_data(attr));
+    wininfo->y = data_int(attribute_first_data(attr), ctx);
   attr = composite_find_attribute(node, "width");
   if (attr != NULL)
-    wininfo->width = data_int(attribute_first_data(attr));
+    wininfo->width = data_int(attribute_first_data(attr), ctx);
   attr = composite_find_attribute(node, "height");
   if (attr != NULL)
-    wininfo->height = data_int(attribute_first_data(attr));
+    wininfo->height = data_int(attribute_first_data(attr), ctx);
   attr = composite_find_attribute(node, "isopen");
   if (attr != NULL)
-    wininfo->isopen = data_boolean(attribute_first_data(attr));
+    wininfo->isopen = data_boolean(attribute_first_data(attr), ctx);
 
   g_hash_table_insert(persistent_windows, role, wininfo);
 }
 
 /** Load a persistent string into the strings hashtable */
 static void
-persistence_load_entrystring(gchar *role, xmlNodePtr node)
+persistence_load_entrystring(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
   gchar *string = NULL;
@@ -116,7 +118,7 @@ persistence_load_entrystring(gchar *role, xmlNodePtr node)
   /* Find the contents? */
   attr = composite_find_attribute(node, "stringvalue");
   if (attr != NULL)
-    string = data_string(attribute_first_data(attr));
+    string = data_string(attribute_first_data(attr), ctx);
   else 
     return;
 
@@ -125,7 +127,7 @@ persistence_load_entrystring(gchar *role, xmlNodePtr node)
 }
 
 static void
-persistence_load_list(gchar *role, xmlNodePtr node)
+persistence_load_list(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
   gchar *string = NULL;
@@ -133,7 +135,7 @@ persistence_load_list(gchar *role, xmlNodePtr node)
   /* Find the contents? */
   attr = composite_find_attribute(node, "listvalue");
   if (attr != NULL)
-    string = data_string(attribute_first_data(attr));
+    string = data_string(attribute_first_data(attr), ctx);
   else 
     return;
 
@@ -159,7 +161,7 @@ persistence_load_list(gchar *role, xmlNodePtr node)
 }
 
 static void
-persistence_load_integer(gchar *role, xmlNodePtr node)
+persistence_load_integer(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
 
@@ -167,13 +169,13 @@ persistence_load_integer(gchar *role, xmlNodePtr node)
   attr = composite_find_attribute(node, "intvalue");
   if (attr != NULL) {
     gint *integer = g_new(gint, 1);
-    *integer = data_int(attribute_first_data(attr));
+    *integer = data_int(attribute_first_data(attr), ctx);
     g_hash_table_insert(persistent_integers, role, integer);
   }
 }
 
 static void
-persistence_load_real(gchar *role, xmlNodePtr node)
+persistence_load_real(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
 
@@ -181,13 +183,13 @@ persistence_load_real(gchar *role, xmlNodePtr node)
   attr = composite_find_attribute(node, "realvalue");
   if (attr != NULL) {
     real *realval = g_new(real, 1);
-    *realval = data_real(attribute_first_data(attr));
+    *realval = data_real(attribute_first_data(attr), ctx);
     g_hash_table_insert(persistent_reals, role, realval);
   }
 }
 
 static void
-persistence_load_boolean(gchar *role, xmlNodePtr node)
+persistence_load_boolean(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
 
@@ -195,26 +197,26 @@ persistence_load_boolean(gchar *role, xmlNodePtr node)
   attr = composite_find_attribute(node, "booleanvalue");
   if (attr != NULL) {
     gboolean *booleanval = g_new(gboolean, 1);
-    *booleanval = data_boolean(attribute_first_data(attr));
+    *booleanval = data_boolean(attribute_first_data(attr), ctx);
     g_hash_table_insert(persistent_booleans, role, booleanval);
   }
 }
 
 static void
-persistence_load_string(gchar *role, xmlNodePtr node)
+persistence_load_string(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
 
   /* Find the contents? */
   attr = composite_find_attribute(node, "stringvalue");
   if (attr != NULL) {
-    gchar *stringval = data_string(attribute_first_data(attr));
+    gchar *stringval = data_string(attribute_first_data(attr), ctx);
     g_hash_table_insert(persistent_strings, role, stringval);
   }
 }
 
 static void
-persistence_load_color(gchar *role, xmlNodePtr node)
+persistence_load_color(gchar *role, xmlNodePtr node, DiaContext *ctx)
 {
   AttributeNode attr;
 
@@ -222,7 +224,7 @@ persistence_load_color(gchar *role, xmlNodePtr node)
   attr = composite_find_attribute(node, "colorvalue");
   if (attr != NULL) {
     Color *colorval = g_new(Color, 1);
-    data_color(attribute_first_data(attr), colorval);
+    data_color(attribute_first_data(attr), colorval, ctx);
     g_hash_table_insert(persistent_colors, role, colorval);
   }
 }
@@ -230,10 +232,10 @@ persistence_load_color(gchar *role, xmlNodePtr node)
 static GHashTable *type_handlers;
 
 /** Load the named type of entries using the given function.
- * func is a void (*func)(gchar *role, xmlNodePtr *node)
+ * func is a void (*func)(gchar *role, xmlNodePtr *node, DiaContext *ctx)
  */
 static void
-persistence_load_type(xmlNodePtr node)
+persistence_load_type(xmlNodePtr node, DiaContext *ctx)
 {
   const gchar *typename = (gchar *) node->name;
   gchar *name;
@@ -249,7 +251,7 @@ persistence_load_type(xmlNodePtr node)
     return;
   }
   
-  (*func)(name, node);
+  (*func)(name, node, ctx);
 }
 
 static void
@@ -305,6 +307,7 @@ persistence_load()
 {
   xmlDocPtr doc;
   gchar *filename = dia_config_filename("persistence");
+  DiaContext *ctx;
 
   persistence_init();
 
@@ -312,7 +315,9 @@ persistence_load()
     g_free (filename);
     return;
   }
-  doc = xmlDiaParseFile(filename);
+  ctx = dia_context_new(_("Persistence"));
+  dia_context_set_filename(ctx, filename);
+  doc = diaXmlParseFile(filename, ctx, FALSE);
   if (doc != NULL) {
     if (doc->xmlRootNode != NULL) {
       xmlNsPtr namespace = xmlSearchNs(doc, doc->xmlRootNode, (const xmlChar *)"dia");
@@ -320,13 +325,14 @@ persistence_load()
 	  namespace != NULL) {
 	xmlNodePtr child_node = doc->xmlRootNode->children;
 	for (; child_node != NULL; child_node = child_node->next) {
-	  persistence_load_type(child_node);
+	  persistence_load_type(child_node, ctx);
 	}
       }
     }
     xmlFreeDoc(doc);
   }
   g_free(filename);
+  dia_context_release(ctx);
 }
 
 /* *********************** SAVING FUNCTIONS *********************** */
diff --git a/lib/plug-ins.c b/lib/plug-ins.c
index d7b9431..87ae62b 100644
--- a/lib/plug-ins.c
+++ b/lib/plug-ins.c
@@ -36,10 +36,10 @@
 #include <libxml/tree.h>
 #include "dia_xml_libxml.h"
 #include "dia_xml.h"
+#include "intl.h"
+#include "message.h" /* only for dia_log_message() */
 
 #include "plug-ins.h"
-#include "intl.h"
-#include "message.h"
 #include "dia_dirs.h"
 
 #ifdef G_OS_WIN32
@@ -300,7 +300,7 @@ for_each_in_dir(const gchar *directory, ForEachInDirDoFunc dofunc,
 
   dp = g_dir_open(directory, 0, &error);
   if (dp == NULL) {
-    message_warning(_("Could not open `%s'\n`%s'"), directory, error->message);
+    g_warning("Could not open `%s'\n`%s'", directory, error->message);
     g_error_free (error);
     return;
   }
@@ -438,12 +438,14 @@ static void
 ensure_pluginrc(void)
 {
   gchar *filename;
+  DiaContext *ctx = dia_context_new (_("Plugin Configuration"));
 
   if (pluginrc)
     return;
   filename = dia_config_filename("pluginrc");
+  dia_context_set_filename (ctx, filename);
   if (g_file_test (filename,  G_FILE_TEST_IS_REGULAR))
-    pluginrc = xmlDiaParseFile(filename);
+    pluginrc = diaXmlParseFile(filename, ctx, FALSE);
   else
     pluginrc = NULL;
   
@@ -455,6 +457,7 @@ ensure_pluginrc(void)
     xmlDocSetRootElement(pluginrc,
 			 xmlNewDocNode(pluginrc, NULL, (const xmlChar *)"plugins", NULL));
   }
+  dia_context_release (ctx);
 }
 
 static void
diff --git a/lib/poly_conn.c b/lib/poly_conn.c
index ccd1167..301b465 100644
--- a/lib/poly_conn.c
+++ b/lib/poly_conn.c
@@ -25,7 +25,6 @@
 #include <string.h> /* memcpy() */
 
 #include "poly_conn.h"
-#include "message.h"
 #include "diarenderer.h"
 
 enum change_type {
@@ -100,7 +99,7 @@ polyconn_move_handle(PolyConn *poly, Handle *handle,
     poly->points[handle_nr] = *to;
     break;
   default:
-    message_error("Internal error in polyconn_move_handle.\n");
+    g_warning("Internal error in polyconn_move_handle.\n");
     break;
   }
 
@@ -455,7 +454,7 @@ polyconn_save(PolyConn *poly, ObjectNode obj_node)
 }
 
 void
-polyconn_load(PolyConn *poly, ObjectNode obj_node) /* NOTE: Does object_init() */
+polyconn_load(PolyConn *poly, ObjectNode obj_node, DiaContext *ctx) /* NOTE: Does object_init() */
 {
   int i;
   AttributeNode attr;
@@ -463,7 +462,7 @@ polyconn_load(PolyConn *poly, ObjectNode obj_node) /* NOTE: Does object_init() *
   
   DiaObject *obj = &poly->object;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "poly_points");
 
@@ -477,7 +476,7 @@ polyconn_load(PolyConn *poly, ObjectNode obj_node) /* NOTE: Does object_init() *
   data = attribute_first_data(attr);
   poly->points = g_malloc(poly->numpoints*sizeof(Point));
   for (i=0;i<poly->numpoints;i++) {
-    data_point(data, &poly->points[i]);
+    data_point(data, &poly->points[i], ctx);
     data = data_next(data);
   }
 
diff --git a/lib/poly_conn.h b/lib/poly_conn.h
index 95c303d..03ba71a 100644
--- a/lib/poly_conn.h
+++ b/lib/poly_conn.h
@@ -46,7 +46,7 @@ void polyconn_set_points(PolyConn *poly, int num_points, Point *points);
 void polyconn_destroy(PolyConn *poly);
 void polyconn_copy(PolyConn *from, PolyConn *to);
 void polyconn_save(PolyConn *poly, ObjectNode obj_node);
-void polyconn_load(PolyConn *poly, ObjectNode obj_node);  /* NOTE: Does object_init() */
+void polyconn_load(PolyConn *poly, ObjectNode obj_node, DiaContext *ctx);  /* NOTE: Does object_init() */
 ObjectChange *polyconn_add_point(PolyConn *poly, int segment, Point *point);
 ObjectChange *polyconn_remove_point(PolyConn *poly, int point);
 ObjectChange *polyconn_move_handle(PolyConn *poly, Handle *id,
diff --git a/lib/polyshape.c b/lib/polyshape.c
index e04e0df..8f3fb0d 100644
--- a/lib/polyshape.c
+++ b/lib/polyshape.c
@@ -526,7 +526,7 @@ polyshape_save(PolyShape *poly, ObjectNode obj_node)
 }
 
 void
-polyshape_load(PolyShape *poly, ObjectNode obj_node) /* NOTE: Does object_init() */
+polyshape_load(PolyShape *poly, ObjectNode obj_node, DiaContext *ctx) /* NOTE: Does object_init() */
 {
   int i;
   AttributeNode attr;
@@ -534,7 +534,7 @@ polyshape_load(PolyShape *poly, ObjectNode obj_node) /* NOTE: Does object_init()
   
   DiaObject *obj = &poly->object;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "poly_points");
 
@@ -548,7 +548,7 @@ polyshape_load(PolyShape *poly, ObjectNode obj_node) /* NOTE: Does object_init()
   data = attribute_first_data(attr);
   poly->points = g_new(Point, poly->numpoints);
   for (i=0;i<poly->numpoints;i++) {
-    data_point(data, &poly->points[i]);
+    data_point(data, &poly->points[i], ctx);
     data = data_next(data);
   }
 
diff --git a/lib/polyshape.h b/lib/polyshape.h
index f6a381e..d478584 100644
--- a/lib/polyshape.h
+++ b/lib/polyshape.h
@@ -45,7 +45,7 @@ void polyshape_set_points(PolyShape *poly, int num_points, Point *points);
 void polyshape_destroy(PolyShape *poly);
 void polyshape_copy(PolyShape *from, PolyShape *to);
 void polyshape_save(PolyShape *poly, ObjectNode obj_node);
-void polyshape_load(PolyShape *poly, ObjectNode obj_node);  /* NOTE: Does object_init() */
+void polyshape_load(PolyShape *poly, ObjectNode obj_node, DiaContext *ctx);  /* NOTE: Does object_init() */
 ObjectChange *polyshape_add_point(PolyShape *poly, int segment, Point *point);
 ObjectChange *polyshape_remove_point(PolyShape *poly, int point);
 ObjectChange *polyshape_move_handle(PolyShape *poly, Handle *id,
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index 8b891bc..310c791 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -86,21 +86,21 @@ linestyleprop_set_from_widget(LinestyleProperty *prop, WIDGET *widget)
 }
 
 static void 
-linestyleprop_load(LinestyleProperty *prop, AttributeNode attr, DataNode data)
+linestyleprop_load(LinestyleProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  prop->style = data_enum(data);
+  prop->style = data_enum(data, ctx);
   prop->dash = 1.0;
   /* don't bother checking dash length if we have a solid line. */
   if (prop->style != LINESTYLE_SOLID) {
     data = data_next(data);
     if (data)
-      prop->dash = data_real(data);
+      prop->dash = data_real(data, ctx);
     else {
       ObjectNode obj_node = attr->parent;
       /* backward compatibility */
       if ((attr = object_find_attribute(obj_node, "dashlength")) &&
           (data = attribute_first_data(attr)))
-        prop->dash = data_real(data);
+        prop->dash = data_real(data, ctx);
     }
   }
 }
@@ -197,12 +197,12 @@ arrowprop_set_from_widget(ArrowProperty *prop, WIDGET *widget)
 }
 
 static void 
-arrowprop_load(ArrowProperty *prop, AttributeNode attr, DataNode data)
+arrowprop_load(ArrowProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   /* Maybe it would be better to store arrows as a single composite
    * attribute rather than three seperate attributes. This would break
    * binary compatibility though.*/
-  prop->arrow_data.type = data_enum(data);
+  prop->arrow_data.type = data_enum(data, ctx);
   prop->arrow_data.length = DEFAULT_ARROW_SIZE;
   prop->arrow_data.width = DEFAULT_ARROW_SIZE;
   if (prop->arrow_data.type != ARROW_NONE) {
@@ -210,12 +210,12 @@ arrowprop_load(ArrowProperty *prop, AttributeNode attr, DataNode data)
     gchar *str = g_strconcat(prop->common.descr->name, "_length", NULL);
     if ((attr = object_find_attribute(obj_node, str)) &&
         (data = attribute_first_data(attr)))
-      prop->arrow_data.length = data_real(data);
+      prop->arrow_data.length = data_real(data, ctx);
     g_free(str);
     str = g_strconcat(prop->common.descr->name, "_width", NULL);
     if ((attr = object_find_attribute(obj_node, str)) &&
         (data = attribute_first_data(attr)))
-      prop->arrow_data.width = data_real(data);
+      prop->arrow_data.width = data_real(data, ctx);
     g_free(str);
   }
 }
@@ -317,9 +317,9 @@ colorprop_set_from_widget(ColorProperty *prop, WIDGET *widget)
 }
 
 static void 
-colorprop_load(ColorProperty *prop, AttributeNode attr, DataNode data)
+colorprop_load(ColorProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  data_color(data,&prop->color_data);
+  data_color(data,&prop->color_data, ctx);
 }
 
 static void 
@@ -416,11 +416,11 @@ fontprop_set_from_widget(FontProperty *prop, WIDGET *widget)
 }
 
 static void 
-fontprop_load(FontProperty *prop, AttributeNode attr, DataNode data)
+fontprop_load(FontProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   if (prop->font_data)
     dia_font_unref(prop->font_data);
-  prop->font_data = data_font(data);
+  prop->font_data = data_font(data, ctx);
 }
 
 static void 
diff --git a/lib/prop_basic.c b/lib/prop_basic.c
index 0f01530..454de5d 100644
--- a/lib/prop_basic.c
+++ b/lib/prop_basic.c
@@ -143,9 +143,9 @@ commonprop_set_from_widget(Property *prop, WIDGET *widget)
 }
 
 static void 
-commonprop_load(Property *prop, AttributeNode attr, DataNode data)
+commonprop_load(Property *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  prop->real_ops->load(prop,attr,data);
+  prop->real_ops->load(prop,attr,data,ctx);
   prop->experience |= PXP_LOADED;
 }
 
@@ -272,7 +272,7 @@ noopprop_set_from_widget(NoopProperty *prop, WIDGET *widget)
 }
 
 void 
-noopprop_load(NoopProperty *prop, AttributeNode attr, DataNode data)
+noopprop_load(NoopProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
 }
 
@@ -366,7 +366,7 @@ invalidprop_set_from_widget(InvalidProperty *prop, WIDGET *widget)
 }
 
 void 
-invalidprop_load(InvalidProperty *prop, AttributeNode attr, DataNode data)
+invalidprop_load(InvalidProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {  
   g_assert_not_reached();
 }
@@ -460,7 +460,8 @@ unimplementedprop_set_from_widget(UnimplementedProperty *prop, WIDGET *widget)
 
 void 
 unimplementedprop_load(UnimplementedProperty *prop, 
-                       AttributeNode attr, DataNode data) 
+                       AttributeNode attr, DataNode data,
+		       DiaContext *ctx) 
 {
  g_warning("%s: for property %s",G_STRFUNC,prop->common.descr->name); 
 }
diff --git a/lib/prop_basic.h b/lib/prop_basic.h
index b1ac544..08504fd 100644
--- a/lib/prop_basic.h
+++ b/lib/prop_basic.h
@@ -44,7 +44,7 @@ NoopProperty *noopprop_copy(NoopProperty *src);
 WIDGET *noopprop_get_widget(NoopProperty *prop, PropDialog *dialog);
 void noopprop_reset_widget(NoopProperty *prop, WIDGET *widget);
 void noopprop_set_from_widget(NoopProperty *prop, WIDGET *widget);
-void noopprop_load(NoopProperty *prop, AttributeNode attr, DataNode data);
+void noopprop_load(NoopProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx);
 void noopprop_save(NoopProperty *prop, AttributeNode attr);
 gboolean noopprop_can_merge(const PropDescription *pd1, 
                             const PropDescription *pd2);
@@ -67,7 +67,7 @@ WIDGET *invalidprop_get_widget(InvalidProperty *prop, PropDialog *dialog);
 void invalidprop_reset_widget(InvalidProperty *prop, WIDGET *widget);
 void invalidprop_set_from_widget(InvalidProperty *prop, WIDGET *widget);
 void invalidprop_load(InvalidProperty *prop, AttributeNode attr, 
-                      DataNode data);
+                      DataNode data, DiaContext *ctx);
 void invalidprop_save(InvalidProperty *prop, AttributeNode attr);
 gboolean invalidprop_can_merge(const PropDescription *pd1, 
                                const PropDescription *pd2);
@@ -90,7 +90,7 @@ void unimplementedprop_reset_widget(UnimplementedProperty *prop,
 void unimplementedprop_set_from_widget(UnimplementedProperty *prop, 
                                        WIDGET *widget);
 void unimplementedprop_load(UnimplementedProperty *prop, 
-                            AttributeNode attr, DataNode data); 
+                            AttributeNode attr, DataNode data, DiaContext *ctx); 
 void unimplementedprop_save(UnimplementedProperty *prop, AttributeNode attr);
 gboolean unimplementedprop_can_merge(const PropDescription *pd1, 
                                      const PropDescription *pd2);
diff --git a/lib/prop_dict.c b/lib/prop_dict.c
index a03f393..5c076d3 100644
--- a/lib/prop_dict.c
+++ b/lib/prop_dict.c
@@ -90,7 +90,7 @@ dictprop_copy(DictProperty *src)
 }
 
 static void 
-dictprop_load(DictProperty *prop, AttributeNode attr, DataNode data)
+dictprop_load(DictProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   DataNode kv;
   guint nvals = attribute_num_data(attr);
@@ -102,7 +102,7 @@ dictprop_load(DictProperty *prop, AttributeNode attr, DataNode data)
     xmlChar *key = xmlGetProp(kv, (const xmlChar *)"name");
 
     if (key) {
-      gchar *value = data_string(attribute_first_data (kv));
+      gchar *value = data_string(attribute_first_data (kv), ctx);
       if (value)
         g_hash_table_insert (prop->dict, g_strdup((gchar *)key), value);
       xmlFree (key);
@@ -349,7 +349,7 @@ prop_dicttypes_register(void)
 }
 
 GHashTable *
-data_dict (DataNode data)
+data_dict (DataNode data, DiaContext *ctx)
 {
   GHashTable *ht = NULL;
   int nvals = attribute_num_data (data);
@@ -363,7 +363,7 @@ data_dict (DataNode data)
       xmlChar *key = xmlGetProp(kv, (const xmlChar *)"name");
 
       if (key) {
-        val = data_string (attribute_first_data (kv));
+        val = data_string (attribute_first_data (kv), ctx);
         if (val)
           g_hash_table_insert (ht, g_strdup ((gchar *)key), val);
 	xmlFree (key);
diff --git a/lib/prop_geomtypes.c b/lib/prop_geomtypes.c
index 407a693..2acc0f7 100644
--- a/lib/prop_geomtypes.c
+++ b/lib/prop_geomtypes.c
@@ -103,9 +103,9 @@ realprop_set_from_widget(RealProperty *prop, WIDGET *widget)
 }
 
 static void 
-realprop_load(RealProperty *prop, AttributeNode attr, DataNode data)
+realprop_load(RealProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  prop->real_data = data_real(data);
+  prop->real_data = data_real(data, ctx);
 }
 
 static void 
@@ -216,9 +216,9 @@ lengthprop_set_from_widget(LengthProperty *prop, WIDGET *widget)
 }
 
 static void 
-lengthprop_load(LengthProperty *prop, AttributeNode attr, DataNode data)
+lengthprop_load(LengthProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  prop->length_data = data_real(data);
+  prop->length_data = data_real(data, ctx);
 }
 
 static void 
@@ -314,10 +314,10 @@ fontsizeprop_set_from_widget(FontsizeProperty *prop, WIDGET *widget)
 }
 
 static void 
-fontsizeprop_load(FontsizeProperty *prop, AttributeNode attr, DataNode data)
+fontsizeprop_load(FontsizeProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   PropNumData *numdata = prop->common.descr->extra_data;
-  real value = data_real(data);
+  real value = data_real(data, ctx);
 
   if (numdata) {
     if (value < numdata->min)
@@ -405,9 +405,9 @@ pointprop_copy(PointProperty *src)
 }
 
 static void 
-pointprop_load(PointProperty *prop, AttributeNode attr, DataNode data)
+pointprop_load(PointProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  data_point(data,&prop->point_data);
+  data_point(data,&prop->point_data, ctx);
 }
 
 static void 
@@ -482,13 +482,13 @@ pointarrayprop_copy(PointarrayProperty *src)
 }
 
 static void 
-pointarrayprop_load(PointarrayProperty *prop, AttributeNode attr, DataNode data)
+pointarrayprop_load(PointarrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   guint nvals = attribute_num_data(attr);
   guint i;
   g_array_set_size(prop->pointarray_data,nvals);
   for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
-    data_point(data,&g_array_index(prop->pointarray_data,Point,i));
+    data_point(data,&g_array_index(prop->pointarray_data,Point,i),ctx);
   if (i != nvals) 
     g_warning("attribute_num_data() and actual data count mismatch "
               "(shouldn't happen)");
@@ -569,9 +569,9 @@ bezpointprop_copy(BezPointProperty *src)
 }
 
 static void 
-bezpointprop_load(BezPointProperty *prop, AttributeNode attr, DataNode data)
+bezpointprop_load(BezPointProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  data_bezpoint(data,&prop->bezpoint_data);
+  data_bezpoint(data,&prop->bezpoint_data,ctx);
 }
 
 static void 
@@ -647,7 +647,8 @@ bezpointarrayprop_copy(BezPointarrayProperty *src)
 
 static void 
 bezpointarrayprop_load(BezPointarrayProperty *prop, 
-                       AttributeNode attr, DataNode data)
+                       AttributeNode attr, DataNode data,
+		       DiaContext *ctx)
 {
   guint nvals = attribute_num_data(attr);
   guint i;
@@ -655,7 +656,7 @@ bezpointarrayprop_load(BezPointarrayProperty *prop,
   g_array_set_size(prop->bezpointarray_data,nvals);
 
   for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
-    data_bezpoint(data,&g_array_index(prop->bezpointarray_data,BezPoint,i));
+    data_bezpoint(data,&g_array_index(prop->bezpointarray_data,BezPoint,i),ctx);
   if (i != nvals) 
     g_warning("attribute_num_data() and actual data count mismatch "
               "(shouldn't happen)");
@@ -736,9 +737,9 @@ rectprop_copy(RectProperty *src)
 }
 
 static void 
-rectprop_load(RectProperty *prop, AttributeNode attr, DataNode data)
+rectprop_load(RectProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  data_rectangle(data,&prop->rect_data);
+  data_rectangle(data,&prop->rect_data,ctx);
 }
 
 static void 
@@ -804,11 +805,11 @@ endpointsprop_copy(EndpointsProperty *src)
 }
 
 static void 
-endpointsprop_load(EndpointsProperty *prop, AttributeNode attr, DataNode data)
+endpointsprop_load(EndpointsProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  data_point(data,&prop->endpoints_data[0]);
+  data_point(data,&prop->endpoints_data[0], ctx);
   data = data_next(data);
-  data_point(data,&prop->endpoints_data[1]);
+  data_point(data,&prop->endpoints_data[1], ctx);
 }
 
 static void 
@@ -877,9 +878,10 @@ connpoint_lineprop_copy(Connpoint_LineProperty *src)
 }
 
 static void 
-connpoint_lineprop_load(Connpoint_LineProperty *prop, AttributeNode attr, DataNode data)
+connpoint_lineprop_load(Connpoint_LineProperty *prop, AttributeNode attr, 
+			DataNode data, DiaContext *ctx)
 {
-  prop->connpoint_line_data = data_int(data);
+  prop->connpoint_line_data = data_int(data,ctx);
 }
 
 static void 
diff --git a/lib/prop_inttypes.c b/lib/prop_inttypes.c
index a950874..a94fddd 100644
--- a/lib/prop_inttypes.c
+++ b/lib/prop_inttypes.c
@@ -33,7 +33,7 @@
 #define WIDGET GtkWidget
 #include "properties.h"
 #include "propinternals.h"
-#include "message.h"
+#include "diacontext.h"
 
 /***************************/
 /* The CHAR property type. */
@@ -86,9 +86,9 @@ charprop_set_from_widget(CharProperty *prop, WIDGET *widget)
 }
 
 static void 
-charprop_load(CharProperty *prop, AttributeNode attr, DataNode data)
+charprop_load(CharProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  gchar *str = data_string(data);
+  gchar *str = data_string(data, ctx);
   
   if (str && str[0]) {
     prop->char_data = g_utf8_get_char(str);
@@ -204,9 +204,9 @@ boolprop_set_from_widget(BoolProperty *prop, WIDGET *widget)
 }
 
 static void 
-boolprop_load(BoolProperty *prop, AttributeNode attr, DataNode data)
+boolprop_load(BoolProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  prop->bool_data = data_boolean(data);
+  prop->bool_data = data_boolean(data,ctx);
 }
 
 static void 
@@ -314,9 +314,9 @@ intprop_set_from_widget(IntProperty *prop, WIDGET *widget)
 }
 
 static void 
-intprop_load(IntProperty *prop, AttributeNode attr, DataNode data)
+intprop_load(IntProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  prop->int_data = data_int(data);
+  prop->int_data = data_int(data,ctx);
 }
 
 static void 
@@ -398,13 +398,13 @@ intarrayprop_copy(IntarrayProperty *src)
 }
 
 static void 
-intarrayprop_load(IntarrayProperty *prop, AttributeNode attr, DataNode data)
+intarrayprop_load(IntarrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   guint nvals = attribute_num_data(attr);
   guint i;
   g_array_set_size(prop->intarray_data,nvals);
   for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
-    g_array_index(prop->intarray_data,gint,i) = data_int(data);
+    g_array_index(prop->intarray_data,gint,i) = data_int(data,ctx);
   if (i != nvals) 
     g_warning("attribute_num_data() and actual data count mismatch "
               "(shouldn't happen)");
@@ -546,15 +546,15 @@ enumprop_set_from_widget(EnumProperty *prop, WIDGET *widget)
 }
 
 static void 
-enumprop_load(EnumProperty *prop, AttributeNode attr, DataNode data)
+enumprop_load(EnumProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
-  DataType dt = data_type (data);
+  DataType dt = data_type (data, ctx);
   if (DATATYPE_ENUM == dt)
-    prop->enum_data = data_enum(data);
+    prop->enum_data = data_enum(data, ctx);
   else if (DATATYPE_INT == dt) {
     gboolean cast_ok = FALSE;
     PropEnumData *enumdata = prop->common.descr->extra_data;
-    guint i, v = data_int(data);
+    guint i, v = data_int(data,ctx);
     for (i = 0; enumdata[i].name != NULL; ++i) {
       if (v == enumdata[i].enumv) {
         prop->enum_data = v;
@@ -564,7 +564,7 @@ enumprop_load(EnumProperty *prop, AttributeNode attr, DataNode data)
     }
     if (!cast_ok) {
       prop->enum_data = enumdata[0].enumv;
-      message_warning (_("Property cast from int to enum out of range"));
+      dia_context_add_message (ctx, _("Property cast from int to enum out of range"));
     }
   }
 }
@@ -641,14 +641,14 @@ enumarrayprop_copy(EnumarrayProperty *src)
 }
 
 static void 
-enumarrayprop_load(EnumarrayProperty *prop, AttributeNode attr, DataNode data)
+enumarrayprop_load(EnumarrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   guint nvals = attribute_num_data(attr);
   guint i;
   g_array_set_size(prop->enumarray_data,nvals);
 
   for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
-    g_array_index(prop->enumarray_data,gint,i) = data_enum(data);
+    g_array_index(prop->enumarray_data,gint,i) = data_enum(data, ctx);
   if (i != nvals) 
     g_warning("attribute_num_data() and actual data count mismatch "
               "(shouldn't happen)");
diff --git a/lib/prop_matrix.c b/lib/prop_matrix.c
index bad678a..0588732 100644
--- a/lib/prop_matrix.c
+++ b/lib/prop_matrix.c
@@ -102,7 +102,7 @@ data_matrix (DataNode data)
 }
 
 static void 
-matrixprop_load(MatrixProperty *prop, AttributeNode attr, DataNode data)
+matrixprop_load(MatrixProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   prop->matrix = data_matrix (data);
 }
diff --git a/lib/prop_pixbuf.c b/lib/prop_pixbuf.c
index 21d2809..50cba0c 100644
--- a/lib/prop_pixbuf.c
+++ b/lib/prop_pixbuf.c
@@ -154,7 +154,7 @@ data_pixbuf (DataNode data)
 }
 
 static void 
-pixbufprop_load(PixbufProperty *prop, AttributeNode attr, DataNode data)
+pixbufprop_load(PixbufProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   prop->pixbuf = data_pixbuf (data);
 }
diff --git a/lib/prop_sdarray.c b/lib/prop_sdarray.c
index 5b13362..3c47aab 100644
--- a/lib/prop_sdarray.c
+++ b/lib/prop_sdarray.c
@@ -85,7 +85,7 @@ arrayprop_copy(ArrayProperty *src)
 }
 
 static void 
-arrayprop_load(ArrayProperty *prop, AttributeNode attr, DataNode data)
+arrayprop_load(ArrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   const PropDescCommonArrayExtra *extra = prop->common.descr->extra_data;
   DataNode composite;
@@ -99,10 +99,8 @@ arrayprop_load(ArrayProperty *prop, AttributeNode attr, DataNode data)
        composite = data_next(composite)) {
     GPtrArray *record = prop_list_from_descs(extra->record,
                                              prop->common.reason);
-    if (!prop_list_load(record,composite, &err)) {
-      g_warning ("%s:%s", prop->common.descr->name, err->message);
-      g_error_free (err);
-      err = NULL;
+    if (!prop_list_load(record,composite, ctx)) {
+      /* context already has the message */
     }
     g_ptr_array_add(prop->records,record);
   }
diff --git a/lib/prop_text.c b/lib/prop_text.c
index 6c3c596..dbc8634 100644
--- a/lib/prop_text.c
+++ b/lib/prop_text.c
@@ -180,10 +180,10 @@ fileprop_set_from_widget(StringProperty *prop, GtkWidget *widget)
 }
 
 static void 
-stringprop_load(StringProperty *prop, AttributeNode attr, DataNode data)
+stringprop_load(StringProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   g_free(prop->string_data);
-  prop->string_data = data_string(data);
+  prop->string_data = data_string(data, ctx);
   if (prop->string_data == NULL) {
     prop->string_data = g_strdup("");
   }
@@ -253,7 +253,7 @@ stringlistprop_copy(StringListProperty *src)
 }
 
 static void 
-stringlistprop_load(StringListProperty *prop, AttributeNode attr, DataNode data)
+stringlistprop_load(StringListProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   g_warning("stringlistprop_load not implemented");
 }
@@ -388,11 +388,11 @@ textprop_free(TextProperty *prop)
 }
 
 static void 
-textprop_load(TextProperty *prop, AttributeNode attr, DataNode data)
+textprop_load(TextProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
 {
   Text *text;
   g_free(prop->text_data);
-  text = data_text(data);
+  text = data_text(data, ctx);
   text_get_attributes(text,&prop->attr);
   prop->text_data = text_get_string_copy(text);
   text_destroy(text);
diff --git a/lib/properties.h b/lib/properties.h
index e5db91e..65b0697 100644
--- a/lib/properties.h
+++ b/lib/properties.h
@@ -47,6 +47,7 @@
 #include "dia_xml.h"
 #include "intl.h"
 #include "textattr.h"
+#include "diacontext.h"
 
 G_BEGIN_DECLS
 
@@ -105,7 +106,7 @@ typedef void (* PropertyType_ResetWidget)(const Property *prop, WIDGET *widget);
 /* Set the value of the property from the current value of the widget */
 typedef void (* PropertyType_SetFromWidget)(Property *prop, WIDGET *widget);
 /* load/save a property */
-typedef void (*PropertyType_Load)(Property *prop, AttributeNode attr, DataNode data);
+typedef void (*PropertyType_Load)(Property *prop, AttributeNode attr, DataNode data, DiaContext *ctx);
 typedef void (*PropertyType_Save)(Property *prop, AttributeNode attr);
 
 /* If a property descriptor can be merged with another 
diff --git a/lib/propinternals.h b/lib/propinternals.h
index b4b1734..116c6ac 100644
--- a/lib/propinternals.h
+++ b/lib/propinternals.h
@@ -37,8 +37,8 @@
 gboolean propdescs_can_be_merged(const PropDescription *p1, 
                                  const PropDescription *p2);
 
-/* returns FALSE if error is set cause of meesed up format */
-gboolean prop_list_load(GPtrArray *props, DataNode data, GError **err);
+/* returns FALSE if error is set cause of messed up format */
+gboolean prop_list_load(GPtrArray *props, DataNode data, DiaContext *ctx);
 void prop_list_save(GPtrArray *props, DataNode data);
 
 #define struct_member(sp, off, tp) (*(tp *)(((char *)sp) + off))
diff --git a/lib/proplist.c b/lib/proplist.c
index 6882e6a..3f9e981 100644
--- a/lib/proplist.c
+++ b/lib/proplist.c
@@ -143,7 +143,7 @@ prop_list_copy_empty(GPtrArray *plist)
 }
 
 gboolean 
-prop_list_load(GPtrArray *props, DataNode data_node, GError **err)
+prop_list_load(GPtrArray *props, DataNode data_node, DiaContext *ctx)
 {
   guint i;
   gboolean ret = TRUE;
@@ -157,16 +157,14 @@ prop_list_load(GPtrArray *props, DataNode data_node, GError **err)
       continue;
     }
     if ((!attr) || (!data)) {
-      if (err && !*err)
-	*err = g_error_new (DIA_ERROR,
-                            DIA_ERROR_FORMAT,
-			    _("No attribute '%s' (%p) or no data (%p) in this attribute"),
-			    prop->descr->name,attr,data);
+      dia_context_add_message(ctx,
+			      _("No attribute '%s' (%p) or no data (%p) in this attribute"),
+			      prop->descr->name,attr,data);
       prop->experience |= PXP_NOTSET;
       ret = FALSE;
       continue;
     }
-    prop->ops->load(prop,attr,data);
+    prop->ops->load(prop,attr,data,ctx);
   }
   return ret;
 }
diff --git a/lib/propobject.c b/lib/propobject.c
index 01be39a..f9b1f0f 100644
--- a/lib/propobject.c
+++ b/lib/propobject.c
@@ -309,7 +309,7 @@ object_copy_props(DiaObject *dest, const DiaObject *src, gboolean is_default)
 }
 
 void
-object_load_props(DiaObject *obj, ObjectNode obj_node)
+object_load_props(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx)
 {
   GPtrArray *props;
   GError *err = NULL;
@@ -321,9 +321,8 @@ object_load_props(DiaObject *obj, ObjectNode obj_node)
   props = prop_list_from_descs(object_get_prop_descriptions(obj),
                                pdtpp_do_load);  
 
-  if (!prop_list_load(props,obj_node, &err)) {
-    g_warning ("%s: %s", obj->type->name, err->message);
-    g_error_free(err);
+  if (!prop_list_load(props,obj_node, ctx)) {
+    /* context already has the message */
   }
 
   obj->ops->set_props(obj, props);
diff --git a/lib/text.c b/lib/text.c
index 17dc15c..1f04a63 100644
--- a/lib/text.c
+++ b/lib/text.c
@@ -27,7 +27,6 @@
 
 #include "propinternals.h"
 #include "text.h"
-#include "message.h"
 #include "diarenderer.h"
 #include "diagramdata.h"
 #include "objchange.h"
@@ -682,8 +681,8 @@ text_set_cursor(Text *text, Point *clicked_point,
     text->cursor_pos = 0;
 
     if (!renderer->is_interactive) {
-      message_error("Internal error: Select gives non interactive renderer!\n"
-		    "val: %d\n", renderer->is_interactive);
+      g_warning("Internal error: Select gives non interactive renderer!\n"
+		"val: %d\n", renderer->is_interactive);
       return;
     }
 
@@ -1091,7 +1090,7 @@ data_add_text(AttributeNode attr, Text *text)
 
 
 Text *
-data_text(AttributeNode text_attr)
+data_text(AttributeNode text_attr, DiaContext *ctx)
 {
   char *string = NULL;
   DiaFont *font;
@@ -1104,33 +1103,33 @@ data_text(AttributeNode text_attr)
 
   attr = composite_find_attribute(text_attr, "string");
   if (attr != NULL)
-    string = data_string(attribute_first_data(attr));
+    string = data_string(attribute_first_data(attr), ctx);
 
   height = 1.0;
   attr = composite_find_attribute(text_attr, "height");
   if (attr != NULL)
-    height = data_real(attribute_first_data(attr));
+    height = data_real(attribute_first_data(attr), ctx);
 
   attr = composite_find_attribute(text_attr, "font");
   if (attr != NULL) {
-    font = data_font(attribute_first_data(attr));
+    font = data_font(attribute_first_data(attr), ctx);
   } else {
     font = dia_font_new_from_style(DIA_FONT_SANS,1.0);
   }
   
   attr = composite_find_attribute(text_attr, "pos");
   if (attr != NULL)
-    data_point(attribute_first_data(attr), &pos);
+    data_point(attribute_first_data(attr), &pos, ctx);
 
   col = color_black;
   attr = composite_find_attribute(text_attr, "color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &col);
+    data_color(attribute_first_data(attr), &col, ctx);
 
   align = ALIGN_LEFT;
   attr = composite_find_attribute(text_attr, "alignment");
   if (attr != NULL)
-    align = data_enum(attribute_first_data(attr));
+    align = data_enum(attribute_first_data(attr), ctx);
   
   text = new_text(string ? string : "", font, height, &pos, &col, align);
   if (font) dia_font_unref(font);
diff --git a/lib/text.h b/lib/text.h
index a003015..f2c00ad 100644
--- a/lib/text.h
+++ b/lib/text.h
@@ -92,7 +92,7 @@ real text_get_descent(Text *text);
  * events of insensitive clods^H^H^H^H^Hmenu items. LC 21/10 2007*/
 gboolean text_delete_key_handler(Focus *focus, ObjectChange **change);
 void data_add_text(AttributeNode attr, Text *text);
-Text *data_text(AttributeNode attr);
+Text *data_text(AttributeNode attr, DiaContext *ctx);
 
 gboolean apply_textattr_properties(GPtrArray *props,
                                    Text *text, const gchar *textname,
diff --git a/lib/widgets.h b/lib/widgets.h
index 0f9f38e..68f9fec 100644
--- a/lib/widgets.h
+++ b/lib/widgets.h
@@ -37,10 +37,6 @@ void       dia_alignment_selector_set_alignment (GtkWidget *as, Alignment align)
 #define DIALINESTYLESELECTOR_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, dia_line_style_selector_get_type (), DiaLineStyleSelectorClass)
 #define IS_DIALINESTYLESELECTOR(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_line_style_selector_get_type ())
 
-#define DEFAULT_LINESTYLE LINESTYLE_SOLID
-#define DEFAULT_LINESTYLE_DASHLEN 1.0
-
-
 GType      dia_line_style_selector_get_type      (void);
 GtkWidget* dia_line_style_selector_new           (void);
 void       dia_line_style_selector_get_linestyle (DiaLineStyleSelector *as,
diff --git a/objects/AADL/aadl.h b/objects/AADL/aadl.h
index 454bcdc..5ee5208 100755
--- a/objects/AADL/aadl.h
+++ b/objects/AADL/aadl.h
@@ -196,7 +196,7 @@ void aadlbox_set_props(Aadlbox *aadlbox, GPtrArray *props);
 DiaObject *aadlbox_copy(DiaObject *obj);
 DiaMenu * aadlbox_get_object_menu(Aadlbox *aadlbox, Point *clickedpoint);
 void aadlbox_save(Aadlbox *aadlbox, ObjectNode obj_node, const char *filename);
-void aadlbox_load(ObjectNode obj_node, int version, const char *filename,
+void aadlbox_load(ObjectNode obj_node, int version, DiaContext *ctx,
 			Aadlbox *aadlbox);
 
 /* aadldata.c */
diff --git a/objects/AADL/aadlbox.c b/objects/AADL/aadlbox.c
index b447321..3da3d24 100755
--- a/objects/AADL/aadlbox.c
+++ b/objects/AADL/aadlbox.c
@@ -950,7 +950,7 @@ aadlbox_save(Aadlbox *aadlbox, ObjectNode obj_node, const char *filename)
 }
 
 /* *NOT A CALLBACK* --> Must be called by inherited class (see aadldata.c) */
-void aadlbox_load(ObjectNode obj_node, int version, const char *filename,
+void aadlbox_load(ObjectNode obj_node, int version, DiaContext *ctx,
 		   Aadlbox *aadlbox)
 {
   AttributeNode attr;
@@ -971,13 +971,13 @@ void aadlbox_load(ObjectNode obj_node, int version, const char *filename,
     
     Point p;
     attr = composite_find_attribute(composite, "point");
-    data_point( attribute_first_data(attr), &p);
+    data_point(attribute_first_data(attr), &p, ctx);
     
     attr = composite_find_attribute(composite, "port_type");
-    type = data_enum(attribute_first_data(attr));
+    type = data_enum(attribute_first_data(attr), ctx);
     
     attr = composite_find_attribute(composite, "port_declaration");
-    declaration = data_string(attribute_first_data(attr));
+    declaration = data_string(attribute_first_data(attr), ctx);
   
     port = g_new0(Aadlport,1);
     port->handle = g_new0(Handle,1);
@@ -996,7 +996,7 @@ void aadlbox_load(ObjectNode obj_node, int version, const char *filename,
   
   for (i=0; i<num; i++) {
     Point p;
-    data_point( data, &p );
+    data_point(data, &p, ctx);
 
     connection = g_new0(ConnectionPoint,1);
     aadlbox_add_connection(aadlbox, &p, connection);
@@ -1004,5 +1004,5 @@ void aadlbox_load(ObjectNode obj_node, int version, const char *filename,
     data = data_next(data);
   }
   
-  object_load_props(&aadlbox->element.object,obj_node);
+  object_load_props(&aadlbox->element.object,obj_node, ctx);
 }
diff --git a/objects/AADL/aadlbus.c b/objects/AADL/aadlbus.c
index 8dfe2a3..1e178d5 100755
--- a/objects/AADL/aadlbus.c
+++ b/objects/AADL/aadlbus.c
@@ -226,14 +226,14 @@ static DiaObject *aadlbus_create(Point *startpoint, void *user_data, Handle **ha
   return obj;
 }
 
-static DiaObject *aadlbus_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *aadlbus_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlbus_create(&startpoint,&aadlbus_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadldata.c b/objects/AADL/aadldata.c
index 5458cda..91bfc0c 100755
--- a/objects/AADL/aadldata.c
+++ b/objects/AADL/aadldata.c
@@ -179,14 +179,14 @@ static DiaObject *aadldata_create(Point *startpoint, void *user_data, Handle **h
   return obj;
 }
 
-static DiaObject *aadldata_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *aadldata_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadldata_create(&startpoint,&aadldata_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   
   return obj;
 }
diff --git a/objects/AADL/aadldevice.c b/objects/AADL/aadldevice.c
index 3efb4d6..2dba17d 100755
--- a/objects/AADL/aadldevice.c
+++ b/objects/AADL/aadldevice.c
@@ -163,14 +163,15 @@ static DiaObject *aadldevice_create(Point *startpoint, void *user_data, Handle *
   return obj;
 }
 
-static DiaObject *aadldevice_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadldevice_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadldevice_create(&startpoint,&aadldevice_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlmemory.c b/objects/AADL/aadlmemory.c
index 42d9218..1d540f5 100755
--- a/objects/AADL/aadlmemory.c
+++ b/objects/AADL/aadlmemory.c
@@ -148,14 +148,15 @@ static DiaObject *aadlmemory_create(Point *startpoint, void *user_data, Handle *
   return obj;
 }
 
-static DiaObject *aadlmemory_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlmemory_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlmemory_create(&startpoint,&aadlmemory_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlpackage.c b/objects/AADL/aadlpackage.c
index b35d5f4..3c0c5db 100755
--- a/objects/AADL/aadlpackage.c
+++ b/objects/AADL/aadlpackage.c
@@ -126,14 +126,15 @@ static DiaObject *aadlpackage_create(Point *startpoint, void *user_data, Handle
   return obj;
 }
 
-static DiaObject *aadlpackage_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlpackage_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlpackage_create(&startpoint,&aadlpackage_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   
   return obj;
 }
diff --git a/objects/AADL/aadlprocess.c b/objects/AADL/aadlprocess.c
index f692d26..c04c53f 100755
--- a/objects/AADL/aadlprocess.c
+++ b/objects/AADL/aadlprocess.c
@@ -167,14 +167,15 @@ static DiaObject *aadlprocess_create(Point *startpoint, void *user_data, Handle
   return obj;
 }
 
-static DiaObject *aadlprocess_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlprocess_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlprocess_create(&startpoint,&aadlprocess_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlprocessor.c b/objects/AADL/aadlprocessor.c
index 1829308..ddb9730 100755
--- a/objects/AADL/aadlprocessor.c
+++ b/objects/AADL/aadlprocessor.c
@@ -137,14 +137,15 @@ static DiaObject *aadlprocessor_create(Point *startpoint, void *user_data, Handl
   return obj;
 }
 
-static DiaObject *aadlprocessor_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlprocessor_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlprocessor_create(&startpoint,&aadlprocessor_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlsubprogram.c b/objects/AADL/aadlsubprogram.c
index c59f8ab..dc74ed7 100755
--- a/objects/AADL/aadlsubprogram.c
+++ b/objects/AADL/aadlsubprogram.c
@@ -149,14 +149,15 @@ static DiaObject *aadlsubprogram_create(Point *startpoint, void *user_data, Hand
   return obj;
 }
 
-static DiaObject *aadlsubprogram_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlsubprogram_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlsubprogram_create(&startpoint,&aadlsubprogram_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlsystem.c b/objects/AADL/aadlsystem.c
index 8f34a64..cbe8c9f 100755
--- a/objects/AADL/aadlsystem.c
+++ b/objects/AADL/aadlsystem.c
@@ -159,14 +159,15 @@ static DiaObject *aadlsystem_create(Point *startpoint, void *user_data, Handle *
   return obj;
 }
 
-static DiaObject *aadlsystem_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlsystem_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlsystem_create(&startpoint,&aadlsystem_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlthread.c b/objects/AADL/aadlthread.c
index eb76f47..cec348c 100755
--- a/objects/AADL/aadlthread.c
+++ b/objects/AADL/aadlthread.c
@@ -91,14 +91,15 @@ static DiaObject *aadlthread_create(Point *startpoint, void *user_data, Handle *
   return obj;
 }
 
-static DiaObject *aadlthread_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlthread_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
   Handle *handle1,*handle2;
   
   obj = aadlthread_create(&startpoint,&aadlthread_specific, &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/AADL/aadlthreadgroup.c b/objects/AADL/aadlthreadgroup.c
index 5999eb4..e4e6e2f 100755
--- a/objects/AADL/aadlthreadgroup.c
+++ b/objects/AADL/aadlthreadgroup.c
@@ -94,7 +94,8 @@ static DiaObject *aadlthreadgroup_create(Point *startpoint, void *user_data, Han
   return obj;
 }
 
-static DiaObject *aadlthreadgroup_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *
+aadlthreadgroup_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   Point startpoint = {0.0,0.0};
@@ -102,7 +103,7 @@ static DiaObject *aadlthreadgroup_load(ObjectNode obj_node, int version, const c
   
   obj = aadlthreadgroup_create(&startpoint, &aadlthreadgroup_specific, 
 			       &handle1,&handle2);
-  aadlbox_load(obj_node, version, filename, (Aadlbox *) obj);
+  aadlbox_load(obj_node, version, ctx, (Aadlbox *) obj);
   return obj;
 }
 
diff --git a/objects/Database/compound.c b/objects/Database/compound.c
index 42e5ee4..becaa6f 100644
--- a/objects/Database/compound.c
+++ b/objects/Database/compound.c
@@ -113,7 +113,7 @@ static void
 mount_point_move_change_free (MountPointMoveChange *);
 
 static DiaObject * compound_create (Point *, void *, Handle **, Handle **);
-static DiaObject * compound_load (ObjectNode, int, const char *);
+static DiaObject * compound_load (ObjectNode obj_node, int version,DiaContext *ctx);
 static void compound_save (Compound *, ObjectNode, const char *);
 static void compound_destroy (Compound *);
 static void compound_draw (Compound *, DiaRenderer *);
@@ -432,7 +432,7 @@ compound_create (Point * start_point, void * user_data,
 }
 
 static DiaObject *
-compound_load (ObjectNode obj_node, int version, const char *filename)
+compound_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Compound * comp;
   DiaObject * obj;
@@ -443,7 +443,7 @@ compound_load (ObjectNode obj_node, int version, const char *filename)
   comp = g_new0 (Compound, 1);
   obj = &comp->object;
   /* load the objects position and bounding box */
-  object_load (obj, obj_node);
+  object_load (obj, obj_node, ctx);
   /* init the object */
   obj->type = &compound_type;
   obj->ops = &compound_ops;
@@ -458,7 +458,7 @@ compound_load (ObjectNode obj_node, int version, const char *filename)
   data = attribute_first_data (attr);
   /* init our mount_point */
   setup_mount_point (&comp->mount_point, obj, NULL);
-  data_point (data, &comp->mount_point.pos);
+  data_point (data, &comp->mount_point.pos, ctx);
   obj->connections[0] = &comp->mount_point;
   /* now init the handles */
   comp->num_arms = num_handles-1;
@@ -473,7 +473,7 @@ compound_load (ObjectNode obj_node, int version, const char *filename)
       obj->handles[i] = &comp->handles[i];
       setup_handle (obj->handles[i], HANDLE_ARM,
                     HANDLE_MINOR_CONTROL, HANDLE_CONNECTABLE_NOBREAK);
-      data_point (data, &obj->handles[i]->pos);
+      data_point (data, &obj->handles[i]->pos, ctx);
       data = data_next (data);
     }
 
@@ -482,12 +482,12 @@ compound_load (ObjectNode obj_node, int version, const char *filename)
   if (attr == NULL)
     comp->line_width = 0.1;
   else
-    comp->line_width = data_real (attribute_first_data (attr));
+    comp->line_width = data_real (attribute_first_data (attr), ctx);
   attr = object_find_attribute (obj_node, "line_colour");
   if (attr == NULL)
     comp->line_color = color_black;
   else
-    data_color (attribute_first_data (attr), &comp->line_color);
+    data_color (attribute_first_data (attr), &comp->line_color, ctx);
 
   compound_update_data (comp);
   compound_sanity_check (comp, "Loaded");
diff --git a/objects/Database/reference.c b/objects/Database/reference.c
index 891a6e2..df947d0 100644
--- a/objects/Database/reference.c
+++ b/objects/Database/reference.c
@@ -48,7 +48,7 @@ static PropDescription * reference_describe_props (TableReference *);
 static void reference_get_props (TableReference *, GPtrArray *);
 static void reference_set_props (TableReference *, GPtrArray *);
 static void reference_update_data (TableReference *);
-static DiaObject * reference_load (ObjectNode, int, const char *);
+static DiaObject * reference_load (ObjectNode obj_node, int version,DiaContext *ctx);
 static void update_desc_data (Point *, Alignment *,
                               Point *, Point *, Orientation, real, real);
 static void get_desc_bbox (Rectangle *, gchar *, real, Point *, Alignment,
@@ -206,10 +206,10 @@ reference_destroy (TableReference * ref)
 }
 
 static DiaObject *
-reference_load (ObjectNode obj_node, int version, const char *filename)
+reference_load (ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject * obj = object_load_using_properties (&reference_type,
-                                                  obj_node, version, filename);
+                                                  obj_node, version,ctx);
   return obj;
 }
 
diff --git a/objects/Database/table.c b/objects/Database/table.c
index 66641fe..66a541b 100644
--- a/objects/Database/table.c
+++ b/objects/Database/table.c
@@ -55,7 +55,7 @@
 static real         table_calculate_namebox_data (Table *);
 static real         table_init_attributesbox_height (Table *);
 static DiaObject *  table_create (Point *, void *, Handle **, Handle **);
-static DiaObject *  table_load (ObjectNode, int, const char *);
+static DiaObject *  table_load (ObjectNode obj_node, int version, DiaContext *ctx);
 static void         table_save (Table *, ObjectNode, const char *);
 static void         table_destroy (Table *);
 static real         table_distance_from (Table *, Point *);
@@ -413,7 +413,7 @@ table_create (Point * startpoint,
 }
 
 static DiaObject *
-table_load (ObjectNode obj_node, int version, const char *filename)
+table_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Table * table;
   Element * elem;
@@ -427,10 +427,10 @@ table_load (ObjectNode obj_node, int version, const char *filename)
   obj->type = &table_type;
   obj->ops = &table_ops;
 
-  element_load (elem, obj_node);
+  element_load (elem, obj_node, ctx);
   element_init (elem, 8, TABLE_CONNECTIONPOINTS);
 
-  object_load_props(obj,obj_node);
+  object_load_props(obj,obj_node, ctx);
 
   /* fill in defaults if not given in the loaded file */
   if (object_find_attribute (obj_node, "line_colour") == NULL)
diff --git a/objects/ER/attribute.c b/objects/ER/attribute.c
index 3f366d2..72c0484 100644
--- a/objects/ER/attribute.c
+++ b/objects/ER/attribute.c
@@ -32,7 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "properties.h"
 
 #include "pixmaps/attribute.xpm"
@@ -110,8 +109,7 @@ attribute_set_props(Attribute *attribute, GPtrArray *props);
 
 static void attribute_save(Attribute *attribute, ObjectNode obj_node,
 			   const char *filename);
-static DiaObject *attribute_load(ObjectNode obj_node, int version,
-			      const char *filename);
+static DiaObject *attribute_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps attribute_type_ops =
 {
@@ -528,8 +526,7 @@ attribute_save(Attribute *attribute, ObjectNode obj_node,
 		attribute->font_height);
 }
 
-static DiaObject *attribute_load(ObjectNode obj_node, int version,
-			      const char *filename)
+static DiaObject *attribute_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Attribute *attribute;
   Element *elem;
@@ -544,43 +541,43 @@ static DiaObject *attribute_load(ObjectNode obj_node, int version,
   obj->type = &attribute_type;
   obj->ops = &attribute_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
 
   attribute->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    attribute->border_width =  data_real( attribute_first_data(attr) );
+    attribute->border_width =  data_real(attribute_first_data(attr), ctx);
 
   attribute->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &attribute->border_color);
+    data_color(attribute_first_data(attr), &attribute->border_color, ctx);
   
   attribute->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &attribute->inner_color);
+    data_color(attribute_first_data(attr), &attribute->inner_color, ctx);
   
   attribute->name = NULL;
   attr = object_find_attribute(obj_node, "name");
   if (attr != NULL)
-    attribute->name = data_string(attribute_first_data(attr));
+    attribute->name = data_string(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "key");
   if (attr != NULL)
-    attribute->key = data_boolean(attribute_first_data(attr));
+    attribute->key = data_boolean(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "weak_key");
   if (attr != NULL)
-    attribute->weakkey = data_boolean(attribute_first_data(attr));
+    attribute->weakkey = data_boolean(attribute_first_data(attr), ctx);
   
   attr = object_find_attribute(obj_node, "derived");
   if (attr != NULL)
-    attribute->derived = data_boolean(attribute_first_data(attr));
+    attribute->derived = data_boolean(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "multivalued");
   if (attr != NULL)
-    attribute->multivalue = data_boolean(attribute_first_data(attr));
+    attribute->multivalue = data_boolean(attribute_first_data(attr), ctx);
 
   if (attribute->font != NULL) {
     /* This shouldn't happen, but doesn't hurt */
@@ -589,12 +586,12 @@ static DiaObject *attribute_load(ObjectNode obj_node, int version,
   }
   attr = object_find_attribute (obj_node, "font");
   if (attr != NULL)
-	  attribute->font = data_font (attribute_first_data (attr));
+    attribute->font = data_font (attribute_first_data (attr), ctx);
 
   attribute->font_height = FONT_HEIGHT;
   attr = object_find_attribute (obj_node, "font_height");
   if (attr != NULL)
-    attribute->font_height = data_real( attribute_first_data(attr) );
+    attribute->font_height = data_real(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
@@ -605,19 +602,17 @@ static DiaObject *attribute_load(ObjectNode obj_node, int version,
   }
   attribute->connections[8].flags = CP_FLAGS_MAIN;
 
-  if (attribute->font == NULL) {
-	  attribute->font = dia_font_new_from_style(DIA_FONT_MONOSPACE,
+  if (attribute->font == NULL)
+    attribute->font = dia_font_new_from_style(DIA_FONT_MONOSPACE,
                                               attribute->font_height);
-  }
 
   attribute->name_width = dia_font_string_width(attribute->name,
                                                 attribute->font,
                                                 attribute->font_height);
   attribute_update_data(attribute);
 
-  for (i=0;i<8;i++) {
+  for (i=0;i<8;i++)
     obj->handles[i]->type = HANDLE_NON_MOVABLE;
-  }
 
   return &attribute->element.object;
 }
diff --git a/objects/ER/entity.c b/objects/ER/entity.c
index 48031a6..084fbbb 100644
--- a/objects/ER/entity.c
+++ b/objects/ER/entity.c
@@ -32,7 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "properties.h"
 
 #include "pixmaps/entity.xpm"
@@ -92,8 +91,7 @@ static void entity_set_props(Entity *entity, GPtrArray *props);
 
 static void entity_save(Entity *entity, ObjectNode obj_node,
 			const char *filename);
-static DiaObject *entity_load(ObjectNode obj_node, int version,
-			   const char *filename);
+static DiaObject *entity_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps entity_type_ops =
 {
@@ -499,7 +497,7 @@ entity_save(Entity *entity, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-entity_load(ObjectNode obj_node, int version, const char *filename)
+entity_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Entity *entity;
   Element *elem;
@@ -514,35 +512,35 @@ entity_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &entity_type;
   obj->ops = &entity_ops;
 
-  element_load(elem, obj_node);
-  
+  element_load(elem, obj_node, ctx);
+
   entity->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    entity->border_width =  data_real( attribute_first_data(attr) );
+    entity->border_width =  data_real(attribute_first_data(attr), ctx);
 
   entity->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &entity->border_color);
+    data_color(attribute_first_data(attr), &entity->border_color, ctx);
   
   entity->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &entity->inner_color);
+    data_color(attribute_first_data(attr), &entity->inner_color, ctx);
   
   entity->name = NULL;
   attr = object_find_attribute(obj_node, "name");
   if (attr != NULL)
-    entity->name = data_string(attribute_first_data(attr));
+    entity->name = data_string(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "weak");
   if (attr != NULL)
-    entity->weak = data_boolean(attribute_first_data(attr));
+    entity->weak = data_boolean(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "associative");
   if (attr != NULL)
-    entity->associative = data_boolean(attribute_first_data(attr));
+    entity->associative = data_boolean(attribute_first_data(attr), ctx);
 
   if (entity->font != NULL) {
     /* This shouldn't happen, but doesn't hurt */
@@ -551,12 +549,12 @@ entity_load(ObjectNode obj_node, int version, const char *filename)
   }
   attr = object_find_attribute (obj_node, "font");
   if (attr != NULL)
-    entity->font = data_font (attribute_first_data (attr));
+    entity->font = data_font (attribute_first_data (attr), ctx);
 
   entity->font_height = FONT_HEIGHT;
   attr = object_find_attribute(obj_node, "font_height");
   if (attr != NULL)
-    entity->font_height = data_real(attribute_first_data(attr));
+    entity->font_height = data_real(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
@@ -567,18 +565,16 @@ entity_load(ObjectNode obj_node, int version, const char *filename)
   }
   entity->connections[8].flags = CP_FLAGS_MAIN;
 
-  if (entity->font == NULL) {
+  if (entity->font == NULL)
     entity->font = dia_font_new_from_style(DIA_FONT_MONOSPACE,1.0);
-  }
 
   entity->name_width =
     dia_font_string_width(entity->name, entity->font, entity->font_height);
 
   entity_update_data(entity);
 
-  for (i=0;i<8;i++) {
+  for (i=0;i<8;i++)
     obj->handles[i]->type = HANDLE_NON_MOVABLE;
-  }
 
   return &entity->element.object;
 }
diff --git a/objects/ER/participation.c b/objects/ER/participation.c
index acf68da..f52d21a 100644
--- a/objects/ER/participation.c
+++ b/objects/ER/participation.c
@@ -65,8 +65,7 @@ static DiaObject *participation_create(Point *startpoint,
 static DiaObject *participation_copy(Participation *dep);
 static void participation_save(Participation *dep, ObjectNode obj_node,
 			       const char *filename);
-static DiaObject *participation_load(ObjectNode obj_node, int version,
-				  const char *filename);
+static DiaObject *participation_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static void participation_update_data(Participation *dep);
 static PropDescription *
 participation_describe_props(Participation *participation);
@@ -358,7 +357,7 @@ participation_save(Participation *participation, ObjectNode obj_node,
 }
 
 static DiaObject *
-participation_load(ObjectNode obj_node, int version, const char *filename)
+participation_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   AttributeNode attr;
   Participation *participation;
@@ -373,11 +372,11 @@ participation_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &participation_type;
   obj->ops = &participation_ops;
 
-  orthconn_load(orth, obj_node);
+  orthconn_load(orth, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "total");
   if (attr != NULL)
-    participation->total = data_boolean(attribute_first_data(attr));
+    participation->total = data_boolean(attribute_first_data(attr), ctx);
 
   participation_update_data(participation);
 
diff --git a/objects/ER/relationship.c b/objects/ER/relationship.c
index ebada8a..3f01fe7 100644
--- a/objects/ER/relationship.c
+++ b/objects/ER/relationship.c
@@ -32,7 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "properties.h"
 
 #include "pixmaps/relationship.xpm"
@@ -91,8 +90,7 @@ static DiaObject *relationship_copy(Relationship *relationship);
 
 static void relationship_save(Relationship *relationship,
 			      ObjectNode obj_node, const char *filename);
-static DiaObject *relationship_load(ObjectNode obj_node, int version,
-				 const char *filename);
+static DiaObject *relationship_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *
 relationship_describe_props(Relationship *relationship);
 static void
@@ -557,7 +555,7 @@ relationship_save(Relationship *relationship, ObjectNode obj_node,
 }
 
 static DiaObject *
-relationship_load(ObjectNode obj_node, int version, const char *filename)
+relationship_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Relationship *relationship;
   Element *elem;
@@ -572,55 +570,55 @@ relationship_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &relationship_type;
   obj->ops = &relationship_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   relationship->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    relationship->border_width =  data_real( attribute_first_data(attr) );
+    relationship->border_width =  data_real(attribute_first_data(attr), ctx);
 
   relationship->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &relationship->border_color);
+    data_color(attribute_first_data(attr), &relationship->border_color, ctx);
   
   relationship->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &relationship->inner_color);
+    data_color(attribute_first_data(attr), &relationship->inner_color, ctx);
 
   relationship->name = NULL;
   attr = object_find_attribute(obj_node, "name");
   if (attr != NULL)
-    relationship->name = data_string(attribute_first_data(attr));
+    relationship->name = data_string(attribute_first_data(attr), ctx);
 
   relationship->left_cardinality = NULL;
   attr = object_find_attribute(obj_node, "left_card");
   if (attr != NULL)
-    relationship->left_cardinality = data_string(attribute_first_data(attr));
+    relationship->left_cardinality = data_string(attribute_first_data(attr), ctx);
 
   relationship->right_cardinality = NULL;
   attr = object_find_attribute(obj_node, "right_card");
   if (attr != NULL)
-    relationship->right_cardinality = data_string(attribute_first_data(attr));
+    relationship->right_cardinality = data_string(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "identifying");
   if (attr != NULL)
-    relationship->identifying = data_boolean(attribute_first_data(attr));
+    relationship->identifying = data_boolean(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "rotated");
   if (attr != NULL)
-    relationship->rotate = data_boolean(attribute_first_data(attr));
+    relationship->rotate = data_boolean(attribute_first_data(attr), ctx);
 
   relationship->font = NULL;
   attr = object_find_attribute (obj_node, "font");
   if (attr != NULL)
-	  relationship->font = data_font (attribute_first_data (attr));
+    relationship->font = data_font (attribute_first_data (attr), ctx);
 
   relationship->font_height = FONT_HEIGHT;
   attr = object_find_attribute(obj_node, "font_height");
   if (attr != NULL)
-    relationship->font_height = data_real(attribute_first_data(attr));
+    relationship->font_height = data_real(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
@@ -631,16 +629,14 @@ relationship_load(ObjectNode obj_node, int version, const char *filename)
   }
   relationship->connections[8].flags = CP_FLAGS_MAIN;
 
-  if (relationship->font == NULL) {
+  if (relationship->font == NULL)
     relationship->font = dia_font_new_from_style(DIA_FONT_MONOSPACE,
                                                  FONT_HEIGHT);
-  }
 
   relationship_update_data(relationship);
 
-  for (i=0;i<8;i++) {
+  for (i=0;i<8;i++)
     obj->handles[i]->type = HANDLE_NON_MOVABLE;
-  }
 
   return &relationship->element.object;
 }
diff --git a/objects/FS/flow-ortho.c b/objects/FS/flow-ortho.c
index cb96f0d..12b0510 100644
--- a/objects/FS/flow-ortho.c
+++ b/objects/FS/flow-ortho.c
@@ -114,8 +114,7 @@ static void
 orthflow_set_props(Orthflow * orthflow, GPtrArray *props);
 static void orthflow_save(Orthflow *orthflow, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *orthflow_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *orthflow_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static DiaMenu *orthflow_get_object_menu(Orthflow *orthflow, Point *clickedpoint) ;
 
 
@@ -550,7 +549,7 @@ orthflow_save(Orthflow *orthflow, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-orthflow_load(ObjectNode obj_node, int version, const char *filename)
+orthflow_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Orthflow *orthflow;
   AttributeNode attr;
@@ -567,12 +566,12 @@ orthflow_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &orthflow_type;
   obj->ops = &orthflow_ops;
 
-  orthconn_load(orth, obj_node);
+  orthconn_load(orth, obj_node, ctx);
 
   orthflow->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    orthflow->text = data_text(attribute_first_data(attr));
+    orthflow->text = data_text(attribute_first_data(attr), ctx);
   else { /* paranoid */
     DiaFont *font = dia_font_new_from_style(DIA_FONT_SANS, ORTHFLOW_FONTHEIGHT);
 
@@ -582,7 +581,7 @@ orthflow_load(ObjectNode obj_node, int version, const char *filename)
 
   attr = object_find_attribute(obj_node, "type");
   if (attr != NULL)
-    orthflow->type = (OrthflowType)data_int(attribute_first_data(attr));
+    orthflow->type = (OrthflowType)data_int(attribute_first_data(attr), ctx);
 
   orthflow->text_handle.id = HANDLE_MOVE_TEXT;
   orthflow->text_handle.type = HANDLE_MINOR_CONTROL;
diff --git a/objects/FS/flow.c b/objects/FS/flow.c
index 23c4b69..29c6d5b 100644
--- a/objects/FS/flow.c
+++ b/objects/FS/flow.c
@@ -88,8 +88,7 @@ static void flow_destroy(Flow *flow);
 static DiaObject *flow_copy(Flow *flow);
 static void flow_save(Flow *flow, ObjectNode obj_node,
 		      const char *filename);
-static DiaObject *flow_load(ObjectNode obj_node, int version,
-			 const char *filename);
+static DiaObject *flow_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *flow_describe_props(Flow *mes);
 static void
 flow_get_props(Flow * flow, GPtrArray *props);
@@ -516,7 +515,7 @@ flow_save(Flow *flow, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-flow_load(ObjectNode obj_node, int version, const char *filename)
+flow_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Flow *flow;
   AttributeNode attr;
@@ -533,14 +532,14 @@ flow_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &flow_type;
   obj->ops = &flow_ops;
 
-  connection_load(conn, obj_node);
+  connection_load(conn, obj_node, ctx);
   
   connection_init(conn, 3, 0);
 
   flow->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    flow->text = data_text(attribute_first_data(attr));
+    flow->text = data_text(attribute_first_data(attr), ctx);
   else { /* pathologic */
     DiaFont *font = dia_font_new_from_style(DIA_FONT_SANS, FLOW_FONTHEIGHT);
 
@@ -550,7 +549,7 @@ flow_load(ObjectNode obj_node, int version, const char *filename)
 
   attr = object_find_attribute(obj_node, "type");
   if (attr != NULL)
-    flow->type = (FlowType)data_int(attribute_first_data(attr));
+    flow->type = (FlowType)data_int(attribute_first_data(attr), ctx);
 
   flow->text_handle.id = HANDLE_MOVE_TEXT;
   flow->text_handle.type = HANDLE_MINOR_CONTROL;
diff --git a/objects/FS/function.c b/objects/FS/function.c
index 4a53a1f..ae1b776 100644
--- a/objects/FS/function.c
+++ b/objects/FS/function.c
@@ -94,8 +94,7 @@ static void function_destroy(Function *pkg);
 static DiaObject *function_copy(Function *pkg);
 static void function_save(Function *pkg, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *function_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *function_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static void function_update_data(Function *pkg);
 static DiaMenu *function_get_object_menu(Function *func, Point *clickedpoint) ;
 static PropDescription *function_describe_props(Function *mes);
@@ -540,7 +539,7 @@ function_save(Function *pkg, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-function_load(ObjectNode obj_node, int version, const char *filename)
+function_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Function *pkg;
   AttributeNode attr;
@@ -555,12 +554,12 @@ function_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &function_type;
   obj->ops = &function_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   pkg->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    pkg->text = data_text(attribute_first_data(attr));
+    pkg->text = data_text(attribute_first_data(attr), ctx);
   else { /* paranoid */
     DiaFont *font = dia_font_new_from_style (DIA_FONT_SANS,FUNCTION_FONTHEIGHT);
     pkg->text = new_text("", font, FUNCTION_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
@@ -569,13 +568,13 @@ function_load(ObjectNode obj_node, int version, const char *filename)
 
   attr = object_find_attribute(obj_node, "is_wish");
   if (attr != NULL)
-    pkg->is_wish = data_boolean(attribute_first_data(attr));
+    pkg->is_wish = data_boolean(attribute_first_data(attr), ctx);
   else
     pkg->is_wish = FALSE;
 
   attr = object_find_attribute(obj_node, "is_user");
   if (attr != NULL)
-    pkg->is_user = data_boolean(attribute_first_data(attr));
+    pkg->is_user = data_boolean(attribute_first_data(attr), ctx);
   else
     pkg->is_user = FALSE;
 
diff --git a/objects/GRAFCET/action.c b/objects/GRAFCET/action.c
index 5c89623..a9f2b64 100644
--- a/objects/GRAFCET/action.c
+++ b/objects/GRAFCET/action.c
@@ -32,8 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 #include "geometry.h"
@@ -81,8 +79,7 @@ static DiaObject *action_create(Point *startpoint,
 static real action_distance_from(Action *action, Point *point);
 static void action_update_data(Action *action);
 static void action_destroy(Action *action);
-static DiaObject *action_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *action_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *action_describe_props(Action *action);
 static void action_get_props(Action *action, 
                                  GPtrArray *props);
@@ -453,10 +450,10 @@ action_destroy(Action *action)
 }
  
 static DiaObject *
-action_load(ObjectNode obj_node, int version, const char *filename)
+action_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&action_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/GRAFCET/action_text_draw.c b/objects/GRAFCET/action_text_draw.c
index a662b9c..e6a2cab 100644
--- a/objects/GRAFCET/action_text_draw.c
+++ b/objects/GRAFCET/action_text_draw.c
@@ -31,7 +31,6 @@
 #include "diarenderer.h"
 #include "text.h"
 #include "action_text_draw.h"
-#include "message.h"
 
 /* This used to be really horrible code. Really. 
    Now it's just a code fork. */
diff --git a/objects/GRAFCET/boolequation.c b/objects/GRAFCET/boolequation.c
index 138115f..7ec2e5c 100644
--- a/objects/GRAFCET/boolequation.c
+++ b/objects/GRAFCET/boolequation.c
@@ -595,30 +595,6 @@ void save_boolequation(ObjectNode obj_node, const gchar *attrname,
   data_add_string(new_attribute(obj_node,attrname),(gchar *)booleq->value);
 }
 
-Boolequation *
-load_boolequation(ObjectNode obj_node,
-		 const gchar *attrname,
-		 const gchar *defaultvalue,
-		 DiaFont *font,
-		 real fontheight, Color *color)
-{
-  gchar *value = NULL;
-  Boolequation *booleq;
-  AttributeNode attr;
-
-  booleq = boolequation_create(NULL,font,fontheight,color);
-  attr = object_find_attribute(obj_node,attrname);
-  if (attr) 
-    value = data_string(attribute_first_data(attr));
-  else if (defaultvalue)
-    value = g_strdup (defaultvalue);
-  if (value) 
-    boolequation_set_value(booleq,value);
-  g_free(value);
-
-  return booleq;
-}
- 
 void 
 boolequation_draw(Boolequation *booleq, DiaRenderer *renderer)
 {
diff --git a/objects/GRAFCET/boolequation.h b/objects/GRAFCET/boolequation.h
index 13b816c..01986a8 100644
--- a/objects/GRAFCET/boolequation.h
+++ b/objects/GRAFCET/boolequation.h
@@ -60,12 +60,6 @@ extern void boolequation_set_value(Boolequation *rcep, const gchar *value);
 extern void save_boolequation(ObjectNode obj_node, const gchar *attrname,
 			     Boolequation *rcep);
 
-extern Boolequation *load_boolequation(ObjectNode obj_node,
-				     const gchar *attrname,
-				     const gchar *defaultvalue,
-				     DiaFont *font,
-				     real fontheight,
-				     Color *color);
 extern void boolequation_set_pos(Boolequation *rcep, Point *pos);
 extern void boolequation_draw(Boolequation *rcep, DiaRenderer *renderer);
 extern void boolequation_calc_boundingbox(Boolequation *rcep, Rectangle *box);
diff --git a/objects/GRAFCET/condition.c b/objects/GRAFCET/condition.c
index c1028ff..341b5a9 100644
--- a/objects/GRAFCET/condition.c
+++ b/objects/GRAFCET/condition.c
@@ -32,8 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 #include "geometry.h"
@@ -81,7 +79,7 @@ static real condition_distance_from(Condition *condition, Point *point);
 static void condition_update_data(Condition *condition);
 static void condition_destroy(Condition *condition);
 static DiaObject *condition_load(ObjectNode obj_node, int version,
-			       const char *filename);
+				 DiaContext *context);
 static PropDescription *condition_describe_props(Condition *condition);
 static void condition_get_props(Condition *condition, 
                                 GPtrArray *props);
@@ -91,7 +89,7 @@ static void condition_set_props(Condition *condition,
 static ObjectTypeOps condition_type_ops =
 {
   (CreateFunc)condition_create,   /* create */
-  (LoadFunc)  condition_load /*using_properties*/,     /* load */
+  (LoadFunc)  condition_load,     /* load */
   (SaveFunc)  object_save_using_properties,      /* save */
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL
@@ -386,10 +384,10 @@ condition_destroy(Condition *condition)
 }
 
 static DiaObject *
-condition_load(ObjectNode obj_node, int version, const char *filename)
+condition_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&condition_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/GRAFCET/step.c b/objects/GRAFCET/step.c
index 39aa64d..b27d201 100644
--- a/objects/GRAFCET/step.c
+++ b/objects/GRAFCET/step.c
@@ -35,7 +35,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "properties.h"
 
 #include "grafcet.h"
@@ -101,7 +100,7 @@ static void step_destroy(Step *step);
 static void step_been_renamed(const gchar *sid);
 
 static DiaObject *step_load(ObjectNode obj_node, int version,
-			   const char *filename);
+			    DiaContext *ctx);
 static PropDescription *step_describe_props(Step *step);
 static void step_get_props(Step *step, 
                                  GPtrArray *props);
@@ -111,7 +110,7 @@ static void step_set_props(Step *step,
 static ObjectTypeOps step_type_ops =
 {
   (CreateFunc) step_create,
-  (LoadFunc)   step_load/*using properties*/,
+  (LoadFunc)   step_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -559,10 +558,10 @@ step_destroy(Step *step)
 }
 
 static DiaObject *
-step_load(ObjectNode obj_node, int version, const char *filename)
+step_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&step_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
  
 
diff --git a/objects/GRAFCET/transition.c b/objects/GRAFCET/transition.c
index e5d0f3c..faf4cf3 100644
--- a/objects/GRAFCET/transition.c
+++ b/objects/GRAFCET/transition.c
@@ -32,8 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 #include "geometry.h"
@@ -92,7 +90,7 @@ static void transition_update_data(Transition *transition);
 static void transition_destroy(Transition *transition);
 
 static DiaObject *transition_load(ObjectNode obj_node, int version,
-			       const char *filename);
+				  DiaContext *ctx);
 static PropDescription *transition_describe_props(Transition *transition);
 static void transition_get_props(Transition *transition, 
                                  GPtrArray *props);
@@ -102,7 +100,7 @@ static void transition_set_props(Transition *transition,
 static ObjectTypeOps transition_type_ops =
 {
   (CreateFunc)transition_create,   /* create */
-  (LoadFunc)  transition_load /*using_properties*/,
+  (LoadFunc)  transition_load,
   (SaveFunc)  object_save_using_properties,      /* save */
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL
@@ -446,10 +444,10 @@ transition_destroy(Transition *transition)
 }
 
 static DiaObject *
-transition_load(ObjectNode obj_node, int version, const char *filename)
+transition_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&transition_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/GRAFCET/vector.c b/objects/GRAFCET/vector.c
index 228f82d..2cb1712 100644
--- a/objects/GRAFCET/vector.c
+++ b/objects/GRAFCET/vector.c
@@ -34,8 +34,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "grafcet.h"
@@ -71,8 +69,7 @@ static void arc_destroy(Arc *arc);
 static DiaMenu *arc_get_object_menu(Arc *arc,
 					   Point *clickedpoint);
 
-static DiaObject *arc_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *arc_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *arc_describe_props(Arc *arc);
 static void arc_get_props(Arc *arc, 
                                  GPtrArray *props);
@@ -338,10 +335,10 @@ arc_get_object_menu(Arc *arc, Point *clickedpoint)
 
 
 static DiaObject *
-arc_load(ObjectNode obj_node, int version, const char *filename)
+arc_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&grafcet_arc_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
diff --git a/objects/GRAFCET/vergent.c b/objects/GRAFCET/vergent.c
index c524d5c..dddf99d 100644
--- a/objects/GRAFCET/vergent.c
+++ b/objects/GRAFCET/vergent.c
@@ -32,8 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 #include "geometry.h"
@@ -71,8 +69,7 @@ static DiaObject *vergent_create(Point *startpoint,
 static real vergent_distance_from(Vergent *vergent, Point *point);
 static void vergent_update_data(Vergent *vergent);
 static void vergent_destroy(Vergent *vergent);
-static DiaObject *vergent_load(ObjectNode obj_node, int version,
-                            const char *filename);
+static DiaObject *vergent_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *vergent_describe_props(Vergent *vergent);
 static void vergent_get_props(Vergent *vergent, 
                               GPtrArray *props);
@@ -491,10 +488,10 @@ vergent_destroy(Vergent *vergent)
 }
 
 static DiaObject *
-vergent_load(ObjectNode obj_node, int version, const char *filename)
+vergent_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&vergent_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/Istar/actor.c b/objects/Istar/actor.c
index b4bba7a..ded0fb3 100644
--- a/objects/Istar/actor.c
+++ b/objects/Istar/actor.c
@@ -36,8 +36,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "pixmaps/actor.xpm"
@@ -102,7 +100,7 @@ static PropDescription *actor_describe_props(Actor *actor);
 static void actor_get_props(Actor *actor, GPtrArray *props);
 static void actor_set_props(Actor *actor, GPtrArray *props);
 
-static DiaObject *actor_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *actor_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps actor_type_ops =
 {
@@ -504,10 +502,10 @@ actor_destroy(Actor *actor)
 }
 
 static DiaObject *
-actor_load(ObjectNode obj_node, int version, const char *filename)
+actor_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&istar_actor_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/Istar/goal.c b/objects/Istar/goal.c
index 1244a52..d2b8837 100644
--- a/objects/Istar/goal.c
+++ b/objects/Istar/goal.c
@@ -42,8 +42,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -105,7 +103,7 @@ static DiaObject *goal_create(Point *startpoint,
 			  Handle **handle2);
 static void goal_destroy(Goal *goal);
 static DiaObject *goal_load(ObjectNode obj_node, int version,
-                            const char *filename);
+                            DiaContext *ctx);
 
 static PropDescription *goal_describe_props(Goal *goal);
 static void goal_get_props(Goal *goal, GPtrArray *props);
@@ -118,7 +116,7 @@ static void compute_cloud(Goal *goal, BezPoint* bpl);
 static ObjectTypeOps istar_goal_type_ops =
 {
   (CreateFunc) goal_create,
-  (LoadFunc)   goal_load/*using_properties*/,
+  (LoadFunc)   goal_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -565,10 +563,10 @@ goal_destroy(Goal *goal)
 
 
 static DiaObject *
-goal_load(ObjectNode obj_node, int version, const char *filename)
+goal_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&istar_goal_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/Istar/link.c b/objects/Istar/link.c
index a67eded..d520a00 100644
--- a/objects/Istar/link.c
+++ b/objects/Istar/link.c
@@ -97,8 +97,7 @@ static DiaObject *link_create(Point *startpoint,
 static real link_distance_from(Link *link, Point *point);
 static void link_update_data(Link *link);
 static void link_destroy(Link *link);
-static DiaObject *link_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *link_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *link_describe_props(Link *mes);
 static void link_get_props(Link * link, GPtrArray *props);
@@ -656,7 +655,7 @@ link_update_data(Link *link)
 }
 
 static DiaObject *
-link_load(ObjectNode obj_node, int version, const char *filename)
+link_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
-  return object_load_using_properties(&istar_link_type,obj_node,version,filename);
+  return object_load_using_properties(&istar_link_type,obj_node,version,ctx);
 }
diff --git a/objects/Istar/other.c b/objects/Istar/other.c
index 5e2eec2..933f1f9 100644
--- a/objects/Istar/other.c
+++ b/objects/Istar/other.c
@@ -41,8 +41,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -102,7 +100,7 @@ static DiaObject *other_create(Point *startpoint,
 			  Handle **handle2);
 static void other_destroy(Other *other);
 static DiaObject *other_load(ObjectNode obj_node, int version,
-                            const char *filename);
+                             DiaContext *ctx);
 static DiaMenu *other_get_object_menu(Other *other, Point *clickedpoint);
 
 static PropDescription *other_describe_props(Other *other);
@@ -112,7 +110,7 @@ static void other_set_props(Other *other, GPtrArray *props);
 static ObjectTypeOps istar_other_type_ops =
 {
   (CreateFunc) other_create,
-  (LoadFunc)   other_load/*using_properties*/,
+  (LoadFunc)   other_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -572,10 +570,10 @@ other_destroy(Other *other)
 
 
 static DiaObject *
-other_load(ObjectNode obj_node, int version, const char *filename)
+other_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&istar_other_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/Jackson/domain.c b/objects/Jackson/domain.c
index ad49584..2fcc94e 100644
--- a/objects/Jackson/domain.c
+++ b/objects/Jackson/domain.c
@@ -42,8 +42,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -129,7 +127,7 @@ static DiaObject *jackson_box_create(Point *startpoint,
 			  Handle **handle2);
 static void jackson_box_destroy(Box *box);
 static DiaObject *jackson_box_load(ObjectNode obj_node, int version,
-                            const char *filename);
+				   DiaContext *ctx);
 static DiaMenu *jackson_box_get_object_menu(Box *box, Point *clickedpoint);
 
 static PropDescription *jackson_box_describe_props(Box *box);
@@ -139,7 +137,7 @@ static void jackson_box_set_props(Box *box, GPtrArray *props);
 static ObjectTypeOps jackson_domain_type_ops =
 {
   (CreateFunc) jackson_box_create,
-  (LoadFunc)   jackson_box_load/*using_properties*/,
+  (LoadFunc)   jackson_box_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -638,11 +636,8 @@ jackson_box_destroy(Box *box)
 
 
 static DiaObject *
-jackson_box_load(ObjectNode obj_node, int version, const char *filename)
+jackson_box_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&jackson_domain_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
-
-
-
diff --git a/objects/Jackson/phenomenon.c b/objects/Jackson/phenomenon.c
index 130dc1a..631cfda 100644
--- a/objects/Jackson/phenomenon.c
+++ b/objects/Jackson/phenomenon.c
@@ -90,8 +90,7 @@ static DiaObject *message_create(Point *startpoint,
 static real message_distance_from(Message *message, Point *point);
 static void message_update_data(Message *message);
 static void message_destroy(Message *message);
-static DiaObject *message_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *message_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *message_describe_props(Message *mes);
 static void message_get_props(Message * message, GPtrArray *props);
@@ -405,10 +404,10 @@ message_update_data(Message *message)
 
 
 static DiaObject *
-message_load(ObjectNode obj_node, int version, const char *filename)
+message_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&jackson_phenomenon_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/Jackson/requirement.c b/objects/Jackson/requirement.c
index a35a40c..86840ba 100644
--- a/objects/Jackson/requirement.c
+++ b/objects/Jackson/requirement.c
@@ -84,8 +84,7 @@ static DiaObject *req_create(Point *startpoint,
 			      Handle **handle1,
 			      Handle **handle2);
 static void req_destroy(Requirement *req);
-static DiaObject *req_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *req_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static void req_update_data(Requirement *req);
 static PropDescription *req_describe_props(Requirement *req);
 static void req_get_props(Requirement *req, GPtrArray *props);
@@ -431,10 +430,10 @@ req_destroy(Requirement *req)
 }
 
 static DiaObject *
-req_load(ObjectNode obj_node, int version, const char *filename)
+req_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&jackson_requirement_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/KAOS/goal.c b/objects/KAOS/goal.c
index 4758ba4..f84f769 100644
--- a/objects/KAOS/goal.c
+++ b/objects/KAOS/goal.c
@@ -42,8 +42,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -111,7 +109,7 @@ static DiaObject *goal_create(Point *startpoint,
 			  Handle **handle2);
 static void goal_destroy(Goal *goal);
 static DiaObject *goal_load(ObjectNode obj_node, int version,
-                            const char *filename);
+                            DiaContext *ctx);
 static DiaMenu *goal_get_object_menu(Goal *goal, Point *clickedpoint);
 
 static PropDescription *goal_describe_props(Goal *goal);
@@ -121,7 +119,7 @@ static void goal_set_props(Goal *goal, GPtrArray *props);
 static ObjectTypeOps kaos_goal_type_ops =
 {
   (CreateFunc) goal_create,
-  (LoadFunc)   goal_load/*using_properties*/,
+  (LoadFunc)   goal_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -677,10 +675,10 @@ goal_destroy(Goal *goal)
 
 
 static DiaObject *
-goal_load(ObjectNode obj_node, int version, const char *filename)
+goal_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&kaos_goal_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/KAOS/metaandorrel.c b/objects/KAOS/metaandorrel.c
index 851d9d0..21a4d3d 100644
--- a/objects/KAOS/metaandorrel.c
+++ b/objects/KAOS/metaandorrel.c
@@ -101,8 +101,7 @@ static DiaObject *maor_create(Point *startpoint,
 static real maor_distance_from(Maor *maor, Point *point);
 static void maor_update_data(Maor *maor);
 static void maor_destroy(Maor *maor);
-static DiaObject *maor_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *maor_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *maor_describe_props(Maor *mes);
 static void maor_get_props(Maor * maor, GPtrArray *props);
@@ -634,8 +633,8 @@ maor_update_data(Maor *maor)
 }
 
 static DiaObject *
-maor_load(ObjectNode obj_node, int version, const char *filename)
+maor_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&kaos_maor_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
diff --git a/objects/KAOS/metabinrel.c b/objects/KAOS/metabinrel.c
index a8bce30..2733396 100644
--- a/objects/KAOS/metabinrel.c
+++ b/objects/KAOS/metabinrel.c
@@ -109,8 +109,7 @@ static DiaObject *mbr_create(Point *startpoint,
 static real mbr_distance_from(Mbr *mbr, Point *point);
 static void mbr_update_data(Mbr *mbr);
 static void mbr_destroy(Mbr *mbr);
-static DiaObject *mbr_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *mbr_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *mbr_describe_props(Mbr *mes);
 static void mbr_get_props(Mbr * mbr, GPtrArray *props);
@@ -582,8 +581,8 @@ mbr_update_data(Mbr *mbr)
 }
 
 static DiaObject *
-mbr_load(ObjectNode obj_node, int version, const char *filename)
+mbr_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&kaos_mbr_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
diff --git a/objects/KAOS/other.c b/objects/KAOS/other.c
index 623ff8d..cdd635a 100644
--- a/objects/KAOS/other.c
+++ b/objects/KAOS/other.c
@@ -42,8 +42,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -105,7 +103,7 @@ static DiaObject *other_create(Point *startpoint,
 			  Handle **handle2);
 static void other_destroy(Other *other);
 static DiaObject *other_load(ObjectNode obj_node, int version,
-                            const char *filename);
+                             DiaContext *cts);
 static DiaMenu *other_get_object_menu(Other *other, Point *clickedpoint);
 
 static PropDescription *other_describe_props(Other *other);
@@ -115,7 +113,7 @@ static void other_set_props(Other *other, GPtrArray *props);
 static ObjectTypeOps kaos_other_type_ops =
 {
   (CreateFunc) other_create,
-  (LoadFunc)   other_load/*using_properties*/,
+  (LoadFunc)   other_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -629,10 +627,10 @@ other_destroy(Other *other)
 
 
 static DiaObject *
-other_load(ObjectNode obj_node, int version, const char *filename)
+other_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&kaos_other_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/Misc/analog_clock.c b/objects/Misc/analog_clock.c
index 7e59c34..9fc7e85 100644
--- a/objects/Misc/analog_clock.c
+++ b/objects/Misc/analog_clock.c
@@ -35,8 +35,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 #include "dynamic_obj.h"
@@ -84,7 +82,7 @@ static DiaObject *analog_clock_create(Point *startpoint,
                                    Handle **handle2);
 static void analog_clock_destroy(Analog_Clock *analog_clock);
 static DiaObject *analog_clock_load(ObjectNode obj_node, int version, 
-                                 const char *filename);
+                                    DiaContext *ctx);
 static PropDescription *analog_clock_describe_props(
   Analog_Clock *analog_clock);
 static void analog_clock_get_props(Analog_Clock *analog_clock, 
@@ -95,7 +93,7 @@ static void analog_clock_set_props(Analog_Clock *analog_clock,
 static ObjectTypeOps analog_clock_type_ops =
 {
   (CreateFunc) analog_clock_create,
-  (LoadFunc)   analog_clock_load/*using properties*/,
+  (LoadFunc)   analog_clock_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL
@@ -471,8 +469,8 @@ analog_clock_destroy(Analog_Clock *analog_clock)
 }
 
 static DiaObject *
-analog_clock_load(ObjectNode obj_node, int version, const char *filename)
+analog_clock_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&analog_clock_type,
-                                      obj_node,version,filename);  
+                                      obj_node,version,ctx);  
 }
diff --git a/objects/Misc/diagram_as_object.c b/objects/Misc/diagram_as_object.c
index aa26437..74f4fcd 100644
--- a/objects/Misc/diagram_as_object.c
+++ b/objects/Misc/diagram_as_object.c
@@ -75,7 +75,7 @@ _dae_create (Point *startpoint,
 	     Handle **handle1,
 	     Handle **handle2);
 static DiaObject *
-_dae_load (ObjectNode obj_node, int version, const char *filename);
+_dae_load (ObjectNode obj_node, int version, DiaContext *ctx);
 static void
 _dae_save (DiaObject *obj, ObjectNode obj_node, const char *filename);
 
@@ -249,10 +249,15 @@ _dae_update_data(DiagramAsElement *dae)
     dae->data = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
 
     inf = filter_guess_import_filter(dae->filename);
-    if (inf && inf->import_func(dae->filename, dae->data, inf->user_data)) {
-      dae->scale = dae->element.width / (dae->data->extents.right - dae->data->extents.left);
-      dae->element.height = (dae->data->extents.bottom - dae->data->extents.top) * dae->scale;
-      dae->mtime = statbuf.st_mtime;
+    if (inf) {
+      DiaContext *ctx = dia_context_new (diagram_as_element_type.name);
+
+      if (inf->import_func(dae->filename, dae->data, ctx, inf->user_data)) {
+        dae->scale = dae->element.width / (dae->data->extents.right - dae->data->extents.left);
+        dae->element.height = (dae->data->extents.bottom - dae->data->extents.top) * dae->scale;
+        dae->mtime = statbuf.st_mtime;
+      }
+      dia_context_release (ctx);
     }
     /* invalidate possibly cached image */
     if (dae->image) {
@@ -348,17 +353,17 @@ _dae_create (Point *startpoint,
 }
 
 static DiaObject *
-_dae_load (ObjectNode obj_node, int version, const char *filename)
+_dae_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   DiaObject *obj;
   DiagramAsElement *dae;
  
   obj = object_load_using_properties (&diagram_as_element_type,
-                                       obj_node, version, filename);
+                                       obj_node, version, ctx);
   /* filename de-normalization */
   dae = (DiagramAsElement*)obj;
   if (strlen(dae->filename) && !g_path_is_absolute (dae->filename)) {
-    gchar *dirname = g_path_get_dirname (filename);
+    gchar *dirname = g_path_get_dirname (dia_context_get_filename(ctx));
     gchar *fname = g_build_filename (dirname, dae->filename, NULL);
     g_free (dae->filename);
     dae->filename = fname;
diff --git a/objects/Misc/grid_object.c b/objects/Misc/grid_object.c
index b6203a8..a278f36 100644
--- a/objects/Misc/grid_object.c
+++ b/objects/Misc/grid_object.c
@@ -36,8 +36,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 
@@ -83,7 +81,7 @@ static DiaObject *grid_object_create(Point *startpoint,
 static void grid_object_reallocate_cells (Grid_Object* grid_object);
 static void grid_object_destroy(Grid_Object *grid_object);
 static DiaObject *grid_object_load(ObjectNode obj_node, int version, 
-                                 const char *filename);
+                                   DiaContext *ctx);
 static PropDescription *grid_object_describe_props(
   Grid_Object *grid_object);
 static void grid_object_get_props(Grid_Object *grid_object, 
@@ -94,7 +92,7 @@ static void grid_object_set_props(Grid_Object *grid_object,
 static ObjectTypeOps grid_object_type_ops =
 {
   (CreateFunc) grid_object_create,
-  (LoadFunc)   grid_object_load/*using properties*/,
+  (LoadFunc)   grid_object_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL
@@ -518,8 +516,8 @@ grid_object_destroy(Grid_Object *grid_object)
 }
 
 static DiaObject *
-grid_object_load(ObjectNode obj_node, int version, const char *filename)
+grid_object_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&grid_object_type,
-                                      obj_node,version,filename);  
+                                      obj_node,version,ctx);  
 }
diff --git a/objects/Misc/measure.c b/objects/Misc/measure.c
index c10a575..b74f81c 100644
--- a/objects/Misc/measure.c
+++ b/objects/Misc/measure.c
@@ -55,7 +55,7 @@ static DiaObject *measure_create (Point *startpoint,
 				  Handle **handle1,
 				  Handle **handle2);
 static DiaObject *
-measure_load(ObjectNode obj_node, int version, const char *filename);
+measure_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps measure_type_ops =
 {
@@ -159,10 +159,10 @@ measure_create (Point *startpoint,
   return obj;
 }
 static DiaObject *
-measure_load(ObjectNode obj_node, int version, const char *filename)
+measure_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&measure_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 static PropNumData scale_range = {1e-9, 1e9, 1 };
 static PropEnumData unit_data[] = {
diff --git a/objects/Misc/tree.c b/objects/Misc/tree.c
index c7553af..b244488 100644
--- a/objects/Misc/tree.c
+++ b/objects/Misc/tree.c
@@ -87,8 +87,7 @@ static PropDescription *tree_describe_props(Tree *tree);
 static void tree_get_props(Tree *tree, GPtrArray *props);
 static void tree_set_props(Tree *tree, GPtrArray *props);
 static void tree_save(Tree *tree, ObjectNode obj_node, const char *filename);
-static DiaObject *tree_load(ObjectNode obj_node, int version,
-			const char *filename);
+static DiaObject *tree_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static DiaMenu *tree_get_object_menu(Tree *tree, Point *clickedpoint);
 
 static ObjectChange *
@@ -633,7 +632,7 @@ tree_save(Tree *tree, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-tree_load(ObjectNode obj_node, int version, const char *filename)
+tree_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Tree *tree;
   Connection *conn;
@@ -652,7 +651,7 @@ tree_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &tree_type;
   obj->ops = &tree_ops;
 
-  connection_load(conn, obj_node);
+  connection_load(conn, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "tree_handles");
 
@@ -671,7 +670,7 @@ tree_load(ObjectNode obj_node, int version, const char *filename)
     tree->handles[i]->type = HANDLE_MINOR_CONTROL;
     tree->handles[i]->connect_type = HANDLE_CONNECTABLE_NOBREAK;
     tree->handles[i]->connected_to = NULL;
-    data_point(data, &tree->handles[i]->pos);
+    data_point(data, &tree->handles[i]->pos, ctx);
     obj->handles[2+i] = tree->handles[i];
 
     data = data_next(data);
@@ -680,7 +679,7 @@ tree_load(ObjectNode obj_node, int version, const char *filename)
   tree->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &tree->line_color);
+    data_color(attribute_first_data(attr), &tree->line_color, ctx);
 
   extra->start_trans = 
     extra->end_trans = 
diff --git a/objects/SADT/annotation.c b/objects/SADT/annotation.c
index 62f18fe..5bd13ef 100644
--- a/objects/SADT/annotation.c
+++ b/objects/SADT/annotation.c
@@ -75,8 +75,7 @@ static DiaObject *annotation_create(Point *startpoint,
 static real annotation_distance_from(Annotation *annotation, Point *point);
 static void annotation_update_data(Annotation *annotation);
 static void annotation_destroy(Annotation *annotation);
-static DiaObject *annotation_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *annotation_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *annotation_describe_props(Annotation *annotation);
 static void annotation_get_props(Annotation *annotation, 
                                  GPtrArray *props);
@@ -421,8 +420,8 @@ annotation_update_data(Annotation *annotation)
 }
 
 static DiaObject *
-annotation_load(ObjectNode obj_node, int version, const char *filename)
+annotation_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&sadtannotation_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
diff --git a/objects/SADT/arrow.c b/objects/SADT/arrow.c
index 81bc7ba..059747c 100644
--- a/objects/SADT/arrow.c
+++ b/objects/SADT/arrow.c
@@ -32,8 +32,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "color.h"
 #include "properties.h"
 
@@ -88,7 +86,7 @@ static DiaMenu *sadtarrow_get_object_menu(Sadtarrow *sadtarrow,
 					   Point *clickedpoint);
 
 static DiaObject *sadtarrow_load(ObjectNode obj_node, int version,
-			       const char *filename);
+				 DiaContext *ctx);
 static PropDescription *sadtarrow_describe_props(Sadtarrow *sadtarrow);
 static void sadtarrow_get_props(Sadtarrow *sadtarrow, 
                                  GPtrArray *props);
@@ -99,7 +97,7 @@ static void sadtarrow_set_props(Sadtarrow *sadtarrow,
 static ObjectTypeOps sadtarrow_type_ops =
 {
   (CreateFunc)sadtarrow_create,   /* create */
-  (LoadFunc)  sadtarrow_load/*using properties*/,     /* load */
+  (LoadFunc)  sadtarrow_load,     /* load */
   (SaveFunc)  object_save_using_properties, /* save */
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL
@@ -487,9 +485,9 @@ sadtarrow_get_object_menu(Sadtarrow *sadtarrow, Point *clickedpoint)
 }
 
 static DiaObject *
-sadtarrow_load(ObjectNode obj_node, int version, const char *filename)
+sadtarrow_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&sadtarrow_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
diff --git a/objects/SADT/box.c b/objects/SADT/box.c
index 3cecb92..19d1ab2 100644
--- a/objects/SADT/box.c
+++ b/objects/SADT/box.c
@@ -38,8 +38,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -89,7 +87,7 @@ static DiaObject *sadtbox_create(Point *startpoint,
 			  Handle **handle2);
 static void sadtbox_destroy(Box *box);
 static DiaObject *sadtbox_load(ObjectNode obj_node, int version, 
-                            const char *filename);
+                               DiaContext *ctx);
 static DiaMenu *sadtbox_get_object_menu(Box *box, Point *clickedpoint);
 
 static PropDescription *sadtbox_describe_props(Box *box);
@@ -99,7 +97,7 @@ static void sadtbox_set_props(Box *box, GPtrArray *props);
 static ObjectTypeOps sadtbox_type_ops =
 {
   (CreateFunc) sadtbox_create,
-  (LoadFunc)   sadtbox_load/*using_properties*/,
+  (LoadFunc)   sadtbox_load,
   (SaveFunc)   object_save_using_properties,
   (GetDefaultsFunc)   NULL,
   (ApplyDefaultsFunc) NULL,
@@ -553,9 +551,9 @@ sadtbox_destroy(Box *box)
 
 
 static DiaObject *
-sadtbox_load(ObjectNode obj_node, int version, const char *filename)
+sadtbox_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&sadtbox_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
diff --git a/objects/UML/activity.c b/objects/UML/activity.c
index f4c3d16..1e5d43b 100644
--- a/objects/UML/activity.c
+++ b/objects/UML/activity.c
@@ -72,8 +72,7 @@ static DiaObject *state_create_activity(Point *startpoint,
 			   Handle **handle1,
 			   Handle **handle2);
 static void state_destroy(State *state);
-static DiaObject *state_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *state_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *state_describe_props(State *state);
 static void state_get_props(State *state, GPtrArray *props);
 static void state_set_props(State *state, GPtrArray *props);
@@ -360,10 +359,10 @@ state_destroy(State *state)
 }
 
 static DiaObject *
-state_load(ObjectNode obj_node, int version, const char *filename)
+state_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&activity_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/actor.c b/objects/UML/actor.c
index f960356..8f69a34 100644
--- a/objects/UML/actor.c
+++ b/objects/UML/actor.c
@@ -70,8 +70,7 @@ static DiaObject *actor_create(Point *startpoint,
 			   Handle **handle1,
 			   Handle **handle2);
 static void actor_destroy(Actor *actor);
-static DiaObject *actor_load(ObjectNode obj_node, int version,
-			  const char *filename);
+static DiaObject *actor_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *actor_describe_props(Actor *actor);
 static void actor_get_props(Actor *actor, GPtrArray *props);
@@ -390,10 +389,10 @@ actor_destroy(Actor *actor)
 }
 
 static DiaObject *
-actor_load(ObjectNode obj_node, int version, const char *filename)
+actor_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&actor_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   AttributeNode attr;
   /* For compatibility with previous dia files. If no line_width, use
    * ACTOR_LINEWIDTH, that was the previous line width.
diff --git a/objects/UML/association.c b/objects/UML/association.c
index e019c56..34881f6 100644
--- a/objects/UML/association.c
+++ b/objects/UML/association.c
@@ -174,8 +174,7 @@ static AssociationState *association_get_state(Association *assoc);
 static void association_set_state(Association *assoc,
 				  AssociationState *state);
 
-static DiaObject *association_load(ObjectNode obj_node, int version,
-				const char *filename);
+static DiaObject *association_load(ObjectNode obj_node, int version, DiaContext *ctx);
 
 static void association_update_data(Association *assoc);
 static coord get_aggregate_pos_diff(AssociationEnd *end, const Association *assoc);
@@ -944,7 +943,7 @@ association_copy(Association *assoc)
 }
 
 static DiaObject *
-association_load(ObjectNode obj_node, int version, const char *filename)
+association_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Association *assoc;
   AttributeNode attr;
@@ -954,7 +953,7 @@ association_load(ObjectNode obj_node, int version, const char *filename)
   int i;
   
   /* first calls our _create() method */
-  obj = object_load_using_properties(&association_type, obj_node, version, filename);
+  obj = object_load_using_properties(&association_type, obj_node, version, ctx);
   assoc = (Association *)obj;
   orth = &assoc->orth;
   /* ... butnot orthconn_load()  */
@@ -965,7 +964,7 @@ association_load(ObjectNode obj_node, int version, const char *filename)
     /* vesrion 1 used to name it differently */
     attr = object_find_attribute(obj_node, "autorouting");
     if (attr != NULL)
-      orth->autorouting = data_boolean(attribute_first_data(attr));
+      orth->autorouting = data_boolean(attribute_first_data(attr), ctx);
 
     attr = object_find_attribute(obj_node, "ends");
     composite = attribute_first_data(attr);
@@ -974,7 +973,7 @@ association_load(ObjectNode obj_node, int version, const char *filename)
       assoc->end[i].role = NULL;
       attr = composite_find_attribute(composite, "role");
       if (attr != NULL) {
-        assoc->end[i].role = data_string(attribute_first_data(attr));
+        assoc->end[i].role = data_string(attribute_first_data(attr), ctx);
       }
       if (   assoc->end[i].role != NULL 
           && 0 == strcmp(assoc->end[i].role, "")) {
@@ -985,7 +984,7 @@ association_load(ObjectNode obj_node, int version, const char *filename)
       assoc->end[i].multiplicity = NULL;
       attr = composite_find_attribute(composite, "multiplicity");
       if (attr != NULL) {
-        assoc->end[i].multiplicity = data_string(attribute_first_data(attr));
+        assoc->end[i].multiplicity = data_string(attribute_first_data(attr), ctx);
       }
       if (   assoc->end[i].multiplicity != NULL
 	  && 0 == strcmp(assoc->end[i].multiplicity, "")) {
@@ -996,17 +995,17 @@ association_load(ObjectNode obj_node, int version, const char *filename)
       assoc->end[i].arrow = FALSE;
       attr = composite_find_attribute(composite, "arrow");
       if (attr != NULL)
-        assoc->end[i].arrow = data_boolean(attribute_first_data(attr));
+        assoc->end[i].arrow = data_boolean(attribute_first_data(attr), ctx);
 
       assoc->end[i].aggregate = AGGREGATE_NONE;
       attr = composite_find_attribute(composite, "aggregate");
       if (attr != NULL)
-        assoc->end[i].aggregate = data_enum(attribute_first_data(attr));
-  
+        assoc->end[i].aggregate = data_enum(attribute_first_data(attr), ctx);
+
       assoc->end[i].visibility = FALSE;
       attr = composite_find_attribute(composite, "visibility");
       if (attr != NULL)
-        assoc->end[i].visibility =  data_enum( attribute_first_data(attr) );
+        assoc->end[i].visibility = data_enum(attribute_first_data(attr), ctx);
 
       assoc->end[i].text_width = 0.0;
       if (assoc->end[i].role != NULL) {
diff --git a/objects/UML/branch.c b/objects/UML/branch.c
index 91bef96..dd4a969 100644
--- a/objects/UML/branch.c
+++ b/objects/UML/branch.c
@@ -65,8 +65,7 @@ static DiaObject *branch_create(Point *startpoint,
 			     Handle **handle1,
 			     Handle **handle2);
 static void branch_destroy(Branch *branch);
-static DiaObject *branch_load(ObjectNode obj_node, int version,
-			   const char *filename);
+static DiaObject *branch_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *branch_describe_props(Branch *branch);
 static void branch_get_props(Branch *branch, GPtrArray *props);
@@ -295,10 +294,10 @@ static void branch_destroy(Branch *branch)
   element_destroy(&branch->element);
 }
 
-static DiaObject *branch_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *branch_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&branch_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/class.c b/objects/UML/class.c
index 1be9896..20f1937 100644
--- a/objects/UML/class.c
+++ b/objects/UML/class.c
@@ -64,8 +64,7 @@ static DiaObject *umlclass_copy(UMLClass *umlclass);
 
 static void umlclass_save(UMLClass *umlclass, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *umlclass_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *umlclass_load(ObjectNode obj_node, int version, DiaContext *ctx);
 
 static DiaMenu * umlclass_object_menu(DiaObject *obj, Point *p);
 static ObjectChange *umlclass_show_comments_callback(DiaObject *obj, Point *pos, gpointer data);
@@ -2223,8 +2222,8 @@ umlclass_save(UMLClass *umlclass, ObjectNode obj_node,
   }
 }
 
-static DiaObject *umlclass_load(ObjectNode obj_node, int version,
-			     const char *filename)
+static DiaObject *
+umlclass_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   UMLClass *umlclass;
   Element *elem;
@@ -2241,7 +2240,7 @@ static DiaObject *umlclass_load(ObjectNode obj_node, int version,
   obj->type = &umlclass_type;
   obj->ops = &umlclass_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
 
 #ifdef UML_MAINPOINT
   element_init(elem, 8, UMLCLASS_CONNECTIONPOINTS + 1);
@@ -2260,10 +2259,10 @@ static DiaObject *umlclass_load(ObjectNode obj_node, int version,
   fill_in_fontdata(umlclass);
   
   /* kind of dirty, object_load_props() may leave us in an inconsistent state --hb */
-  object_load_props(obj,obj_node);
+  object_load_props(obj,obj_node, ctx);
 
   /* parameters loaded via StdProp dont belong here anymore. In case of strings they 
-   * will produce leaks. Otherwise the are just wasteing time (at runtime and while 
+   * will produce leaks. Otherwise they are just wasting time (at runtime and while 
    * reading the code). Except maybe for some compatibility stuff. 
    * Although that *could* probably done via StdProp too.                      --hb
    */
@@ -2272,12 +2271,12 @@ static DiaObject *umlclass_load(ObjectNode obj_node, int version,
   umlclass->wrap_operations = FALSE;
   attr_node = object_find_attribute(obj_node, "wrap_operations");
   if (attr_node != NULL)
-    umlclass->wrap_operations = data_boolean(attribute_first_data(attr_node));
+    umlclass->wrap_operations = data_boolean(attribute_first_data(attr_node), ctx);
   
   umlclass->wrap_after_char = UMLCLASS_WRAP_AFTER_CHAR;
   attr_node = object_find_attribute(obj_node, "wrap_after_char");
   if (attr_node != NULL)
-    umlclass->wrap_after_char = data_int(attribute_first_data(attr_node));
+    umlclass->wrap_after_char = data_int(attribute_first_data(attr_node), ctx);
 
   /* if it uses the new name the value is already set by object_load_props() above */
   umlclass->comment_line_length = UMLCLASS_COMMENT_LINE_LENGTH;
@@ -2286,43 +2285,43 @@ static DiaObject *umlclass_load(ObjectNode obj_node, int version,
   if (attr_node == NULL)
     attr_node = object_find_attribute(obj_node,"Comment_line_length");
   if (attr_node != NULL)
-    umlclass->comment_line_length = data_int(attribute_first_data(attr_node));
+    umlclass->comment_line_length = data_int(attribute_first_data(attr_node), ctx);
 
   /* compatibility with 0.94 and before as well as the temporary state with only 'comment_line_length' */
   umlclass->comment_tagging = (attr_node != NULL);
   attr_node = object_find_attribute(obj_node, "comment_tagging");
   if (attr_node != NULL)
-    umlclass->comment_tagging = data_boolean(attribute_first_data(attr_node));
+    umlclass->comment_tagging = data_boolean(attribute_first_data(attr_node), ctx);
   
   /* Loads the line width */
   umlclass->line_width = UMLCLASS_BORDER;
   attr_node = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if(attr_node != NULL)
-    umlclass->line_width = data_real(attribute_first_data(attr_node));
+    umlclass->line_width = data_real(attribute_first_data(attr_node), ctx);
 
   umlclass->line_color = color_black;
   /* support the old name ... */
   attr_node = object_find_attribute(obj_node, "foreground_color");
   if(attr_node != NULL)
-    data_color(attribute_first_data(attr_node), &umlclass->line_color); 
+    data_color(attribute_first_data(attr_node), &umlclass->line_color, ctx);
   umlclass->text_color = umlclass->line_color;
   /* ... but prefer the new one */
   attr_node = object_find_attribute(obj_node, "line_color");
   if(attr_node != NULL)
-    data_color(attribute_first_data(attr_node), &umlclass->line_color); 
+    data_color(attribute_first_data(attr_node), &umlclass->line_color, ctx); 
   attr_node = object_find_attribute(obj_node, "text_color");
   if(attr_node != NULL)
-    data_color(attribute_first_data(attr_node), &umlclass->text_color); 
-  
+    data_color(attribute_first_data(attr_node), &umlclass->text_color, ctx);
+
   umlclass->fill_color = color_white;
   /* support the old name ... */
   attr_node = object_find_attribute(obj_node, "background_color");
   if(attr_node != NULL)
-    data_color(attribute_first_data(attr_node), &umlclass->fill_color); 
+    data_color(attribute_first_data(attr_node), &umlclass->fill_color, ctx);
   /* ... but prefer the new one */
   attr_node = object_find_attribute(obj_node, "fill_color");
   if(attr_node != NULL)
-    data_color(attribute_first_data(attr_node), &umlclass->fill_color); 
+    data_color(attribute_first_data(attr_node), &umlclass->fill_color, ctx);
 
   /* Attribute info: */
   list = umlclass->attributes;
@@ -2348,8 +2347,8 @@ static DiaObject *umlclass_load(ObjectNode obj_node, int version,
   umlclass->template = FALSE;
   attr_node = object_find_attribute(obj_node, "template");
   if (attr_node != NULL)
-    umlclass->template = data_boolean(attribute_first_data(attr_node));
-  
+    umlclass->template = data_boolean(attribute_first_data(attr_node), ctx);
+
   fill_in_fontdata(umlclass);
   
   umlclass->stereotype_string = NULL;
diff --git a/objects/UML/class.h b/objects/UML/class.h
index 539e927..46bc07f 100644
--- a/objects/UML/class.h
+++ b/objects/UML/class.h
@@ -27,7 +27,6 @@
 #include "object.h"
 #include "element.h"
 #include "connectionpoint.h"
-#include "widgets.h"
 
 #include "uml.h"
 
diff --git a/objects/UML/class_dialog.h b/objects/UML/class_dialog.h
index 4589379..919d0b5 100644
--- a/objects/UML/class_dialog.h
+++ b/objects/UML/class_dialog.h
@@ -1,3 +1,4 @@
+#include "widgets.h"
 /**
  * \brief Very special user interface for UMLClass parametrization
  *
diff --git a/objects/UML/classicon.c b/objects/UML/classicon.c
index c35d93a..6086740 100644
--- a/objects/UML/classicon.c
+++ b/objects/UML/classicon.c
@@ -82,8 +82,7 @@ static DiaObject *classicon_create(Point *startpoint,
 				Handle **handle1,
 				Handle **handle2);
 static void classicon_destroy(Classicon *cicon);
-static DiaObject *classicon_load(ObjectNode obj_node, int version,
-			      const char *filename);
+static DiaObject *classicon_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *classicon_describe_props(Classicon *classicon);
 static void classicon_get_props(Classicon *classicon, GPtrArray *props);
 static void classicon_set_props(Classicon *classicon, GPtrArray *props);
@@ -495,10 +494,10 @@ classicon_destroy(Classicon *cicon)
 }
 
 static DiaObject *
-classicon_load(ObjectNode obj_node, int version, const char *filename)
+classicon_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&classicon_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/component.c b/objects/UML/component.c
index e117666..44605ac 100644
--- a/objects/UML/component.c
+++ b/objects/UML/component.c
@@ -73,8 +73,7 @@ static DiaObject *component_create(Point *startpoint,
 				   Handle **handle1,
 				   Handle **handle2);
 static void component_destroy(Component *cmp);
-static DiaObject *component_load(ObjectNode obj_node, int version,
-				 const char *filename);
+static DiaObject *component_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *component_describe_props(Component *component);
 static void component_get_props(Component *component, GPtrArray *props);
@@ -452,10 +451,10 @@ component_destroy(Component *cmp)
 }
 
 static DiaObject *
-component_load(ObjectNode obj_node, int version, const char *filename)
+component_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&component_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/component_feature.c b/objects/UML/component_feature.c
index 9183bab..aaca9e0 100644
--- a/objects/UML/component_feature.c
+++ b/objects/UML/component_feature.c
@@ -104,8 +104,7 @@ static DiaMenu *compfeat_get_object_menu(Compfeat *compfeat,
 static PropDescription *compfeat_describe_props(Compfeat *compfeat);
 static void compfeat_get_props(Compfeat * compfeat, GPtrArray *props);
 static void compfeat_set_props(Compfeat * compfeat, GPtrArray *props);
-static DiaObject *compfeat_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *compfeat_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 
 static ObjectTypeOps compfeat_type_ops =
@@ -464,10 +463,10 @@ compfeat_update_data(Compfeat *compfeat)
 }
 
 static DiaObject *
-compfeat_load(ObjectNode obj_node, int version, const char *filename)
+compfeat_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&compfeat_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
diff --git a/objects/UML/constraint.c b/objects/UML/constraint.c
index 4f956f5..59eddbe 100644
--- a/objects/UML/constraint.c
+++ b/objects/UML/constraint.c
@@ -83,8 +83,7 @@ static PropDescription *constraint_describe_props(Constraint *constraint);
 static void constraint_get_props(Constraint * constraint, GPtrArray *props);
 static void constraint_set_props(Constraint * constraint, GPtrArray *props);
 
-static DiaObject *constraint_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *constraint_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps constraint_type_ops =
 {
@@ -397,8 +396,8 @@ constraint_update_data(Constraint *constraint)
 
 
 static DiaObject *
-constraint_load(ObjectNode obj_node, int version, const char *filename)
+constraint_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&constraint_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
diff --git a/objects/UML/dependency.c b/objects/UML/dependency.c
index ec52b45..9db853e 100644
--- a/objects/UML/dependency.c
+++ b/objects/UML/dependency.c
@@ -81,8 +81,7 @@ static void dependency_destroy(Dependency *dep);
 static DiaMenu *dependency_get_object_menu(Dependency *dep,
 					   Point *clickedpoint);
 
-static DiaObject *dependency_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *dependency_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *dependency_describe_props(Dependency *dependency);
 static void dependency_get_props(Dependency * dependency, GPtrArray *props);
 static void dependency_set_props(Dependency * dependency, GPtrArray *props);
@@ -458,10 +457,10 @@ dependency_destroy(Dependency *dep)
 }
 
 static DiaObject *
-dependency_load(ObjectNode obj_node, int version, const char *filename)
+dependency_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&dependency_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
diff --git a/objects/UML/fork.c b/objects/UML/fork.c
index fccbf4e..ce6693e 100644
--- a/objects/UML/fork.c
+++ b/objects/UML/fork.c
@@ -65,8 +65,7 @@ static DiaObject *fork_create(Point *startpoint,
 			     Handle **handle1,
 			     Handle **handle2);
 static void fork_destroy(Fork *branch);
-static DiaObject *fork_load(ObjectNode obj_node, int version,
-			   const char *filename);
+static DiaObject *fork_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *fork_describe_props(Fork *branch);
 static void fork_get_props(Fork *branch, GPtrArray *props);
@@ -297,10 +296,10 @@ static void fork_destroy(Fork *branch)
   element_destroy(&branch->element);
 }
 
-static DiaObject *fork_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *fork_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&fork_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/generalization.c b/objects/UML/generalization.c
index 1902952..3214932 100644
--- a/objects/UML/generalization.c
+++ b/objects/UML/generalization.c
@@ -81,8 +81,7 @@ static PropDescription *generalization_describe_props(Generalization *generaliza
 static void generalization_get_props(Generalization * generalization, GPtrArray *props);
 static void generalization_set_props(Generalization * generalization, GPtrArray *props);
 
-static DiaObject *generalization_load(ObjectNode obj_node, int version,
-				   const char *filename);
+static DiaObject *generalization_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static void generalization_update_data(Generalization *genlz);
 
@@ -454,11 +453,10 @@ generalization_destroy(Generalization *genlz)
 }
 
 static DiaObject *
-generalization_load(ObjectNode obj_node, int version,
-		    const char *filename)
+generalization_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&generalization_type,
-						obj_node,version,filename);
+						obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
diff --git a/objects/UML/implements.c b/objects/UML/implements.c
index 02b1e9a..3e0e0e8 100644
--- a/objects/UML/implements.c
+++ b/objects/UML/implements.c
@@ -83,8 +83,7 @@ static PropDescription *implements_describe_props(Implements *implements);
 static void implements_get_props(Implements * implements, GPtrArray *props);
 static void implements_set_props(Implements * implements, GPtrArray *props);
 
-static DiaObject *implements_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *implements_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 
 static ObjectTypeOps implements_type_ops =
@@ -426,8 +425,8 @@ implements_update_data(Implements *implements)
 }
 
 static DiaObject *
-implements_load(ObjectNode obj_node, int version, const char *filename)
+implements_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&implements_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
diff --git a/objects/UML/large_package.c b/objects/UML/large_package.c
index 7284639..6228d6f 100644
--- a/objects/UML/large_package.c
+++ b/objects/UML/large_package.c
@@ -88,8 +88,7 @@ static void largepackage_update_data(LargePackage *pkg);
 static PropDescription *largepackage_describe_props(LargePackage *largepackage);
 static void largepackage_get_props(LargePackage *largepackage, GPtrArray *props);
 static void largepackage_set_props(LargePackage *largepackage, GPtrArray *props);
-static DiaObject *largepackage_load(ObjectNode obj_node, int version, 
-                                 const char *filename);
+static DiaObject *largepackage_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps largepackage_type_ops =
 {
@@ -412,10 +411,10 @@ largepackage_destroy(LargePackage *pkg)
 }
 
 static DiaObject *
-largepackage_load(ObjectNode obj_node, int version, const char *filename)
+largepackage_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&largepackage_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   AttributeNode attr;
   /* For compatibility with previous dia files. If no line_width, use
    * LARGEPACKAGE_BORDERWIDTH, that was the previous line width.
diff --git a/objects/UML/lifeline.c b/objects/UML/lifeline.c
index 40d854a..8d472c6 100644
--- a/objects/UML/lifeline.c
+++ b/objects/UML/lifeline.c
@@ -102,8 +102,7 @@ static DiaObject *lifeline_create(Point *startpoint,
 static real lifeline_distance_from(Lifeline *lifeline, Point *point);
 static void lifeline_update_data(Lifeline *lifeline);
 static void lifeline_destroy(Lifeline *lifeline);
-static DiaObject *lifeline_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *lifeline_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *lifeline_describe_props(Lifeline *lifeline);
 
 static void lifeline_get_props(Lifeline * lifeline, GPtrArray *props);
@@ -739,11 +738,11 @@ lifeline_update_data(Lifeline *lifeline)
 }
 
 static DiaObject *
-lifeline_load(ObjectNode obj_node, int version, const char *filename)
+lifeline_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Lifeline *lifeline;
   DiaObject *obj = object_load_using_properties(&lifeline_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
 
   lifeline = (Lifeline*)obj;
   return obj;
diff --git a/objects/UML/message.c b/objects/UML/message.c
index ec086eb..5e90f27 100644
--- a/objects/UML/message.c
+++ b/objects/UML/message.c
@@ -91,8 +91,7 @@ static DiaObject *message_create(Point *startpoint,
 static real message_distance_from(Message *message, Point *point);
 static void message_update_data(Message *message);
 static void message_destroy(Message *message);
-static DiaObject *message_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *message_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *message_describe_props(Message *mes);
 static void message_get_props(Message * message, GPtrArray *props);
@@ -460,10 +459,10 @@ message_update_data(Message *message)
 
 
 static DiaObject *
-message_load(ObjectNode obj_node, int version, const char *filename)
+message_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&message_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/node.c b/objects/UML/node.c
index 910fe99..e10e73d 100644
--- a/objects/UML/node.c
+++ b/objects/UML/node.c
@@ -75,8 +75,7 @@ static DiaObject *node_create(Point *startpoint,
 				   Handle **handle1,
 				   Handle **handle2);
 static void node_destroy(Node *node);
-static DiaObject *node_load(ObjectNode obj_node, int version,
-				 const char *filename);
+static DiaObject *node_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *node_describe_props(Node *node);
 static void node_get_props(Node *node, GPtrArray *props);
@@ -381,8 +380,8 @@ static void node_destroy(Node *node)
   element_destroy(&node->element);
 }
 
-static DiaObject *node_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *node_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&node_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
diff --git a/objects/UML/note.c b/objects/UML/note.c
index 0010c24..579e4b7 100644
--- a/objects/UML/note.c
+++ b/objects/UML/note.c
@@ -68,8 +68,7 @@ static DiaObject *note_create(Point *startpoint,
 			   Handle **handle1,
 			   Handle **handle2);
 static void note_destroy(Note *note);
-static DiaObject *note_load(ObjectNode obj_node, int version,
-			 const char *filename);
+static DiaObject *note_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *note_describe_props(Note *note);
 static void note_get_props(Note *note, GPtrArray *props);
@@ -363,10 +362,10 @@ note_destroy(Note *note)
 }
 
 static DiaObject *
-note_load(ObjectNode obj_node, int version, const char *filename)
+note_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject * obj = object_load_using_properties(&note_type,
-                                                 obj_node,version,filename);
+                                                 obj_node,version,ctx);
   AttributeNode attr;
   /* For compatibility with previous dia files. If no line_width, use
    * NOTE_BORDERWIDTH, that was the previous line width.
diff --git a/objects/UML/object.c b/objects/UML/object.c
index e15541c..d8f90bb 100644
--- a/objects/UML/object.c
+++ b/objects/UML/object.c
@@ -87,8 +87,7 @@ static DiaObject *objet_create(Point *startpoint,
 			    Handle **handle1,
 			    Handle **handle2);
 static void objet_destroy(Objet *ob);
-static DiaObject *objet_load(ObjectNode obj_node, int version,
-			  const char *filename);
+static DiaObject *objet_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *objet_describe_props(Objet *objet);
 static void objet_get_props(Objet *objet, GPtrArray *props);
 static void objet_set_props(Objet *objet, GPtrArray *props);
@@ -536,10 +535,10 @@ objet_destroy(Objet *ob)
 }
 
 static DiaObject *
-objet_load(ObjectNode obj_node, int version, const char *filename)
+objet_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject * obj = object_load_using_properties(&objet_type,
-                                                 obj_node,version,filename);
+                                                 obj_node,version,ctx);
   AttributeNode attr;
   /* For compatibility with previous dia files. If no line_width, use
    * OBJET_BORDERWIDTH, that was the previous line width.
diff --git a/objects/UML/realizes.c b/objects/UML/realizes.c
index 1bfe58b..4194cb0 100644
--- a/objects/UML/realizes.c
+++ b/objects/UML/realizes.c
@@ -81,8 +81,7 @@ static PropDescription *realizes_describe_props(Realizes *realizes);
 static void realizes_get_props(Realizes * realizes, GPtrArray *props);
 static void realizes_set_props(Realizes * realizes, GPtrArray *props);
 
-static DiaObject *realizes_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *realizes_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static void realizes_update_data(Realizes *realize);
 
@@ -451,10 +450,10 @@ realizes_destroy(Realizes *realize)
 }
 
 static DiaObject *
-realizes_load(ObjectNode obj_node, int version, const char *filename)
+realizes_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&realizes_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
diff --git a/objects/UML/small_package.c b/objects/UML/small_package.c
index 1a7193d..0e0ca5d 100644
--- a/objects/UML/small_package.c
+++ b/objects/UML/small_package.c
@@ -77,8 +77,7 @@ static DiaObject *smallpackage_create(Point *startpoint,
 				   Handle **handle1,
 				   Handle **handle2);
 static void smallpackage_destroy(SmallPackage *pkg);
-static DiaObject *smallpackage_load(ObjectNode obj_node, int version,
-				 const char *filename);
+static DiaObject *smallpackage_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static PropDescription *smallpackage_describe_props(SmallPackage *smallpackage);
 static void smallpackage_get_props(SmallPackage *smallpackage, GPtrArray *props);
@@ -412,10 +411,10 @@ smallpackage_destroy(SmallPackage *pkg)
 }
 
 static DiaObject *
-smallpackage_load(ObjectNode obj_node, int version, const char *filename)
+smallpackage_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&smallpackage_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   AttributeNode attr;
   /* For compatibility with previous dia files. If no line_width, use
    * SMALLPACKAGE_BORDERWIDTH, that was the previous line width.
diff --git a/objects/UML/state.c b/objects/UML/state.c
index 53122ce..65d9d88 100644
--- a/objects/UML/state.c
+++ b/objects/UML/state.c
@@ -95,8 +95,7 @@ static DiaObject *state_create(Point *startpoint,
 			   Handle **handle1,
 			   Handle **handle2);
 static void state_destroy(State *state);
-static DiaObject *state_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *state_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *state_describe_props(State *state);
 static void state_get_props(State *state, GPtrArray *props);
 static void state_set_props(State *state, GPtrArray *props);
@@ -483,10 +482,10 @@ state_destroy(State *state)
 }
 
 static DiaObject *
-state_load(ObjectNode obj_node, int version, const char *filename)
+state_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   State *obj = (State*)object_load_using_properties(&state_type,
-					     obj_node,version,filename);
+					     obj_node,version,ctx);
   if (obj->state_type != STATE_NORMAL) {
     /* Would like to create a state_term instead, but making the connections
      * is a pain */
diff --git a/objects/UML/state_term.c b/objects/UML/state_term.c
index 365d52b..46aa7ab 100644
--- a/objects/UML/state_term.c
+++ b/objects/UML/state_term.c
@@ -73,8 +73,7 @@ static DiaObject *state_create(Point *startpoint,
 			   Handle **handle1,
 			   Handle **handle2);
 static void state_destroy(State *state);
-static DiaObject *state_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *state_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription *state_describe_props(State *state);
 static void state_get_props(State *state, GPtrArray *props);
 static void state_set_props(State *state, GPtrArray *props);
@@ -323,10 +322,10 @@ state_destroy(State *state)
 }
 
 static DiaObject *
-state_load(ObjectNode obj_node, int version, const char *filename)
+state_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&state_term_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 
diff --git a/objects/UML/transition.c b/objects/UML/transition.c
index 245d012..0180a65 100644
--- a/objects/UML/transition.c
+++ b/objects/UML/transition.c
@@ -66,8 +66,7 @@ static DiaObject *transition_create(Point *startpoint,
                                     void *user_data,
                                     Handle **handle1,
                                     Handle **handle2);
-static DiaObject *transition_load(ObjectNode obj_node, int version,
-                                  const char *filename);
+static DiaObject *transition_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static void transition_destroy(Transition* transition);
 static void transition_draw(Transition* transition, DiaRenderer* ddisp);
@@ -242,11 +241,10 @@ transition_create(Point *startpoint,
   return obj;
 }
 
-static DiaObject *transition_load(ObjectNode obj_node, int version,
-                                  const char *filename)
+static DiaObject *transition_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&uml_transition_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
diff --git a/objects/UML/usecase.c b/objects/UML/usecase.c
index eb5123e..e2ff1fa 100644
--- a/objects/UML/usecase.c
+++ b/objects/UML/usecase.c
@@ -84,8 +84,7 @@ static DiaObject *usecase_create(Point *startpoint,
 			      Handle **handle1,
 			      Handle **handle2);
 static void usecase_destroy(Usecase *usecase);
-static DiaObject *usecase_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *usecase_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static void usecase_update_data(Usecase *usecase);
 static PropDescription *usecase_describe_props(Usecase *usecase);
 static void usecase_get_props(Usecase *usecase, GPtrArray *props);
@@ -463,10 +462,10 @@ usecase_destroy(Usecase *usecase)
 }
 
 static DiaObject *
-usecase_load(ObjectNode obj_node, int version, const char *filename)
+usecase_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   DiaObject *obj = object_load_using_properties(&usecase_type,
-                                                obj_node,version,filename);
+                                                obj_node,version,ctx);
   AttributeNode attr;
   /* For compatibility with previous dia files. If no line_width, use
    * USECASE_LINEWIDTH, that was the previous line width.
diff --git a/objects/chronogram/chronoline.c b/objects/chronogram/chronoline.c
index cb72e06..fd515e8 100644
--- a/objects/chronogram/chronoline.c
+++ b/objects/chronogram/chronoline.c
@@ -38,8 +38,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -98,7 +96,7 @@ static DiaObject *chronoline_create(Point *startpoint,
 			  Handle **handle2);
 static void chronoline_destroy(Chronoline *chronoline);
 static DiaObject *chronoline_load(ObjectNode obj_node, int version, 
-                               const char *filename);
+				  DiaContext *ctx);
 static PropDescription *chronoline_describe_props(Chronoline *chronoline);
 static void chronoline_get_props(Chronoline *chronoline, 
                                  GPtrArray *props);
@@ -658,8 +656,8 @@ chronoline_destroy(Chronoline *chronoline)
 }
 
 static DiaObject *
-chronoline_load(ObjectNode obj_node, int version, const char *filename)
+chronoline_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&chronoline_type,
-                                      obj_node,version,filename);  
+                                      obj_node,version,ctx);  
 }
diff --git a/objects/chronogram/chronoref.c b/objects/chronogram/chronoref.c
index 2b12323..1e607bc 100644
--- a/objects/chronogram/chronoref.c
+++ b/objects/chronogram/chronoref.c
@@ -38,8 +38,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "connpoint_line.h"
 #include "color.h"
 #include "properties.h"
@@ -89,7 +87,7 @@ static DiaObject *chronoref_create(Point *startpoint,
 			  Handle **handle2);
 static void chronoref_destroy(Chronoref *chronoref);
 static DiaObject *chronoref_load(ObjectNode obj_node, int version, 
-                              const char *filename);
+				 DiaContext *ctx);
 static PropDescription *chronoref_describe_props(Chronoref *chronoref);
 static void chronoref_get_props(Chronoref *chronoref, 
                                  GPtrArray *props);
@@ -465,8 +463,8 @@ chronoref_destroy(Chronoref *chronoref)
 }
 
 static DiaObject *
-chronoref_load(ObjectNode obj_node, int version, const char *filename)
+chronoref_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   return object_load_using_properties(&chronoref_type,
-                                      obj_node,version,filename);  
+                                      obj_node,version,ctx);  
 }
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index 37a75d5..dc709b8 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -45,8 +45,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "sheet.h"
 #include "properties.h"
 #include "dia_image.h"
@@ -157,7 +155,7 @@ static PropDescription *custom_describe_props(Custom *custom);
 static void custom_get_props(Custom *custom, GPtrArray *props);
 static void custom_set_props(Custom *custom, GPtrArray *props);
 
-static DiaObject *custom_load_using_properties(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *custom_load_using_properties(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps custom_type_ops =
   {
@@ -1670,7 +1668,7 @@ custom_copy(Custom *custom)
 }
 
 static DiaObject *
-custom_load_using_properties(ObjectNode obj_node, int version, const char *filename)
+custom_load_using_properties(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Custom *custom;
   DiaObject *obj;
@@ -1684,7 +1682,7 @@ custom_load_using_properties(ObjectNode obj_node, int version, const char *filen
       custom->padding = 0.5 * M_SQRT1_2; /* old pading */
     /* old default: only grow from text box, no auto-shrink. */
     custom->text_fitting = (custom->info->resize_with_text ? TEXTFIT_WHEN_NEEDED : TEXTFIT_NEVER);
-    object_load_props(obj,obj_node);
+    object_load_props(obj,obj_node,ctx);
   
     custom_update_data(custom, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
     custom->old_subscale = custom->subscale;
diff --git a/objects/custom_lines/custom_linetypes.c b/objects/custom_lines/custom_linetypes.c
index b54d084..35826ab 100644
--- a/objects/custom_lines/custom_linetypes.c
+++ b/objects/custom_lines/custom_linetypes.c
@@ -48,9 +48,9 @@ static DiaObject* customline_create(Point *startpoint,
                                     void *user_data,
                                     Handle **handle1,
                                     Handle **handle2);
-static DiaObject *custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename);
-static DiaObject *custom_polyline_load   (ObjectNode obj_node, int version, const char *filename);
-static DiaObject *custom_bezierline_load (ObjectNode obj_node, int version, const char *filename);
+static DiaObject *custom_zigzagline_load (ObjectNode obj_node, int version, DiaContext *ctx);
+static DiaObject *custom_polyline_load   (ObjectNode obj_node, int version, DiaContext *ctx);
+static DiaObject *custom_bezierline_load (ObjectNode obj_node, int version, DiaContext *ctx);
 
 static void customline_save (DiaObject *object, ObjectNode obj_node, const char *filename);
 
@@ -101,7 +101,7 @@ ensure_standard_types (void)
 }
 
 static DiaObject *
-_custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename, DiaObjectType *delegate)
+_custom_zigzagline_load (ObjectNode obj_node, int version, DiaContext *ctx, DiaObjectType *delegate)
 {
   DiaObject *obj;
   DiaObjectType *ot;
@@ -115,40 +115,40 @@ _custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename,
   if (typestr)
     xmlFree(typestr);
 
-  obj = delegate->ops->load (obj_node, version, filename);
+  obj = delegate->ops->load (obj_node, version, ctx);
   obj->type = line_info->object_type;
 
   return obj;
 }
 static DiaObject *
-custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename)
+custom_zigzagline_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   ensure_standard_types ();
   if (!zigzag_ot) {
     g_warning ("Can't delegate to 'Standard - ZigZagLine'");
     return NULL;
   }
-  return _custom_zigzagline_load(obj_node, version, filename, zigzag_ot);
+  return _custom_zigzagline_load(obj_node, version, ctx, zigzag_ot);
 }
 static DiaObject *
-custom_polyline_load (ObjectNode obj_node, int version, const char *filename)
+custom_polyline_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   ensure_standard_types ();
   if (!polyline_ot) {
     g_warning ("Can't delegate to 'Standard - PolyLine'");
     return NULL;
   }
-  return _custom_zigzagline_load(obj_node, version, filename, polyline_ot);
+  return _custom_zigzagline_load(obj_node, version, ctx, polyline_ot);
 }
 static DiaObject *
-custom_bezierline_load (ObjectNode obj_node, int version, const char *filename)
+custom_bezierline_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   ensure_standard_types ();
   if (!bezier_ot) {
     g_warning ("Can't delegate to 'Standard - BezierLine'");
     return NULL;
   }
-  return _custom_zigzagline_load(obj_node, version, filename, bezier_ot);
+  return _custom_zigzagline_load(obj_node, version, ctx, bezier_ot);
 }
 
 static void 
diff --git a/objects/flowchart/box.c b/objects/flowchart/box.c
index 339e1c0..21f2726 100644
--- a/objects/flowchart/box.c
+++ b/objects/flowchart/box.c
@@ -35,8 +35,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "pixmaps/box.xpm"
@@ -102,7 +100,7 @@ static void box_get_props(Box *box, GPtrArray *props);
 static void box_set_props(Box *box, GPtrArray *props);
 
 static void box_save(Box *box, ObjectNode obj_node, const char *filename);
-static DiaObject *box_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *box_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps box_type_ops =
 {
@@ -718,7 +716,7 @@ box_save(Box *box, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-box_load(ObjectNode obj_node, int version, const char *filename)
+box_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Box *box;
   Element *elem;
@@ -733,52 +731,51 @@ box_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &fc_box_type;
   obj->ops = &box_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
 
   box->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    box->border_width =  data_real( attribute_first_data(attr) );
+    box->border_width =  data_real(attribute_first_data(attr), ctx);
   box->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &box->border_color);
+    data_color(attribute_first_data(attr), &box->border_color, ctx);
   
   box->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &box->inner_color);
+    data_color(attribute_first_data(attr), &box->inner_color, ctx);
   
   box->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    box->show_background = data_boolean( attribute_first_data(attr) );
+    box->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   box->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    box->line_style =  data_enum( attribute_first_data(attr) );
+    box->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   box->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    box->dashlength = data_real(attribute_first_data(attr));
+    box->dashlength = data_real(attribute_first_data(attr), ctx);
 
   box->corner_radius = 0.0;
   attr = object_find_attribute(obj_node, "corner_radius");
   if (attr != NULL)
-    box->corner_radius =  data_real( attribute_first_data(attr) );
+    box->corner_radius =  data_real(attribute_first_data(attr), ctx);
 
   box->padding = default_properties.padding;
   attr = object_find_attribute(obj_node, "padding");
   if (attr != NULL)
-    box->padding =  data_real( attribute_first_data(attr) );
-  
+    box->padding =  data_real(attribute_first_data(attr), ctx);
 
   box->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    box->text = data_text(attribute_first_data(attr));
+    box->text = data_text(attribute_first_data(attr), ctx);
   else /* paranoid */
     box->text = new_text_default(&obj->position, &box->border_color, ALIGN_CENTER);
   text_get_attributes(box->text,&box->attrs);
@@ -787,7 +784,7 @@ box_load(ObjectNode obj_node, int version, const char *filename)
   box->text_fitting = TEXTFIT_WHEN_NEEDED;
   attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
   if (attr != NULL)
-    box->text_fitting = data_enum(attribute_first_data(attr));
+    box->text_fitting = data_enum(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
diff --git a/objects/flowchart/diamond.c b/objects/flowchart/diamond.c
index de86e17..cb117d3 100644
--- a/objects/flowchart/diamond.c
+++ b/objects/flowchart/diamond.c
@@ -35,8 +35,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "pixmaps/diamond.xpm"
@@ -103,7 +101,7 @@ static void diamond_get_props(Diamond *diamond, GPtrArray *props);
 static void diamond_set_props(Diamond *diamond, GPtrArray *props);
 
 static void diamond_save(Diamond *diamond, ObjectNode obj_node, const char *filename);
-static DiaObject *diamond_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *diamond_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps diamond_type_ops =
 {
@@ -604,7 +602,7 @@ diamond_save(Diamond *diamond, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-diamond_load(ObjectNode obj_node, int version, const char *filename)
+diamond_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Diamond *diamond;
   Element *elem;
@@ -619,47 +617,47 @@ diamond_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &diamond_type;
   obj->ops = &diamond_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   diamond->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    diamond->border_width =  data_real( attribute_first_data(attr) );
+    diamond->border_width =  data_real(attribute_first_data(attr), ctx);
 
   diamond->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &diamond->border_color);
-  
+    data_color(attribute_first_data(attr), &diamond->border_color, ctx);
+
   diamond->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &diamond->inner_color);
+    data_color(attribute_first_data(attr), &diamond->inner_color, ctx);
   
   diamond->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    diamond->show_background = data_boolean( attribute_first_data(attr) );
+    diamond->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   diamond->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    diamond->line_style =  data_enum( attribute_first_data(attr) );
+    diamond->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   diamond->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    diamond->dashlength = data_real(attribute_first_data(attr));
+    diamond->dashlength = data_real(attribute_first_data(attr), ctx);
 
   diamond->padding = default_properties.padding;
   attr = object_find_attribute(obj_node, "padding");
   if (attr != NULL)
-    diamond->padding =  data_real( attribute_first_data(attr) );
+    diamond->padding =  data_real(attribute_first_data(attr), ctx);
   
   diamond->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    diamond->text = data_text(attribute_first_data(attr));
+    diamond->text = data_text(attribute_first_data(attr), ctx);
   else /* paranoid */
     diamond->text = new_text_default(&obj->position, &diamond->border_color, ALIGN_CENTER);
   text_get_attributes(diamond->text, &diamond->attrs);
@@ -668,7 +666,7 @@ diamond_load(ObjectNode obj_node, int version, const char *filename)
   diamond->text_fitting = TEXTFIT_WHEN_NEEDED;
   attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
   if (attr != NULL)
-    diamond->text_fitting = data_enum(attribute_first_data(attr));
+    diamond->text_fitting = data_enum(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
diff --git a/objects/flowchart/ellipse.c b/objects/flowchart/ellipse.c
index 8d0fc3a..3644795 100644
--- a/objects/flowchart/ellipse.c
+++ b/objects/flowchart/ellipse.c
@@ -35,8 +35,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "pixmaps/ellipse.xpm"
@@ -102,7 +100,7 @@ static void ellipse_get_props(Ellipse *ellipse, GPtrArray *props);
 static void ellipse_set_props(Ellipse *ellipse, GPtrArray *props);
 
 static void ellipse_save(Ellipse *ellipse, ObjectNode obj_node, const char *filename);
-static DiaObject *ellipse_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *ellipse_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps ellipse_type_ops =
 {
@@ -579,7 +577,7 @@ ellipse_save(Ellipse *ellipse, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-ellipse_load(ObjectNode obj_node, int version, const char *filename)
+ellipse_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Ellipse *ellipse;
   Element *elem;
@@ -594,47 +592,47 @@ ellipse_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &fc_ellipse_type;
   obj->ops = &ellipse_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   ellipse->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    ellipse->border_width =  data_real( attribute_first_data(attr) );
+    ellipse->border_width =  data_real(attribute_first_data(attr), ctx);
 
   ellipse->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &ellipse->border_color);
+    data_color(attribute_first_data(attr), &ellipse->border_color, ctx);
   
   ellipse->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &ellipse->inner_color);
+    data_color(attribute_first_data(attr), &ellipse->inner_color, ctx);
   
   ellipse->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    ellipse->show_background = data_boolean( attribute_first_data(attr) );
+    ellipse->show_background = data_boolean( attribute_first_data(attr), ctx);
 
   ellipse->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    ellipse->line_style =  data_enum( attribute_first_data(attr) );
+    ellipse->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   ellipse->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    ellipse->dashlength = data_real(attribute_first_data(attr));
+    ellipse->dashlength = data_real(attribute_first_data(attr), ctx);
 
   ellipse->padding = default_properties.padding;
   attr = object_find_attribute(obj_node, "padding");
   if (attr != NULL)
-    ellipse->padding =  data_real( attribute_first_data(attr) );
+    ellipse->padding =  data_real(attribute_first_data(attr), ctx);
   
   ellipse->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    ellipse->text = data_text(attribute_first_data(attr));
+    ellipse->text = data_text(attribute_first_data(attr), ctx);
   else
     ellipse->text = new_text_default(&obj->position, &ellipse->border_color, ALIGN_CENTER);
   text_get_attributes(ellipse->text, &ellipse->attrs);
@@ -642,7 +640,7 @@ ellipse_load(ObjectNode obj_node, int version, const char *filename)
   ellipse->text_fitting = TEXTFIT_WHEN_NEEDED;
   attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
   if (attr != NULL)
-    ellipse->text_fitting = data_enum(attribute_first_data(attr));
+    ellipse->text_fitting = data_enum(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
diff --git a/objects/flowchart/parallelogram.c b/objects/flowchart/parallelogram.c
index 5ef62db..e69b63f 100644
--- a/objects/flowchart/parallelogram.c
+++ b/objects/flowchart/parallelogram.c
@@ -35,8 +35,6 @@
 #include "diarenderer.h"
 #include "attributes.h"
 #include "text.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "pixmaps/pgram.xpm"
@@ -104,7 +102,7 @@ static void pgram_get_props(Pgram *pgram, GPtrArray *props);
 static void pgram_set_props(Pgram *pgram, GPtrArray *props);
 
 static void pgram_save(Pgram *pgram, ObjectNode obj_node, const char *filename);
-static DiaObject *pgram_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *pgram_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps pgram_type_ops =
 {
@@ -662,7 +660,7 @@ pgram_save(Pgram *pgram, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-pgram_load(ObjectNode obj_node, int version, const char *filename)
+pgram_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Pgram *pgram;
   Element *elem;
@@ -677,53 +675,53 @@ pgram_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &pgram_type;
   obj->ops = &pgram_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   pgram->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    pgram->border_width =  data_real( attribute_first_data(attr) );
+    pgram->border_width =  data_real(attribute_first_data(attr), ctx);
 
   pgram->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &pgram->border_color);
+    data_color(attribute_first_data(attr), &pgram->border_color, ctx);
   
   pgram->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &pgram->inner_color);
+    data_color(attribute_first_data(attr), &pgram->inner_color, ctx);
   
   pgram->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    pgram->show_background = data_boolean( attribute_first_data(attr) );
+    pgram->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   pgram->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    pgram->line_style =  data_enum( attribute_first_data(attr) );
+    pgram->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   pgram->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    pgram->dashlength = data_real(attribute_first_data(attr));
+    pgram->dashlength = data_real(attribute_first_data(attr), ctx);
 
   pgram->shear_angle = 0.0;
   attr = object_find_attribute(obj_node, "shear_angle");
   if (attr != NULL)
-    pgram->shear_angle =  data_real( attribute_first_data(attr) );
+    pgram->shear_angle =  data_real(attribute_first_data(attr), ctx);
   pgram->shear_grad = tan(M_PI/2.0 - M_PI/180.0 * pgram->shear_angle);
 
   pgram->padding = default_properties.padding;
   attr = object_find_attribute(obj_node, "padding");
   if (attr != NULL)
-    pgram->padding =  data_real( attribute_first_data(attr) );
+    pgram->padding =  data_real(attribute_first_data(attr), ctx);
   
   pgram->text = NULL;
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL)
-    pgram->text = data_text(attribute_first_data(attr));
+    pgram->text = data_text(attribute_first_data(attr), ctx);
   else /* paranoid */
     pgram->text = new_text_default(&obj->position, &pgram->border_color, ALIGN_CENTER);
   text_get_attributes(pgram->text, &pgram->attrs);
@@ -732,7 +730,7 @@ pgram_load(ObjectNode obj_node, int version, const char *filename)
   pgram->text_fitting = TEXTFIT_WHEN_NEEDED;
   attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
   if (attr != NULL)
-    pgram->text_fitting = data_enum(attribute_first_data(attr));
+    pgram->text_fitting = data_enum(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
diff --git a/objects/network/basestation.c b/objects/network/basestation.c
index 401658c..97f0847 100644
--- a/objects/network/basestation.c
+++ b/objects/network/basestation.c
@@ -77,9 +77,7 @@ static DiaObject *basestation_create(Point *startpoint,
                                   Handle **handle1,
                                   Handle **handle2);
 static void basestation_destroy(Basestation *basestation);
-static DiaObject *basestation_load(ObjectNode obj_node,
-                                int version,
-                                const char *filename);
+static DiaObject *basestation_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static PropDescription
     *basestation_describe_props(Basestation *basestation);
 static void basestation_get_props(Basestation *basestation,
@@ -439,8 +437,8 @@ basestation_destroy(Basestation *basestation)
 }
 
 static DiaObject *
-basestation_load(ObjectNode obj_node, int version, const char *filename)
+basestation_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&basestation_type,
-                                      obj_node, version, filename);
+                                      obj_node, version,ctx);
 }
diff --git a/objects/network/bus.c b/objects/network/bus.c
index 7648e3d..2a7cc60 100644
--- a/objects/network/bus.c
+++ b/objects/network/bus.c
@@ -87,8 +87,7 @@ static PropDescription *bus_describe_props(Bus *bus);
 static void bus_get_props(Bus *bus, GPtrArray *props);
 static void bus_set_props(Bus *bus, GPtrArray *props);
 static void bus_save(Bus *bus, ObjectNode obj_node, const char *filename);
-static DiaObject *bus_load(ObjectNode obj_node, int version,
-			const char *filename);
+static DiaObject *bus_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *bus_get_object_menu(Bus *bus, Point *clickedpoint);
 
 static ObjectChange *
@@ -641,7 +640,7 @@ bus_save(Bus *bus, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-bus_load(ObjectNode obj_node, int version, const char *filename)
+bus_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Bus *bus;
   Connection *conn;
@@ -660,7 +659,7 @@ bus_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &bus_type;
   obj->ops = &bus_ops;
 
-  connection_load(conn, obj_node);
+  connection_load(conn, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "bus_handles");
 
@@ -679,7 +678,7 @@ bus_load(ObjectNode obj_node, int version, const char *filename)
     bus->handles[i]->type = HANDLE_MINOR_CONTROL;
     bus->handles[i]->connect_type = HANDLE_CONNECTABLE_NOBREAK;
     bus->handles[i]->connected_to = NULL;
-    data_point(data, &bus->handles[i]->pos);
+    data_point(data, &bus->handles[i]->pos, ctx);
     obj->handles[2+i] = bus->handles[i];
 
     data = data_next(data);
@@ -688,7 +687,7 @@ bus_load(ObjectNode obj_node, int version, const char *filename)
   bus->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &bus->line_color);
+    data_color(attribute_first_data(attr), &bus->line_color, ctx);
 
   extra->start_trans = 
     extra->end_trans = 
diff --git a/objects/network/radiocell.c b/objects/network/radiocell.c
index 1523493..2f9e248 100644
--- a/objects/network/radiocell.c
+++ b/objects/network/radiocell.c
@@ -77,8 +77,7 @@ static void radiocell_update_data(RadioCell *radiocell);
 static PropDescription *radiocell_describe_props(RadioCell *radiocell);
 static void radiocell_get_props(RadioCell *radiocell, GPtrArray *props);
 static void radiocell_set_props(RadioCell *radiocell, GPtrArray *props);
-static DiaObject *radiocell_load(ObjectNode obj_node, int version,
-			      const char *filename);
+static DiaObject *radiocell_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps radiocell_type_ops =
 {
@@ -371,8 +370,8 @@ radiocell_destroy(RadioCell *radiocell)
 }
 
 static DiaObject *
-radiocell_load(ObjectNode obj_node, int version, const char *filename)
+radiocell_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&radiocell_type,
-                                      obj_node, version, filename);
+                                      obj_node, version,ctx);
 }
diff --git a/objects/network/wanlink.c b/objects/network/wanlink.c
index e968b3b..91825e6 100644
--- a/objects/network/wanlink.c
+++ b/objects/network/wanlink.c
@@ -72,8 +72,7 @@ static void wanlink_get_props(WanLink *wanlink, GPtrArray *props);
 static void wanlink_set_props(WanLink *wanlink, GPtrArray *props);
 static void wanlink_save(WanLink *wanlink, ObjectNode obj_node,
 			 const char *filename);
-static DiaObject *wanlink_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *wanlink_load(ObjectNode obj_node, int version,DiaContext *ctx);
 static void wanlink_update_data(WanLink *wanlink);
 
 static ObjectTypeOps wanlink_type_ops =
@@ -322,7 +321,7 @@ wanlink_save(WanLink *wanlink, ObjectNode obj_node,
 }
 
 static DiaObject *
-wanlink_load(ObjectNode obj_node, int version, const char *filename)
+wanlink_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
     WanLink *wanlink;
     Connection *conn;
@@ -338,25 +337,25 @@ wanlink_load(ObjectNode obj_node, int version, const char *filename)
     obj->type = &wanlink_type;
     obj->ops = &wanlink_ops;
 
-    connection_load(conn, obj_node);
+    connection_load(conn, obj_node, ctx);
     connection_init(conn, 2, 0);
     
     attr = object_find_attribute(obj_node, "width");
     if (attr != NULL) {
 	data = attribute_first_data(attr);
-	wanlink->width = data_real( data);
+	wanlink->width = data_real(data, ctx);
     }
 
     wanlink->line_color = color_black;
     attr = object_find_attribute(obj_node, "line_color");
     if (attr != NULL)
-        data_color(attribute_first_data(attr), &wanlink->line_color);
+      data_color(attribute_first_data(attr), &wanlink->line_color, ctx);
     /* both colors where black at the time this was hardcoded ... */
     wanlink->fill_color = color_black;
     attr = object_find_attribute(obj_node, "fill_color");
     if (attr != NULL)
-        data_color(attribute_first_data(attr), &wanlink->fill_color);
-    
+      data_color(attribute_first_data(attr), &wanlink->fill_color, ctx);
+
     wanlink_update_data (wanlink);
     
     return obj;
diff --git a/objects/standard/arc.c b/objects/standard/arc.c
index dfc11f3..b220f86 100644
--- a/objects/standard/arc.c
+++ b/objects/standard/arc.c
@@ -28,7 +28,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "arrows.h"
 #include "properties.h"
 
@@ -88,7 +87,7 @@ static void arc_get_props(Arc *arc, GPtrArray *props);
 static void arc_set_props(Arc *arc, GPtrArray *props);
 
 static void arc_save(Arc *arc, ObjectNode obj_node, const char *filename);
-static DiaObject *arc_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *arc_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static int arc_compute_midpoint(Arc *arc, const Point * ep0, const Point * ep1 , Point * midpoint);
 static void calculate_arc_object_edge(Arc *arc, real ang_start, real ang_end, DiaObject *obj, Point *target, gboolean clockwiseness);
 static void arc_get_point_at_angle(Arc *arc, Point* point, real angle);
@@ -957,7 +956,7 @@ arc_save(Arc *arc, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-arc_load(ObjectNode obj_node, int version, const char *filename)
+arc_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   Arc *arc;
   Connection *conn;
@@ -972,43 +971,43 @@ arc_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &arc_type;
   obj->ops = &arc_ops;
 
-  connection_load(conn, obj_node);
+  connection_load(conn, obj_node, ctx);
 
   arc->arc_color = color_black;
   attr = object_find_attribute(obj_node, "arc_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &arc->arc_color);
+    data_color(attribute_first_data(attr), &arc->arc_color, ctx);
 
   arc->curve_distance = 0.1;
   attr = object_find_attribute(obj_node, "curve_distance");
   if (attr != NULL)
-    arc->curve_distance = data_real(attribute_first_data(attr));
+    arc->curve_distance = data_real(attribute_first_data(attr), ctx);
 
   arc->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    arc->line_width = data_real(attribute_first_data(attr));
+    arc->line_width = data_real(attribute_first_data(attr), ctx);
 
   arc->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    arc->line_style = data_enum(attribute_first_data(attr));
+    arc->line_style = data_enum(attribute_first_data(attr), ctx);
 
   arc->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    arc->dashlength = data_real(attribute_first_data(attr));
+    arc->dashlength = data_real(attribute_first_data(attr), ctx);
 
   arc->line_caps = LINECAPS_BUTT;
   attr = object_find_attribute(obj_node, "line_caps");
   if (attr != NULL)
-    arc->line_caps = data_enum(attribute_first_data(attr));
+    arc->line_caps = data_enum(attribute_first_data(attr), ctx);
 
   load_arrow(obj_node, &arc->start_arrow, "start_arrow",
-	     "start_arrow_length", "start_arrow_width");
+	     "start_arrow_length", "start_arrow_width", ctx);
 
   load_arrow(obj_node, &arc->end_arrow, "end_arrow",
-	     "end_arrow_length", "end_arrow_width");
+	     "end_arrow_length", "end_arrow_width", ctx);
 
   connection_init(conn, 4, 0);
 
diff --git a/objects/standard/bezier.c b/objects/standard/bezier.c
index 33487b4..bbcd3ee 100644
--- a/objects/standard/bezier.c
+++ b/objects/standard/bezier.c
@@ -32,9 +32,7 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "diamenu.h"
-#include "message.h"
 #include "properties.h"
 #include "create.h"
 
@@ -80,8 +78,7 @@ static void bezierline_set_props(Bezierline *bezierline, GPtrArray *props);
 
 static void bezierline_save(Bezierline *bezierline, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *bezierline_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *bezierline_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *bezierline_get_object_menu(Bezierline *bezierline, Point *clickedpoint);
 
 static void compute_gap_points(Bezierline *bezierline, Point *gap_points);
@@ -637,7 +634,7 @@ bezierline_save(Bezierline *bezierline, ObjectNode obj_node,
 }
 
 static DiaObject *
-bezierline_load(ObjectNode obj_node, int version, const char *filename)
+bezierline_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Bezierline *bezierline;
   BezierConn *bez;
@@ -652,52 +649,52 @@ bezierline_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &bezierline_type;
   obj->ops = &bezierline_ops;
 
-  bezierconn_load(bez, obj_node);
+  bezierconn_load(bez, obj_node, ctx);
 
   bezierline->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &bezierline->line_color);
+    data_color(attribute_first_data(attr), &bezierline->line_color, ctx);
 
   bezierline->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    bezierline->line_width = data_real(attribute_first_data(attr));
+    bezierline->line_width = data_real(attribute_first_data(attr), ctx);
 
   bezierline->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    bezierline->line_style = data_enum(attribute_first_data(attr));
+    bezierline->line_style = data_enum(attribute_first_data(attr), ctx);
 
   bezierline->line_join = LINEJOIN_MITER;
   attr = object_find_attribute(obj_node, "line_join");
   if (attr != NULL)
-    bezierline->line_join = data_enum(attribute_first_data(attr));
+    bezierline->line_join = data_enum(attribute_first_data(attr), ctx);
 
   bezierline->line_caps = LINECAPS_BUTT;
   attr = object_find_attribute(obj_node, "line_caps");
   if (attr != NULL)
-    bezierline->line_caps = data_enum(attribute_first_data(attr));
+    bezierline->line_caps = data_enum(attribute_first_data(attr), ctx);
 
   bezierline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    bezierline->dashlength = data_real(attribute_first_data(attr));
+    bezierline->dashlength = data_real(attribute_first_data(attr), ctx);
 
   load_arrow(obj_node, &bezierline->start_arrow, "start_arrow",
-	     "start_arrow_length", "start_arrow_width");
+	     "start_arrow_length", "start_arrow_width", ctx);
 
   load_arrow(obj_node, &bezierline->end_arrow, "end_arrow",
-	     "end_arrow_length", "end_arrow_width");
+	     "end_arrow_length", "end_arrow_width", ctx);
 
   bezierline->absolute_start_gap = 0.0;
   attr = object_find_attribute(obj_node, "absolute_start_gap");
   if (attr != NULL)
-    bezierline->absolute_start_gap =  data_real( attribute_first_data(attr) );
+    bezierline->absolute_start_gap =  data_real(attribute_first_data(attr), ctx);
   bezierline->absolute_end_gap = 0.0;
   attr = object_find_attribute(obj_node, "absolute_end_gap");
   if (attr != NULL)
-    bezierline->absolute_end_gap =  data_real( attribute_first_data(attr) );
+    bezierline->absolute_end_gap =  data_real(attribute_first_data(attr), ctx);
   
   /* if "screws up the bounding box if auto_gap" it must be fixed there
    * not by copying some meaningless bounding_box before this function call!
diff --git a/objects/standard/beziergon.c b/objects/standard/beziergon.c
index 9c4916c..48c7e79 100644
--- a/objects/standard/beziergon.c
+++ b/objects/standard/beziergon.c
@@ -32,9 +32,7 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "diamenu.h"
-#include "message.h"
 #include "properties.h"
 #include "create.h"
 
@@ -82,8 +80,7 @@ static void beziergon_set_props(Beziergon *beziergon, GPtrArray *props);
 
 static void beziergon_save(Beziergon *beziergon, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *beziergon_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *beziergon_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *beziergon_get_object_menu(Beziergon *beziergon,
 					  Point *clickedpoint);
 
@@ -403,7 +400,7 @@ beziergon_save(Beziergon *beziergon, ObjectNode obj_node,
 }
 
 static DiaObject *
-beziergon_load(ObjectNode obj_node, int version, const char *filename)
+beziergon_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Beziergon *beziergon;
   BezierShape *bezier;
@@ -418,42 +415,42 @@ beziergon_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &beziergon_type;
   obj->ops = &beziergon_ops;
 
-  beziershape_load(bezier, obj_node);
+  beziershape_load(bezier, obj_node, ctx);
 
   beziergon->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &beziergon->line_color);
+    data_color(attribute_first_data(attr), &beziergon->line_color, ctx);
 
   beziergon->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    beziergon->line_width = data_real(attribute_first_data(attr));
+    beziergon->line_width = data_real(attribute_first_data(attr), ctx);
 
   beziergon->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &beziergon->inner_color);
+    data_color(attribute_first_data(attr), &beziergon->inner_color, ctx);
   
   beziergon->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    beziergon->show_background = data_boolean( attribute_first_data(attr) );
+    beziergon->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   beziergon->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    beziergon->line_style = data_enum(attribute_first_data(attr));
+    beziergon->line_style = data_enum(attribute_first_data(attr), ctx);
 
   beziergon->line_join = LINEJOIN_MITER;
   attr = object_find_attribute(obj_node, "line_join");
   if (attr != NULL)
-    beziergon->line_join = data_enum(attribute_first_data(attr));
+    beziergon->line_join = data_enum(attribute_first_data(attr), ctx);
 
   beziergon->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    beziergon->dashlength = data_real(attribute_first_data(attr));
+    beziergon->dashlength = data_real(attribute_first_data(attr), ctx);
 
   beziergon_update_data(beziergon);
 
diff --git a/objects/standard/box.c b/objects/standard/box.c
index 88e5f35..26260f8 100644
--- a/objects/standard/box.c
+++ b/objects/standard/box.c
@@ -29,8 +29,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "tool-icons.h"
@@ -92,7 +90,7 @@ static void box_get_props(Box *box, GPtrArray *props);
 static void box_set_props(Box *box, GPtrArray *props);
 
 static void box_save(Box *box, ObjectNode obj_node, const char *filename);
-static DiaObject *box_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *box_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *box_get_object_menu(Box *box, Point *clickedpoint);
 
 static ObjectTypeOps box_type_ops =
@@ -551,7 +549,7 @@ box_save(Box *box, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-box_load(ObjectNode obj_node, int version, const char *filename)
+box_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Box *box;
   Element *elem;
@@ -566,47 +564,47 @@ box_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &box_type;
   obj->ops = &box_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   box->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    box->border_width =  data_real( attribute_first_data(attr) );
+    box->border_width =  data_real(attribute_first_data(attr), ctx);
 
   box->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &box->border_color);
+    data_color(attribute_first_data(attr), &box->border_color, ctx);
   
   box->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &box->inner_color);
+    data_color(attribute_first_data(attr), &box->inner_color, ctx);
   
   box->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    box->show_background = data_boolean( attribute_first_data(attr) );
+    box->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   box->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    box->line_style =  data_enum( attribute_first_data(attr) );
+    box->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   box->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    box->dashlength = data_real(attribute_first_data(attr));
+    box->dashlength = data_real(attribute_first_data(attr), ctx);
 
   box->corner_radius = 0.0;
   attr = object_find_attribute(obj_node, "corner_radius");
   if (attr != NULL)
-    box->corner_radius =  data_real( attribute_first_data(attr) );
+    box->corner_radius =  data_real(attribute_first_data(attr), ctx);
 
   box->aspect = FREE_ASPECT;
   attr = object_find_attribute(obj_node, "aspect");
   if (attr != NULL)
-    box->aspect = data_enum(attribute_first_data(attr));
+    box->aspect = data_enum(attribute_first_data(attr), ctx);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 
diff --git a/objects/standard/ellipse.c b/objects/standard/ellipse.c
index 4abd98a..7c768d6 100644
--- a/objects/standard/ellipse.c
+++ b/objects/standard/ellipse.c
@@ -29,8 +29,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 
 #include "tool-icons.h"
@@ -88,7 +86,7 @@ static void ellipse_get_props(Ellipse *ellipse, GPtrArray *props);
 static void ellipse_set_props(Ellipse *ellipse, GPtrArray *props);
 
 static void ellipse_save(Ellipse *ellipse, ObjectNode obj_node, const char *filename);
-static DiaObject *ellipse_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *ellipse_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *ellipse_get_object_menu(Ellipse *ellipse, Point *clickedpoint);
 
 static ObjectTypeOps ellipse_type_ops =
@@ -529,7 +527,7 @@ ellipse_save(Ellipse *ellipse, ObjectNode obj_node, const char *filename)
   }
 }
 
-static DiaObject *ellipse_load(ObjectNode obj_node, int version, const char *filename)
+static DiaObject *ellipse_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Ellipse *ellipse;
   Element *elem;
@@ -544,42 +542,42 @@ static DiaObject *ellipse_load(ObjectNode obj_node, int version, const char *fil
   obj->type = &ellipse_type;
   obj->ops = &ellipse_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
 
   ellipse->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    ellipse->border_width =  data_real( attribute_first_data(attr) );
+    ellipse->border_width =  data_real(attribute_first_data(attr), ctx);
 
   ellipse->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &ellipse->border_color);
+    data_color(attribute_first_data(attr), &ellipse->border_color, ctx);
   
   ellipse->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &ellipse->inner_color);
+    data_color(attribute_first_data(attr), &ellipse->inner_color, ctx);
   
   ellipse->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    ellipse->show_background = data_boolean(attribute_first_data(attr));
+    ellipse->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   ellipse->aspect = FREE_ASPECT;
   attr = object_find_attribute(obj_node, "aspect");
   if (attr != NULL)
-    ellipse->aspect = data_enum(attribute_first_data(attr));
+    ellipse->aspect = data_enum(attribute_first_data(attr), ctx);
 
   ellipse->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    ellipse->line_style =  data_enum( attribute_first_data(attr) );
+    ellipse->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   ellipse->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-	  ellipse->dashlength = data_real(attribute_first_data(attr));
+    ellipse->dashlength = data_real(attribute_first_data(attr), ctx);
 
   element_init(elem, 9, 9);
 
diff --git a/objects/standard/image.c b/objects/standard/image.c
index 66fe7f5..efb4a21 100644
--- a/objects/standard/image.c
+++ b/objects/standard/image.c
@@ -34,7 +34,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "dia_image.h"
 #include "message.h"
 #include "properties.h"
@@ -98,7 +97,7 @@ static void image_get_props(Image *image, GPtrArray *props);
 static void image_set_props(Image *image, GPtrArray *props);
 
 static void image_save(Image *image, ObjectNode obj_node, const char *filename);
-static DiaObject *image_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *image_load(ObjectNode obj_node, int version, DiaContext *ctx);
 
 static ObjectTypeOps image_type_ops =
 {
@@ -675,7 +674,7 @@ image_save(Image *image, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-image_load(ObjectNode obj_node, int version, const char *filename)
+image_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Image *image;
   Element *elem;
@@ -691,41 +690,41 @@ image_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &image_type;
   obj->ops = &image_ops;
 
-  element_load(elem, obj_node);
+  element_load(elem, obj_node, ctx);
   
   image->border_width = 0.1;
   attr = object_find_attribute(obj_node, "border_width");
   if (attr != NULL)
-    image->border_width =  data_real( attribute_first_data(attr) );
+    image->border_width =  data_real(attribute_first_data(attr), ctx);
 
   image->border_color = color_black;
   attr = object_find_attribute(obj_node, "border_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &image->border_color);
+    data_color(attribute_first_data(attr), &image->border_color, ctx);
   
   image->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    image->line_style =  data_enum( attribute_first_data(attr) );
+    image->line_style =  data_enum(attribute_first_data(attr), ctx);
 
   image->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    image->dashlength = data_real(attribute_first_data(attr));
+    image->dashlength = data_real(attribute_first_data(attr), ctx);
 
   image->draw_border = TRUE;
   attr = object_find_attribute(obj_node, "draw_border");
   if (attr != NULL)
-    image->draw_border =  data_boolean( attribute_first_data(attr) );
+    image->draw_border =  data_boolean(attribute_first_data(attr), ctx);
 
   image->keep_aspect = TRUE;
   attr = object_find_attribute(obj_node, "keep_aspect");
   if (attr != NULL)
-    image->keep_aspect =  data_boolean( attribute_first_data(attr) );
+    image->keep_aspect =  data_boolean(attribute_first_data(attr), ctx);
 
   attr = object_find_attribute(obj_node, "file");
   if (attr != NULL) {
-    image->file =  data_filename( attribute_first_data(attr) );
+    image->file =  data_filename(attribute_first_data(attr), ctx);
   } else {
     image->file = g_strdup("");
   }
@@ -742,7 +741,7 @@ image_load(ObjectNode obj_node, int version, const char *filename)
   image->image = NULL;
   
   if (strcmp(image->file, "")!=0) {
-    diafile_dir = get_directory(filename);
+    diafile_dir = get_directory(dia_context_get_filename(ctx));
 
     if (g_path_is_absolute(image->file)) { /* Absolute pathname */
       image->image = dia_image_load(image->file);
diff --git a/objects/standard/line.c b/objects/standard/line.c
index 0409eae..d3ab543 100644
--- a/objects/standard/line.c
+++ b/objects/standard/line.c
@@ -30,7 +30,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "arrows.h"
 #include "connpoint_line.h"
 #include "properties.h"
@@ -83,7 +82,7 @@ static void line_get_props(Line *line, GPtrArray *props);
 static void line_set_props(Line *line, GPtrArray *props);
 
 static void line_save(Line *line, ObjectNode obj_node, const char *filename);
-static DiaObject *line_load(ObjectNode obj_node, int version, const char *filename);
+static DiaObject *line_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *line_get_object_menu(Line *line, Point *clickedpoint);
 
 void Line_adjust_for_absolute_gap(Line *line, Point *gap_endpoints);
@@ -573,7 +572,7 @@ line_save(Line *line, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-line_load(ObjectNode obj_node, int version, const char *filename)
+line_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Line *line;
   Connection *conn;
@@ -588,51 +587,51 @@ line_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &line_type;
   obj->ops = &line_ops;
 
-  connection_load(conn, obj_node);
+  connection_load(conn, obj_node, ctx);
 
   line->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &line->line_color);
+    data_color(attribute_first_data(attr), &line->line_color, ctx);
 
   line->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    line->line_width = data_real(attribute_first_data(attr));
+    line->line_width = data_real(attribute_first_data(attr), ctx);
 
   line->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    line->line_style = data_enum(attribute_first_data(attr));
+    line->line_style = data_enum(attribute_first_data(attr), ctx);
 
   line->line_caps = LINECAPS_BUTT;
   attr = object_find_attribute(obj_node, "line_caps");
   if (attr != NULL)
-    line->line_caps = data_enum(attribute_first_data(attr));
+    line->line_caps = data_enum(attribute_first_data(attr), ctx);
 
   load_arrow(obj_node, &line->start_arrow, 
-	     "start_arrow", "start_arrow_length", "start_arrow_width");
+	     "start_arrow", "start_arrow_length", "start_arrow_width", ctx);
 
   load_arrow(obj_node, &line->end_arrow, 
-	     "end_arrow", "end_arrow_length", "end_arrow_width");
+	     "end_arrow", "end_arrow_length", "end_arrow_width", ctx);
 
   line->absolute_start_gap = 0.0;
   attr = object_find_attribute(obj_node, "absolute_start_gap");
   if (attr != NULL)
-    line->absolute_start_gap =  data_real( attribute_first_data(attr) );
+    line->absolute_start_gap =  data_real(attribute_first_data(attr), ctx);
   line->absolute_end_gap = 0.0;
   attr = object_find_attribute(obj_node, "absolute_end_gap");
   if (attr != NULL)
-    line->absolute_end_gap =  data_real( attribute_first_data(attr) );
+    line->absolute_end_gap =  data_real(attribute_first_data(attr), ctx);
 
   line->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    line->dashlength = data_real(attribute_first_data(attr));
+    line->dashlength = data_real(attribute_first_data(attr), ctx);
 
   connection_init(conn, 2, 0);
 
-  line->cpl = connpointline_load(obj,obj_node,"numcp",1,NULL);
+  line->cpl = connpointline_load(obj,obj_node,"numcp",1,NULL, ctx);
   line_update_data(line);
 
   return &line->connection.object;
diff --git a/objects/standard/outline.c b/objects/standard/outline.c
index 4ba3e9f..ee354bc 100644
--- a/objects/standard/outline.c
+++ b/objects/standard/outline.c
@@ -76,7 +76,7 @@ static DiaObject *outline_create (Point *startpoint,
 				  Handle **handle1,
 				  Handle **handle2);
 static DiaObject *
-outline_load(ObjectNode obj_node, int version, const char *filename);
+outline_load(ObjectNode obj_node, int version,DiaContext *ctx);
 
 static ObjectTypeOps outline_type_ops =
 {
@@ -190,10 +190,10 @@ outline_create (Point *startpoint,
   return obj;
 }
 static DiaObject *
-outline_load(ObjectNode obj_node, int version, const char *filename)
+outline_load(ObjectNode obj_node, int version,DiaContext *ctx)
 {
   return object_load_using_properties(&outline_type,
-                                      obj_node,version,filename);
+                                      obj_node,version,ctx);
 }
 
 /* Class/Object implementation */
diff --git a/objects/standard/polygon.c b/objects/standard/polygon.c
index 193f4d4..80ef88b 100644
--- a/objects/standard/polygon.c
+++ b/objects/standard/polygon.c
@@ -29,9 +29,7 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "diamenu.h"
-#include "message.h"
 #include "properties.h"
 
 #include "tool-icons.h"
@@ -86,8 +84,7 @@ static void polygon_set_props(Polygon *polygon, GPtrArray *props);
 
 static void polygon_save(Polygon *polygon, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *polygon_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *polygon_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *polygon_get_object_menu(Polygon *polygon, Point *clickedpoint);
 
 static ObjectTypeOps polygon_type_ops =
@@ -377,7 +374,7 @@ polygon_save(Polygon *polygon, ObjectNode obj_node,
 }
 
 static DiaObject *
-polygon_load(ObjectNode obj_node, int version, const char *filename)
+polygon_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Polygon *polygon;
   PolyShape *poly;
@@ -392,42 +389,42 @@ polygon_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &polygon_type;
   obj->ops = &polygon_ops;
 
-  polyshape_load(poly, obj_node);
+  polyshape_load(poly, obj_node, ctx);
 
   polygon->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &polygon->line_color);
+    data_color(attribute_first_data(attr), &polygon->line_color, ctx);
 
   polygon->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    polygon->line_width = data_real(attribute_first_data(attr));
+    polygon->line_width = data_real(attribute_first_data(attr), ctx);
 
   polygon->inner_color = color_white;
   attr = object_find_attribute(obj_node, "inner_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &polygon->inner_color);
+    data_color(attribute_first_data(attr), &polygon->inner_color, ctx);
   
   polygon->show_background = TRUE;
   attr = object_find_attribute(obj_node, "show_background");
   if (attr != NULL)
-    polygon->show_background = data_boolean( attribute_first_data(attr) );
+    polygon->show_background = data_boolean(attribute_first_data(attr), ctx);
 
   polygon->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    polygon->line_style = data_enum(attribute_first_data(attr));
+    polygon->line_style = data_enum(attribute_first_data(attr), ctx);
 
   polygon->line_join = LINEJOIN_MITER;
   attr = object_find_attribute(obj_node, "line_join");
   if (attr != NULL)
-    polygon->line_join = data_enum(attribute_first_data(attr));
+    polygon->line_join = data_enum(attribute_first_data(attr), ctx);
 
   polygon->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    polygon->dashlength = data_real(attribute_first_data(attr));
+    polygon->dashlength = data_real(attribute_first_data(attr), ctx);
 
   polygon_update_data(polygon);
 
diff --git a/objects/standard/polyline.c b/objects/standard/polyline.c
index bd5a5af..dc477e2 100644
--- a/objects/standard/polyline.c
+++ b/objects/standard/polyline.c
@@ -29,9 +29,7 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "diamenu.h"
-#include "message.h"
 #include "properties.h"
 
 #include "create.h"
@@ -77,8 +75,7 @@ static void polyline_set_props(Polyline *polyline, GPtrArray *props);
 
 static void polyline_save(Polyline *polyline, ObjectNode obj_node,
 			  const char *filename);
-static DiaObject *polyline_load(ObjectNode obj_node, int version,
-			     const char *filename);
+static DiaObject *polyline_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static DiaMenu *polyline_get_object_menu(Polyline *polyline, Point *clickedpoint);
 void polyline_calculate_gap_endpoints(Polyline *polyline, Point *gap_endpoints);
 static void polyline_exchange_gap_points(Polyline *polyline,  Point *gap_points);
@@ -528,7 +525,7 @@ polyline_save(Polyline *polyline, ObjectNode obj_node,
 }
 
 static DiaObject *
-polyline_load(ObjectNode obj_node, int version, const char *filename)
+polyline_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Polyline *polyline;
   PolyConn *poly;
@@ -543,58 +540,57 @@ polyline_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &polyline_type;
   obj->ops = &polyline_ops;
 
-  polyconn_load(poly, obj_node);
+  polyconn_load(poly, obj_node, ctx);
 
   polyline->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &polyline->line_color);
+    data_color(attribute_first_data(attr), &polyline->line_color, ctx);
 
   polyline->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    polyline->line_width = data_real(attribute_first_data(attr));
+    polyline->line_width = data_real(attribute_first_data(attr), ctx);
 
   polyline->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    polyline->line_style = data_enum(attribute_first_data(attr));
+    polyline->line_style = data_enum(attribute_first_data(attr), ctx);
 
   polyline->line_join = LINEJOIN_MITER;
   attr = object_find_attribute(obj_node, "line_join");
   if (attr != NULL)
-    polyline->line_join = data_enum(attribute_first_data(attr));
+    polyline->line_join = data_enum(attribute_first_data(attr), ctx);
 
   polyline->line_caps = LINECAPS_BUTT;
   attr = object_find_attribute(obj_node, "line_caps");
   if (attr != NULL)
-    polyline->line_caps = data_enum(attribute_first_data(attr));
+    polyline->line_caps = data_enum(attribute_first_data(attr), ctx);
 
   polyline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    polyline->dashlength = data_real(attribute_first_data(attr));
+    polyline->dashlength = data_real(attribute_first_data(attr), ctx);
 
   load_arrow(obj_node, &polyline->start_arrow, "start_arrow",
-	     "start_arrow_length", "start_arrow_width");
+	     "start_arrow_length", "start_arrow_width", ctx);
 
   load_arrow(obj_node, &polyline->end_arrow, "end_arrow",
-	     "end_arrow_length", "end_arrow_width");
+	     "end_arrow_length", "end_arrow_width", ctx);
 
   polyline->absolute_start_gap = 0.0;
   attr = object_find_attribute(obj_node, "absolute_start_gap");
   if (attr != NULL)
-    polyline->absolute_start_gap =  data_real( attribute_first_data(attr) );
+    polyline->absolute_start_gap =  data_real(attribute_first_data(attr), ctx);
   polyline->absolute_end_gap = 0.0;
   attr = object_find_attribute(obj_node, "absolute_end_gap");
   if (attr != NULL)
-    polyline->absolute_end_gap =  data_real( attribute_first_data(attr) );
-
+    polyline->absolute_end_gap =  data_real(attribute_first_data(attr), ctx);
 
   polyline->corner_radius = 0.0;
   attr = object_find_attribute(obj_node, "corner_radius");
   if (attr != NULL)
-    polyline->corner_radius =  data_real( attribute_first_data(attr) );
+    polyline->corner_radius =  data_real(attribute_first_data(attr), ctx);
 
   polyline_update_data(polyline);
 
diff --git a/objects/standard/textobj.c b/objects/standard/textobj.c
index cd65f5c..be191f1 100644
--- a/objects/standard/textobj.c
+++ b/objects/standard/textobj.c
@@ -30,7 +30,6 @@
 #include "font.h"
 #include "text.h"
 #include "attributes.h"
-#include "widgets.h"
 #include "properties.h"
 
 #include "tool-icons.h"
@@ -85,8 +84,7 @@ static void textobj_set_props(Textobj *textobj, GPtrArray *props);
 
 static void textobj_save(Textobj *textobj, ObjectNode obj_node,
 			 const char *filename);
-static DiaObject *textobj_load(ObjectNode obj_node, int version,
-			    const char *filename);
+static DiaObject *textobj_load(ObjectNode obj_node, int version, DiaContext *ctx);
 static void textobj_valign_point(Textobj *textobj, Point* p, real factor);
 
 static ObjectTypeOps textobj_type_ops =
@@ -368,7 +366,7 @@ textobj_save(Textobj *textobj, ObjectNode obj_node, const char *filename)
 }
 
 static DiaObject *
-textobj_load(ObjectNode obj_node, int version, const char *filename)
+textobj_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Textobj *textobj;
   DiaObject *obj;
@@ -381,11 +379,11 @@ textobj_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &textobj_type;
   obj->ops = &textobj_ops;
 
-  object_load(obj, obj_node);
+  object_load(obj, obj_node, ctx);
 
   attr = object_find_attribute(obj_node, "text");
   if (attr != NULL) {
-    textobj->text = data_text( attribute_first_data(attr) );
+    textobj->text = data_text(attribute_first_data(attr), ctx);
   } else {
     DiaFont* font = dia_font_new_from_style(DIA_FONT_MONOSPACE,1.0);
     textobj->text = new_text("", font, 1.0,
@@ -397,7 +395,7 @@ textobj_load(ObjectNode obj_node, int version, const char *filename)
 
   attr = object_find_attribute(obj_node, "valign");
   if (attr != NULL)
-    textobj->vert_align = data_enum( attribute_first_data(attr) );
+    textobj->vert_align = data_enum(attribute_first_data(attr), ctx);
   else if (version == 0) {
     textobj->vert_align = VALIGN_FIRST_LINE;
   }
@@ -406,10 +404,10 @@ textobj_load(ObjectNode obj_node, int version, const char *filename)
   textobj->fill_color = attributes_get_background();
   attr = object_find_attribute(obj_node, "fill_color");
   if (attr)
-    data_color(attribute_first_data(attr), &textobj->fill_color);
+    data_color(attribute_first_data(attr), &textobj->fill_color, ctx);
   attr = object_find_attribute(obj_node, "show_background");
   if (attr)
-    textobj->show_background = data_boolean( attribute_first_data(attr) );
+    textobj->show_background = data_boolean(attribute_first_data(attr), ctx);
   else
     textobj->show_background = FALSE;
 
diff --git a/objects/standard/zigzagline.c b/objects/standard/zigzagline.c
index 9ee9f9e..4aaa946 100644
--- a/objects/standard/zigzagline.c
+++ b/objects/standard/zigzagline.c
@@ -29,8 +29,6 @@
 #include "connectionpoint.h"
 #include "diarenderer.h"
 #include "attributes.h"
-#include "widgets.h"
-#include "message.h"
 #include "properties.h"
 #include "autoroute.h"
 
@@ -78,8 +76,7 @@ static void zigzagline_set_props(Zigzagline *zigzagline, GPtrArray *props);
 
 static void zigzagline_save(Zigzagline *zigzagline, ObjectNode obj_node,
 			    const char *filename);
-static DiaObject *zigzagline_load(ObjectNode obj_node, int version,
-			       const char *filename);
+static DiaObject *zigzagline_load(ObjectNode obj_node, int version, DiaContext *ctx);
 
 static ObjectTypeOps zigzagline_type_ops =
 {
@@ -455,7 +452,7 @@ zigzagline_save(Zigzagline *zigzagline, ObjectNode obj_node,
 }
 
 static DiaObject *
-zigzagline_load(ObjectNode obj_node, int version, const char *filename)
+zigzagline_load(ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Zigzagline *zigzagline;
   OrthConn *orth;
@@ -470,48 +467,48 @@ zigzagline_load(ObjectNode obj_node, int version, const char *filename)
   obj->type = &zigzagline_type;
   obj->ops = &zigzagline_ops;
 
-  orthconn_load(orth, obj_node);
+  orthconn_load(orth, obj_node, ctx);
 
   zigzagline->line_color = color_black;
   attr = object_find_attribute(obj_node, "line_color");
   if (attr != NULL)
-    data_color(attribute_first_data(attr), &zigzagline->line_color);
+    data_color(attribute_first_data(attr), &zigzagline->line_color, ctx);
 
   zigzagline->line_width = 0.1;
   attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
   if (attr != NULL)
-    zigzagline->line_width = data_real(attribute_first_data(attr));
+    zigzagline->line_width = data_real(attribute_first_data(attr), ctx);
 
   zigzagline->line_style = LINESTYLE_SOLID;
   attr = object_find_attribute(obj_node, "line_style");
   if (attr != NULL)
-    zigzagline->line_style = data_enum(attribute_first_data(attr));
+    zigzagline->line_style = data_enum(attribute_first_data(attr), ctx);
 
   zigzagline->line_join = LINEJOIN_MITER;
   attr = object_find_attribute(obj_node, "line_join");
   if (attr != NULL)
-    zigzagline->line_join = data_enum(attribute_first_data(attr));
+    zigzagline->line_join = data_enum(attribute_first_data(attr), ctx);
 
   zigzagline->line_caps = LINECAPS_BUTT;
   attr = object_find_attribute(obj_node, "line_caps");
   if (attr != NULL)
-    zigzagline->line_caps = data_enum(attribute_first_data(attr));
+    zigzagline->line_caps = data_enum(attribute_first_data(attr), ctx);
 
   load_arrow(obj_node, &zigzagline->start_arrow, "start_arrow",
-	     "start_arrow_length", "start_arrow_width");
+	     "start_arrow_length", "start_arrow_width", ctx);
 
   load_arrow(obj_node, &zigzagline->end_arrow, "end_arrow",
-	     "end_arrow_length", "end_arrow_width");
+	     "end_arrow_length", "end_arrow_width", ctx);
 
   zigzagline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
   attr = object_find_attribute(obj_node, "dashlength");
   if (attr != NULL)
-    zigzagline->dashlength = data_real(attribute_first_data(attr));
+    zigzagline->dashlength = data_real(attribute_first_data(attr), ctx);
 
   zigzagline->corner_radius = 0.0;
   attr = object_find_attribute(obj_node, "corner_radius");
   if (attr != NULL)
-    zigzagline->corner_radius =  data_real( attribute_first_data(attr) );
+    zigzagline->corner_radius = data_real(attribute_first_data(attr), ctx);
 
   zigzagline_update_data(zigzagline);
 
diff --git a/plug-ins/drs/dia-render-script-import.c b/plug-ins/drs/dia-render-script-import.c
index 76993ab..3c21160 100644
--- a/plug-ins/drs/dia-render-script-import.c
+++ b/plug-ins/drs/dia-render-script-import.c
@@ -159,7 +159,7 @@ find_child_named (xmlNodePtr node, const char *name)
  * Can be called recusively to allow groups in groups.
  */
 static GList*
-read_items (xmlNodePtr startnode)
+read_items (xmlNodePtr startnode, DiaContext *ctx)
 {
   xmlNodePtr node;
   GList *items = NULL;
@@ -180,7 +180,7 @@ read_items (xmlNodePtr startnode)
       if (ot && !ot->ops) {
 	GList *moreitems;
         /* FIXME: 'render' is also the grouping element */
-	moreitems = read_items (render->children);
+	moreitems = read_items (render->children, ctx);
 	if (moreitems) {
 	  DiaObject *group = group_create (moreitems);
 	    /* group eats list */
@@ -195,7 +195,7 @@ read_items (xmlNodePtr startnode)
                             ot->default_user_data, 
 			    &handle1,&handle2);
 	if (o) {
-	  object_load_props (o, props);
+	  object_load_props (o, props, ctx);
 	  items = g_list_append (items, o);
 	}
       } else {
@@ -210,7 +210,7 @@ read_items (xmlNodePtr startnode)
 
 /* imports the given DRS file, returns TRUE if successful */
 gboolean
-import_drs (const gchar *filename, DiagramData *dia, void* user_data) 
+import_drs (const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data) 
 {
   GList *item, *items;
   xmlDocPtr doc = xmlParseFile(filename);
@@ -222,7 +222,7 @@ import_drs (const gchar *filename, DiagramData *dia, void* user_data)
       root = node;
 
   if (!root || !(root = find_child_named (root, "diagram"))) {
-    message_warning (_("Broken file?"));
+    dia_context_add_message (ctx, _("Broken file?"));
     return FALSE;
   }
 
@@ -241,7 +241,7 @@ import_drs (const gchar *filename, DiagramData *dia, void* user_data)
 	xmlFree (str);
       }
 
-      items = read_items (node->children);
+      items = read_items (node->children, ctx);
       for (item = items; item != NULL; item = g_list_next (item)) {
         DiaObject *obj = (DiaObject *)item->data;
         layer_add_object(layer, obj);
diff --git a/plug-ins/drs/dia-render-script.h b/plug-ins/drs/dia-render-script.h
index f594832..823c27b 100644
--- a/plug-ins/drs/dia-render-script.h
+++ b/plug-ins/drs/dia-render-script.h
@@ -19,4 +19,4 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-gboolean import_drs (const gchar *filename, DiagramData *dia, void* user_data);
+gboolean import_drs (const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data);
diff --git a/plug-ins/dxf/dxf-import.c b/plug-ins/dxf/dxf-import.c
index fd9c498..84de5b2 100644
--- a/plug-ins/dxf/dxf-import.c
+++ b/plug-ins/dxf/dxf-import.c
@@ -71,7 +71,7 @@ typedef struct _DxfData
     char value[DXF_LINE_LENGTH];
 } DxfData;
 
-static gboolean import_dxf(const gchar *filename, DiagramData *dia, void* user_data);
+static gboolean import_dxf(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data);
 static gboolean read_dxf_codes(FILE *filedxf, DxfData *data);
 static DiaObject *read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia);
 static DiaObject *read_entity_circle_dxf(FILE *filedxf, DxfData *data, DiagramData *dia);
@@ -1280,15 +1280,15 @@ read_section_blocks_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 
 /* imports the given dxf-file, returns TRUE if successful */
 static gboolean
-import_dxf(const gchar *filename, DiagramData *dia, void* user_data)
+import_dxf(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data)
 {
     FILE *filedxf;
     DxfData *data;
     
     filedxf = g_fopen(filename,"r");
     if(filedxf == NULL){
-        message_error(_("Couldn't open: '%s' for reading.\n"), 
-		      dia_message_filename(filename));
+        dia_context_add_message(ctx, _("Couldn't open: '%s' for reading.\n"),
+				dia_context_get_filename (ctx));
         return FALSE;
     }
     
@@ -1297,15 +1297,15 @@ import_dxf(const gchar *filename, DiagramData *dia, void* user_data)
     do {
         if(read_dxf_codes(filedxf, data) == FALSE) {
             g_free(data);
-	    message_error(_("read_dxf_codes failed on '%s'\n"),
-			  dia_message_filename(filename) );
+	    dia_context_add_message(ctx, _("read_dxf_codes failed on '%s'"),
+			            dia_context_get_filename(ctx) );
             return FALSE;
         }
         else {
             if (0 == data->code && strstr(data->codeline, "AutoCAD Binary DXF")) {
                 g_free(data);
-	        message_error(_("Binary DXF from '%s' not supported\n"),
-			      dia_message_filename(filename) );
+	        dia_context_add_message(ctx, _("Binary DXF from '%s' not supported"),
+			                dia_context_get_filename(ctx));
                 return FALSE;
             }
 	    if (0 == data->code) {
diff --git a/plug-ins/pixbuf/pixbuf.c b/plug-ins/pixbuf/pixbuf.c
index c6052c8..fa50a9c 100644
--- a/plug-ins/pixbuf/pixbuf.c
+++ b/plug-ins/pixbuf/pixbuf.c
@@ -100,7 +100,7 @@ export_data(DiagramData *data, const gchar *filename,
 }
 
 static gboolean
-import_data (const gchar *filename, DiagramData *data, void* user_data)
+import_data (const gchar *filename, DiagramData *data, DiaContext *ctx, void* user_data)
 {
   DiaObjectType *otype = object_get_type("Standard - Image");
   gint width, height;
@@ -108,7 +108,10 @@ import_data (const gchar *filename, DiagramData *data, void* user_data)
   if (!otype) /* this would be really broken */
     return FALSE;
 
-  g_assert (user_data);
+  if (!user_data) {
+    dia_context_add_message(ctx, _("Calling error, missing user_data."));
+    return FALSE;
+  }
 
   if (gdk_pixbuf_get_file_info (filename, &width, &height))
     {
@@ -142,7 +145,8 @@ import_data (const gchar *filename, DiagramData *data, void* user_data)
     }
   else
     {
-      message_warning ("Pixbuf[%s] can't load:\n%s", (gchar*)user_data, filename);
+      dia_context_add_message(ctx, _("Pixbuf[%s] can't load:\n%s"), 
+			      (gchar*)user_data, dia_context_get_filename(ctx));
     }
 
   return FALSE;
diff --git a/plug-ins/python/diamodule.c b/plug-ins/python/diamodule.c
index f03c6c6..21ab03a 100644
--- a/plug-ins/python/diamodule.c
+++ b/plug-ins/python/diamodule.c
@@ -268,14 +268,14 @@ PyDia_RegisterExport(PyObject *self, PyObject *args)
  * dia.register_import
  */
 static gboolean
-PyDia_import_data (const gchar* filename, DiagramData *dia, void *user_data)
+PyDia_import_data (const gchar* filename, DiagramData *dia, DiaContext *ctx, void *user_data)
 {
     PyObject *diaobj, *arg, *func = user_data;
     char* old_locale;
     gboolean bRet = FALSE;
 
     if (!func || !PyCallable_Check (func)) {
-        message_error ("Import called without valid callback function.");
+        dia_context_add_message (ctx, "Import called without valid callback function.");
         return FALSE;
     }
     if (dia)
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index cb8d8b6..2201dac 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -50,7 +50,7 @@
 #include "font.h"
 #include "attributes.h"
 
-gboolean import_svg(const gchar *filename, DiagramData *dia, void* user_data);
+gboolean import_svg(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data);
 static GList *read_ellipse_svg(xmlNodePtr node, DiaSvgStyle *parent_style, GList *list);
 static GList *read_rect_svg(xmlNodePtr node, DiaSvgStyle *parent_style, GList *list);
 static GList *read_line_svg(xmlNodePtr node, DiaSvgStyle *parent_style, GList *list);
@@ -1112,7 +1112,7 @@ read_items (xmlNodePtr   startnode,
 
 /* imports the given SVG file, returns TRUE if successful */
 gboolean
-import_svg(const gchar *filename, DiagramData *dia, void* user_data) 
+import_svg(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data) 
 {
   xmlDocPtr doc = xmlDoParseFile(filename);
   xmlNsPtr svg_ns;
@@ -1120,8 +1120,8 @@ import_svg(const gchar *filename, DiagramData *dia, void* user_data)
   GList *items, *item;
 
   if (!doc) {
-    message_warning("parse error for %s", 
-		    dia_message_filename(filename));
+    dia_context_add_message(ctx, _("Parse error for %s"), 
+		            dia_context_get_filename (ctx));
     return FALSE;
   }
   /* skip (emacs) comments */
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index 0c75b17..167fc06 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -55,8 +55,6 @@
 #include "bezier_conn.h"
 #include "connection.h"
 
-gboolean import_vdx(const gchar *filename, DiagramData *dia, void* user_data);
-
 void static vdx_get_colors(xmlNodePtr cur, VDXDocument* theDoc);
 void static vdx_get_facenames(xmlNodePtr cur, VDXDocument* theDoc);
 void static vdx_get_fonts(xmlNodePtr cur, VDXDocument* theDoc);
@@ -2854,9 +2852,8 @@ vdx_free(VDXDocument *theDoc)
  * @param user_data unused
  * @returns TRUE if successful, FALSE otherwise
  */
-
-gboolean
-import_vdx(const gchar *filename, DiagramData *dia, void* user_data)
+static gboolean
+import_vdx(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data)
 {
     xmlDocPtr doc = xmlDoParseFile(filename);
     xmlNodePtr root, cur;
@@ -2868,8 +2865,8 @@ import_vdx(const gchar *filename, DiagramData *dia, void* user_data)
     char* old_locale;
 
     if (!doc) {
-        message_warning("parse error for %s",
-                        dia_message_filename(filename));
+        dia_context_add_message(ctx, "Parse error for %s",
+                                dia_context_get_filename(ctx));
         return FALSE;
     }
     /* skip comments */
@@ -2879,12 +2876,12 @@ import_vdx(const gchar *filename, DiagramData *dia, void* user_data)
     }
     if (!root || xmlIsBlankNode(root))
     {
-        g_warning("Nothing in document!");
+        dia_context_add_message(ctx, _("Nothing in document!"));
         return FALSE;
     }
     if (strcmp((char *)root->name, "VisioDocument"))
     {
-        g_warning("%s not VisioDocument", root->name);
+        dia_context_add_message(ctx, _("Expecting VisioDocument, got %s"), root->name);
         return FALSE;
     }
     if (root->ns && root->ns->href &&
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index 9ea56b3..a95b971 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -352,7 +352,7 @@ set_linecaps(DiaRenderer *self, LineCaps mode)
   case LINECAPS_PROJECTING:
     break;
   default:
-    message_error("WpgRenderer : Unsupported fill mode specified!\n");
+    g_warning("WpgRenderer : Unsupported fill mode specified!\n");
   }
 }
 
@@ -369,7 +369,7 @@ set_linejoin(DiaRenderer *self, LineJoin mode)
   case LINEJOIN_BEVEL:
     break;
   default:
-    message_error("WpgRenderer : Unsupported fill mode specified!\n");
+    g_warning("WpgRenderer : Unsupported fill mode specified!\n");
   }
 }
 
@@ -401,7 +401,7 @@ set_linestyle(DiaRenderer *self, LineStyle mode)
     renderer->LineAttr.Type = WPG_LA_DOTS;
     break;
   default:
-    message_error("WpgRenderer : Unsupported fill mode specified!\n");
+    g_warning("WpgRenderer : Unsupported fill mode specified!\n");
   }
 }
 
@@ -428,7 +428,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
     renderer->FillAttr.Type = WPG_FA_SOLID;
     break;
   default:
-    message_error("WpgRenderer : Unsupported fill mode specified!\n");
+    g_warning("WpgRenderer : Unsupported fill mode specified!\n");
   }
 }
 
@@ -1169,7 +1169,7 @@ import_object(DiaRenderer* self, DiagramData *dia,
 } 
 
 static gboolean
-import_data (const gchar *filename, DiagramData *dia, void* user_data)
+import_data (const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data)
 {
   FILE* f;
   gboolean bRet;
@@ -1178,8 +1178,7 @@ import_data (const gchar *filename, DiagramData *dia, void* user_data)
   f = g_fopen(filename, "rb");
 
   if (NULL == f) {
-    message_error(_("Couldn't open: '%s' for reading.\n"), 
-		  dia_message_filename(filename));
+    dia_context_add_message(ctx, _("Couldn't open: '%s' for reading.\n"), filename);
     bRet = FALSE;
   }
   
@@ -1191,8 +1190,7 @@ import_data (const gchar *filename, DiagramData *dia, void* user_data)
             && fhead.fid[2] == 'P' && fhead.fid[3] == 'C'
             && (1 == fhead.MajorVersion) && (0 == fhead.MinorVersion));
     if (!bRet)
-      message_error(_("File: %s type/version unsupported.\n"), 
-		    dia_message_filename(filename));
+      dia_context_add_message(ctx, _("File: %s type/version unsupported.\n"), filename);
   }
 
   if (bRet) {
diff --git a/plug-ins/xfig/xfig-import.c b/plug-ins/xfig/xfig-import.c
index fbeecc0..7ff145b 100644
--- a/plug-ins/xfig/xfig-import.c
+++ b/plug-ins/xfig/xfig-import.c
@@ -43,7 +43,6 @@
 #include <glib/gstdio.h>
 
 #include "intl.h"
-#include "message.h"
 #include "geometry.h"
 #include "filter.h"
 #include "object.h"
@@ -58,8 +57,6 @@
 
 static Color fig_colors[FIG_MAX_USER_COLORS];
 
-gboolean import_fig(const gchar *filename, DiagramData *dia, void* user_data);
-
 /** Eats the rest of the line.
  */
 static void
@@ -99,7 +96,7 @@ skip_comments(FILE *file) {
 }
 
 static Color
-fig_color(int color_index) 
+fig_color(int color_index, DiaContext *ctx)
 {
     if (color_index <= -1) 
         return color_black; /* Default color */
@@ -108,16 +105,18 @@ fig_color(int color_index)
     else if (color_index < FIG_MAX_USER_COLORS) 
 	return fig_colors[color_index-FIG_MAX_DEFAULT_COLORS];
     else {
-	message_error(_("Color index %d too high; only 512 colors allowed. Using black instead."),
-		      color_index);
+        dia_context_add_message(ctx, 
+	  _("Color index %d too high; only 512 colors allowed. Using black instead."),
+	  color_index);
 	return color_black;
     }
 }
 
 static Color
-fig_area_fill_color(int area_fill, int color_index) {
+fig_area_fill_color(int area_fill, int color_index, DiaContext *ctx)
+{
     Color col;
-    col = fig_color(color_index);
+    col = fig_color(color_index, ctx);
     if (area_fill == -1) return col;
     if (area_fill >= 0 && area_fill <= 20) {
 	if (color_index == -1 || color_index == 0) {
@@ -138,7 +137,7 @@ fig_area_fill_color(int area_fill, int color_index) {
 	col.blue += (0xff-col.blue)*(area_fill-20)/20;
 	col.alpha = 1.0;
     } else {
-	message_warning(_("Patterns are not supported by Dia"));
+	dia_context_add_message(ctx, _("Patterns are not supported by Dia"));
     }
     
     return col;
@@ -152,7 +151,7 @@ static PropDescription xfig_simple_prop_descs_line[] = {
     PROP_DESC_END};
 
 static LineStyle 
-fig_line_style_to_dia(int line_style) 
+fig_line_style_to_dia(int line_style, DiaContext *ctx) 
 {
     switch (line_style) {
     case 0:
@@ -166,11 +165,11 @@ fig_line_style_to_dia(int line_style)
     case 4:
         return LINESTYLE_DASH_DOT_DOT;
     case 5:
-        message_warning(_("Triple-dotted lines are not supported by Dia; "
-			  "using double-dotted"));
+	dia_context_add_message(ctx, _("Triple-dotted lines are not supported by Dia; "
+			               "using double-dotted"));
         return LINESTYLE_DASH_DOT_DOT;
     default:
-        message_error(_("Line style %d should not appear\n"), line_style);
+        dia_context_add_message(ctx, _("Line style %d should not appear"), line_style);
         return LINESTYLE_SOLID;
     }
 }
@@ -182,7 +181,9 @@ fig_simple_properties(DiaObject *obj,
 		      int thickness,
 		      int pen_color,
 		      int fill_color,
-		      int area_fill) {
+		      int area_fill,
+		      DiaContext *ctx)
+{
     GPtrArray *props = prop_list_from_descs(xfig_simple_prop_descs_line,
                                             pdtpp_true);
     RealProperty *rprop;
@@ -194,7 +195,7 @@ fig_simple_properties(DiaObject *obj,
     rprop->real_data = thickness/FIG_ALT_UNIT;
     
     cprop = g_ptr_array_index(props,1);
-    cprop->color_data = fig_color(pen_color);
+    cprop->color_data = fig_color(pen_color, ctx);
 
 
     if (line_style != -1) {
@@ -203,7 +204,7 @@ fig_simple_properties(DiaObject *obj,
                                                PROP_TYPE_LINESTYLE,
                                                PROP_FLAG_DONT_SAVE);
         lsprop->dash = dash_length/FIG_ALT_UNIT;
-        lsprop->style = fig_line_style_to_dia(line_style);
+        lsprop->style = fig_line_style_to_dia(line_style, ctx);
 
         g_ptr_array_add(props,lsprop);
     }
@@ -220,7 +221,7 @@ fig_simple_properties(DiaObject *obj,
             (ColorProperty *)make_new_prop("fill_colour",
                                            PROP_TYPE_COLOUR,
                                            PROP_FLAG_DONT_SAVE);
-        cprop->color_data = fig_area_fill_color(area_fill, fill_color);
+        cprop->color_data = fig_area_fill_color(area_fill, fill_color, ctx);
 
         g_ptr_array_add(props,cprop);
     }
@@ -230,7 +231,8 @@ fig_simple_properties(DiaObject *obj,
 }
 
 static int
-fig_read_n_points(FILE *file, int n, Point **points) {
+fig_read_n_points(FILE *file, int n, Point **points, DiaContext *ctx)
+{
     int i;
     GArray *points_list = g_array_sized_new(FALSE, FALSE, sizeof(Point), n);
 
@@ -238,8 +240,8 @@ fig_read_n_points(FILE *file, int n, Point **points) {
 	int x,y;
 	Point p;
 	if (fscanf(file, " %d %d ", &x, &y) != 2) {
-	    message_error(_("Error while reading %dth of %d points: %s\n"),
-			  i, n, strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error while reading %dth of %d points"), i, n);
 	    g_array_free(points_list, TRUE);
 	    return FALSE;
 	}
@@ -255,7 +257,8 @@ fig_read_n_points(FILE *file, int n, Point **points) {
 }
 
 static Arrow *
-fig_read_arrow(FILE *file) {
+fig_read_arrow(FILE *file, DiaContext *ctx)
+{
     int arrow_type, style;
     real thickness, width, height;
     Arrow *arrow;
@@ -266,7 +269,7 @@ fig_read_arrow(FILE *file) {
     if (fscanf(file, "%d %d %lf %lf %lf\n",
 	       &arrow_type, &style, &thickness,
 	       &width, &height) != 5) {
-	message_error(_("Error while reading arrowhead\n"));
+	dia_context_add_message(ctx, _("Error while reading arrowhead"));
 	setlocale(LC_NUMERIC,old_locale);
 	return NULL;
     }
@@ -288,7 +291,7 @@ fig_read_arrow(FILE *file) {
 	arrow->type = (style?ARROW_FILLED_DIAMOND:ARROW_HOLLOW_DIAMOND);
 	break;
     default:
-	message_error(_("Unknown arrow type %d\n"), arrow_type);
+	dia_context_add_message(ctx, _("Unknown arrow type %d\n"), arrow_type);
 	g_free(arrow);
 	return NULL;
     }
@@ -377,9 +380,10 @@ static int compound_depth;
  * @param depth A depth as in the Fig format, max 999
  */
 static void
-add_at_depth(DiaObject *newobj, int depth) {
+add_at_depth(DiaObject *newobj, int depth, DiaContext *ctx)
+{
     if (depth < 0 || depth >= FIG_MAX_DEPTHS) {
-	message_error(_("Depth %d of of range, only 0-%d allowed.\n"),
+	dia_context_add_message(ctx, _("Depth %d of of range, only 0-%d allowed.\n"),
 		      depth, FIG_MAX_DEPTHS-1);
 	depth = FIG_MAX_DEPTHS - 1;
     }
@@ -390,7 +394,8 @@ add_at_depth(DiaObject *newobj, int depth) {
 }
 
 static DiaObject *
-fig_read_ellipse(FILE *file) {
+fig_read_ellipse(FILE *file, DiaContext *ctx)
+{
     int sub_type;
     int line_style;
     int thickness;
@@ -426,7 +431,8 @@ fig_read_ellipse(FILE *file) {
 	       &radius_x, &radius_y,
 	       &start_x, &start_y,
 	       &end_x, &end_y) < 19) {
-	message_error(_("Couldn't read ellipse info: %s\n"), strerror(errno));
+	dia_context_set_errno(ctx, errno);
+	dia_context_add_message(ctx, _("Couldn't read ellipse info."));
 	setlocale(LC_NUMERIC, old_locale);
 	return NULL;
     }
@@ -440,7 +446,7 @@ fig_read_ellipse(FILE *file) {
 				     (2*radius_y)/FIG_UNIT);
     if (newobj == NULL) return NULL;
     fig_simple_properties(newobj, line_style, style_val, thickness,
-			  pen_color, fill_color, area_fill);
+			  pen_color, fill_color, area_fill, ctx);
 
     /* Pen style field (not used) */
     /* Style_val (size of dots and dashes) in 1/80 inch */
@@ -448,13 +454,14 @@ fig_read_ellipse(FILE *file) {
     /* Angle -- can't rotate yet */
 
     /* Depth field */
-    add_at_depth(newobj, depth);
+    add_at_depth(newobj, depth, ctx);
 
     return newobj;
 }
 
 static DiaObject *
-fig_read_polyline(FILE *file) {
+fig_read_polyline(FILE *file, DiaContext *ctx) 
+{
     int sub_type;
     int line_style;
     int thickness;
@@ -494,22 +501,24 @@ fig_read_polyline(FILE *file) {
 	       &forward_arrow,
 	       &backward_arrow,
 	       &npoints) != 15) {
-	message_error(_("Couldn't read polyline info: %s\n"), strerror(errno));
+	dia_context_set_errno(ctx, errno);
+	dia_context_add_message(ctx, _("Couldn't read polyline info.\n"));
 	goto exit;
     }
 
     if (forward_arrow == 1) {
-	forward_arrow_info = fig_read_arrow(file);
+	forward_arrow_info = fig_read_arrow(file, ctx);
     }
 
     if (backward_arrow == 1) {
-	backward_arrow_info = fig_read_arrow(file);
+	backward_arrow_info = fig_read_arrow(file, ctx);
     }
 
     if (sub_type == 5) { /* image has image name before npoints */
 	/* Despite what the specs say */
 	if (fscanf(file, " %d", &flipped) != 1) {
-	    message_error(_("Couldn't read flipped bit: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Couldn't read flipped bit."));
 	    goto exit;
 	}
 
@@ -517,7 +526,7 @@ fig_read_polyline(FILE *file) {
 
     }
 
-    if (!fig_read_n_points(file, npoints, &points)) {
+    if (!fig_read_n_points(file, npoints, &points, ctx)) {
 	goto exit;
     }
      
@@ -527,7 +536,7 @@ fig_read_polyline(FILE *file) {
 	    (RealProperty *)make_new_prop("corner_radius",
 					  PROP_TYPE_REAL,PROP_FLAG_DONT_SAVE);
 	if (radius < 0) {
-	    message_warning(_("Negative corner radius; negating"));
+	    dia_context_add_message(ctx, _("Negative corner radius; negating"));
 	    rprop->real_data = -radius/FIG_ALT_UNIT;
 	} else {
 	    rprop->real_data = radius/FIG_ALT_UNIT;
@@ -570,19 +579,19 @@ fig_read_polyline(FILE *file) {
 	if (newobj == NULL) goto exit;
 	break;
     default: 
-	message_error(_("Unknown polyline subtype: %d\n"), sub_type);
+	dia_context_add_message(ctx, _("Unknown polyline subtype: %d\n"), sub_type);
 	goto exit;
     }
 
     fig_simple_properties(newobj, line_style, style_val, thickness,
-			  pen_color, fill_color, area_fill);
+			  pen_color, fill_color, area_fill, ctx);
     /* Pen style field (not used) */
     /* Style_val (size of dots and dashes) in 1/80 inch*/
     /* Join style */
     /* Cap style */
      
     /* Depth field */
-    add_at_depth(newobj, depth);
+    add_at_depth(newobj, depth, ctx);
  exit:
     setlocale(LC_NUMERIC, old_locale);
     prop_list_free(props);
@@ -684,7 +693,8 @@ static real matrix_catmull_to_bezier[4][4] =
      {0,      0,   5,   5/6.0}};
 
 static DiaObject *
-fig_read_spline(FILE *file) {
+fig_read_spline(FILE *file, DiaContext *ctx)
+{
     int sub_type;
     int line_style;
     int thickness;
@@ -720,26 +730,27 @@ fig_read_spline(FILE *file) {
 	       &forward_arrow,
 	       &backward_arrow,
 	       &npoints) != 13) {
-	message_error(_("Couldn't read spline info: %s\n"), strerror(errno));
+	dia_context_set_errno(ctx, errno);
+	dia_context_add_message(ctx, _("Couldn't read spline info."));
 	goto exit;
     }
 
     if (forward_arrow == 1) {
-	forward_arrow_info = fig_read_arrow(file);
+	forward_arrow_info = fig_read_arrow(file, ctx);
     }
 
     if (backward_arrow == 1) {
-	backward_arrow_info = fig_read_arrow(file);
+	backward_arrow_info = fig_read_arrow(file, ctx);
     }
 
-    if (!fig_read_n_points(file, npoints, &points)) {
+    if (!fig_read_n_points(file, npoints, &points, ctx)) {
 	goto exit;
     }
      
     switch (sub_type) {
     case 0: /* Open approximated spline */
     case 1: /* Closed approximated spline */
-	message_warning(_("Cannot convert approximated spline yet."));
+	dia_context_add_message(ctx, _("Cannot convert approximated spline yet."));
 	goto exit;
     case 2: /* Open interpolated spline */
     case 3: /* Closed interpolated spline */
@@ -752,12 +763,12 @@ fig_read_spline(FILE *file) {
 	    gboolean interpolated = TRUE;
 	    for (i = 0; i < npoints; i++) {
 		if (fscanf(file, " %lf ", &f) != 1) {
-		    message_error(_("Couldn't read spline info: %s\n"),
-				  strerror(errno));
+		    dia_context_set_errno(ctx, errno);
+		    dia_context_add_message(ctx, _("Couldn't read spline info."));
 		    goto exit;
 		}
 		if (f != -1.0 && f != 0.0) {
-		    message_warning(_("Cannot convert approximated spline yet."));
+		    dia_context_add_message(ctx, _("Cannot convert approximated spline yet."));
 		    interpolated = FALSE;
 		}
 	    }
@@ -795,18 +806,18 @@ fig_read_spline(FILE *file) {
 	if (newobj == NULL) goto exit;
 	break;
     default: 
-	message_error(_("Unknown spline subtype: %d\n"), sub_type);
+	dia_context_add_message(ctx, _("Unknown spline subtype: %d\n"), sub_type);
 	goto exit;
     }
 
     fig_simple_properties(newobj, line_style, style_val, thickness,
-			  pen_color, fill_color, area_fill);
+			  pen_color, fill_color, area_fill, ctx);
     /* Pen style field (not used) */
     /* Style_val (size of dots and dashes) in 1/80 inch*/
     /* Cap style */
      
     /* Depth field */
-    add_at_depth(newobj, depth);
+    add_at_depth(newobj, depth, ctx);
  exit:
     setlocale(LC_NUMERIC, old_locale);
     prop_list_free(props);
@@ -817,7 +828,8 @@ fig_read_spline(FILE *file) {
 }
 
 static DiaObject *
-fig_read_arc(FILE *file) {
+fig_read_arc(FILE *file, DiaContext *ctx)
+{
     int sub_type;
     int line_style;
     int thickness;
@@ -860,16 +872,17 @@ fig_read_arc(FILE *file) {
 	       &x1, &y1,
 	       &x2, &y2,
 	       &x3, &y3) != 21) {
-	message_error(_("Couldn't read arc info: %s\n"), strerror(errno));
+	dia_context_set_errno(ctx, errno);
+	dia_context_add_message(ctx, _("Couldn't read arc info."));
 	goto exit;
     }
 
     if (forward_arrow == 1) {
-	forward_arrow_info = fig_read_arrow(file);
+	forward_arrow_info = fig_read_arrow(file, ctx);
     }
 
     if (backward_arrow == 1) {
-	backward_arrow_info = fig_read_arrow(file);
+	backward_arrow_info = fig_read_arrow(file, ctx);
     }
 
     radius = sqrt((x1-center_x)*(x1-center_x)+(y1-center_y)*(y1-center_y))/FIG_UNIT;
@@ -889,16 +902,16 @@ fig_read_arc(FILE *file) {
 	if (newobj == NULL) goto exit;
 	if (sub_type == 2) {
 		/* set new fill property on arc? */
-		message_warning (_("Filled arc treated as unfilled"));
+		dia_context_add_message(ctx, _("Filled arc treated as unfilled"));
 	}
 	break;
     default: 
-	message_error(_("Unknown polyline arc: %d\n"), sub_type);
+	dia_context_add_message(ctx, _("Unknown polyline arc: %d\n"), sub_type);
 	goto exit;
     }
 
     fig_simple_properties(newobj, line_style, style_val, thickness,
-			  pen_color, fill_color, area_fill);
+			  pen_color, fill_color, area_fill, ctx);
 
     /* Pen style field (not used) */
     /* Style_val (size of dots and dashes) in 1/80 inch*/
@@ -906,7 +919,7 @@ fig_read_arc(FILE *file) {
     /* Cap style */
      
     /* Depth field */
-    add_at_depth(newobj, depth);
+    add_at_depth(newobj, depth, ctx);
 
  exit:
     setlocale(LC_NUMERIC, old_locale);
@@ -924,7 +937,8 @@ static PropDescription xfig_text_descs[] = {
 };
 
 static DiaObject *
-fig_read_text(FILE *file) {
+fig_read_text(FILE *file, DiaContext *ctx)
+{
     GPtrArray *props = NULL;
     TextProperty *tprop;
 
@@ -957,7 +971,8 @@ fig_read_text(FILE *file) {
 	       &length,
 	       &x,
 	       &y) != 12) {
-	message_error(_("Couldn't read text info: %s\n"), strerror(errno));
+	dia_context_set_errno(ctx, errno);
+	dia_context_add_message(ctx, _("Couldn't read text info."));
 	setlocale(LC_NUMERIC, old_locale);
 	return NULL;
     }
@@ -984,7 +999,8 @@ fig_read_text(FILE *file) {
 	case 3: tprop->attr.font = dia_font_new_from_legacy_name("Times-Italic"); break;
 	case 4: tprop->attr.font = dia_font_new_from_legacy_name("Helvetica"); break;
 	case 5: tprop->attr.font = dia_font_new_from_legacy_name("Courier"); break;
-	default: message_warning("Can't find LaTeX font nr. %d, using sans\n", font);
+	default:
+	    dia_context_add_message(ctx, _("Can't find LaTeX font nr. %d, using sans"), font);
 	    tprop->attr.font = dia_font_new_from_legacy_name("Helvetica");
 	}
     } else {
@@ -992,18 +1008,19 @@ fig_read_text(FILE *file) {
 	    /* "Default font" - wazzat? */
 	    tprop->attr.font = dia_font_new_from_legacy_name("Times-Roman");
 	} else if (font < 0 || font >= num_fig_fonts()) {
-	    message_warning("Can't find Postscript font nr. %d, using sans\n", font);
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Can't find Postscript font nr. %d, using sans"), font);
 	    tprop->attr.font = dia_font_new_from_legacy_name("Helvetica");
 	} else {
 	    tprop->attr.font = dia_font_new_from_legacy_name(fig_fonts[font]);
 	}
     }
     tprop->attr.height = font_size*2.54/72.0;
-    tprop->attr.color = fig_color(color);
+    tprop->attr.color = fig_color(color, ctx);
     newobj->ops->set_props(newobj, props);
     
     /* Depth field */
-    add_at_depth(newobj, depth);
+    add_at_depth(newobj, depth, ctx);
 
  exit:
     setlocale(LC_NUMERIC, old_locale);
@@ -1013,13 +1030,15 @@ fig_read_text(FILE *file) {
 }
 
 static gboolean
-fig_read_object(FILE *file) {
+fig_read_object(FILE *file, DiaContext *ctx)
+{
     int objecttype;
     DiaObject *item = NULL;
 
     if (fscanf(file, "%d ", &objecttype) != 1) {
 	if (!feof(file)) {
-	    message_error(_("Couldn't identify Fig object: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Couldn't identify Fig object."));
 	}
 	return FALSE;
     }
@@ -1027,7 +1046,7 @@ fig_read_object(FILE *file) {
     switch (objecttype) {
     case -6: { /* End of compound */
 	if (compound_stack == NULL) {
-	    message_error(_("Compound end outside compound\n"));
+	    dia_context_add_message(ctx, _("Compound end outside compound\n"));
 	    return FALSE;
 	}
 
@@ -1046,12 +1065,13 @@ fig_read_object(FILE *file) {
 	Color color;
 
 	if (fscanf(file, " %d #%xd", &colornumber, &colorvalues) != 2) {
-	    message_error(_("Couldn't read color: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Couldn't read color: %s\n"));
 	    return FALSE;
 	}
 
 	if (colornumber < 32 || colornumber > FIG_MAX_USER_COLORS) {
-	    message_error(_("Color number %d out of range 0..%d.  Discarding color.\n"),
+	    dia_context_add_message(ctx, _("Color number %d out of range 0..%d.  Discarding color.\n"),
 			  colornumber, FIG_MAX_USER_COLORS);
 	    return FALSE;
 	}
@@ -1065,32 +1085,32 @@ fig_read_object(FILE *file) {
 	break;
     }
     case 1: { /* Ellipse which is a generalization of circle. */
-	item = fig_read_ellipse(file);
+	item = fig_read_ellipse(file, ctx);
 	if (item == NULL) {
 	    return FALSE;
 	}
 	break;
     }
     case 2: /* Polyline which includes polygon and box. */
-	item = fig_read_polyline(file);
+	item = fig_read_polyline(file, ctx);
 	if (item == NULL) {
 	    return FALSE;
 	}
 	break;
     case 3: /* Spline which includes closed/open control/interpolated spline. */
-	item = fig_read_spline(file);
+	item = fig_read_spline(file, ctx);
 	if (item == NULL) {
 	    return FALSE;
 	}
 	break;
     case 4: /* Text. */
-	item = fig_read_text(file);
+	item = fig_read_text(file, ctx);
 	if (item == NULL) {
 	    return FALSE;
 	}
 	break;
     case 5: /* Arc. */
-	item = fig_read_arc(file);
+	item = fig_read_arc(file, ctx);
 	if (item == NULL) {
 	    return FALSE;
 	}
@@ -1098,7 +1118,8 @@ fig_read_object(FILE *file) {
     case 6: {/* Compound object which is composed of one or more objects. */
 	int dummy;
 	if (fscanf(file, " %d %d %d %d\n", &dummy, &dummy, &dummy, &dummy) != 4) {
-	    message_error(_("Couldn't read group extend: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Couldn't read group extend."));
 	    return FALSE;
 	}
 	/* Group extends don't really matter */
@@ -1109,7 +1130,7 @@ fig_read_object(FILE *file) {
 	break;
     }
     default:
-	message_error(_("Unknown object type %d\n"), objecttype);
+	dia_context_add_message(ctx, _("Unknown object type %d\n"), objecttype);
 	return FALSE;
 	break;
     }
@@ -1122,7 +1143,8 @@ fig_read_object(FILE *file) {
 }
 
 static int
-fig_read_line_choice(FILE *file, char *choice1, char *choice2) {
+fig_read_line_choice(FILE *file, char *choice1, char *choice2, DiaContext *ctx)
+{
     char buf[BUFLEN];
 
     if (!fgets(buf, BUFLEN, file)) {
@@ -1133,17 +1155,18 @@ fig_read_line_choice(FILE *file, char *choice1, char *choice2) {
     g_strstrip(buf); /* And any other whitespace */
     if (!g_ascii_strcasecmp(buf, choice1)) return 0;
     if (!g_ascii_strcasecmp(buf, choice2)) return 1;
-    message_warning(_("`%s' is not one of `%s' or `%s'\n"), buf, choice1, choice2);
+    dia_context_add_message(ctx, _("`%s' is not one of `%s' or `%s'\n"), buf, choice1, choice2);
     return 0;
 }
 
 static int
-fig_read_paper_size(FILE *file, DiagramData *dia) {
+fig_read_paper_size(FILE *file, DiagramData *dia, DiaContext *ctx) {
     char buf[BUFLEN];
     int paper;
 
     if (!fgets(buf, BUFLEN, file)) {
-	message_error(_("Error reading paper size: %s\n"), strerror(errno));
+	dia_context_set_errno(ctx, errno);
+	dia_context_add_message(ctx, _("Error reading paper size."));
 	return FALSE;
     }
 
@@ -1154,19 +1177,21 @@ fig_read_paper_size(FILE *file, DiagramData *dia) {
 	return TRUE;
     }
 
-    message_warning(_("Unknown paper size `%s', using default\n"), buf);
+    dia_context_add_message(ctx, _("Unknown paper size `%s', using default\n"), buf);
     return TRUE;
 }
 
 int figversion;
 
 static int
-fig_read_meta_data(FILE *file, DiagramData *dia) {
+fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
+{
     if (figversion >= 300) { /* Might exist earlier */
 	int portrait;
 
-	if ((portrait = fig_read_line_choice(file, "Portrait", "Landscape")) == -1) {
-	    message_error(_("Error reading paper orientation: %s\n"), strerror(errno));
+	if ((portrait = fig_read_line_choice(file, "Portrait", "Landscape", ctx)) == -1) {
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading paper orientation."));
 	    return FALSE;
 	}
 	dia->paper.is_portrait = portrait;
@@ -1175,8 +1200,9 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
     if (figversion >= 300) { /* Might exist earlier */
 	int justify;
 
-	if ((justify = fig_read_line_choice(file, "Center", "Flush Left")) == -1) {
-	    message_error(_("Error reading justification: %s\n"), strerror(errno));
+	if ((justify = fig_read_line_choice(file, "Center", "Flush Left", ctx)) == -1) {
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading justification."));
 	    return FALSE;
 	}
 	/* Don't know what to do with this */
@@ -1185,15 +1211,16 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
     if (figversion >= 300) { /* Might exist earlier */
 	int units;
 
-	if ((units = fig_read_line_choice(file, "Metric", "Inches")) == -1) {
-	    message_error(_("Error reading units: %s\n"), strerror(errno));
+	if ((units = fig_read_line_choice(file, "Metric", "Inches", ctx)) == -1) {
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading units."));
 	    return FALSE;
 	}
 	/* Don't know what to do with this */
     }
 
     if (figversion >= 302) {
-	if (!fig_read_paper_size(file, dia)) return FALSE;
+	if (!fig_read_paper_size(file, dia, ctx)) return FALSE;
     }
 
     {
@@ -1202,7 +1229,8 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
 
 	old_locale = setlocale(LC_NUMERIC, "C");
 	if (fscanf(file, "%lf\n", &mag) != 1) {
-	    message_error(_("Error reading magnification: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading magnification."));
 	    setlocale(LC_NUMERIC, old_locale);
 	    return FALSE;
 	}
@@ -1214,8 +1242,9 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
     if (figversion >= 302) {
 	int multiple;
 
-	if ((multiple = fig_read_line_choice(file, "Single", "Multiple")) == -1) {
-	    message_error(_("Error reading multipage indicator: %s\n"), strerror(errno));
+	if ((multiple = fig_read_line_choice(file, "Single", "Multiple", ctx)) == -1) {
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading multipage indicator."));
 	    return FALSE;
 	}
 
@@ -1226,7 +1255,8 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
 	int transparent;
 
 	if (fscanf(file, "%d\n", &transparent) != 1) {
-	    message_error(_("Error reading transparent color: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading transparent color."));
 	    return FALSE;
 	}
     
@@ -1235,9 +1265,10 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
 
     if (!skip_comments(file)) {
 	if (!feof(file)) {
-	    message_error(_("Error reading Fig file: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading Fig file."));
 	} else {
-	    message_error(_("Premature end of Fig file\n"));
+	    dia_context_add_message(ctx, _("Premature end of Fig file\n"));
 	}
 	return FALSE;
     }
@@ -1246,7 +1277,8 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
 	int resolution, coord_system;
 
 	if (fscanf(file, "%d %d\n", &resolution, &coord_system) != 2) {
-	    message_error(_("Error reading resolution: %s\n"), strerror(errno));
+	    dia_context_set_errno(ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading resolution."));
 	    return FALSE;
 	}
     
@@ -1256,8 +1288,9 @@ fig_read_meta_data(FILE *file, DiagramData *dia) {
 }
 
 /* imports the given fig-file, returns TRUE if successful */
-gboolean 
-import_fig(const gchar *filename, DiagramData *dia, void* user_data) {
+static gboolean 
+import_fig(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_data)
+{
     FILE *figfile;
     char buf[BUFLEN];
     int figmajor, figminor;	
@@ -1272,36 +1305,40 @@ import_fig(const gchar *filename, DiagramData *dia, void* user_data) {
 
     figfile = g_fopen(filename,"r");
     if(figfile == NULL){
-	message_error(_("Couldn't open: '%s' for reading.\n"), 
-		      dia_message_filename(filename));
+	dia_context_add_message(ctx, _("Couldn't open: '%s' for reading.\n"), 
+		                dia_context_get_filename(ctx));
 	return FALSE;
     }
   
     /* First check magic bytes */
     if (fgets(buf, BUFLEN, figfile) == NULL ||
         sscanf(buf, "#FIG %d.%d\n", &figmajor, &figminor) != 2) {
-	message_error(_("Doesn't look like a Fig file: %s\n"), strerror(errno));
+	
+	dia_context_set_errno (ctx, errno);
+	dia_context_add_message(ctx, _("Doesn't look like a Fig file"));
 	fclose(figfile);
 	return FALSE;
     }
 	
     if (figmajor != 3 || figminor != 2) {
-	message_warning(_("This is a Fig version %d.%d file. It may not be importable.\n"), figmajor, figminor);
+	dia_context_add_message(ctx, _("This is a Fig version %d.%d file.\n It may not be importable."), 
+				figmajor, figminor);
     }
 
     figversion = figmajor*100+figminor;
 
     if (!skip_comments(figfile)) {
 	if (!feof(figfile)) {
-	    message_error(_("Error reading Fig file: %s\n"), strerror(errno));
+	    dia_context_set_errno (ctx, errno);
+	    dia_context_add_message(ctx, _("Error reading Fig file."));
 	} else {
-	    message_error(_("Premature end of Fig file\n"));
+	    dia_context_add_message(ctx, _("Premature end of Fig file"));
 	}
 	fclose(figfile);
 	return FALSE;
     }
 
-    if (!fig_read_meta_data(figfile, dia)) {
+    if (!fig_read_meta_data(figfile, dia, ctx)) {
 	fclose(figfile);
 	return FALSE;
     }
@@ -1311,12 +1348,13 @@ import_fig(const gchar *filename, DiagramData *dia, void* user_data) {
     do {
 	if (!skip_comments(figfile)) {
 	    if (!feof(figfile)) {
-		message_error(_("Error reading Fig file: %s\n"), strerror(errno));
+	        dia_context_set_errno (ctx, errno);
+		dia_context_add_message(ctx, _("Error reading Fig file."));
 	    } else {
 		break;
 	    }
 	}
-	if (! fig_read_object(figfile)) {
+	if (! fig_read_object(figfile, ctx)) {
 	    fclose(figfile);
 	    break;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]