summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2013-03-22 15:59:02 +0000
committerAlex Merry <dev@randomguy3.me.uk>2013-03-22 15:59:02 +0000
commitce114d1100efb2c7635227e2aa1a5b738bc54b1f (patch)
tree8cd0582f01af471540f615ef2e1aab141f6d2a93
parentc27208f7a1051dcd5fa9c042d3eb87ae9a42f28f (diff)
Add "space" shortcut to refresh preview without it grabbing focus
-rw-r--r--tikzit/src/gtk/Application.h12
-rw-r--r--tikzit/src/gtk/Application.m19
-rw-r--r--tikzit/src/gtk/GraphEditorPanel.m8
-rw-r--r--tikzit/src/gtk/Menu.m8
4 files changed, 35 insertions, 12 deletions
diff --git a/tikzit/src/gtk/Application.h b/tikzit/src/gtk/Application.h
index e82d2b1..c17a523 100644
--- a/tikzit/src/gtk/Application.h
+++ b/tikzit/src/gtk/Application.h
@@ -129,19 +129,23 @@ extern Application* app;
/**
* Show the dialog for editing preambles.
*/
-- (void) showPreamblesEditor;
+- (void) presentPreamblesEditor;
/**
* Show the context-aware window
*/
-- (void) showContextWindow;
+- (void) presentContextWindow;
/**
* Show or update the preview window.
*/
-- (void) showPreviewForDocument:(TikzDocument*)doc;
+- (void) presentPreviewForDocument:(TikzDocument*)doc;
+/**
+ * Show or update the preview window without it grabbing focus
+ */
+- (void) previewDocument:(TikzDocument*)doc;
/**
* Show the settings dialog.
*/
-- (void) showSettingsDialog;
+- (void) presentSettingsDialog;
/**
* Save the application configuration to permanent storage
diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m
index bfde140..2720bb6 100644
--- a/tikzit/src/gtk/Application.m
+++ b/tikzit/src/gtk/Application.m
@@ -262,7 +262,7 @@ Application* app = nil;
gtk_main_quit();
}
-- (void) showPreamblesEditor {
+- (void) presentPreamblesEditor {
#ifdef HAVE_POPPLER
if (preambleWindow == nil) {
preambleWindow = [[PreambleEditor alloc] initWithPreambles:preambles];
@@ -272,11 +272,11 @@ Application* app = nil;
#endif
}
-- (void) showContextWindow {
+- (void) presentContextWindow {
[contextWindow present];
}
-- (void) showPreviewForDocument:(TikzDocument*)doc {
+- (void) presentPreviewForDocument:(TikzDocument*)doc {
#ifdef HAVE_POPPLER
if (previewWindow == nil) {
previewWindow = [[PreviewWindow alloc] initWithPreambles:preambles config:configFile];
@@ -287,7 +287,18 @@ Application* app = nil;
#endif
}
-- (void) showSettingsDialog {
+- (void) previewDocument:(TikzDocument*)doc {
+#ifdef HAVE_POPPLER
+ if (previewWindow == nil) {
+ previewWindow = [[PreviewWindow alloc] initWithPreambles:preambles config:configFile];
+ //[previewWindow setParentWindow:mainWindow];
+ [previewWindow setDocument:doc];
+ }
+ [previewWindow show];
+#endif
+}
+
+- (void) presentSettingsDialog {
if (settingsDialog == nil) {
settingsDialog = [[SettingsDialog alloc] initWithConfiguration:configFile
andStyleManager:styleManager];
diff --git a/tikzit/src/gtk/GraphEditorPanel.m b/tikzit/src/gtk/GraphEditorPanel.m
index 553f261..a1c63a2 100644
--- a/tikzit/src/gtk/GraphEditorPanel.m
+++ b/tikzit/src/gtk/GraphEditorPanel.m
@@ -24,6 +24,8 @@
#import "TikzDocument.h"
#import "WidgetSurface.h"
+#import <gdk/gdkkeysyms.h>
+
@class GraphRenderer;
@class WidgetSurface;
@@ -176,6 +178,9 @@
}
- (void) keyPressed:(unsigned int)keyVal withMask:(InputMask)mask {
+ if (keyVal == GDK_KEY_space && !mask) {
+ return;
+ }
if (![app activateToolForKey:keyVal withMask:mask]) {
id<Tool> tool = [panel activeTool];
if ([panel hasTool] && [tool respondsToSelector:@selector(keyPressed:withMask:)]) {
@@ -185,6 +190,9 @@
}
- (void) keyReleased:(unsigned int)keyVal withMask:(InputMask)mask {
+ if (keyVal == GDK_KEY_space && !mask) {
+ [app previewDocument:[panel document]];
+ }
if (![app activateToolForKey:keyVal withMask:mask]) {
id<Tool> tool = [panel activeTool];
if ([panel hasTool] && [tool respondsToSelector:@selector(keyReleased:withMask:)]) {
diff --git a/tikzit/src/gtk/Menu.m b/tikzit/src/gtk/Menu.m
index 7472f84..83bb2b3 100644
--- a/tikzit/src/gtk/Menu.m
+++ b/tikzit/src/gtk/Menu.m
@@ -55,21 +55,21 @@ static void refresh_shapes_cb (GtkAction *action, Application *appl) {
static void show_preferences_cb (GtkAction *action, Application *appl) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [appl showSettingsDialog];
+ [appl presentSettingsDialog];
[pool drain];
}
#ifdef HAVE_POPPLER
static void show_preamble_cb (GtkAction *action, Application *appl) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [appl showPreamblesEditor];
+ [appl presentPreamblesEditor];
[pool drain];
}
#endif
static void show_context_window_cb (GtkAction *action, Application *appl) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [appl showContextWindow];
+ [appl presentContextWindow];
[pool drain];
}
@@ -316,7 +316,7 @@ static void send_to_back_cb (GtkAction *action, Window *window) {
#ifdef HAVE_POPPLER
static void show_preview_cb (GtkAction *action, Window *window) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [app showPreviewForDocument:[window document]];
+ [app presentPreviewForDocument:[window document]];
[pool drain];
}
#endif