diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-12-17 17:51:10 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-12-17 18:00:22 +0000 |
commit | 5ac1d383d2a89d22fbf54d688d64bf6a1036df6b (patch) | |
tree | 4633a52220e18eb0be7db5bae90d7b6e286c4d38 /tikzit | |
parent | 410fdf146246e014f1598e1880b5326e75159c43 (diff) |
Factor out properties pane from properties window
PropertiesWindow is now ContextWindow.
Preparing for putting more stuff in this window.
Diffstat (limited to 'tikzit')
-rw-r--r-- | tikzit/src/Makefile.am | 3 | ||||
-rw-r--r-- | tikzit/src/gtk/Application.h | 8 | ||||
-rw-r--r-- | tikzit/src/gtk/Application.m | 19 | ||||
-rw-r--r-- | tikzit/src/gtk/ContextWindow.h | 48 | ||||
-rw-r--r-- | tikzit/src/gtk/ContextWindow.m | 151 | ||||
-rw-r--r-- | tikzit/src/gtk/Menu.m | 10 | ||||
-rw-r--r-- | tikzit/src/gtk/PropertiesPane.h (renamed from tikzit/src/gtk/PropertiesWindow.h) | 29 | ||||
-rw-r--r-- | tikzit/src/gtk/PropertiesPane.m (renamed from tikzit/src/gtk/PropertiesWindow.m) | 140 |
8 files changed, 301 insertions, 107 deletions
diff --git a/tikzit/src/Makefile.am b/tikzit/src/Makefile.am index 276723d..6890928 100644 --- a/tikzit/src/Makefile.am +++ b/tikzit/src/Makefile.am @@ -30,6 +30,7 @@ tikzit_SOURCES = gtk/Application.m \ gtk/ColorRGB+IntegerListStorage.m \ gtk/ColorRGB+Gtk.m \ gtk/Configuration.m \ + gtk/ContextWindow.m \ gtk/CreateEdgeTool.m \ gtk/CreateNodeTool.m \ gtk/Edge+Render.m \ @@ -54,7 +55,7 @@ tikzit_SOURCES = gtk/Application.m \ gtk/NSError+Glib.m \ gtk/NSFileManager+Glib.m \ gtk/NSString+Glib.m \ - gtk/PropertiesWindow.m \ + gtk/PropertiesPane.m \ gtk/PropertyListEditor.m \ gtk/RecentManager.m \ gtk/SelectTool.m \ diff --git a/tikzit/src/gtk/Application.h b/tikzit/src/gtk/Application.h index eb9dbbf..b364c5e 100644 --- a/tikzit/src/gtk/Application.h +++ b/tikzit/src/gtk/Application.h @@ -20,10 +20,10 @@ @class Application; @class Configuration; +@class ContextWindow; @class Preambles; @class PreambleEditor; @class PreviewWindow; -@class PropertiesWindow; @class SettingsDialog; @class StyleManager; @class TikzDocument; @@ -50,7 +50,7 @@ extern Application* app; ToolBox *toolBox; PreambleEditor *preambleWindow; PreviewWindow *previewWindow; - PropertiesWindow *propertiesWindow; + ContextWindow *contextWindow; SettingsDialog *settingsDialog; // the open windows (array of Window*) @@ -131,9 +131,9 @@ extern Application* app; */ - (void) showPreamblesEditor; /** - * Show the property editor pane + * Show the context-aware window */ -- (void) showPropertyEditor; +- (void) showContextWindow; /** * Show or update the preview window. */ diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m index a7f1824..cdf4b4e 100644 --- a/tikzit/src/gtk/Application.m +++ b/tikzit/src/gtk/Application.m @@ -21,7 +21,7 @@ #import "EdgeStylesModel.h" #import "NodeStylesModel.h" #import "PreambleEditor.h" -#import "PropertiesWindow.h" +#import "ContextWindow.h" #import "Shape.h" #import "StyleManager.h" #import "StyleManager+Storage.h" @@ -134,8 +134,9 @@ Application* app = nil; object:toolBox]; [toolBox show]; - propertiesWindow = [[PropertiesWindow alloc] init]; - [propertiesWindow loadConfiguration:configFile]; + contextWindow = [[ContextWindow alloc] initWithNodeStylesModel:nsm + andEdgeStylesModel:esm]; + [contextWindow loadConfiguration:configFile]; app = [self retain]; } @@ -191,7 +192,7 @@ Application* app = nil; [tools release]; [activeTool release]; [toolBox release]; - [propertiesWindow release]; + [contextWindow release]; [super dealloc]; } @@ -270,8 +271,8 @@ Application* app = nil; #endif } -- (void) showPropertyEditor { - [propertiesWindow present]; +- (void) showContextWindow { + [contextWindow present]; } - (void) showPreviewForDocument:(TikzDocument*)doc { @@ -319,7 +320,7 @@ Application* app = nil; } [toolBox saveConfiguration:configFile]; - [propertiesWindow saveConfiguration:configFile]; + [contextWindow saveConfiguration:configFile]; if (lastOpenFolder != nil) { [configFile setStringEntry:@"lastOpenFolder" inGroup:@"Paths" value:lastOpenFolder]; @@ -361,7 +362,7 @@ Application* app = nil; } - (void) windowDocumentChanged:(NSNotification*)n { - [propertiesWindow setDocument:[[n userInfo] objectForKey:@"document"]]; + [contextWindow setDocument:[[n userInfo] objectForKey:@"document"]]; } @end @@ -371,7 +372,7 @@ Application* app = nil; name:@"DocumentChanged" object:nil]; - [propertiesWindow setDocument:[window document]]; + [contextWindow setDocument:[window document]]; [[NSNotificationCenter defaultCenter] addObserver:self diff --git a/tikzit/src/gtk/ContextWindow.h b/tikzit/src/gtk/ContextWindow.h new file mode 100644 index 0000000..7662fe4 --- /dev/null +++ b/tikzit/src/gtk/ContextWindow.h @@ -0,0 +1,48 @@ +/* + * Copyright 2011-2012 Alex Merry <dev@randomguy3.me.uk> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#import "TZFoundation.h" +#import <gtk/gtk.h> + +@class Configuration; +@class EdgeStylesModel; +@class NodeStylesModel; +@class PropertiesPane; +@class StyleManager; +@class TikzDocument; + +@interface ContextWindow: NSObject { + GtkWidget *window; + GtkWidget *layout; + PropertiesPane *propsPane; +} + +@property (retain) TikzDocument *document; +@property (assign) BOOL visible; + +- (id) initWithStyleManager:(StyleManager*)mgr; +- (id) initWithNodeStylesModel:(NodeStylesModel*)nsm + andEdgeStylesModel:(EdgeStylesModel*)esm; + +- (void) present; + +- (void) loadConfiguration:(Configuration*)config; +- (void) saveConfiguration:(Configuration*)config; + +@end + +// vim:ft=objc:ts=8:et:sts=4:sw=4:foldmethod=marker diff --git a/tikzit/src/gtk/ContextWindow.m b/tikzit/src/gtk/ContextWindow.m new file mode 100644 index 0000000..c414bfc --- /dev/null +++ b/tikzit/src/gtk/ContextWindow.m @@ -0,0 +1,151 @@ +/* + * Copyright 2011-2012 Alex Merry <dev@randomguy3.me.uk> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#import "ContextWindow.h" + +#import "Configuration.h" +#import "EdgeStylesModel.h" +#import "NodeStylesModel.h" +#import "PropertiesPane.h" +#import "StyleManager.h" + +#import "gtkhelpers.h" + +static gboolean props_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, ContextWindow *window); + +@implementation ContextWindow + +- (id) init { + [self release]; + return nil; +} + +- (id) initWithStyleManager:(StyleManager*)sm { + return [self initWithNodeStylesModel:[NodeStylesModel modelWithStyleManager:sm] + andEdgeStylesModel:[EdgeStylesModel modelWithStyleManager:sm]]; +} + +- (id) initWithNodeStylesModel:(NodeStylesModel*)nsm + andEdgeStylesModel:(EdgeStylesModel*)esm { + self = [super init]; + + if (self) { + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_object_ref_sink (window); + gtk_window_set_title (GTK_WINDOW (window), "Context"); + gtk_window_set_role (GTK_WINDOW (window), "context"); + gtk_window_set_type_hint (GTK_WINDOW (window), + GDK_WINDOW_TYPE_HINT_UTILITY); + gtk_window_set_default_size (GTK_WINDOW (window), 200, 500); + g_signal_connect (G_OBJECT (window), + "delete-event", + G_CALLBACK (props_window_delete_event_cb), + self); + + layout = gtk_vbox_new (FALSE, 3); + g_object_ref_sink (layout); + gtk_widget_show (layout); + gtk_container_set_border_width (GTK_CONTAINER (layout), 6); + + gtk_container_add (GTK_CONTAINER (window), layout); + + propsPane = [[PropertiesPane alloc] initWithNodeStylesModel:nsm + andEdgeStylesModel:esm]; + gtk_box_pack_start (GTK_BOX (layout), [propsPane gtkWidget], + TRUE, TRUE, 0); + + // hack to position the context window somewhere sensible + // (upper right) + gtk_window_parse_geometry (GTK_WINDOW (window), "-0+0"); + } + + return self; +} + +- (void) dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + g_object_unref (layout); + g_object_unref (window); + + [propsPane release]; + + [super dealloc]; +} + +- (TikzDocument*) document { + return [propsPane document]; +} + +- (void) setDocument:(TikzDocument*)doc { + [propsPane setDocument:doc]; +} + +- (BOOL) visible { + return gtk_widget_get_visible (window); +} + +- (void) setVisible:(BOOL)visible { + gtk_widget_set_visible (window, visible); +} + +- (void) present { + gtk_window_present (GTK_WINDOW (window)); +} + +- (void) loadConfiguration:(Configuration*)config { + [propsPane loadConfiguration:config]; + + if ([config hasGroup:@"ContextWindow"]) { + tz_restore_window (GTK_WINDOW (window), + [config integerEntry:@"x" inGroup:@"ContextWindow"], + [config integerEntry:@"y" inGroup:@"ContextWindow"], + [config integerEntry:@"w" inGroup:@"ContextWindow"], + [config integerEntry:@"h" inGroup:@"ContextWindow"]); + } + [self setVisible:[config booleanEntry:@"visible" + inGroup:@"ContextWindow" + withDefault:YES]]; +} + +- (void) saveConfiguration:(Configuration*)config { + gint x, y, w, h; + + gtk_window_get_position (GTK_WINDOW (window), &x, &y); + gtk_window_get_size (GTK_WINDOW (window), &w, &h); + + [config setIntegerEntry:@"x" inGroup:@"ContextWindow" value:x]; + [config setIntegerEntry:@"y" inGroup:@"ContextWindow" value:y]; + [config setIntegerEntry:@"w" inGroup:@"ContextWindow" value:w]; + [config setIntegerEntry:@"h" inGroup:@"ContextWindow" value:h]; + [config setBooleanEntry:@"visible" + inGroup:@"ContextWindow" + value:[self visible]]; + + [propsPane saveConfiguration:config]; +} + +@end + +static gboolean props_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, ContextWindow *window) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [window setVisible:NO]; + [pool drain]; + return TRUE; +} + +// vim:ft=objc:ts=8:et:sts=4:sw=4:foldmethod=marker diff --git a/tikzit/src/gtk/Menu.m b/tikzit/src/gtk/Menu.m index e6b87fe..a741520 100644 --- a/tikzit/src/gtk/Menu.m +++ b/tikzit/src/gtk/Menu.m @@ -67,9 +67,9 @@ static void show_preamble_cb (GtkAction *action, Application *appl) { } #endif -static void show_properties_cb (GtkAction *action, Application *appl) { +static void show_context_window_cb (GtkAction *action, Application *appl) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [appl showPropertyEditor]; + [appl showContextWindow]; [pool drain]; } @@ -160,8 +160,8 @@ 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) }, + { "ShowContextWindow", NULL, N_("_Context Window"), NULL, + N_("Show the contextual tools window"), G_CALLBACK (show_context_window_cb) }, /* HelpMenu */ { "HelpManual", GTK_STOCK_HELP, N_("_Online manual"), "F1", @@ -509,7 +509,7 @@ static const gchar ui_info[] = #endif " </menu>" " <menu action='ViewMenu'>" -" <menuitem action='ShowProperties'/>" +" <menuitem action='ShowContextWindow'/>" #ifdef HAVE_POPPLER " <menuitem action='ShowPreamble'/>" " <menuitem action='ShowPreview'/>" diff --git a/tikzit/src/gtk/PropertiesWindow.h b/tikzit/src/gtk/PropertiesPane.h index cc4316f..696fd0b 100644 --- a/tikzit/src/gtk/PropertiesWindow.h +++ b/tikzit/src/gtk/PropertiesPane.h @@ -1,5 +1,5 @@ /* - * Copyright 2011 Alex Merry <dev@randomguy3.me.uk> + * Copyright 2011-2012 Alex Merry <dev@randomguy3.me.uk> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,16 +17,19 @@ #import "TZFoundation.h" #import <gtk/gtk.h> -#import "Configuration.h" -#import "TikzDocument.h" -@class PropertyListEditor; +@class Configuration; +@class EdgeNodePropertyDelegate; +@class EdgePropertyDelegate; +@class EdgeStylesModel; @class GraphPropertyDelegate; @class NodePropertyDelegate; -@class EdgePropertyDelegate; -@class EdgeNodePropertyDelegate; +@class NodeStylesModel; +@class PropertyListEditor; +@class StyleManager; +@class TikzDocument; -@interface PropertiesWindow: NSObject { +@interface PropertiesPane: NSObject { TikzDocument *document; BOOL blockUpdates; @@ -40,8 +43,9 @@ EdgePropertyDelegate *edgePropDelegate; EdgeNodePropertyDelegate *edgeNodePropDelegate; - GtkWidget *window; - GtkWidget *propertiesPane; + GtkWidget *layout; + + GtkWidget *currentPropsWidget; // no ref! GtkWidget *graphPropsWidget; GtkWidget *nodePropsWidget; @@ -55,10 +59,11 @@ @property (retain) TikzDocument *document; @property (assign) BOOL visible; +@property (readonly) GtkWidget *gtkWidget; -- (id) init; - -- (void) present; +- (id) initWithStyleManager:(StyleManager*)mgr; +- (id) initWithNodeStylesModel:(NodeStylesModel*)nsm + andEdgeStylesModel:(EdgeStylesModel*)esm; - (void) loadConfiguration:(Configuration*)config; - (void) saveConfiguration:(Configuration*)config; diff --git a/tikzit/src/gtk/PropertiesWindow.m b/tikzit/src/gtk/PropertiesPane.m index 98e4f4b..684668e 100644 --- a/tikzit/src/gtk/PropertiesWindow.m +++ b/tikzit/src/gtk/PropertiesPane.m @@ -1,5 +1,5 @@ /* - * Copyright 2011 Alex Merry <dev@randomguy3.me.uk> + * Copyright 2011-2012 Alex Merry <dev@randomguy3.me.uk> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,11 +15,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#import "PropertiesWindow.h" +#import "PropertiesPane.h" #import "Configuration.h" -#import "PropertyListEditor.h" +#import "EdgeStylesModel.h" #import "GraphElementProperty.h" +#import "NodeStylesModel.h" +#import "PropertyListEditor.h" +#import "StyleManager.h" +#import "TikzDocument.h" #import "gtkhelpers.h" @@ -30,13 +34,12 @@ static GtkWidget *createPropsPaneWithLabelEntry (PropertyListEditor *props, GtkE static GtkWidget *createBoldLabel (const gchar *text); // }}} // {{{ GTK+ callbacks -static gboolean props_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, PropertiesWindow *window); -static void node_label_changed_cb (GtkEditable *widget, PropertiesWindow *pane); -static void edge_node_label_changed_cb (GtkEditable *widget, PropertiesWindow *pane); -static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pane); +static void node_label_changed_cb (GtkEditable *widget, PropertiesPane *pane); +static void edge_node_label_changed_cb (GtkEditable *widget, PropertiesPane *pane); +static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesPane *pane); // }}} -@interface PropertiesWindow (Notifications) +@interface PropertiesPane (Notifications) - (void) nodeSelectionChanged:(NSNotification*)n; - (void) edgeSelectionChanged:(NSNotification*)n; - (void) graphChanged:(NSNotification*)n; @@ -45,7 +48,7 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan - (void) edgeNodeToggled:(BOOL)newValue; @end -@interface PropertiesWindow (Private) +@interface PropertiesPane (Private) - (void) _updatePane; - (void) _setDisplayedWidget:(GtkWidget*)widget; @end @@ -79,9 +82,20 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan // }}} // {{{ API -@implementation PropertiesWindow +@implementation PropertiesPane - (id) init { + [self release]; + return nil; +} + +- (id) initWithStyleManager:(StyleManager*)sm { + return [self initWithNodeStylesModel:[NodeStylesModel modelWithStyleManager:sm] + andEdgeStylesModel:[EdgeStylesModel modelWithStyleManager:sm]]; +} + +- (id) initWithNodeStylesModel:(NodeStylesModel*)nsm + andEdgeStylesModel:(EdgeStylesModel*)esm { self = [super init]; if (self) { @@ -103,24 +117,15 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan edgeNodeProps = [[PropertyListEditor alloc] init]; [edgeNodeProps setDelegate:edgePropDelegate]; - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_object_ref_sink (window); - gtk_window_set_title (GTK_WINDOW (window), "Properties"); - gtk_window_set_role (GTK_WINDOW (window), "properties"); - gtk_window_set_type_hint (GTK_WINDOW (window), - GDK_WINDOW_TYPE_HINT_UTILITY); - gtk_window_set_default_size (GTK_WINDOW (window), 200, 500); - g_signal_connect (G_OBJECT (window), - "delete-event", - G_CALLBACK (props_window_delete_event_cb), - self); + layout = gtk_vbox_new (FALSE, 0); + g_object_ref_sink (layout); + gtk_widget_show (layout); /* * Graph properties */ graphPropsWidget = gtk_vbox_new (FALSE, 6); g_object_ref_sink (graphPropsWidget); - gtk_container_set_border_width (GTK_CONTAINER (graphPropsWidget), 6); gtk_widget_show (graphPropsWidget); GtkWidget *label = createBoldLabel ("Graph properties"); @@ -133,9 +138,10 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan gtk_box_pack_start (GTK_BOX (graphPropsWidget), [graphProps widget], TRUE, TRUE, 0); - gtk_widget_show (graphPropsWidget); - gtk_container_add (GTK_CONTAINER (window), graphPropsWidget); + gtk_box_pack_start (GTK_BOX (layout), + graphPropsWidget, + TRUE, TRUE, 0); /* @@ -143,8 +149,9 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan */ nodePropsWidget = gtk_vbox_new (FALSE, 6); g_object_ref_sink (nodePropsWidget); - gtk_container_set_border_width (GTK_CONTAINER (nodePropsWidget), 6); - gtk_widget_show (nodePropsWidget); + gtk_box_pack_start (GTK_BOX (layout), + nodePropsWidget, + TRUE, TRUE, 0); label = createBoldLabel ("Node properties"); gtk_widget_show (label); @@ -173,8 +180,9 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan */ edgePropsWidget = gtk_vbox_new (FALSE, 6); g_object_ref_sink (edgePropsWidget); - gtk_container_set_border_width (GTK_CONTAINER (edgePropsWidget), 6); - gtk_widget_show (edgePropsWidget); + gtk_box_pack_start (GTK_BOX (layout), + edgePropsWidget, + TRUE, TRUE, 0); label = createBoldLabel ("Edge properties"); gtk_widget_show (label); @@ -215,9 +223,11 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan G_CALLBACK (edge_node_label_changed_cb), self); - // hack to position the props window somewhere sensible - // (upper right) - gtk_window_parse_geometry (GTK_WINDOW (window), "-0+0"); + /* + * Misc setup + */ + + [self _setDisplayedWidget:graphPropsWidget]; } return self; @@ -225,23 +235,29 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [document release]; g_object_unref (graphPropsWidget); g_object_unref (nodePropsWidget); g_object_unref (edgePropsWidget); + g_object_unref (nodeLabelEntry); g_object_unref (edgeNodeToggle); g_object_unref (edgeNodePropsWidget); g_object_unref (edgeNodeLabelEntry); + g_object_unref (layout); + [graphProps release]; [nodeProps release]; [edgeProps release]; [edgeNodeProps release]; + [graphPropDelegate release]; [nodePropDelegate release]; [edgePropDelegate release]; + [edgeNodePropDelegate release]; + + [document release]; [super dealloc]; } @@ -280,50 +296,28 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan } - (BOOL) visible { - return gtk_widget_get_visible (window); + return gtk_widget_get_visible (layout); } - (void) setVisible:(BOOL)visible { - gtk_widget_set_visible (window, visible); + gtk_widget_set_visible (layout, visible); } -- (void) present { - gtk_window_present (GTK_WINDOW (window)); +- (GtkWidget*) gtkWidget { + return layout; } - (void) loadConfiguration:(Configuration*)config { - if ([config hasGroup:@"PropertiesWindow"]) { - tz_restore_window (GTK_WINDOW (window), - [config integerEntry:@"x" inGroup:@"PropertiesWindow"], - [config integerEntry:@"y" inGroup:@"PropertiesWindow"], - [config integerEntry:@"w" inGroup:@"PropertiesWindow"], - [config integerEntry:@"h" inGroup:@"PropertiesWindow"]); - } - [self setVisible:[config booleanEntry:@"visible" - inGroup:@"PropertiesWindow" - withDefault:YES]]; } - (void) saveConfiguration:(Configuration*)config { - gint x, y, w, h; - - gtk_window_get_position (GTK_WINDOW (window), &x, &y); - gtk_window_get_size (GTK_WINDOW (window), &w, &h); - - [config setIntegerEntry:@"x" inGroup:@"PropertiesWindow" value:x]; - [config setIntegerEntry:@"y" inGroup:@"PropertiesWindow" value:y]; - [config setIntegerEntry:@"w" inGroup:@"PropertiesWindow" value:w]; - [config setIntegerEntry:@"h" inGroup:@"PropertiesWindow" value:h]; - [config setBooleanEntry:@"visible" - inGroup:@"PropertiesWindow" - value:[self visible]]; } @end // }}} // {{{ Notifications -@implementation PropertiesWindow (Notifications) +@implementation PropertiesPane (Notifications) - (void) nodeSelectionChanged:(NSNotification*)n { [self _updatePane]; @@ -395,13 +389,15 @@ static void edge_node_toggled_cb (GtkToggleButton *widget, PropertiesWindow *pan // }}} // {{{ Private -@implementation PropertiesWindow (Private) +@implementation PropertiesPane (Private) - (void) _setDisplayedWidget:(GtkWidget*)widget { - GtkWidget *current = gtk_bin_get_child (GTK_BIN (window)); - if (current != widget) { - gtk_container_remove (GTK_CONTAINER (window), current); - gtk_container_add (GTK_CONTAINER (window), widget); + if (currentPropsWidget != widget) { + if (currentPropsWidget) + gtk_widget_hide (currentPropsWidget); + currentPropsWidget = widget; + if (widget) + gtk_widget_show (widget); } } @@ -571,8 +567,7 @@ static GtkWidget *createLabelledEntry (const gchar *labelText, GtkEntry **entry) } static GtkWidget *createPropsPaneWithLabelEntry (PropertyListEditor *props, GtkEntry **labelEntry) { - GtkBox *box = GTK_BOX (gtk_vbox_new (FALSE, 0)); - gtk_box_set_spacing (box, 6); + GtkBox *box = GTK_BOX (gtk_vbox_new (FALSE, 6)); GtkWidget *labelWidget = createLabelledEntry ("Label", labelEntry); gtk_widget_show (labelWidget); @@ -596,14 +591,7 @@ static GtkWidget *createBoldLabel (const gchar *text) { // }}} // {{{ GTK+ callbacks -static gboolean props_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, PropertiesWindow *window) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [window setVisible:NO]; - [pool drain]; - return TRUE; -} - -static void node_label_changed_cb (GtkEditable *editable, PropertiesWindow *pane) { +static void node_label_changed_cb (GtkEditable *editable, PropertiesPane *pane) { if (!gtk_widget_is_sensitive (GTK_WIDGET (editable))) { // clearly wasn't the user editing return; @@ -617,7 +605,7 @@ static void node_label_changed_cb (GtkEditable *editable, PropertiesWindow *pane [pool drain]; } -static void edge_node_label_changed_cb (GtkEditable *editable, PropertiesWindow *pane) { +static void edge_node_label_changed_cb (GtkEditable *editable, PropertiesPane *pane) { if (!gtk_widget_is_sensitive (GTK_WIDGET (editable))) { // clearly wasn't the user editing return; @@ -631,7 +619,7 @@ static void edge_node_label_changed_cb (GtkEditable *editable, PropertiesWindow [pool drain]; } -static void edge_node_toggled_cb (GtkToggleButton *toggle, PropertiesWindow *pane) { +static void edge_node_toggled_cb (GtkToggleButton *toggle, PropertiesPane *pane) { if (!gtk_widget_is_sensitive (GTK_WIDGET (toggle))) { // clearly wasn't the user editing return; |