From 6dad73c50b6e35e36b955e9b771808226f44f2c8 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 13 Sep 2013 16:52:39 +0200 Subject: Load from command line --- src/colloquium.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/colloquium.c') diff --git a/src/colloquium.c b/src/colloquium.c index 380c67b..1f372d8 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -34,7 +34,7 @@ static void show_help(const char *s) { - printf("Syntax: %s [options]\n\n", s); + printf("Syntax: %s [options] []\n\n", s); printf( "A tiny presentation program.\n" "\n" @@ -46,7 +46,6 @@ static void show_help(const char *s) int main(int argc, char *argv[]) { int c; - struct presentation *p; /* Long options */ const struct option longopts[] = { @@ -74,12 +73,33 @@ int main(int argc, char *argv[]) } - p = new_presentation(); - p->cur_edit_slide = add_slide(p, 0); - p->completely_empty = 1; - if ( open_mainwindow(p) ) { - fprintf(stderr, "Couldn't open main window.\n"); - return 1; + if ( optind == argc ) { + + struct presentation *p; + + p = new_presentation(); + p->cur_edit_slide = add_slide(p, 0); + p->completely_empty = 1; + if ( open_mainwindow(p) ) { + fprintf(stderr, "Couldn't open main window.\n"); + return 1; + } + } + + while ( optind < argc ) { + + char *filename; + struct presentation *p; + + filename = argv[optind++]; + + p = new_presentation(); + if ( load_presentation(p, filename) ) { + fprintf(stderr, "Failed to open presentation"); + } else { + open_mainwindow(p); + } + } gtk_main(); -- cgit v1.2.3