Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs91
1 files changed, 80 insertions, 11 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs
index 8e4e9ebd94..d26b2d4bac 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs
@@ -24,12 +24,18 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using MonoDevelop.Ide.Tasks;
+using MonoDevelop.Ide.Gui;
namespace MonoDevelop.Components
{
public class TooltipPopoverWindow: PopoverWindow
{
Gtk.Label label;
+ TaskSeverity? severity;
+ bool hasMarkup;
+ string text;
+ Gtk.Alignment alignment;
public TooltipPopoverWindow ()
{
@@ -40,43 +46,106 @@ namespace MonoDevelop.Components
public string Text {
get {
- return label != null ? label.Text : string.Empty;
+ return text;
}
set {
+ hasMarkup = false;
+ text = value;
AddLabel ();
- label.Text = value;
+ UpdateLabel ();
AdjustSize ();
}
}
public string Markup {
get {
- return label != null ? label.Text : string.Empty;
+ return text;
}
set {
+ hasMarkup = true;
+ text = value;
AddLabel ();
- label.Markup = value;
+ UpdateLabel ();
AdjustSize ();
}
}
+ public TaskSeverity? Severity {
+ get { return severity; }
+ set {
+ severity = value;
+ UpdateLabel ();
+ if (severity.HasValue) {
+ Theme.Padding = 3;
+ Theme.CornerRadius = 5;
+ alignment.SetPadding (4, 6, 6, 6);
+ Theme.BorderColor = new Cairo.Color (0, 0, 0, 0);
+ var f = Style.FontDescription.Copy ();
+ f.Size = ((f.Size / (int)Pango.Scale.PangoScale) - 1) * (int) Pango.Scale.PangoScale;
+ label.ModifyFont (f);
+ switch (severity.Value) {
+ case TaskSeverity.Information:
+ Theme.SetFlatColor (Styles.PopoverWindow.InformationBackgroundColor);
+ Theme.BorderColor = Styles.PopoverWindow.InformationBackgroundColor;
+ break;
+ case TaskSeverity.Comment:
+ Theme.SetFlatColor (Styles.PopoverWindow.InformationBackgroundColor);
+ Theme.BorderColor = Styles.PopoverWindow.InformationBackgroundColor;
+ break;
+ case TaskSeverity.Error:
+ Theme.SetFlatColor (Styles.PopoverWindow.ErrorBackgroundColor);
+ Theme.BorderColor = Styles.PopoverWindow.ErrorBackgroundColor;
+ return;
+ case TaskSeverity.Warning:
+ Theme.SetFlatColor (Styles.PopoverWindow.WarningBackgroundColor);
+ Theme.BorderColor = Styles.PopoverWindow.WarningBackgroundColor;
+ return;
+ }
+ } else {
+ Theme.SetFlatColor (new Cairo.Color (1d, 243d / 255d, 207d / 255d, 0.9d));
+ Theme.BorderColor = new Cairo.Color (128d/255d, 122d / 255d, 104d / 255d);
+ }
+ }
+ }
+
void AddLabel ()
{
if (label == null) {
- Gtk.Alignment al = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f);
- al.SetPadding (6, 6, 6, 6);
+ alignment = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f);
+ alignment.SetPadding (6, 6, 6, 6);
label = new Gtk.Label ();
- al.Add (label);
- ContentBox.Add (al);
- al.ShowAll ();
+ alignment.Add (label);
+ ContentBox.Add (alignment);
+ alignment.ShowAll ();
+ }
+ }
+
+ void UpdateLabel ()
+ {
+ if (severity.HasValue) {
+ string msg = hasMarkup ? text : GLib.Markup.EscapeText (text);
+ switch (severity.Value) {
+ case TaskSeverity.Information:
+ case TaskSeverity.Comment:
+ case TaskSeverity.Error:
+ label.Markup = "<b><span color='white'>" + text + "</span></b>";
+ return;
+ case TaskSeverity.Warning:
+ label.Markup = "<b><span color='#6D5607'>" + text + "</span></b>";
+ return;
+ }
}
+ if (hasMarkup)
+ label.Markup = text;
+ else
+ label.Text = text;
}
void AdjustSize ()
{
- if (label.SizeRequest ().Width > 300) {
+ if (label.SizeRequest ().Width > 330) {
label.Wrap = true;
- label.WidthRequest = 300;
+ label.WidthRequest = 330;
} else {
label.Wrap = false;
label.WidthRequest = -1;