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

« back to all changes in this revision

Viewing changes to Do.Interface.Linux.Docky/src/Docky.Interface/PoofWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2011-02-15 21:50:02 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110215215002-1j8ylb69o15asb06
Tags: 0.8.4-0ubuntu1
* The Race Against FF upload.  Merge from unreleased Debian git.
  Remaining Ubuntu changes:
  + debian/patches/05_disable_resize_grips.patch.diff:
    Disable resize handles for the Do windows.
  + debian/control:
    Bump gtk# build dep for HasResizeGrip API.
* New Debian changes:
* The long fortold release
  + Fixes a threadsafety issue resulting in 100% CPU usage (Closes: 565591,
    LP: #450852).
  + Proxies all keyring calls to the GTK main thread, as required by the new
    gnome-keyring (Closes: 603876, LP: #553643)
* debian/patches/00_bundledlibs.dpatch:
* debian/rules:
  + Upstream has dropped bundled gmcs binary; now 100% DFSG-free, so we don't
    have to repack the tarball or patch the buildsystem.
* debian/patches/03_disable_docky.dpatch:
  + Drop.  Docky is now gone in the upstream tarball.
* debian/rules:
* debian/control:
* debian/patches/*:
  + Switch to quilt to harmonise with other pkg-cli-* packages.
* debian/control:
  + Drop recommends on gnome-do-docklets.  Docky is now a separate package,
    so the docklets are useless for Do.
  + Bump Breaks on gnome-do-plugins to 0.8.3.  Do no longer provides the Wink
    library, which has been imported into the 0.8.3 do-plugins sources.
  + Bump standards-version; no changes needed.
  + Migrate to git and update VCS fields appropriately

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
using System;
3
 
using System.Collections.Generic;
4
 
using System.Linq;
5
 
 
6
 
using Cairo;
7
 
using Gdk;
8
 
using Gtk;
9
 
 
10
 
using Do.Interface;
11
 
using Do.Interface.CairoUtils;
12
 
using Docky.Utilities;
13
 
 
14
 
namespace Docky.Interface
15
 
{
16
 
        
17
 
        
18
 
        public class PoofWindow
19
 
        {
20
 
                TimeSpan run_length = new TimeSpan (0, 0, 0, 0, 300);
21
 
                
22
 
                Gdk.Pixbuf poof;
23
 
                Gtk.Window window;
24
 
                
25
 
                int size;
26
 
                int x, y;
27
 
                
28
 
                DateTime run_time;
29
 
                
30
 
                double AnimationState {
31
 
                        get { 
32
 
                                return Math.Max (0, Math.Min (1, (DateTime.UtcNow - run_time).TotalMilliseconds / run_length.TotalMilliseconds));
33
 
                        }
34
 
                }
35
 
                
36
 
                public PoofWindow (int size)
37
 
                {
38
 
                        this.size = size;
39
 
                }
40
 
                
41
 
                public void SetCenterPosition (Gdk.Point point)
42
 
                {
43
 
                        x = point.X - (size / 2);
44
 
                        y = point.Y - (size / 2);
45
 
                }
46
 
                
47
 
                public void Run ()
48
 
                {
49
 
                        window = new Gtk.Window (Gtk.WindowType.Toplevel);
50
 
                        poof = new Pixbuf (GetType ().Assembly, "poof.png");
51
 
                        
52
 
                        window.AppPaintable = true;
53
 
                        window.Resizable = false;
54
 
                        window.KeepAbove = true;
55
 
                        window.CanFocus = false;
56
 
                        window.TypeHint = WindowTypeHint.Splashscreen;
57
 
                        window.SetCompositeColormap ();
58
 
                        
59
 
                        window.Realized += delegate { window.GdkWindow.SetBackPixmap (null, false); };
60
 
                        
61
 
                        window.SetSizeRequest (size, size);
62
 
                        window.ExposeEvent += HandleExposeEvent;
63
 
                        
64
 
                        GLib.Timeout.Add (30, delegate {
65
 
                                if (AnimationState == 1) {
66
 
                                        window.Hide ();
67
 
                                        window.Destroy ();
68
 
                                        poof.Dispose ();
69
 
                                        return false;
70
 
                                } else {
71
 
                                        window.QueueDraw ();
72
 
                                        return true;
73
 
                                }
74
 
                        });
75
 
                        
76
 
                        window.Move (x, y);
77
 
                        window.ShowAll ();
78
 
                        run_time = DateTime.UtcNow;
79
 
                }
80
 
 
81
 
                void HandleExposeEvent (object o, ExposeEventArgs args)
82
 
                {
83
 
                        using (Cairo.Context cr = CairoHelper.Create (window.GdkWindow)) {
84
 
                                cr.Scale ((double) size / 128, (double) size / 128);
85
 
                                cr.AlphaFill ();
86
 
                                int offset;
87
 
                                switch ((int) Math.Floor (5 * AnimationState)) {
88
 
                                case 0:
89
 
                                        offset = 0;
90
 
                                        break;
91
 
                                case 1:
92
 
                                        offset = 128;
93
 
                                        break;
94
 
                                case 2:
95
 
                                        offset = 128 * 2;
96
 
                                        break;
97
 
                                case 3:
98
 
                                        offset = 128 * 3;
99
 
                                        break;
100
 
                                default:
101
 
                                        offset = 128 * 4;
102
 
                                        break;
103
 
                                }
104
 
                                
105
 
                                CairoHelper.SetSourcePixbuf (cr, poof, 0, -(offset));
106
 
                                cr.Paint ();
107
 
                        }
108
 
                }
109
 
        }
110
 
}