~ubuntu-branches/ubuntu/wily/gnome-do/wily

« back to all changes in this revision

Viewing changes to Do.Interface.Linux/src/Do.Interface/Do.Interface.AnimationBase/Bezel.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:
1
 
// Bezel.cs
2
 
// 
3
 
// Copyright (C) 2008 GNOME-Do
4
 
//
5
 
// This program is free software: you can redistribute it and/or modify
6
 
// it under the terms of the GNU General Public License as published by
7
 
// the Free Software Foundation, either version 3 of the License, or
8
 
// (at your option) any later version.
9
 
//
10
 
// This program is distributed in the hope that it will be useful,
11
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
// GNU General Public License for more details.
14
 
//
15
 
// You should have received a copy of the GNU General Public License
16
 
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
//
18
 
 
19
 
using System;
20
 
using System.Collections.Generic;
21
 
using System.Linq;
22
 
 
23
 
using Cairo;
24
 
using Gdk;
25
 
using Gtk;
26
 
 
27
 
using Do.Universe;
28
 
using Do.Platform;
29
 
using Do.Interface;
30
 
 
31
 
namespace Do.Interface.AnimationBase
32
 
{
33
 
        
34
 
        
35
 
        public abstract class AbstractAnimatedInterface : Gtk.Window, IDoWindow
36
 
        {
37
 
                BezelDrawingArea bezel_drawing_area;
38
 
                BezelGlassResults bezel_glass_results;
39
 
                BezelGlassWindow bezel_glass_window;
40
 
                IDoController controller;
41
 
                PositionWindow pw;
42
 
                
43
 
                public Pane CurrentPane {
44
 
                        get { return bezel_drawing_area.Focus; }
45
 
                        set { bezel_drawing_area.Focus = value; }
46
 
                }
47
 
                
48
 
                public new string Name { 
49
 
                        get { return RenderTheme.Name; }
50
 
                }
51
 
                
52
 
                protected abstract IRenderTheme RenderTheme { get; }
53
 
                
54
 
                public AbstractAnimatedInterface () : base (Gtk.WindowType.Toplevel)
55
 
                {
56
 
                }
57
 
                
58
 
                public void Initialize (IDoController controller)
59
 
                {
60
 
                        this.controller = controller;
61
 
                        Build ();
62
 
                }
63
 
                
64
 
                void Build ()
65
 
                {
66
 
                        Decorated = false;
67
 
                        AppPaintable = true;
68
 
                        KeepAbove = true;
69
 
                        
70
 
                        TypeHint = WindowTypeHint.Splashscreen;
71
 
                        SetColormap ();
72
 
                        
73
 
                        bezel_drawing_area = new BezelDrawingArea (controller, RenderTheme, false);
74
 
                        bezel_drawing_area.Show ();
75
 
                        
76
 
                        bezel_glass_results = bezel_drawing_area.Results;
77
 
                        bezel_glass_window = new BezelGlassWindow (bezel_glass_results);
78
 
        
79
 
                        Add (bezel_drawing_area);
80
 
                        
81
 
                        pw = new PositionWindow (this, bezel_glass_window);
82
 
                }
83
 
                
84
 
                protected override void OnDestroyed ()
85
 
                {
86
 
                        base.OnDestroyed ();
87
 
                        bezel_drawing_area.Destroy ();
88
 
                        bezel_drawing_area = null;
89
 
                        bezel_glass_results.Destroy ();
90
 
                        bezel_glass_results = null;
91
 
                }
92
 
 
93
 
                protected override bool OnButtonPressEvent (EventButton evnt)
94
 
                {
95
 
                        Gdk.Point global_point = new Gdk.Point ((int) evnt.XRoot, (int) evnt.YRoot);
96
 
                        Gdk.Point local_point = new Gdk.Point ((int) evnt.X, (int) evnt.Y);
97
 
                        
98
 
                        switch (bezel_drawing_area.GetPointLocation (local_point)) {
99
 
                        case PointLocation.Close:
100
 
                        case PointLocation.Outside:
101
 
                                controller.ButtonPressOffWindow ();
102
 
                                break;
103
 
                        case PointLocation.Preferences:
104
 
                                Services.Windowing.ShowMainMenu (global_point.X, global_point.Y);
105
 
                                // Have to re-grab the pane from the menu.
106
 
                                Interface.Windowing.PresentWindow (this);
107
 
                                break;
108
 
                        }
109
 
 
110
 
                        return base.OnButtonPressEvent (evnt);
111
 
                }
112
 
                
113
 
                protected override bool OnKeyPressEvent (EventKey evnt)
114
 
                {
115
 
                        KeyPressEvent (evnt);
116
 
 
117
 
                        return base.OnKeyPressEvent (evnt);
118
 
                }
119
 
                
120
 
                protected override bool OnExposeEvent (EventExpose evnt)
121
 
                {
122
 
                        if (IsDrawable) {
123
 
                                Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow);
124
 
                                cr.Operator = Cairo.Operator.Source;
125
 
                                cr.Paint ();
126
 
                                (cr as IDisposable).Dispose ();
127
 
                        }
128
 
                        return base.OnExposeEvent (evnt);
129
 
                }
130
 
 
131
 
                
132
 
                protected virtual void SetColormap ()
133
 
                {
134
 
                        Gdk.Colormap  colormap;
135
 
 
136
 
                        colormap = Screen.RgbaColormap;
137
 
                        if (colormap == null) {
138
 
                                colormap = Screen.RgbColormap;
139
 
                                Console.Error.WriteLine ("No alpha support.");
140
 
                        }
141
 
                        
142
 
                        Colormap = colormap;
143
 
                        colormap.Dispose ();
144
 
                }
145
 
 
146
 
                public void Summon ()
147
 
                {
148
 
                        int width, height;
149
 
                        GetSize (out width, out height);
150
 
                        
151
 
                        pw.UpdatePosition (0, Pane.First, new Gdk.Rectangle (((int)(bezel_drawing_area.WindowWidth-bezel_glass_results.WidthRequest)/2), -10, 0, 0));
152
 
                        Show ();
153
 
                        bezel_glass_window.Show ();
154
 
                        Interface.Windowing.PresentWindow (this);
155
 
                }
156
 
 
157
 
                public void Vanish ()
158
 
                {
159
 
                        Interface.Windowing.UnpresentWindow (this);
160
 
                        Hide ();
161
 
                        bezel_glass_window.Hide ();
162
 
                }
163
 
 
164
 
                public void Reset ()
165
 
                {
166
 
                        bezel_drawing_area.Clear ();
167
 
                        bezel_glass_results.Clear ();
168
 
                }
169
 
 
170
 
                public void Grow ()
171
 
                {
172
 
                        bezel_drawing_area.ThirdPaneVisible = true;
173
 
                }
174
 
 
175
 
                public void Shrink ()
176
 
                {
177
 
                        bezel_drawing_area.ThirdPaneVisible = false;
178
 
                }
179
 
 
180
 
                public void GrowResults ()
181
 
                {
182
 
                        bezel_glass_results.SlideIn ();
183
 
                }
184
 
 
185
 
                public void ShrinkResults ()
186
 
                {
187
 
                        bezel_glass_results.SlideOut ();
188
 
                }
189
 
 
190
 
                public void SetPaneContext (Pane pane, IUIContext context)
191
 
                {
192
 
                        // This prevents the odd situation of nothing drawing in the third pane.  Ultimately what has
193
 
                        // happened is the universe has "nulled" the pane by fluke.  We detect this and replace the
194
 
                        // query with an invisible space.
195
 
                        string query;
196
 
                        if (pane == Pane.Third && context.Selection == null && string.IsNullOrEmpty (context.Query) && !context.Results.Any ()) {
197
 
                                query = " ";
198
 
                        } else {
199
 
                                query = context.Query;
200
 
                        }
201
 
                        bezel_drawing_area.BezelSetPaneObject (pane, context.Selection);
202
 
                        bezel_drawing_area.BezelSetQuery      (pane, query);
203
 
                        bezel_drawing_area.BezelSetTextMode   (pane, context.LargeTextDisplay);
204
 
                        bezel_drawing_area.BezelSetEntryMode (pane, context.LargeTextModeType == TextModeType.Explicit);
205
 
                        
206
 
                        if (CurrentPane == pane) {
207
 
                                bezel_glass_results.Context = context;
208
 
                        }
209
 
                }
210
 
 
211
 
                public void ClearPane (Pane pane)
212
 
                {
213
 
                        bezel_drawing_area.BezelSetPaneObject (pane, null);
214
 
                        bezel_drawing_area.BezelSetQuery (pane, "");
215
 
                        bezel_drawing_area.BezelSetEntryMode (pane, false);
216
 
                        
217
 
                        if (pane == CurrentPane) {
218
 
                                bezel_glass_results.Clear ();
219
 
                        }
220
 
                }
221
 
 
222
 
                public bool ResultsCanHide { get { return true; } }
223
 
                
224
 
                public new event DoEventKeyDelegate KeyPressEvent;
225
 
        }
226
 
}