[Monodevelop-patches-list] r1475 - in trunk/MonoDevelop: build/AddIns src/Main/Base src/Main/Base/Commands src/Main/Base/Gui/Components
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sat Apr 17 18:47:58 EDT 2004
Author: tberman
Date: 2004-04-17 18:47:57 -0400 (Sat, 17 Apr 2004)
New Revision: 1475
Modified:
trunk/MonoDevelop/build/AddIns/SharpDevelopCore.addin.xml
trunk/MonoDevelop/src/Main/Base/ChangeLog
trunk/MonoDevelop/src/Main/Base/Commands/MenuItemBuilders.cs
trunk/MonoDevelop/src/Main/Base/Gui/Components/SdMenu.cs
Log:
finally get around to fixing our previously broken menus. this is so much faster now.
Modified: trunk/MonoDevelop/build/AddIns/SharpDevelopCore.addin.xml
===================================================================
--- trunk/MonoDevelop/build/AddIns/SharpDevelopCore.addin.xml 2004-04-17 07:04:41 UTC (rev 1474)
+++ trunk/MonoDevelop/build/AddIns/SharpDevelopCore.addin.xml 2004-04-17 22:47:57 UTC (rev 1475)
@@ -856,6 +856,7 @@
description = "${res:XML.MainMenu.FileMenu.CloseAll.Description}"
class = "MonoDevelop.Commands.CloseAllWindows" />
</Conditional>
+<MenuItem id = "contentSep" _label = "-" />
<MenuItem id = "ContentBuilder" _label = "bogus_label" class="MonoDevelop.Commands.OpenContentsMenuBuilder"/>
</MenuItem>
Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-04-17 07:04:41 UTC (rev 1474)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-04-17 22:47:57 UTC (rev 1475)
@@ -1,3 +1,13 @@
+2004-04-17 Todd Berman <tberman at sevenl.net>
+
+ * Gui/Components/SdMenu.cs:
+ * Commands/MenuItemBuilders.cs:
+ Fix the menu system so we dont rebuild the menu's from scratch every
+ time you use them. This should speed using the menu's up a lot.
+ The only trick is new SubmenuItemBuilders need to create menu types
+ with the ISubmenuItem interface so we can tell that they are built
+ and not static.
+
2004-04-16 John Luke <jluke at cfl.rr.com>
* Gui/Dialogs/SharpDevelopAboutPanels.cs: align the labels to
Modified: trunk/MonoDevelop/src/Main/Base/Commands/MenuItemBuilders.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Commands/MenuItemBuilders.cs 2004-04-17 07:04:41 UTC (rev 1474)
+++ trunk/MonoDevelop/src/Main/Base/Commands/MenuItemBuilders.cs 2004-04-17 22:47:57 UTC (rev 1475)
@@ -29,8 +29,22 @@
namespace MonoDevelop.Commands
{
+
+ public interface ISubmenuItem
+ {
+ }
+
public class RecentFilesMenuBuilder : ISubmenuBuilder
{
+
+ class RFMItem : SdMenuCommand, ISubmenuItem {
+ public RFMItem (ConditionCollection a, object b, string c) : base (a, b, c) {
+ }
+ public RFMItem (ConditionCollection a, object b, string c, EventHandler d) : base (a, b, c, d) {
+ }
+ }
+
+
public Gtk.MenuItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
@@ -40,11 +54,11 @@
RecentOpen recentOpen = fileService.RecentOpen;
if (recentOpen.RecentFile.Count > 0) {
- SdMenuCommand[] items = new SdMenuCommand[recentOpen.RecentFile.Count];
+ RFMItem[] items = new RFMItem[recentOpen.RecentFile.Count];
for (int i = 0; i < recentOpen.RecentFile.Count; ++i) {
string accelaratorKeyPrefix = i < 10 ? "&" + ((i + 1) % 10).ToString() + " " : "";
- items[i] = new SdMenuCommand(null, null, accelaratorKeyPrefix + recentOpen.RecentFile[i].ToString(), new EventHandler(LoadRecentFile));
+ items[i] = new RFMItem(null, null, accelaratorKeyPrefix + recentOpen.RecentFile[i].ToString(), new EventHandler(LoadRecentFile));
items[i].Tag = recentOpen.RecentFile[i].ToString();
items[i].Description = stringParserService.Parse(resourceService.GetString("Dialog.Componnents.RichMenuItem.LoadFileDescription"),
new string[,] { {"FILE", recentOpen.RecentFile[i].ToString()} });
@@ -52,10 +66,10 @@
return items;
}
- SdMenuCommand defaultMenu = new SdMenuCommand(null, null, GettextCatalog.GetString("recent files"));
+ RFMItem defaultMenu = new RFMItem(null, null, GettextCatalog.GetString("recent files"));
defaultMenu.Sensitive = false;
- return new SdMenuCommand[] { defaultMenu };
+ return new RFMItem[] { defaultMenu };
}
void LoadRecentFile(object sender, EventArgs e)
@@ -68,6 +82,13 @@
public class RecentProjectsMenuBuilder : ISubmenuBuilder
{
+ class RPMItem : SdMenuCommand, ISubmenuItem {
+ public RPMItem (ConditionCollection a, object b, string c) : base (a, b, c) {
+ }
+ public RPMItem (ConditionCollection a, object b, string c, EventHandler d) : base (a, b, c, d) {
+ }
+ }
+
public Gtk.MenuItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
@@ -77,20 +98,20 @@
RecentOpen recentOpen = fileService.RecentOpen;
if (recentOpen.RecentProject.Count > 0) {
- SdMenuCommand[] items = new SdMenuCommand[recentOpen.RecentProject.Count];
+ RPMItem[] items = new RPMItem[recentOpen.RecentProject.Count];
for (int i = 0; i < recentOpen.RecentProject.Count; ++i) {
string accelaratorKeyPrefix = i < 10 ? "&" + ((i + 1) % 10).ToString() + " " : "";
- items[i] = new SdMenuCommand(null, null, accelaratorKeyPrefix + recentOpen.RecentProject[i].ToString(), new EventHandler(LoadRecentProject));
+ items[i] = new RPMItem(null, null, accelaratorKeyPrefix + recentOpen.RecentProject[i].ToString(), new EventHandler(LoadRecentProject));
items[i].Tag = recentOpen.RecentProject[i].ToString();
items[i].Description = String.Format (GettextCatalog.GetString ("load solution {0}"), recentOpen.RecentProject[i].ToString ());
}
return items;
}
- SdMenuCommand defaultMenu = new SdMenuCommand(null, null, GettextCatalog.GetString ("recent solutions"));
+ RPMItem defaultMenu = new RPMItem(null, null, GettextCatalog.GetString ("recent solutions"));
defaultMenu.Sensitive = false;
- return new SdMenuCommand[] { defaultMenu };
+ return new RPMItem[] { defaultMenu };
}
void LoadRecentProject(object sender, EventArgs e)
{
@@ -111,12 +132,17 @@
public class ToolMenuBuilder : ISubmenuBuilder
{
+ class TMItem : SdMenuCommand, ISubmenuItem {
+ public TMItem (ConditionCollection a, object b, string c, EventHandler d) : base (a, b, c, d) {
+ }
+ }
+
public Gtk.MenuItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
// IconMenuStyle iconMenuStyle = (IconMenuStyle)propertyService.GetProperty("IconMenuItem.IconMenuStyle", IconMenuStyle.VSNet);
- SdMenuCommand[] items = new SdMenuCommand[ToolLoader.Tool.Count];
+ TMItem[] items = new TMItem[ToolLoader.Tool.Count];
for (int i = 0; i < ToolLoader.Tool.Count; ++i) {
- SdMenuCommand item = new SdMenuCommand(null, null, ToolLoader.Tool[i].ToString(), new EventHandler(ToolEvt));
+ TMItem item = new TMItem(null, null, ToolLoader.Tool[i].ToString(), new EventHandler(ToolEvt));
item.Description = GettextCatalog.GetString ("Start tool") + " " + String.Join(String.Empty, ToolLoader.Tool[i].ToString().Split('&'));
items[i] = item;
}
@@ -179,7 +205,7 @@
public class OpenContentsMenuBuilder : ISubmenuBuilder
{
- class MyMenuItem : SdMenuCheckBox
+ class MyMenuItem : SdMenuCheckBox, ISubmenuItem
{
public MyMenuItem(string name) : base(null, null, name)
{
@@ -199,12 +225,11 @@
if (contentCount == 0) {
return new Gtk.MenuItem[] {};
}
- Gtk.MenuItem[] items = new Gtk.MenuItem[contentCount + 1];
- items[0] = new SdMenuSeparator(null, null);
+ Gtk.MenuItem[] items = new Gtk.MenuItem[contentCount];
for (int i = 0; i < contentCount; ++i) {
IViewContent content = (IViewContent)WorkbenchSingleton.Workbench.ViewContentCollection[i];
- SdMenuCheckBox item = new MyMenuItem(content.WorkbenchWindow.Title);
+ MyMenuItem item = new MyMenuItem(content.WorkbenchWindow.Title);
item.Tag = content.WorkbenchWindow;
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == content.WorkbenchWindow) {
item.Active = true;
@@ -222,7 +247,7 @@
item.AccelPath = accel_path;
}
}
- items[i + 1] = item;
+ items[i] = item;
}
return items;
}
@@ -235,7 +260,7 @@
MyMenuItem includeInCompileItem;
MyMenuItem includeInDeployItem;
- class MyMenuItem : SdMenuCheckBox
+ class MyMenuItem : SdMenuCheckBox, ISubmenuItem
{
IncludeFilesBuilder builder;
@@ -326,7 +351,7 @@
public class ViewMenuBuilder : ISubmenuBuilder
{
- class MyMenuItem : SdMenuCheckBox
+ class MyMenuItem : SdMenuCheckBox, ISubmenuItem
{
IPadContent padContent;
@@ -352,6 +377,7 @@
}
Active = IsPadVisible;
}
+
public override void UpdateStatus()
{
base.UpdateStatus();
@@ -370,13 +396,13 @@
}
}
- return (Gtk.MenuItem[])items.ToArray(typeof(Gtk.MenuItem));
+ return (MyMenuItem[])items.ToArray(typeof(MyMenuItem));
}
}
public class LayoutsMenuBuilder : ISubmenuBuilder
{
- class MyMenuItem : SdMenuCheckBox
+ class MyMenuItem : SdMenuCheckBox, ISubmenuItem
{
string layoutName;
@@ -397,6 +423,7 @@
{
WorkbenchSingleton.Workbench.WorkbenchLayout.CurrentLayout = layoutName;
}
+
public override void UpdateStatus()
{
base.UpdateStatus();
@@ -416,7 +443,7 @@
}
}
- return (Gtk.MenuItem[]) items.ToArray (typeof (Gtk.MenuItem));
+ return (MyMenuItem[]) items.ToArray (typeof (MyMenuItem));
}
}
}
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Components/SdMenu.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Components/SdMenu.cs 2004-04-17 07:04:41 UTC (rev 1474)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Components/SdMenu.cs 2004-04-17 22:47:57 UTC (rev 1475)
@@ -16,6 +16,8 @@
using MonoDevelop.Core.AddIns.Conditions;
using MonoDevelop.Core.AddIns.Codons;
+using MonoDevelop.Commands;
+
namespace MonoDevelop.Gui.Components
{
public interface IStatusUpdate
@@ -85,7 +87,10 @@
if (Visible) {
foreach (Gtk.Widget widg in ((Gtk.Menu)Submenu).Children) {
- ((Gtk.Menu)Submenu).Remove (widg);
+ if (widg is ISubmenuItem) {
+ ((Gtk.Menu)Submenu).Remove (widg);
+ widg.Destroy ();
+ }
}
foreach (object item in SubItems) {
if (item is Gtk.MenuItem) {
@@ -94,12 +99,13 @@
}
Append((Gtk.MenuItem)item);
} else {
+ int location = SubItems.IndexOf (item);
ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
Gtk.MenuItem[] items = submenuBuilder.BuildSubmenu(conditionCollection, caller);
foreach (Gtk.MenuItem menuItem in items) {
- Append (menuItem);
+ subMenu.Insert (menuItem, location);
+ location++;
}
-
}
}
ShowAll ();
More information about the Monodevelop-patches-list
mailing list