From 2dd42d84ee66360c7713c9c86ca6b86f0c4a3b09 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 7 Dec 2012 17:52:42 +0000 Subject: Present windows if already shown Also, allow the properties window to be hidden and shown --- tikzit/src/gtk/Application.h | 4 ++++ tikzit/src/gtk/Application.m | 14 ++++++++++---- tikzit/src/gtk/Menu.m | 10 ++++++++++ tikzit/src/gtk/PreambleEditor.h | 1 + tikzit/src/gtk/PreambleEditor.m | 6 ++++++ tikzit/src/gtk/PreviewWindow.h | 1 + tikzit/src/gtk/PreviewWindow.m | 8 ++++++++ tikzit/src/gtk/PropertiesWindow.h | 6 ++++-- tikzit/src/gtk/PropertiesWindow.m | 19 ++++++++++++++++--- tikzit/src/gtk/SettingsDialog.h | 1 + tikzit/src/gtk/SettingsDialog.m | 6 ++++++ tikzit/src/gtk/ToolBox.h | 2 ++ tikzit/src/gtk/ToolBox.m | 4 ++++ tikzit/src/gtk/Window.h | 5 +++++ tikzit/src/gtk/Window.m | 4 ++++ 15 files changed, 82 insertions(+), 9 deletions(-) diff --git a/tikzit/src/gtk/Application.h b/tikzit/src/gtk/Application.h index f412a67..1e5ab97 100644 --- a/tikzit/src/gtk/Application.h +++ b/tikzit/src/gtk/Application.h @@ -129,6 +129,10 @@ extern Application* app; * Show the dialog for editing preambles. */ - (void) showPreamblesEditor; +/** + * Show the property editor pane + */ +- (void) showPropertyEditor; /** * Show or update the preview window. */ diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m index 9f5fba5..4096fe9 100644 --- a/tikzit/src/gtk/Application.m +++ b/tikzit/src/gtk/Application.m @@ -125,7 +125,7 @@ Application* app = nil; object:toolBox]; propertiesWindow = [[PropertiesWindow alloc] init]; - [propertiesWindow setVisible:YES]; + [propertiesWindow loadConfiguration:configFile]; app = [self retain]; } @@ -241,10 +241,14 @@ Application* app = nil; preambleWindow = [[PreambleEditor alloc] initWithPreambles:preambles]; //[preambleWindow setParentWindow:mainWindow]; } - [preambleWindow show]; + [preambleWindow present]; #endif } +- (void) showPropertyEditor { + [propertiesWindow present]; +} + - (void) showPreviewForDocument:(TikzDocument*)doc { #ifdef HAVE_POPPLER if (previewWindow == nil) { @@ -252,7 +256,7 @@ Application* app = nil; //[previewWindow setParentWindow:mainWindow]; [previewWindow setDocument:doc]; } - [previewWindow show]; + [previewWindow present]; #endif } @@ -262,7 +266,7 @@ Application* app = nil; settingsDialog = [[SettingsDialog alloc] initWithConfiguration:configFile]; //[settingsDialog setParentWindow:mainWindow]; } - [settingsDialog show]; + [settingsDialog present]; #endif } @@ -290,6 +294,8 @@ Application* app = nil; } [toolBox saveConfiguration:configFile]; + [propertiesWindow saveConfiguration:configFile]; + if (lastOpenFolder != nil) { [configFile setStringEntry:@"lastOpenFolder" inGroup:@"Paths" value:lastOpenFolder]; } diff --git a/tikzit/src/gtk/Menu.m b/tikzit/src/gtk/Menu.m index 4652599..e6b87fe 100644 --- a/tikzit/src/gtk/Menu.m +++ b/tikzit/src/gtk/Menu.m @@ -67,6 +67,12 @@ static void show_preamble_cb (GtkAction *action, Application *appl) { } #endif +static void show_properties_cb (GtkAction *action, Application *appl) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [appl showPropertyEditor]; + [pool drain]; +} + static void quit_cb (GtkAction *action, Application *appl) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [appl quit]; @@ -154,6 +160,9 @@ static GtkActionEntry app_action_entries[] = { N_("Edit the preambles used to generate the preview"), G_CALLBACK (show_preamble_cb) }, #endif + { "ShowProperties", NULL, N_("_Properties Window"), NULL, + N_("Show the property editor window"), G_CALLBACK (show_properties_cb) }, + /* HelpMenu */ { "HelpManual", GTK_STOCK_HELP, N_("_Online manual"), "F1", N_("TikZiT manual (online)"), G_CALLBACK (help_cb) }, @@ -500,6 +509,7 @@ static const gchar ui_info[] = #endif " " " " +" " #ifdef HAVE_POPPLER " " " " diff --git a/tikzit/src/gtk/PreambleEditor.h b/tikzit/src/gtk/PreambleEditor.h index b081e00..f181446 100644 --- a/tikzit/src/gtk/PreambleEditor.h +++ b/tikzit/src/gtk/PreambleEditor.h @@ -40,6 +40,7 @@ - (Preambles*) preambles; +- (void) present; - (void) show; - (void) hide; - (BOOL) isVisible; diff --git a/tikzit/src/gtk/PreambleEditor.m b/tikzit/src/gtk/PreambleEditor.m index 2c292f5..feae6a5 100644 --- a/tikzit/src/gtk/PreambleEditor.m +++ b/tikzit/src/gtk/PreambleEditor.m @@ -116,6 +116,12 @@ static void preamble_selection_changed_cb (GtkTreeSelection *treeselection, } } +- (void) present { + [self loadUi]; + gtk_window_present (GTK_WINDOW (window)); + [self revert]; +} + - (void) show { [self loadUi]; gtk_widget_show (GTK_WIDGET (window)); diff --git a/tikzit/src/gtk/PreviewWindow.h b/tikzit/src/gtk/PreviewWindow.h index ca6b30c..8bcd3e5 100644 --- a/tikzit/src/gtk/PreviewWindow.h +++ b/tikzit/src/gtk/PreviewWindow.h @@ -40,6 +40,7 @@ - (BOOL) update; +- (void) present; - (void) show; - (void) hide; - (BOOL) isVisible; diff --git a/tikzit/src/gtk/PreviewWindow.m b/tikzit/src/gtk/PreviewWindow.m index 5443e8d..c5f138a 100644 --- a/tikzit/src/gtk/PreviewWindow.m +++ b/tikzit/src/gtk/PreviewWindow.m @@ -83,6 +83,14 @@ [previewer setDocument:doc]; } +- (void) present { + if ([self updateOrShowError]) { + [self updateDefaultSize]; + gtk_window_present (GTK_WINDOW (window)); + [surface invalidate]; + } +} + - (BOOL) update { if ([self updateOrShowError]) { [self updateDefaultSize]; diff --git a/tikzit/src/gtk/PropertiesWindow.h b/tikzit/src/gtk/PropertiesWindow.h index e5485cf..3f4cce4 100644 --- a/tikzit/src/gtk/PropertiesWindow.h +++ b/tikzit/src/gtk/PropertiesWindow.h @@ -58,8 +58,10 @@ - (id) init; -- (void) restoreUiStateFromConfig:(Configuration*)file group:(NSString*)group; -- (void) saveUiStateToConfig:(Configuration*)file group:(NSString*)group; +- (void) present; + +- (void) loadConfiguration:(Configuration*)config; +- (void) saveConfiguration:(Configuration*)config; @end diff --git a/tikzit/src/gtk/PropertiesWindow.m b/tikzit/src/gtk/PropertiesWindow.m index 7ae592b..cc0f017 100644 --- a/tikzit/src/gtk/PropertiesWindow.m +++ b/tikzit/src/gtk/PropertiesWindow.m @@ -16,8 +16,11 @@ */ #import "PropertiesWindow.h" + +#import "Configuration.h" #import "PropertyListEditor.h" #import "GraphElementProperty.h" + #import "gtkhelpers.h" // {{{ Internal interfaces @@ -243,10 +246,20 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan gtk_widget_set_visible (window, visible); } -- (void) restoreUiStateFromConfig:(Configuration*)file group:(NSString*)group { +- (void) present { + gtk_window_present (GTK_WINDOW (window)); +} + +- (void) loadConfiguration:(Configuration*)config { + [self setVisible:[config booleanEntry:@"visible" + inGroup:@"PropertiesWindow" + withDefault:YES]]; } -- (void) saveUiStateToConfig:(Configuration*)file group:(NSString*)group { +- (void) saveConfiguration:(Configuration*)config { + [config setBooleanEntry:@"visible" + inGroup:@"PropertiesWindow" + value:[self visible]]; } @end @@ -518,7 +531,7 @@ static GtkWidget *createPropsPaneWithLabelEntry (PropertyListEditor *props, GtkE static gboolean props_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, PropertiesWindow *window) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - //[window setVisible:NO]; + [window setVisible:NO]; [pool drain]; return TRUE; } diff --git a/tikzit/src/gtk/SettingsDialog.h b/tikzit/src/gtk/SettingsDialog.h index a159afb..d937774 100644 --- a/tikzit/src/gtk/SettingsDialog.h +++ b/tikzit/src/gtk/SettingsDialog.h @@ -36,6 +36,7 @@ - (void) setParentWindow:(GtkWindow*)parent; +- (void) present; - (void) show; - (void) hide; - (BOOL) isVisible; diff --git a/tikzit/src/gtk/SettingsDialog.m b/tikzit/src/gtk/SettingsDialog.m index aa5517f..11a0d0d 100644 --- a/tikzit/src/gtk/SettingsDialog.m +++ b/tikzit/src/gtk/SettingsDialog.m @@ -82,6 +82,12 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) } } +- (void) present { + [self loadUi]; + [self revert]; + gtk_window_present (GTK_WINDOW (window)); +} + - (void) show { [self loadUi]; [self revert]; diff --git a/tikzit/src/gtk/ToolBox.h b/tikzit/src/gtk/ToolBox.h index 6d1045a..881dd24 100644 --- a/tikzit/src/gtk/ToolBox.h +++ b/tikzit/src/gtk/ToolBox.h @@ -33,6 +33,8 @@ - (id) initWithTools:(NSArray*)tools; +- (void) present; + - (void) loadConfiguration:(Configuration*)config; - (void) saveConfiguration:(Configuration*)config; @end diff --git a/tikzit/src/gtk/ToolBox.m b/tikzit/src/gtk/ToolBox.m index 837c5f9..0a963fd 100644 --- a/tikzit/src/gtk/ToolBox.m +++ b/tikzit/src/gtk/ToolBox.m @@ -174,6 +174,10 @@ static void unretain (gpointer data); [self _setToolWidget:[tool configurationWidget]]; } +- (void) present { + gtk_window_present (GTK_WINDOW (window)); +} + - (void) loadConfiguration:(Configuration*)config { } diff --git a/tikzit/src/gtk/Window.h b/tikzit/src/gtk/Window.h index 089cc49..0e8ccdc 100644 --- a/tikzit/src/gtk/Window.h +++ b/tikzit/src/gtk/Window.h @@ -70,6 +70,11 @@ - (id) initWithDocument:(TikzDocument*)doc; + (id) windowWithDocument:(TikzDocument*)doc; +/** + * Present the window to the user + */ +- (void) present; + /** * Open a file, asking the user which file to open */ diff --git a/tikzit/src/gtk/Window.m b/tikzit/src/gtk/Window.m index 1856b9d..c7f98ff 100644 --- a/tikzit/src/gtk/Window.m +++ b/tikzit/src/gtk/Window.m @@ -173,6 +173,10 @@ static void update_paste_action (GtkClipboard *clipboard, GdkEvent *event, GtkAc } } +- (void) present { + gtk_window_present (GTK_WINDOW (window)); +} + - (void) openFile { FileChooserDialog *dialog = [FileChooserDialog openDialogWithParent:window]; [dialog addStandardFilters]; -- cgit v1.2.3