[dia] Give DiaContext* to export/save functions
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Give DiaContext* to export/save functions
- Date: Sat, 21 Jul 2012 16:16:09 +0000 (UTC)
commit ea66d057c13b1ac62d3d7e10a0967429b96f90a1
Author: Hans Breuer <hans breuer org>
Date: Fri Jul 13 23:14:51 2012 +0200
Give DiaContext* to export/save functions
More message_*() in low level code gone.
Remove dia_context_set_errno() and introduce
dia_context_add_message_with_errno()
ToDo(still):
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)
app/app_procs.c | 6 +-
app/commands.c | 8 +++-
app/display.c | 4 +-
app/filedlg.c | 8 +++-
app/load_save.c | 60 ++++++++++++++++--------------
bindings/dia-object.cpp | 4 +-
bindings/dia-object.h | 2 +-
bindings/dia.swig | 4 +-
lib/filter.h | 5 +-
lib/libdia.def | 2 +-
lib/plug-ins.h | 2 +-
objects/Misc/diagram_as_object.c | 26 +++++++-----
plug-ins/cairo/diacairo-renderer.c | 8 ++--
plug-ins/cairo/diacairo.c | 50 ++++++++++++++----------
plug-ins/cgm/cgm.c | 17 +++++---
plug-ins/drs/dia-render-script.c | 16 ++++---
plug-ins/dxf/dxf-export.c | 15 ++++---
plug-ins/hpgl/hpgl.c | 26 +++++++------
plug-ins/libart/export_png.c | 7 ++-
plug-ins/metapost/render_metapost.c | 17 +++++---
plug-ins/pgf/render_pgf.c | 16 +++++---
plug-ins/pixbuf/pixbuf.c | 22 ++++++-----
plug-ins/postscript/ps-utf8.h | 5 ++
plug-ins/postscript/render_eps.c | 67 ++++++++++++++++++++------------
plug-ins/pstricks/render_pstricks.c | 18 +++++---
plug-ins/python/pydia-export.h | 3 +-
plug-ins/python/pydia-render.c | 15 ++++---
plug-ins/shape/shape-export.c | 33 ++++++----------
plug-ins/svg/render_svg.c | 18 +++------
plug-ins/vdx/vdx-export.c | 22 +++++-----
plug-ins/wmf/paginate_gdiprint.cpp | 14 +++---
plug-ins/wmf/paginate_gdiprint.h | 2 +-
plug-ins/wmf/wmf.cpp | 33 ++++++++++------
plug-ins/wpg/wpg.c | 15 ++++---
plug-ins/xfig/xfig-export.c | 15 ++++---
plug-ins/xfig/xfig-import.c | 71 ++++++++++++-----------------------
plug-ins/xslt/xslt.c | 6 +-
37 files changed, 360 insertions(+), 302 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index a700cbd..32814b0 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -371,15 +371,15 @@ do_convert(const char *infname,
*/
if (size) {
if (ef == filter_get_by_name ("png-libart")) /* the warning we get is appropriate, don't cast */
- ef->export_func(diagdata, outfname, infname, size);
+ ef->export_func(diagdata, ctx, outfname, infname, size);
else {
g_warning ("--size parameter unsupported for %s filter",
ef->unique_name ? ef->unique_name : "selected");
- ef->export_func(diagdata, outfname, infname, ef->user_data);
+ ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
}
}
else
- ef->export_func(diagdata, outfname, infname, ef->user_data);
+ ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
/* if (!quiet) */ fprintf(stdout,
_("%s --> %s\n"),
infname,outfname);
diff --git a/app/commands.c b/app/commands.c
index 4cc316d..542af9f 100644
--- a/app/commands.c
+++ b/app/commands.c
@@ -356,6 +356,7 @@ _clipboard_get_data_callback (GtkClipboard *clipboard,
guint info,
gpointer owner_or_user_data)
{
+ DiaContext *ctx = dia_context_new (_("Clipboard Copy"));
DiagramData *dia = owner_or_user_data; /* todo: check it's still valid */
const gchar *ext = strchr (target_entries[info-1].target, '/')+1;
/* Although asked for bmp, deliver png because of potentially better renderer
@@ -384,7 +385,9 @@ _clipboard_get_data_callback (GtkClipboard *clipboard,
if (strcmp(ext, "png") != 0 && filter_get_by_name ("cairo-alpha-png") != NULL)
ef = filter_get_by_name ("cairo-alpha-png");
#endif
- ef->export_func(DIA_DIAGRAM_DATA(dia), outfname, "clipboard-copy", ef->user_data);
+ dia_context_set_filename (ctx, outfname);
+ ef->export_func(DIA_DIAGRAM_DATA(dia), ctx,
+ outfname, "clipboard-copy", ef->user_data);
/* if we have a vector format, don't convert it to pixbuf */
if (strcmp (ext, "svg") != 0 && strcmp (ext, "emf") != 0 && strcmp (ext, "wmf") != 0) {
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(outfname, &error);
@@ -413,9 +416,10 @@ _clipboard_get_data_callback (GtkClipboard *clipboard,
}
}
if (error) {
- message_warning (error->message);
+ dia_context_add_message (ctx, error->message);
g_error_free (error);
}
+ dia_context_release (ctx);
}
/** GtkClipboardClearFunc */
diff --git a/app/display.c b/app/display.c
index d7b6147..3c1d8fc 100644
--- a/app/display.c
+++ b/app/display.c
@@ -1165,6 +1165,7 @@ void
ddisplay_set_renderer(DDisplay *ddisp, int aa_renderer)
{
int width, height;
+ GdkWindow *window = gtk_widget_get_window(ddisp->canvas);
/* dont mix new renderer with old updates */
if (ddisp->update_id) {
@@ -1186,7 +1187,8 @@ ddisplay_set_renderer(DDisplay *ddisp, int aa_renderer)
ddisp->renderer = new_gdk_renderer(ddisp);
}
- dia_renderer_set_size(ddisp->renderer, gtk_widget_get_window(ddisp->canvas), width, height);
+ if (window)
+ dia_renderer_set_size(ddisp->renderer, window, width, height);
}
void
diff --git a/app/filedlg.c b/app/filedlg.c
index e71401f..65307b2 100644
--- a/app/filedlg.c
+++ b/app/filedlg.c
@@ -43,6 +43,7 @@
#include "interface.h"
#include "recent_files.h"
#include "confirm.h"
+#include "diacontext.h"
#include "filedlg.h"
@@ -734,9 +735,14 @@ file_export_response_callback(GtkWidget *fs,
if (!ef)
ef = filter_guess_export_filter(filename);
if (ef) {
+ DiaContext *ctx = dia_context_new ("file-export");
+
g_object_ref(dia->data);
- ef->export_func(dia->data, filename, dia->filename, ef->user_data);
+ dia_context_set_filename (ctx, filename);
+ ef->export_func(dia->data, ctx,
+ filename, dia->filename, ef->user_data);
g_object_unref(dia->data);
+ dia_context_release (ctx);
} else
message_error(_("Could not determine which export filter\n"
"to use to save '%s'"), dia_message_filename(filename));
diff --git a/app/load_save.c b/app/load_save.c
index 1f111d2..72d2e60 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -82,7 +82,7 @@ static gboolean write_connections(GList *objects, xmlNodePtr layer_node,
GHashTable *objects_hash);
static xmlDocPtr diagram_data_write_doc(DiagramData *data, const char *filename);
static int diagram_data_raw_save(DiagramData *data, const char *filename);
-static int diagram_data_save(DiagramData *data, const char *filename);
+static gboolean diagram_data_save(DiagramData *data, DiaContext *ctx, const char *filename);
static void
@@ -998,8 +998,8 @@ diagram_data_raw_save(DiagramData *data, const char *filename)
* @returns TRUE on successfull save, FALSE otherwise. If a failure is
* indicated, an error message will already have been given to the user.
*/
-static int
-diagram_data_save(DiagramData *data, const char *user_filename)
+static gboolean
+diagram_data_save(DiagramData *data, DiaContext *ctx, const char *user_filename)
{
FILE *file;
char *bakname=NULL,*tmpname=NULL,*dirname=NULL,*p;
@@ -1014,8 +1014,8 @@ diagram_data_save(DiagramData *data, const char *user_filename)
/* not going to work with 'My Docments' - read-only but still useable, see bug #504469 */
if ( g_file_test(filename, G_FILE_TEST_EXISTS)
&& g_access(filename, W_OK) != 0) {
- message_error(_("Not allowed to write to output file %s\n"),
- dia_message_filename(filename));
+ dia_context_add_message (ctx, _("Not allowed to write to output file %s\n"),
+ dia_context_get_filename(ctx));
goto CLEANUP;
}
#endif
@@ -1024,7 +1024,7 @@ diagram_data_save(DiagramData *data, const char *user_filename)
GError *error = NULL;
filename = g_file_read_link(user_filename, &error);
if (!filename) {
- message_error("%s", error->message);
+ dia_context_add_message (ctx, "%s", error->message);
g_error_free(error);
goto CLEANUP;
}
@@ -1046,8 +1046,8 @@ diagram_data_save(DiagramData *data, const char *user_filename)
/* Check that we can create the other files */
if ( g_file_test(dirname, G_FILE_TEST_EXISTS)
&& g_access(dirname, W_OK) != 0) {
- message_error(_("Not allowed to write temporary files in %s\n"),
- dia_message_filename(dirname));
+ dia_context_add_message (ctx, _("Not allowed to write temporary files in %s\n"),
+ dia_message_filename(dirname));
goto CLEANUP;
}
#endif
@@ -1068,8 +1068,9 @@ diagram_data_save(DiagramData *data, const char *user_filename)
/* Now write the data in the temporary file name. */
if (file==NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(tmpname), strerror(errno));
+ dia_context_add_message_with_errno (ctx, errno,
+ _("Can't open output file %s"),
+ dia_message_filename(tmpname));
goto CLEANUP;
}
fclose(file);
@@ -1079,8 +1080,8 @@ diagram_data_save(DiagramData *data, const char *user_filename)
if (ret < 0) {
/* Save failed; we clean our stuff up, without touching the file named
"filename" if it existed. */
- message_error(_("Internal error %d writing file %s\n"),
- ret, dia_message_filename(tmpname));
+ dia_context_add_message(ctx, _("Internal error %d writing file %s\n"),
+ ret, dia_message_filename(tmpname));
g_unlink(tmpname);
goto CLEANUP;
}
@@ -1090,9 +1091,9 @@ diagram_data_save(DiagramData *data, const char *user_filename)
g_rename(filename,bakname);
ret = g_rename(tmpname,filename);
if (ret < 0) {
- message_error(_("Can't rename %s to final output file %s: %s\n"),
- dia_message_filename(filename),
- dia_message_filename(filename), strerror(errno));
+ dia_context_add_message_with_errno(ctx, errno, _("Can't rename %s to final output file %s: %s\n"),
+ dia_message_filename(tmpname),
+ dia_context_get_filename(ctx));
}
CLEANUP:
if (filename != user_filename)
@@ -1106,19 +1107,21 @@ CLEANUP:
int
diagram_save(Diagram *dia, const char *filename)
{
- gboolean res = diagram_data_save(dia->data, filename);
+ DiaContext *ctx = dia_context_new (_("Diagram Save"));
+ gboolean res = FALSE;
- if (!res) {
- return res;
- }
+ if (diagram_data_save(dia->data, ctx, filename)) {
+ dia->unsaved = FALSE;
+ undo_mark_save(dia->undo);
+ diagram_set_modified (dia, FALSE);
- dia->unsaved = FALSE;
- undo_mark_save(dia->undo);
- diagram_set_modified (dia, FALSE);
+ diagram_cleanup_autosave(dia);
- diagram_cleanup_autosave(dia);
+ res = TRUE;
+ }
+ dia_context_release (ctx);
- return TRUE;
+ return res;
}
/* Autosave stuff. Needs to use low-level save to avoid setting and resetting flags */
@@ -1224,11 +1227,12 @@ diagram_autosave(Diagram *dia)
}
/* --- filter interfaces --- */
-static void
-export_native(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_native(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
- diagram_data_save(data, filename);
+ return diagram_data_save(data, ctx, filename);
}
static const gchar *extensions[] = { "dia", NULL };
diff --git a/bindings/dia-object.cpp b/bindings/dia-object.cpp
index 9b32a84..7b4e714 100644
--- a/bindings/dia-object.cpp
+++ b/bindings/dia-object.cpp
@@ -51,10 +51,10 @@ dia::ObjectType::create(double x, double y, dia::Handle** h1, dia::Handle** h2)
* Allows to load an object from storage. Not sure if this becomes useful for language bindings.
*/
dia::Object*
-dia::ObjectType::load (ObjectNode node, int version, const char* filename) const
+dia::ObjectType::load (ObjectNode node, int version, DiaContext *ctx) const
{
assert (self);
- return new dia::Object (self->ops->load (node, version, filename));
+ return new dia::Object (self->ops->load (node, version, ctx));
}
/*! Allows to save an Object to ObjectNode file filename.
* . Not sure if this becomes useful for language bindings.
diff --git a/bindings/dia-object.h b/bindings/dia-object.h
index 4f02f45..9befddd 100644
--- a/bindings/dia-object.h
+++ b/bindings/dia-object.h
@@ -34,7 +34,7 @@ public :
//! create a default initialized object
Object* create (double x, double y, dia::Handle** h1 = 0, dia::Handle** h2 = 0) const;
//! load an object from storage
- Object* load (ObjectNode node, int version, const char* filename) const;
+ Object* load (ObjectNode node, int version, DiaContext *ctx) const;
//! save an object to file filename
void save (Object* o, ObjectNode node, const char* filename) const;
//! OPTIONAL: open the defaults dialog
diff --git a/bindings/dia.swig b/bindings/dia.swig
index 66207f5..c43f5ec 100755
--- a/bindings/dia.swig
+++ b/bindings/dia.swig
@@ -297,10 +297,12 @@ PyObject* dia_IProperty_value_get (dia::IProperty* self) {
%extend _DiaExportFilter {
// don't use 'export' as this produces nothing w/o warning
void do_export (dia::DiagramData *dia, const gchar *filename) {
+ DiaContext *ctx = dia_context_new ("Export");
if (dia)
- self->export_func (dia->Self(), filename, filename, self->user_data);
+ self->export_func (dia->Self(), ctx, filename, filename, self->user_data);
else
g_warning ( "%s no data", G_STRFUNC);
+ dia_context_release (ctx);
}
};
diff --git a/lib/filter.h b/lib/filter.h
index a0d76e5..9e30e9e 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -32,8 +32,9 @@ enum FilterFlags {
FILTER_DONT_GUESS = (1<<0)
};
-typedef void (* DiaExportFunc) (DiagramData *dia, const gchar *filename,
- const gchar *diafilename, void* user_data);
+typedef gboolean (* DiaExportFunc) (DiagramData *dia, DiaContext *ctx,
+ const gchar *filename, const char *diagram_filename,
+ void* user_data);
struct _DiaExportFilter {
const gchar *description;
diff --git a/lib/libdia.def b/lib/libdia.def
index b770c95..97fed25 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -206,10 +206,10 @@ EXPORTS
dia_config_filename
dia_context_add_message
+ dia_context_add_message_with_errno
dia_context_get_filename
dia_context_new
dia_context_release
- dia_context_set_errno
dia_context_set_filename
dia_dynamic_menu_get_type
diff --git a/lib/plug-ins.h b/lib/plug-ins.h
index 783c389..d999929 100644
--- a/lib/plug-ins.h
+++ b/lib/plug-ins.h
@@ -48,7 +48,7 @@ G_BEGIN_DECLS
* The list is by no means complete. If in doubt about your change
* please ask on dia-list or alternative increment ;-) --hb
*/
-#define DIA_PLUGIN_API_VERSION 16
+#define DIA_PLUGIN_API_VERSION 17
typedef enum {
DIA_PLUGIN_INIT_OK,
diff --git a/objects/Misc/diagram_as_object.c b/objects/Misc/diagram_as_object.c
index 74f4fcd..ed19ad2 100644
--- a/objects/Misc/diagram_as_object.c
+++ b/objects/Misc/diagram_as_object.c
@@ -208,20 +208,24 @@ _dae_draw(DiagramAsElement *dae, DiaRenderer *renderer)
ef = filter_guess_export_filter (imgfname);
close(fd);
if (ef) {
- DiaImage *tmp_image;
- ef->export_func (dae->data, imgfname, dae->filename, ef->user_data);
- /* TODO: change export_func to return success or GError* */
- tmp_image = dia_image_load (imgfname);
- /* some extra gymnastics to create an image w/o filename */
- if (tmp_image) {
- dae->image = dia_image_new_from_pixbuf ((GdkPixbuf *)dia_image_pixbuf (tmp_image));
- g_object_unref (tmp_image);
+ DiaContext *ctx = dia_context_new ("Diagram as Object");
+
+ if (ef->export_func (dae->data, ctx, imgfname, dae->filename, ef->user_data)) {
+ DiaImage *tmp_image = dia_image_load (imgfname);
+
+ /* some extra gymnastics to create an image w/o filename */
+ if (tmp_image) {
+ dae->image = dia_image_new_from_pixbuf ((GdkPixbuf *)dia_image_pixbuf (tmp_image));
+ g_object_unref (tmp_image);
+ }
+ /* FIXME: where to put the message in case of an error? */
+ dia_context_release (ctx);
}
- }
+ } /* found a filter */
g_unlink (imgfname);
g_free (imgfname);
- }
- }
+ } /* temporary file created*/
+ } /* only if we have no image yet */
if (dae->image)
renderer_ops->draw_image (renderer, &elem->corner, elem->width, elem->height, dae->image);
}
diff --git a/plug-ins/cairo/diacairo-renderer.c b/plug-ins/cairo/diacairo-renderer.c
index 27e7cba..a9fef2b 100644
--- a/plug-ins/cairo/diacairo-renderer.c
+++ b/plug-ins/cairo/diacairo-renderer.c
@@ -272,7 +272,7 @@ set_linecaps(DiaRenderer *self, LineCaps mode)
cairo_set_line_cap (renderer->cr, CAIRO_LINE_CAP_SQUARE); /* ?? */
break;
default:
- message_error("DiaCairoRenderer : Unsupported caps mode specified!\n");
+ g_warning("DiaCairoRenderer : Unsupported caps mode specified!\n");
}
DIAG_STATE(renderer->cr)
}
@@ -295,7 +295,7 @@ set_linejoin(DiaRenderer *self, LineJoin mode)
cairo_set_line_join (renderer->cr, CAIRO_LINE_JOIN_BEVEL);
break;
default:
- message_error("DiaCairoRenderer : Unsupported join mode specified!\n");
+ g_warning("DiaCairoRenderer : Unsupported join mode specified!\n");
}
DIAG_STATE(renderer->cr)
}
@@ -343,7 +343,7 @@ set_linestyle(DiaRenderer *self, LineStyle mode)
cairo_set_dash (renderer->cr, dash, 2, 0);
break;
default:
- message_error("DiaCairoRenderer : Unsupported line style specified!\n");
+ g_warning("DiaCairoRenderer : Unsupported line style specified!\n");
}
DIAG_STATE(renderer->cr)
}
@@ -377,7 +377,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
*/
break;
default:
- message_error("DiaCairoRenderer : Unsupported fill mode specified!\n");
+ g_warning("DiaCairoRenderer : Unsupported fill mode specified!\n");
}
DIAG_STATE(DIA_CAIRO_RENDERER (self)->cr)
}
diff --git a/plug-ins/cairo/diacairo.c b/plug-ins/cairo/diacairo.c
index d32b630..acd0f62 100644
--- a/plug-ins/cairo/diacairo.c
+++ b/plug-ins/cairo/diacairo.c
@@ -72,7 +72,6 @@
#endif
#include "intl.h"
-#include "message.h"
#include "geometry.h"
#include "dia_image.h"
#include "diarenderer.h"
@@ -101,9 +100,10 @@ typedef enum OutputKind
#endif
/* dia export funtion */
-static void
-export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
DiaCairoRenderer *renderer;
FILE *file;
@@ -122,18 +122,18 @@ export_data(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "wb"); /* "wb" for binary! */
if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno(ctx, errno, _("Can't open output file %s."),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
fclose (file);
#ifdef G_OS_WIN32
filename_crt = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
if (!filename_crt) {
- message_error(_("Can't convert output filename '%s' to locale encoding.\n"
- "Please choose a different name to save with Cairo.\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message(ctx, _("Can't convert output filename '%s' to locale encoding.\n"
+ "Please choose a different name to save with Cairo.\n"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
#endif
} /* != CLIPBOARD */
@@ -302,7 +302,7 @@ export_data(DiagramData *data, const gchar *filename,
fwrite(pData,1,nSize,f);
fclose(f);
} else {
- message_error (_("Can't write %d bytes to %s"), nSize, filename);
+ dia_context_add_message(ctx, _("Can't write %d bytes to %s"), nSize, filename);
}
DeleteEnhMetaFile (hEmf);
g_free (pData);
@@ -318,7 +318,7 @@ export_data(DiagramData *data, const gchar *filename,
fwrite(pData,1,nSize,f);
fclose(f);
} else {
- message_error (_("Can't write %d bytes to %s"), nSize, filename);
+ dia_context_add_message(ctx, _("Can't write %d bytes to %s"), nSize, filename);
}
ReleaseDC(NULL, hdc);
DeleteEnhMetaFile (hEmf);
@@ -331,7 +331,7 @@ export_data(DiagramData *data, const gchar *filename,
&& CloseClipboard ()) {
hEmf = NULL; /* data now owned by clipboard */
} else {
- message_error (_("Clipboard copy failed"));
+ dia_context_add_message(ctx, _("Clipboard copy failed"));
DeleteEnhMetaFile (hEmf);
}
}
@@ -339,11 +339,13 @@ export_data(DiagramData *data, const gchar *filename,
g_object_unref(renderer);
if (filename != filename_crt)
g_free (filename_crt);
+ return TRUE;
}
-static void
-export_print_data (DiagramData *data, const gchar *filename_utf8,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_print_data (DiagramData *data, DiaContext *ctx,
+ const gchar *filename_utf8, const gchar *diafilename,
+ void* user_data)
{
OutputKind kind = (OutputKind)user_data;
GtkPrintOperation *op = create_print_operation (data, filename_utf8);
@@ -356,16 +358,18 @@ export_print_data (DiagramData *data, const gchar *filename_utf8,
# endif
if (!data) {
- message_error (_("Nothing to print"));
- return;
+ dia_context_add_message(ctx, _("Nothing to print"));
+ return FALSE;
}
gtk_print_operation_set_export_filename (op, filename_utf8 ? filename_utf8 : "output.pdf");
res = gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, &error);
if (GTK_PRINT_OPERATION_RESULT_ERROR == res) {
- message_error (error->message);
+ dia_context_add_message(ctx, "%s", error->message);
g_error_free (error);
+ return FALSE;
}
+ return TRUE;
}
#ifdef CAIRO_HAS_PS_SURFACE
@@ -459,10 +463,14 @@ cairo_clipboard_callback (DiagramData *data,
guint flags, /* further additions */
void *user_data)
{
+ DiaContext *ctx = dia_context_new(_("Cairo Clipboard Copy"));
+
g_return_val_if_fail ((OutputKind)user_data == OUTPUT_CLIPBOARD, NULL);
g_return_val_if_fail (data != NULL, NULL);
+
/* filename is not necessary */
- export_data (data, filename, filename, user_data);
+ export_data (data, ctx, filename, filename, user_data);
+ dia_context_release (ctx);
return NULL;
}
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index 5422471..fd2009a 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -719,7 +719,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
write_int16(renderer->file, 1);
break;
default:
- message_error("svg_renderer: Unsupported fill mode specified!\n");
+ g_warning("cgm_renderer: Unsupported fill mode specified!");
}
#endif
}
@@ -1155,9 +1155,10 @@ draw_image(DiaRenderer *self,
g_free (pImg);
}
-static void
-export_cgm(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_cgm(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
CgmRenderer *renderer;
FILE *file;
@@ -1167,9 +1168,9 @@ export_cgm(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "wb");
if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(CGM_TYPE_RENDERER, NULL);
@@ -1287,6 +1288,8 @@ export_cgm(DiagramData *data, const gchar *filename,
if (renderer->font != NULL)
dia_font_unref(renderer->font);
g_object_unref(renderer);
+
+ return TRUE;
}
/* GObject stuff */
diff --git a/plug-ins/drs/dia-render-script.c b/plug-ins/drs/dia-render-script.c
index a390f8c..b83c66d 100644
--- a/plug-ins/drs/dia-render-script.c
+++ b/plug-ins/drs/dia-render-script.c
@@ -59,7 +59,6 @@
#include "intl.h"
#include "filter.h"
#include "plug-ins.h"
-#include "message.h"
#include "diagramdata.h"
#include "dia_xml_libxml.h"
@@ -108,9 +107,10 @@ drs_data_render (DiagramData *data, DiaRenderer *renderer)
}
/* dia export funtion */
-static void
-export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
DrsRenderer *renderer;
xmlDtdPtr dtd;
@@ -121,9 +121,9 @@ export_data(DiagramData *data, const gchar *filename,
FILE *file = g_fopen(filename, "w");
if (!file) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s."),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
fclose(file);
}
@@ -149,6 +149,8 @@ export_data(DiagramData *data, const gchar *filename,
xmlFreeDoc(doc);
g_object_unref(renderer);
+
+ return TRUE;
}
static const gchar *extensions[] = { "drs", NULL };
diff --git a/plug-ins/dxf/dxf-export.c b/plug-ins/dxf/dxf-export.c
index e51deb5..324a1d7 100644
--- a/plug-ins/dxf/dxf-export.c
+++ b/plug-ins/dxf/dxf-export.c
@@ -582,9 +582,10 @@ draw_image(DiaRenderer *self,
{
}
-static void
-export_dxf(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_dxf(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
DxfRenderer *renderer;
FILE *file;
@@ -596,9 +597,9 @@ export_dxf(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "w");
if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(DXF_TYPE_RENDERER, NULL);
@@ -646,6 +647,8 @@ export_dxf(DiagramData *data, const gchar *filename,
DIA_RENDERER_GET_CLASS(renderer)->end_render(DIA_RENDERER(renderer));
g_object_unref(renderer);
+
+ return TRUE;
}
static const gchar *extensions[] = { "dxf", NULL };
diff --git a/plug-ins/hpgl/hpgl.c b/plug-ins/hpgl/hpgl.c
index 1efb26e..43e2ccf 100644
--- a/plug-ins/hpgl/hpgl.c
+++ b/plug-ins/hpgl/hpgl.c
@@ -40,7 +40,6 @@
#include <glib/gstdio.h>
#include "intl.h"
-#include "message.h"
#include "geometry.h"
#include "diarenderer.h"
#include "filter.h"
@@ -213,7 +212,7 @@ set_linecaps(DiaRenderer *object, LineCaps mode)
case LINECAPS_PROJECTING:
break;
default:
- message_error("HpglRenderer: Unsupported fill mode specified!\n");
+ g_warning("HpglRenderer: Unsupported fill mode specified!");
}
}
@@ -230,7 +229,7 @@ set_linejoin(DiaRenderer *object, LineJoin mode)
case LINEJOIN_BEVEL:
break;
default:
- message_error("HpglRenderer : Unsupported fill mode specified!\n");
+ g_warning("HpglRenderer : Unsupported fill mode specified!");
}
}
@@ -262,7 +261,7 @@ set_linestyle(DiaRenderer *object, LineStyle mode)
fprintf(renderer->file, "LT1;\n");
break;
default:
- message_error("HpglRenderer : Unsupported fill mode specified!\n");
+ g_warning("HpglRenderer : Unsupported fill mode specified!");
}
}
@@ -286,7 +285,7 @@ set_fillstyle(DiaRenderer *object, FillStyle mode)
case FILLSTYLE_SOLID:
break;
default:
- message_error("HpglRenderer : Unsupported fill mode specified!\n");
+ g_warning("HpglRenderer : Unsupported fill mode specified!");
}
}
@@ -695,9 +694,10 @@ hpgl_renderer_class_init (HpglRendererClass *klass)
}
/* plug-in interface : export function */
-static void
-export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
HpglRenderer *renderer;
FILE *file;
@@ -706,10 +706,10 @@ export_data(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "w"); /* "wb" for binary! */
- if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ if (!file) {
+ dia_context_add_message_with_errno(ctx, errno, _("Can't open output file %s."),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(HPGL_TYPE_RENDERER, NULL);
@@ -744,6 +744,8 @@ export_data(DiagramData *data, const gchar *filename,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+
+ return TRUE;
}
static const gchar *extensions[] = { "plt", "hpgl", NULL };
diff --git a/plug-ins/libart/export_png.c b/plug-ins/libart/export_png.c
index a8f219f..c8e8e2a 100644
--- a/plug-ins/libart/export_png.c
+++ b/plug-ins/libart/export_png.c
@@ -305,9 +305,10 @@ export_png_ratio(GtkAdjustment *limits, gpointer userdata)
in_progress = FALSE;
}
-static void
-export_png(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_png(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
/* Create the callback data. Can't be stack allocated, as the function
returns before the callback is called. Must be freed by the
diff --git a/plug-ins/metapost/render_metapost.c b/plug-ins/metapost/render_metapost.c
index 15444a8..4e39081 100644
--- a/plug-ins/metapost/render_metapost.c
+++ b/plug-ins/metapost/render_metapost.c
@@ -1158,9 +1158,10 @@ draw_image(DiaRenderer *self,
}
/* --- export filter interface --- */
-static void
-export_metapost(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_metapost(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
MetapostRenderer *renderer;
FILE *file;
@@ -1176,10 +1177,10 @@ export_metapost(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "wb");
- if (file==NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ if (file == NULL) {
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(METAPOST_TYPE_RENDERER, NULL);
@@ -1258,6 +1259,8 @@ export_metapost(DiagramData *data, const gchar *filename,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+
+ return TRUE;
}
static const gchar *extensions[] = { "mp", NULL };
diff --git a/plug-ins/pgf/render_pgf.c b/plug-ins/pgf/render_pgf.c
index 16ec5e1..0180e2f 100644
--- a/plug-ins/pgf/render_pgf.c
+++ b/plug-ins/pgf/render_pgf.c
@@ -1184,9 +1184,10 @@ draw_image(DiaRenderer *self,
}
/* --- export filter interface --- */
-static void
-export_pgf(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_pgf(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
PgfRenderer *renderer;
FILE *file;
@@ -1199,9 +1200,10 @@ export_pgf(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "wb");
- if (file==NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
+ if (file == NULL) {
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(PGF_TYPE_RENDERER, NULL);
@@ -1256,6 +1258,8 @@ export_pgf(DiagramData *data, const gchar *filename,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+
+ return TRUE;
}
static const gchar *extensions[] = { "tex", NULL };
diff --git a/plug-ins/pixbuf/pixbuf.c b/plug-ins/pixbuf/pixbuf.c
index fa50a9c..a530252 100644
--- a/plug-ins/pixbuf/pixbuf.c
+++ b/plug-ins/pixbuf/pixbuf.c
@@ -35,18 +35,18 @@
#include "prop_geomtypes.h"
#include "object.h"
-static Rectangle rect;
-static real zoom = 1.0;
-
-static void
-export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
DiaGdkRenderer *renderer;
GdkColor color;
int width, height;
GdkPixbuf* pixbuf = NULL;
GError* error = NULL;
+ Rectangle rect;
+ real zoom = 1.0;
const char* format = (const char*)user_data;
rect.left = data->extents.left;
@@ -85,18 +85,20 @@ export_data(DiagramData *data, const gchar *filename,
}
else
{
- message_error ("Failed to create pixbuf from drawable.");
+ dia_context_add_message(ctx, _("Failed to create pixbuf from drawable."));
}
if (error)
{
- message_warning(_("Could not save file:\n%s\n%s"),
- dia_message_filename(filename),
- error->message);
+ dia_context_add_message(ctx, _("Could not save file:\n%s"),
+ dia_context_get_filename(ctx),
+ error->message);
g_error_free (error);
}
g_object_unref (renderer);
+
+ return TRUE;
}
static gboolean
diff --git a/plug-ins/postscript/ps-utf8.h b/plug-ins/postscript/ps-utf8.h
index 3a3df90..e25eb94 100644
--- a/plug-ins/postscript/ps-utf8.h
+++ b/plug-ins/postscript/ps-utf8.h
@@ -28,6 +28,11 @@
#include "diatypes.h"
+typedef struct _PSFontDescriptor PSFontDescriptor;
+typedef struct _PSEncodingPage PSEncodingPage;
+typedef struct _PSUnicoder PSUnicoder;
+typedef struct _PSUnicoderCallbacks PSUnicoderCallbacks;
+
#define PSEPAGE_BEGIN 32
#define PSEPAGE_SIZE (256-PSEPAGE_BEGIN)
diff --git a/plug-ins/postscript/render_eps.c b/plug-ins/postscript/render_eps.c
index 072393a..e227d97 100644
--- a/plug-ins/postscript/render_eps.c
+++ b/plug-ins/postscript/render_eps.c
@@ -68,44 +68,60 @@
#include "diapsft2renderer.h"
#endif
-static void export_eps(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data);
-static void export_render_eps(DiaPsRenderer *renderer,
- DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data);
+static gboolean export_eps(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data);
+static gboolean export_render_eps(DiaPsRenderer *renderer,
+ DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data);
#ifdef HAVE_FREETYPE
-static void export_ft2_eps(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data);
-static void
-export_ft2_eps(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data) {
- export_render_eps(g_object_new (DIA_TYPE_PS_FT2_RENDERER, NULL),
- data, filename, diafilename, user_data);
+static gboolean export_ft2_eps(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data);
+static gboolean
+export_ft2_eps(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
+{
+ gboolean ret;
+ DiaPsRenderer *renderer = g_object_new (DIA_TYPE_PS_FT2_RENDERER, NULL);
+
+ ret = export_render_eps(renderer, data, ctx, filename, diafilename, user_data);
+ g_object_unref (renderer);
+
+ return ret;
}
#endif
-static void
-export_eps(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_eps(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
- export_render_eps(g_object_new (DIA_TYPE_PS_RENDERER, NULL),
- data, filename, diafilename, user_data);
+ gboolean ret;
+ DiaPsRenderer *renderer = g_object_new (DIA_TYPE_PS_RENDERER, NULL);
+
+ ret = export_render_eps(renderer, data, ctx, filename, diafilename, user_data);
+ g_object_unref (renderer);
+
+ return ret;
}
-static void
+static gboolean
export_render_eps(DiaPsRenderer *renderer,
- DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+ DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
FILE *outfile;
outfile = g_fopen(filename, "w");
if (outfile == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- g_object_unref(renderer);
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer->file = outfile;
renderer->scale = 28.346 * data->paper.scaling;
@@ -121,8 +137,9 @@ export_render_eps(DiaPsRenderer *renderer,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
}
- g_object_unref (renderer);
fclose(outfile);
+
+ return TRUE;
}
DiaRenderer *
diff --git a/plug-ins/pstricks/render_pstricks.c b/plug-ins/pstricks/render_pstricks.c
index 2b5745a..01ae990 100644
--- a/plug-ins/pstricks/render_pstricks.c
+++ b/plug-ins/pstricks/render_pstricks.c
@@ -381,7 +381,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
case FILLSTYLE_SOLID:
break;
default:
- message_error("pstricks_renderer: Unsupported fill mode specified!\n");
+ g_warning("pstricks_renderer: Unsupported fill mode specified!\n");
}
}
@@ -894,9 +894,10 @@ draw_image(DiaRenderer *self,
}
/* --- export filter interface --- */
-static void
-export_pstricks(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_pstricks(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
PstricksRenderer *renderer;
FILE *file;
@@ -915,9 +916,10 @@ export_pstricks(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "wb");
- if (file==NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
+ if (file == NULL) {
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(PSTRICKS_TYPE_RENDERER, NULL);
@@ -983,6 +985,8 @@ export_pstricks(DiagramData *data, const gchar *filename,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+
+ return TRUE;
}
static const gchar *extensions[] = { "tex", NULL };
diff --git a/plug-ins/python/pydia-export.h b/plug-ins/python/pydia-export.h
index 2942e80..8f37044 100644
--- a/plug-ins/python/pydia-export.h
+++ b/plug-ins/python/pydia-export.h
@@ -16,6 +16,7 @@ extern PyTypeObject PyDiaExportFilter_Type;
PyObject *PyDiaExportFilter_New(DiaExportFilter *filter);
/* first callback for file exports */
-void PyDia_export_data(DiagramData *data, const gchar *filename, const gchar *diafilename, void *user_data);
+gboolean PyDia_export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename, void *user_data);
#endif
diff --git a/plug-ins/python/pydia-render.c b/plug-ins/python/pydia-render.c
index ac7b39c..5141a7a 100644
--- a/plug-ins/python/pydia-render.c
+++ b/plug-ins/python/pydia-render.c
@@ -26,7 +26,6 @@
#include <locale.h>
#include "intl.h"
-#include "message.h"
#include "geometry.h"
#include "pydia-object.h" /* for PyObject_HEAD_INIT */
@@ -919,9 +918,9 @@ draw_image(DiaRenderer *renderer,
}
}
-void
-PyDia_export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+gboolean
+PyDia_export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename, void* user_data)
{
DiaPyRenderer *renderer;
@@ -930,9 +929,9 @@ PyDia_export_data(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "w"); /* "wb" for binary! */
if (file == NULL) {
- message_error(_("Couldn't open '%s' for writing.\n"),
- dia_message_filename(filename));
- return;
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't open '%s' for writing.\n"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
else
fclose (file);
@@ -950,6 +949,8 @@ PyDia_export_data(DiagramData *data, const gchar *filename,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+
+ return TRUE;
}
DiaRenderer *
diff --git a/plug-ins/shape/shape-export.c b/plug-ins/shape/shape-export.c
index ca8e074..d330621 100644
--- a/plug-ins/shape/shape-export.c
+++ b/plug-ins/shape/shape-export.c
@@ -132,15 +132,6 @@ new_shape_renderer(DiagramData *data, const char *filename)
char *sheetname;
char *basename;
- file = g_fopen(filename, "w");
-
- if (file==NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return NULL;
- }
- fclose(file);
-
shape_renderer = g_object_new(SHAPE_TYPE_RENDERER, NULL);
renderer = DIA_SVG_RENDERER (shape_renderer);
@@ -460,9 +451,10 @@ draw_ellipse(DiaRenderer *self,
add_ellipse_connection_points(renderer, center, width, height);
}
-static void
-export_shape(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_shape(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
DiaSvgRenderer *renderer;
int i;
@@ -475,10 +467,9 @@ export_shape(DiagramData *data, const gchar *filename,
/* create the png preview shown in the toolbox */
point = strrchr(filename, '.');
- if (point == NULL ||
- strcmp(point, ".shape")) {
- message_warning(_("Shape files must end in .shape, or they cannot be loaded by Dia"));
- return;
+ if (point == NULL || strcmp(point, ".shape") != 0) {
+ dia_context_add_message(ctx, _("Shape files must end in .shape, or they cannot be loaded by Dia"));
+ return FALSE;
}
i = (int)(point-filename);
point = g_strndup(filename, i);
@@ -491,26 +482,28 @@ export_shape(DiagramData *data, const gchar *filename,
exportfilter = filter_guess_export_filter(png_filename);
if (!exportfilter) {
- message_warning(_("Can't export PNG icon without export plugin!"));
+ dia_context_add_message(ctx, _("Can't export PNG icon without export plugin!"));
} else {
/* get the scaling right */
old_scaling = data->paper.scaling;
scaling_x = 22/((ext->right - ext->left) * 20);
scaling_y = 22/((ext->bottom - ext->top) * 20);
data->paper.scaling = MIN(scaling_x, scaling_y);
- exportfilter->export_func(data, png_filename, diafilename, exportfilter->user_data);
+ exportfilter->export_func(data, ctx, png_filename, diafilename, exportfilter->user_data);
data->paper.scaling = old_scaling;
}
+ g_free(png_filename);
+
/* create the shape */
if((renderer = new_shape_renderer(data, filename))) {
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref (renderer);
+ return TRUE;
}
/* Create a sheet entry if applicable (../../sheets exists) */
-
- g_free(png_filename);
+ return FALSE;
}
static const gchar *extensions[] = { "shape", NULL };
diff --git a/plug-ins/svg/render_svg.c b/plug-ins/svg/render_svg.c
index d7a05f1..b7cd25e 100644
--- a/plug-ins/svg/render_svg.c
+++ b/plug-ins/svg/render_svg.c
@@ -192,15 +192,6 @@ new_svg_renderer(DiagramData *data, const char *filename)
Rectangle *extent;
xmlDtdPtr dtd;
- file = g_fopen(filename, "w");
-
- if (file==NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return NULL;
- }
- fclose(file);
-
/* we need access to our base object */
renderer = DIA_SVG_RENDERER (g_object_new(SVG_TYPE_RENDERER, NULL));
@@ -486,16 +477,19 @@ draw_text (DiaRenderer *self, Text *text)
}
}
-static void
-export_svg(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_svg(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
DiaSvgRenderer *renderer;
if ((renderer = new_svg_renderer(data, filename))) {
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+ return TRUE;
}
+ return FALSE;
}
static const gchar *extensions[] = { "svg", NULL };
diff --git a/plug-ins/vdx/vdx-export.c b/plug-ins/vdx/vdx-export.c
index 89c34bd..36826d5 100644
--- a/plug-ins/vdx/vdx-export.c
+++ b/plug-ins/vdx/vdx-export.c
@@ -39,7 +39,6 @@
#include <glib/gstdio.h>
#include "intl.h"
-#include "message.h"
#include "geometry.h"
#include "diarenderer.h"
#include "filter.h"
@@ -154,9 +153,9 @@ static void draw_image(DiaRenderer *self,
static void vdx_renderer_class_init (VDXRendererClass *klass);
-static void
-export_vdx(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data);
+static gboolean export_vdx(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data);
static int
vdxCheckColor(VDXRenderer *renderer, Color *color);
@@ -1514,7 +1513,7 @@ static void draw_image(DiaRenderer *self,
*/
const char *
-vdx_string_color(Color c)
+vdx_string_color(const Color c)
{
static char buf[8];
sprintf(buf, "#%.2X%.2X%.2X",
@@ -1785,9 +1784,10 @@ write_trailer(DiagramData *data, VDXRenderer *renderer)
* @note Must know if 2002 or 2003 before start
*/
-static void
-export_vdx(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_vdx(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
FILE *file;
VDXRenderer *renderer;
@@ -1798,9 +1798,9 @@ export_vdx(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "w");
if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
/* ugly, but still better than creatin corrupt files */
diff --git a/plug-ins/wmf/paginate_gdiprint.cpp b/plug-ins/wmf/paginate_gdiprint.cpp
index 813afde..81d7049 100644
--- a/plug-ins/wmf/paginate_gdiprint.cpp
+++ b/plug-ins/wmf/paginate_gdiprint.cpp
@@ -62,7 +62,7 @@ namespace W32 {
static guint
print_page(DiagramData *data, DiaExportFilter* pExp, W32::HANDLE hDC,
- Rectangle *bounds, gint xpos, gint ypos)
+ Rectangle *bounds, gint xpos, gint ypos, DiaContext *ctx)
{
guint nobjs = 0;
DiagramData page_data = *data; /* ugliness! */
@@ -77,14 +77,14 @@ print_page(DiagramData *data, DiaExportFilter* pExp, W32::HANDLE hDC,
/* render the region */
W32::StartPage((W32::HDC)hDC);
- pExp->export_func(&page_data, "", "", (W32::HDC)hDC);
+ pExp->export_func(&page_data, ctx, "", "", (W32::HDC)hDC);
W32::EndPage((W32::HDC)hDC);
return nobjs;
}
static void
-paginate_gdiprint(DiagramData *data, DiaExportFilter* pExp, W32::HANDLE hDC)
+paginate_gdiprint(DiagramData *data, DiaExportFilter* pExp, W32::HANDLE hDC, DiaContext *ctx)
{
Rectangle *extents;
gdouble width, height;
@@ -122,7 +122,7 @@ paginate_gdiprint(DiagramData *data, DiaExportFilter* pExp, W32::HANDLE hDC)
page_bounds.top = y;
page_bounds.bottom = y + height;
- nobjs += print_page(data, pExp, hDC, &page_bounds, xpos, ypos);
+ nobjs += print_page(data, pExp, hDC, &page_bounds, xpos, ypos, ctx);
}
}
}
@@ -133,7 +133,7 @@ static W32::HGLOBAL hDevNames = NULL;
extern "C"
void
-diagram_print_gdi(DiagramData *data, const gchar *filename)
+diagram_print_gdi(DiagramData *data, const gchar *filename, DiaContext *ctx)
{
W32::PRINTDLG printDlg;
W32::DOCINFO docInfo;
@@ -144,7 +144,7 @@ diagram_print_gdi(DiagramData *data, const gchar *filename)
pExp = filter_get_by_name("wmf");
if (!pExp) {
- message_error("Can't print without the WMF plugin installed");
+ dia_context_add_message (ctx, "Can't print without the WMF plugin installed");
return;
}
@@ -221,7 +221,7 @@ diagram_print_gdi(DiagramData *data, const gchar *filename)
if (0 >= W32::StartDoc(printDlg.hDC, &docInfo))
ERROR_RETURN(W32::GetLastError());
for (i = 0; i < printDlg.nCopies; i++)
- paginate_gdiprint(data, pExp, printDlg.hDC);
+ paginate_gdiprint(data, pExp, printDlg.hDC, ctx);
/* clean up */
if (0 >= W32::EndDoc(printDlg.hDC))
diff --git a/plug-ins/wmf/paginate_gdiprint.h b/plug-ins/wmf/paginate_gdiprint.h
index 0876947..76615c8 100644
--- a/plug-ins/wmf/paginate_gdiprint.h
+++ b/plug-ins/wmf/paginate_gdiprint.h
@@ -3,6 +3,6 @@
#include "diagramdata.h"
-extern "C" void diagram_print_gdi(DiagramData *data, const gchar* filename);
+extern "C" void diagram_print_gdi(DiagramData *data, const gchar* filename, DiaContext *ctx);
#endif
diff --git a/plug-ins/wmf/wmf.cpp b/plug-ins/wmf/wmf.cpp
index 80f68cb..2c929ae 100644
--- a/plug-ins/wmf/wmf.cpp
+++ b/plug-ins/wmf/wmf.cpp
@@ -416,7 +416,7 @@ set_linecaps(DiaRenderer *self, LineCaps mode)
renderer->fnPenStyle |= PS_ENDCAP_SQUARE;
break;
default:
- message_error("WmfRenderer : Unsupported fill mode specified!\n");
+ g_warning("WmfRenderer : Unsupported fill mode specified!\n");
}
}
@@ -442,7 +442,7 @@ set_linejoin(DiaRenderer *self, LineJoin mode)
renderer->fnPenStyle |= PS_JOIN_BEVEL;
break;
default:
- message_error("WmfRenderer : Unsupported fill mode specified!\n");
+ g_warning("WmfRenderer : Unsupported fill mode specified!\n");
}
}
@@ -472,7 +472,7 @@ set_linestyle(DiaRenderer *self, LineStyle mode)
renderer->fnPenStyle |= PS_DOT;
break;
default:
- message_error("WmfRenderer : Unsupported fill mode specified!\n");
+ g_warning("WmfRenderer : Unsupported fill mode specified!\n");
}
if (renderer->platform_is_nt)
@@ -514,7 +514,7 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
case FILLSTYLE_SOLID:
break;
default:
- message_error("WmfRenderer : Unsupported fill mode specified!\n");
+ g_warning("WmfRenderer : Unsupported fill mode specified!\n");
}
}
@@ -1318,9 +1318,10 @@ wmf_renderer_class_init (WmfRendererClass *klass)
}
/* plug-in export api */
-static void
-export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
WmfRenderer *renderer;
W32::HDC file = NULL;
@@ -1367,9 +1368,9 @@ export_data(DiagramData *data, const gchar *filename,
"Dia\0Diagram\0"); // pointer to an optional description string
#endif
if (file == NULL) {
- message_error(_("Couldn't open: '%s' for writing.\n"),
- dia_message_filename(filename));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = (WmfRenderer*)g_object_new(WMF_TYPE_RENDERER, NULL);
@@ -1462,6 +1463,8 @@ export_data(DiagramData *data, const gchar *filename,
g_object_unref(renderer);
W32::ReleaseDC (NULL, refDC);
+
+ return TRUE;
}
static const gchar *wmf_extensions[] = { "wmf", NULL };
@@ -1489,10 +1492,16 @@ print_callback (DiagramData *data,
guint flags,
void *user_data)
{
+ /* Todo: get the context from caller */
+ DiaContext *ctx = dia_context_new ("PrintGDI");
+
if (!data)
- message_error (_("Nothing to print"));
+ dia_context_add_message (ctx, _("Nothing to print"));
else
- diagram_print_gdi (data, filename);
+ diagram_print_gdi (data, filename, ctx);
+
+ dia_context_release (ctx);
+
return NULL;
}
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index a95b971..bbdaea3 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -1061,9 +1061,10 @@ wpg_renderer_class_init (WpgRendererClass *klass)
}
/* dia export funtion */
-static void
-export_data(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_data(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
WpgRenderer *renderer;
FILE *file;
@@ -1073,9 +1074,9 @@ export_data(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "wb"); /* "wb" for binary! */
if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new (WPG_TYPE_RENDERER, NULL);
@@ -1116,6 +1117,8 @@ export_data(DiagramData *data, const gchar *filename,
data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
g_object_unref(renderer);
+
+ return TRUE;
}
#if WPG_WITH_IMPORT
diff --git a/plug-ins/xfig/xfig-export.c b/plug-ins/xfig/xfig-export.c
index 32c580e..679488b 100644
--- a/plug-ins/xfig/xfig-export.c
+++ b/plug-ins/xfig/xfig-export.c
@@ -1141,9 +1141,10 @@ draw_object(DiaRenderer *self,
fprintf(renderer->file, "-6\n");
}
-static void
-export_fig(DiagramData *data, const gchar *filename,
- const gchar *diafilename, void* user_data)
+static gboolean
+export_fig(DiagramData *data, DiaContext *ctx,
+ const gchar *filename, const gchar *diafilename,
+ void* user_data)
{
FILE *file;
XfigRenderer *renderer;
@@ -1154,9 +1155,9 @@ export_fig(DiagramData *data, const gchar *filename,
file = g_fopen(filename, "w");
if (file == NULL) {
- message_error(_("Can't open output file %s: %s\n"),
- dia_message_filename(filename), strerror(errno));
- return;
+ dia_context_add_message_with_errno (ctx, errno, _("Can't open output file %s"),
+ dia_context_get_filename(ctx));
+ return FALSE;
}
renderer = g_object_new(XFIG_TYPE_RENDERER, NULL);
@@ -1204,6 +1205,8 @@ export_fig(DiagramData *data, const gchar *filename,
g_object_unref(renderer);
fclose(file);
+
+ return TRUE;
}
static const gchar *extensions[] = { "fig", NULL };
diff --git a/plug-ins/xfig/xfig-import.c b/plug-ins/xfig/xfig-import.c
index 7ff145b..7d4d6f9 100644
--- a/plug-ins/xfig/xfig-import.c
+++ b/plug-ins/xfig/xfig-import.c
@@ -240,8 +240,8 @@ fig_read_n_points(FILE *file, int n, Point **points, DiaContext *ctx)
int x,y;
Point p;
if (fscanf(file, " %d %d ", &x, &y) != 2) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Error while reading %dth of %d points"), i, n);
+ dia_context_add_message_with_errno (ctx, errno,
+ _("Error while reading %dth of %d points"), i, n);
g_array_free(points_list, TRUE);
return FALSE;
}
@@ -431,8 +431,7 @@ fig_read_ellipse(FILE *file, DiaContext *ctx)
&radius_x, &radius_y,
&start_x, &start_y,
&end_x, &end_y) < 19) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read ellipse info."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read ellipse info."));
setlocale(LC_NUMERIC, old_locale);
return NULL;
}
@@ -501,8 +500,7 @@ fig_read_polyline(FILE *file, DiaContext *ctx)
&forward_arrow,
&backward_arrow,
&npoints) != 15) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read polyline info.\n"));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read polyline info.\n"));
goto exit;
}
@@ -517,8 +515,7 @@ fig_read_polyline(FILE *file, DiaContext *ctx)
if (sub_type == 5) { /* image has image name before npoints */
/* Despite what the specs say */
if (fscanf(file, " %d", &flipped) != 1) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read flipped bit."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read flipped bit."));
goto exit;
}
@@ -730,8 +727,7 @@ fig_read_spline(FILE *file, DiaContext *ctx)
&forward_arrow,
&backward_arrow,
&npoints) != 13) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read spline info."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read spline info."));
goto exit;
}
@@ -763,8 +759,7 @@ fig_read_spline(FILE *file, DiaContext *ctx)
gboolean interpolated = TRUE;
for (i = 0; i < npoints; i++) {
if (fscanf(file, " %lf ", &f) != 1) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read spline info."));
+ dia_context_add_message_with_errno(ctx, errno,_("Couldn't read spline info."));
goto exit;
}
if (f != -1.0 && f != 0.0) {
@@ -872,8 +867,7 @@ fig_read_arc(FILE *file, DiaContext *ctx)
&x1, &y1,
&x2, &y2,
&x3, &y3) != 21) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read arc info."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read arc info."));
goto exit;
}
@@ -971,8 +965,7 @@ fig_read_text(FILE *file, DiaContext *ctx)
&length,
&x,
&y) != 12) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read text info."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read text info."));
setlocale(LC_NUMERIC, old_locale);
return NULL;
}
@@ -1008,7 +1001,6 @@ fig_read_text(FILE *file, DiaContext *ctx)
/* "Default font" - wazzat? */
tprop->attr.font = dia_font_new_from_legacy_name("Times-Roman");
} else if (font < 0 || font >= num_fig_fonts()) {
- 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 {
@@ -1037,8 +1029,7 @@ fig_read_object(FILE *file, DiaContext *ctx)
if (fscanf(file, "%d ", &objecttype) != 1) {
if (!feof(file)) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't identify Fig object."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't identify Fig object."));
}
return FALSE;
}
@@ -1065,8 +1056,7 @@ fig_read_object(FILE *file, DiaContext *ctx)
Color color;
if (fscanf(file, " %d #%xd", &colornumber, &colorvalues) != 2) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read color: %s\n"));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read color: %s\n"));
return FALSE;
}
@@ -1118,8 +1108,7 @@ fig_read_object(FILE *file, DiaContext *ctx)
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) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Couldn't read group extend."));
+ dia_context_add_message_with_errno(ctx, errno, _("Couldn't read group extend."));
return FALSE;
}
/* Group extends don't really matter */
@@ -1165,8 +1154,7 @@ fig_read_paper_size(FILE *file, DiagramData *dia, DiaContext *ctx) {
int paper;
if (!fgets(buf, BUFLEN, file)) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Error reading paper size."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading paper size."));
return FALSE;
}
@@ -1190,7 +1178,6 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
int portrait;
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;
}
@@ -1201,7 +1188,6 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
int justify;
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;
}
@@ -1212,7 +1198,6 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
int units;
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;
}
@@ -1229,8 +1214,7 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
old_locale = setlocale(LC_NUMERIC, "C");
if (fscanf(file, "%lf\n", &mag) != 1) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Error reading magnification."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading magnification."));
setlocale(LC_NUMERIC, old_locale);
return FALSE;
}
@@ -1243,7 +1227,6 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
int multiple;
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;
}
@@ -1255,8 +1238,7 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
int transparent;
if (fscanf(file, "%d\n", &transparent) != 1) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Error reading transparent color."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading transparent color."));
return FALSE;
}
@@ -1265,8 +1247,7 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
if (!skip_comments(file)) {
if (!feof(file)) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Error reading Fig file."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading Fig file."));
} else {
dia_context_add_message(ctx, _("Premature end of Fig file\n"));
}
@@ -1277,8 +1258,7 @@ fig_read_meta_data(FILE *file, DiagramData *dia, DiaContext *ctx)
int resolution, coord_system;
if (fscanf(file, "%d %d\n", &resolution, &coord_system) != 2) {
- dia_context_set_errno(ctx, errno);
- dia_context_add_message(ctx, _("Error reading resolution."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading resolution."));
return FALSE;
}
@@ -1304,18 +1284,17 @@ import_fig(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_
}
figfile = g_fopen(filename,"r");
- if(figfile == NULL){
- dia_context_add_message(ctx, _("Couldn't open: '%s' for reading.\n"),
+ if (figfile == NULL) {
+ dia_context_add_message_with_errno(ctx, errno, _("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) {
-
- dia_context_set_errno (ctx, errno);
- dia_context_add_message(ctx, _("Doesn't look like a Fig file"));
+ sscanf(buf, "#FIG %d.%d\n", &figmajor, &figminor) != 2)
+ {
+ dia_context_add_message_with_errno(ctx, errno, _("Doesn't look like a Fig file"));
fclose(figfile);
return FALSE;
}
@@ -1329,8 +1308,7 @@ import_fig(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_
if (!skip_comments(figfile)) {
if (!feof(figfile)) {
- dia_context_set_errno (ctx, errno);
- dia_context_add_message(ctx, _("Error reading Fig file."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading Fig file."));
} else {
dia_context_add_message(ctx, _("Premature end of Fig file"));
}
@@ -1348,8 +1326,7 @@ import_fig(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_
do {
if (!skip_comments(figfile)) {
if (!feof(figfile)) {
- dia_context_set_errno (ctx, errno);
- dia_context_add_message(ctx, _("Error reading Fig file."));
+ dia_context_add_message_with_errno(ctx, errno, _("Error reading Fig file."));
} else {
break;
}
diff --git a/plug-ins/xslt/xslt.c b/plug-ins/xslt/xslt.c
index 01caad4..92dbbb6 100644
--- a/plug-ins/xslt/xslt.c
+++ b/plug-ins/xslt/xslt.c
@@ -53,9 +53,9 @@ fromxsl_t *xsl_from;
static char *diafilename = NULL;
static char *filename = NULL;
-static void
-export_xslt(DiagramData *data, const gchar *f,
- const gchar *diaf, void* user_data)
+static gboolean
+export_xslt(DiagramData *data, DiaContext *ctx,
+ const gchar *f, const gchar *diaf, void* user_data)
{
if(filename != NULL)
g_free(filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]