[MonoDevelop] [patch] stop/clear button in application/build output pads

Ben Motmans Ben Motmans <ben.motmans@gmail.com>
Fri, 11 Feb 2005 17:02:10 +0100


------=_Part_1013_11546114.1108137730533
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Fri, 11 Feb 2005 16:40:43 +0100, Lluis Sanchez <lluis@ximian.com> wrote:
> Hi!
> Here are some comments:
> 
> OutputProgressMonitor can do this assignment in its constructor.
> ... 
> It is wrong to cast to OutputProgressMonitor since IProgressMonitor
> doesn't need to necessarily be an OutputProgressMonitor in the future.

fixed

-- Ben

------=_Part_1013_11546114.1108137730533
Content-Type: text/x-patch; name="stopbutton_2.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="stopbutton_2.diff"

Index: Core/src/MonoDevelop.Base/Services/Tasks/OutputProgressMonitor.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/Services/Tasks/OutputProgressMonitor.cs=09(re=
vision 2246)
+++ Core/src/MonoDevelop.Base/Services/Tasks/OutputProgressMonitor.cs=09(wo=
rking copy)
@@ -28,6 +28,7 @@
 =09=09
 =09=09public OutputProgressMonitor (DefaultMonitorPad pad, string title, s=
tring icon)
 =09=09{
+=09=09=09pad.AsyncOperation =3D this.AsyncOperation;
 =09=09=09outputPad =3D pad;
 =09=09=09outputPad.BeginProgress (title);
 =09=09}
Index: Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs=09(revision 224=
6)
+++ Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs=09(working copy=
)
@@ -86,13 +86,14 @@
 =09=09=09=09}
 =09=09=09}
 =09=09=09
-=09=09=09DefaultMonitorPad defMonitor =3D new DefaultMonitorPad (title, ic=
on);
-=09=09=09defMonitor.Id =3D (monitorId++).ToString ();
-=09=09=09Runtime.Gui.Workbench.ShowPad (defMonitor);
-=09=09=09if (bringToFront) defMonitor.BringToFront ();
-=09=09=09return new OutputProgressMonitor (defMonitor, title, icon);
+=09=09=09DefaultMonitorPad monitorPad =3D new DefaultMonitorPad (title, ic=
on);
+=09=09=09monitorPad.Id =3D (monitorId++).ToString ();
+=09=09=09Runtime.Gui.Workbench.ShowPad (monitorPad);
+=09=09=09if (bringToFront) monitorPad.BringToFront ();
+
+=09=09=09return new OutputProgressMonitor (monitorPad, title, icon);
 =09=09}
-=09=09
+
 =09=09internal void ReleasePad (DefaultMonitorPad pad)
 =09=09{
 =09=09=09lock (outputMonitors) {
Index: Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs=09(=
revision 2246)
+++ Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs=09(=
working copy)
@@ -89,19 +89,29 @@
 =09=09=09} else {
 =09=09=09=09// This should create an vte pad instead, but an output panel =
will be enough until we can do it
 =09=09=09=09IProgressMonitor monitor =3D Runtime.TaskService.GetOutputProg=
ressMonitor ("Application Output", MonoDevelop.Gui.Stock.RunProgramIcon, tr=
ue, true);
+
 =09=09=09=09ProcessMonitor pm =3D new ProcessMonitor ();
 =09=09=09=09pm.Exited =3D exited;
 =09=09=09=09pm.Monitor =3D monitor;
-=09=09=09=09return StartProcess (command, arguments, workingDirectory, mon=
itor.Log, monitor.Log, new EventHandler (pm.OnExited));
+=09=09=09=09pm.CancelHandler =3D new MonitorHandler(pm.OnCancelRequest);
+
+=09=09=09=09monitor.CancelRequested +=3D pm.CancelHandler;
+
+=09=09=09=09ProcessWrapper pw =3D StartProcess (command, arguments, workin=
gDirectory, monitor.Log, monitor.Log, new EventHandler (pm.OnExited));
+=09=09=09=09pm.ProcessWrapper =3D pw;
+
+=09=09=09=09return pw;
 =09=09=09}
 =09=09}
-=09=09
 =09}
 =09
 =09class ProcessMonitor
 =09{
 =09=09public IProgressMonitor Monitor;
 =09=09public EventHandler Exited;
+
+=09=09public ProcessWrapper ProcessWrapper;
+=09=09public MonitorHandler CancelHandler;
 =09=09
 =09=09public void OnExited (object sender, EventArgs args)
 =09=09{
@@ -114,6 +124,17 @@
 =09=09=09=09Monitor.Dispose ();
 =09=09=09}
 =09=09}
+
+=09=09public void OnCancelRequest (IProgressMonitor monitor) {
+=09=09=09if (ProcessWrapper !=3D null) {
+=09=09=09=09if (!ProcessWrapper.HasExited) {
+=09=09=09=09=09ProcessWrapper.Kill();
+=09=09=09=09=09monitor.Log.WriteLine("Application stopped by user.");
+=09=09=09=09}
+=09=09=09}
+=09=09=09//remove the cancel handler, it will be attached again when Start=
ConsoleProcess is called
+=09=09=09monitor.CancelRequested -=3D CancelHandler;
+=09=09}
 =09}
 =09
 =09class OutWriter
Index: Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs=09(revision 224=
6)
+++ Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs=09(working copy=
)
@@ -27,6 +27,9 @@
 =09=09Gtk.TextBuffer buffer;
 =09=09Gtk.TextView textEditorControl;
 =09=09Gtk.ScrolledWindow scroller;
+=09=09Gtk.HBox hbox;
+
+=09=09private static Gtk.Tooltips tips =3D new Gtk.Tooltips ();
 =09=09
 =09=09TextTag tag;
 =09=09TextTag bold;
@@ -37,7 +40,9 @@
 =09=09string title;
 =09=09string icon;
 =09=09string id;
-=09=09
+
+=09=09private IAsyncOperation asyncOperation;
+
 =09=09public DefaultMonitorPad (string title, string icon)
 =09=09{
 =09=09=09buffer =3D new Gtk.TextBuffer (new Gtk.TextTagTable ());
@@ -46,6 +51,25 @@
 =09=09=09scroller =3D new Gtk.ScrolledWindow ();
 =09=09=09scroller.ShadowType =3D ShadowType.In;
 =09=09=09scroller.Add (textEditorControl);
+
+=09=09=09Toolbar toolbar =3D new Toolbar ();
+=09=09=09toolbar.IconSize =3D IconSize.SmallToolbar;
+=09=09=09toolbar.Orientation =3D Orientation.Vertical;
+=09=09=09toolbar.ToolbarStyle =3D ToolbarStyle.Icons;
+
+=09=09=09ToolButton buttonStop =3D new ToolButton ("gtk-media-stop");
+=09=09=09buttonStop.Clicked +=3D new EventHandler (OnButtonStopClick);
+=09=09=09buttonStop.SetTooltip (tips, "Stop", "Stop");
+=09=09=09toolbar.Insert (buttonStop, -1);
+
+=09=09=09ToolButton buttonClear =3D new ToolButton ("gtk-clear");
+=09=09=09buttonClear.Clicked +=3D new EventHandler (OnButtonClearClick);
+=09=09=09buttonClear.SetTooltip (tips, "Clear console", "Clear console");
+=09=09=09toolbar.Insert (buttonClear, -1);
+
+=09=09=09hbox =3D new HBox (false, 5);
+=09=09=09hbox.PackStart (scroller, true, true, 0);
+=09=09=09hbox.PackEnd (toolbar, false, false, 0);
 =09=09=09
 =09=09=09bold =3D new TextTag ("bold");
 =09=09=09bold.Weight =3D Pango.Weight.Bold;
@@ -55,12 +79,29 @@
 =09=09=09tag.Indent =3D 10;
 =09=09=09buffer.TagTable.Add (tag);
 =09=09=09tags.Add (tag);
-=09=09=09
+
 =09=09=09this.title =3D title;
 =09=09=09this.icon =3D icon;
 =09=09=09this.markupTitle =3D title;
 =09=09}
-=09=09
+
+=09=09public IAsyncOperation AsyncOperation {
+=09=09=09get {
+=09=09=09=09return asyncOperation;
+=09=09=09}
+=09=09=09set {
+=09=09=09=09asyncOperation =3D value;
+=09=09=09}
+=09=09}
+
+=09=09void OnButtonClearClick (object sender, EventArgs e) {
+=09=09=09buffer.Clear();
+=09=09}
+
+=09=09void OnButtonStopClick (object sender, EventArgs e) {
+=09=09=09asyncOperation.Cancel ();
+=09=09}
+
 =09=09public void BeginProgress (string title)
 =09=09{
 =09=09=09this.title =3D title;
@@ -91,8 +132,8 @@
 =09=09=09=09textEditorControl.ScrollMarkOnscreen (buffer.InsertMark);
 =09=09}
 =09=09
