~ubuntu-branches/debian/sid/f-spot/sid

« back to all changes in this revision

Viewing changes to lib/Hyena/src/Hyena.Gui/Hyena.Gui/BaseWidgetAccessible.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2010-05-24 10:35:57 UTC
  • mfrom: (2.4.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20100524103557-1j0i8f66caybci2n
* New upstream release 0.7.0
 + First release of the unstable 0.7 development series. Massive changes.
 + Reparenting and detaching support (Anton Keks) (Closes: #559745)
 + A new Mallard-based documentation (Harold Schreckengost)
 + No longer embeds flickrnet, uses distribution copy (Iain Lane)
 + Adoption of a large amount of Hyena functionality (Paul Lange, Peter
   Goetz)
 + No longer embeds gnome-keyring-sharp
 + Completely rewritten import, much faster and less memory hungry (Ruben
   Vermeersch) (Closes: #559080, #492658, #341790, #357811, #426017) (LP:
   #412091)
 + No longer use gphoto2-sharp, now uses gvfs which is less crash-pron
   (Ruben Vermeersch)
 + Fix Facebook support (Ruben Vermeersch)
 + Modernized unit tests
 + Revamped build (Mike Gemünde)
 + Much improved duplicate detection (much faster too) (Ruben Vermeersch)
 + Mouse selection in Iconview (Vincent Pomey)
 + Image panning support using middle mouse button (Wojciech Dzierżanowski)
 + Timeline slider now restricted to the size of the window (Iain Churcher)
 + Over 100 bugs closed (http://bit.ly/cyVjnD)
   - No more warnings about schema defaults (Closes: #584215) (LP: #586132)
* debian/control: Clean up build deps to match configure checks
* debian/rules: Don't run dh_makeshilbs as we don't ship any shared
  libraries. There are some private ones though, which get picked up and
  result in a useless postinst/postrm call to ldconfig. Thanks, lintian.
* debian/patches/debian_fix-distclean.patch,
  debian/patches/debian_fix_f-spot.exe.config.patch,
  debian/patches/debian_link-system-flickrnet.patch,
  debian/patches/debian_link-system-gnome-keyring.patch,
  debian/patches/debian_disable-unit-tests,
  debian/patches/git_transition_duration.patch,
  debian/patches/ubuntu_fix_folder_export_hang.patch:
  Clean up obsolete patches which are no longer necessary 
* debian/patches/*: Temporarily disable patches which originated from Ubuntu
  and no longer apply cleanly. We will get these back in a future upstream
  development release.
* debian/patches/*: Refresh to apply cleanly 
* debian/rules: Add new include dir to autoreconf call to pick up f-spot
  macros 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// BaseWidgetAccessible.cs
 
3
//
 
4
// Author:
 
5
//   Gabriel Burt <gburt@novell.com>
 
6
//
 
7
// Copyright (C) 2009 Novell, Inc.
 
8
//
 
9
// Permission is hereby granted, free of charge, to any person obtaining
 
10
// a copy of this software and associated documentation files (the
 
11
// "Software"), to deal in the Software without restriction, including
 
12
// without limitation the rights to use, copy, modify, merge, publish,
 
13
// distribute, sublicense, and/or sell copies of the Software, and to
 
14
// permit persons to whom the Software is furnished to do so, subject to
 
15
// the following conditions:
 
16
//
 
17
// The above copyright notice and this permission notice shall be
 
18
// included in all copies or substantial portions of the Software.
 
19
//
 
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
//
 
28
 
 
29
using System;
 
30
using System.Linq;
 
31
using System.Collections.Generic;
 
32
 
 
33
using Atk;
 
34
 
 
35
namespace Hyena.Gui
 
36
{
 
37
#if ENABLE_ATK
 
38
    public class BaseWidgetAccessible : Gtk.Accessible, Atk.ComponentImplementor
 
39
    {
 
40
        private Gtk.Widget widget;
 
41
        private uint focus_id = 0;
 
42
        private Dictionary<uint, Atk.FocusHandler> focus_handlers = new Dictionary<uint, Atk.FocusHandler> ();
 
43
 
 
44
        public BaseWidgetAccessible (Gtk.Widget widget)
 
45
        {
 
46
            this.widget = widget;
 
47
            widget.SizeAllocated += OnAllocated;
 
48
            widget.Mapped += OnMap;
 
49
            widget.Unmapped += OnMap;
 
50
            widget.FocusInEvent += OnFocus;
 
51
            widget.FocusOutEvent += OnFocus;
 
52
            widget.AddNotification ("sensitive", (o, a) => NotifyStateChange (StateType.Sensitive, widget.Sensitive));
 
53
            widget.AddNotification ("visible",   (o, a) => NotifyStateChange (StateType.Visible, widget.Visible));
 
54
        }
 
55
 
 
56
        public virtual new Atk.Layer Layer {
 
57
            get { return Layer.Widget; }
 
58
        }
 
59
 
 
60
        protected override Atk.StateSet OnRefStateSet ()
 
61
        {
 
62
            var s = base.OnRefStateSet ();
 
63
 
 
64
            AddStateIf (s, widget.CanFocus,   StateType.Focusable);
 
65
            AddStateIf (s, widget.HasFocus,   StateType.Focused);
 
66
            AddStateIf (s, widget.Sensitive,  StateType.Sensitive);
 
67
            AddStateIf (s, widget.Sensitive,  StateType.Enabled);
 
68
            AddStateIf (s, widget.HasDefault, StateType.Default);
 
69
            AddStateIf (s, widget.Visible,    StateType.Visible);
 
70
            AddStateIf (s, widget.Visible && widget.IsMapped, StateType.Showing);
 
71
 
 
72
            return s;
 
73
        }
 
74
 
 
75
        private static void AddStateIf (StateSet s, bool condition, StateType t)
 
76
        {
 
77
            if (condition) {
 
78
                s.AddState (t);
 
79
            }
 
80
        }
 
81
 
 
82
        private void OnFocus (object o, EventArgs args)
 
83
        {
 
84
            NotifyStateChange (StateType.Focused, widget.HasFocus);
 
85
            var handler = FocusChanged;
 
86
            if (handler != null) {
 
87
                handler (this, widget.HasFocus);
 
88
            }
 
89
        }
 
90
 
 
91
        private void OnMap (object o, EventArgs args)
 
92
        {
 
93
            NotifyStateChange (StateType.Showing, widget.Visible && widget.IsMapped);
 
94
        }
 
95
 
 
96
        private void OnAllocated (object o, EventArgs args)
 
97
        {
 
98
            var a = widget.Allocation;
 
99
            var bounds = new Atk.Rectangle () { X = a.X, Y = a.Y, Width = a.Width, Height = a.Height };
 
100
            GLib.Signal.Emit (this, "bounds_changed", bounds);
 
101
            /*var handler = BoundsChanged;
 
102
            if (handler != null) {
 
103
                handler (this, new BoundsChangedArgs () { Args = new object [] { bounds } });
 
104
            }*/
 
105
        }
 
106
 
 
107
        private event FocusHandler FocusChanged;
 
108
 
 
109
        #region Atk.Component
 
110
 
 
111
        public uint AddFocusHandler (Atk.FocusHandler handler)
 
112
        {
 
113
            if (!focus_handlers.ContainsValue (handler)) {
 
114
                FocusChanged += handler;
 
115
                focus_handlers[++focus_id] = handler;
 
116
                return focus_id;
 
117
            }
 
118
            return 0;
 
119
        }
 
120
 
 
121
        public bool Contains (int x, int y, Atk.CoordType coordType)
 
122
        {
 
123
            int x_extents, y_extents, w, h;
 
124
            GetExtents (out x_extents, out y_extents, out w, out h, coordType);
 
125
            Gdk.Rectangle extents = new Gdk.Rectangle (x_extents, y_extents, w, h);
 
126
            return extents.Contains (x, y);
 
127
        }
 
128
 
 
129
        public virtual Atk.Object RefAccessibleAtPoint (int x, int y, Atk.CoordType coordType)
 
130
        {
 
131
            return new NoOpObject (widget);
 
132
        }
 
133
 
 
134
        public void GetExtents (out int x, out int y, out int w, out int h, Atk.CoordType coordType)
 
135
        {
 
136
            w = widget.Allocation.Width;
 
137
            h = widget.Allocation.Height;
 
138
 
 
139
            GetPosition (out x, out y, coordType);
 
140
        }
 
141
 
 
142
        public void GetPosition (out int x, out int y, Atk.CoordType coordType)
 
143
        {
 
144
            Gdk.Window window = null;
 
145
 
 
146
            if (!widget.IsDrawable) {
 
147
                x = y = Int32.MinValue;
 
148
                return;
 
149
            }
 
150
 
 
151
            if (widget.Parent != null) {
 
152
                x = widget.Allocation.X;
 
153
                y = widget.Allocation.Y;
 
154
                window = widget.ParentWindow;
 
155
            } else {
 
156
                x = 0;
 
157
                y = 0;
 
158
                window = widget.GdkWindow;
 
159
            }
 
160
 
 
161
            int x_window, y_window;
 
162
            window.GetOrigin (out x_window, out y_window);
 
163
            x += x_window;
 
164
            y += y_window;
 
165
 
 
166
            if (coordType == Atk.CoordType.Window) {
 
167
                window = widget.GdkWindow.Toplevel;
 
168
                int x_toplevel, y_toplevel;
 
169
                window.GetOrigin (out x_toplevel, out y_toplevel);
 
170
 
 
171
                x -= x_toplevel;
 
172
                y -= y_toplevel;
 
173
            }
 
174
        }
 
175
 
 
176
        public void GetSize (out int w, out int h)
 
177
        {
 
178
            w = widget.Allocation.Width;
 
179
            h = widget.Allocation.Height;
 
180
        }
 
181
 
 
182
        public bool GrabFocus ()
 
183
        {
 
184
            if (!widget.CanFocus) {
 
185
                return false;
 
186
            }
 
187
 
 
188
            widget.GrabFocus ();
 
189
 
 
190
            var toplevel_window = widget.Toplevel as Gtk.Window;
 
191
            if (toplevel_window != null) {
 
192
                toplevel_window.Present ();
 
193
            }
 
194
 
 
195
            return true;
 
196
        }
 
197
 
 
198
        public void RemoveFocusHandler (uint handlerId)
 
199
        {
 
200
            if (focus_handlers.ContainsKey (handlerId)) {
 
201
                FocusChanged -= focus_handlers[handlerId];
 
202
                focus_handlers.Remove (handlerId);
 
203
            }
 
204
        }
 
205
 
 
206
        public bool SetExtents (int x, int y, int w, int h, Atk.CoordType coordType)
 
207
        {
 
208
            return SetSizeAndPosition (x, y, w, h, coordType, true);
 
209
        }
 
210
 
 
211
        public bool SetPosition (int x, int y, Atk.CoordType coordType)
 
212
        {
 
213
            return SetSizeAndPosition (x, y, 0, 0, coordType, false);
 
214
        }
 
215
 
 
216
        private bool SetSizeAndPosition (int x, int y, int w, int h, Atk.CoordType coordType, bool setSize)
 
217
        {
 
218
            if (!widget.IsTopLevel) {
 
219
                return false;
 
220
            }
 
221
 
 
222
            if (coordType == CoordType.Window) {
 
223
                int x_off, y_off;
 
224
                widget.GdkWindow.GetOrigin (out x_off, out y_off);
 
225
                x += x_off;
 
226
                y += y_off;
 
227
 
 
228
                if (x < 0 || y < 0) {
 
229
                    return false;
 
230
                }
 
231
            }
 
232
 
 
233
            #pragma warning disable 0612
 
234
            widget.SetUposition (x, y);
 
235
            #pragma warning restore 0612
 
236
 
 
237
            if (setSize) {
 
238
                widget.SetSizeRequest (w, h);
 
239
            }
 
240
 
 
241
            return true;
 
242
        }
 
243
 
 
244
        public bool SetSize (int w, int h)
 
245
        {
 
246
            if (widget.IsTopLevel) {
 
247
                widget.SetSizeRequest (w, h);
 
248
                return true;
 
249
            } else {
 
250
                return false;
 
251
            }
 
252
        }
 
253
 
 
254
        public double Alpha {
 
255
            get { return 1.0; }
 
256
        }
 
257
 
 
258
        #endregion Atk.Component
 
259
 
 
260
    }
 
261
#endif
 
262
}