diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-08-15 21:25:57 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-08-15 21:25:57 +0200 |
commit | 008fde3497c1669f516d6b43f5effd34258b1213 (patch) | |
tree | a781277a73b379cfc8a01b941eef2f5209f9b46e /src/loadsave.c | |
parent | b821d554b526f478bffee3dbdea73aa14081ce03 (diff) |
Add loading and saving stuff
Diffstat (limited to 'src/loadsave.c')
-rw-r--r-- | src/loadsave.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/loadsave.c b/src/loadsave.c new file mode 100644 index 0000000..27476a0 --- /dev/null +++ b/src/loadsave.c @@ -0,0 +1,102 @@ +/* + * loadsave.v + * + * Colloquium - A tiny presentation program + * + * Copyright (c) 2011 Thomas White <taw@bitwiz.org.uk> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + + +#include "presentation.h" +#include "objects.h" +#include "stylesheet.h" + + +int load_presentation(struct presentation *p, const char *filename) +{ + return 0; +} + + +static const char *type_text(enum objtype t) +{ + switch ( t ) + { + case TEXT : return "text"; + default : return "unknown"; + } +} + + +static void write_stylesheet(StyleSheet *ss, FILE *fh) +{ +} + + +int save_presentation(struct presentation *p, const char *filename) +{ + FILE *fh; + int i; + + fh = fopen(filename, "w"); + if ( fh == NULL ) return 1; + + fprintf(fh, "# Colloquium presentation file\n"); + fprintf(fh, "version=0\n"); + + write_stylesheet(p->ss, fh); + + for ( i=0; i<p->num_slides; i++ ) { + + int j; + struct slide *s; + + s = p->slides[i]; + + fprintf(fh, "++slide\n"); + fprintf(fh, "width=%.2f\n", s->slide_width); + fprintf(fh, "height=%.2f\n", s->slide_height); + + for ( j=0; j<s->num_objects; j++ ) { + + struct object *o; + + o = s->objects[j]; + + if ( o->empty ) continue; + + fprintf(fh, "++object\n"); + fprintf(fh, "type=%s\n", type_text(o->type)); + fprintf(fh, "x=%.2f\n", o->x); + fprintf(fh, "y=%.2f\n", o->y); + fprintf(fh, "w=%.2f\n", o->bb_width); + fprintf(fh, "h=%.2f\n", o->bb_height); + fprintf(fh, "--object\n"); + } + + fprintf(fh, "--slide\n"); + + } + + fclose(fh); + return 0; +} |