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
=== modified file 'Docky/Docky/ConfigurationWindow.cs'
--- Docky/Docky/ConfigurationWindow.cs 2009-10-31 06:57:19 +0000
+++ Docky/Docky/ConfigurationWindow.cs 2009-11-01 21:05:19 +0000
@@ -151,11 +151,15 @@
151 151
152 protected virtual void OnDeleteDockButtonClicked (object sender, System.EventArgs e)152 protected virtual void OnDeleteDockButtonClicked (object sender, System.EventArgs e)
153 {153 {
154 if (!(Docky.Controller.Docks.Count () > 1))
155 return;
156
154 if (ActiveDock != null) {157 if (ActiveDock != null) {
155 Docky.Controller.DeleteDock (ActiveDock);158 Docky.Controller.DeleteDock (ActiveDock);
156 ActiveDock = null;159 ActiveDock = null;
157 SetupConfigAlignment ();160 SetupConfigAlignment ();
158 }161 }
162 CheckButtons ();
159 }163 }
160 164
161 protected virtual void OnNewDockButtonClicked (object sender, System.EventArgs e)165 protected virtual void OnNewDockButtonClicked (object sender, System.EventArgs e)
@@ -168,6 +172,24 @@
168 ActiveDock = newDock;172 ActiveDock = newDock;
169 SetupConfigAlignment ();173 SetupConfigAlignment ();
170 }174 }
175 CheckButtons ();
176 }
177
178 void CheckButtons ()
179 {
180 new_dock_button.Sensitive = true;
181 delete_dock_button.Sensitive = true;
182 if (Docky.Controller.Docks.Count () == 1) {
183 delete_dock_button.Sensitive = false;
184 new_dock_button.Sensitive = true;
185 }
186 int spotsAvailable = 0;
187 for (int i = 0; i < Screen.Default.NMonitors; i++)
188 spotsAvailable += Docky.Controller.PositionsAvailableForDock (i).Count ();
189 if (spotsAvailable == 0) {
190 delete_dock_button.Sensitive = true;
191 new_dock_button.Sensitive = false;
192 }
171 }193 }
172194
173 string AutoStartDir {195 string AutoStartDir {
174196
=== modified file 'Docky/Docky/DockController.cs'
--- Docky/Docky/DockController.cs 2009-10-31 16:05:10 +0000
+++ Docky/Docky/DockController.cs 2009-11-01 21:05:19 +0000
@@ -31,7 +31,13 @@
3131
32namespace Docky32namespace Docky
33{33{
3434
35 class DockMonitor
36 {
37 public Rectangle Geo { get; set; }
38 public int MonitorNumber { get; set; }
39 public IEnumerable<DockPosition> PossiblePositions { get; set; }
40 }
3541
36 internal class DockController : IDisposable42 internal class DockController : IDisposable
37 {43 {
@@ -50,6 +56,21 @@
50 get { return DockNames.Count (); }56 get { return DockNames.Count (); }
51 }57 }
52 58
59 List<DockMonitor> DockMonitors { get; set; }
60
61 public IEnumerable<DockPosition> PositionsAvailableForDock (int monitorNum)
62 {
63 foreach (DockPosition position in DockMonitors.Where (d => d.MonitorNumber == monitorNum).First ().PossiblePositions) {
64 if (!DocksForMonitor (monitorNum).Any (dock => dock.Preferences.Position == position))
65 yield return position;
66 }
67 }
68
69 public IEnumerable<Dock> DocksForMonitor (int monitorNumber)
70 {
71 return docks.Where (d => d.Preferences.MonitorNumber == monitorNumber);
72 }
73
53 IEnumerable<string> ThemeContainerFolders {74 IEnumerable<string> ThemeContainerFolders {
54 get {75 get {
55 yield return Path.Combine (DockServices.System.SystemDataFolder, "themes");76 yield return Path.Combine (DockServices.System.SystemDataFolder, "themes");
@@ -111,6 +132,7 @@
111 {132 {
112 docks = new List<Dock> ();133 docks = new List<Dock> ();
113 prefs = DockServices.Preferences.Get<DockController> ();134 prefs = DockServices.Preferences.Get<DockController> ();
135 DetectMonitors ();
114 CreateDocks ();136 CreateDocks ();
115 137
116 GLib.Timeout.Add (500, delegate {138 GLib.Timeout.Add (500, delegate {
@@ -119,6 +141,41 @@
119 });141 });
120 }142 }
121 143
144 void DetectMonitors ()
145 {
146 DockMonitors = new List<DockMonitor> ();
147
148 // first add all of the screens and their geometries
149 for (int i = 0; i < Screen.Default.NMonitors; i++) {
150 DockMonitor mon = new DockMonitor ();
151 mon.MonitorNumber = i;
152 mon.Geo = Screen.Default.GetMonitorGeometry (i);
153 DockMonitors.Add (mon);
154 }
155
156 int topDockVal = DockMonitors.OrderBy (d => d.Geo.Top).First ().Geo.Top;
157 int bottomDockVal = DockMonitors.OrderByDescending (d => d.Geo.Bottom).First ().Geo.Bottom;
158 int leftDockVal = DockMonitors.OrderBy (d => d.Geo.Left).First ().Geo.Left;
159 int rightDockVal = DockMonitors.OrderByDescending (d => d.Geo.Right).First ().Geo.Right;
160
161 // now build the list of available positions for a given screen.
162 for (int i = 0; i < DockMonitors.Count (); i++) {
163 List<DockPosition> positions = new List<DockPosition> ();
164 DockMonitor mon = DockMonitors.Where (d => d.MonitorNumber == i).First ();
165
166 if (mon.Geo.Left == leftDockVal)
167 positions.Add (DockPosition.Left);
168 if (mon.Geo.Right == rightDockVal)
169 positions.Add (DockPosition.Right);
170 if (mon.Geo.Top == topDockVal)
171 positions.Add (DockPosition.Top);
172 if (mon.Geo.Bottom == bottomDockVal)
173 positions.Add (DockPosition.Bottom);
174
175 mon.PossiblePositions = positions;
176 }
177 }
178
122 string FolderForTheme (string theme)179 string FolderForTheme (string theme)
123 {180 {
124 foreach (string dir in ThemeContainerFolders) {181 foreach (string dir in ThemeContainerFolders) {
@@ -146,8 +203,13 @@
146 203
147 public Dock CreateDock ()204 public Dock CreateDock ()
148 {205 {
149 if (docks.Count >= 4)206 int mon;
150 return null;207 for (mon = 0; mon < Screen.Default.NMonitors; mon++) {
208 if (PositionsAvailableForDock (mon).Any ())
209 break;
210 if (mon == Screen.Default.NMonitors - 1)
211 return null;
212 }
151 213
152 string name = "Dock" + 1;214 string name = "Dock" + 1;
153 for (int i = 2; DockNames.Contains (name); i++)215 for (int i = 2; DockNames.Contains (name); i++)
@@ -155,7 +217,7 @@
155 217
156 DockNames = DockNames.Concat (new [] { name });218 DockNames = DockNames.Concat (new [] { name });
157 219
158 DockPreferences dockPrefs = new DockPreferences (name);220 DockPreferences dockPrefs = new DockPreferences (name, mon);
159 Dock dock = new Dock (dockPrefs);221 Dock dock = new Dock (dockPrefs);
160 docks.Add (dock);222 docks.Add (dock);
161 223
@@ -172,7 +234,6 @@
172 dock.Dispose ();234 dock.Dispose ();
173 DockNames = DockNames.Where (s => s != dock.Preferences.GetName ());235 DockNames = DockNames.Where (s => s != dock.Preferences.GetName ());
174 236
175 EnsurePluginState ();
176 return true;237 return true;
177 }238 }
178 239
179240
=== modified file 'Docky/Docky/Interface/DockPreferences.cs'
--- Docky/Docky/Interface/DockPreferences.cs 2009-10-31 16:05:10 +0000
+++ Docky/Docky/Interface/DockPreferences.cs 2009-11-01 21:05:19 +0000
@@ -128,13 +128,9 @@
128 set {128 set {
129 if (position == value)129 if (position == value)
130 return;130 return;
131 Dock other_dock = null;
132 if (Docky.Controller.Docks.Any (d => d.Preferences.Position == value))
133 other_dock = Docky.Controller.Docks.Where (d => d.Preferences.Position == value).First();
134 DockPosition old_position = position;
135 position = value;131 position = value;
136 if (other_dock != null)132 if (!Docky.Controller.PositionsAvailableForDock (MonitorNumber).Contains (value))
137 other_dock.Preferences.Position = old_position;133 position = Docky.Controller.PositionsAvailableForDock (MonitorNumber).First ();
138 SetOption<string> ("Position", position.ToString ());134 SetOption<string> ("Position", position.ToString ());
139 OnPositionChanged ();135 OnPositionChanged ();
140 }136 }
@@ -195,7 +191,7 @@
195 get {191 get {
196 if (!zoom_percent.HasValue)192 if (!zoom_percent.HasValue)
197 zoom_percent = GetOption<double?> ("ZoomPercent", 2.0);193 zoom_percent = GetOption<double?> ("ZoomPercent", 2.0);
198 return zoom_percent.Value; 194 return zoom_percent.Value;
199 }195 }
200 set {196 set {
201 value = Clamp (value, 4, 1);197 value = Clamp (value, 4, 1);
@@ -207,6 +203,21 @@
207 OnZoomPercentChanged ();203 OnZoomPercentChanged ();
208 }204 }
209 }205 }
206
207 int? monitor_number;
208 public int MonitorNumber {
209 get {
210 if (!monitor_number.HasValue)
211 monitor_number = GetOption<int?> ("MonitorNumber", 0);
212 return monitor_number.Value;
213 }
214 set {
215 if (monitor_number == value)
216 return;
217 monitor_number = value;
218 SetOption<int?> ("MonitorNumber", monitor_number.Value);
219 }
220 }
210 #endregion221 #endregion
211 222
212 bool? window_manager;223 bool? window_manager;
@@ -248,8 +259,15 @@
248 set { prefs.Set<bool> ("FirstRun", value); }259 set { prefs.Set<bool> ("FirstRun", value); }
249 }260 }
250 261
262 public DockPreferences (string dockName, int monitorNumber) : this(dockName)
263 {
264 MonitorNumber = monitorNumber;
265 }
266
251 public DockPreferences (string dockName)267 public DockPreferences (string dockName)
252 {268 {
269 prefs = DockServices.Preferences.Get<DockPreferences> ();
270
253 // ensures position actually gets set271 // ensures position actually gets set
254 position = (DockPosition) 100;272 position = (DockPosition) 100;
255 273
@@ -264,8 +282,6 @@
264 282
265 name = dockName;283 name = dockName;
266 284
267 prefs = DockServices.Preferences.Get<DockPreferences> ();
268
269 BuildItemProviders ();285 BuildItemProviders ();
270 BuildOptions ();286 BuildOptions ();
271 287
@@ -435,13 +451,8 @@
435 DockPosition position = (DockPosition) Enum.Parse (typeof(DockPosition), 451 DockPosition position = (DockPosition) Enum.Parse (typeof(DockPosition),
436 GetOption ("Position", DockPosition.Bottom.ToString ()));452 GetOption ("Position", DockPosition.Bottom.ToString ()));
437 453
438 while (Docky.Controller.Docks.Any ((Dock d) => d.Preferences.Position == position)) {
439 Log<DockPreferences>.Error ("Dock position already in use: " + position.ToString ());
440 position = (DockPosition) ((((int) position) + 1) % 4);
441 }
442 Position = position;454 Position = position;
443 455
444
445 if (WindowManager)456 if (WindowManager)
446 DefaultProvider.SetWindowManager ();457 DefaultProvider.SetWindowManager ();
447 458
448459
=== modified file 'Docky/Docky/Interface/DockWindow.cs'
--- Docky/Docky/Interface/DockWindow.cs 2009-11-01 21:03:51 +0000
+++ Docky/Docky/Interface/DockWindow.cs 2009-11-01 21:05:20 +0000
@@ -344,7 +344,7 @@
344 344
345 //fixme345 //fixme
346 int Monitor {346 int Monitor {
347 get { return 0; }347 get { return Preferences.MonitorNumber; }
348 }348 }
349 349
350 internal DockPosition Position {350 internal DockPosition Position {
351351
=== modified file 'Docky/Docky/Interface/IDockPreferences.cs'
--- Docky/Docky/Interface/IDockPreferences.cs 2009-10-31 03:57:40 +0000
+++ Docky/Docky/Interface/IDockPreferences.cs 2009-11-01 21:05:20 +0000
@@ -62,6 +62,8 @@
62 62
63 double ZoomPercent { get; set; }63 double ZoomPercent { get; set; }
64 64
65 int MonitorNumber { get; set; }
66
65 bool SetName (string name);67 bool SetName (string name);
66 68
67 string GetName ();69 string GetName ();
6870
=== modified file 'Docky/gtk-gui/gui.stetic'
--- Docky/gtk-gui/gui.stetic 2009-10-31 06:37:25 +0000
+++ Docky/gtk-gui/gui.stetic 2009-11-01 21:05:20 +0000
@@ -7,11 +7,8 @@
7 <import>7 <import>
8 <widget-library name="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />8 <widget-library name="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
9 <widget-library name="wnck-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />9 <widget-library name="wnck-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
10 <widget-library name="../../Docky.Services/bin/Debug/Docky.Services.dll" />10 <widget-library name="gnomedesktop-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
11 <widget-library name="../../Docky.Items/bin/Debug/Docky.Items.dll" />
12 <widget-library name="../../Docky.Windowing/bin/Debug/Docky.Windowing.dll" />
13 <widget-library name="../bin/Debug/Docky.exe" internal="true" />11 <widget-library name="../bin/Debug/Docky.exe" internal="true" />
14 <widget-library name="gnomedesktop-sharp, Version=2.20.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
15 </import>12 </import>
16 <widget class="Gtk.Bin" id="Docky.Interface.DockPreferences" design-size="368 331">13 <widget class="Gtk.Bin" id="Docky.Interface.DockPreferences" design-size="368 331">
17 <property name="MemberName" />14 <property name="MemberName" />

Subscribers

People subscribed via source and target branches

to status/vote changes: