diff options
author | Mike Kestner <mkestner@gmail.com> | 2009-09-04 03:34:51 +0400 |
---|---|---|
committer | Mike Kestner <mkestner@gmail.com> | 2009-09-04 03:34:51 +0400 |
commit | 98ca905d21832473c0c8e0a11a4ab9ab48945950 (patch) | |
tree | b2a0932be9245337987cacd0e0cf981e833b6a8a /Mono.Profiler | |
parent | 8504766756a339199c570063a330f411bd3a4b57 (diff) |
2009-09-03 Mike Kestner <mkestner@novell.com>
* StartPage.cs: add Quick Sessions section to repeat configs from
the history.
2009-09-03 Mike Kestner <mkestner@novell.com>
* MainWindow.cs : hook into Repeat events from the StartPage.
svn path=/trunk/mono-tools/; revision=141290
Diffstat (limited to 'Mono.Profiler')
-rw-r--r-- | Mono.Profiler/Mono.Profiler.Widgets/ChangeLog | 5 | ||||
-rw-r--r-- | Mono.Profiler/Mono.Profiler.Widgets/StartPage.cs | 129 | ||||
-rw-r--r-- | Mono.Profiler/mprof-gui/ChangeLog | 4 | ||||
-rw-r--r-- | Mono.Profiler/mprof-gui/MainWindow.cs | 35 |
4 files changed, 119 insertions, 54 deletions
diff --git a/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog b/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog index 3632b657..fa4a5e0d 100644 --- a/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog +++ b/Mono.Profiler/Mono.Profiler.Widgets/ChangeLog @@ -1,5 +1,10 @@ 2009-09-03 Mike Kestner <mkestner@novell.com> + * StartPage.cs: add Quick Sessions section to repeat configs from + the history. + +2009-09-03 Mike Kestner <mkestner@novell.com> + * History.cs: add recent config support. * ProfileConfiguration.cs: new encapsulation for profile params. * ProfilerProcess.cs: construct from ProfileConfiguation. diff --git a/Mono.Profiler/Mono.Profiler.Widgets/StartPage.cs b/Mono.Profiler/Mono.Profiler.Widgets/StartPage.cs index f4becdd7..a1fbbb3c 100644 --- a/Mono.Profiler/Mono.Profiler.Widgets/StartPage.cs +++ b/Mono.Profiler/Mono.Profiler.Widgets/StartPage.cs @@ -36,6 +36,7 @@ namespace Mono.Profiler.Widgets { public class StartEventArgs : EventArgs { + ProfileConfiguration config; StartEventType type; string detail; @@ -45,6 +46,16 @@ namespace Mono.Profiler.Widgets { this.detail = detail; } + public StartEventArgs (ProfileConfiguration config) + { + this.type = StartEventType.Repeat; + this.config = config; + } + + public ProfileConfiguration Config { + get { return config; } + } + public string Detail { get { return detail; } } @@ -56,8 +67,8 @@ namespace Mono.Profiler.Widgets { public class StartPage : Gtk.DrawingArea { - const int padding = 10; - const int text_padding = 8; + const int padding = 8; + const int text_padding = 3; bool pressed; BannerItem banner; @@ -105,10 +116,8 @@ namespace Mono.Profiler.Widgets { Gdk.Point pt = new Gdk.Point ((int)ev.X, (int)ev.Y); - if (selected_item.Bounds.Contains (pt)) { - OnActivated (); - // button release animation - } + if (selected_item.Bounds.Contains (pt)) + selected_item.OnActivated (); return base.OnButtonReleaseEvent (ev); } @@ -138,7 +147,8 @@ namespace Mono.Profiler.Widgets { case Gdk.Key.KP_Enter: case Gdk.Key.ISO_Enter: case Gdk.Key.Return: - OnActivated (); + if (selected_item != null) + selected_item.OnActivated (); break; default: return false; @@ -196,6 +206,10 @@ namespace Mono.Profiler.Widgets { } public abstract void Draw (Gdk.Rectangle clip); + + public virtual void OnActivated () + { + } } class BannerItem : Item { @@ -234,13 +248,13 @@ namespace Mono.Profiler.Widgets { string markup; Gdk.Point text_offset; - public LabelItem (StartPage owner, string label, int y) : base (owner) + public LabelItem (StartPage owner, string label, int x, int y) : base (owner) { markup = "<span foreground=\"#000099\"><b><big>" + label + "</big></b></span>"; owner.layout.SetMarkup (markup); Pango.Rectangle ink, log; owner.layout.GetPixelExtents (out ink, out log); - Bounds = new Gdk.Rectangle (30, y, ink.Width, ink.Height); + Bounds = new Gdk.Rectangle (x + 30, y, ink.Width, ink.Height); text_offset = new Gdk.Point (ink.X, ink.Y); } @@ -259,34 +273,32 @@ namespace Mono.Profiler.Widgets { Gdk.Point text_offset; Gdk.Point description_offset; - public LinkItem (StartPage owner, string caption, StartEventType type, string detail, int y) : base (owner) + protected LinkItem (StartPage owner, string caption, string description, int x, int y) : base (owner) { markup = "<span underline=\"single\" foreground=\"#0000FF\">" + caption + "</span>"; - Type = type; - Detail = detail; + this.description = description; owner.layout.SetMarkup (markup); Pango.Rectangle ink, log; owner.layout.GetPixelExtents (out ink, out log); text_offset = new Gdk.Point (padding - ink.X, padding - ink.Y); - Bounds = new Gdk.Rectangle (60, y, ink.Width + 2 * padding, ink.Height + 2 * padding); + if (String.IsNullOrEmpty (description)) + Bounds = new Gdk.Rectangle (x + 40, y, ink.Width + 2 * padding, ink.Height + 2 * padding); + else { + int height = ink.Height + padding; + int width = ink.Width; + owner.layout.SetMarkup ("<i>" + description + "</i>"); + owner.layout.GetPixelExtents (out ink, out log); + description_offset = new Gdk.Point (padding - ink.X, height + text_padding - ink.Y); + Bounds = new Gdk.Rectangle (x + 40, y, width > ink.Width ? width + 2 * padding : ink.Width + 2 * padding, height + ink.Height + padding + text_padding); + } } - public LinkItem (StartPage owner, string caption, string description, StartEventType type, string detail, int y) : base (owner) + public LinkItem (StartPage owner, string caption, StartEventType type, string detail, int x, int y) : this (owner, caption, null, type, detail, x, y) {} + + public LinkItem (StartPage owner, string caption, string description, StartEventType type, string detail, int x, int y) : this (owner, caption, description, x, y) { - markup = "<span underline=\"single\" foreground=\"#0000FF\">" + caption + "</span>"; - this.description = description; Type = type; Detail = detail; - owner.layout.SetMarkup (markup); - Pango.Rectangle ink, log; - owner.layout.GetPixelExtents (out ink, out log); - text_offset = new Gdk.Point (padding - ink.X, padding - ink.Y); - int height = ink.Height + padding; - int width = ink.Width; - owner.layout.SetMarkup ("<i>" + description + "</i>"); - owner.layout.GetPixelExtents (out ink, out log); - description_offset = new Gdk.Point (padding - ink.X, height - ink.Y); - Bounds = new Gdk.Rectangle (60, y, width > ink.Width ? width + 2 * padding : ink.Width + 2 * padding, height + ink.Height + padding); } public override void Draw (Gdk.Rectangle clip) @@ -301,18 +313,26 @@ namespace Mono.Profiler.Widgets { owner.GdkWindow.DrawLayout (owner.Style.TextGC (Gtk.StateType.Normal), Bounds.X + description_offset.X, Bounds.Y + description_offset.Y, owner.layout); } } + + public override void OnActivated () + { + owner.OnActivated (new StartEventArgs (Type, Detail)); + } } - void OnActivated () - { - if (Activated != null && selected_item != null) - Activated (this, new StartEventArgs (selected_item.Type, selected_item.Detail)); - } + class QuickStartItem : LinkItem { - void Refresh () - { - Layout (); - QueueDraw (); + ProfileConfiguration config; + + public QuickStartItem (StartPage owner, ProfileConfiguration config, string caption, string description, int x, int y) : base (owner, caption, description, x, y) + { + this.config = config; + } + + public override void OnActivated () + { + owner.OnActivated (new StartEventArgs (config)); + } } void Layout () @@ -322,23 +342,46 @@ namespace Mono.Profiler.Widgets { items.Clear (); items.Add (banner); - Item item = new LabelItem (this, "Common Actions:", banner.Bounds.Bottom + 3 * text_padding); + Item item = new LabelItem (this, "Common Actions:", 0, banner.Bounds.Bottom + 3 * padding); items.Add (item); - item = new LinkItem (this, "Create New Profile", StartEventType.Create, null, item.Bounds.Bottom + text_padding); + item = new LinkItem (this, "Create New Profile", StartEventType.Create, null, 0, item.Bounds.Bottom + text_padding); items.Add (item); - item = new LinkItem (this, "Open Profile Log File", StartEventType.Open, null, item.Bounds.Bottom); + item = new LinkItem (this, "Open Profile Log File", StartEventType.Open, null, 0, item.Bounds.Bottom); items.Add (item); + int y = item.Bounds.Bottom + 3 * padding; if (history.LogFiles.Count > 0) { - item = new LabelItem (this, "Recent Logs:", item.Bounds.Bottom + 3 * text_padding); + item = new LabelItem (this, "Recent Logs:", 0, y); + y = item.Bounds.Bottom + text_padding; items.Add (item); foreach (LogInfo info in history.LogFiles) { - item = new LinkItem (this, info.Caption, info.Detail, StartEventType.Open, info.Filename, item.Bounds.Bottom); + item = new LinkItem (this, info.Caption, info.Detail, StartEventType.Open, info.Filename, 0, y); + items.Add (item); + y = item.Bounds.Bottom; + } + } + + int x = Allocation.Width / 2; + if (history.Configs.Count > 0) { + item = new LabelItem (this, "Quick Sessions:", x, banner.Bounds.Bottom + 3 * padding); + items.Add (item); + y = item.Bounds.Bottom + text_padding; + foreach (ProfileConfiguration config in history.Configs) { + string text = config.ToString (); + int idx = text.IndexOf (":"); + item = new QuickStartItem (this, config, text.Substring (0, idx), text.Substring (idx + 1), x, y); items.Add (item); + y = item.Bounds.Bottom; } } } + void OnActivated (StartEventArgs args) + { + if (Activated != null) + Activated (this, args); + } + void Paint (Gdk.EventExpose ev) { Gtk.Style.PaintBox (Style, GdkWindow, Gtk.StateType.Normal, Gtk.ShadowType.In, ev.Area, this, null, 0, 0, Allocation.Width, Allocation.Height); @@ -347,6 +390,12 @@ namespace Mono.Profiler.Widgets { item.Draw (ev.Area); } + void Refresh () + { + Layout (); + QueueDraw (); + } + void SelectItem (LinkItem item) { if (selected_item != null) diff --git a/Mono.Profiler/mprof-gui/ChangeLog b/Mono.Profiler/mprof-gui/ChangeLog index 7693216a..e6a9d09d 100644 --- a/Mono.Profiler/mprof-gui/ChangeLog +++ b/Mono.Profiler/mprof-gui/ChangeLog @@ -1,5 +1,9 @@ 2009-09-03 Mike Kestner <mkestner@novell.com> + * MainWindow.cs : hook into Repeat events from the StartPage. + +2009-09-03 Mike Kestner <mkestner@novell.com> + * MainWindow.cs : refactor for ProfileConfiguration. Add recent configs to history. diff --git a/Mono.Profiler/mprof-gui/MainWindow.cs b/Mono.Profiler/mprof-gui/MainWindow.cs index 8ed371b7..5a7d86ad 100644 --- a/Mono.Profiler/mprof-gui/MainWindow.cs +++ b/Mono.Profiler/mprof-gui/MainWindow.cs @@ -111,6 +111,22 @@ namespace Mono.Profiler.Gui { }); } + void StartProfile (ProfileConfiguration config) + { + ProfileView view = new ProfileView (); + view.Show (); + View = view; + logging_enabled_action.Visible = true; + logging_enabled_action.Active = config.StartEnabled; + proc = new ProfilerProcess (config); + proc.Paused += delegate { Refresh (view); }; + proc.Exited += delegate { Refresh (view); logging_enabled_action.Visible = false; }; + proc.Start (); + log_info = new LogInfo (proc.LogFile, config.ToString ()); + history.LogFiles.Prepend (log_info); + history.Configs.Prepend (config); + } + void Shutdown () { history.Save (); @@ -120,20 +136,8 @@ namespace Mono.Profiler.Gui { void OnNewActivated (object sender, System.EventArgs e) { ProfileSetupDialog d = new ProfileSetupDialog (this); - if (d.Run () == (int) Gtk.ResponseType.Accept) { - ProfileView view = new ProfileView (); - view.Show (); - View = view; - logging_enabled_action.Visible = true; - logging_enabled_action.Active = d.Config.StartEnabled; - proc = new ProfilerProcess (d.Config); - proc.Paused += delegate { Refresh (view); }; - proc.Exited += delegate { Refresh (view); logging_enabled_action.Visible = false; }; - proc.Start (); - log_info = new LogInfo (proc.LogFile, d.Config.ToString ()); - history.LogFiles.Prepend (log_info); - history.Configs.Prepend (d.Config); - } + if (d.Run () == (int) Gtk.ResponseType.Accept) + StartProfile (d.Config); d.Destroy (); } @@ -203,6 +207,9 @@ namespace Mono.Profiler.Gui { else OpenProfile (args.Detail); break; + case StartEventType.Repeat: + StartProfile (args.Config); + break; default: throw new NotSupportedException (); } |