| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001424bdb4927-d8d8f1c3-9352-4153-86d7-f1c2719d0b32-000000@email.amazonses.com> |
Branch: refs/heads/cleanups
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/10aeefdaf780...5c547addb35c
Commit: 5c547addb35c8ed5f9ad812ea0eb326906fbbb5c
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 10:27:21 GMT
URL: https://github.com/mono/monodevelop/commit/5c547addb35c8ed5f9ad812ea0eb326906fbbb5c
[Cleanup] MonoDevelop.GtkCore cleanup
Changed paths:
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDocumentOutline.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WindowsFolder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/Counters.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkCoreService.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkDesignInfo.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ObjectsDocument.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ProjectResourceProvider.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ReferenceManager.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs
M main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetParser.cs
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/BindDesignDialog.cs
===================================================================
@@ -39,25 +39,25 @@ namespace MonoDevelop.GtkCore.Dialogs
{
class BindDesignDialog: IDisposable
{
- [Glade.Widget ("BindDesignDialog")] protected Gtk.Dialog dialog;
- [Glade.Widget] protected Gtk.Label labelMessage;
- [Glade.Widget] protected Gtk.ComboBox comboClasses;
- [Glade.Widget] protected Gtk.Entry entryClassName;
- [Glade.Widget] protected Gtk.Entry entryNamespace;
- [Glade.Widget] protected Gtk.RadioButton radioSelect;
- [Glade.Widget] protected Gtk.RadioButton radioCreate;
- [Glade.Widget] protected Gtk.Table tableNewClass;
- [Glade.Widget] protected Gtk.Button okButton;
- [Glade.Widget] protected Gtk.EventBox fileEntryBox;
+ [Glade.Widget ("BindDesignDialog")] protected Dialog dialog;
+ [Glade.Widget] protected Label labelMessage;
+ [Glade.Widget] protected ComboBox comboClasses;
+ [Glade.Widget] protected Entry entryClassName;
+ [Glade.Widget] protected Entry entryNamespace;
+ [Glade.Widget] protected RadioButton radioSelect;
+ [Glade.Widget] protected RadioButton radioCreate;
+ [Glade.Widget] protected Table tableNewClass;
+ [Glade.Widget] protected Button okButton;
+ [Glade.Widget] protected EventBox fileEntryBox;
- FolderEntry fileEntry;
+ readonly FolderEntry fileEntry;
- ListStore store;
+ readonly ListStore store;
static string lastNamespace = "";
public BindDesignDialog (string id, ArrayList validClasses, string baseFolder)
{
- XML glade = new XML (null, "gui.glade", "BindDesignDialog", null);
+ var glade = new XML (null, "gui.glade", "BindDesignDialog", null);
glade.Autoconnect (this);
labelMessage.Text = GettextCatalog.GetString ("The widget design {0} is not currently bound to a class.", id);
@@ -71,7 +71,7 @@ public BindDesignDialog (string id, ArrayList validClasses, string baseFolder)
foreach (string cname in validClasses)
store.AppendValues (cname);
comboClasses.Model = store;
- CellRendererText cr = new CellRendererText ();
+ var cr = new CellRendererText ();
comboClasses.PackStart (cr, true);
comboClasses.AddAttribute (cr, "text", 0);
comboClasses.Active = 0;
@@ -93,13 +93,13 @@ public BindDesignDialog (string id, ArrayList validClasses, string baseFolder)
entryNamespace.Text = lastNamespace;
}
- dialog.Response += new Gtk.ResponseHandler (OnResponse);
+ dialog.Response += OnResponse;
UpdateStatus ();
}
- void OnResponse (object ob, Gtk.ResponseArgs args)
+ void OnResponse (object ob, ResponseArgs args)
{
- dialog.Response -= new Gtk.ResponseHandler (OnResponse);
+ dialog.Response -= OnResponse;
if (args.ResponseId == ResponseType.Ok && radioCreate.Active)
lastNamespace = Namespace;
}
@@ -118,15 +118,14 @@ public bool Run ()
if (radioCreate.Active) {
return entryClassName.Text;
} else {
- Gtk.TreeIter it;
+ TreeIter it;
if (!comboClasses.GetActiveIter (out it))
return "";
- string s = (string) store.GetValue (it, 0);
+ string s = (string)store.GetValue (it, 0);
int i = s.IndexOf ('.');
if (i != -1)
- return s.Substring (i+1);
- else
- return s;
+ return s.Substring (i + 1);
+ return s;
}
}
}
@@ -136,15 +135,14 @@ public bool Run ()
if (radioCreate.Active) {
return entryNamespace.Text;
} else {
- Gtk.TreeIter it;
+ TreeIter it;
if (!comboClasses.GetActiveIter (out it))
return "";
- string s = (string) store.GetValue (it, 0);
+ string s = (string)store.GetValue (it, 0);
int i = s.IndexOf ('.');
if (i != -1)
return s.Substring (0, i);
- else
- return "";
+ return "";
}
}
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/ConfirmWindowDeleteDialog.cs
===================================================================
@@ -28,7 +28,6 @@
using System;
using Glade;
-using Gtk;
using MonoDevelop.Core;
using MonoDevelop.Ide;
@@ -42,7 +41,7 @@ class ConfirmWindowDeleteDialog: IDisposable
public ConfirmWindowDeleteDialog (string windowName, string fileName, Stetic.ProjectItemInfo obj)
{
- XML glade = new XML (null, "gui.glade", "ConfirmWindowDeleteDialog", null);
+ var glade = new XML (null, "gui.glade", "ConfirmWindowDeleteDialog", null);
glade.Autoconnect (this);
if (obj is Stetic.WidgetInfo && ((Stetic.WidgetInfo)obj).IsWindow) {
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkDesignerOptionsPanelWidget.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.GtkCore.GuiBuilder;
using Gtk;
using MonoDevelop.Ide.Gui.Dialogs;
@@ -49,11 +48,11 @@ public override void ApplyChanges ()
}
[System.ComponentModel.ToolboxItem(true)]
- public partial class GtkDesignerOptionsPanelWidget : Gtk.Bin
+ public partial class GtkDesignerOptionsPanelWidget : Bin
{
public GtkDesignerOptionsPanelWidget()
{
- this.Build();
+ Build ();
}
public bool AutoSwitchLayout {
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/GtkFeatureWidget.cs
===================================================================
@@ -1,5 +1,4 @@
-using System;
using MonoDevelop.Ide.Templates;
using MonoDevelop.Core;
using MonoDevelop.Projects;
@@ -7,24 +6,24 @@
namespace MonoDevelop.GtkCore.Dialogs
{
- class GtkFeatureWidget : Gtk.VBox
+ class GtkFeatureWidget : VBox
{
- ComboBox versionCombo;
+ readonly ComboBox versionCombo;
public GtkFeatureWidget (DotNetProject project)
{
Spacing = 6;
- versionCombo = Gtk.ComboBox.NewText ();
- ReferenceManager refmgr = new ReferenceManager (project);
+ versionCombo = ComboBox.NewText ();
+ var refmgr = new ReferenceManager (project);
foreach (string v in refmgr.SupportedGtkVersions)
versionCombo.AppendText (v);
versionCombo.Active = 0;
refmgr.Dispose ();
// GTK# version selector
- HBox box = new HBox (false, 6);
- Gtk.Label vlab = new Label (GettextCatalog.GetString ("Target GTK# version:"));
+ var box = new HBox (false, 6);
+ var vlab = new Label (GettextCatalog.GetString ("Target GTK# version:"));
box.PackStart (vlab, false, false, 0);
box.PackStart (versionCombo, false, false, 0);
box.PackStart (new Label (GettextCatalog.GetString ("(or upper)")), false, false, 0);
@@ -53,16 +52,15 @@ public FeatureSupportLevel GetSupportLevel (SolutionFolder parentCombine, Soluti
if (!(entry is DotNetProject) || !GtkDesignInfo.SupportsRefactoring (entry as DotNetProject))
return FeatureSupportLevel.NotSupported;
- ReferenceManager refmgr = new ReferenceManager ((DotNetProject)entry);
+ var refmgr = new ReferenceManager ((DotNetProject)entry);
if (refmgr.SupportedGtkVersions.Count == 0)
return FeatureSupportLevel.NotSupported;
if (GtkDesignInfo.SupportsDesigner ((Project)entry))
return FeatureSupportLevel.Enabled;
- else if (entry is DotNetAssemblyProject)
+ if (entry is DotNetAssemblyProject)
return FeatureSupportLevel.SupportedByDefault;
- else
- return FeatureSupportLevel.Supported;
+ return FeatureSupportLevel.Supported;
}
public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionItem entry)
@@ -72,13 +70,13 @@ public Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionItem en
public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry, Widget editor)
{
- GtkFeatureWidget fw = (GtkFeatureWidget) editor;
- ReferenceManager refmgr = new ReferenceManager ((DotNetProject) entry);
+ var fw = (GtkFeatureWidget) editor;
+ var refmgr = new ReferenceManager ((DotNetProject) entry);
refmgr.GtkPackageVersion = fw.SelectedVersion;
refmgr.Dispose ();
}
- public string Validate (SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor)
+ public string Validate (SolutionFolder parentCombine, SolutionItem entry, Widget editor)
{
return null;
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/SelectRenamedClassDialog.cs
===================================================================
@@ -40,25 +40,25 @@ namespace MonoDevelop.GtkCore.Dialogs
{
public class SelectRenamedClassDialog: IDisposable
{
- [Glade.Widget ("SelectRenamedClassDialog")] protected Gtk.Dialog dialog;
- [Glade.Widget] protected Gtk.TreeView treeClasses;
- ListStore store;
+ [Glade.Widget ("SelectRenamedClassDialog")] protected Dialog dialog;
+ [Glade.Widget] protected TreeView treeClasses;
+ readonly ListStore store;
public SelectRenamedClassDialog (IEnumerable<IType> classes)
{
- XML glade = new XML (null, "gui.glade", "SelectRenamedClassDialog", null);
+ var glade = new XML (null, "gui.glade", "SelectRenamedClassDialog", null);
glade.Autoconnect (this);
store = new ListStore (typeof(Pixbuf), typeof(string));
treeClasses.Model = store;
- TreeViewColumn column = new TreeViewColumn ();
+ var column = new TreeViewColumn ();
var pr = new CellRendererPixbuf ();
column.PackStart (pr, false);
column.AddAttribute (pr, "pixbuf", 0);
- CellRendererText crt = new CellRendererText ();
+ var crt = new CellRendererText ();
column.PackStart (crt, true);
column.AddAttribute (crt, "text", 1);
@@ -77,8 +77,8 @@ public bool Run ()
public string SelectedClass {
get {
- Gtk.TreeModel foo;
- Gtk.TreeIter iter;
+ TreeModel foo;
+ TreeIter iter;
if (!treeClasses.Selection.GetSelected (out foo, out iter))
return null;
return (string) store.GetValue (iter, 1);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.Dialogs/WidgetBuilderOptionPanel.cs
===================================================================
@@ -38,23 +38,23 @@ namespace MonoDevelop.GtkCore.Dialogs
{
class WidgetBuilderOptionPanel: ItemOptionsPanel
{
- class WidgetBuilderOptionPanelWidget : Gtk.VBox
+ class WidgetBuilderOptionPanelWidget : VBox
{
- Gtk.CheckButton checkGettext;
- Gtk.Entry entryGettext;
- Gtk.ComboBox comboVersions;
+ readonly CheckButton checkGettext;
+ readonly Entry entryGettext;
+ readonly ComboBox comboVersions;
- DotNetProject project;
+ readonly DotNetProject project;
public WidgetBuilderOptionPanelWidget (Project project) : base (false, 6)
{
this.project = project as DotNetProject;
- Gtk.HBox box = new Gtk.HBox (false, 3);
- Gtk.Label lbl = new Gtk.Label (GettextCatalog.GetString ("Target Gtk# version:"));
+ var box = new HBox (false, 3);
+ var lbl = new Label (GettextCatalog.GetString ("Target Gtk# version:"));
box.PackStart (lbl, false, false, 0);
comboVersions = ComboBox.NewText ();
- ReferenceManager refmgr = new ReferenceManager (project as DotNetProject);
+ var refmgr = new ReferenceManager (project as DotNetProject);
foreach (string v in refmgr.SupportedGtkVersions)
comboVersions.AppendText (v);
comboVersions.Active = refmgr.SupportedGtkVersions.IndexOf (refmgr.GtkPackageVersion);
@@ -63,7 +63,7 @@ public WidgetBuilderOptionPanelWidget (Project project) : base (false, 6)
box.ShowAll ();
PackStart (box, false, false, 0);
- HSeparator sep = new HSeparator ();
+ var sep = new HSeparator ();
sep.Show ();
PackStart (sep, false, false, 0);
@@ -75,9 +75,9 @@ public WidgetBuilderOptionPanelWidget (Project project) : base (false, 6)
checkGettext.Active = designInfo.GenerateGettext;
checkGettext.Show ();
PackStart (checkGettext, false, false, 0);
- box = new Gtk.HBox (false, 3);
+ box = new HBox (false, 3);
box.PackStart (new Label (GettextCatalog.GetString ("Gettext class:")), false, false, 0);
- entryGettext = new Gtk.Entry ();
+ entryGettext = new Entry ();
entryGettext.Text = designInfo.GettextClass;
entryGettext.Sensitive = checkGettext.Active;
box.PackStart (entryGettext, false, false, 0);
@@ -93,7 +93,7 @@ public WidgetBuilderOptionPanelWidget (Project project) : base (false, 6)
public void Store ()
{
- ReferenceManager refmgr = new ReferenceManager (project);
+ var refmgr = new ReferenceManager (project);
if (!string.IsNullOrEmpty (comboVersions.ActiveText))
refmgr.GtkPackageVersion = comboVersions.ActiveText;
if (GtkDesignInfo.HasDesignedObjects (project)) {
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs
===================================================================
@@ -43,10 +43,10 @@ namespace MonoDevelop.GtkCore.GuiBuilder
{
public class ActionGroupDisplayBinding : IViewDisplayBinding
{
- bool excludeThis = false;
+ bool excludeThis;
public string Name {
- get { return MonoDevelop.Core.GettextCatalog.GetString ("Action Group Editor"); }
+ get { return GettextCatalog.GetString ("Action Group Editor"); }
}
public bool CanUseAsDefault {
@@ -77,15 +77,15 @@ public IViewContent CreateContent (FilePath fileName, string mimeType, Project o
{
excludeThis = true;
var db = DisplayBindingService.GetDefaultViewBinding (fileName, mimeType, ownerProject);
- GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) ownerProject);
+ GtkDesignInfo info = GtkDesignInfo.FromProject (ownerProject);
var content = db.CreateContent (fileName, mimeType, ownerProject);
- ActionGroupView view = new ActionGroupView (content, GetActionGroup (fileName), info.GuiBuilderProject);
+ var view = new ActionGroupView (content, GetActionGroup (fileName), info.GuiBuilderProject);
excludeThis = false;
return view;
}
- Stetic.ActionGroupInfo GetActionGroup (string file)
+ static Stetic.ActionGroupInfo GetActionGroup (string file)
{
Project project = IdeApp.Workspace.GetProjectContainingFile (file);
if (!GtkDesignInfo.HasDesignedObjects (project))
@@ -103,7 +103,7 @@ internal static string BindToClass (Project project, Stetic.ActionGroupInfo grou
// Find the classes that could be bound to this design
- ArrayList list = new ArrayList ();
+ var list = new ArrayList ();
var ctx = gproject.GetParserContext ();
foreach (var cls in ctx.MainAssembly.GetAllTypeDefinitions ())
if (IsValidClass (cls))
@@ -111,7 +111,7 @@ internal static string BindToClass (Project project, Stetic.ActionGroupInfo grou
// Ask what to do
- using (BindDesignDialog dialog = new BindDesignDialog (group.Name, list, project.BaseDirectory)) {
+ using (var dialog = new BindDesignDialog (group.Name, list, project.BaseDirectory)) {
if (!dialog.Run ())
return null;
@@ -153,7 +153,7 @@ static IUnresolvedTypeDefinition CreateClass (Project project, Stetic.ActionGrou
// Add signal handlers
foreach (Stetic.ActionComponent action in group.GetActions ()) {
foreach (Stetic.Signal signal in action.GetSignals ()) {
- CodeMemberMethod met = new CodeMemberMethod ();
+ var met = new CodeMemberMethod ();
met.Name = signal.Handler;
met.Attributes = MemberAttributes.Family;
met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
===================================================================
@@ -27,9 +27,7 @@
//
using System;
-using System.Collections;
-using MonoDevelop.Projects;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Commands;
@@ -44,10 +42,10 @@ public class ActionGroupView: CombinedDesignView
{
Stetic.ActionGroupDesigner designer;
CodeBinder codeBinder;
- GuiBuilderProject project;
+ readonly GuiBuilderProject project;
Stetic.ActionGroupComponent group;
Stetic.ActionGroupInfo groupInfo;
- string groupName;
+ readonly string groupName;
public ActionGroupView (IViewContent content, Stetic.ActionGroupInfo group, GuiBuilderProject project): base (content)
{
@@ -68,9 +66,9 @@ void LoadDesigner ()
designer = project.SteticProject.CreateActionGroupDesigner (groupInfo, false);
designer.AllowActionBinding = project.Project.UsePartialTypes;
- designer.BindField += new EventHandler (OnBindField);
+ designer.BindField += OnBindField;
- ActionGroupPage actionsPage = new ActionGroupPage ();
+ var actionsPage = new ActionGroupPage ();
actionsPage.PackStart (designer, true, true, 0);
actionsPage.ShowAll ();
@@ -129,7 +127,7 @@ protected override void OnPageShown (int npage)
// the code for the window (only the fields in fact) and update the parser database, it
// will not save the code to disk.
if (project.Project.UsePartialTypes)
- GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)project.Project, designer.RootComponent, null, false, false);
+ GuiBuilderService.GenerateSteticCodeStructure (project.Project, designer.RootComponent, null, false, false);
}
base.OnPageShown (npage);
}
@@ -215,10 +213,6 @@ void OnBindField (object s, EventArgs args)
class ActionGroupPage: Gtk.VBox, ICustomPropertyPadProvider
{
- public ActionGroupPage ()
- {
- }
-
Gtk.Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
{
return PropertiesWidget.Instance;
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs
===================================================================
@@ -26,16 +26,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using Gtk;
-using System;
-using System.Collections;
-using System.CodeDom;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
namespace MonoDevelop.GtkCore.GuiBuilder
{
- internal class ClassUtils
+ static class ClassUtils
{
public static IField FindWidgetField (ITypeDefinition cls, string name)
{
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
===================================================================
@@ -26,12 +26,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using MonoDevelop.Core;
-using MonoDevelop.Core.ProgressMonitoring;
using MonoDevelop.Projects;
using MonoDevelop.Projects.Text;
using MonoDevelop.Ide.Gui;
@@ -39,7 +37,6 @@
using MonoDevelop.Ide;
using ICSharpCode.NRefactory.TypeSystem;
using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Ide.FindInFiles;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace MonoDevelop.GtkCore.GuiBuilder
@@ -53,10 +50,10 @@ namespace MonoDevelop.GtkCore.GuiBuilder
public class CodeBinder
{
- ITextFileProvider textFileProvider;
+ readonly ITextFileProvider textFileProvider;
Stetic.Component targetObject;
- Project project;
- GuiBuilderProject gproject;
+ readonly Project project;
+ readonly GuiBuilderProject gproject;
string className;
string classFile;
@@ -73,7 +70,7 @@ public CodeBinder (Project project, ITextFileProvider textFileProvider, Stetic.C
public Stetic.Component TargetObject {
get { return targetObject; }
set {
- this.targetObject = value;
+ targetObject = value;
if (targetObject != null) {
var cls = gproject.FindClass (GetClassName (targetObject));
if (cls != null) {
@@ -111,7 +108,7 @@ void UpdateBindings (Stetic.Component obj, IUnresolvedTypeDefinition cls)
Stetic.SignalCollection objectSignals = obj.GetSignals ();
if (objectSignals != null) {
- Stetic.Signal[] signals = new Stetic.Signal [objectSignals.Count];
+ var signals = new Stetic.Signal [objectSignals.Count];
objectSignals.CopyTo (signals, 0);
var resolved = cls.Resolve (project);
foreach (Stetic.Signal signal in signals) {
@@ -127,7 +124,7 @@ void UpdateBindings (Stetic.Component obj, IUnresolvedTypeDefinition cls)
UpdateBindings (ob, cls);
}
- IMethod FindSignalHandler (IType cls, Stetic.Signal signal)
+ static IMethod FindSignalHandler (IType cls, Stetic.Signal signal)
{
foreach (var met in cls.GetMethods ()) {
if (met.Name == signal.Handler) {
@@ -220,7 +217,7 @@ public void BindToField (Stetic.Component obj)
}
}
- IUnresolvedField GetFieldCode (IUnresolvedTypeDefinition cls, Stetic.Component obj, string name)
+ static IUnresolvedField GetFieldCode (IUnresolvedTypeDefinition cls, Stetic.Component obj, string name)
{
return new DefaultUnresolvedField (cls, name) {
ReturnType = ReflectionHelper.ParseReflectionName (obj.Type.ClassName),
@@ -228,7 +225,7 @@ IUnresolvedField GetFieldCode (IUnresolvedTypeDefinition cls, Stetic.Component o
};
}
- IField FindField (IType cls, string name)
+ static IField FindField (IType cls, string name)
{
foreach (IField field in cls.GetFields ())
if (field.Name == name)
@@ -276,7 +273,7 @@ public IUnresolvedTypeDefinition GetClass (bool getUserClass)
// If not found, warn the user.
if (unit != null && unit.TopLevelTypeDefinitions.Count > 0) {
- using (SelectRenamedClassDialog dialog = new SelectRenamedClassDialog (unit.TopLevelTypeDefinitions.Select (c => c.Resolve (project)))) {
+ using (var dialog = new SelectRenamedClassDialog (unit.TopLevelTypeDefinitions.Select (c => c.Resolve (project)))) {
if (dialog.Run ()) {
className = dialog.SelectedClass;
if (className == null)
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CombinedDesignView.cs
===================================================================
@@ -42,8 +42,8 @@ namespace MonoDevelop.GtkCore.GuiBuilder
public class CombinedDesignView : AbstractViewContent
{
IViewContent content;
- Gtk.Widget control;
- List<TabView> tabs = new List<TabView> ();
+ Widget control;
+ readonly List<TabView> tabs = new List<TabView> ();
public CombinedDesignView (IViewContent content)
{
@@ -54,14 +54,14 @@ public CombinedDesignView (IViewContent content)
ShowPage (0);
};
}*/
- content.ContentChanged += new EventHandler (OnTextContentChanged);
- content.DirtyChanged += new EventHandler (OnTextDirtyChanged);
+ content.ContentChanged += OnTextContentChanged;
+ content.DirtyChanged += OnTextDirtyChanged;
- CommandRouterContainer crc = new CommandRouterContainer (content.Control, content, true);
+ var crc = new CommandRouterContainer (content.Control, content, true);
crc.Show ();
control = crc;
- IdeApp.Workbench.ActiveDocumentChanged += new EventHandler (OnActiveDocumentChanged);
+ IdeApp.Workbench.ActiveDocumentChanged += OnActiveDocumentChanged;
}
public virtual Stetic.Designer Designer {
@@ -74,9 +74,9 @@ public CombinedDesignView (IViewContent content)
}
}
- protected void AddButton (string label, Gtk.Widget page)
+ protected void AddButton (string label, Widget page)
{
- TabView view = new TabView (label, page);
+ var view = new TabView (label, page);
tabs.Add (view);
if (WorkbenchWindow != null) {
view.WorkbenchWindow = WorkbenchWindow;
@@ -84,12 +84,12 @@ protected void AddButton (string label, Gtk.Widget page)
}
}
- public bool HasPage (Gtk.Widget page)
+ public bool HasPage (Widget page)
{
return tabs.Any (p => p.Control == page);
}
- public void RemoveButton (Gtk.Widget page)
+ public void RemoveButton (Widget page)
{
/* int i = notebook.PageNum (page);
if (i != -1)
@@ -133,7 +133,7 @@ void OnActiveViewContentChanged (object o, ActiveViewContentEventArgs e)
if (WorkbenchWindow.ActiveViewContent == this)
OnPageShown (0);
else {
- TabView tab = WorkbenchWindow.ActiveViewContent as TabView;
+ var tab = WorkbenchWindow.ActiveViewContent as TabView;
if (tab != null) {
int n = tabs.IndexOf (tab);
if (n != -1)
@@ -160,9 +160,9 @@ protected virtual void OnPageShown (int npage)
public override void Dispose ()
{
- content.ContentChanged -= new EventHandler (OnTextContentChanged);
- content.DirtyChanged -= new EventHandler (OnTextDirtyChanged);
- IdeApp.Workbench.ActiveDocumentChanged -= new EventHandler (OnActiveDocumentChanged);
+ content.ContentChanged -= OnTextContentChanged;
+ content.DirtyChanged -= OnTextDirtyChanged;
+ IdeApp.Workbench.ActiveDocumentChanged -= OnActiveDocumentChanged;
content.Dispose ();
content = null;
@@ -177,7 +177,7 @@ public override void Load (string fileName)
content.Load (fileName);
}
- public override Gtk.Widget Control {
+ public override Widget Control {
get { return control; }
}
@@ -246,7 +246,7 @@ public override object GetContent (Type type)
public void JumpTo (int line, int column)
{
- IEditableTextBuffer ip = (IEditableTextBuffer) content.GetContent (typeof(IEditableTextBuffer));
+ var ip = (IEditableTextBuffer) content.GetContent (typeof(IEditableTextBuffer));
if (ip != null) {
ShowPage (0);
ip.SetCaretTo (line, column);
@@ -256,10 +256,10 @@ public void JumpTo (int line, int column)
class TabView: AbstractBaseViewContent, IAttachableViewContent
{
- string label;
- Gtk.Widget content;
+ readonly string label;
+ readonly Widget content;
- public TabView (string label, Gtk.Widget content)
+ public TabView (string label, Widget content)
{
this.label = label;
this.content = content;
@@ -267,9 +267,7 @@ public TabView (string label, Gtk.Widget content)
public override object GetContent (Type type)
{
- if (type.IsInstanceOfType (Control))
- return Control;
- return base.GetContent (type);
+ return type.IsInstanceOfType (Control) ? Control : base.GetContent (type);
}
#region IAttachableViewContent implementation
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GtkProjectServiceExtension.cs
===================================================================
@@ -14,24 +14,24 @@ public override bool SupportsItem (IBuildTarget item)
if (!IdeApp.IsInitialized)
return false;
- DotNetProject project = item as DotNetProject;
+ var project = item as DotNetProject;
return project != null && GtkDesignInfo.HasDesignedObjects (project);
}
- protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
+ protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
{
- DotNetProject project = (DotNetProject) entry;
+ var project = (DotNetProject) item;
GtkDesignInfo info = GtkDesignInfo.FromProject (project);
// The code generator must run in the GUI thread since it needs to
// access to Gtk classes
- Generator gen = new Generator ();
+ var gen = new Generator ();
lock (gen) {
Gtk.Application.Invoke (delegate { gen.Run (monitor, project, configuration); });
Monitor.Wait (gen);
}
- BuildResult res = base.Build (monitor, entry, configuration);
+ BuildResult res = base.Build (monitor, item, configuration);
if (gen.Messages != null) {
foreach (string s in gen.Messages)
@@ -59,9 +59,10 @@ protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityIt
class Generator
{
+ readonly object locker = new object ();
public void Run (IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
{
- lock (this) {
+ lock (locker) {
try {
Stetic.CodeGenerationResult res = GuiBuilderService.GenerateSteticCode (monitor, project, configuration);
if (res != null)
@@ -69,7 +70,7 @@ public void Run (IProgressMonitor monitor, DotNetProject project, ConfigurationS
} catch (Exception ex) {
Error = ex;
LoggingService.LogError (ex.ToString ());
- Messages = new string [] { Error.Message };
+ Messages = new [] { Error.Message };
}
Monitor.PulseAll (this);
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDisplayBinding.cs
===================================================================
@@ -36,7 +36,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder
{
public class GuiBuilderDisplayBinding : IViewDisplayBinding
{
- bool excludeThis = false;
+ bool excludeThis;
public string Name {
get { return MonoDevelop.Core.GettextCatalog.GetString ("Window Designer"); }
@@ -68,7 +68,7 @@ public IViewContent CreateContent (MonoDevelop.Core.FilePath fileName, string mi
excludeThis = true;
var db = DisplayBindingService.GetDefaultViewBinding (fileName, mimeType, ownerProject);
var content = db.CreateContent (fileName, mimeType, ownerProject);
- GuiBuilderView view = new GuiBuilderView (content, GetWindow (fileName));
+ var view = new GuiBuilderView (content, GetWindow (fileName));
excludeThis = false;
return view;
}
@@ -90,7 +90,7 @@ internal static GuiBuilderWindow GetWindow (string file)
return null;
GtkDesignInfo info = GtkDesignInfo.FromProject (project);
- if (file.StartsWith (info.GtkGuiFolder))
+ if (file.StartsWith (info.GtkGuiFolder, System.StringComparison.Ordinal))
return null;
var doc = TypeSystemService.ParseFile (project, file);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderDocumentOutline.cs
===================================================================
@@ -27,16 +27,14 @@
//
-using System;
using Gtk;
-using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Commands;
using MonoDevelop.Components.Commands;
using MonoDevelop.DesignerSupport;
namespace MonoDevelop.GtkCore.GuiBuilder
{
- internal class GuiBuilderDocumentOutline: Alignment, ICustomPropertyPadProvider
+ class GuiBuilderDocumentOutline: Alignment, ICustomPropertyPadProvider
{
static GuiBuilderDocumentOutline instance;
@@ -56,7 +54,7 @@ internal class GuiBuilderDocumentOutline: Alignment, ICustomPropertyPadProvider
}
}
- Gtk.Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
+ Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
{
return PropertiesWidget.Instance;
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
===================================================================
@@ -49,14 +49,14 @@ public class GuiBuilderProject
List<GuiBuilderWindow> formInfos;
Stetic.Project gproject;
- DotNetProject project;
- string fileName;
+ readonly DotNetProject project;
+ readonly string fileName;
bool hasError;
bool needsUpdate = true;
FileSystemWatcher watcher;
DateTime lastSaveTime;
- object fileSaveLock = new object ();
+ readonly object fileSaveLock = new object ();
bool disposed;
bool librariesUpdated;
@@ -114,7 +114,7 @@ void Load ()
if (System.IO.File.Exists (fileName)) {
watcher.Path = Path.GetDirectoryName (fileName);
watcher.Filter = Path.GetFileName (fileName);
- watcher.Changed += (FileSystemEventHandler) DispatchService.GuiDispatch (new FileSystemEventHandler (OnSteticFileChanged));
+ watcher.Changed += DispatchService.GuiDispatch (new FileSystemEventHandler (OnSteticFileChanged));
watcher.EnableRaisingEvents = true;
}
}
@@ -280,7 +280,7 @@ void RegisterWindow (Stetic.WidgetInfo widget, bool notify)
if (w.RootWidget == widget)
return;
- GuiBuilderWindow win = new GuiBuilderWindow (this, gproject, widget);
+ var win = new GuiBuilderWindow (this, gproject, widget);
formInfos.Add (win);
if (notify) {
@@ -349,7 +349,7 @@ void OnFileAdded (object sender, ProjectFileEventArgs e)
string path = Path.Combine (dir, t.FullName + ".xml");
if (!System.IO.File.Exists (path))
continue;
- XmlDocument xmldoc = new XmlDocument ();
+ var xmldoc = new XmlDocument ();
xmldoc.Load (path);
AddNewComponent (xmldoc.DocumentElement);
System.IO.File.Delete (path);
@@ -359,7 +359,7 @@ void OnFileAdded (object sender, ProjectFileEventArgs e)
void OnFileRemoved (object sender, ProjectFileEventArgs e)
{
- ArrayList toDelete = new ArrayList ();
+ var toDelete = new ArrayList ();
foreach (ProjectFileEventInfo args in e) {
var doc = TypeSystemService.ParseFile (args.Project, args.ProjectFile.Name);
@@ -410,7 +410,7 @@ string GetReferenceLibraryPath (MonoDevelop.Projects.ProjectReference pref)
string path = null;
if (pref.ReferenceType == ReferenceType.Project) {
- DotNetProject p = project.ParentSolution.FindProjectByName (pref.Reference) as DotNetProject;
+ var p = project.ParentSolution.FindProjectByName (pref.Reference) as DotNetProject;
if (p != null)
path = p.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
} else if (pref.ReferenceType == ReferenceType.Assembly) {
@@ -420,8 +420,7 @@ string GetReferenceLibraryPath (MonoDevelop.Projects.ProjectReference pref)
}
if (path != null && GuiBuilderService.SteticApp.IsWidgetLibrary (path))
return path;
- else
- return null;
+ return null;
}
public void ImportGladeFile ()
@@ -490,9 +489,7 @@ public FilePath GetSourceCodeFile (Stetic.ProjectItemInfo obj)
public FilePath GetSourceCodeFile (Stetic.ProjectItemInfo obj, bool getUserClass)
{
var cls = GetClass (obj, getUserClass);
- if (cls != null)
- return cls.Region.FileName;
- return null;
+ return cls != null ? cls.Region.FileName : null;
}
IUnresolvedTypeDefinition GetClass (Stetic.ProjectItemInfo obj, bool getUserClass)
@@ -529,7 +526,7 @@ public IUnresolvedTypeDefinition FindClass (string className, bool getUserClass)
}
if (getUserClass && !string.IsNullOrEmpty (cls.Region.FileName) && ((FilePath)cls.Region.FileName).IsChildPathOf (gui_folder))
continue;
- return cls.Parts.First ();
+ return cls.Parts [0];
}
}
return null;
@@ -561,7 +558,7 @@ public void UpdateLibraries ()
string[] oldLibs = gproject.WidgetLibraries;
- ArrayList libs = new ArrayList ();
+ var libs = new ArrayList ();
string[] internalLibs;
foreach (var pref in project.References) {
@@ -570,7 +567,7 @@ public void UpdateLibraries ()
libs.Add (wref);
}
- ReferenceManager refmgr = new ReferenceManager (project);
+ var refmgr = new ReferenceManager (project);
string target_version = refmgr.TargetGtkVersion;
refmgr.Dispose ();
@@ -582,11 +579,11 @@ public void UpdateLibraries ()
string outLib = project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration);
if (!string.IsNullOrEmpty (outLib))
- internalLibs = new string [] { outLib };
+ internalLibs = new [] { outLib };
else
internalLibs = new string [0];
- string[] newLibs = (string[]) libs.ToArray (typeof(string));
+ var newLibs = (string[]) libs.ToArray (typeof(string));
// See if something has changed
if (LibrariesChanged (oldLibs, internalLibs, newLibs)) {
@@ -600,7 +597,7 @@ public void UpdateLibraries ()
SaveAll (true);
}
- bool LibrariesChanged (string[] oldLibs, string[] internalLibs, string[] newLibs)
+ static bool LibrariesChanged (string[] oldLibs, string[] internalLibs, string[] newLibs)
{
if (oldLibs.Length == newLibs.Length + internalLibs.Length) {
foreach (string s in newLibs) {
@@ -612,8 +609,8 @@ bool LibrariesChanged (string[] oldLibs, string[] internalLibs, string[] newLibs
return true;
}
return false;
- } else
- return true;
+ }
+ return true;
}
void NotifyChanged ()
@@ -624,12 +621,12 @@ void NotifyChanged ()
public StringCollection GenerateFiles (string guiFolder)
{
- StringCollection files = new StringCollection ();
+ var files = new StringCollection ();
if (hasError)
return files;
- IDotNetLanguageBinding binding = LanguageBindingService.GetBindingPerLanguageName (project.LanguageName) as IDotNetLanguageBinding;
+ var binding = LanguageBindingService.GetBindingPerLanguageName (project.LanguageName) as IDotNetLanguageBinding;
string path = Path.Combine (guiFolder, binding.GetFileName ("generated"));
if (!System.IO.File.Exists (path)) {
// Generate an empty build class
@@ -656,7 +653,7 @@ public StringCollection GenerateFiles (string guiFolder)
public class WindowEventArgs: EventArgs
{
- GuiBuilderWindow win;
+ readonly GuiBuilderWindow win;
public WindowEventArgs (GuiBuilderWindow win)
{
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
===================================================================
@@ -34,7 +34,6 @@
using MonoDevelop.Ide.Gui;
using MonoDevelop.Projects;
-using MonoDevelop.Projects.Text;
using MonoDevelop.Core;
using MonoDevelop.Core.Execution;
using MonoDevelop.Deployment;
@@ -46,9 +45,9 @@
namespace MonoDevelop.GtkCore.GuiBuilder
{
- class GuiBuilderService
+ static class GuiBuilderService
{
- static string GuiBuilderLayout = "Visual Design";
+ const string GuiBuilderLayout = "Visual Design";
static int loadedGuiProjects;
#if DUMMY_STRINGS_FOR_TRANSLATION_DO_NOT_COMPILE
@@ -65,7 +64,7 @@ private void DoNotCompile ()
static bool generating;
- static Stetic.IsolationMode IsolationMode = Stetic.IsolationMode.None;
+ static readonly Stetic.IsolationMode IsolationMode = Stetic.IsolationMode.None;
// static Stetic.IsolationMode IsolationMode = Stetic.IsolationMode.ProcessUnix;
static GuiBuilderService ()
@@ -201,7 +200,7 @@ static void OnActiveDocumentChanged (object s, EventArgs args)
SetDesignerLayout ();
return;
}
- else if (SteticApp.ActiveDesigner != null) {
+ if (SteticApp.ActiveDesigner != null) {
SteticApp.ActiveDesigner = null;
RestoreLayout ();
}
@@ -217,7 +216,7 @@ static void SetDesignerLayout ()
Pad p = IdeApp.Workbench.GetPad<MonoDevelop.DesignerSupport.ToolboxPad> ();
if (p != null) p.Visible = true;
p = IdeApp.Workbench.GetPad<MonoDevelop.DesignerSupport.PropertyPad> ();
- if (p != null) p.Visible = true;
+ p.Visible |= p != null;
}
}
}
@@ -322,13 +321,13 @@ static string GenerateSteticCodeStructure (DotNetProject project, Stetic.Project
if (item != null)
component = item.Component;
- CodeCompileUnit cu = new CodeCompileUnit ();
+ var cu = new CodeCompileUnit ();
if (project.UsePartialTypes) {
- CodeNamespace cns = new CodeNamespace (ns);
+ var cns = new CodeNamespace (ns);
cu.Namespaces.Add (cns);
- CodeTypeDeclaration type = new CodeTypeDeclaration (name);
+ var type = new CodeTypeDeclaration (name);
type.IsPartial = true;
type.Attributes = MemberAttributes.Public;
type.TypeAttributes = System.Reflection.TypeAttributes.Public;
@@ -349,7 +348,7 @@ static string GenerateSteticCodeStructure (DotNetProject project, Stetic.Project
} else {
if (!saveToFile)
return fileName;
- CodeNamespace cns = new CodeNamespace ();
+ var cns = new CodeNamespace ();
cns.Comments.Add (new CodeCommentStatement ("Generated code for component " + component.Name));
cu.Namespaces.Add (cns);
}
@@ -361,7 +360,7 @@ static string GenerateSteticCodeStructure (DotNetProject project, Stetic.Project
string text;
var pol = project.Policies.Get<TextStylePolicy> ();
using (var fileStream = new StringWriter ()) {
- var options = new CodeGeneratorOptions () {
+ var options = new CodeGeneratorOptions {
IndentString = pol.TabsToSpaces? new string (' ', pol.TabWidth) : "\t",
BlankLinesBetweenMembers = true,
};
@@ -442,7 +441,7 @@ public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor m
info.GuiBuilderProject.UpdateLibraries ();
- ArrayList projects = new ArrayList ();
+ var projects = new ArrayList ();
projects.Add (info.GuiBuilderProject.File);
generating = true;
@@ -458,7 +457,7 @@ public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor m
System.Threading.ThreadPool.QueueUserWorkItem (delegate {
try {
// Generate the code in another process if stetic is not isolated
- CodeGeneratorProcess cob = (CodeGeneratorProcess)Runtime.ProcessService.CreateExternalProcessObject (typeof(CodeGeneratorProcess), false);
+ var cob = (CodeGeneratorProcess)Runtime.ProcessService.CreateExternalProcessObject (typeof(CodeGeneratorProcess), false);
using (cob) {
generationResult = cob.GenerateCode (projects, info.GenerateGettext, info.GettextClass, project.UsePartialTypes);
}
@@ -478,7 +477,7 @@ public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor m
// No need to create another process, since stetic has its own backend process
// or the widget libraries have no custom wrappers
try {
- Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
+ var options = new Stetic.GenerationOptions ();
options.UseGettext = info.GenerateGettext;
options.GettextClass = info.GettextClass;
options.UsePartialClasses = project.UsePartialTypes;
@@ -509,7 +508,7 @@ public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor m
string ext = Path.GetExtension (info.SteticGeneratedFile);
var pol = project.Policies.Get<TextStylePolicy> ();
- var codeGeneratorOptions = new CodeGeneratorOptions () {
+ var codeGeneratorOptions = new CodeGeneratorOptions {
IndentString = pol.TabsToSpaces? new string (' ', pol.TabWidth) : "\t",
BlankLinesBetweenMembers = true
};
@@ -520,7 +519,7 @@ public static Stetic.CodeGenerationResult GenerateSteticCode (IProgressMonitor m
fname = info.SteticGeneratedFile;
else
fname = Path.Combine (basePath, unit.Name) + ext;
- StringWriter sw = new StringWriter ();
+ var sw = new StringWriter ();
try {
foreach (CodeNamespace ns in unit.Namespaces)
ns.Comments.Add (new CodeCommentStatement ("This file has been generated by the GUI designer. Do not modify."));
@@ -555,13 +554,13 @@ internal static string ImportFile (Project prj, string file)
{
ProjectFile pfile = prj.Files.GetFile (file);
if (pfile == null) {
- var files = IdeApp.ProjectOperations.AddFilesToProject (prj, new string[] { file }, prj.BaseDirectory);
+ var files = IdeApp.ProjectOperations.AddFilesToProject (prj, new [] { file }, prj.BaseDirectory);
if (files.Count == 0 || files[0] == null)
return null;
pfile = files [0];
}
if (pfile.BuildAction == BuildAction.EmbeddedResource) {
- AlertButton embedButton = new AlertButton (GettextCatalog.GetString ("_Use as Source"));
+ var embedButton = new AlertButton (GettextCatalog.GetString ("_Use as Source"));
if (MessageService.AskQuestion (GettextCatalog.GetString ("You are requesting the file '{0}' to be used as source for an image. However, this file is already added to the project as a resource. Are you sure you want to continue (the file will have to be removed from the resource list)?"), AlertButton.Cancel, embedButton) == embedButton)
return null;
}
@@ -591,7 +590,7 @@ static string FormatGeneratedFile (string file, string content, Project project,
static string StripHeaderAndBlankLines (string text, CodeDomProvider provider)
{
- Mono.TextEditor.TextDocument doc = new Mono.TextEditor.TextDocument ();
+ var doc = new Mono.TextEditor.TextDocument ();
doc.Text = text;
int realStartLine = 0;
for (int i = 1; i <= doc.LineCount; i++) {
@@ -654,13 +653,13 @@ public Stetic.CodeGenerationResult GenerateCode (ArrayList projectFiles, bool us
Stetic.Application app = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
- Stetic.Project[] projects = new Stetic.Project [projectFiles.Count];
+ var projects = new Stetic.Project [projectFiles.Count];
for (int n=0; n < projectFiles.Count; n++) {
projects [n] = app.CreateProject ();
projects [n].Load ((string) projectFiles [n]);
}
- Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
+ var options = new Stetic.GenerationOptions ();
options.UseGettext = useGettext;
options.GettextClass = gettextClass;
options.UsePartialClasses = usePartialClasses;
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
===================================================================
@@ -41,7 +41,6 @@
using MonoDevelop.DesignerSupport;
using Gtk;
-using Gdk;
using MonoDevelop.Ide;
namespace MonoDevelop.GtkCore.GuiBuilder
@@ -52,13 +51,13 @@ public class GuiBuilderView : CombinedDesignView, ISupportsProjectReload
Stetic.ActionGroupDesigner actionsBox;
GuiBuilderWindow window;
- DesignerPage designerPage;
- ActionGroupPage actionsPage;
+ readonly DesignerPage designerPage;
+ readonly ActionGroupPage actionsPage;
CodeBinder codeBinder;
GuiBuilderProject gproject;
- string rootName;
+ readonly string rootName;
object designerStatus;
public GuiBuilderView (IViewContent content, GuiBuilderWindow window): base (content)
@@ -101,7 +100,7 @@ void ISupportsProjectReload.Update (Project project)
CloseDesigner ();
CloseProject ();
if (project != null) {
- GuiBuilderWindow w = GuiBuilderDisplayBinding.GetWindow (this.ContentName);
+ GuiBuilderWindow w = GuiBuilderDisplayBinding.GetWindow (ContentName);
if (w != null) {
AttachWindow (w);
if (designerStatus != null)
@@ -113,7 +112,7 @@ void ISupportsProjectReload.Update (Project project)
void LoadDesigner ()
{
- this.window = gproject.GetWindow (rootName);
+ window = gproject.GetWindow (rootName);
if (window == null) {
// The window doesn't exist anymore
return;
@@ -150,8 +149,8 @@ void LoadDesigner ()
// Actions designer
actionsBox = designer.CreateActionGroupDesigner ();
actionsBox.AllowActionBinding = !gproject.Project.UsePartialTypes;
- actionsBox.BindField += new EventHandler (OnBindActionField);
- actionsBox.ModifiedChanged += new EventHandler (OnActionshanged);
+ actionsBox.BindField += OnBindActionField;
+ actionsBox.ModifiedChanged += OnActionshanged;
actionsPage.ClearChild ();
actionsPage.PackStart (actionsBox, true, true, 0);
@@ -232,9 +231,9 @@ public override void Dispose ()
base.Dispose ();
}
- Gtk.Widget CreateDesignerNotAvailableWidget ()
+ static Widget CreateDesignerNotAvailableWidget ()
{
- Gtk.Label label = new Gtk.Label (GettextCatalog.GetString ("Designer not available"));
+ var label = new Label (GettextCatalog.GetString ("Designer not available"));
label.Show ();
return label;
}
@@ -247,7 +246,7 @@ protected override void OnPageShown (int npage)
// the code for the window (only the fields in fact) and update the parser database, it
// will not save the code to disk.
if (gproject.Project.UsePartialTypes)
- GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project, designer.RootComponent, null, false, false);
+ GuiBuilderService.GenerateSteticCodeStructure (gproject.Project, designer.RootComponent, null, false, false);
}
base.OnPageShown (npage);
}
@@ -271,7 +270,7 @@ void OnComponentNameChanged (object s, Stetic.ComponentNameEventArgs args)
// old name, and UpdateField will be able to find it (to rename the
// references to the field, it needs to have the old name).
if (gproject.Project.UsePartialTypes)
- GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project, designer.RootComponent, args, false, false);
+ GuiBuilderService.GenerateSteticCodeStructure (gproject.Project, designer.RootComponent, args, false, false);
codeBinder.UpdateField (args.Component, args.OldName);
}
@@ -280,7 +279,7 @@ void OnComponentNameChanged (object s, Stetic.ComponentNameEventArgs args)
}
}
- void OnComponentTypesChanged (object s, EventArgs a)
+ static void OnComponentTypesChanged (object s, EventArgs a)
{
if (ToolboxProvider.Instance != null)
ToolboxProvider.Instance.NotifyItemsChanged ();
@@ -398,9 +397,9 @@ public void ShowActionDesignerView (string name)
}
}
- class DesignerPage: Gtk.EventBox, ICustomPropertyPadProvider, IToolboxConsumer, MonoDevelop.DesignerSupport.IOutlinedDocument
+ class DesignerPage: EventBox, ICustomPropertyPadProvider, IToolboxConsumer, IOutlinedDocument
{
- GuiBuilderProject gproject;
+ readonly GuiBuilderProject gproject;
public DesignerPage (GuiBuilderProject gproject)
{
@@ -409,17 +408,14 @@ public DesignerPage (GuiBuilderProject gproject)
public Stetic.ComponentType[] GetComponentTypes ()
{
- if (Designer != null)
- return Designer.GetComponentTypes ();
- else
- return null;
+ return Designer != null ? Designer.GetComponentTypes () : null;
}
public DotNetProject Project {
get { return gproject.Project; }
}
- Gtk.Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
+ Widget ICustomPropertyPadProvider.GetCustomPropertyWidget ()
{
return PropertiesWidget.Instance;
}
@@ -437,7 +433,7 @@ void ICustomPropertyPadProvider.DisposeCustomPropertyWidget ()
public void ClearChild ()
{
if (Child != null) {
- Gtk.Widget w = Child;
+ Widget w = Child;
Remove (w);
w.Destroy ();
}
@@ -450,7 +446,7 @@ void IToolboxConsumer.ConsumeItem (ItemToolboxNode item)
//Toolbox service uses this to filter toolbox items.
ToolboxItemFilterAttribute[] IToolboxConsumer.ToolboxFilterAttributes {
get {
- return new ToolboxItemFilterAttribute [] {
+ return new [] {
new ToolboxItemFilterAttribute ("gtk-sharp", ToolboxItemFilterType.Custom)
};
}
@@ -460,7 +456,7 @@ void IToolboxConsumer.ConsumeItem (ItemToolboxNode item)
//If not expecting it, should just return false
bool IToolboxConsumer.CustomFilterSupports (ItemToolboxNode item)
{
- ComponentToolboxNode cnode = item as ComponentToolboxNode;
+ var cnode = item as ComponentToolboxNode;
if (cnode != null && gproject.SteticProject != null) {
if (cnode.GtkVersion == null || Mono.Addins.Addin.CompareVersions (gproject.SteticProject.TargetGtkVersion, cnode.GtkVersion) <= 0)
return true;
@@ -472,10 +468,10 @@ bool IToolboxConsumer.CustomFilterSupports (ItemToolboxNode item)
get { return ComponentToolboxNode.GtkWidgetDomain; }
}
- void IToolboxConsumer.DragItem (ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx)
+ void IToolboxConsumer.DragItem (ItemToolboxNode item, Widget source, Gdk.DragContext ctx)
{
if (Designer != null) {
- ComponentToolboxNode node = item as ComponentToolboxNode;
+ var node = item as ComponentToolboxNode;
if (node != null) {
if (node.Reference == null)
Designer.BeginComponentDrag (node.ComponentType, source, ctx);
@@ -598,17 +594,17 @@ protected void OnUpdateRedo (CommandInfo cinfo)
cinfo.Enabled = Designer != null && Designer.UndoQueue.CanRedo;
}
- Widget MonoDevelop.DesignerSupport.IOutlinedDocument.GetOutlineWidget ()
+ Widget IOutlinedDocument.GetOutlineWidget ()
{
return GuiBuilderDocumentOutline.Instance;
}
- IEnumerable<Gtk.Widget> MonoDevelop.DesignerSupport.IOutlinedDocument.GetToolbarWidgets ()
+ IEnumerable<Widget> IOutlinedDocument.GetToolbarWidgets ()
{
return null;
}
- void MonoDevelop.DesignerSupport.IOutlinedDocument.ReleaseOutlineWidget ()
+ void IOutlinedDocument.ReleaseOutlineWidget ()
{
//Do nothing. We keep the instance to avoid creation cost when switching documents.
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs
===================================================================
@@ -33,7 +33,6 @@
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
-using MonoDevelop.Projects;
using MonoDevelop.Projects.Text;
using MonoDevelop.GtkCore.Dialogs;
using MonoDevelop.Ide;
@@ -44,8 +43,8 @@ namespace MonoDevelop.GtkCore.GuiBuilder
public class GuiBuilderWindow: IDisposable
{
Stetic.WidgetInfo rootWidget;
- GuiBuilderProject fproject;
- Stetic.Project gproject;
+ readonly GuiBuilderProject fproject;
+ readonly Stetic.Project gproject;
string name;
public event WindowEventHandler Changed;
@@ -106,7 +105,7 @@ public bool BindToClass ()
// Find the classes that could be bound to this design
var ctx = fproject.GetParserContext ();
- ArrayList list = new ArrayList ();
+ var list = new ArrayList ();
foreach (var cls in ctx.MainAssembly.GetAllTypeDefinitions ()) {
if (IsValidClass (cls))
list.Add (cls.FullName);
@@ -115,7 +114,7 @@ public bool BindToClass ()
// Ask what to do
try {
- using (BindDesignDialog dialog = new BindDesignDialog (Name, list, Project.Project.BaseDirectory)) {
+ using (var dialog = new BindDesignDialog (Name, list, Project.Project.BaseDirectory)) {
if (!dialog.Run ())
return false;
@@ -209,7 +208,7 @@ void CreateClass (string name, string namspace, string folder)
void AddSignalsRec (CodeTypeDeclaration type, Stetic.Component comp)
{
foreach (Stetic.Signal signal in comp.GetSignals ()) {
- CodeMemberMethod met = new CodeMemberMethod ();
+ var met = new CodeMemberMethod ();
met.Name = signal.Handler;
met.Attributes = MemberAttributes.Family;
met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/PropertiesWidget.cs
===================================================================
@@ -30,18 +30,13 @@
using System;
using Gtk;
using MonoDevelop.Core;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide.Commands;
-
namespace MonoDevelop.GtkCore.GuiBuilder
{
- class PropertiesWidget: Gtk.VBox
+ class PropertiesWidget: VBox
{
public static PropertiesWidget Instance;
- Stetic.SignalsEditor signalsEditor;
+ readonly Stetic.SignalsEditor signalsEditor;
static PropertiesWidget ()
{
@@ -52,16 +47,16 @@ public PropertiesWidget ()
{
Stetic.WidgetPropertyTree grid = GuiBuilderService.SteticApp.PropertiesWidget;
- Notebook tabs = new Notebook ();
+ var tabs = new Notebook ();
tabs.AppendPage (grid, new Label (GettextCatalog.GetString ("Properties")));
signalsEditor = GuiBuilderService.SteticApp.SignalsWidget;
- signalsEditor.SignalActivated += new EventHandler (OnSignalActivated);
+ signalsEditor.SignalActivated += OnSignalActivated;
tabs.AppendPage (signalsEditor, new Label (GettextCatalog.GetString ("Signals")));
- Gtk.EventBox infoBox = new Gtk.EventBox ();
- tabs.AppendPage (infoBox, new Gtk.Label (""));
+ var infoBox = new EventBox ();
+ tabs.AppendPage (infoBox, new Label (""));
PackStart (tabs, true, true, 0);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs
===================================================================
@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Collections.Generic;
using MonoDevelop.DesignerSupport.Toolbox;
using MonoDevelop.Projects;
@@ -40,7 +39,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder
public class ToolboxLoader: IToolboxLoader
{
public virtual string[] FileTypes {
- get { return new string [] { "dll", "exe" }; }
+ get { return new [] { "dll", "exe" }; }
}
public virtual IList<ItemToolboxNode> Load (LoaderContext ctx, string filename)
@@ -57,7 +56,7 @@ public virtual IList<ItemToolboxNode> Load (LoaderContext ctx, string filename)
rname = filename;
}
- List<ItemToolboxNode> list = new List<ItemToolboxNode> ();
+ var list = new List<ItemToolboxNode> ();
ComponentType[] types = null;
DispatchService.GuiSyncDispatch (delegate {
// Stetic is not thread safe, it has to be used from the gui thread
@@ -66,7 +65,7 @@ public virtual IList<ItemToolboxNode> Load (LoaderContext ctx, string filename)
foreach (ComponentType ct in types) {
if (ct.Category == "window")
continue;
- ComponentToolboxNode cn = new ComponentToolboxNode (ct);
+ var cn = new ComponentToolboxNode (ct);
cn.ReferenceType = rt;
cn.Reference = rname;
list.Add (cn);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxProvider.cs
===================================================================
@@ -24,7 +24,7 @@ public ToolboxProvider ()
public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer)
{
- DesignerPage view = consumer as DesignerPage;
+ var view = consumer as DesignerPage;
if (view == null)
return null;
@@ -32,11 +32,11 @@ public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer)
if (types == null)
return null;
- Hashtable refs = new Hashtable ();
- Hashtable projects = new Hashtable ();
+ var refs = new Hashtable ();
+ var projects = new Hashtable ();
string of = FileService.GetFullPath (view.Project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration));
projects [of] = view.Project.Name;
- foreach (ProjectReference pr in ((DotNetProject)view.Project).References)
+ foreach (ProjectReference pr in view.Project.References)
foreach (string f in pr.GetReferencedFileNames (IdeApp.Workspace.ActiveConfiguration)) {
if (pr.ReferenceType == ReferenceType.Project)
projects[FileService.GetFullPath (f)] = pr.Reference;
@@ -44,7 +44,7 @@ public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer)
refs[FileService.GetFullPath (f)] = f;
}
- List<ItemToolboxNode> list = new List<ItemToolboxNode> ();
+ var list = new List<ItemToolboxNode> ();
foreach (ComponentType type in types) {
if (type.Category == "window")
continue;
@@ -54,10 +54,10 @@ public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer)
fullName = FileService.GetFullPath (type.Library);
if (type.ClassName == "Gtk.Action" || (fullName != null && refs.Contains (fullName))) {
- ComponentToolboxNode node = new ComponentToolboxNode (type);
+ var node = new ComponentToolboxNode (type);
list.Add (node);
} else if (fullName != null && projects.Contains (fullName)) {
- ComponentToolboxNode node = new ComponentToolboxNode (type);
+ var node = new ComponentToolboxNode (type);
node.Category = (string) projects [fullName];
list.Add (node);
}
@@ -94,11 +94,11 @@ class ComponentToolboxNode: ItemToolboxNode
[ItemProperty]
string reference;
[ItemProperty]
- string className;
+ readonly string className;
[ItemProperty]
- string gtkVersion;
+ readonly string gtkVersion;
- static ToolboxItemFilterAttribute[] attributes = new ToolboxItemFilterAttribute[] {
+ static readonly ToolboxItemFilterAttribute[] attributes = {
new ToolboxItemFilterAttribute ("gtk-sharp", ToolboxItemFilterType.Require)
};
@@ -133,7 +133,7 @@ public ComponentToolboxNode (ComponentType type)
}
[Browsable (false)]
- public Stetic.ComponentType ComponentType {
+ public ComponentType ComponentType {
get {
return componentType;
}
@@ -183,14 +183,13 @@ public ComponentToolboxNode (ComponentType type)
}
}
- string GetCategoryName (string cat)
+ static string GetCategoryName (string cat)
{
if (cat == "container")
return GettextCatalog.GetString ("Containers");
- else if (cat == "widget")
+ if (cat == "widget")
return GettextCatalog.GetString ("Widgets");
- else
- return cat;
+ return cat;
}
[Browsable (false)]
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ActionGroupNodeBuilder.cs
===================================================================
@@ -53,27 +53,27 @@ public class ActionGroupNodeBuilder: TypeNodeBuilder
public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
{
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
+ var group = (Stetic.ActionGroupInfo) dataObject;
return group.Name;
}
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
{
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
+ var group = (Stetic.ActionGroupInfo) dataObject;
label = group.Name;
icon = ImageService.GetPixbuf ("md-gtkcore-actiongroup", Gtk.IconSize.Menu);
}
public override void OnNodeAdded (object dataObject)
{
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
- group.Changed += new EventHandler (OnChanged);
+ var group = (Stetic.ActionGroupInfo) dataObject;
+ group.Changed += OnChanged;
}
public override void OnNodeRemoved (object dataObject)
{
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) dataObject;
- group.Changed -= new EventHandler (OnChanged);
+ var group = (Stetic.ActionGroupInfo) dataObject;
+ group.Changed -= OnChanged;
}
void OnChanged (object s, EventArgs a)
@@ -88,7 +88,7 @@ class ActionGroupCommandHandler: NodeCommandHandler
{
public override void ActivateItem ()
{
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
+ var w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
if (w != null) {
if (w.SourceCodeFile == FilePath.Null && !w.BindToClass ())
return;
@@ -101,8 +101,8 @@ public override void ActivateItem ()
}
}
else {
- Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) CurrentNode.DataItem;
+ var project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
+ var group = (Stetic.ActionGroupInfo) CurrentNode.DataItem;
GuiBuilderService.OpenActionGroup (project, group);
}
}
@@ -110,24 +110,24 @@ public override void ActivateItem ()
public override bool CanDeleteItem ()
{
// Don't allow deleting action groups local to a window
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
+ var w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
return (w == null);
}
public override void DeleteItem ()
{
// Don't allow deleting action groups local to a window
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
+ var w = (GuiBuilderWindow) CurrentNode.GetParentDataItem (typeof(GuiBuilderWindow), false);
if (w != null)
return;
- Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
- Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo) CurrentNode.DataItem;
+ var project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
+ var group = (Stetic.ActionGroupInfo) CurrentNode.DataItem;
GuiBuilderProject gproject = GtkDesignInfo.FromProject (project).GuiBuilderProject;
string sfile = gproject.GetSourceCodeFile (group);
if (sfile != null) {
- using (ConfirmWindowDeleteDialog dialog = new ConfirmWindowDeleteDialog (group.Name, sfile, group)) {
+ using (var dialog = new ConfirmWindowDeleteDialog (group.Name, sfile, group)) {
if (dialog.Run () == (int) Gtk.ResponseType.Yes) {
if (dialog.DeleteFile) {
ProjectFile file = project.GetProjectFile (sfile);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectFolderNodeBuilderExtension.cs
===================================================================
@@ -49,12 +49,12 @@ public override bool CanBuildNode (Type dataType)
get { return typeof(UserInterfaceCommandHandler); }
}
- public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
+ public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
{
- if (treeNavigator.Options ["ShowAllFiles"])
+ if (parentNode.Options ["ShowAllFiles"])
return;
- ProjectFolder folder = dataObject as ProjectFolder;
+ var folder = dataObject as ProjectFolder;
if (folder != null && folder.Project is DotNetProject) {
GtkDesignInfo info = GtkDesignInfo.FromProject (folder.Project);
if (info.GtkGuiFolder == folder.Path)
@@ -65,49 +65,49 @@ public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dat
class UserInterfaceCommandHandler: NodeCommandHandler
{
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewDialog)]
+ [CommandHandler (GtkCommands.AddNewDialog)]
public void AddNewDialogToProject()
{
AddNewWindow ("DialogFileTemplate");
}
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewDialog)]
+ [CommandUpdateHandler (GtkCommands.AddNewDialog)]
public void UpdateAddNewDialogToProject (CommandInfo cinfo)
{
cinfo.Visible = CanAddWindow ();
}
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWindow)]
+ [CommandHandler (GtkCommands.AddNewWindow)]
public void AddNewWindowToProject()
{
AddNewWindow ("WindowFileTemplate");
}
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWindow)]
+ [CommandUpdateHandler (GtkCommands.AddNewWindow)]
public void UpdateAddNewWindowToProject (CommandInfo cinfo)
{
cinfo.Visible = CanAddWindow ();
}
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWidget)]
+ [CommandHandler (GtkCommands.AddNewWidget)]
public void AddNewWidgetToProject()
{
AddNewWindow ("WidgetFileTemplate");
}
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewWidget)]
+ [CommandUpdateHandler (GtkCommands.AddNewWidget)]
public void UpdateAddNewWidgetToProject (CommandInfo cinfo)
{
cinfo.Visible = CanAddWindow ();
}
- [CommandHandler (MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup)]
+ [CommandHandler (GtkCommands.AddNewActionGroup)]
public void AddNewActionGroupToProject()
{
AddNewWindow ("ActionGroupFileTemplate");
}
- [CommandUpdateHandler (MonoDevelop.GtkCore.GtkCommands.AddNewActionGroup)]
+ [CommandUpdateHandler (GtkCommands.AddNewActionGroup)]
public void UpdateAddNewActionGroupToProject(CommandInfo cinfo)
{
cinfo.Visible = CanAddWindow ();
@@ -116,7 +116,7 @@ public void UpdateAddNewActionGroupToProject(CommandInfo cinfo)
[CommandHandler (GtkCommands.ImportGladeFile)]
protected void OnImportGladeFile ()
{
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
+ var project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
GuiBuilderService.ImportGladeFile (project);
}
@@ -129,7 +129,7 @@ protected void UpdateImportGladeFile (CommandInfo cinfo)
[CommandHandler (GtkCommands.EditIcons)]
protected void OnEditIcons ()
{
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
+ var project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
GuiBuilderProject gp = GtkDesignInfo.FromProject (project).GuiBuilderProject;
Stetic.Project sp = gp.SteticProject;
sp.EditIcons ();
@@ -145,7 +145,7 @@ protected void UpdateEditIcons (CommandInfo cinfo)
[CommandHandler (GtkCommands.GtkSettings)]
protected void OnGtkSettings ()
{
- Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
+ var project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project;
IdeApp.ProjectOperations.ShowOptions (project, "SteticOptionsPanel");
}
@@ -157,28 +157,24 @@ protected void UpdateGtkSettings (CommandInfo cinfo)
bool CanAddWindow ()
{
- DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
+ var project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
return GtkDesignInfo.SupportsDesigner (project);
}
public void AddNewWindow (string id)
{
- DotNetProject project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
+ var project = CurrentNode.GetParentDataItem (typeof(Project), true) as DotNetProject;
if (project == null)
return;
object dataItem = CurrentNode.DataItem;
- ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
+ var folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder;
if (project.UsePartialTypes)
id = "Partial" + id;
- string path;
- if (folder != null)
- path = folder.Path;
- else
- path = project.BaseDirectory;
+ string path = folder != null ? folder.Path : project.BaseDirectory;
IdeApp.ProjectOperations.CreateProjectFile (project, path, id);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/ProjectNodeBuilder.cs
===================================================================
@@ -27,16 +27,9 @@
//
using System;
-using System.Collections;
-
using MonoDevelop.Projects;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.GtkCore.GuiBuilder;
-
namespace MonoDevelop.GtkCore.NodeBuilders
{
public class ProjectNodeBuilder: NodeBuilderExtension
@@ -60,10 +53,10 @@ public override void Dispose ()
instance = null;
}
- public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
+ public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
{
if (GtkDesignInfo.HasDesignedObjects ((Project)dataObject))
- builder.AddChild (new WindowsFolder ((Project)dataObject));
+ treeBuilder.AddChild (new WindowsFolder ((Project)dataObject));
}
public static void OnSupportChanged (Project p)
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/StockIconsNodeBuilder.cs
===================================================================
@@ -2,7 +2,6 @@
using System;
using Gdk;
-using MonoDevelop.Ide.Gui.Pads;
using MonoDevelop.Core;
using MonoDevelop.Projects;
using MonoDevelop.Components.Commands;
@@ -15,7 +14,7 @@ class StockIconsNode
{
public StockIconsNode (Project project)
{
- this.Project = project;
+ Project = project;
}
public Project Project;
@@ -23,7 +22,7 @@ public StockIconsNode (Project project)
public class StockIconsNodeBuilder: TypeNodeBuilder
{
- Pixbuf iconsIcon;
+ readonly Pixbuf iconsIcon;
public override Type NodeDataType {
get { return typeof(StockIconsNode); }
@@ -66,14 +65,12 @@ public class StockIconsNodeCommandHandler: NodeCommandHandler
{
public override void ActivateItem ()
{
- StockIconsNode node = (StockIconsNode) CurrentNode.DataItem;
+ var node = (StockIconsNode) CurrentNode.DataItem;
GtkDesignInfo info = GtkDesignInfo.FromProject (node.Project);
GuiBuilderProject gp = info.GuiBuilderProject;
Stetic.Project sp = gp.SteticProject;
sp.ImagesRootPath = FileService.AbsoluteToRelativePath (info.GtkGuiFolder, gp.Project.BaseDirectory);
- sp.ImportFileCallback = delegate (string file) {
- return GuiBuilderService.ImportFile (gp.Project, file);
- };
+ sp.ImportFileCallback = file => GuiBuilderService.ImportFile (gp.Project, file);
sp.EditIcons ();
gp.SaveProject (true);
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WidgetNodeBuilder.cs
===================================================================
@@ -40,7 +40,7 @@ namespace MonoDevelop.GtkCore.NodeBuilders
{
public class WidgetNodeBuilder: TypeNodeBuilder
{
- WindowEventHandler onChanged;
+ readonly WindowEventHandler onChanged;
public WidgetNodeBuilder ()
{
@@ -61,46 +61,43 @@ public WidgetNodeBuilder ()
public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
{
- GuiBuilderWindow win = (GuiBuilderWindow) dataObject;
+ var win = (GuiBuilderWindow) dataObject;
return win.Name;
}
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
{
- GuiBuilderWindow win = (GuiBuilderWindow) dataObject;
+ var win = (GuiBuilderWindow) dataObject;
label = win.Name;
// if (win.RootWidget.IsWindow)
// icon = ImageService.GetPixbuf ("md-gtkcore-window");
- if (win.RootWidget.IsWindow)
- icon = ImageService.GetPixbuf ("md-gtkcore-dialog", Gtk.IconSize.Menu);
- else
- icon = ImageService.GetPixbuf ("md-gtkcore-widget", Gtk.IconSize.Menu);
+ icon = ImageService.GetPixbuf (win.RootWidget.IsWindow ? "md-gtkcore-dialog" : "md-gtkcore-widget", Gtk.IconSize.Menu);
}
- public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
+ public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
{
- GuiBuilderWindow win = (GuiBuilderWindow) dataObject;
+ var win = (GuiBuilderWindow) dataObject;
foreach (Stetic.ActionGroupInfo agroup in win.RootWidget.ActionGroups) {
- builder.AddChild (agroup);
+ treeBuilder.AddChild (agroup);
}
}
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
{
- GuiBuilderWindow win = (GuiBuilderWindow) dataObject;
+ var win = (GuiBuilderWindow) dataObject;
return win.RootWidget.ActionGroups.GetEnumerator().MoveNext ();
}
public override void OnNodeAdded (object dataObject)
{
- GuiBuilderWindow win = (GuiBuilderWindow) dataObject;
+ var win = (GuiBuilderWindow) dataObject;
win.Changed += onChanged;
}
public override void OnNodeRemoved (object dataObject)
{
- GuiBuilderWindow win = (GuiBuilderWindow) dataObject;
+ var win = (GuiBuilderWindow) dataObject;
win.Changed -= onChanged;
}
@@ -116,7 +113,7 @@ class GladeWindowCommandHandler: NodeCommandHandler
{
public override void ActivateItem ()
{
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.DataItem;
+ var w = (GuiBuilderWindow) CurrentNode.DataItem;
if (w.SourceCodeFile == FilePath.Null && !w.BindToClass ())
return;
@@ -130,9 +127,9 @@ public override void ActivateItem ()
public override void DeleteItem ()
{
- GuiBuilderWindow w = (GuiBuilderWindow) CurrentNode.DataItem;
+ var w = (GuiBuilderWindow) CurrentNode.DataItem;
string fn = FileService.AbsoluteToRelativePath (w.Project.Project.BaseDirectory, w.SourceCodeFile);
- using (ConfirmWindowDeleteDialog dialog = new ConfirmWindowDeleteDialog (w.Name, fn, w.RootWidget)) {
+ using (var dialog = new ConfirmWindowDeleteDialog (w.Name, fn, w.RootWidget)) {
if (dialog.Run () == (int) Gtk.ResponseType.Yes) {
if (dialog.DeleteFile) {
ProjectFile file = w.Project.Project.GetProjectFile (w.SourceCodeFile);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WindowsFolder.cs
===================================================================
@@ -34,8 +34,8 @@ namespace MonoDevelop.GtkCore.NodeBuilders
{
class WindowsFolder
{
- Project project;
- GuiBuilderProject gproject;
+ readonly Project project;
+ readonly GuiBuilderProject gproject;
public event EventHandler Changed;
@@ -64,7 +64,7 @@ void OnUpdateFiles (object s, EventArgs args)
public override bool Equals (object obj)
{
- WindowsFolder wf = obj as WindowsFolder;
+ var wf = obj as WindowsFolder;
return wf != null && wf.project == project;
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.NodeBuilders/WindowsFolderNodeBuilder.cs
===================================================================
@@ -39,11 +39,11 @@ namespace MonoDevelop.GtkCore.NodeBuilders
{
public class WindowsFolderNodeBuilder: TypeNodeBuilder
{
- EventHandler updateDelegate;
+ readonly EventHandler updateDelegate;
public WindowsFolderNodeBuilder ()
{
- updateDelegate = (EventHandler) DispatchService.GuiDispatch (new EventHandler (OnUpdateFiles));
+ updateDelegate = DispatchService.GuiDispatch (new EventHandler (OnUpdateFiles));
}
public override Type NodeDataType {
@@ -76,16 +76,16 @@ public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref
closedIcon = Context.GetIcon (Stock.ClosedResourceFolder);
}
- public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
+ public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
{
Project p = ((WindowsFolder)dataObject).Project;
GtkDesignInfo info = GtkDesignInfo.FromProject (p);
if (!info.GuiBuilderProject.HasError) {
- builder.AddChild (new StockIconsNode (p));
+ treeBuilder.AddChild (new StockIconsNode (p));
foreach (GuiBuilderWindow fi in info.GuiBuilderProject.Windows)
- builder.AddChild (fi);
+ treeBuilder.AddChild (fi);
foreach (Stetic.ActionGroupInfo group in info.GuiBuilderProject.SteticProject.ActionGroups)
- builder.AddChild (group);
+ treeBuilder.AddChild (group);
}
}
@@ -98,13 +98,12 @@ public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator othe
{
if (otherNode.DataItem is ProjectReferenceCollection)
return 1;
- else
- return -1;
+ return -1;
}
public override void OnNodeAdded (object dataObject)
{
- WindowsFolder w = (WindowsFolder) dataObject;
+ var w = (WindowsFolder) dataObject;
w.Changed += updateDelegate;
}
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/Counters.cs
===================================================================
@@ -24,12 +24,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.Core.Instrumentation;
namespace MonoDevelop.GtkCore
{
- internal static class Counters
+ static class Counters
{
public static Counter GuiProjectsInMemory = InstrumentationService.CreateCounter ("GUI Projects in Memory", "GTK# Designer");
public static Counter GuiProjectsLoaded = InstrumentationService.CreateCounter ("GUI Projects Loaded", "GTK# Designer");
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkCoreService.cs
===================================================================
@@ -26,9 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Collections.Generic;
-using MonoDevelop.Core;
using MonoDevelop.Components.Commands;
namespace MonoDevelop.GtkCore
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/GtkDesignInfo.cs
===================================================================
@@ -61,7 +61,7 @@ public class GtkDesignInfo: IDisposable
GtkDesignInfo (DotNetProject project)
{
- IExtendedDataItem item = (IExtendedDataItem) project;
+ IExtendedDataItem item = project;
item.ExtendedProperties ["GtkDesignInfo"] = this;
Project = project;
}
@@ -198,7 +198,7 @@ public static bool SupportsDesigner (Project project)
if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DISABLE_STETIC"))) {
return false;
}
- DotNetProject dnp = project as DotNetProject;
+ var dnp = project as DotNetProject;
return dnp != null && HasGtkReference (dnp) && SupportsRefactoring (dnp);
}
@@ -215,7 +215,7 @@ static bool IsGtkReference (ProjectReference pref)
if (pref.ReferenceType != ReferenceType.Package)
return false;
- int idx = pref.StoredReference.IndexOf (",");
+ int idx = pref.StoredReference.IndexOf (",", StringComparison.Ordinal);
if (idx == -1)
return false;
@@ -236,20 +236,20 @@ public void ForceCodeGenerationOnBuild ()
if (!SupportsDesigner (project))
return;
try {
- FileInfo fi = new FileInfo (SteticFile);
+ var fi = new FileInfo (SteticFile);
fi.LastWriteTime = DateTime.Now;
} catch {
// Ignore errors here
}
}
- bool CleanGtkFolder (StringCollection remaining_files)
+ bool CleanGtkFolder (StringCollection remainingFiles)
{
bool projectModified = false;
// Remove all project files which are not in the generated list
foreach (ProjectFile pf in project.Files.GetFilesInPath (GtkGuiFolder)) {
- if (remaining_files.Contains (pf.FilePath))
+ if (remainingFiles.Contains (pf.FilePath))
continue;
project.Files.Remove (pf);
@@ -257,7 +257,7 @@ bool CleanGtkFolder (StringCollection remaining_files)
projectModified = true;
}
- if (remaining_files.Count == 0)
+ if (remainingFiles.Count == 0)
FileService.DeleteDirectory (GtkGuiFolder);
return projectModified;
@@ -277,7 +277,7 @@ public bool UpdateGtkFolder ()
if (!File.Exists (SteticFile)) {
initialGeneration = true;
- StreamWriter sw = new StreamWriter (SteticFile);
+ var sw = new StreamWriter (SteticFile);
sw.WriteLine ("<stetic-interface />");
sw.Close ();
FileService.NotifyFileChanged (SteticFile);
@@ -308,8 +308,7 @@ public bool UpdateGtkFolder ()
files.Add (ObjectsFile);
files.Add (SteticFile);
- if (CleanGtkFolder (files))
- projectModified = true;
+ projectModified |= CleanGtkFolder (files);
return ReferenceManager.Update () || projectModified;
}
@@ -319,7 +318,7 @@ void UpdateObjectsFile ()
if (!File.Exists (ObjectsFile))
return;
- ObjectsDocument doc = new ObjectsDocument (ObjectsFile);
+ var doc = new ObjectsDocument (ObjectsFile);
doc.Update (GuiBuilderProject.WidgetParser, GuiBuilderProject.SteticProject);
}
@@ -329,12 +328,12 @@ public static void DisableProject (Project project)
return;
GtkDesignInfo info = FromProject (project);
- StringCollection saveFiles = new StringCollection ();
+ var saveFiles = new StringCollection ();
saveFiles.AddRange (new string[] {info.ObjectsFile, info.SteticFile});
info.CleanGtkFolder (saveFiles);
project.Files.Remove (info.ObjectsFile);
project.Files.Remove (info.SteticFile);
- IExtendedDataItem item = (IExtendedDataItem) project;
+ IExtendedDataItem item = project;
item.ExtendedProperties.Remove ("GtkDesignInfo");
info.Dispose ();
ProjectNodeBuilder.OnSupportChanged (project);
@@ -345,7 +344,7 @@ public static GtkDesignInfo FromProject (Project project)
if (!(project is DotNetProject))
return new GtkDesignInfo ();
- IExtendedDataItem item = (IExtendedDataItem) project;
+ IExtendedDataItem item = project;
GtkDesignInfo info = item.ExtendedProperties ["GtkDesignInfo"] as GtkDesignInfo;
if (info == null)
info = new GtkDesignInfo ((DotNetProject) project);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ObjectsDocument.cs
===================================================================
@@ -29,7 +29,6 @@
using System;
using System.Xml;
-using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -43,7 +42,7 @@ namespace MonoDevelop.GtkCore
public class ObjectsDocument : XmlDocument
{
- string path;
+ readonly string path;
public ObjectsDocument (string path) : base ()
{
@@ -53,7 +52,7 @@ public ObjectsDocument (string path) : base ()
public StringCollection ObjectNames {
get {
- StringCollection names = new StringCollection ();
+ var names = new StringCollection ();
foreach (XmlNode node in DocumentElement) {
if (node.Name != "object")
continue;
@@ -76,10 +75,9 @@ enum SyncState
if (DocumentElement.HasAttribute ("attr-sync")) {
if (DocumentElement.GetAttribute ("attr-sync").ToLower () == "off")
return SyncState.Off;
- else
- return SyncState.On;
- } else
- return SyncState.Unspecified;
+ return SyncState.On;
+ }
+ return SyncState.Unspecified;
}
set {
switch (value) {
@@ -109,7 +107,7 @@ public void Save ()
Indent = true,
OmitXmlDeclaration = true,
};
- using (var writer = XmlTextWriter.Create (path, settings)) {
+ using (var writer = XmlWriter.Create (path, settings)) {
Save (writer);
}
}
@@ -124,7 +122,7 @@ void InsertToolboxItemAttributes (WidgetParser parser)
if (cls == null)
continue;
CodeGenerationService.AddAttribute (cls, "System.ComponentModel.ToolboxItem", true);
- XmlElement elem = DocumentElement.SelectSingleNode ("object[@type='" + clsname + "']") as XmlElement;
+ var elem = DocumentElement.SelectSingleNode ("object[@type='" + clsname + "']") as XmlElement;
if (elem != null && elem.HasAttribute ("palette-category")) {
CodeGenerationService.AddAttribute (cls, "System.ComponentModel.Category", elem.GetAttribute ("palette-category"));
}
@@ -137,16 +135,17 @@ public void Update (WidgetParser parser, Stetic.Project stetic)
InsertToolboxItemAttributes (parser);
AttrSyncState = SyncState.On;
return;
- } else if (AttrSyncState == SyncState.Off)
+ }
+ if (AttrSyncState == SyncState.Off)
return;
- StringCollection tb_names = new StringCollection ();
+ var tb_names = new StringCollection ();
foreach (var cls in parser.GetToolboxItems().Values) {
UpdateClass (parser, stetic, cls, null);
tb_names.Add (cls.FullName);
}
- List<XmlElement> toDelete = new List<XmlElement> ();
+ var toDelete = new List<XmlElement> ();
foreach (XmlElement elem in SelectNodes ("objects/object")) {
string name = elem.GetAttribute ("type");
@@ -164,7 +163,7 @@ void UpdateClass (WidgetParser parser, Stetic.Project stetic, ITypeDefinition wi
{
string typeName = widgetClass.FullName;
string basetypeName = GetBaseType (parser, widgetClass, stetic);
- XmlElement objectElem = (XmlElement) SelectSingleNode ("objects/object[@type='" + typeName + "']");
+ var objectElem = (XmlElement) SelectSingleNode ("objects/object[@type='" + typeName + "']");
if (objectElem == null) {
@@ -194,10 +193,10 @@ void UpdateClass (WidgetParser parser, Stetic.Project stetic, ITypeDefinition wi
UpdateObject (parser, basetypeName, objectElem, widgetClass, wrapperClass);
}
- string GetBaseType (WidgetParser parser, ITypeDefinition widgetClass, Stetic.Project stetic)
+ static string GetBaseType (WidgetParser parser, ITypeDefinition widgetClass, Stetic.Project stetic)
{
string[] types = stetic.GetWidgetTypes ();
- Hashtable typesHash = new Hashtable ();
+ var typesHash = new Hashtable ();
foreach (string t in types)
typesHash [t] = t;
@@ -212,8 +211,8 @@ void UpdateObject (WidgetParser parser, string topType, XmlElement objectElem, I
else
objectElem.SetAttribute ("internal", "true");
- ListDictionary properties = new ListDictionary ();
- ListDictionary events = new ListDictionary ();
+ var properties = new ListDictionary ();
+ var events = new ListDictionary ();
parser.CollectMembers (widgetClass, true, topType, properties, events);
if (wrapperClass != null)
@@ -226,7 +225,7 @@ void UpdateObject (WidgetParser parser, string topType, XmlElement objectElem, I
MergeEvent (parser, objectElem, ev);
// Remove old properties
- ArrayList toDelete = new ArrayList ();
+ var toDelete = new ArrayList ();
foreach (XmlElement xprop in objectElem.SelectNodes ("itemgroups/itemgroup/property")) {
if (!properties.Contains (xprop.GetAttribute ("name")))
toDelete.Add (xprop);
@@ -239,7 +238,7 @@ void UpdateObject (WidgetParser parser, string topType, XmlElement objectElem, I
}
foreach (XmlElement el in toDelete) {
- XmlElement pe = (XmlElement) el.ParentNode;
+ var pe = (XmlElement) el.ParentNode;
pe.RemoveChild (el);
if (pe.ChildNodes.Count == 0)
pe.ParentNode.RemoveChild (pe);
@@ -257,7 +256,7 @@ void MergeProperty (WidgetParser parser, XmlElement objectElem, IProperty prop)
string cat = parser.GetCategory (prop);
XmlElement itemGroup = GetItemGroup (prop.DeclaringType, itemGroups, cat, "Properties");
- XmlElement propElem = (XmlElement) itemGroup.SelectSingleNode ("property[@name='" + prop.Name + "']");
+ var propElem = (XmlElement) itemGroup.SelectSingleNode ("property[@name='" + prop.Name + "']");
if (propElem == null) {
propElem = itemGroup.OwnerDocument.CreateElement ("property");
propElem.SetAttribute ("name", prop.Name);
@@ -276,7 +275,7 @@ void MergeEvent (WidgetParser parser, XmlElement objectElem, IEvent evnt)
string cat = parser.GetCategory (evnt);
XmlElement itemGroup = GetItemGroup (evnt.DeclaringType, itemGroups, cat, "Signals");
- XmlElement signalElem = (XmlElement) itemGroup.SelectSingleNode ("signal[@name='" + evnt.Name + "']");
+ var signalElem = (XmlElement) itemGroup.SelectSingleNode ("signal[@name='" + evnt.Name + "']");
if (signalElem == null) {
signalElem = itemGroup.OwnerDocument.CreateElement ("signal");
signalElem.SetAttribute ("name", evnt.Name);
@@ -295,7 +294,7 @@ XmlElement GetItemGroup (IType cls, XmlElement itemGroups, string cat, string gr
if (itemGroup == null) {
itemGroup = itemGroups.OwnerDocument.CreateElement ("itemgroup");
- if (cat != null && cat != "") {
+ if (!string.IsNullOrEmpty (cat)) {
itemGroup.SetAttribute ("name", cat);
itemGroup.SetAttribute ("label", cat);
} else
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ProjectResourceProvider.cs
===================================================================
@@ -36,7 +36,7 @@ namespace MonoDevelop.GtkCore
{
public class ProjectResourceProvider: MarshalByRefObject, Stetic.IResourceProvider
{
- Project project;
+ readonly Project project;
public ProjectResourceProvider (Project project)
{
@@ -45,7 +45,7 @@ public ProjectResourceProvider (Project project)
public Stetic.ResourceInfo[] GetResources ()
{
- ArrayList list = new ArrayList ();
+ var list = new ArrayList ();
foreach (ProjectFile file in project.Files) {
if (file.BuildAction == BuildAction.EmbeddedResource)
list.Add (new Stetic.ResourceInfo (file.ResourceId, file.Name, DesktopService.GetMimeTypeForUri (file.Name)));
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ReferenceManager.cs
===================================================================
@@ -61,7 +61,7 @@ void ResetSupportedVersions (object o, EventArgs a)
if (!IsGtkReference (pref))
continue;
string val = pref.StoredReference;
- int idx = val.IndexOf (",") + 1;
+ int idx = val.IndexOf (",", StringComparison.Ordinal) + 1;
return val.Substring (idx).Trim ();
}
return String.Empty;
@@ -83,10 +83,10 @@ void ResetSupportedVersions (object o, EventArgs a)
string assm_version = CurrentAssemblyVersion;
if (String.IsNullOrEmpty (assm_version))
return String.Empty;
- int idx = assm_version.IndexOf (",");
+ int idx = assm_version.IndexOf (",", StringComparison.Ordinal);
if (idx > 0)
assm_version = assm_version.Substring (0, idx);
- idx = assm_version.IndexOf ("=");
+ idx = assm_version.IndexOf ("=", StringComparison.Ordinal);
if (idx > 0)
assm_version = assm_version.Substring (idx + 1);
string[] toks = assm_version.Split ('.');
@@ -96,14 +96,14 @@ void ResetSupportedVersions (object o, EventArgs a)
}
}
- string GetGtkAssemblyVersion (string pkg_version)
+ string GetGtkAssemblyVersion (string pkgVersion)
{
- if (String.IsNullOrEmpty (pkg_version))
+ if (String.IsNullOrEmpty (pkgVersion))
return String.Empty;
- pkg_version = pkg_version + ".";
+ pkgVersion = pkgVersion + ".";
foreach (SystemAssembly asm in project.AssemblyContext.GetAssemblies ()) {
- if (asm.Name == "gtk-sharp" && asm.Version.StartsWith (pkg_version)) {
+ if (asm.Name == "gtk-sharp" && asm.Version.StartsWith (pkgVersion, StringComparison.Ordinal)) {
int i = asm.FullName.IndexOf (',');
return asm.FullName.Substring (i+1).Trim ();
}
@@ -111,14 +111,14 @@ string GetGtkAssemblyVersion (string pkg_version)
return string.Empty;
}
- string GetGtkPackageVersion (string assembly_version)
+ string GetGtkPackageVersion (string assemblyVersion)
{
- if (String.IsNullOrEmpty (assembly_version))
+ if (String.IsNullOrEmpty (assemblyVersion))
return String.Empty;
- int i = assembly_version.IndexOf ('=');
- assembly_version = assembly_version.Substring (i+1);
- return GetVersionPrefix (assembly_version);
+ int i = assemblyVersion.IndexOf ('=');
+ assemblyVersion = assemblyVersion.Substring (i+1);
+ return GetVersionPrefix (assemblyVersion);
}
public bool Update ()
@@ -126,10 +126,10 @@ public bool Update ()
return Update (CurrentAssemblyVersion);
}
- bool Update (string assm_version)
+ bool Update (string assmVersion)
{
- if (assm_version == null)
- throw new ArgumentException (assm_version);
+ if (assmVersion == null)
+ throw new ArgumentException (assmVersion);
bool changed = false;
updating = true;
@@ -152,20 +152,20 @@ bool Update (string assm_version)
continue;
string sr = r.StoredReference;
- string version = sr.Substring (sr.IndexOf (",") + 1).Trim ();
- if (version != assm_version) {
+ string version = sr.Substring (sr.IndexOf (",", StringComparison.Ordinal) + 1).Trim ();
+ if (version != assmVersion) {
project.References.Remove (r);
- if (name == "gnome-sharp" && assm_version == "Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f") {
+ if (name == "gnome-sharp" && assmVersion == "Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f") {
project.References.Add (new ProjectReference (ReferenceType.Package, name + ", Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"));
} else {
- project.References.Add (new ProjectReference (ReferenceType.Package, name + ", " + assm_version));
+ project.References.Add (new ProjectReference (ReferenceType.Package, name + ", " + assmVersion));
}
changed = true;
}
}
if (!gtk) {
- project.References.Add (new ProjectReference (ReferenceType.Package, "gtk-sharp" + ", " + assm_version));
+ project.References.Add (new ProjectReference (ReferenceType.Package, "gtk-sharp" + ", " + assmVersion));
changed = true;
}
@@ -174,7 +174,7 @@ bool Update (string assm_version)
GtkDesignInfo info = GtkDesignInfo.FromProject (project);
if (!gdk) {
- project.References.Add (new ProjectReference (ReferenceType.Package, "gdk-sharp" + ", " + assm_version));
+ project.References.Add (new ProjectReference (ReferenceType.Package, "gdk-sharp" + ", " + assmVersion));
changed = true;
}
@@ -194,7 +194,7 @@ bool Update (string assm_version)
}
static bool updating;
- static string[] gnome_assemblies = new string [] {
+ static readonly string[] gnome_assemblies = {
"art-sharp", "atk-sharp", "gconf-sharp", "gdk-sharp",
"glade-sharp","glib-sharp", "gnome-sharp",
"gnome-vfs-sharp", "gtk-dotnet", "gtkhtml-sharp",
@@ -213,8 +213,8 @@ static void OnReferenceAdded (object o, ProjectReferenceEventArgs args)
return;
string sr = args.ProjectReference.StoredReference;
- string version = sr.Substring (sr.IndexOf (",") + 1).Trim ();
- ReferenceManager rm = new ReferenceManager (args.Project as DotNetProject);
+ string version = sr.Substring (sr.IndexOf (",", StringComparison.Ordinal) + 1).Trim ();
+ var rm = new ReferenceManager (args.Project as DotNetProject);
rm.Update (version);
}
@@ -223,7 +223,7 @@ static void OnReferenceRemoved (object o, ProjectReferenceEventArgs args)
if (updating || !IsGtkReference (args.ProjectReference))
return;
- DotNetProject dnp = args.Project as DotNetProject;
+ var dnp = args.Project as DotNetProject;
if (MessageService.Confirm (GettextCatalog.GetString ("The Gtk# User Interface designer will be disabled by removing the gtk-sharp reference."), new AlertButton (GettextCatalog.GetString ("Disable Designer"))))
GtkDesignInfo.DisableProject (dnp);
@@ -234,7 +234,7 @@ static void OnReferenceRemoved (object o, ProjectReferenceEventArgs args)
static string GetReferenceName (ProjectReference pref)
{
string stored = pref.StoredReference;
- int idx =stored.IndexOf (",");
+ int idx = stored.IndexOf (",", StringComparison.Ordinal);
if (idx == -1)
return stored.Trim ();
@@ -287,7 +287,7 @@ public static bool HasGtkReference (DotNetProject project)
}
}
- string GetVersionPrefix (string version)
+ static string GetVersionPrefix (string version)
{
int i = version.IndexOf ('.');
i = version.IndexOf ('.', i + 1);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetFileDescriptionTemplate.cs
===================================================================
@@ -53,7 +53,7 @@ public class WidgetFileDescriptionTemplate: FileDescriptionTemplate
public override void Load (XmlElement filenode, FilePath baseDirectory)
{
foreach (XmlNode node in filenode.ChildNodes) {
- XmlElement elem = node as XmlElement;
+ var elem = node as XmlElement;
if (elem == null) continue;
if (elem.Name == "SteticTemplate") {
@@ -80,12 +80,12 @@ public override bool SupportsProject (Project project, string projectPath)
public override bool AddToProject (SolutionItem policyParent, Project project, string language, string directory, string name)
{
if (!GtkDesignInfo.SupportsDesigner (project)) {
- ReferenceManager mgr = new ReferenceManager (project as DotNetProject);
+ var mgr = new ReferenceManager (project as DotNetProject);
mgr.GtkPackageVersion = mgr.DefaultGtkVersion;
mgr.Dispose ();
}
- GtkDesignInfo info = GtkDesignInfo.FromProject ((DotNetProject) project);
+ GtkDesignInfo info = GtkDesignInfo.FromProject (project);
GuiBuilderProject gproject = info.GuiBuilderProject;
@@ -94,7 +94,7 @@ public override bool AddToProject (SolutionItem policyParent, Project project, s
TypeSystemService.ParseFile (project, fileName);
- DotNetProject netProject = project as DotNetProject;
+ var netProject = project as DotNetProject;
string ns = netProject != null ? netProject.GetDefaultNamespace (fileName) : "";
string cname = Path.GetFileNameWithoutExtension (fileName);
string fullName = ns.Length > 0 ? ns + "." + cname : cname;
@@ -109,7 +109,7 @@ public override bool AddToProject (SolutionItem policyParent, Project project, s
string content = widgetElem.OuterXml;
content = StringParserService.Parse (content, tags);
- XmlDocument doc = new XmlDocument ();
+ var doc = new XmlDocument ();
doc.LoadXml (content);
gproject.AddNewComponent (doc.DocumentElement);
@@ -123,7 +123,7 @@ public override bool AddToProject (SolutionItem policyParent, Project project, s
string content = widgetElem.OuterXml;
content = StringParserService.Parse (content, tags);
- XmlDocument doc = new XmlDocument ();
+ var doc = new XmlDocument ();
doc.LoadXml (content);
gproject.SteticProject.AddNewActionGroup (doc.DocumentElement);
Modified: main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetParser.cs
===================================================================
@@ -28,8 +28,6 @@
//
using System;
-using System.Xml;
-using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -42,7 +40,7 @@ namespace MonoDevelop.GtkCore
public class WidgetParser
{
- ICompilation ctx;
+ readonly ICompilation ctx;
public ICompilation Ctx {
get {
@@ -153,7 +151,7 @@ public bool IsBrowsable (IMember member)
if (!member.IsPublic)
return false;
- IProperty prop = member as IProperty;
+ var prop = member as IProperty;
if (prop != null) {
if (!prop.CanGet || !prop.CanSet)
return false;
@@ -206,10 +204,9 @@ public bool IsToolboxWidget (ITypeDefinition cls)
var val = pargs[0] as ConstantResolveResult;
if (val.ConstantValue == null)
return false;
- else if (val.ConstantValue is bool)
+ if (val.ConstantValue is bool)
return (bool) val.ConstantValue;
- else
- return val.ConstantValue != null;
+ return val.ConstantValue != null;
}
}
@@ -221,7 +218,7 @@ public bool IsToolboxWidget (ITypeDefinition cls)
return false;
}
- static string[] supported_types = new string[] {
+ static readonly string[] supported_types = {
"System.Boolean",
"System.Char",
"System.SByte",
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches