summaryrefslogtreecommitdiff
path: root/tikzit/src/gtk/Application.m
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/gtk/Application.m')
-rw-r--r--tikzit/src/gtk/Application.m48
1 files changed, 34 insertions, 14 deletions
diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m
index 2631bb3..ac6a451 100644
--- a/tikzit/src/gtk/Application.m
+++ b/tikzit/src/gtk/Application.m
@@ -27,12 +27,19 @@
#ifdef HAVE_POPPLER
#import "SettingsDialog.h"
#endif
+#import "Shape.h"
#import "StyleManager.h"
#import "StyleManager+Storage.h"
#import "SupportDir.h"
#import "TikzDocument.h"
#import "Window.h"
+#import "BoundingBoxTool.h"
+#import "CreateNodeTool.h"
+#import "CreateEdgeTool.h"
+#import "HandTool.h"
+#import "SelectTool.h"
+
// used for args to g_mkdir_with_parents
#import "stat.h"
@@ -47,7 +54,7 @@ Application* app = nil;
@synthesize mainConfiguration=configFile;
@synthesize styleManager, preambles;
@synthesize lastOpenFolder, lastSaveAsFolder;
-@synthesize activeDocument;
+@synthesize tools;
+ (Application*) app {
if (app == nil) {
@@ -93,6 +100,15 @@ Application* app = nil;
openWindows = [[NSMutableArray alloc] init];
+ tools = [[NSArray alloc] initWithObjects:
+ [SelectTool tool],
+ [CreateNodeTool tool],
+ [CreateEdgeTool tool],
+ [BoundingBoxTool tool],
+ [HandTool tool],
+ nil];
+ activeTool = [[tools objectAtIndex:0] retain];
+
// FIXME: toolboxes
app = [self retain];
@@ -142,23 +158,25 @@ Application* app = nil;
[preambles release];
[lastOpenFolder release];
[lastSaveAsFolder release];
- [activeDocument release];
[preambleWindow release];
[previewWindow release];
[settingsDialog release];
[openWindows release];
+ [tools release];
+ [activeTool release];
[super dealloc];
}
-- (void) newWindow {
- [self newWindowWithDocument:nil];
+- (id<Tool>) activeTool { return activeTool; }
+- (void) setActiveTool:(id<Tool>)tool {
+ for (Window* window in openWindows) {
+ [window setActiveTool:tool];
+ }
}
-- (void) newWindowWithDocument:(TikzDocument*)doc {
- Window *window = (doc == nil)
- ? [Window window]
- : [Window windowWithDocument:doc];
+- (void) _addWindow:(Window*)window {
+ [window setActiveTool:activeTool];
[openWindows addObject:window];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowClosed:)
@@ -167,6 +185,14 @@ Application* app = nil;
// FIXME: focus?
}
+- (void) newWindow {
+ [self _addWindow:[Window window]];
+}
+
+- (void) newWindowWithDocument:(TikzDocument*)doc {
+ [self _addWindow:[Window windowWithDocument:doc]];
+}
+
- (void) quit {
NSMutableArray *unsavedDocs = [NSMutableArray arrayWithCapacity:[openWindows count]];
for (Window *window in openWindows) {
@@ -217,10 +243,6 @@ Application* app = nil;
return configFile;
}
-- (TikzDocument*) activeDocument {
- return activeDocument;
-}
-
- (void) saveConfiguration {
NSError *error = nil;
@@ -259,8 +281,6 @@ Application* app = nil;
object:window];
if ([openWindows count] == 0) {
gtk_main_quit();
- } else if ([[window document] isEqual:activeDocument]) {
- [self setActiveDocument:[[openWindows objectAtIndex:0] document]];
}
}
@end