Merge lp:~cszikszoy/docky/mmv3 into lp:docky

Proposed by Chris S.
Status: Merged
Merged at revision: not available
Proposed branch: lp:~cszikszoy/docky/mmv3
Merge into: lp:docky
Diff against target: 301 lines
6 files modified
Docky/Docky/ConfigurationWindow.cs (+22/-0)
Docky/Docky/DockController.cs (+66/-5)
Docky/Docky/Interface/DockPreferences.cs (+25/-14)
Docky/Docky/Interface/DockWindow.cs (+1/-1)
Docky/Docky/Interface/IDockPreferences.cs (+2/-0)
Docky/gtk-gui/gui.stetic (+1/-4)
To merge this branch: bzr merge lp:~cszikszoy/docky/mmv3
Reviewer Review Type Date Requested Status
Docky Core Pending
Review via email: mp+14290@code.launchpad.net
To post a comment you must log in.
lp:~cszikszoy/docky/mmv3 updated
378. By Chris S.

simplify CheckButtons code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Docky/Docky/ConfigurationWindow.cs'
2--- Docky/Docky/ConfigurationWindow.cs 2009-10-31 06:57:19 +0000
3+++ Docky/Docky/ConfigurationWindow.cs 2009-11-01 21:05:19 +0000
4@@ -151,11 +151,15 @@
5
6 protected virtual void OnDeleteDockButtonClicked (object sender, System.EventArgs e)
7 {
8+ if (!(Docky.Controller.Docks.Count () > 1))
9+ return;
10+
11 if (ActiveDock != null) {
12 Docky.Controller.DeleteDock (ActiveDock);
13 ActiveDock = null;
14 SetupConfigAlignment ();
15 }
16+ CheckButtons ();
17 }
18
19 protected virtual void OnNewDockButtonClicked (object sender, System.EventArgs e)
20@@ -168,6 +172,24 @@
21 ActiveDock = newDock;
22 SetupConfigAlignment ();
23 }
24+ CheckButtons ();
25+ }
26+
27+ void CheckButtons ()
28+ {
29+ new_dock_button.Sensitive = true;
30+ delete_dock_button.Sensitive = true;
31+ if (Docky.Controller.Docks.Count () == 1) {
32+ delete_dock_button.Sensitive = false;
33+ new_dock_button.Sensitive = true;
34+ }
35+ int spotsAvailable = 0;
36+ for (int i = 0; i < Screen.Default.NMonitors; i++)
37+ spotsAvailable += Docky.Controller.PositionsAvailableForDock (i).Count ();
38+ if (spotsAvailable == 0) {
39+ delete_dock_button.Sensitive = true;
40+ new_dock_button.Sensitive = false;
41+ }
42 }
43
44 string AutoStartDir {
45
46=== modified file 'Docky/Docky/DockController.cs'
47--- Docky/Docky/DockController.cs 2009-10-31 16:05:10 +0000
48+++ Docky/Docky/DockController.cs 2009-11-01 21:05:19 +0000
49@@ -31,7 +31,13 @@
50
51 namespace Docky
52 {
53-
54+
55+ class DockMonitor
56+ {
57+ public Rectangle Geo { get; set; }
58+ public int MonitorNumber { get; set; }
59+ public IEnumerable<DockPosition> PossiblePositions { get; set; }
60+ }
61
62 internal class DockController : IDisposable
63 {
64@@ -50,6 +56,21 @@
65 get { return DockNames.Count (); }
66 }
67
68+ List<DockMonitor> DockMonitors { get; set; }
69+
70+ public IEnumerable<DockPosition> PositionsAvailableForDock (int monitorNum)
71+ {
72+ foreach (DockPosition position in DockMonitors.Where (d => d.MonitorNumber == monitorNum).First ().PossiblePositions) {
73+ if (!DocksForMonitor (monitorNum).Any (dock => dock.Preferences.Position == position))
74+ yield return position;
75+ }
76+ }
77+
78+ public IEnumerable<Dock> DocksForMonitor (int monitorNumber)
79+ {
80+ return docks.Where (d => d.Preferences.MonitorNumber == monitorNumber);
81+ }
82+
83 IEnumerable<string> ThemeContainerFolders {
84 get {
85 yield return Path.Combine (DockServices.System.SystemDataFolder, "themes");
86@@ -111,6 +132,7 @@
87 {
88 docks = new List<Dock> ();
89 prefs = DockServices.Preferences.Get<DockController> ();
90+ DetectMonitors ();
91 CreateDocks ();
92
93 GLib.Timeout.Add (500, delegate {
94@@ -119,6 +141,41 @@
95 });
96 }
97
98+ void DetectMonitors ()
99+ {
100+ DockMonitors = new List<DockMonitor> ();
101+
102+ // first add all of the screens and their geometries
103+ for (int i = 0; i < Screen.Default.NMonitors; i++) {
104+ DockMonitor mon = new DockMonitor ();
105+ mon.MonitorNumber = i;
106+ mon.Geo = Screen.Default.GetMonitorGeometry (i);
107+ DockMonitors.Add (mon);
108+ }
109+
110+ int topDockVal = DockMonitors.OrderBy (d => d.Geo.Top).First ().Geo.Top;
111+ int bottomDockVal = DockMonitors.OrderByDescending (d => d.Geo.Bottom).First ().Geo.Bottom;
112+ int leftDockVal = DockMonitors.OrderBy (d => d.Geo.Left).First ().Geo.Left;
113+ int rightDockVal = DockMonitors.OrderByDescending (d => d.Geo.Right).First ().Geo.Right;
114+
115+ // now build the list of available positions for a given screen.
116+ for (int i = 0; i < DockMonitors.Count (); i++) {
117+ List<DockPosition> positions = new List<DockPosition> ();
118+ DockMonitor mon = DockMonitors.Where (d => d.MonitorNumber == i).First ();
119+
120+ if (mon.Geo.Left == leftDockVal)
121+ positions.Add (DockPosition.Left);
122+ if (mon.Geo.Right == rightDockVal)
123+ positions.Add (DockPosition.Right);
124+ if (mon.Geo.Top == topDockVal)
125+ positions.Add (DockPosition.Top);
126+ if (mon.Geo.Bottom == bottomDockVal)
127+ positions.Add (DockPosition.Bottom);
128+
129+ mon.PossiblePositions = positions;
130+ }
131+ }
132+
133 string FolderForTheme (string theme)
134 {
135 foreach (string dir in ThemeContainerFolders) {
136@@ -146,8 +203,13 @@
137
138 public Dock CreateDock ()
139 {
140- if (docks.Count >= 4)
141- return null;
142+ int mon;
143+ for (mon = 0; mon < Screen.Default.NMonitors; mon++) {
144+ if (PositionsAvailableForDock (mon).Any ())
145+ break;
146+ if (mon == Screen.Default.NMonitors - 1)
147+ return null;
148+ }
149
150 string name = "Dock" + 1;
151 for (int i = 2; DockNames.Contains (name); i++)
152@@ -155,7 +217,7 @@
153
154 DockNames = DockNames.Concat (new [] { name });
155
156- DockPreferences dockPrefs = new DockPreferences (name);
157+ DockPreferences dockPrefs = new DockPreferences (name, mon);
158 Dock dock = new Dock (dockPrefs);
159 docks.Add (dock);
160
161@@ -172,7 +234,6 @@
162 dock.Dispose ();
163 DockNames = DockNames.Where (s => s != dock.Preferences.GetName ());
164
165- EnsurePluginState ();
166 return true;
167 }
168
169
170=== modified file 'Docky/Docky/Interface/DockPreferences.cs'
171--- Docky/Docky/Interface/DockPreferences.cs 2009-10-31 16:05:10 +0000
172+++ Docky/Docky/Interface/DockPreferences.cs 2009-11-01 21:05:19 +0000
173@@ -128,13 +128,9 @@
174 set {
175 if (position == value)
176 return;
177- Dock other_dock = null;
178- if (Docky.Controller.Docks.Any (d => d.Preferences.Position == value))
179- other_dock = Docky.Controller.Docks.Where (d => d.Preferences.Position == value).First();
180- DockPosition old_position = position;
181 position = value;
182- if (other_dock != null)
183- other_dock.Preferences.Position = old_position;
184+ if (!Docky.Controller.PositionsAvailableForDock (MonitorNumber).Contains (value))
185+ position = Docky.Controller.PositionsAvailableForDock (MonitorNumber).First ();
186 SetOption<string> ("Position", position.ToString ());
187 OnPositionChanged ();
188 }
189@@ -195,7 +191,7 @@
190 get {
191 if (!zoom_percent.HasValue)
192 zoom_percent = GetOption<double?> ("ZoomPercent", 2.0);
193- return zoom_percent.Value;
194+ return zoom_percent.Value;
195 }
196 set {
197 value = Clamp (value, 4, 1);
198@@ -207,6 +203,21 @@
199 OnZoomPercentChanged ();
200 }
201 }
202+
203+ int? monitor_number;
204+ public int MonitorNumber {
205+ get {
206+ if (!monitor_number.HasValue)
207+ monitor_number = GetOption<int?> ("MonitorNumber", 0);
208+ return monitor_number.Value;
209+ }
210+ set {
211+ if (monitor_number == value)
212+ return;
213+ monitor_number = value;
214+ SetOption<int?> ("MonitorNumber", monitor_number.Value);
215+ }
216+ }
217 #endregion
218
219 bool? window_manager;
220@@ -248,8 +259,15 @@
221 set { prefs.Set<bool> ("FirstRun", value); }
222 }
223
224+ public DockPreferences (string dockName, int monitorNumber) : this(dockName)
225+ {
226+ MonitorNumber = monitorNumber;
227+ }
228+
229 public DockPreferences (string dockName)
230 {
231+ prefs = DockServices.Preferences.Get<DockPreferences> ();
232+
233 // ensures position actually gets set
234 position = (DockPosition) 100;
235
236@@ -264,8 +282,6 @@
237
238 name = dockName;
239
240- prefs = DockServices.Preferences.Get<DockPreferences> ();
241-
242 BuildItemProviders ();
243 BuildOptions ();
244
245@@ -435,13 +451,8 @@
246 DockPosition position = (DockPosition) Enum.Parse (typeof(DockPosition),
247 GetOption ("Position", DockPosition.Bottom.ToString ()));
248
249- while (Docky.Controller.Docks.Any ((Dock d) => d.Preferences.Position == position)) {
250- Log<DockPreferences>.Error ("Dock position already in use: " + position.ToString ());
251- position = (DockPosition) ((((int) position) + 1) % 4);
252- }
253 Position = position;
254
255-
256 if (WindowManager)
257 DefaultProvider.SetWindowManager ();
258
259
260=== modified file 'Docky/Docky/Interface/DockWindow.cs'
261--- Docky/Docky/Interface/DockWindow.cs 2009-11-01 21:03:51 +0000
262+++ Docky/Docky/Interface/DockWindow.cs 2009-11-01 21:05:20 +0000
263@@ -344,7 +344,7 @@
264
265 //fixme
266 int Monitor {
267- get { return 0; }
268+ get { return Preferences.MonitorNumber; }
269 }
270
271 internal DockPosition Position {
272
273=== modified file 'Docky/Docky/Interface/IDockPreferences.cs'
274--- Docky/Docky/Interface/IDockPreferences.cs 2009-10-31 03:57:40 +0000
275+++ Docky/Docky/Interface/IDockPreferences.cs 2009-11-01 21:05:20 +0000
276@@ -62,6 +62,8 @@
277
278 double ZoomPercent { get; set; }
279
280+ int MonitorNumber { get; set; }
281+
282 bool SetName (string name);
283
284 string GetName ();
285
286=== modified file 'Docky/gtk-gui/gui.stetic'
287--- Docky/gtk-gui/gui.stetic 2009-10-31 06:37:25 +0000
288+++ Docky/gtk-gui/gui.stetic 2009-11-01 21:05:20 +0000
289@@ -7,11 +7,8 @@
290 <import>
291 <widget-library name="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
292 <widget-library name="wnck-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
293- <widget-library name="../../Docky.Services/bin/Debug/Docky.Services.dll" />
294- <widget-library name="../../Docky.Items/bin/Debug/Docky.Items.dll" />
295- <widget-library name="../../Docky.Windowing/bin/Debug/Docky.Windowing.dll" />
296+ <widget-library name="gnomedesktop-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
297 <widget-library name="../bin/Debug/Docky.exe" internal="true" />
298- <widget-library name="gnomedesktop-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
299 </import>
300 <widget class="Gtk.Bin" id="Docky.Interface.DockPreferences" design-size="368 331">
301 <property name="MemberName" />

Subscribers

People subscribed via source and target branches

to status/vote changes: