From fe1b43c7b7c83e392b60ffc71ac29f7e63810f58 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 4 Feb 2013 13:47:58 +0000 Subject: Put node and edge style editors into settings dialog --- tikzit/src/gtk/Application.m | 7 +- tikzit/src/gtk/EdgeStylesPalette.h | 3 - tikzit/src/gtk/EdgeStylesPalette.m | 127 ++++++------------------------------- tikzit/src/gtk/Menu.m | 6 +- tikzit/src/gtk/NodeStylesPalette.h | 3 - tikzit/src/gtk/NodeStylesPalette.m | 126 ++++++------------------------------ tikzit/src/gtk/SettingsDialog.h | 16 +++-- tikzit/src/gtk/SettingsDialog.m | 53 +++++++++++++++- 8 files changed, 106 insertions(+), 235 deletions(-) diff --git a/tikzit/src/gtk/Application.m b/tikzit/src/gtk/Application.m index 61fb85d..4c696a2 100644 --- a/tikzit/src/gtk/Application.m +++ b/tikzit/src/gtk/Application.m @@ -23,6 +23,7 @@ #import "PreambleEditor.h" #import "ContextWindow.h" #import "Shape.h" +#import "SettingsDialog.h" #import "StyleManager.h" #import "StyleManager+Storage.h" #import "SupportDir.h" @@ -34,7 +35,6 @@ #import "Preambles.h" #import "Preambles+Storage.h" #import "PreviewWindow.h" -#import "SettingsDialog.h" #endif #import "BoundingBoxTool.h" @@ -287,13 +287,12 @@ Application* app = nil; } - (void) showSettingsDialog { -#ifdef HAVE_POPPLER if (settingsDialog == nil) { - settingsDialog = [[SettingsDialog alloc] initWithConfiguration:configFile]; + settingsDialog = [[SettingsDialog alloc] initWithConfiguration:configFile + andStyleManager:styleManager]; //[settingsDialog setParentWindow:mainWindow]; } [settingsDialog present]; -#endif } - (Configuration*) mainConfiguration { diff --git a/tikzit/src/gtk/EdgeStylesPalette.h b/tikzit/src/gtk/EdgeStylesPalette.h index a7d715b..c0c6c4b 100644 --- a/tikzit/src/gtk/EdgeStylesPalette.h +++ b/tikzit/src/gtk/EdgeStylesPalette.h @@ -21,10 +21,8 @@ @class StyleManager; @class EdgeStyleSelector; @class EdgeStyleEditor; -@class TikzDocument; @interface EdgeStylesPalette: NSObject { - TikzDocument *document; EdgeStyleSelector *selector; EdgeStyleEditor *editor; @@ -36,7 +34,6 @@ } @property (retain) StyleManager *styleManager; -@property (retain) TikzDocument *document; @property (readonly) GtkWidget *widget; - (id) initWithManager:(StyleManager*)m; diff --git a/tikzit/src/gtk/EdgeStylesPalette.m b/tikzit/src/gtk/EdgeStylesPalette.m index 7e42552..612003f 100644 --- a/tikzit/src/gtk/EdgeStylesPalette.m +++ b/tikzit/src/gtk/EdgeStylesPalette.m @@ -20,20 +20,16 @@ #import "EdgeStyleSelector.h" #import "EdgeStyleEditor.h" #import "StyleManager.h" -#import "TikzDocument.h" // {{{ Internal interfaces // {{{ GTK+ Callbacks static void add_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette); static void remove_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette); -static void apply_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette); -static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette); // }}} // {{{ Notifications @interface EdgeStylesPalette (Notifications) - (void) selectedStyleChanged:(NSNotification*)notification; -- (void) edgeSelectionChanged:(NSNotification*)n; @end // }}} @@ -42,8 +38,6 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette @interface EdgeStylesPalette (Private) - (void) updateButtonState; - (void) removeSelectedStyle; -- (void) applySelectedStyle; -- (void) clearSelectedStyle; @end // }}} @@ -64,35 +58,40 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette self = [super init]; if (self) { - document = nil; selector = [[EdgeStyleSelector alloc] initWithStyleManager:m]; editor = [[EdgeStyleEditor alloc] init]; - palette = gtk_vbox_new (FALSE, 0); - // FIXME: remove this line when we add edge styles + palette = gtk_vbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (palette), 6); - gtk_box_set_spacing (GTK_BOX (palette), 6); g_object_ref_sink (palette); - gtk_box_pack_start (GTK_BOX (palette), [editor widget], FALSE, FALSE, 0); - gtk_widget_show ([editor widget]); + GtkWidget *mainBox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (palette), mainBox, FALSE, FALSE, 0); + gtk_widget_show (mainBox); + + GtkWidget *selectorScroller = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selectorScroller), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); GtkWidget *selectorFrame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (selectorFrame), [selector widget]); - gtk_box_pack_start (GTK_BOX (palette), selectorFrame, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (selectorScroller), [selector widget]); + gtk_container_add (GTK_CONTAINER (selectorFrame), selectorScroller); + gtk_box_pack_start (GTK_BOX (mainBox), selectorFrame, TRUE, TRUE, 0); + gtk_widget_show (selectorScroller); gtk_widget_show (selectorFrame); gtk_widget_show ([selector widget]); - GtkBox *buttonBox = GTK_BOX (gtk_hbox_new(FALSE, 5)); - gtk_box_pack_start (GTK_BOX (palette), GTK_WIDGET (buttonBox), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (mainBox), [editor widget], TRUE, TRUE, 0); + gtk_widget_show ([editor widget]); - GtkBox *bbox1 = GTK_BOX (gtk_hbox_new(FALSE, 0)); - gtk_box_pack_start (buttonBox, GTK_WIDGET (bbox1), FALSE, FALSE, 0); + GtkBox *buttonBox = GTK_BOX (gtk_hbox_new(FALSE, 0)); + gtk_box_pack_start (GTK_BOX (palette), GTK_WIDGET (buttonBox), FALSE, FALSE, 0); GtkWidget *addStyleButton = gtk_button_new (); gtk_widget_set_tooltip_text (addStyleButton, "Add a new style"); GtkWidget *addIcon = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (addStyleButton), addIcon); - gtk_box_pack_start (bbox1, addStyleButton, FALSE, FALSE, 0); + gtk_box_pack_start (buttonBox, addStyleButton, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (addStyleButton), "clicked", G_CALLBACK (add_style_button_cb), @@ -103,33 +102,12 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette gtk_widget_set_tooltip_text (removeStyleButton, "Delete selected style"); GtkWidget *removeIcon = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (removeStyleButton), removeIcon); - gtk_box_pack_start (bbox1, removeStyleButton, FALSE, FALSE, 0); + gtk_box_pack_start (buttonBox, removeStyleButton, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (removeStyleButton), "clicked", G_CALLBACK (remove_style_button_cb), self); - GtkBox *bbox2 = GTK_BOX (gtk_hbox_new(FALSE, 0)); - gtk_box_pack_start (buttonBox, GTK_WIDGET (bbox2), FALSE, FALSE, 0); - - applyStyleButton = gtk_button_new_with_label ("Apply"); - g_object_ref_sink (applyStyleButton); - gtk_widget_set_tooltip_text (applyStyleButton, "Apply style to selected edges"); - gtk_box_pack_start (bbox2, applyStyleButton, FALSE, FALSE, 5); - g_signal_connect (G_OBJECT (applyStyleButton), - "clicked", - G_CALLBACK (apply_style_button_cb), - self); - - clearStyleButton = gtk_button_new_with_label ("Clear"); - g_object_ref_sink (clearStyleButton); - gtk_widget_set_tooltip_text (clearStyleButton, "Clear style from selected edges"); - gtk_box_pack_start (bbox2, clearStyleButton, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (clearStyleButton), - "clicked", - G_CALLBACK (clear_style_button_cb), - self); - gtk_widget_show_all (GTK_WIDGET (buttonBox)); [[NSNotificationCenter defaultCenter] addObserver:self @@ -151,40 +129,14 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette [[selector model] setStyleManager:m]; } -- (TikzDocument*) document { - return document; -} - -- (void) setDocument:(TikzDocument*)doc { - if (document != nil) { - [[NSNotificationCenter defaultCenter] removeObserver:self - name:nil - object:[document pickSupport]]; - } - - [doc retain]; - [document release]; - document = doc; - - if (document != nil) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(edgeSelectionChanged:) - name:@"EdgeSelectionChanged" - object:[document pickSupport]]; - } -} - - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [editor release]; [selector release]; - [document release]; g_object_unref (palette); g_object_unref (removeStyleButton); - g_object_unref (applyStyleButton); - g_object_unref (clearStyleButton); [super dealloc]; } @@ -199,10 +151,6 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette [editor setStyle:[selector selectedStyle]]; [self updateButtonState]; } - -- (void) edgeSelectionChanged:(NSNotification*)n { - [self updateButtonState]; -} @end // }}} @@ -210,11 +158,7 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette @implementation EdgeStylesPalette (Private) - (void) updateButtonState { - gboolean hasEdgeSelection = [[[document pickSupport] selectedEdges] count] > 0; gboolean hasStyleSelection = [selector selectedStyle] != nil; - - gtk_widget_set_sensitive (applyStyleButton, hasEdgeSelection && hasStyleSelection); - gtk_widget_set_sensitive (clearStyleButton, hasEdgeSelection); gtk_widget_set_sensitive (removeStyleButton, hasStyleSelection); } @@ -224,27 +168,6 @@ static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette [[[selector model] styleManager] removeEdgeStyle:style]; } -- (void) applySelectedStyle { - [document startModifyEdges:[[document pickSupport] selectedEdges]]; - - EdgeStyle *style = [selector selectedStyle]; - for (Edge *edge in [[document pickSupport] selectedEdges]) { - [edge setStyle:style]; - } - - [document endModifyEdges]; -} - -- (void) clearSelectedStyle { - [document startModifyEdges:[[document pickSupport] selectedEdges]]; - - for (Edge *edge in [[document pickSupport] selectedEdges]) { - [edge setStyle:nil]; - } - - [document endModifyEdges]; -} - @end // }}} @@ -265,18 +188,6 @@ static void remove_style_button_cb (GtkButton *widget, EdgeStylesPalette *palett [pool drain]; } -static void apply_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [palette applySelectedStyle]; - [pool drain]; -} - -static void clear_style_button_cb (GtkButton *widget, EdgeStylesPalette *palette) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [palette clearSelectedStyle]; - [pool drain]; -} - // }}} // 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 a741520..7472f84 100644 --- a/tikzit/src/gtk/Menu.m +++ b/tikzit/src/gtk/Menu.m @@ -53,13 +53,13 @@ static void refresh_shapes_cb (GtkAction *action, Application *appl) { [pool drain]; } -#ifdef HAVE_POPPLER static void show_preferences_cb (GtkAction *action, Application *appl) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [appl showSettingsDialog]; [pool drain]; } +#ifdef HAVE_POPPLER static void show_preamble_cb (GtkAction *action, Application *appl) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [appl showPreamblesEditor]; @@ -152,10 +152,10 @@ static GtkActionEntry app_action_entries[] = { { "Tool", NULL, N_("_Tool") }, -#ifdef HAVE_POPPLER { "ShowPreferences", GTK_STOCK_PREFERENCES, NULL, NULL, N_("Edit the TikZiT preferences"), G_CALLBACK (show_preferences_cb) }, +#ifdef HAVE_POPPLER { "ShowPreamble", NULL, N_("_Edit Preambles..."), NULL, N_("Edit the preambles used to generate the preview"), G_CALLBACK (show_preamble_cb) }, #endif @@ -503,10 +503,8 @@ static const gchar ui_info[] = " " " " " " -#ifdef HAVE_POPPLER " " " " -#endif " " " " " " diff --git a/tikzit/src/gtk/NodeStylesPalette.h b/tikzit/src/gtk/NodeStylesPalette.h index 0185857..ac712ea 100644 --- a/tikzit/src/gtk/NodeStylesPalette.h +++ b/tikzit/src/gtk/NodeStylesPalette.h @@ -21,10 +21,8 @@ @class StyleManager; @class NodeStyleSelector; @class NodeStyleEditor; -@class TikzDocument; @interface NodeStylesPalette: NSObject { - TikzDocument *document; NodeStyleSelector *selector; NodeStyleEditor *editor; @@ -36,7 +34,6 @@ } @property (retain) StyleManager *styleManager; -@property (retain) TikzDocument *document; @property (readonly) GtkWidget *widget; - (id) initWithManager:(StyleManager*)m; diff --git a/tikzit/src/gtk/NodeStylesPalette.m b/tikzit/src/gtk/NodeStylesPalette.m index 23ca7ea..37e6077 100644 --- a/tikzit/src/gtk/NodeStylesPalette.m +++ b/tikzit/src/gtk/NodeStylesPalette.m @@ -20,20 +20,16 @@ #import "NodeStyleSelector.h" #import "NodeStyleEditor.h" #import "StyleManager.h" -#import "TikzDocument.h" // {{{ Internal interfaces // {{{ GTK+ Callbacks static void add_style_button_cb (GtkButton *widget, NodeStylesPalette *palette); static void remove_style_button_cb (GtkButton *widget, NodeStylesPalette *palette); -static void apply_style_button_cb (GtkButton *widget, NodeStylesPalette *palette); -static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette); // }}} // {{{ Notifications @interface NodeStylesPalette (Notifications) - (void) selectedStyleChanged:(NSNotification*)notification; -- (void) nodeSelectionChanged:(NSNotification*)n; @end // }}} @@ -42,8 +38,6 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette @interface NodeStylesPalette (Private) - (void) updateButtonState; - (void) removeSelectedStyle; -- (void) applySelectedStyle; -- (void) clearSelectedStyle; @end // }}} @@ -64,33 +58,40 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette self = [super init]; if (self) { - document = nil; selector = [[NodeStyleSelector alloc] initWithStyleManager:m]; editor = [[NodeStyleEditor alloc] init]; - palette = gtk_vbox_new (FALSE, 0); - gtk_box_set_spacing (GTK_BOX (palette), 6); + palette = gtk_vbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (palette), 6); g_object_ref_sink (palette); - gtk_box_pack_start (GTK_BOX (palette), [editor widget], FALSE, FALSE, 0); - gtk_widget_show ([editor widget]); + GtkWidget *mainBox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (palette), mainBox, FALSE, FALSE, 0); + gtk_widget_show (mainBox); + + GtkWidget *selectorScroller = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selectorScroller), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); GtkWidget *selectorFrame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (selectorFrame), [selector widget]); - gtk_box_pack_start (GTK_BOX (palette), selectorFrame, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (selectorScroller), [selector widget]); + gtk_container_add (GTK_CONTAINER (selectorFrame), selectorScroller); + gtk_box_pack_start (GTK_BOX (mainBox), selectorFrame, TRUE, TRUE, 0); + gtk_widget_show (selectorScroller); gtk_widget_show (selectorFrame); gtk_widget_show ([selector widget]); - GtkBox *buttonBox = GTK_BOX (gtk_hbox_new(FALSE, 5)); - gtk_box_pack_start (GTK_BOX (palette), GTK_WIDGET (buttonBox), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (mainBox), [editor widget], TRUE, TRUE, 0); + gtk_widget_show ([editor widget]); - GtkBox *bbox1 = GTK_BOX (gtk_hbox_new(FALSE, 0)); - gtk_box_pack_start (buttonBox, GTK_WIDGET (bbox1), FALSE, FALSE, 0); + GtkBox *buttonBox = GTK_BOX (gtk_hbox_new(FALSE, 0)); + gtk_box_pack_start (GTK_BOX (palette), GTK_WIDGET (buttonBox), FALSE, FALSE, 0); GtkWidget *addStyleButton = gtk_button_new (); gtk_widget_set_tooltip_text (addStyleButton, "Add a new style"); GtkWidget *addIcon = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (addStyleButton), addIcon); - gtk_box_pack_start (bbox1, addStyleButton, FALSE, FALSE, 0); + gtk_box_pack_start (buttonBox, addStyleButton, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (addStyleButton), "clicked", G_CALLBACK (add_style_button_cb), @@ -101,33 +102,12 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette gtk_widget_set_tooltip_text (removeStyleButton, "Delete selected style"); GtkWidget *removeIcon = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (removeStyleButton), removeIcon); - gtk_box_pack_start (bbox1, removeStyleButton, FALSE, FALSE, 0); + gtk_box_pack_start (buttonBox, removeStyleButton, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (removeStyleButton), "clicked", G_CALLBACK (remove_style_button_cb), self); - GtkBox *bbox2 = GTK_BOX (gtk_hbox_new(FALSE, 0)); - gtk_box_pack_start (buttonBox, GTK_WIDGET (bbox2), FALSE, FALSE, 0); - - applyStyleButton = gtk_button_new_with_label ("Apply"); - g_object_ref_sink (applyStyleButton); - gtk_widget_set_tooltip_text (applyStyleButton, "Apply style to selected nodes"); - gtk_box_pack_start (bbox2, applyStyleButton, FALSE, FALSE, 5); - g_signal_connect (G_OBJECT (applyStyleButton), - "clicked", - G_CALLBACK (apply_style_button_cb), - self); - - clearStyleButton = gtk_button_new_with_label ("Clear"); - g_object_ref_sink (clearStyleButton); - gtk_widget_set_tooltip_text (clearStyleButton, "Clear style from selected nodes"); - gtk_box_pack_start (bbox2, clearStyleButton, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (clearStyleButton), - "clicked", - G_CALLBACK (clear_style_button_cb), - self); - gtk_widget_show_all (GTK_WIDGET (buttonBox)); [[NSNotificationCenter defaultCenter] addObserver:self @@ -149,38 +129,12 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette [[selector model] setStyleManager:m]; } -- (TikzDocument*) document { - return document; -} - -- (void) setDocument:(TikzDocument*)doc { - if (document != nil) { - [[NSNotificationCenter defaultCenter] removeObserver:self - name:nil - object:[document pickSupport]]; - } - - [doc retain]; - [document release]; - document = doc; - - if (document != nil) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(nodeSelectionChanged:) - name:@"NodeSelectionChanged" - object:[document pickSupport]]; - } -} - - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [editor release]; [selector release]; - [document release]; g_object_unref (palette); g_object_unref (removeStyleButton); - g_object_unref (applyStyleButton); - g_object_unref (clearStyleButton); [super dealloc]; } @@ -195,10 +149,6 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette [editor setStyle:[selector selectedStyle]]; [self updateButtonState]; } - -- (void) nodeSelectionChanged:(NSNotification*)n { - [self updateButtonState]; -} @end // }}} @@ -206,11 +156,8 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette @implementation NodeStylesPalette (Private) - (void) updateButtonState { - gboolean hasNodeSelection = [[[document pickSupport] selectedNodes] count] > 0; gboolean hasStyleSelection = [selector selectedStyle] != nil; - gtk_widget_set_sensitive (applyStyleButton, hasNodeSelection && hasStyleSelection); - gtk_widget_set_sensitive (clearStyleButton, hasNodeSelection); gtk_widget_set_sensitive (removeStyleButton, hasStyleSelection); } @@ -220,27 +167,6 @@ static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette [[[selector model] styleManager] removeNodeStyle:style]; } -- (void) applySelectedStyle { - [document startModifyNodes:[[document pickSupport] selectedNodes]]; - - NodeStyle *style = [selector selectedStyle]; - for (Node *node in [[document pickSupport] selectedNodes]) { - [node setStyle:style]; - } - - [document endModifyNodes]; -} - -- (void) clearSelectedStyle { - [document startModifyNodes:[[document pickSupport] selectedNodes]]; - - for (Node *node in [[document pickSupport] selectedNodes]) { - [node setStyle:nil]; - } - - [document endModifyNodes]; -} - @end // }}} @@ -261,18 +187,6 @@ static void remove_style_button_cb (GtkButton *widget, NodeStylesPalette *palett [pool drain]; } -static void apply_style_button_cb (GtkButton *widget, NodeStylesPalette *palette) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [palette applySelectedStyle]; - [pool drain]; -} - -static void clear_style_button_cb (GtkButton *widget, NodeStylesPalette *palette) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [palette clearSelectedStyle]; - [pool drain]; -} - // }}} // vim:ft=objc:ts=8:et:sts=4:sw=4:foldmethod=marker diff --git a/tikzit/src/gtk/SettingsDialog.h b/tikzit/src/gtk/SettingsDialog.h index 22d0d17..9c1582d 100644 --- a/tikzit/src/gtk/SettingsDialog.h +++ b/tikzit/src/gtk/SettingsDialog.h @@ -19,22 +19,30 @@ #import @class Configuration; +@class EdgeStylesPalette; +@class NodeStylesPalette; +@class StyleManager; @interface SettingsDialog: NSObject { - Configuration *configuration; + Configuration *configuration; + StyleManager *styleManager; + NodeStylesPalette *nodePalette; + EdgeStylesPalette *edgePalette; - // we don't keep any refs, as we control - // the top window GtkWindow *parentWindow; GtkWindow *window; + + // we don't keep any refs, as we control + // the top window GtkEntry *pdflatexPathEntry; } @property (retain) Configuration *configuration; +@property (retain) StyleManager *styleManager; @property (assign) GtkWindow *parentWindow; @property (assign,getter=isVisible) BOOL visible; -- (id) initWithConfiguration:(Configuration*)c; +- (id) initWithConfiguration:(Configuration*)c andStyleManager:(StyleManager*)m; - (void) present; - (void) show; diff --git a/tikzit/src/gtk/SettingsDialog.m b/tikzit/src/gtk/SettingsDialog.m index a70a412..096cca3 100644 --- a/tikzit/src/gtk/SettingsDialog.m +++ b/tikzit/src/gtk/SettingsDialog.m @@ -18,6 +18,8 @@ #import "SettingsDialog.h" #import "Configuration.h" +#import "EdgeStylesPalette.h" +#import "NodeStylesPalette.h" // {{{ Internal interfaces // {{{ Signals @@ -45,11 +47,12 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) return nil; } -- (id) initWithConfiguration:(Configuration*)c { +- (id) initWithConfiguration:(Configuration*)c andStyleManager:(StyleManager*)m { self = [super init]; if (self) { configuration = [c retain]; + styleManager = [m retain]; } return self; @@ -64,6 +67,9 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) } [configuration release]; + [styleManager release]; + [nodePalette release]; + [edgePalette release]; [super dealloc]; } @@ -79,6 +85,19 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) [self revert]; } +- (StyleManager*) styleManager { + return styleManager; +} + +- (void) setStyleManager:(StyleManager*)m { + [m retain]; + [styleManager release]; + styleManager = m; + + [nodePalette setStyleManager:m]; + [edgePalette setStyleManager:m]; +} + - (GtkWindow*) parentWindow { return parentWindow; } @@ -144,7 +163,11 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) return; } + nodePalette = [[NodeStylesPalette alloc] initWithManager:styleManager]; + edgePalette = [[EdgeStylesPalette alloc] initWithManager:styleManager]; + window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); + gtk_window_set_default_size (window, 570, -1); gtk_window_set_title (window, "Preamble editor"); gtk_window_set_modal (window, TRUE); gtk_window_set_position (window, GTK_WIN_POS_CENTER_ON_PARENT); @@ -160,6 +183,7 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) GtkWidget *mainBox = gtk_vbox_new (FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (mainBox), 12); gtk_container_add (GTK_CONTAINER (window), mainBox); + gtk_widget_show (mainBox); #ifdef HAVE_POPPLER /* @@ -183,10 +207,33 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) gtk_box_pack_start (pdflatexBox, GTK_WIDGET (pdflatexPathEntry), TRUE, TRUE, 0); + + gtk_widget_show_all (pdflatexFrame); #else pdflatexPathEntry = NULL; #endif + /* + * Node styles + */ + GtkWidget *nodeStylesFrame = gtk_frame_new ("Node Styles"); + gtk_widget_show (nodeStylesFrame); + gtk_box_pack_start (GTK_BOX (mainBox), nodeStylesFrame, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (nodeStylesFrame), + GTK_WIDGET ([nodePalette widget])); + gtk_widget_show ([nodePalette widget]); + + + /* + * Edge styles + */ + GtkWidget *edgeStylesFrame = gtk_frame_new ("Edge Styles"); + gtk_widget_show (edgeStylesFrame); + gtk_box_pack_start (GTK_BOX (mainBox), edgeStylesFrame, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (edgeStylesFrame), + GTK_WIDGET ([edgePalette widget])); + gtk_widget_show ([edgePalette widget]); + /* * Bottom buttons @@ -213,9 +260,9 @@ static void cancel_button_clicked_cb (GtkButton *widget, SettingsDialog *dialog) G_CALLBACK (cancel_button_clicked_cb), self); - [self revert]; + gtk_widget_show_all (GTK_WIDGET (buttonBox)); - gtk_widget_show_all (mainBox); + [self revert]; } - (void) save { -- cgit v1.2.3