-=09=09public Gtk.Widget Control {
-=09=09=09get { return scroller; }
+=09=09public virtual Gtk.Widget Control {
+=09=09=09get { return hbox; }
 =09=09}
 =09=09
 =09=09public string Title {
Index: Core/src/MonoDevelop.Base/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/ChangeLog=09(revision 2246)
+++ Core/src/MonoDevelop.Base/ChangeLog=09(working copy)
@@ -1,3 +1,13 @@
+2005-02-11  Ben Motmans <ben.motmans@gmail.com>
+
+=09* Internal/ProgressMonitoring/BaseProgressMonitor.cs:
+=09moved cancelRequestedEvent inside MbrWrapper
+=09* Services/Tasks/TaskService.cs
+=09* Services/Tasks/OutputProgressMonitor
+=09* Services/ProcessService/ProcessService.cs
+=09* Gui/Pads/DefaultMonitorPad.cs:
+=09Added kill and clear button
+
 2005-02-10  Todd Berman  <tberman@off.net>
=20
 =09* Internal/Project/Combine/Combine.cs: Don't generate makefiles on
Index: Core/src/MonoDevelop.Base/Internal/ProgressMonitoring/BaseProgressMo=
nitor.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/Internal/ProgressMonitoring/BaseProgressMonit=
or.cs=09(revision 2246)
+++ Core/src/MonoDevelop.Base/Internal/ProgressMonitoring/BaseProgressMonit=
or.cs=09(working copy)
@@ -38,6 +38,15 @@
 =09{
 =09=09class MbrWrapper {
 =09=09=09public ManualResetEvent waitEvent;
+
+=09=09=09//workaround for "** ERROR **: file icall.c: line 2419 (ves_icall=
_InternalExecute): assertion failed" bug when
+=09=09=09//handling the CancelRequested event
+=09=09=09public event MonitorHandler cancelRequestedEvent;
+
+=09=09=09public void RaiseEvent (IProgressMonitor monitor) {
+=09=09=09=09if (cancelRequestedEvent !=3D null)
+=09=09=09=09=09cancelRequestedEvent (monitor);
+=09=09=09}
 =09=09}
 =09=09
 =09=09MbrWrapper c =3D new MbrWrapper ();
@@ -46,7 +55,6 @@
 =09=09bool canceled;
 =09=09
 =09=09event OperationHandler completedEvent;
-=09=09event MonitorHandler cancelRequestedEvent;
 =09=09
 =09=09StringCollection errorsMessages =3D new StringCollection ();
 =09=09StringCollection successMessages =3D new StringCollection ();
@@ -186,14 +194,14 @@
 =09=09=09add {
 =09=09=09=09bool alreadyCanceled =3D false;
 =09=09=09=09lock (progressTracker) {
-=09=09=09=09=09cancelRequestedEvent +=3D value;
+=09=09=09=09=09c.cancelRequestedEvent +=3D value;
 =09=09=09=09=09alreadyCanceled =3D canceled;
 =09=09=09=09}
 =09=09=09=09if (alreadyCanceled) value (this);
 =09=09=09}
 =09=09=09remove {
 =09=09=09=09lock (progressTracker) {
-=09=09=09=09=09cancelRequestedEvent -=3D value;
+=09=09=09=09=09c.cancelRequestedEvent -=3D value;
 =09=09=09=09}
 =09=09=09}
 =09=09}=09=09
@@ -231,17 +239,16 @@
 =09=09=09if (completedEvent !=3D null)
 =09=09=09=09completedEvent (AsyncOperation);
 =09=09}
-=09=09=09=09
+
 =09=09protected virtual void OnCancelRequested ()
 =09=09{
 =09=09=09lock (progressTracker) {
 =09=09=09=09canceled =3D true;
 =09=09=09}
=20
-=09=09=09if (cancelRequestedEvent !=3D null)
-=09=09=09=09cancelRequestedEvent (this);
+=09=09=09c.RaiseEvent(this);
 =09=09}
-=09=09
+
 =09=09[AsyncDispatch]
 =09=09void WriteLogInternal (string text)
 =09=09{

------=_Part_1013_11546114.1108137730533--