From ab6af6b34c9e5fdfa8cff44fa0f78f9c34ed28ef Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 27 Sep 2014 00:24:41 +0200 Subject: SCEditor, part I --- src/colloquium.c | 141 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 98 insertions(+), 43 deletions(-) (limited to 'src/colloquium.c') diff --git a/src/colloquium.c b/src/colloquium.c index 1f372d8..ce23be5 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -1,7 +1,7 @@ /* * colloquium.c * - * Copyright © 2013 Thomas White + * Copyright © 2013-2014 Thomas White * * This file is part of Colloquium. * @@ -29,12 +29,95 @@ #include #include "presentation.h" -#include "mainwindow.h" +#include "narrative_window.h" + + +static void colloquium_activate(GApplication *app) +{ + printf("activate!\n"); +} + + +static void colloquium_open(GApplication *app, GFile **files, gint n_files, + const gchar *hint) +{ + int i; + + for ( i = 0; ifinalize(object); +} + + +static void colloquium_startup(GApplication *app) +{ + G_APPLICATION_CLASS(colloquium_parent_class)->startup(app); +} + + +static void colloquium_shutdown(GApplication *app) +{ + G_APPLICATION_CLASS(colloquium_parent_class)->shutdown(app); +} + + +static void colloquium_class_init(ColloquiumClass *class) +{ + GApplicationClass *app_class = G_APPLICATION_CLASS(class); + GObjectClass *object_class = G_OBJECT_CLASS(class); + + app_class->startup = colloquium_startup; + app_class->shutdown = colloquium_shutdown; + app_class->activate = colloquium_activate; + app_class->open = colloquium_open; + + object_class->finalize = colloquium_finalize; +} + + +static void colloquium_init(Colloquium *app) +{ +} + + +static Colloquium *colloquium_new() +{ + Colloquium *app; + + g_type_init(); + g_set_application_name("Colloquium"); + app = g_object_new(colloquium_get_type(), + "application-id", "uk.org.bitwiz.Colloquium", + "flags", G_APPLICATION_HANDLES_OPEN, + "register-session", TRUE, + NULL); + return app; +} 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,6 +129,8 @@ static void show_help(const char *s) int main(int argc, char *argv[]) { int c; + int status; + Colloquium *app; /* Long options */ const struct option longopts[] = { @@ -53,56 +138,26 @@ int main(int argc, char *argv[]) {0, 0, NULL, 0} }; - gtk_init(&argc, &argv); - /* Short options */ - while ((c = getopt_long(argc, argv, "h", - longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "h", longopts, NULL)) != -1) { - switch (c) { - case 'h' : + switch (c) + { + case 'h' : show_help(argv[0]); return 0; - case 0 : + case 0 : break; - default : - 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"); + default : 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(); - - return 0; + app = colloquium_new(); + status = g_application_run(G_APPLICATION(app), argc, argv); + g_object_unref(app); + return status; } -- cgit v1.2.3