[Monodevelop-patches-list] r2199 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Gui/Components Services/Toolbar
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Mon Jan 31 12:55:08 EST 2005
Author: jluke
Date: 2005-01-31 12:55:08 -0500 (Mon, 31 Jan 2005)
New Revision: 2199
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Components/SdToolbarCommand.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Toolbar/ToolbarService.cs
Log:
quick port to newer toolbar api
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-01-31 17:51:39 UTC (rev 2198)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-01-31 17:55:08 UTC (rev 2199)
@@ -1,3 +1,9 @@
+2005-01-31 John Luke <john.luke at gmail.com>
+
+ * Gui/Components/SdToolbarCommand.cs:
+ * Services/Toolbar/ToolbarService.cs:
+ use newer gtk toolbar API, and simplify it a little
+
2005-01-30 John Luke <john.luke at gmail.com>
* Internal/Project/Project/DotNetProject.cs: pass fileName
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Components/SdToolbarCommand.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Components/SdToolbarCommand.cs 2005-01-31 17:51:39 UTC (rev 2198)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Components/SdToolbarCommand.cs 2005-01-31 17:55:08 UTC (rev 2199)
@@ -6,20 +6,17 @@
// </file>
using System;
-using System.Drawing;
-using System.Diagnostics;
-using System.Drawing.Text;
-using System.Drawing.Imaging;
+using Gtk;
+
using MonoDevelop.Core.AddIns.Conditions;
using MonoDevelop.Core.AddIns.Codons;
-using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
-//using Reflector.UserInterface;
-
namespace MonoDevelop.Gui.Components
{
- public class SdToolbarCommand : Gtk.Button, IStatusUpdate
+ public class SdToolbarCommand : Gtk.ToolButton, IStatusUpdate
{
+ static Tooltips tips = new Tooltips ();
object caller;
ConditionCollection conditionCollection;
string description = String.Empty;
@@ -27,82 +24,46 @@
ICommand menuCommand = null;
public ICommand Command {
- get {
- return menuCommand;
- }
+ get { return menuCommand; }
set {
menuCommand = value;
UpdateStatus();
}
}
- public string Description {
- get {
- return description;
- }
- set {
- description = value;
- }
- }
-
public string Text {
- get {
- return localizedText;
- }
+ get { return localizedText; }
}
- public SdToolbarCommand (string text) : base ()
+ public SdToolbarCommand (ToolbarItemCodon codon, object caller) : base (null, "")
{
- localizedText = text;
+ this.caller = caller;
+ this.IconWidget = Runtime.Gui.Resources.GetImage (codon.Icon, Gtk.IconSize.LargeToolbar);
+ this.conditionCollection = codon.Conditions;
+ this.localizedText = codon.ToolTip;
+ this.Label = this.Text;
+ if (codon.Class != null)
+ this.Command = (ICommand) codon.AddIn.CreateObject (codon.Class);
- Clicked += new EventHandler (ToolbarClicked);
+ this.SetTooltip (tips, Text, Text);
+ this.Clicked += new EventHandler (ToolbarClicked);
+ this.ShowAll ();
}
- public SdToolbarCommand(ConditionCollection conditionCollection, object caller, string label) : this(label)
- {
- this.caller = caller;
- this.conditionCollection = conditionCollection;
- UpdateStatus();
+ void ToolbarClicked (object o, EventArgs e) {
+ if (menuCommand != null)
+ menuCommand.Run ();
}
-
- public SdToolbarCommand(ConditionCollection conditionCollection, object caller, string label, ICommand menuCommand) : this(label)
- {
- this.caller = caller;
- this.conditionCollection = conditionCollection;
- this.menuCommand = menuCommand;
- UpdateStatus();
- }
-
- public SdToolbarCommand(ConditionCollection conditionCollection, object caller, string label, EventHandler handler) : this(label)
- {
- this.caller = caller;
- this.conditionCollection = conditionCollection;
- UpdateStatus();
- }
-
- public SdToolbarCommand(object caller, string label, EventHandler handler) : this(label)
- {
- this.caller = caller;
- UpdateStatus();
- }
-
- // To be called from ToolbarService
- public void ToolbarClicked(object o, EventArgs e) {
- if (menuCommand != null) {
- menuCommand.Run();
- }
- }
- public virtual void UpdateStatus()
+ public virtual void UpdateStatus ()
{
if (conditionCollection != null) {
- ConditionFailedAction failedAction = conditionCollection.GetCurrentConditionFailedAction(caller);
+ ConditionFailedAction failedAction = conditionCollection.GetCurrentConditionFailedAction (caller);
this.Sensitive = failedAction != ConditionFailedAction.Disable;
this.Visible = failedAction != ConditionFailedAction.Exclude;
}
- if (menuCommand != null && menuCommand is IMenuCommand) {
- Sensitive = ((IMenuCommand)menuCommand).IsEnabled;
- }
+ if (menuCommand != null && menuCommand is IMenuCommand)
+ this.Sensitive = ((IMenuCommand) menuCommand).IsEnabled;
}
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Toolbar/ToolbarService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Toolbar/ToolbarService.cs 2005-01-31 17:51:39 UTC (rev 2198)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Toolbar/ToolbarService.cs 2005-01-31 17:55:08 UTC (rev 2199)
@@ -16,7 +16,6 @@
using MonoDevelop.Internal.Project;
using MonoDevelop.Core.AddIns.Codons;
using MonoDevelop.Core.AddIns;
-
using MonoDevelop.Core.Services;
using MonoDevelop.Services;
@@ -46,43 +45,22 @@
return toolBars;
}
- public Gtk.Toolbar CreateToolBarFromCodon(object owner, ToolbarItemCodon codon)
+ public Gtk.Toolbar CreateToolBarFromCodon (object owner, ToolbarItemCodon codon)
{
- Gtk.Toolbar bar = new Gtk.Toolbar();
+ Gtk.Toolbar bar = new Gtk.Toolbar ();
bar.ToolbarStyle = Gtk.ToolbarStyle.Icons;
- foreach (ToolbarItemCodon childCodon in codon.SubItems) {
- SdToolbarCommand item = null;
-
+ foreach (ToolbarItemCodon childCodon in codon.SubItems)
+ {
if (childCodon.ToolTip != null) {
- if (childCodon.ToolTip == "-") {
- //bar.Insert (new SeparatorToolItem (), -1);
- bar.AppendSpace ();
- continue;
- } else {
- item = new SdToolbarCommand(childCodon.Conditions, owner, GettextCatalog.GetString (childCodon.ToolTip));
- Gtk.Image img = Runtime.Gui.Resources.GetImage(childCodon.Icon, Gtk.IconSize.LargeToolbar);
- item.Add (img);
- item.Relief = ReliefStyle.None;
-
- //if (img.StorageType == Gtk.ImageType.Stock) {
- // item.Stock = img.Stock;
- // item.IconSize = (int)Gtk.IconSize.SmallToolbar;
- //} else {
- // item.Pixbuf = img.Pixbuf;
- //}
- item.ShowAll();
- }
- } else {
- Console.WriteLine ("Tooltip was null");
- continue;
+ if (childCodon.ToolTip == "-")
+ bar.Insert (new SeparatorToolItem (), -1);
+ else
+ bar.Insert (new SdToolbarCommand (childCodon, owner), -1);
}
- if (childCodon.Class != null) {
- ((SdToolbarCommand)item).Command = (ICommand)childCodon.AddIn.CreateObject(childCodon.Class);
- }
- bar.AppendWidget (item, item.Text, item.Text);
}
return bar;
}
}
}
+
More information about the Monodevelop-patches-list
mailing list