Merge lp:~jassmith/do/painterservice into lp:do
- painterservice
- Merge into trunk
Proposed by
Jason Smith
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~jassmith/do/painterservice |
Merge into: | lp:do |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~jassmith/do/painterservice |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Siegel (community) | Approve | ||
Review via email: mp+4195@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote : | # |
Revision history for this message
David Siegel (djsiegel-deactivatedaccount) wrote : | # |
Looks great to me.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Do.Interface.Linux.Docky/Makefile.am' | |||
2 | --- Do.Interface.Linux.Docky/Makefile.am 2009-03-04 20:41:38 +0000 | |||
3 | +++ Do.Interface.Linux.Docky/Makefile.am 2009-03-05 05:00:17 +0000 | |||
4 | @@ -59,7 +59,6 @@ | |||
5 | 59 | src/Docky.Interface/IRightClickable.cs \ | 59 | src/Docky.Interface/IRightClickable.cs \ |
6 | 60 | src/Docky.Interface/ItemPositionProvider.cs \ | 60 | src/Docky.Interface/ItemPositionProvider.cs \ |
7 | 61 | src/Docky.Interface/LayoutUtils.cs \ | 61 | src/Docky.Interface/LayoutUtils.cs \ |
8 | 62 | src/Docky.Interface/PainterService.cs \ | ||
9 | 63 | src/Docky.Interface/PaintNeededArgs.cs \ | 62 | src/Docky.Interface/PaintNeededArgs.cs \ |
10 | 64 | src/Docky.Interface/UpdateRequestArgs.cs \ | 63 | src/Docky.Interface/UpdateRequestArgs.cs \ |
11 | 65 | src/Docky.Interface/Util.cs \ | 64 | src/Docky.Interface/Util.cs \ |
12 | 66 | 65 | ||
13 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/PainterService.cs' | |||
14 | --- Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/PainterService.cs 2009-02-03 09:37:39 +0000 | |||
15 | +++ Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/PainterService.cs 2009-03-05 05:00:17 +0000 | |||
16 | @@ -17,6 +17,7 @@ | |||
17 | 17 | // | 17 | // |
18 | 18 | 18 | ||
19 | 19 | using System; | 19 | using System; |
20 | 20 | using System.Collections.Generic; | ||
21 | 20 | 21 | ||
22 | 21 | using Do.Platform; | 22 | using Do.Platform; |
23 | 22 | 23 | ||
24 | @@ -31,24 +32,59 @@ | |||
25 | 31 | { | 32 | { |
26 | 32 | 33 | ||
27 | 33 | 34 | ||
28 | 35 | ICollection<IDockPainter> painters; | ||
29 | 36 | |||
30 | 34 | #region IPainterService implementation | 37 | #region IPainterService implementation |
31 | 38 | |||
32 | 39 | public event EventHandler PainterHideRequest; | ||
33 | 40 | public event EventHandler PainterShowRequest; | ||
34 | 41 | |||
35 | 35 | public void RegisterPainter (IDockPainter painter) | 42 | public void RegisterPainter (IDockPainter painter) |
36 | 36 | { | 43 | { |
38 | 37 | Log<PainterService>.Error ("Default Painter Services cannot register painters"); | 44 | painters.Add (painter); |
39 | 45 | painter.ShowRequested += HandleShowRequested; | ||
40 | 46 | painter.HideRequested += HandleHideRequested; | ||
41 | 47 | } | ||
42 | 48 | |||
43 | 49 | void HandleHideRequested(object sender, EventArgs e) | ||
44 | 50 | { | ||
45 | 51 | IDockPainter painter = sender as IDockPainter; | ||
46 | 52 | if (painter == null || PainterHideRequest == null) | ||
47 | 53 | return; | ||
48 | 54 | |||
49 | 55 | PainterHideRequest (sender, e); | ||
50 | 56 | } | ||
51 | 57 | |||
52 | 58 | void HandleShowRequested(object sender, EventArgs e) | ||
53 | 59 | { | ||
54 | 60 | IDockPainter painter = sender as IDockPainter; | ||
55 | 61 | if (painter == null || PainterShowRequest == null) | ||
56 | 62 | return; | ||
57 | 63 | |||
58 | 64 | PainterShowRequest (sender, e); | ||
59 | 65 | } | ||
60 | 66 | |||
61 | 67 | #endregion | ||
62 | 68 | |||
63 | 69 | public PainterService () | ||
64 | 70 | { | ||
65 | 71 | painters = new List<IDockPainter> (); | ||
66 | 38 | } | 72 | } |
67 | 39 | 73 | ||
68 | 40 | #region IDisposable implementation | 74 | #region IDisposable implementation |
69 | 41 | 75 | ||
70 | 42 | public void Dispose () | 76 | public void Dispose () |
71 | 43 | { | 77 | { |
72 | 78 | DockServices.UnregisterService (this); | ||
73 | 79 | |||
74 | 80 | foreach (IDockPainter painter in painters) { | ||
75 | 81 | painter.ShowRequested -= HandleShowRequested; | ||
76 | 82 | painter.HideRequested -= HandleHideRequested; | ||
77 | 83 | painter.Dispose (); | ||
78 | 84 | } | ||
79 | 85 | painters.Clear (); | ||
80 | 44 | } | 86 | } |
81 | 45 | 87 | ||
89 | 46 | #endregion | 88 | #endregion |
83 | 47 | |||
84 | 48 | |||
85 | 49 | #endregion | ||
86 | 50 | |||
87 | 51 | |||
88 | 52 | |||
90 | 53 | } | 89 | } |
91 | 54 | } | 90 | } |
92 | 55 | 91 | ||
93 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Core/IPainterService.cs' | |||
94 | --- Do.Interface.Linux.Docky/src/Docky.Core/IPainterService.cs 2009-02-03 09:37:39 +0000 | |||
95 | +++ Do.Interface.Linux.Docky/src/Docky.Core/IPainterService.cs 2009-03-05 05:00:17 +0000 | |||
96 | @@ -25,6 +25,10 @@ | |||
97 | 25 | 25 | ||
98 | 26 | public interface IPainterService : IDockService | 26 | public interface IPainterService : IDockService |
99 | 27 | { | 27 | { |
100 | 28 | event EventHandler PainterHideRequest; | ||
101 | 29 | |||
102 | 30 | event EventHandler PainterShowRequest; | ||
103 | 31 | |||
104 | 28 | void RegisterPainter (IDockPainter painter); | 32 | void RegisterPainter (IDockPainter painter); |
105 | 29 | } | 33 | } |
106 | 30 | } | 34 | } |
107 | 31 | 35 | ||
108 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs' | |||
109 | --- Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-03-04 16:10:30 +0000 | |||
110 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-03-05 05:34:14 +0000 | |||
111 | @@ -123,8 +123,6 @@ | |||
112 | 123 | 123 | ||
113 | 124 | bool CursorIsOverDockArea { get; set; } | 124 | bool CursorIsOverDockArea { get; set; } |
114 | 125 | 125 | ||
115 | 126 | PainterService PainterService { get; set; } | ||
116 | 127 | |||
117 | 128 | ModifierType CursorModifier { get; set; } | 126 | ModifierType CursorModifier { get; set; } |
118 | 129 | 127 | ||
119 | 130 | ReadOnlyCollection<AbstractDockItem> DockItems { | 128 | ReadOnlyCollection<AbstractDockItem> DockItems { |
120 | @@ -204,10 +202,6 @@ | |||
121 | 204 | SetSize (); | 202 | SetSize (); |
122 | 205 | SetSizeRequest (Width, Height); | 203 | SetSizeRequest (Width, Height); |
123 | 206 | 204 | ||
124 | 207 | PainterService = new PainterService (this); | ||
125 | 208 | PainterService.BuildPainters (); | ||
126 | 209 | DockServices.RegisterService (PainterService); | ||
127 | 210 | |||
128 | 211 | PositionProvider = new ItemPositionProvider (this); | 205 | PositionProvider = new ItemPositionProvider (this); |
129 | 212 | 206 | ||
130 | 213 | AnimationState = new DockAnimationState (); | 207 | AnimationState = new DockAnimationState (); |
131 | @@ -253,6 +247,9 @@ | |||
132 | 253 | DockServices.ItemsService.DockItemsChanged += OnDockItemsChanged; | 247 | DockServices.ItemsService.DockItemsChanged += OnDockItemsChanged; |
133 | 254 | DockServices.ItemsService.ItemNeedsUpdate += HandleItemNeedsUpdate; | 248 | DockServices.ItemsService.ItemNeedsUpdate += HandleItemNeedsUpdate; |
134 | 255 | DockPreferences.IconSizeChanged += HandleIconSizeChanged; | 249 | DockPreferences.IconSizeChanged += HandleIconSizeChanged; |
135 | 250 | |||
136 | 251 | DockServices.PainterService.PainterShowRequest += HandlePainterShowRequest; | ||
137 | 252 | DockServices.PainterService.PainterHideRequest += HandlePainterHideRequest; | ||
138 | 256 | 253 | ||
139 | 257 | PopupMenu.Hidden += OnDockItemMenuHidden; | 254 | PopupMenu.Hidden += OnDockItemMenuHidden; |
140 | 258 | PopupMenu.Shown += OnDockItemMenuShown; | 255 | PopupMenu.Shown += OnDockItemMenuShown; |
141 | @@ -273,9 +270,14 @@ | |||
142 | 273 | DockServices.ItemsService.DockItemsChanged -= OnDockItemsChanged; | 270 | DockServices.ItemsService.DockItemsChanged -= OnDockItemsChanged; |
143 | 274 | DockServices.ItemsService.ItemNeedsUpdate -= HandleItemNeedsUpdate; | 271 | DockServices.ItemsService.ItemNeedsUpdate -= HandleItemNeedsUpdate; |
144 | 275 | DockPreferences.IconSizeChanged -= HandleIconSizeChanged; | 272 | DockPreferences.IconSizeChanged -= HandleIconSizeChanged; |
145 | 273 | |||
146 | 274 | DockServices.PainterService.PainterShowRequest -= HandlePainterShowRequest; | ||
147 | 275 | DockServices.PainterService.PainterHideRequest -= HandlePainterHideRequest; | ||
148 | 276 | 276 | ||
149 | 277 | PopupMenu.Hidden -= OnDockItemMenuHidden; | 277 | PopupMenu.Hidden -= OnDockItemMenuHidden; |
150 | 278 | PopupMenu.Shown -= OnDockItemMenuShown; | 278 | PopupMenu.Shown -= OnDockItemMenuShown; |
151 | 279 | |||
152 | 280 | Services.Core.UniverseInitialized -= HandleUniverseInitialized; | ||
153 | 279 | } | 281 | } |
154 | 280 | 282 | ||
155 | 281 | void BuildAnimationStateEngine () | 283 | void BuildAnimationStateEngine () |
156 | @@ -311,6 +313,7 @@ | |||
157 | 311 | void HandleUniverseInitialized(object sender, EventArgs e) | 313 | void HandleUniverseInitialized(object sender, EventArgs e) |
158 | 312 | { | 314 | { |
159 | 313 | GLib.Timeout.Add (2000, delegate { | 315 | GLib.Timeout.Add (2000, delegate { |
160 | 316 | DockServices.ItemsService.ForceUpdate (); | ||
161 | 314 | SetIconRegions (); | 317 | SetIconRegions (); |
162 | 315 | return false; | 318 | return false; |
163 | 316 | }); | 319 | }); |
164 | @@ -336,6 +339,51 @@ | |||
165 | 336 | AnimatedDraw (); | 339 | AnimatedDraw (); |
166 | 337 | } | 340 | } |
167 | 338 | 341 | ||
168 | 342 | void HandlePainterHideRequest(object sender, EventArgs e) | ||
169 | 343 | { | ||
170 | 344 | IDockPainter painter = sender as IDockPainter; | ||
171 | 345 | if (Painter != painter) | ||
172 | 346 | return; | ||
173 | 347 | |||
174 | 348 | Painter = null; | ||
175 | 349 | PainterOverlayVisible = false; | ||
176 | 350 | interface_change_time = DateTime.UtcNow; | ||
177 | 351 | |||
178 | 352 | SetParentInputMask (); | ||
179 | 353 | AnimatedDraw (); | ||
180 | 354 | |||
181 | 355 | GLib.Timeout.Add (500, () => { | ||
182 | 356 | DockServices.ItemsService.ForceUpdate (); | ||
183 | 357 | return false; | ||
184 | 358 | }); | ||
185 | 359 | |||
186 | 360 | window.UnpresentWindow (); | ||
187 | 361 | RegisterGtkDragSource (); | ||
188 | 362 | } | ||
189 | 363 | |||
190 | 364 | void HandlePainterShowRequest(object sender, EventArgs e) | ||
191 | 365 | { | ||
192 | 366 | IDockPainter painter = sender as IDockPainter; | ||
193 | 367 | if (Painter == painter) | ||
194 | 368 | return; | ||
195 | 369 | |||
196 | 370 | if (Painter == null || Painter.Interruptable) { | ||
197 | 371 | if (Painter != null) | ||
198 | 372 | Painter.Interrupt (); | ||
199 | 373 | Painter = painter; | ||
200 | 374 | PainterOverlayVisible = true; | ||
201 | 375 | interface_change_time = DateTime.UtcNow; | ||
202 | 376 | |||
203 | 377 | SetParentInputMask (); | ||
204 | 378 | AnimatedDraw (); | ||
205 | 379 | } else { | ||
206 | 380 | painter.Interrupt (); | ||
207 | 381 | } | ||
208 | 382 | |||
209 | 383 | window.PresentWindow (); | ||
210 | 384 | UnregisterGtkDragSource (); | ||
211 | 385 | } | ||
212 | 386 | |||
213 | 339 | void ResetCursorTimer () | 387 | void ResetCursorTimer () |
214 | 340 | { | 388 | { |
215 | 341 | if (disposed) | 389 | if (disposed) |
216 | @@ -622,50 +670,6 @@ | |||
217 | 622 | } | 670 | } |
218 | 623 | } | 671 | } |
219 | 624 | 672 | ||
220 | 625 | public bool RequestShowPainter (IDockPainter painter) | ||
221 | 626 | { | ||
222 | 627 | if (Painter == painter) | ||
223 | 628 | return true; | ||
224 | 629 | |||
225 | 630 | if (Painter == null || Painter.Interruptable) { | ||
226 | 631 | if (Painter != null) | ||
227 | 632 | Painter.Interrupt (); | ||
228 | 633 | Painter = painter; | ||
229 | 634 | PainterOverlayVisible = true; | ||
230 | 635 | interface_change_time = DateTime.UtcNow; | ||
231 | 636 | |||
232 | 637 | SetParentInputMask (); | ||
233 | 638 | AnimatedDraw (); | ||
234 | 639 | } else { | ||
235 | 640 | return false; | ||
236 | 641 | } | ||
237 | 642 | window.PresentWindow (); | ||
238 | 643 | UnregisterGtkDragSource (); | ||
239 | 644 | return true; | ||
240 | 645 | } | ||
241 | 646 | |||
242 | 647 | public bool RequestHidePainter (IDockPainter painter) | ||
243 | 648 | { | ||
244 | 649 | if (Painter != painter) | ||
245 | 650 | return false; | ||
246 | 651 | |||
247 | 652 | Painter = null; | ||
248 | 653 | PainterOverlayVisible = false; | ||
249 | 654 | interface_change_time = DateTime.UtcNow; | ||
250 | 655 | |||
251 | 656 | SetParentInputMask (); | ||
252 | 657 | AnimatedDraw (); | ||
253 | 658 | |||
254 | 659 | GLib.Timeout.Add (500, () => { | ||
255 | 660 | DockServices.ItemsService.ForceUpdate (); | ||
256 | 661 | return false; | ||
257 | 662 | }); | ||
258 | 663 | |||
259 | 664 | window.UnpresentWindow (); | ||
260 | 665 | RegisterGtkDragSource (); | ||
261 | 666 | return true; | ||
262 | 667 | } | ||
263 | 668 | |||
264 | 669 | void InterruptPainter () | 673 | void InterruptPainter () |
265 | 670 | { | 674 | { |
266 | 671 | if (Painter == null || !Painter.Interruptable) return; | 675 | if (Painter == null || !Painter.Interruptable) return; |
267 | @@ -713,9 +717,6 @@ | |||
268 | 713 | Painter.PaintNeeded -= HandlePaintNeeded; | 717 | Painter.PaintNeeded -= HandlePaintNeeded; |
269 | 714 | } | 718 | } |
270 | 715 | 719 | ||
271 | 716 | DockServices.UnregisterService (PainterService); | ||
272 | 717 | PainterService.Dispose (); | ||
273 | 718 | |||
274 | 719 | window = null; | 720 | window = null; |
275 | 720 | 721 | ||
276 | 721 | if (cursor_timer > 0) | 722 | if (cursor_timer > 0) |
277 | 722 | 723 | ||
278 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs' | |||
279 | --- Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs 2009-03-03 13:59:44 +0000 | |||
280 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs 2009-03-05 05:00:17 +0000 | |||
281 | @@ -77,6 +77,8 @@ | |||
282 | 77 | 77 | ||
283 | 78 | interop_service = new DoInteropService (controller); | 78 | interop_service = new DoInteropService (controller); |
284 | 79 | Core.DockServices.RegisterService (interop_service); | 79 | Core.DockServices.RegisterService (interop_service); |
285 | 80 | |||
286 | 81 | Core.DockServices.PainterService.RegisterPainter (new Painters.SummonModeRenderer ()); | ||
287 | 80 | 82 | ||
288 | 81 | RegisterEvents (); | 83 | RegisterEvents (); |
289 | 82 | Build (); | 84 | Build (); |
290 | 83 | 85 | ||
291 | === removed file 'Do.Interface.Linux.Docky/src/Docky.Interface/PainterService.cs' | |||
292 | --- Do.Interface.Linux.Docky/src/Docky.Interface/PainterService.cs 2009-02-23 06:09:46 +0000 | |||
293 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/PainterService.cs 1970-01-01 00:00:00 +0000 | |||
294 | @@ -1,94 +0,0 @@ | |||
295 | 1 | // PainterService.cs | ||
296 | 2 | // | ||
297 | 3 | // Copyright (C) 2009 GNOME Do | ||
298 | 4 | // | ||
299 | 5 | // This program is free software: you can redistribute it and/or modify | ||
300 | 6 | // it under the terms of the GNU General Public License as published by | ||
301 | 7 | // the Free Software Foundation, either version 3 of the License, or | ||
302 | 8 | // (at your option) any later version. | ||
303 | 9 | // | ||
304 | 10 | // This program is distributed in the hope that it will be useful, | ||
305 | 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
306 | 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
307 | 13 | // GNU General Public License for more details. | ||
308 | 14 | // | ||
309 | 15 | // You should have received a copy of the GNU General Public License | ||
310 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
311 | 17 | // | ||
312 | 18 | |||
313 | 19 | using System; | ||
314 | 20 | using System.Collections.Generic; | ||
315 | 21 | |||
316 | 22 | using Docky.Core; | ||
317 | 23 | |||
318 | 24 | namespace Docky.Interface | ||
319 | 25 | { | ||
320 | 26 | |||
321 | 27 | |||
322 | 28 | internal class PainterService : IPainterService | ||
323 | 29 | { | ||
324 | 30 | ICollection<IDockPainter> painters; | ||
325 | 31 | DockArea parent; | ||
326 | 32 | |||
327 | 33 | #region IPainterService implementation | ||
328 | 34 | |||
329 | 35 | public void RegisterPainter (IDockPainter painter) | ||
330 | 36 | { | ||
331 | 37 | painters.Add (painter); | ||
332 | 38 | painter.ShowRequested += HandleShowRequested; | ||
333 | 39 | painter.HideRequested += HandleHideRequested; | ||
334 | 40 | } | ||
335 | 41 | |||
336 | 42 | void HandleHideRequested(object sender, EventArgs e) | ||
337 | 43 | { | ||
338 | 44 | IDockPainter painter = sender as IDockPainter; | ||
339 | 45 | if (painter == null) | ||
340 | 46 | return; | ||
341 | 47 | |||
342 | 48 | parent.RequestHidePainter (painter); | ||
343 | 49 | } | ||
344 | 50 | |||
345 | 51 | void HandleShowRequested(object sender, EventArgs e) | ||
346 | 52 | { | ||
347 | 53 | IDockPainter painter = sender as IDockPainter; | ||
348 | 54 | if (painter == null) | ||
349 | 55 | return; | ||
350 | 56 | |||
351 | 57 | bool shown = parent.RequestShowPainter (painter); | ||
352 | 58 | if (!shown) | ||
353 | 59 | painter.Interrupt (); | ||
354 | 60 | } | ||
355 | 61 | |||
356 | 62 | #endregion | ||
357 | 63 | |||
358 | 64 | internal PainterService (DockArea parent) | ||
359 | 65 | { | ||
360 | 66 | this.parent = parent; | ||
361 | 67 | painters = new List<IDockPainter> (); | ||
362 | 68 | } | ||
363 | 69 | |||
364 | 70 | public void BuildPainters () | ||
365 | 71 | { | ||
366 | 72 | RegisterPainter (new Painters.SummonModeRenderer ()); | ||
367 | 73 | } | ||
368 | 74 | |||
369 | 75 | #region IDisposable implementation | ||
370 | 76 | |||
371 | 77 | public void Dispose () | ||
372 | 78 | { | ||
373 | 79 | DockServices.UnregisterService (this); | ||
374 | 80 | |||
375 | 81 | foreach (IDockPainter painter in painters) { | ||
376 | 82 | painter.ShowRequested -= HandleShowRequested; | ||
377 | 83 | painter.HideRequested -= HandleHideRequested; | ||
378 | 84 | painter.Dispose (); | ||
379 | 85 | } | ||
380 | 86 | painters.Clear (); | ||
381 | 87 | |||
382 | 88 | parent = null; | ||
383 | 89 | } | ||
384 | 90 | |||
385 | 91 | #endregion | ||
386 | 92 | |||
387 | 93 | } | ||
388 | 94 | } |
Fixes bug where clock painter stops working after monitor switch