1
/* SymbolDisplayLabel.cs
3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this source distribution.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28
namespace Do.Interface.Widgets
30
public class SymbolDisplayLabel : Label
32
const string DisplayFormat = "<span size=\"medium\"> {1} </span>";
35
string name, description;
37
public SymbolDisplayLabel ():
40
highlight = name = description = "";
47
Ellipsize = Pango.EllipsizeMode.Middle;
48
Justify = Justification.Center;
50
ModifyFg (StateType.Normal,
51
new Gdk.Color (byte.MaxValue, byte.MaxValue, byte.MaxValue));
54
public Do.Universe.Item DisplayObject
57
Do.Universe.Item displayObject;
59
displayObject = value;
60
name = description = highlight = "";
61
if (displayObject != null) {
62
name = displayObject.Name;
63
description = displayObject.Description;
65
SetDisplayLabel (name, description);
69
public void SetDisplayLabel (string name, string description)
71
this.name = (name ?? "").Replace ("\n", " ");
72
this.description = (description ?? "").Replace ("\n", " ");
77
public string Highlight
79
get { return highlight; }
81
highlight = value ?? "";
88
string highlighted, safe_name, safe_description;
90
safe_name = Util.Appearance.MarkupSafeString (name);
91
safe_description = Util.Appearance.MarkupSafeString (description);
92
highlighted = Util.FormatCommonSubstrings(safe_name, highlight, "<u>{0}</u>");
93
Markup = string.Format (DisplayFormat, highlighted, safe_description);