From ce114d1100efb2c7635227e2aa1a5b738bc54b1f Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 22 Mar 2013 15:59:02 +0000 Subject: Add "space" shortcut to refresh preview without it grabbing focus --- tikzit/src/gtk/Application.h | 12 ++++++++---- tikzit/src/gtk/Application.m | 19 +++++++++++++++---- tikzit/src/gtk/GraphEditorPanel.m | 8 ++++++++ tikzit/src/gtk/Menu.m | 8 ++++---- 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 + @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 = [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 = [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 -- cgit v1.2.3