diff options
author | Mike Krüger <mkrueger@novell.com> | 2009-04-28 14:39:00 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2009-04-28 14:39:00 +0400 |
commit | 121fddc19d69bb3df72a8e0054702c4d25a03c81 (patch) | |
tree | cdd2b77b2d89b4fbcd2e70db8b822639302eddfc /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting | |
parent | f7e9a3c531c5bdef8348b674a1f06f99f73efbaf (diff) |
* MonoDevelop.Ide.Gui/DocumentSwitcher.cs:
* MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs:
* MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs:
* MonoDevelop.Ide.CodeTemplates/CodeTemplatePanel.cs:
* MonoDevelop.Ide.CodeTemplates/EditTemplateDialog.cs:
* gtk-gui/MonoDevelop.Ide.Gui.Dialogs.TipOfTheDayWindow.cs:
* MonoDevelop.Ide.Gui.Pads.ClassPad/ClassBrowserPadWidget.cs:
* MonoDevelop.Ide.CodeFormatting/CodeFormattingPolicyPanel.cs:
* MonoDevelop.Ide.CodeFormatting/EditFormattingPolicyDialog.cs:
Removed some delegate methods and added explicit event handlers.
svn path=/trunk/monodevelop/; revision=132823
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting')
2 files changed, 123 insertions, 101 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormattingPolicyPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormattingPolicyPanel.cs index 7d9e582ba2..c507ea2d26 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormattingPolicyPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormattingPolicyPanel.cs @@ -113,61 +113,70 @@ namespace MonoDevelop.Ide.CodeFormatting texteditor1.Document.ReadOnly = true; texteditor1.Document.MimeType = description.MimeType; - buttonAdd.Clicked += delegate { - AddPolicyDialog addPolicy = new AddPolicyDialog (settings); - ResponseType response = (ResponseType)addPolicy.Run (); - if (response == ResponseType.Ok) { - settings.Add (new CodeFormatSettings (TextFileService.GetSettings (description, addPolicy.InitFrom), addPolicy.NewPolicyName)); - FillFormattingPolicies (); - comboboxFormattingPolicies.Active = settings.Count - 1; - TextFileService.SetSettings (description, settings); - } - addPolicy.Destroy (); - }; - - buttonEdit.Clicked += delegate { - EditFormattingPolicyDialog d = new EditFormattingPolicyDialog (); - CodeFormatSettings setting = new CodeFormatSettings ("New settings"); + buttonAdd.Clicked += ButtonAddClicked; + buttonEdit.Clicked += ButtonEditClicked; + buttonImport.Clicked += ButtonImportClicked; + buttonRemove.Clicked += ButtonRemoveClicked; + FillFormattingPolicies (); + } + + void ButtonRemoveClicked (object sender, EventArgs e) + { + int a = comboboxFormattingPolicies.Active; + if (a >= 0 && a < settings.Count) + settings.RemoveAt (a); + FillFormattingPolicies (); + TextFileService.SetSettings (description, settings); + } + + void ButtonImportClicked (object sender, EventArgs e) + { + Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog (GettextCatalog.GetString ("Import Profile"), + null, + FileChooserAction.Open, + Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok); + FileFilter f1 = new FileFilter(); + f1.Name = "*.xml"; + f1.AddPattern ("*.xml"); + dialog.AddFilter (f1); + FileFilter f2 = new FileFilter(); + f1.Name = "*"; + f2.AddPattern ("*"); + dialog.AddFilter (f2); + if (ResponseType.Ok == (ResponseType)dialog.Run ()) { + settings.Add (description.ImportSettings (dialog.Filename)); int a = comboboxFormattingPolicies.Active; - if (a >= 0 && a < settings.Count) - setting = settings [a]; - d.SetFormat (description, setting); - d.Run (); - d.Destroy (); FillFormattingPolicies (); comboboxFormattingPolicies.Active = a; - }; - - buttonImport.Clicked += delegate { - Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog (GettextCatalog.GetString ("Import Profile"), - null, - FileChooserAction.Open, - Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok); - FileFilter f1 = new FileFilter(); - f1.Name = "*.xml"; - f1.AddPattern ("*.xml"); - dialog.AddFilter (f1); - FileFilter f2 = new FileFilter(); - f1.Name = "*"; - f2.AddPattern ("*"); - dialog.AddFilter (f2); - if (ResponseType.Ok == (ResponseType)dialog.Run ()) { - settings.Add (description.ImportSettings (dialog.Filename)); - int a = comboboxFormattingPolicies.Active; - FillFormattingPolicies (); - comboboxFormattingPolicies.Active = a; - } - dialog.Destroy (); - }; - - buttonRemove.Clicked += delegate { - int a = comboboxFormattingPolicies.Active; - if (a >= 0 && a < settings.Count) - settings.RemoveAt (a); + } + dialog.Destroy (); + } + + void ButtonEditClicked (object sender, EventArgs e) + { + EditFormattingPolicyDialog d = new EditFormattingPolicyDialog (); + CodeFormatSettings setting = new CodeFormatSettings ("New settings"); + int a = comboboxFormattingPolicies.Active; + if (a >= 0 && a < settings.Count) + setting = settings [a]; + d.SetFormat (description, setting); + d.Run (); + d.Destroy (); + FillFormattingPolicies (); + comboboxFormattingPolicies.Active = a; + } + + void ButtonAddClicked (object sender, EventArgs e) + { + AddPolicyDialog addPolicy = new AddPolicyDialog (settings); + ResponseType response = (ResponseType)addPolicy.Run (); + if (response == ResponseType.Ok) { + settings.Add (new CodeFormatSettings (TextFileService.GetSettings (description, addPolicy.InitFrom), addPolicy.NewPolicyName)); FillFormattingPolicies (); + comboboxFormattingPolicies.Active = settings.Count - 1; TextFileService.SetSettings (description, settings); - }; - FillFormattingPolicies (); + } + addPolicy.Destroy (); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/EditFormattingPolicyDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/EditFormattingPolicyDialog.cs index 154644a584..f120db1176 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/EditFormattingPolicyDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/EditFormattingPolicyDialog.cs @@ -47,29 +47,10 @@ namespace MonoDevelop.Ide.CodeFormatting public EditFormattingPolicyDialog() { this.Build(); - buttonOk.Clicked += delegate { - if (description == null) - return; - settings.Name = this.entryName.Text; - }; + buttonOk.Clicked += ButtonOkClicked; - buttonExport.Clicked += delegate { - Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog (GettextCatalog.GetString ("Export Profile"), - this, - FileChooserAction.Save, - Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Save, Gtk.ResponseType.Ok); - dialog.Filter = new FileFilter(); - dialog.Filter.AddPattern ("*.xml"); - if (ResponseType.Ok == (ResponseType)dialog.Run ()) { -// System.Console.WriteLine("fn:" + dialog.Filename); - description.ExportSettings (settings, dialog.Filename); - } - dialog.Destroy (); - }; - checkbuttonWhiteSpaces.Toggled += delegate { - options.ShowSpaces = options.ShowTabs = options.ShowEolMarkers = checkbuttonWhiteSpaces.Active; - this.texteditor1.QueueDraw (); - }; + buttonExport.Clicked += ButtonExportClicked; + checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled; comboboxValue.Clear (); Gtk.CellRendererText ctx = new Gtk.CellRendererText (); comboboxValue.PackStart (ctx, true); @@ -82,6 +63,35 @@ namespace MonoDevelop.Ide.CodeFormatting scrolledwindow2.Child = texteditor1; scrolledwindow2.ShowAll (); } + + void ButtonOkClicked (object sender, EventArgs e) + { + if (description == null) + return; + settings.Name = this.entryName.Text; + } + + void ButtonExportClicked (object sender, EventArgs e) + { + Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog (GettextCatalog.GetString ("Export Profile"), + this, + FileChooserAction.Save, + Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Save, Gtk.ResponseType.Ok); + dialog.Filter = new FileFilter(); + dialog.Filter.AddPattern ("*.xml"); + if (ResponseType.Ok == (ResponseType)dialog.Run ()) { +// System.Console.WriteLine("fn:" + dialog.Filename); + description.ExportSettings (settings, dialog.Filename); + } + dialog.Destroy (); + } + + void CheckbuttonWhiteSpacesToggled (object sender, EventArgs e) + { + options.ShowSpaces = options.ShowTabs = options.ShowEolMarkers = checkbuttonWhiteSpaces.Active; + this.texteditor1.QueueDraw (); + } + Mono.TextEditor.TextEditor texteditor1 = new Mono.TextEditor.TextEditor (); class CustomFormattingPolicy : CodeFormattingPolicy { @@ -187,38 +197,41 @@ namespace MonoDevelop.Ide.CodeFormatting Gtk.TreeView tree = new Gtk.TreeView (store); tree.AppendColumn (GettextCatalog.GetString ("Key"), new CellRendererText (), "text", keyColumn); tree.AppendColumn (GettextCatalog.GetString ("Value"), new CellRendererText (), "text", valueDisplayTextColumn); - tree.Selection.Changed += delegate { - if (tree.Selection.GetSelected (out model, out iter)) { - - option = model.GetValue (iter, objectColumn) as CodeFormatOption; - this.store = store; - if (option == null) { - texteditor1.Document.Text = ""; - // comboboxentryValue.Sensitive = false; - return; - } - comboboxValue.Changed -= HandleChanged; - // comboboxentryValue.Sensitive = true; - CodeFormatType type = description.GetCodeFormatType (option.Type); - texteditor1.Document.Text = option.Example; - - comboBoxStore.Clear (); - int active = 0, i = 0; - KeyValuePair<string, string> curValue = settings.GetValue (description, option); - foreach (KeyValuePair<string, string> v in type.Values) { - if (v.Key == curValue.Key) - active = i; - comboBoxStore.AppendValues (v.Key, GettextCatalog.GetString (v.Value)); - i++; - } - comboboxValue.Active = active; - comboboxValue.Changed += HandleChanged; - UpdateExample (); - } - }; + tree.Selection.Changed += TreeSelectionChanged; ScrolledWindow sw = new ScrolledWindow (); sw.Child = tree; notebookCategories.AppendPage (sw, label); } + + void TreeSelectionChanged (object sender, EventArgs e) + { + Gtk.TreeView tree = (Gtk.TreeView)sender; + if (tree.Selection.GetSelected (out model, out iter)) { + option = model.GetValue (iter, objectColumn) as CodeFormatOption; + this.store = store; + if (option == null) { + texteditor1.Document.Text = ""; +// comboboxentryValue.Sensitive = false; + return; + } + comboboxValue.Changed -= HandleChanged; +// comboboxentryValue.Sensitive = true; + CodeFormatType type = description.GetCodeFormatType (option.Type); + texteditor1.Document.Text = option.Example; + + comboBoxStore.Clear (); + int active = 0, i = 0; + KeyValuePair<string, string> curValue = settings.GetValue (description, option); + foreach (KeyValuePair<string, string> v in type.Values) { + if (v.Key == curValue.Key) + active = i; + comboBoxStore.AppendValues (v.Key, GettextCatalog.GetString (v.Value)); + i++; + } + comboboxValue.Active = active; + comboboxValue.Changed += HandleChanged; + UpdateExample (); + } + } } } |