~ubuntu-branches/ubuntu/natty/gnome-do/natty

« back to all changes in this revision

Viewing changes to Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 10:40:45 UTC
  • mfrom: (1.1.8 upstream) (0.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090627104045-7st10y1cqr6dpz37
Tags: 0.8.2+dfsg-1
* New upstream release
  + No longer uses a plugin repository.  Fixes many plugin-
    related issues. (LP: #343096, LP: #330025, LP #345001)
  + No longer blocks on "About Do" (LP: #361679)
  + Reacts correctly when a Composite manager is enabled/
    disabled at runtime. (LP: #346347, LP: #390150)
  + Fixes for space reserved by Docky blocking drag and 
    drop operations. (LP: #354729, LP: #347052, LP: #382843)
  + Properly sets "Hidden" key on autostart files in response to 
    "Start on login" option.  (Closes: #526023) (LP: #369988)
* debian/patches/10_application_search_path:
  + Drop; included upstream
* debian/patches/10_sk_translation_update:
  + Import sk translation update from Debian BTS.
    (Closes: #531779)
* debian/patches/11_fix_autostart_when_directory_does_not_exist:
  + Patch from upstream.  Fixes the "Start on login" option when the 
    ~/.config/autostart directory does not exist. (LP: #393729)
* debian/control:
  + Update standards version to 3.8.2; no changes required.
  + Add libtool to Build-Depends; required for autoreconf.
  + Add Recommends: on new gnome-do-docklets package.
* debian/gnome-do.1
  + Fix spelling: GNOME-Do => GNOME Do.
  + Miscelaneous lintian fixes; NAME section, escaping minus signs with \-
* debian/copyright:
  + Update for new copyright holders.
  + Minor update to DEP-5 format

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
                const int Height = 22;
40
40
                
41
41
                Gtk.Widget widget;
42
 
                bool hovered;
 
42
                bool hovered, tooltip;
 
43
                string description, icon;
43
44
                
44
45
                public bool Dark { get; set; }
45
46
                
47
48
                        get { return 1; }
48
49
                }
49
50
                
50
 
                public override Gtk.Widget Widget { 
51
 
                        get {
52
 
                                if (widget == null)
53
 
                                        widget = BuildWidget ();
54
 
                                return widget;
55
 
                        }
56
 
                }
57
 
                
58
 
                protected virtual string Description { get; set; }
59
 
                
60
 
                protected virtual string Icon { get; set; }
61
 
                
62
 
                protected virtual bool UseTooltip { get; set; }
 
51
                public override Gtk.Widget Widget {
 
52
                        get { return widget; } 
 
53
                }
 
54
                
 
55
                private Gdk.Pixbuf Pixbuf { get; set; }
 
56
                
 
57
                protected string Description { 
 
58
                        get {
 
59
                                return description;
 
60
                        }
 
61
                        set {
 
62
                                description = value;
 
63
                                BuildWidget ();
 
64
                        }
 
65
                }
 
66
                
 
67
                protected string Icon { 
 
68
                        get {
 
69
                                return icon;
 
70
                        }
 
71
                        set {
 
72
                                icon = value;
 
73
                                BuildWidget ();
 
74
                        }
 
75
                }
 
76
                
 
77
                protected bool UseTooltip {
 
78
                        get {
 
79
                                return tooltip;
 
80
                        }
 
81
                        set {
 
82
                                
 
83
                                tooltip = value;
 
84
                                BuildWidget ();
 
85
                        }
 
86
                }
63
87
                
64
88
                public AbstractMenuButtonArgs ()
65
89
                {
66
 
                        
67
90
                }
68
91
                
69
92
                public AbstractMenuButtonArgs (string description, string icon)
70
93
                {
71
 
                        Description = GLib.Markup.EscapeText (Catalog.GetString (description));
72
 
                        Icon = icon;
 
94
                        this.description = GLib.Markup.EscapeText (Catalog.GetString (description));
 
95
                        this.icon = icon;
 
96
                        
 
97
                        BuildWidget ();
73
98
                }
74
99
                
75
 
                Widget BuildWidget ()
 
100
                void BuildWidget ()
76
101
                {
 
102
                        if (widget != null)
 
103
                                widget.Destroy ();
 
104
                        
77
105
                        DrawingArea button = new DrawingArea ();
78
106
                        
79
107
                        button.ExposeEvent += HandleExposeEvent;
88
116
                        if (UseTooltip)
89
117
                                button.TooltipText = Description;
90
118
                        
91
 
                        return button;
 
119
                        widget = button;
 
120
                        
 
121
                        if (Pixbuf != null)
 
122
                                Pixbuf.Dispose ();
 
123
                        
 
124
                        Pixbuf = GetPixbuf (Height - 8);
92
125
                }
93
126
                
94
127
                void HandleButtonReleaseEvent(object o, ButtonReleaseEventArgs args)
135
168
                                
136
169
                                int width = area.Width - WidthBuffer * 2 - 25;
137
170
                                
138
 
                                TextRenderContext renderContext = new TextRenderContext (cr, string.Format (FormatString, Description), width);
139
 
                                
140
 
                                renderContext.LeftCenteredPoint = new Gdk.Point (area.X + WidthBuffer + 25, area.Y + area.Height / 2);
141
 
                                renderContext.Alignment = Pango.Alignment.Left;
142
 
                                renderContext.EllipsizeMode = Pango.EllipsizeMode.End;
143
 
                                
144
 
                                DockServices.DrawingService.TextPathAtPoint (renderContext);
145
 
                                
146
 
                                cr.Color = new Cairo.Color (1, 1, 1);
147
 
                                cr.Fill ();
148
 
                                
149
 
                                Gdk.Pixbuf pbuf = GetPixbuf (Height - 8);
150
 
                                CairoHelper.SetSourcePixbuf (cr, pbuf, WidthBuffer, (Height - pbuf.Height) / 2);
151
 
                                cr.PaintWithAlpha (IconOpacity);
152
 
                                pbuf.Dispose ();
 
171
                                if (!string.IsNullOrEmpty (Description)) {
 
172
                                        TextRenderContext renderContext = new TextRenderContext (cr, string.Format (FormatString, Description), width);
 
173
                                        
 
174
                                        renderContext.LeftCenteredPoint = new Gdk.Point (area.X + WidthBuffer + 25, area.Y + area.Height / 2);
 
175
                                        renderContext.Alignment = Pango.Alignment.Left;
 
176
                                        renderContext.EllipsizeMode = Pango.EllipsizeMode.End;
 
177
                                        
 
178
                                        DockServices.DrawingService.TextPathAtPoint (renderContext);
 
179
                                        
 
180
                                        cr.Color = new Cairo.Color (1, 1, 1);
 
181
                                        cr.Fill ();
 
182
                                }
 
183
                                
 
184
                                if (Pixbuf != null) {
 
185
                                        CairoHelper.SetSourcePixbuf (cr, Pixbuf, WidthBuffer, (Height - Pixbuf.Height) / 2);
 
186
                                        cr.PaintWithAlpha (IconOpacity);
 
187
                                }
153
188
                        }
154
189
                }
155
190
                
156
191
                protected virtual Gdk.Pixbuf GetPixbuf (int size)
157
192
                {
158
 
                        return IconProvider.PixbufFromIconName (Icon, size);
 
193
                        if (!string.IsNullOrEmpty (Icon))
 
194
                                return IconProvider.PixbufFromIconName (Icon, size);
 
195
                        return null;
159
196
                }
160
197
                
161
198
                public abstract void Action ();
168
205
                
169
206
                public override void Dispose ()
170
207
                {
171
 
                        Widget.Destroy ();
 
208
                        if (Widget != null)
 
209
                                Widget.Destroy ();
 
210
                        if (Pixbuf != null)
 
211
                                Pixbuf.Dispose ();
172
212
                        base.Dispose ();
173
213
                }
174
214