~ubuntu-branches/ubuntu/precise/gnome-do/precise-proposed

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.UI/BaseWidgets/SymbolDisplayLabel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-09-14 10:09:40 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20080914100940-kyghudg7py14bu2z
Tags: upstream-0.6.0.0
ImportĀ upstreamĀ versionĀ 0.6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
{
30
30
        public class SymbolDisplayLabel : Label
31
31
        {
32
 
                // const string displayFormat = " <big>{0}</big> \n {1} ";
33
 
                
34
 
                // Description only:
35
 
                const string displayFormat = "<span size=\"medium\"> {1} </span>";
 
32
                const string DisplayFormat = "<span size=\"medium\"> {1} </span>";
36
33
                
37
34
                string highlight;
38
35
                string name, description;
39
36
                
40
37
                public SymbolDisplayLabel ():
41
 
                        base ("")
 
38
                        base (string.Empty)
42
39
                {
43
 
                        highlight = name = description = "";
 
40
                        highlight = name = description = string.Empty;
44
41
                        Build ();
45
42
                }
46
43
                
47
44
                void Build ()
48
45
                {
49
46
                        UseMarkup = true;
50
 
                        Ellipsize = Pango.EllipsizeMode.End;
 
47
                        Ellipsize = Pango.EllipsizeMode.Middle;
51
48
                        Justify = Justification.Center;
52
 
                        ModifyFg (StateType.Normal, Gtk.Rc.GetStyle (this).Foregrounds[(int) StateType.Selected]);
 
49
                        
 
50
                        ModifyFg (StateType.Normal,
 
51
                                new Gdk.Color (byte.MaxValue, byte.MaxValue, byte.MaxValue));
53
52
                }
54
53
                
55
54
                public IObject DisplayObject
58
57
                                IObject displayObject;
59
58
                                
60
59
                                displayObject = value;
61
 
                                name = description = highlight = "";
 
60
                                name = description = highlight = string.Empty;
62
61
                                if (displayObject != null) {
63
62
                                        name = displayObject.Name;
64
63
                                        description = displayObject.Description;
69
68
                
70
69
                public void SetDisplayLabel (string name, string description)
71
70
                {
72
 
                        this.name = name ?? "";
73
 
                        this.description = description ?? "";
74
 
                        highlight = "";
 
71
                        this.name = (name ?? string.Empty).Replace ("\n", " ");
 
72
                        this.description = (description ?? string.Empty).Replace ("\n", " ");
 
73
                        highlight = string.Empty;
75
74
                        UpdateText ();
76
75
                }
77
76
                
79
78
                {
80
79
                        get { return highlight; }
81
80
                        set {
82
 
                                highlight = value ?? "";
 
81
                                highlight = value ?? string.Empty;
83
82
                                UpdateText ();
84
83
                        }
85
84
                }
91
90
                        safe_name = Util.Appearance.MarkupSafeString (name);
92
91
                        safe_description = Util.Appearance.MarkupSafeString (description);
93
92
                        highlighted = Util.FormatCommonSubstrings(safe_name, highlight, "<u>{0}</u>");
94
 
                        Markup = string.Format (displayFormat, highlighted, safe_description);
 
93
                        Markup = string.Format (DisplayFormat, highlighted, safe_description);
95
94
                }
96
95
                
97
96
        }