summaryrefslogtreecommitdiff
path: root/tikzit/src/gtk/Application.m
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2012-12-06 18:03:26 +0000
committerAlex Merry <dev@randomguy3.me.uk>2012-12-06 18:03:26 +0000
commit7aa6eda371eea746792dce412b97ed9799e3467e (patch)
treea4cd39419ef50345e8700f625066d42736a2bd9d /tikzit/src/gtk/Application.m
parentf23a2d9daa1eb62b2afac8997f1d76eb881628f7 (diff)
Add a toolbox
Just allows selecting tools, so far - no tool configuration.
Diffstat (limited to 'tikzit/src/gtk/Application.m')
-rw-r--r--tikzit/src/gtk/Application.m31
1 files changed, 30 insertions, 1 deletions
diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m
index ac6a451..38ef231 100644
--- a/tikzit/src/gtk/Application.m
+++ b/tikzit/src/gtk/Application.m
@@ -32,6 +32,7 @@
#import "StyleManager+Storage.h"
#import "SupportDir.h"
#import "TikzDocument.h"
+#import "ToolBox.h"
#import "Window.h"
#import "BoundingBoxTool.h"
@@ -47,6 +48,7 @@ Application* app = nil;
@interface Application (Notifications)
- (void) windowClosed:(NSNotification*)notification;
+- (void) selectedToolChanged:(NSNotification*)notification;
@end
@implementation Application
@@ -107,9 +109,18 @@ Application* app = nil;
[BoundingBoxTool tool],
[HandTool tool],
nil];
+ for (id<Tool> tool in tools) {
+ [tool loadConfiguration:configFile];
+ }
activeTool = [[tools objectAtIndex:0] retain];
- // FIXME: toolboxes
+ toolBox = [[ToolBox alloc] initWithTools:tools];
+ [toolBox loadConfiguration:configFile];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(selectedToolChanged:)
+ name:@"ToolSelectionChanged"
+ object:toolBox];
app = [self retain];
}
@@ -164,12 +175,18 @@ Application* app = nil;
[openWindows release];
[tools release];
[activeTool release];
+ [toolBox release];
[super dealloc];
}
- (id<Tool>) activeTool { return activeTool; }
- (void) setActiveTool:(id<Tool>)tool {
+ if (activeTool == tool)
+ return;
+
+ activeTool = tool;
+ [toolBox setSelectedTool:tool];
for (Window* window in openWindows) {
[window setActiveTool:tool];
}
@@ -258,6 +275,11 @@ Application* app = nil;
[styleManager saveStylesUsingConfigurationName:@"styles"];
+ for (id<Tool> tool in tools) {
+ [tool saveConfiguration:configFile];
+ }
+ [toolBox saveConfiguration:configFile];
+
if (lastOpenFolder != nil) {
[configFile setStringEntry:@"lastOpenFolder" inGroup:@"Paths" value:lastOpenFolder];
}
@@ -283,6 +305,13 @@ Application* app = nil;
gtk_main_quit();
}
}
+- (void) selectedToolChanged:(NSNotification*)n {
+ id<Tool> tool = [[n userInfo] objectForKey:@"tool"];
+ if (tool != nil)
+ [self setActiveTool:tool];
+ else
+ NSLog(@"nil tool!");
+}
@end
// vim:ft=objc:ts=8:et:sts=4:sw=4:foldmethod=marker