diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-12-03 19:02:53 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-12-04 11:12:28 +0000 |
commit | 94ff07fc9d728d97dde159e0c3e6ab80e29e0855 (patch) | |
tree | 2e74ff3d709db87e2e2b27aa501ed46727c054d7 /tikzit/src/gtk/main.m | |
parent | 0d715a7f17b8e5570b42d7802c502e4aa234a3c1 (diff) |
Refactor MainWindow into Application and Window
Basic multiple-window support, but no tools.
Diffstat (limited to 'tikzit/src/gtk/main.m')
-rw-r--r-- | tikzit/src/gtk/main.m | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/tikzit/src/gtk/main.m b/tikzit/src/gtk/main.m index 93aa9e4..9d179ab 100644 --- a/tikzit/src/gtk/main.m +++ b/tikzit/src/gtk/main.m @@ -26,9 +26,15 @@ #import "clipboard.h" #import "logo.h" -#import "MainWindow.h" +#import "Application.h" #import "TikzGraphAssembler.h" +static GOptionEntry entries[] = +{ + //{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL }, + { NULL } +}; + void onUncaughtException(NSException* exception) { NSLog(@"uncaught exception: %@", [exception description]); @@ -39,9 +45,20 @@ int main (int argc, char *argv[]) { [[NSAutoreleasePool alloc] init]; - gtk_init (&argc, &argv); - - NSAutoreleasePool *initPool = [[NSAutoreleasePool alloc] init]; + GError *error = NULL; + GOptionContext *context; + context = g_option_context_new ("[FILES] - PGF/TikZ-based graph editor"); + g_option_context_add_main_entries (context, entries, NULL); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + if (!g_option_context_parse (context, &argc, &argv, &error)) + { + if (error->domain == G_OPTION_ERROR) { + g_print ("%s\nUse --help to see available options\n", error->message); + } else { + g_print ("Unexpected error parsing options: %s\n", error->message); + } + exit (1); + } #ifndef WINDOWS GList *icon_list = NULL; @@ -59,15 +76,29 @@ int main (int argc, char *argv[]) { } #endif + NSAutoreleasePool *initPool = [[NSAutoreleasePool alloc] init]; + clipboard_init(); [TikzGraphAssembler setup]; - MainWindow *window = [[MainWindow alloc] init]; + + Application *app = nil; + if (argc > 1) { + NSMutableArray *files = [NSMutableArray arrayWithCapacity:argc-1]; + for (int i = 1; i < argc; ++i) { + [files insertObject:[NSString stringWithGlibFilename:argv[i]] + atIndex:i-1]; + } + NSLog(@"Files: %@", files); + app = [[Application alloc] initWithFiles:files]; + } else { + app = [[Application alloc] init]; + } [initPool drain]; gtk_main (); - [window saveConfiguration]; + [app saveConfiguration]; return 0; } |