#ifdef'd xmlerror.h
[dia.git] / lib / filter.h
blob1698f80f672c091a92ec348ab1b62ee3dd88a507
1 /* Dia -- a diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * filter.h: definitions for adding new loaders and export filters.
5 * Copyright (C) 1999 James Henstridge
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef FILTER_H
22 #define FILTER_H
24 #include <glib.h>
25 #include <diagramdata.h>
27 typedef struct _DiaExportFilter DiaExportFilter;
28 typedef void (* DiaExportFunc) (DiagramData *dia, const gchar *filename,
29 const gchar *diafilename, void* user_data);
31 struct _DiaExportFilter {
32 const gchar *description;
33 /* NULL terminated array of extensions for this file format. The first
34 * one is the prefered extension for files of this type. */
35 const gchar **extensions;
36 DiaExportFunc export;
37 void* user_data;
40 typedef struct _DiaImportFilter DiaImportFilter;
41 /* returns FALSE on error loading diagram */
42 typedef gboolean (* DiaImportFunc) (const gchar *filename, DiagramData *dia,
43 void* user_data);
45 struct _DiaImportFilter {
46 const gchar *description;
47 /* NULL terminated array of extensions for this file format. The first
48 * one is the prefered extension for files of this type. */
49 const gchar **extensions;
50 DiaImportFunc import;
51 void* user_data;
54 typedef struct _DiaCallbackFilter DiaCallbackFilter;
55 /* gets called as menu callback */
56 typedef void (* DiaCallbackFunc) (DiagramData *dia,
57 guint flags, /* further additions */
58 void* user_data);
60 struct _DiaCallbackFilter {
61 const gchar *description;
62 const gchar *menupath;
63 DiaCallbackFunc callback;
64 void* user_data;
67 /* register an export filter. The DiaExportFilter should be static, and
68 * none of its fields should be freed */
69 void filter_register_export(DiaExportFilter *efilter);
71 /* returns a sorted list of the export filters. */
72 GList *filter_get_export_filters(void);
74 /* creates a nice label for the export filter (must be g_free'd) */
75 gchar *filter_get_export_filter_label(DiaExportFilter *efilter);
77 /* guess the filter for a given filename. */
78 DiaExportFilter *filter_guess_export_filter(const gchar *filename);
80 void filter_register_import(DiaImportFilter *ifilter);
81 GList *filter_get_import_filters(void);
82 gchar *filter_get_import_filter_label(DiaImportFilter *ifilter);
83 DiaImportFilter *filter_guess_import_filter(const gchar *filename);
85 void filter_register_callback(DiaCallbackFilter *cbfilter);
86 /* returns all registered callbacks */
87 GList *filter_get_callbacks(void);
89 #endif