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.
26 #include <diagramdata.h>
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_func
;
38 /* A unique name that this filter can always be addressed as from the
39 * command line. If more than one filter can handle an extension, this
40 * will allow disambiguation. Note that import and export filters are
41 * treated seperately for this.
43 const gchar
*unique_name
;
46 /* returns FALSE on error loading diagram */
47 typedef gboolean (* DiaImportFunc
) (const gchar
*filename
, DiagramData
*dia
,
50 struct _DiaImportFilter
{
51 const gchar
*description
;
52 /* NULL terminated array of extensions for this file format. The first
53 * one is the prefered extension for files of this type. */
54 const gchar
**extensions
;
55 DiaImportFunc import_func
;
57 /* A unique name that this filter can always be addressed as from the
58 * command line. If more than one filter can handle an extension, this
59 * will allow disambiguation. Note that import and export filters are
60 * treated seperately for this.
62 const gchar
*unique_name
;
65 /* gets called as menu callback */
66 typedef void (* DiaCallbackFunc
) (DiagramData
*dia
,
67 guint flags
, /* further additions */
70 struct _DiaCallbackFilter
{
71 const gchar
*description
;
72 const gchar
*menupath
;
73 DiaCallbackFunc callback
;
77 /* register an export filter. The DiaExportFilter should be static, and
78 * none of its fields should be freed */
79 void filter_register_export(DiaExportFilter
*efilter
);
80 /* except - maybe - after unregistering it */
81 void filter_unregister_export(DiaExportFilter
*efilter
);
83 /* returns a sorted list of the export filters. */
84 GList
*filter_get_export_filters(void);
86 /* creates a nice label for the export filter (must be g_free'd) */
87 gchar
*filter_get_export_filter_label(DiaExportFilter
*efilter
);
89 /* guess the filter for a given filename. */
90 DiaExportFilter
*filter_guess_export_filter(const gchar
*filename
);
91 /* Get the filter for the unique filename. */
92 DiaExportFilter
*filter_get_by_name(const gchar
*name
);
94 void filter_register_import(DiaImportFilter
*ifilter
);
95 void filter_unregister_import(DiaImportFilter
*ifilter
);
96 GList
*filter_get_import_filters(void);
97 gchar
*filter_get_import_filter_label(DiaImportFilter
*ifilter
);
98 DiaImportFilter
*filter_guess_import_filter(const gchar
*filename
);
100 void filter_register_callback(DiaCallbackFilter
*cbfilter
);
101 /* returns all registered callbacks */
102 GList
*filter_get_callbacks(void);