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

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.UI/PositionWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-04-14 21:36:12 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080414213612-h0dfxdodm6vpcc1h
Tags: upstream-0.4.2.0
ImportĀ upstreamĀ versionĀ 0.4.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// PositionWindow.cs
 
2
//
 
3
//GNOME Do is the legal property of its developers. Please refer to the
 
4
//COPYRIGHT file distributed with this
 
5
//source distribution.
 
6
//
 
7
// This program is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// This program is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
// GNU General Public License for more details.
 
16
// 
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with this program; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
20
//
 
21
//
 
22
 
 
23
using System;
 
24
using Gdk;
 
25
using Gtk;
 
26
 
 
27
namespace Do.UI
 
28
{
 
29
        
 
30
        
 
31
        public class PositionWindow
 
32
        {
 
33
                private int monitor;
 
34
                private Gtk.Window w, r;
 
35
                
 
36
                public PositionWindow (Gtk.Window main, Gtk.Window results) {
 
37
                        this.w = main;
 
38
                        this.r = results;
 
39
                        
 
40
                        Rectangle point;
 
41
                        Display disp = w.Screen.Display;
 
42
                        disp.GetPointer(out point.X, out point.Y);
 
43
                        
 
44
                        monitor = w.Screen.GetMonitorAtPoint (point.X, point.Y);
 
45
                }
 
46
                
 
47
                public void UpdatePosition (int iconboxWidth, Pane currentPane, 
 
48
                                            Rectangle resultsOffset) {
 
49
                        Gdk.Rectangle geo, main, results;
 
50
                        
 
51
                        w.GetPosition (out main.X, out main.Y);
 
52
                        w.GetSize (out main.Width, out main.Height);
 
53
                        
 
54
                        //only change monitors if we are currently not showing the window
 
55
                        if (!w.Visible) {
 
56
                                GetMonitor ();
 
57
                        }
 
58
 
 
59
                        geo = w.Screen.GetMonitorGeometry (monitor);
 
60
                        main.X = ((geo.Width - main.Width) / 2) + geo.X;
 
61
                        main.Y = (int)((geo.Height + geo.Y - main.Height) / 2.5) + geo.Y;
 
62
                        w.Move (main.X, main.Y);
 
63
                        
 
64
                        //position resultsWindow
 
65
                        r.GetSize (out results.Width, out results.Height);
 
66
                        results.Y = main.Y + main.Height + resultsOffset.Y;
 
67
                        results.X = main.X + iconboxWidth * (int) currentPane + 
 
68
                                resultsOffset.X;
 
69
                        r.Move (results.X, results.Y);
 
70
                        
 
71
                        //uncomment here to get debug output
 
72
                        //Console.WriteLine ("Repostion Started For Montior {0}:", monitor);
 
73
                        //Console.WriteLine ("Geo: Width-{0}, Height-{1}, X-{2}, Y-{3}",geo.Width, geo.Height, geo.X, geo.Y);
 
74
                        //Console.WriteLine ("Main: Width-{0}, Height-{1}, X-{2}, Y-{3}",main.Width, main.Height, main.X, main.Y);
 
75
                }
 
76
                
 
77
                public bool GetMonitor () {
 
78
                        Rectangle point;
 
79
                        int tmp;
 
80
                        tmp = monitor;
 
81
                        
 
82
                        Display disp = w.Screen.Display;
 
83
                        disp.GetPointer(out point.X, out point.Y);
 
84
                        
 
85
                        monitor = w.Screen.GetMonitorAtPoint (point.X, point.Y);
 
86
                        
 
87
                        if (tmp == monitor)
 
88
                                return false;
 
89
                        else
 
90
                                return true;
 
91
                }
 
92
        }
 
93
}