aboutsummaryrefslogtreecommitdiff
path: root/src/colloquium.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-09-27 00:24:41 +0200
committerThomas White <taw@bitwiz.org.uk>2014-09-27 00:24:41 +0200
commitab6af6b34c9e5fdfa8cff44fa0f78f9c34ed28ef (patch)
tree8b655e9b7befeff6e370b278bd2c20dbb2bf3be3 /src/colloquium.c
parent217a194d10d404d1b78dec1b8ea89cfcc123ac29 (diff)
SCEditor, part I
Diffstat (limited to 'src/colloquium.c')
-rw-r--r--src/colloquium.c141
1 files changed, 98 insertions, 43 deletions
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 <taw@bitwiz.org.uk>
+ * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk>
*
* This file is part of Colloquium.
*
@@ -29,12 +29,95 @@
#include <getopt.h>
#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; i<n_files; i++ ) {
+ struct presentation *p;
+ char *uri = g_file_get_path(files[i]);
+ printf("open %s\n", uri);
+ p = new_presentation();
+ load_presentation(p, uri);
+ narrative_window_new(p, app);
+ g_free(uri);
+ }
+}
+
+typedef struct
+{
+ GtkApplication parent_instance;
+} Colloquium;
+
+typedef GtkApplicationClass ColloquiumClass;
+
+G_DEFINE_TYPE(Colloquium, colloquium, GTK_TYPE_APPLICATION)
+
+static void colloquium_finalize(GObject *object)
+{
+ G_OBJECT_CLASS(colloquium_parent_class)->finalize(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] [<file.clq>]\n\n", s);
+ printf("Syntax: %s [options] [<file.sc>]\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;
}