Merge lp://qastaging/~jassmith/do-plugins/glitch-free-docky into lp://qastaging/do-plugins

Proposed by Jason Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~jassmith/do-plugins/glitch-free-docky
Merge into: lp://qastaging/do-plugins
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~jassmith/do-plugins/glitch-free-docky
Reviewer Review Type Date Requested Status
Alex Launi (community) Approve
Review via email: mp+5091@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

IWindowInterface has one member, an IEnumerable of windows, this doesn't make any sense, why would a window have multiple windows as it member? Should that be IApplication or something?

a couple of your classes have the constructor at the bottom, while there's nothing wrong with this, it's kind of annoying. You don't have to fix it, I just wanted to let you know.

DoModifyGeometry.cs fix the order of your using statements to be either by length or lexicographically. Also, do you need the Do prefix?
You do a bunch of
     mask = mask | WindowMoveResizeMask.Width;
you know you can do
     mask |= WindowMoveResizeMask.Width;
which is a bit more consise.

The fix using statement order is true for a couple of files.

Can you call the ScreenActionAction class something like AbstractScreenAction? Makes a bit more sense.

yield the SupportedItemType rather than create and return an array

In ScreenCascadeAction.cs, I see you just use the first item. Is there any reason this can't be done across multiple screens?

the ScreenItemSource description doesnt make any sense, an ItemSource doesn't contain actions

same deal with yielding instead of returning an array

you either dont need the square variable, or the width variable in ScreenTileAction.cs. When you assign width = square, you never use square again. Just call square width, or use square.

Can you rename WindowActionAction.cs to AbstractWindowAction?
again, use yields

WindowMoveAction.cs, use yields

and anywhere else i missed, use yields!

review: Approve
593. By Jason Smith

doomed constructors are doomed

594. By Jason Smith

use yield

595. By Jason Smith

Move tile code into core

596. By Jason Smith

Add show desktop action

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DoPlugins.mds'
2--- DoPlugins.mds 2009-03-10 22:25:02 +0000
3+++ DoPlugins.mds 2009-03-29 17:55:48 +0000
4@@ -1,5 +1,4 @@
5-<Combine name="DoPlugins" fileversion="2.0" outputpath="build/bin/" releaseversion="0.4.9.9">
6- <Policies />
7+<Combine fileversion="2.0" outputpath="build/bin/" name="DoPlugins" releaseversion="0.4.9.9">
8 <Configurations active="Debug">
9 <Configuration name="Debug" ctype="CombineConfiguration">
10 <Entry build="True" name="Rhythmbox" configuration="Debug" />
11@@ -291,4 +290,4 @@
12 <Entry filename="YouTube/YouTube.mdp" />
13 <Entry filename="Emesene/Emesene.mdp" />
14 </Entries>
15-</Combine>
16+</Combine>
17\ No newline at end of file
18
19=== modified file 'RSS/gtk-gui/gui.stetic'
20--- RSS/gtk-gui/gui.stetic 2009-01-22 03:46:13 +0000
21+++ RSS/gtk-gui/gui.stetic 2009-03-29 17:55:48 +0000
22@@ -2,8 +2,12 @@
23 <stetic-interface>
24 <configuration>
25 <images-root-path>..</images-root-path>
26- <target-gtk-version>2.12.1</target-gtk-version>
27+ <target-gtk-version>2.12</target-gtk-version>
28 </configuration>
29+ <import>
30+ <widget-library name="Do.Platform.Linux, Version=0.9.0.0, Culture=neutral" />
31+ <widget-library name="../bin/Debug/RSS.dll" internal="true" />
32+ </import>
33 <widget class="Gtk.Bin" id="Do.Plugins.Rss.Configuration" design-size="410 300">
34 <property name="MemberName" />
35 <child>
36
37=== modified file 'RememberTheMilk/RTM.mdp'
38--- RememberTheMilk/RTM.mdp 2009-03-18 14:24:24 +0000
39+++ RememberTheMilk/RTM.mdp 2009-03-29 17:55:48 +0000
40@@ -100,4 +100,4 @@
41 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" />
42 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform.Linux, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" />
43 </References>
44-</Project>
45+</Project>
46\ No newline at end of file
47
48=== modified file 'RequestTracker/RequestTracker.mdp'
49--- RequestTracker/RequestTracker.mdp 2009-03-11 10:31:38 +0000
50+++ RequestTracker/RequestTracker.mdp 2009-03-29 17:55:48 +0000
51@@ -39,4 +39,4 @@
52 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform.Linux, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null" />
53 <ProjectReference type="Gac" localcopy="True" refto="Do.Interface.Linux, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null" />
54 </References>
55-</Project>
56+</Project>
57\ No newline at end of file
58
59=== modified file 'WindowManager/Makefile.am'
60--- WindowManager/Makefile.am 2009-03-20 23:05:29 +0000
61+++ WindowManager/Makefile.am 2009-03-31 16:23:38 +0000
62@@ -3,14 +3,27 @@
63 ASSEMBLY=WindowManager
64
65 FILES = \
66- src/WindowListAction.cs \
67+ src/CurrentApplicationItem.cs \
68+ src/CurrentWindowItem.cs \
69 src/IWindowList.cs \
70 src/WindowItem.cs \
71 src/WindowItemSource.cs \
72- src/ScreenListAction.cs \
73- src/WindowListItems.cs \
74- src/GenericWindowItem.cs \
75- src/ScreenItemSource.cs
76+ src/Screen/CurrentScreenItem.cs \
77+ src/Screen/ScreenItem.cs \
78+ src/Screen/ScreenItemSource.cs \
79+ src/Screen/DoModifyGeometry.cs \
80+ src/Screen/ScreenActionAction.cs \
81+ src/Screen/ScreenCascadeAction.cs \
82+ src/Screen/ScreenRestoreAction.cs \
83+ src/Screen/ScreenSwapAction.cs \
84+ src/Screen/ScreenTileAction.cs \
85+ src/WindowActions/WindowActionAction.cs \
86+ src/WindowActions/WindowCloseAction.cs \
87+ src/WindowActions/WindowFocusAction.cs \
88+ src/WindowActions/WindowMaximizeAction.cs \
89+ src/WindowActions/WindowMinimizeAction.cs \
90+ src/WindowActions/WindowMoveAction.cs
91+
92
93 RESOURCES = \
94 Resources/WindowManager.addin.xml
95
96=== modified file 'WindowManager/Resources/WindowManager.addin.xml'
97--- WindowManager/Resources/WindowManager.addin.xml 2009-02-08 06:14:00 +0000
98+++ WindowManager/Resources/WindowManager.addin.xml 2009-03-31 16:23:38 +0000
99@@ -21,9 +21,12 @@
100 <Action type="WindowManager.WindowMinimizeAction" />
101 <Action type="WindowManager.WindowMaximizeAction" />
102 <Action type="WindowManager.WindowCloseAction" />
103+ <Action type="WindowManager.WindowFocusAction" />
104+ <Action type="WindowManager.WindowMoveAction" />
105 <Action type="WindowManager.ScreenTileAction" />
106 <Action type="WindowManager.ScreenCascadeAction" />
107 <Action type="WindowManager.ScreenRestoreAction" />
108+ <Action type="WindowManager.ScreenSwapAction" />
109 </Extension>
110
111 <Extension path="/Do/ItemSource">
112
113=== modified file 'WindowManager/WindowManager.mdp'
114--- WindowManager/WindowManager.mdp 2009-03-20 23:05:29 +0000
115+++ WindowManager/WindowManager.mdp 2009-03-30 21:59:36 +0000
116@@ -15,15 +15,29 @@
117 </Configurations>
118 <Contents>
119 <File name="src" subtype="Directory" buildaction="Compile" />
120- <File name="src/WindowListAction.cs" subtype="Code" buildaction="Compile" />
121 <File name="src/IWindowList.cs" subtype="Code" buildaction="Compile" />
122 <File name="src/WindowItem.cs" subtype="Code" buildaction="Compile" />
123 <File name="src/WindowItemSource.cs" subtype="Code" buildaction="Compile" />
124- <File name="src/ScreenListAction.cs" subtype="Code" buildaction="Compile" />
125- <File name="src/WindowListItems.cs" subtype="Code" buildaction="Compile" />
126- <File name="src/GenericWindowItem.cs" subtype="Code" buildaction="Compile" />
127- <File name="src/ScreenItemSource.cs" subtype="Code" buildaction="Compile" />
128 <File name="Resources/WindowManager.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
129+ <File name="src/Screen" subtype="Directory" buildaction="Compile" />
130+ <File name="src/Screen/ScreenItem.cs" subtype="Code" buildaction="Compile" />
131+ <File name="src/Screen/ScreenItemSource.cs" subtype="Code" buildaction="Compile" />
132+ <File name="src/Screen/ScreenRestoreAction.cs" subtype="Code" buildaction="Compile" />
133+ <File name="src/Screen/CurrentScreenItem.cs" subtype="Code" buildaction="Compile" />
134+ <File name="src/WindowActions" subtype="Directory" buildaction="Compile" />
135+ <File name="src/WindowActions/WindowActionAction.cs" subtype="Code" buildaction="Compile" />
136+ <File name="src/WindowActions/WindowMaximizeAction.cs" subtype="Code" buildaction="Compile" />
137+ <File name="src/WindowActions/WindowCloseAction.cs" subtype="Code" buildaction="Compile" />
138+ <File name="src/WindowActions/WindowMinimizeAction.cs" subtype="Code" buildaction="Compile" />
139+ <File name="src/WindowActions/WindowMoveAction.cs" subtype="Code" buildaction="Compile" />
140+ <File name="src/CurrentWindowItem.cs" subtype="Code" buildaction="Compile" />
141+ <File name="src/CurrentApplicationItem.cs" subtype="Code" buildaction="Compile" />
142+ <File name="src/Screen/DoModifyGeometry.cs" subtype="Code" buildaction="Compile" />
143+ <File name="src/Screen/ScreenActionAction.cs" subtype="Code" buildaction="Compile" />
144+ <File name="src/Screen/ScreenTileAction.cs" subtype="Code" buildaction="Compile" />
145+ <File name="src/Screen/ScreenCascadeAction.cs" subtype="Code" buildaction="Compile" />
146+ <File name="src/Screen/ScreenSwapAction.cs" subtype="Code" buildaction="Compile" />
147+ <File name="src/WindowActions/WindowFocusAction.cs" subtype="Code" buildaction="Compile" />
148 </Contents>
149 <References>
150 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
151@@ -36,6 +50,7 @@
152 <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
153 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" />
154 <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" />
155+ <ProjectReference type="Gac" localcopy="True" refto="Do.Interface.Wink, Version=1.0.3375.29611, Culture=neutral" />
156 </References>
157 <LanguageParameters ApplicationIcon="." ctype="CSharpProjectParameters" />
158 </Project>
159\ No newline at end of file
160
161=== removed file 'WindowManager/src/GenericWindowItem.cs'
162--- WindowManager/src/GenericWindowItem.cs 2008-12-21 23:44:34 +0000
163+++ WindowManager/src/GenericWindowItem.cs 1970-01-01 00:00:00 +0000
164@@ -1,76 +0,0 @@
165-// GenericWindowItem.cs
166-//
167-//GNOME Do is the legal property of its developers. Please refer to the
168-//COPYRIGHT file distributed with this
169-//source distribution.
170-//
171-// This program is free software; you can redistribute it and/or modify
172-// it under the terms of the GNU General Public License as published by
173-// the Free Software Foundation; either version 2 of the License, or
174-// (at your option) any later version.
175-//
176-// This program is distributed in the hope that it will be useful,
177-// but WITHOUT ANY WARRANTY; without even the implied warranty of
178-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
179-// GNU General Public License for more details.
180-//
181-// You should have received a copy of the GNU General Public License
182-// along with this program; if not, write to the Free Software
183-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
184-//
185-//
186-
187-using System;
188-using Wnck;
189-using Do.Universe;
190-
191-namespace WindowManager
192-{
193- public enum GenericWindowType
194- {
195- CurrentWindow = 0,
196- PreviousWindow = 1,
197- CurrentApplication = 2,
198- PreviousApplication = 3,
199- }
200-
201- public class GenericWindowItem : Item
202- {
203- string name, description, icon;
204- GenericWindowType windowType;
205-
206- public GenericWindowItem (string name, string description, string icon,
207- GenericWindowType windowType)
208- {
209- this.name = name;
210- this.description = description;
211- this.icon = icon;
212- this.windowType = windowType;
213- }
214-
215- public override string Name {
216- get {
217- return name;
218- }
219- }
220-
221- public override string Description {
222- get {
223- return description;
224- }
225- }
226-
227- public override string Icon {
228- get {
229- return icon;
230- }
231- }
232-
233- public GenericWindowType WindowType {
234- get {
235- return windowType;
236- }
237- }
238-
239- }
240-}
241
242=== modified file 'WindowManager/src/IWindowList.cs'
243--- WindowManager/src/IWindowList.cs 2008-12-22 00:19:48 +0000
244+++ WindowManager/src/IWindowList.cs 2009-03-30 00:03:03 +0000
245@@ -21,9 +21,11 @@
246 //
247
248 using System;
249+using System.Collections.Generic;
250 using Wnck;
251
252 using Do.Universe;
253+using Do.Interface.Wink;
254
255 namespace WindowManager
256 {
257@@ -31,12 +33,17 @@
258 // {
259 // }
260
261- public interface IWindowItem : IItem
262+ public interface IWindowItem
263 {
264- Wnck.Window Window { get; }
265+ IEnumerable<Wnck.Window> Windows { get; }
266 }
267
268- public interface IScreenItem : IItem
269+ public interface IScreenItem
270 {
271+ Viewport Viewport { get; }
272+
273+ IEnumerable<Wnck.Window> Windows { get; }
274+
275+ IEnumerable<Wnck.Window> VisibleWindows { get; }
276 }
277 }
278
279=== added directory 'WindowManager/src/Screen'
280=== added file 'WindowManager/src/Screen/CurrentScreenItem.cs'
281--- WindowManager/src/Screen/CurrentScreenItem.cs 1970-01-01 00:00:00 +0000
282+++ WindowManager/src/Screen/CurrentScreenItem.cs 2009-03-29 20:55:02 +0000
283@@ -0,0 +1,72 @@
284+//
285+// Copyright (C) 2009 GNOME Do
286+//
287+// This program is free software: you can redistribute it and/or modify
288+// it under the terms of the GNU General Public License as published by
289+// the Free Software Foundation, either version 3 of the License, or
290+// (at your option) any later version.
291+//
292+// This program is distributed in the hope that it will be useful,
293+// but WITHOUT ANY WARRANTY; without even the implied warranty of
294+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
295+// GNU General Public License for more details.
296+//
297+// You should have received a copy of the GNU General Public License
298+// along with this program. If not, see <http://www.gnu.org/licenses/>.
299+//
300+
301+using System;
302+using System.Collections.Generic;
303+using System.Linq;
304+using Wnck;
305+
306+using Mono.Unix;
307+
308+using Do.Universe;
309+using Do.Interface.Wink;
310+
311+namespace WindowManager
312+{
313+ public class CurrentScreenItem : Item, IScreenItem
314+ {
315+ public override string Name {
316+ get {
317+ return Catalog.GetString ("Current Desktop");
318+ }
319+ }
320+
321+ public override string Description {
322+ get {
323+ return Catalog.GetString ("Everything on the Current Desktop");
324+ }
325+ }
326+
327+ public override string Icon {
328+ get {
329+ return "desktop";
330+ }
331+ }
332+
333+ public IEnumerable<Wnck.Window> Windows {
334+ get {
335+ return ScreenUtils.ViewportWindows (Viewport);
336+ }
337+ }
338+
339+ public IEnumerable<Wnck.Window> VisibleWindows {
340+ get {
341+ return Windows.Where (w => !w.IsMinimized);
342+ }
343+ }
344+
345+ public Viewport Viewport {
346+ get {
347+ return ScreenUtils.ActiveViewport;
348+ }
349+ }
350+
351+ public CurrentScreenItem ()
352+ {
353+ }
354+ }
355+}
356\ No newline at end of file
357
358=== added file 'WindowManager/src/Screen/DoModifyGeometry.cs'
359--- WindowManager/src/Screen/DoModifyGeometry.cs 1970-01-01 00:00:00 +0000
360+++ WindowManager/src/Screen/DoModifyGeometry.cs 2009-03-30 15:06:51 +0000
361@@ -0,0 +1,181 @@
362+//
363+// Copyright (C) 2009 GNOME Do
364+//
365+// This program is free software: you can redistribute it and/or modify
366+// it under the terms of the GNU General Public License as published by
367+// the Free Software Foundation, either version 3 of the License, or
368+// (at your option) any later version.
369+//
370+// This program is distributed in the hope that it will be useful,
371+// but WITHOUT ANY WARRANTY; without even the implied warranty of
372+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
373+// GNU General Public License for more details.
374+//
375+// You should have received a copy of the GNU General Public License
376+// along with this program. If not, see <http://www.gnu.org/licenses/>.
377+//
378+
379+using System;
380+using System.Collections.Generic;
381+using System.Linq;
382+using System.Diagnostics;
383+using System.Threading;
384+
385+using Do.Universe;
386+using Do.Interface.Wink;
387+
388+using Wnck;
389+using Mono.Unix;
390+
391+namespace WindowManager
392+{
393+
394+
395+ public class DoModifyGeometry
396+ {
397+ private class WindowState {
398+ public int X, Y, Height, Width;
399+ public Wnck.WindowState State;
400+
401+ public WindowState (int x, int y, int height,
402+ int width, Wnck.WindowState state)
403+ {
404+ X = x;
405+ Y = y;
406+ Height = height;
407+ Width = width;
408+ state = State;
409+ }
410+ }
411+
412+ static Dictionary<Window, WindowState> windowList;
413+
414+ static DoModifyGeometry ()
415+ {
416+ windowList = new Dictionary<Window, WindowState> ();
417+
418+ Screen.Default.WindowClosed += OnWindowClosed;
419+ }
420+
421+ public static Gdk.Rectangle GetScreenMinusPanelGeometry {
422+ get {
423+ Gdk.Rectangle outRect = new Gdk.Rectangle ();
424+
425+ Screen scrn = Screen.Default;
426+ outRect.Width = scrn.Width;
427+ outRect.Height = scrn.Height;
428+
429+ foreach (Window w in scrn.Windows) {
430+ if (!w.IsSkipTasklist || w.Name == "Do") continue;
431+ if (w.WindowType == WindowType.Dock) {
432+ //ok this is likely a panel. Lets make sure!
433+ Gdk.Rectangle windowGeo = new Gdk.Rectangle ();
434+ w.GetGeometry (out windowGeo.X, out windowGeo.Y,
435+ out windowGeo.Width, out windowGeo.Height);
436+
437+ //we would like to know which edge it sits against
438+ if (windowGeo.Y == 0 && windowGeo.Width > windowGeo.Height) {
439+ //top edge
440+ outRect.Y += windowGeo.Height;
441+ outRect.Height -= windowGeo.Height;
442+ } else if (windowGeo.X == 0 && windowGeo.Height > windowGeo.Width) {
443+ //left edge
444+ outRect.X += windowGeo.Width;
445+ outRect.Width -= windowGeo.Width;
446+ } else if (windowGeo.Y == scrn.Height - windowGeo.Height &&
447+ windowGeo.Width > windowGeo.Height) {
448+ //bottom edge
449+ outRect.Height -= windowGeo.Height;
450+ } else if (windowGeo.X == scrn.Width - windowGeo.Width &&
451+ windowGeo.Height > windowGeo.Width) {
452+ //right edge
453+ outRect.Width -= windowGeo.Width;
454+ }
455+ }
456+ }
457+
458+
459+ return outRect;
460+ }
461+ }
462+
463+ /// <summary>
464+ /// Removes unused windows in the window list that have been closed
465+ /// </summary>
466+ /// <param name="o">
467+ /// A <see cref="System.Object"/>
468+ /// </param>
469+ /// <param name="args">
470+ /// A <see cref="WindowClosedArgs"/>
471+ /// </param>
472+ public static void OnWindowClosed (object o, WindowClosedArgs args) {
473+ if (windowList.ContainsKey (args.Window)) {
474+ windowList.Remove (args.Window);
475+ }
476+ }
477+
478+ public static bool SetWindowGeometry (Window w, int x, int y,
479+ int height, int width, bool save)
480+ {
481+ int oldx, oldy, oldheight, oldwidth;
482+
483+ w.GetGeometry (out oldx, out oldy, out oldwidth, out oldheight);
484+
485+ bool alreadyInList = windowList.ContainsKey (w);
486+
487+ if (save && !alreadyInList)
488+ windowList.Add (w, new WindowState (oldx, oldy, oldheight,
489+ oldwidth, w.State));
490+
491+ if (w.IsMaximized)
492+ w.Unmaximize ();
493+
494+ WindowMoveResizeMask mask = 0;
495+
496+ if (width != oldwidth)
497+ mask = mask | WindowMoveResizeMask.Width;
498+ if (height != oldheight)
499+ mask = mask | WindowMoveResizeMask.Height;
500+ if (x != oldx)
501+ mask = mask | WindowMoveResizeMask.X;
502+ if (y != oldy)
503+ mask = mask | WindowMoveResizeMask.Y;
504+
505+ w.SetGeometry (WindowGravity.Northwest, mask, x, y, width, height);
506+
507+ return true;
508+ }
509+
510+ public static bool RestoreWindowGeometry (Window w)
511+ {
512+ WindowState state;
513+ if (windowList.TryGetValue (w, out state)) {
514+ SetWindowGeometry (w, state.X, state.Y, state.Height,
515+ state.Width, false);
516+ windowList.Remove (w);
517+ return true;
518+ }
519+ return false;
520+ }
521+
522+ /// <summary>
523+ /// Returns a list of the windows that are actually configured
524+ /// </summary>
525+ /// <param name="windows">
526+ /// A <see cref="List`1"/>
527+ /// </param>
528+ /// <returns>
529+ /// A <see cref="List`1"/>
530+ /// </returns>
531+ public static List<Window> IsStored (List<Window> windows)
532+ {
533+ List<Window> retList = new List<Window> ();
534+ foreach (Window w in windows) {
535+ if (windowList.ContainsKey (w)) {
536+ retList.Add (w);
537+ }
538+ }
539+ return retList;
540+ }
541+ }
542+}
543
544=== added file 'WindowManager/src/Screen/ScreenActionAction.cs'
545--- WindowManager/src/Screen/ScreenActionAction.cs 1970-01-01 00:00:00 +0000
546+++ WindowManager/src/Screen/ScreenActionAction.cs 2009-03-30 15:06:51 +0000
547@@ -0,0 +1,67 @@
548+//
549+// Copyright (C) 2009 GNOME Do
550+//
551+// This program is free software: you can redistribute it and/or modify
552+// it under the terms of the GNU General Public License as published by
553+// the Free Software Foundation, either version 3 of the License, or
554+// (at your option) any later version.
555+//
556+// This program is distributed in the hope that it will be useful,
557+// but WITHOUT ANY WARRANTY; without even the implied warranty of
558+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
559+// GNU General Public License for more details.
560+//
561+// You should have received a copy of the GNU General Public License
562+// along with this program. If not, see <http://www.gnu.org/licenses/>.
563+//
564+
565+using System;
566+using System.Collections.Generic;
567+using System.Linq;
568+using System.Diagnostics;
569+using System.Threading;
570+
571+using Do.Universe;
572+using Do.Interface.Wink;
573+
574+using Wnck;
575+using Mono.Unix;
576+
577+namespace WindowManager
578+{
579+
580+
581+ public abstract class ScreenActionAction : Act
582+ {
583+ public override IEnumerable<Type> SupportedItemTypes {
584+ get { return new Type [] {
585+ typeof (IScreenItem), };
586+ }
587+ }
588+
589+ public override bool ModifierItemsOptional {
590+ get { return true; }
591+ }
592+
593+ public override bool SupportsItem (Item item)
594+ {
595+ return true;
596+ }
597+
598+ protected void SetWindowGeometry (Window w, int x, int y, int width, int height)
599+ {
600+ w.SetGeometry (WindowGravity.Northwest,
601+ WindowMoveResizeMask.Width,
602+ x, y, width, height);
603+ w.SetGeometry (WindowGravity.Northwest,
604+ WindowMoveResizeMask.Height,
605+ x, y, width, height);
606+ w.SetGeometry (WindowGravity.Northwest,
607+ WindowMoveResizeMask.X,
608+ x, y, width, height);
609+ w.SetGeometry (WindowGravity.Northwest,
610+ WindowMoveResizeMask.Y,
611+ x, y, width, height);
612+ }
613+ }
614+}
615
616=== added file 'WindowManager/src/Screen/ScreenCascadeAction.cs'
617--- WindowManager/src/Screen/ScreenCascadeAction.cs 1970-01-01 00:00:00 +0000
618+++ WindowManager/src/Screen/ScreenCascadeAction.cs 2009-03-30 15:06:51 +0000
619@@ -0,0 +1,92 @@
620+//
621+// Copyright (C) 2009 GNOME Do
622+//
623+// This program is free software: you can redistribute it and/or modify
624+// it under the terms of the GNU General Public License as published by
625+// the Free Software Foundation, either version 3 of the License, or
626+// (at your option) any later version.
627+//
628+// This program is distributed in the hope that it will be useful,
629+// but WITHOUT ANY WARRANTY; without even the implied warranty of
630+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
631+// GNU General Public License for more details.
632+//
633+// You should have received a copy of the GNU General Public License
634+// along with this program. If not, see <http://www.gnu.org/licenses/>.
635+//
636+
637+using System;
638+using System.Collections.Generic;
639+using System.Linq;
640+using System.Diagnostics;
641+using System.Threading;
642+
643+using Do.Universe;
644+using Do.Interface.Wink;
645+
646+using Wnck;
647+using Mono.Unix;
648+
649+namespace WindowManager
650+{
651+
652+
653+ public class ScreenCascadeAction : ScreenActionAction
654+ {
655+ public override string Name {
656+ get { return Catalog.GetString ("Cascade Windows"); }
657+ }
658+
659+ public override string Description {
660+ get { return Catalog.GetString ("Cascade your Windows"); }
661+ }
662+
663+ public override string Icon {
664+ get { return "preferences-system-windows"; }
665+ }
666+
667+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
668+ {
669+ IScreenItem item = items.First () as IScreenItem;
670+ IEnumerable<Window> windowList = item.VisibleWindows;
671+
672+ //can't tile no windows
673+ if (windowList.Count () <= 1) return null;
674+
675+ int width, height, offsetx, offsety;
676+
677+ int xbuffer = 13;
678+ int ybuffer = 30;
679+ int winbuffer = 30;
680+
681+ //we want to cascade here, so the idea is that for each window we
682+ //need to be able to create a buffer that is about the width of the
683+ //title bar. We will approximate this to around 30px. Therefor our
684+ //width and height need to be (30 * number of Windows) pixels
685+ //smaller than the screen. We will also offset by 100 on both
686+ //the x and y axis, so we should end as such. This needs to be
687+ //calculated for too.
688+
689+ width = (Screen.Default.Width - (2 * xbuffer)) -
690+ (winbuffer * (windowList.Count () - 1));
691+
692+ height = (Screen.Default.Height - (2 * ybuffer)) -
693+ (winbuffer * (windowList.Count () - 1));
694+
695+ offsetx = xbuffer;
696+ offsety = ybuffer;
697+
698+
699+ foreach (Window w in windowList) {
700+ DoModifyGeometry.SetWindowGeometry (w, offsetx, offsety, height,
701+ width, true);
702+
703+ offsetx += winbuffer;
704+ offsety += winbuffer;
705+ }
706+
707+ return null;
708+ }
709+
710+ }
711+}
712
713=== added file 'WindowManager/src/Screen/ScreenItem.cs'
714--- WindowManager/src/Screen/ScreenItem.cs 1970-01-01 00:00:00 +0000
715+++ WindowManager/src/Screen/ScreenItem.cs 2009-03-29 20:55:02 +0000
716@@ -0,0 +1,69 @@
717+//
718+// Copyright (C) 2009 GNOME Do
719+//
720+// This program is free software: you can redistribute it and/or modify
721+// it under the terms of the GNU General Public License as published by
722+// the Free Software Foundation, either version 3 of the License, or
723+// (at your option) any later version.
724+//
725+// This program is distributed in the hope that it will be useful,
726+// but WITHOUT ANY WARRANTY; without even the implied warranty of
727+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
728+// GNU General Public License for more details.
729+//
730+// You should have received a copy of the GNU General Public License
731+// along with this program. If not, see <http://www.gnu.org/licenses/>.
732+//
733+
734+using System;
735+using System.Collections.Generic;
736+using System.Linq;
737+using Wnck;
738+
739+using Mono.Unix;
740+
741+using Do.Universe;
742+using Do.Interface.Wink;
743+
744+namespace WindowManager
745+{
746+ public class ScreenItem : Item, IScreenItem
747+ {
748+ public override string Name {
749+ get {
750+ return Viewport.Name;
751+ }
752+ }
753+
754+ public override string Description {
755+ get {
756+ return Viewport.Name;
757+ }
758+ }
759+
760+ public override string Icon {
761+ get {
762+ return "desktop";
763+ }
764+ }
765+
766+ public IEnumerable<Wnck.Window> Windows {
767+ get {
768+ return ScreenUtils.ViewportWindows (Viewport);
769+ }
770+ }
771+
772+ public IEnumerable<Wnck.Window> VisibleWindows {
773+ get {
774+ return Windows.Where (w => !w.IsMinimized);
775+ }
776+ }
777+
778+ public Viewport Viewport { get; set; }
779+
780+ public ScreenItem (Viewport viewport)
781+ {
782+ Viewport = viewport;
783+ }
784+ }
785+}
786
787=== added file 'WindowManager/src/Screen/ScreenItemSource.cs'
788--- WindowManager/src/Screen/ScreenItemSource.cs 1970-01-01 00:00:00 +0000
789+++ WindowManager/src/Screen/ScreenItemSource.cs 2009-03-30 15:06:51 +0000
790@@ -0,0 +1,80 @@
791+// ScreenItemSource.cs
792+//
793+//GNOME Do is the legal property of its developers. Please refer to the
794+//COPYRIGHT file distributed with this
795+//source distribution.
796+//
797+// This program is free software; you can redistribute it and/or modify
798+// it under the terms of the GNU General Public License as published by
799+// the Free Software Foundation; either version 2 of the License, or
800+// (at your option) any later version.
801+//
802+// This program is distributed in the hope that it will be useful,
803+// but WITHOUT ANY WARRANTY; without even the implied warranty of
804+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
805+// GNU General Public License for more details.
806+//
807+// You should have received a copy of the GNU General Public License
808+// along with this program; if not, write to the Free Software
809+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
810+//
811+//
812+
813+using System;
814+using System.Collections.Generic;
815+
816+using Do.Universe;
817+using Do.Interface.Wink;
818+using Wnck;
819+using Mono.Unix;
820+
821+namespace WindowManager
822+{
823+
824+ public class ScreenItemSource : ItemSource
825+ {
826+ public override string Name {
827+ get {
828+ return Catalog.GetString ("Window Screen Items");
829+ }
830+ }
831+
832+ public override string Description {
833+ get {
834+ return Catalog.GetString ("Actions you can do to your screens.");
835+ }
836+ }
837+
838+ public override string Icon {
839+ get {
840+ return "desktop";
841+ }
842+ }
843+
844+ public override IEnumerable<Type> SupportedItemTypes {
845+ get {
846+ return new Type[] {
847+ typeof (IScreenItem) };
848+ }
849+ }
850+
851+ public override IEnumerable<Item> Items {
852+ get {
853+ yield return new CurrentScreenItem ();
854+
855+
856+ foreach (Viewport viewport in ScreenUtils.Viewports)
857+ yield return new ScreenItem (viewport);
858+ }
859+ }
860+
861+
862+ public ScreenItemSource()
863+ {
864+ }
865+
866+ public override void UpdateItems ()
867+ {
868+ }
869+ }
870+}
871
872=== added file 'WindowManager/src/Screen/ScreenRestoreAction.cs'
873--- WindowManager/src/Screen/ScreenRestoreAction.cs 1970-01-01 00:00:00 +0000
874+++ WindowManager/src/Screen/ScreenRestoreAction.cs 2009-03-30 15:06:51 +0000
875@@ -0,0 +1,63 @@
876+// ScreenListAction.cs
877+//
878+//GNOME Do is the legal property of its developers. Please refer to the
879+//COPYRIGHT file distributed with this
880+//source distribution.
881+//
882+// This program is free software; you can redistribute it and/or modify
883+// it under the terms of the GNU General Public License as published by
884+// the Free Software Foundation; either version 2 of the License, or
885+// (at your option) any later version.
886+//
887+// This program is distributed in the hope that it will be useful,
888+// but WITHOUT ANY WARRANTY; without even the implied warranty of
889+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
890+// GNU General Public License for more details.
891+//
892+// You should have received a copy of the GNU General Public License
893+// along with this program; if not, write to the Free Software
894+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
895+//
896+//
897+
898+using System;
899+using System.Collections.Generic;
900+using System.Linq;
901+using System.Diagnostics;
902+using System.Threading;
903+
904+using Do.Universe;
905+using Do.Interface.Wink;
906+
907+using Wnck;
908+using Mono.Unix;
909+
910+namespace WindowManager
911+{
912+
913+ public class ScreenRestoreAction : ScreenActionAction
914+ {
915+ public override string Name {
916+ get { return Catalog.GetString ("Restore Windows"); }
917+ }
918+
919+ public override string Description {
920+ get { return Catalog.GetString ("Restore Windows to their Previous Positions"); }
921+ }
922+
923+ public override string Icon {
924+ get { return "preferences-system-windows"; }
925+ }
926+
927+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
928+ {
929+ IScreenItem item = items.First () as IScreenItem;
930+
931+ foreach (Window w in ScreenUtils.ViewportWindows (item.Viewport))
932+ DoModifyGeometry.RestoreWindowGeometry (w);
933+
934+ return null;
935+ }
936+
937+ }
938+}
939
940=== added file 'WindowManager/src/Screen/ScreenSwapAction.cs'
941--- WindowManager/src/Screen/ScreenSwapAction.cs 1970-01-01 00:00:00 +0000
942+++ WindowManager/src/Screen/ScreenSwapAction.cs 2009-03-30 21:59:36 +0000
943@@ -0,0 +1,87 @@
944+//
945+// Copyright (C) 2009 GNOME Do
946+//
947+// This program is free software: you can redistribute it and/or modify
948+// it under the terms of the GNU General Public License as published by
949+// the Free Software Foundation, either version 3 of the License, or
950+// (at your option) any later version.
951+//
952+// This program is distributed in the hope that it will be useful,
953+// but WITHOUT ANY WARRANTY; without even the implied warranty of
954+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
955+// GNU General Public License for more details.
956+//
957+// You should have received a copy of the GNU General Public License
958+// along with this program. If not, see <http://www.gnu.org/licenses/>.
959+//
960+
961+using System;
962+using System.Collections.Generic;
963+using System.Linq;
964+using System.Diagnostics;
965+using System.Threading;
966+
967+using Do.Universe;
968+using Do.Interface.Wink;
969+
970+using Wnck;
971+using Mono.Unix;
972+
973+namespace WindowManager
974+{
975+
976+
977+ public class ScreenSwapAction : ScreenActionAction
978+ {
979+
980+ public override string Name {
981+ get { return Catalog.GetString ("Swap With..."); }
982+ }
983+
984+ public override string Description {
985+ get { return Catalog.GetString ("Swap all windows on desktops"); }
986+ }
987+
988+ public override string Icon {
989+ get { return "rotate"; }
990+ }
991+
992+ public override bool ModifierItemsOptional {
993+ get {
994+ return false;
995+ }
996+ }
997+
998+ public override IEnumerable<Type> SupportedModifierItemTypes {
999+ get {
1000+ return SupportedItemTypes;
1001+ }
1002+ }
1003+
1004+ public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem)
1005+ {
1006+ return items.First () != modItem;
1007+ }
1008+
1009+
1010+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1011+ {
1012+ IScreenItem screen1 = items.First () as IScreenItem;
1013+ IScreenItem screen2 = modItems.First () as IScreenItem;
1014+
1015+ IEnumerable<Window> screen2Windows = ScreenUtils.ViewportWindows (screen2.Viewport);
1016+
1017+ // Move screen1 windows to screen2
1018+ foreach (Window w in ScreenUtils.ViewportWindows (screen1.Viewport)) {
1019+ screen2.Viewport.MoveWindowInto (w);
1020+ }
1021+
1022+ // Move screen2 windows to screen1
1023+ foreach (Window w in screen2Windows) {
1024+ screen1.Viewport.MoveWindowInto (w);
1025+ }
1026+
1027+ return null;
1028+ }
1029+ }
1030+}
1031
1032=== added file 'WindowManager/src/Screen/ScreenTileAction.cs'
1033--- WindowManager/src/Screen/ScreenTileAction.cs 1970-01-01 00:00:00 +0000
1034+++ WindowManager/src/Screen/ScreenTileAction.cs 2009-03-30 15:06:51 +0000
1035@@ -0,0 +1,103 @@
1036+//
1037+// Copyright (C) 2009 GNOME Do
1038+//
1039+// This program is free software: you can redistribute it and/or modify
1040+// it under the terms of the GNU General Public License as published by
1041+// the Free Software Foundation, either version 3 of the License, or
1042+// (at your option) any later version.
1043+//
1044+// This program is distributed in the hope that it will be useful,
1045+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1046+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1047+// GNU General Public License for more details.
1048+//
1049+// You should have received a copy of the GNU General Public License
1050+// along with this program. If not, see <http://www.gnu.org/licenses/>.
1051+//
1052+
1053+using System;
1054+using System.Collections.Generic;
1055+using System.Linq;
1056+using System.Diagnostics;
1057+using System.Threading;
1058+
1059+using Do.Universe;
1060+using Do.Interface.Wink;
1061+
1062+using Wnck;
1063+using Mono.Unix;
1064+
1065+namespace WindowManager
1066+{
1067+
1068+
1069+ public class ScreenTileAction : ScreenActionAction
1070+ {
1071+ public override string Name {
1072+ get { return Catalog.GetString ("Tile Windows"); }
1073+ }
1074+
1075+ public override string Description {
1076+ get { return Catalog.GetString ("Tile All Windows in Current Viewport"); }
1077+ }
1078+
1079+ public override string Icon {
1080+ get { return "preferences-system-windows"; }
1081+ }
1082+
1083+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1084+ {
1085+ IScreenItem item = items.First () as IScreenItem;
1086+ IEnumerable<Window> windowList = item.VisibleWindows;
1087+ Gdk.Rectangle screenGeo = DoModifyGeometry.GetScreenMinusPanelGeometry;
1088+
1089+ //can't tile no windows
1090+ if (windowList.Count () <= 1) return null;
1091+
1092+ int square, height, width;
1093+
1094+ //We are going to tile to a square, so what we want is to find
1095+ //the smallest perfect square all our windows will fit into
1096+ square = (int) Math.Ceiling (Math.Sqrt (windowList.Count ()));
1097+
1098+ //Our width will always be our perfect square
1099+ width = square;
1100+
1101+ //Our height is at least one (e.g. a 2x1)
1102+ height = 1;
1103+ while (width * height < windowList.Count ()) {
1104+ height++;
1105+ }
1106+
1107+ int windowWidth, windowHeight;
1108+ windowWidth = screenGeo.Width / width;
1109+
1110+ windowHeight = screenGeo.Height / height;
1111+
1112+ int row = 0, column = 0;
1113+ int x, y;
1114+
1115+ foreach (Wnck.Window window in windowList) {
1116+ x = (column * windowWidth) + screenGeo.X;
1117+ y = (row * windowHeight) + screenGeo.Y;
1118+
1119+ if (window == windowList.Last ()) {
1120+ DoModifyGeometry.SetWindowGeometry (window, x, y,
1121+ windowHeight, screenGeo.Width - x, true);
1122+ } else {
1123+ DoModifyGeometry.SetWindowGeometry (window, x, y, windowHeight,
1124+ windowWidth, true);
1125+ }
1126+
1127+ column++;
1128+ if (column == width) {
1129+ column = 0;
1130+ row++;
1131+ }
1132+ }
1133+
1134+ return null;
1135+ }
1136+
1137+ }
1138+}
1139
1140=== removed file 'WindowManager/src/ScreenItemSource.cs'
1141--- WindowManager/src/ScreenItemSource.cs 2008-12-21 23:44:34 +0000
1142+++ WindowManager/src/ScreenItemSource.cs 1970-01-01 00:00:00 +0000
1143@@ -1,87 +0,0 @@
1144-// ScreenItemSource.cs
1145-//
1146-//GNOME Do is the legal property of its developers. Please refer to the
1147-//COPYRIGHT file distributed with this
1148-//source distribution.
1149-//
1150-// This program is free software; you can redistribute it and/or modify
1151-// it under the terms of the GNU General Public License as published by
1152-// the Free Software Foundation; either version 2 of the License, or
1153-// (at your option) any later version.
1154-//
1155-// This program is distributed in the hope that it will be useful,
1156-// but WITHOUT ANY WARRANTY; without even the implied warranty of
1157-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1158-// GNU General Public License for more details.
1159-//
1160-// You should have received a copy of the GNU General Public License
1161-// along with this program; if not, write to the Free Software
1162-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1163-//
1164-//
1165-
1166-using System;
1167-using System.Collections.Generic;
1168-
1169-using Do.Universe;
1170-using Wnck;
1171-using Mono.Unix;
1172-
1173-namespace WindowManager
1174-{
1175-
1176- public class ScreenItemSource : ItemSource
1177- {
1178- public override string Name {
1179- get {
1180- return Catalog.GetString ("Window Screen Items");
1181- }
1182- }
1183-
1184- public override string Description {
1185- get {
1186- return Catalog.GetString ("Actions you can do to your screens.");
1187- }
1188- }
1189-
1190- public override string Icon {
1191- get {
1192- return "desktop"; //fixme
1193- }
1194- }
1195-
1196- public override IEnumerable<Type> SupportedItemTypes {
1197- get {
1198- return new Type[] {
1199- typeof (IScreenItem) };
1200- }
1201- }
1202-
1203- public override IEnumerable<Item> Items {
1204- get {
1205- List<Item> items;
1206-
1207- items = new List<Item> ();
1208- items.Add (new ScreenItem (Catalog.GetString ("Current Desktop"),
1209- Catalog.GetString ("Everything on the Current Desktop"),
1210- "desktop"));
1211-
1212- return items;
1213- }
1214- }
1215-
1216-
1217- public ScreenItemSource()
1218- {
1219- }
1220-
1221- public override IEnumerable<Item> ChildrenOfItem (Item item)
1222- {
1223- return null;
1224- }
1225-
1226- public override void UpdateItems ()
1227- {
1228- }
1229- }
1230-}
1231
1232=== removed file 'WindowManager/src/ScreenListAction.cs'
1233--- WindowManager/src/ScreenListAction.cs 2009-03-20 23:05:29 +0000
1234+++ WindowManager/src/ScreenListAction.cs 1970-01-01 00:00:00 +0000
1235@@ -1,439 +0,0 @@
1236-// ScreenListAction.cs
1237-//
1238-//GNOME Do is the legal property of its developers. Please refer to the
1239-//COPYRIGHT file distributed with this
1240-//source distribution.
1241-//
1242-// This program is free software; you can redistribute it and/or modify
1243-// it under the terms of the GNU General Public License as published by
1244-// the Free Software Foundation; either version 2 of the License, or
1245-// (at your option) any later version.
1246-//
1247-// This program is distributed in the hope that it will be useful,
1248-// but WITHOUT ANY WARRANTY; without even the implied warranty of
1249-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1250-// GNU General Public License for more details.
1251-//
1252-// You should have received a copy of the GNU General Public License
1253-// along with this program; if not, write to the Free Software
1254-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1255-//
1256-//
1257-
1258-using System;
1259-using System.Collections.Generic;
1260-using System.Diagnostics;
1261-using System.Threading;
1262-
1263-using Do.Universe;
1264-
1265-using Wnck;
1266-using Mono.Unix;
1267-
1268-namespace WindowManager
1269-{
1270- public class DoModifyGeometry
1271- {
1272- private class WindowState {
1273- public int X, Y, Height, Width;
1274- public Wnck.WindowState State;
1275-
1276- public WindowState (int x, int y, int height,
1277- int width, Wnck.WindowState state)
1278- {
1279- X = x;
1280- Y = y;
1281- Height = height;
1282- Width = width;
1283- state = State;
1284- }
1285- }
1286-
1287- static Dictionary<Window, WindowState> windowList;
1288-
1289- static DoModifyGeometry ()
1290- {
1291- windowList = new Dictionary<Window, WindowState> ();
1292-
1293- Screen.Default.WindowClosed += OnWindowClosed;
1294- }
1295-
1296- public static Gdk.Rectangle GetScreenMinusPanelGeometry {
1297- get {
1298- Gdk.Rectangle outRect = new Gdk.Rectangle ();
1299-
1300- Screen scrn = Screen.Default;
1301- outRect.Width = scrn.Width;
1302- outRect.Height = scrn.Height;
1303-
1304- foreach (Window w in scrn.Windows) {
1305- if (!w.IsSkipTasklist || w.Name == "Do") continue;
1306- if (w.WindowType == WindowType.Dock) {
1307- //ok this is likely a panel. Lets make sure!
1308- Gdk.Rectangle windowGeo = new Gdk.Rectangle ();
1309- w.GetGeometry (out windowGeo.X, out windowGeo.Y,
1310- out windowGeo.Width, out windowGeo.Height);
1311-
1312- //we would like to know which edge it sits against
1313- if (windowGeo.Y == 0 && windowGeo.Width > windowGeo.Height) {
1314- //top edge
1315- outRect.Y += windowGeo.Height;
1316- outRect.Height -= windowGeo.Height;
1317- } else if (windowGeo.X == 0 && windowGeo.Height > windowGeo.Width) {
1318- //left edge
1319- outRect.X += windowGeo.Width;
1320- outRect.Width -= windowGeo.Width;
1321- } else if (windowGeo.Y == scrn.Height - windowGeo.Height &&
1322- windowGeo.Width > windowGeo.Height) {
1323- //bottom edge
1324- outRect.Height -= windowGeo.Height;
1325- } else if (windowGeo.X == scrn.Width - windowGeo.Width &&
1326- windowGeo.Height > windowGeo.Width) {
1327- //right edge
1328- outRect.Width -= windowGeo.Width;
1329- }
1330- }
1331- }
1332-
1333-
1334- return outRect;
1335- }
1336- }
1337-
1338- /// <summary>
1339- /// Removes unused windows in the window list that have been closed
1340- /// </summary>
1341- /// <param name="o">
1342- /// A <see cref="System.Object"/>
1343- /// </param>
1344- /// <param name="args">
1345- /// A <see cref="WindowClosedArgs"/>
1346- /// </param>
1347- public static void OnWindowClosed (object o, WindowClosedArgs args) {
1348- if (windowList.ContainsKey (args.Window)) {
1349- windowList.Remove (args.Window);
1350- }
1351- }
1352-
1353- public static bool SetWindowGeometry (Window w, int x, int y,
1354- int height, int width, bool save)
1355- {
1356- int oldx, oldy, oldheight, oldwidth;
1357-
1358- w.GetGeometry (out oldx, out oldy, out oldwidth, out oldheight);
1359-
1360- bool alreadyInList = windowList.ContainsKey (w);
1361-
1362- if (save && !alreadyInList)
1363- windowList.Add (w, new WindowState (oldx, oldy, oldheight,
1364- oldwidth, w.State));
1365-
1366- if (w.IsMaximized)
1367- w.Unmaximize ();
1368-
1369- WindowMoveResizeMask mask = 0;
1370-
1371- if (width != oldwidth)
1372- mask = mask | WindowMoveResizeMask.Width;
1373- if (height != oldheight)
1374- mask = mask | WindowMoveResizeMask.Height;
1375- if (x != oldx)
1376- mask = mask | WindowMoveResizeMask.X;
1377- if (y != oldy)
1378- mask = mask | WindowMoveResizeMask.Y;
1379-
1380- w.SetGeometry (WindowGravity.Northwest, mask, x, y, width, height);
1381-
1382- return true;
1383- }
1384-
1385- public static bool RestoreWindowGeometry (Window w)
1386- {
1387- WindowState state;
1388- if (windowList.TryGetValue (w, out state)) {
1389- SetWindowGeometry (w, state.X, state.Y, state.Height,
1390- state.Width, false);
1391- windowList.Remove (w);
1392- return true;
1393- }
1394- return false;
1395- }
1396-
1397- /// <summary>
1398- /// Returns a list of the windows that are actually configured
1399- /// </summary>
1400- /// <param name="windows">
1401- /// A <see cref="List`1"/>
1402- /// </param>
1403- /// <returns>
1404- /// A <see cref="List`1"/>
1405- /// </returns>
1406- public static List<Window> IsStored (List<Window> windows)
1407- {
1408- List<Window> retList = new List<Window> ();
1409- foreach (Window w in windows) {
1410- if (windowList.ContainsKey (w)) {
1411- retList.Add (w);
1412- }
1413- }
1414- return retList;
1415- }
1416- }
1417-
1418- public class ScreenActionAction : Act
1419- {
1420- public override IEnumerable<Type> SupportedItemTypes {
1421- get { return new Type [] {
1422- typeof (IScreenItem), };
1423- }
1424- }
1425-
1426- public override bool ModifierItemsOptional {
1427- get { return true; }
1428- }
1429-
1430- public override IEnumerable<Type> SupportedModifierItemTypes {
1431- get { return new Type [] {}; }
1432- }
1433-
1434- public override bool SupportsItem (Item item)
1435- {
1436- return true;
1437- }
1438-
1439- public override IEnumerable<Item> DynamicModifierItemsForItem (Item item)
1440- {
1441- return null;
1442- }
1443-
1444- public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem)
1445- {
1446- return false;
1447- }
1448-
1449- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1450- {
1451- throw new NotImplementedException ();
1452- }
1453-
1454- public override string Description {
1455- get { return ""; }
1456- }
1457-
1458- public override string Icon {
1459- get { return ""; }
1460- }
1461-
1462- public override string Name {
1463- get { return ""; }
1464- }
1465-
1466-
1467- protected void SetWindowGeometry (Window w, int x, int y, int width, int height)
1468- {
1469- w.SetGeometry (WindowGravity.Northwest,
1470- WindowMoveResizeMask.Width,
1471- x, y, width, height);
1472- w.SetGeometry (WindowGravity.Northwest,
1473- WindowMoveResizeMask.Height,
1474- x, y, width, height);
1475- w.SetGeometry (WindowGravity.Northwest,
1476- WindowMoveResizeMask.X,
1477- x, y, width, height);
1478- w.SetGeometry (WindowGravity.Northwest,
1479- WindowMoveResizeMask.Y,
1480- x, y, width, height);
1481- }
1482-
1483- protected List<Window> ViewportWindows {
1484- get {
1485- List<Window> windowList = new List<Window> ();
1486-
1487- Dictionary<string, List<Window>> processesList;
1488-
1489- WindowListItems.GetList (out processesList);
1490-
1491- //We need a list of every window in our current viewport only
1492- foreach (KeyValuePair<string, List<Window>> kvp in processesList) {
1493- foreach (Window w in kvp.Value) {
1494- if (w.IsInViewport (Screen.Default.ActiveWorkspace))
1495- windowList.Add (w);
1496- }
1497- }
1498-
1499- return windowList;
1500- }
1501- }
1502-
1503- protected List<Window> VisibleViewportWindows {
1504- get {
1505- return ViewportWindows.FindAll (delegate (Window w) { return !w.IsMinimized; });
1506- }
1507- }
1508- }
1509-
1510- public class ScreenTileAction : ScreenActionAction
1511- {
1512- public override string Name {
1513- get { return Catalog.GetString ("Tile Windows"); }
1514- }
1515-
1516- public override string Description {
1517- get { return Catalog.GetString ("Tile All Windows in Current Viewport"); }
1518- }
1519-
1520- public override string Icon {
1521- get { return "preferences-system-windows"; }
1522- }
1523-
1524- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1525- {
1526- List<Window> windowList = VisibleViewportWindows;
1527- Gdk.Rectangle screenGeo = DoModifyGeometry.GetScreenMinusPanelGeometry;
1528-
1529- //can't tile no windows
1530- if (windowList.Count <= 1) return null;
1531-
1532- int square, height, width;
1533-
1534- //We are going to tile to a square, so what we want is to find
1535- //the smallest perfect square all our windows will fit into
1536- square = (int) Math.Ceiling (Math.Sqrt (windowList.Count));
1537-
1538- //Our width will always be our perfect square
1539- width = square;
1540-
1541- //Our height is at least one (e.g. a 2x1)
1542- height = 1;
1543- while (width * height < windowList.Count) {
1544- height++;
1545- }
1546-
1547- int windowWidth, windowHeight;
1548- windowWidth = screenGeo.Width / width;
1549-
1550- windowHeight = screenGeo.Height / height;
1551-
1552- int row = 0, column = 0;
1553- int x, y;
1554-
1555- for (int i = 0; i < windowList.Count; i++) {
1556- x = (column * windowWidth) + screenGeo.X;
1557- y = (row * windowHeight) + screenGeo.Y;
1558-
1559- if (i == windowList.Count - 1) {
1560- DoModifyGeometry.SetWindowGeometry (windowList[i], x, y,
1561- windowHeight, screenGeo.Width - x, true);
1562- } else {
1563- DoModifyGeometry.SetWindowGeometry (windowList[i], x, y, windowHeight,
1564- windowWidth, true);
1565- }
1566-
1567- column++;
1568- if (column == width) {
1569- column = 0;
1570- row++;
1571- }
1572- }
1573-
1574- return null;
1575- }
1576-
1577- }
1578-
1579- public class ScreenCascadeAction : ScreenActionAction
1580- {
1581- public override string Name {
1582- get { return Catalog.GetString ("Cascade Windows"); }
1583- }
1584-
1585- public override string Description {
1586- get { return Catalog.GetString ("Cascade your Windows"); }
1587- }
1588-
1589- public override string Icon {
1590- get { return "preferences-system-windows"; }
1591- }
1592-
1593- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1594- {
1595- List<Window> windowList = VisibleViewportWindows;
1596-
1597- //can't tile no windows
1598- if (windowList.Count <= 1) return null;
1599-
1600- int width, height, offsetx, offsety;
1601-
1602- int xbuffer = 13;
1603- int ybuffer = 30;
1604- int winbuffer = 30;
1605-
1606- //we want to cascade here, so the idea is that for each window we
1607- //need to be able to create a buffer that is about the width of the
1608- //title bar. We will approximate this to around 30px. Therefor our
1609- //width and height need to be (30 * number of Windows) pixels
1610- //smaller than the screen. We will also offset by 100 on both
1611- //the x and y axis, so we should end as such. This needs to be
1612- //calculated for too.
1613-
1614- width = (Screen.Default.Width - (2 * xbuffer)) -
1615- (winbuffer * (windowList.Count - 1));
1616-
1617- height = (Screen.Default.Height - (2 * ybuffer)) -
1618- (winbuffer * (windowList.Count - 1));
1619-
1620- offsetx = xbuffer;
1621- offsety = ybuffer;
1622-
1623-
1624- foreach (Window w in windowList) {
1625- DoModifyGeometry.SetWindowGeometry (w, offsetx, offsety, height,
1626- width, true);
1627-
1628- offsetx += winbuffer;
1629- offsety += winbuffer;
1630- }
1631-
1632- return null;
1633- }
1634-
1635- }
1636-
1637- public class ScreenRestoreAction : ScreenActionAction
1638- {
1639- public override string Name {
1640- get { return Catalog.GetString ("Restore Windows"); }
1641- }
1642-
1643- public override string Description {
1644- get { return Catalog.GetString ("Restore Windows to their Previous Positions"); }
1645- }
1646-
1647- public override string Icon {
1648- get { return "preferences-system-windows"; }
1649- }
1650-
1651- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1652- {
1653- List<Window> windowList = new List<Window> ();
1654-
1655- Dictionary<string, List<Window>> processesList;
1656-
1657- WindowListItems.GetList (out processesList);
1658-
1659- foreach (KeyValuePair<string, List<Window>> kvp in processesList) {
1660- foreach (Window w in kvp.Value) {
1661- if (w.IsInViewport (Screen.Default.ActiveWorkspace))
1662- windowList.Add (w);
1663- }
1664- }
1665-
1666- foreach (Window w in windowList) {
1667- DoModifyGeometry.RestoreWindowGeometry (w);
1668- }
1669-
1670- return null;
1671- }
1672-
1673- }
1674-}
1675
1676=== added directory 'WindowManager/src/WindowActions'
1677=== added file 'WindowManager/src/WindowActions/WindowActionAction.cs'
1678--- WindowManager/src/WindowActions/WindowActionAction.cs 1970-01-01 00:00:00 +0000
1679+++ WindowManager/src/WindowActions/WindowActionAction.cs 2009-03-30 21:59:36 +0000
1680@@ -0,0 +1,80 @@
1681+// WindowActionAction.cs
1682+//
1683+// GNOME Do is the legal property of its developers. Please refer to the
1684+// COPYRIGHT file distributed with this
1685+// source distribution.
1686+//
1687+// This program is free software; you can redistribute it and/or modify
1688+// it under the terms of the GNU General Public License as published by
1689+// the Free Software Foundation; either version 2 of the License, or
1690+// (at your option) any later version.
1691+//
1692+// This program is distributed in the hope that it will be useful,
1693+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1694+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1695+// GNU General Public License for more details.
1696+//
1697+// You should have received a copy of the GNU General Public License
1698+// along with this program; if not, write to the Free Software
1699+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1700+//
1701+//
1702+
1703+using System;
1704+using System.Collections.Generic;
1705+using System.Linq;
1706+using System.Diagnostics;
1707+using System.Threading;
1708+
1709+using Do.Universe;
1710+using Do.Interface.Wink;
1711+
1712+using Wnck;
1713+using Mono.Unix;
1714+
1715+namespace WindowManager
1716+{
1717+
1718+ public abstract class WindowActionAction : Act
1719+ {
1720+ public override bool ModifierItemsOptional {
1721+ get { return true; }
1722+ }
1723+
1724+ public override IEnumerable<Type> SupportedItemTypes {
1725+ get { return new Type[] {
1726+ typeof (IApplicationItem),
1727+ typeof (IWindowItem),
1728+ };
1729+ }
1730+ }
1731+
1732+ public override bool SupportsItem (Item item)
1733+ {
1734+ if (item is IApplicationItem) {
1735+ string application = (item as IApplicationItem).Exec;
1736+ application = application.Split (new char[] {' '})[0];
1737+
1738+ return WindowUtils.WindowListForCmd (application).Any ();
1739+ } else if (item is IWindowItem) {
1740+ return true;
1741+ }
1742+ return false;
1743+ }
1744+
1745+ public abstract void Action (IEnumerable<Window> windows);
1746+
1747+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
1748+ {
1749+ IEnumerable<Wnck.Window> windows = null;
1750+ if (items.First () is IWindowItem)
1751+ windows = items.Cast<IWindowItem> ().SelectMany (wi => wi.Windows);
1752+ else if (items.First () is IApplicationItem)
1753+ windows = items.Cast<IApplicationItem> ().SelectMany (a => WindowUtils.WindowListForCmd (a.Exec));
1754+
1755+ if (windows != null)
1756+ Action (windows);
1757+ return null;
1758+ }
1759+ }
1760+}
1761
1762=== added file 'WindowManager/src/WindowActions/WindowCloseAction.cs'
1763--- WindowManager/src/WindowActions/WindowCloseAction.cs 1970-01-01 00:00:00 +0000
1764+++ WindowManager/src/WindowActions/WindowCloseAction.cs 2009-03-30 21:59:36 +0000
1765@@ -0,0 +1,50 @@
1766+//
1767+// Copyright (C) 2009 GNOME Do
1768+//
1769+// This program is free software: you can redistribute it and/or modify
1770+// it under the terms of the GNU General Public License as published by
1771+// the Free Software Foundation, either version 3 of the License, or
1772+// (at your option) any later version.
1773+//
1774+// This program is distributed in the hope that it will be useful,
1775+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1776+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1777+// GNU General Public License for more details.
1778+//
1779+// You should have received a copy of the GNU General Public License
1780+// along with this program. If not, see <http://www.gnu.org/licenses/>.
1781+//
1782+
1783+using System;
1784+using System.Collections.Generic;
1785+using System.Linq;
1786+
1787+using Do.Universe;
1788+using Do.Interface.Wink;
1789+
1790+using Wnck;
1791+using Mono.Unix;
1792+
1793+namespace WindowManager
1794+{
1795+
1796+ public class WindowCloseAction : WindowActionAction
1797+ {
1798+ public override string Name {
1799+ get { return Catalog.GetString ("Close"); }
1800+ }
1801+
1802+ public override string Description {
1803+ get { return Catalog.GetString ("Close selected windows."); }
1804+ }
1805+
1806+ public override string Icon {
1807+ get { return Gtk.Stock.Quit; }
1808+ }
1809+
1810+ public override void Action (IEnumerable<Window> windows)
1811+ {
1812+ WindowControl.CloseWindows (windows);
1813+ }
1814+ }
1815+}
1816
1817=== added file 'WindowManager/src/WindowActions/WindowMaximizeAction.cs'
1818--- WindowManager/src/WindowActions/WindowMaximizeAction.cs 1970-01-01 00:00:00 +0000
1819+++ WindowManager/src/WindowActions/WindowMaximizeAction.cs 2009-03-30 21:59:36 +0000
1820@@ -0,0 +1,53 @@
1821+//
1822+// Copyright (C) 2009 GNOME Do
1823+//
1824+// This program is free software: you can redistribute it and/or modify
1825+// it under the terms of the GNU General Public License as published by
1826+// the Free Software Foundation, either version 3 of the License, or
1827+// (at your option) any later version.
1828+//
1829+// This program is distributed in the hope that it will be useful,
1830+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1831+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1832+// GNU General Public License for more details.
1833+//
1834+// You should have received a copy of the GNU General Public License
1835+// along with this program. If not, see <http://www.gnu.org/licenses/>.
1836+//
1837+
1838+using System;
1839+using System.Collections.Generic;
1840+using System.Linq;
1841+
1842+using Do.Universe;
1843+using Do.Interface.Wink;
1844+
1845+using Wnck;
1846+using Mono.Unix;
1847+
1848+namespace WindowManager
1849+{
1850+
1851+
1852+ public class WindowMaximizeAction : WindowActionAction
1853+ {
1854+ public override string Name {
1855+ get { return Catalog.GetString ("Maximize"); }
1856+ }
1857+
1858+ public override string Description {
1859+ get { return Catalog.GetString ("Make a window consume the whole screen"); }
1860+ }
1861+
1862+ public override string Icon {
1863+ get { return "up"; }
1864+ }
1865+
1866+ public override void Action (IEnumerable<Window> windows)
1867+ {
1868+ if (!windows.Any ())
1869+ return;
1870+ WindowControl.MaximizeWindow (windows.First ());
1871+ }
1872+ }
1873+}
1874
1875=== added file 'WindowManager/src/WindowActions/WindowMinimizeAction.cs'
1876--- WindowManager/src/WindowActions/WindowMinimizeAction.cs 1970-01-01 00:00:00 +0000
1877+++ WindowManager/src/WindowActions/WindowMinimizeAction.cs 2009-03-30 21:59:36 +0000
1878@@ -0,0 +1,51 @@
1879+//
1880+// Copyright (C) 2009 GNOME Do
1881+//
1882+// This program is free software: you can redistribute it and/or modify
1883+// it under the terms of the GNU General Public License as published by
1884+// the Free Software Foundation, either version 3 of the License, or
1885+// (at your option) any later version.
1886+//
1887+// This program is distributed in the hope that it will be useful,
1888+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1889+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1890+// GNU General Public License for more details.
1891+//
1892+// You should have received a copy of the GNU General Public License
1893+// along with this program. If not, see <http://www.gnu.org/licenses/>.
1894+//
1895+
1896+using System;
1897+using System.Collections.Generic;
1898+using System.Linq;
1899+
1900+using Do.Universe;
1901+using Do.Interface.Wink;
1902+
1903+using Wnck;
1904+using Mono.Unix;
1905+
1906+namespace WindowManager
1907+{
1908+
1909+
1910+ public class WindowMinimizeAction : WindowActionAction
1911+ {
1912+ public override string Name {
1913+ get { return Catalog.GetString ("Minimize/Restore"); }
1914+ }
1915+
1916+ public override string Description {
1917+ get { return Catalog.GetString ("Minimize/Restore a Window"); }
1918+ }
1919+
1920+ public override string Icon {
1921+ get { return "down"; }
1922+ }
1923+
1924+ public override void Action (IEnumerable<Window> windows)
1925+ {
1926+ WindowControl.MinimizeRestoreWindows (windows);
1927+ }
1928+ }
1929+}
1930
1931=== added file 'WindowManager/src/WindowActions/WindowMoveAction.cs'
1932--- WindowManager/src/WindowActions/WindowMoveAction.cs 1970-01-01 00:00:00 +0000
1933+++ WindowManager/src/WindowActions/WindowMoveAction.cs 2009-03-31 16:23:38 +0000
1934@@ -0,0 +1,98 @@
1935+//
1936+// Copyright (C) 2009 GNOME Do
1937+//
1938+// This program is free software: you can redistribute it and/or modify
1939+// it under the terms of the GNU General Public License as published by
1940+// the Free Software Foundation, either version 3 of the License, or
1941+// (at your option) any later version.
1942+//
1943+// This program is distributed in the hope that it will be useful,
1944+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1945+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1946+// GNU General Public License for more details.
1947+//
1948+// You should have received a copy of the GNU General Public License
1949+// along with this program. If not, see <http://www.gnu.org/licenses/>.
1950+//
1951+
1952+using System;
1953+using System.Collections.Generic;
1954+using System.Linq;
1955+
1956+using Wnck;
1957+
1958+using Do.Platform;
1959+using Do.Universe;
1960+using Do.Interface.Wink;
1961+
1962+namespace WindowManager
1963+{
1964+
1965+
1966+ public class WindowMoveAction : WindowActionAction
1967+ {
1968+
1969+ public WindowMoveAction()
1970+ {
1971+ }
1972+
1973+ public override string Name {
1974+ get {
1975+ return "Move Window To...";
1976+ }
1977+ }
1978+
1979+ public override string Description {
1980+ get {
1981+ return "Move window to remote workspace";
1982+ }
1983+ }
1984+
1985+ public override string Icon {
1986+ get {
1987+ return "forward";
1988+ }
1989+ }
1990+
1991+ public override bool ModifierItemsOptional {
1992+ get {
1993+ return false;
1994+ }
1995+ }
1996+
1997+ public override IEnumerable<Type> SupportedModifierItemTypes {
1998+ get {
1999+ return new [] { typeof (IScreenItem) };
2000+ }
2001+ }
2002+
2003+ public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem)
2004+ {
2005+ return true;
2006+ }
2007+
2008+ public override void Action (IEnumerable<Window> windows)
2009+ {
2010+ // not used
2011+ }
2012+
2013+
2014+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
2015+ {
2016+ IScreenItem screen = modItems.First () as IScreenItem;
2017+
2018+ IEnumerable<Window> windows = null;
2019+ if (items.First () is IApplicationItem) {
2020+ windows = items.Cast<IApplicationItem> ().SelectMany (app => WindowUtils.WindowListForCmd (app.Exec));
2021+ } else if (items.First () is WindowItem) {
2022+ windows = items.Cast<WindowItem> ().SelectMany (wi => wi.Windows);
2023+ }
2024+
2025+ if (windows != null)
2026+ foreach (Wnck.Window window in windows)
2027+ screen.Viewport.MoveWindowInto (window);
2028+
2029+ return null;
2030+ }
2031+ }
2032+}
2033
2034=== modified file 'WindowManager/src/WindowItem.cs'
2035--- WindowManager/src/WindowItem.cs 2008-12-22 00:19:48 +0000
2036+++ WindowManager/src/WindowItem.cs 2009-03-30 00:03:03 +0000
2037@@ -21,32 +21,37 @@
2038 //
2039
2040 using System;
2041+using System.Collections.Generic;
2042+using System.Linq;
2043 using Wnck;
2044
2045+using Mono.Unix;
2046+
2047 using Do.Universe;
2048+using Do.Interface.Wink;
2049
2050 namespace WindowManager
2051 {
2052 public class WindowItem : Item, IWindowItem
2053 {
2054- Wnck.Window window;
2055+ List<Wnck.Window> windows;
2056 string icon;
2057
2058 public override string Name {
2059 get {
2060- return window.Name;
2061+ return windows.First ().Name;
2062 }
2063 }
2064
2065 public override string Description {
2066 get {
2067- return window.Name;
2068+ return windows.First ().Name;
2069 }
2070 }
2071
2072- public Wnck.Window Window {
2073+ public IEnumerable<Wnck.Window> Windows {
2074 get {
2075- return window;
2076+ return windows;
2077 }
2078 }
2079
2080@@ -58,40 +63,15 @@
2081
2082 public WindowItem(Window w, string icon)
2083 {
2084- this.window = w;
2085 this.icon = icon;
2086- }
2087-
2088- }
2089-
2090- public class ScreenItem : Item, IScreenItem
2091- {
2092- string name, description, icon;
2093-
2094- public override string Name {
2095- get {
2096- return name;
2097- }
2098- }
2099-
2100- public override string Description {
2101- get {
2102- return description;
2103- }
2104- }
2105-
2106- public override string Icon {
2107- get {
2108- return icon;
2109- }
2110- }
2111-
2112-
2113- public ScreenItem (string name, string description, string icon)
2114+ windows = new List<Window> ();
2115+ windows.Add (w);
2116+ }
2117+
2118+ public WindowItem(IEnumerable<Window> w, string icon)
2119 {
2120- this.name = name;
2121 this.icon = icon;
2122- this.description = description;
2123+ windows = new List<Window> (w);
2124 }
2125 }
2126 }
2127
2128=== modified file 'WindowManager/src/WindowItemSource.cs'
2129--- WindowManager/src/WindowItemSource.cs 2008-12-21 23:44:34 +0000
2130+++ WindowManager/src/WindowItemSource.cs 2009-03-30 00:03:03 +0000
2131@@ -22,8 +22,11 @@
2132
2133 using System;
2134 using System.Collections.Generic;
2135+using System.Linq;
2136
2137 using Do.Universe;
2138+using Do.Interface.Wink;
2139+
2140 using Wnck;
2141 using Mono.Unix;
2142
2143@@ -54,7 +57,8 @@
2144 public override IEnumerable<Type> SupportedItemTypes {
2145 get {
2146 return new Type [] {
2147- typeof (GenericWindowItem)};
2148+ typeof (IApplicationItem),
2149+ };
2150 }
2151 }
2152
2153@@ -67,33 +71,25 @@
2154 public WindowItemSource ()
2155 {
2156 items = new List<Item> ();
2157-
2158- items.Add (new GenericWindowItem (Catalog.GetString ("Current Window"),
2159- Catalog.GetString ("The Currently Active Window"),
2160- "gnome-window-manager",
2161- GenericWindowType.CurrentWindow));
2162- items.Add (new GenericWindowItem (Catalog.GetString ("Current Application"),
2163- Catalog.GetString ("The Currently Active Application"),
2164- "gnome-window-manager",
2165- GenericWindowType.CurrentApplication));
2166- items.Add (new GenericWindowItem (Catalog.GetString ("Previous Window"),
2167- Catalog.GetString ("The Previously Active Window"),
2168- "gnome-window-manager",
2169- GenericWindowType.PreviousWindow));
2170- items.Add (new GenericWindowItem (Catalog.GetString ("Previous Application"),
2171- Catalog.GetString ("The Previously Active Application"),
2172- "gnome-window-manager",
2173- GenericWindowType.PreviousApplication));
2174+ items.Add (new CurrentApplicationItem ());
2175+ items.Add (new CurrentWindowItem ());
2176 }
2177
2178 public override IEnumerable<Item> ChildrenOfItem (Item item)
2179 {
2180- return null;
2181- }
2182-
2183- public override void UpdateItems ()
2184- {
2185- return;
2186- }
2187+ List<Item> results = new List<Item> ();
2188+ IApplicationItem app = item as IApplicationItem;
2189+ if (app == null)
2190+ return results;
2191+
2192+ List<Wnck.Window> windows = WindowUtils.WindowListForCmd (app.Exec);
2193+ if (!windows.Any ())
2194+ return results;
2195+
2196+ foreach (Wnck.Window window in windows)
2197+ results.Add (new WindowItem (window, app.Icon));
2198+
2199+ return results;
2200+ }
2201 }
2202 }
2203
2204=== removed file 'WindowManager/src/WindowListAction.cs'
2205--- WindowManager/src/WindowListAction.cs 2009-03-20 23:05:29 +0000
2206+++ WindowManager/src/WindowListAction.cs 1970-01-01 00:00:00 +0000
2207@@ -1,276 +0,0 @@
2208-// WindowSwitchAction.cs
2209-//
2210-//GNOME Do is the legal property of its developers. Please refer to the
2211-//COPYRIGHT file distributed with this
2212-//source distribution.
2213-//
2214-// This program is free software; you can redistribute it and/or modify
2215-// it under the terms of the GNU General Public License as published by
2216-// the Free Software Foundation; either version 2 of the License, or
2217-// (at your option) any later version.
2218-//
2219-// This program is distributed in the hope that it will be useful,
2220-// but WITHOUT ANY WARRANTY; without even the implied warranty of
2221-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2222-// GNU General Public License for more details.
2223-//
2224-// You should have received a copy of the GNU General Public License
2225-// along with this program; if not, write to the Free Software
2226-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2227-//
2228-//
2229-
2230-using System;
2231-using System.Collections.Generic;
2232-using System.Linq;
2233-using System.Diagnostics;
2234-using System.Threading;
2235-
2236-using Do.Universe;
2237-using Do.Interface.Wink;
2238-
2239-using Wnck;
2240-using Mono.Unix;
2241-
2242-namespace WindowManager
2243-{
2244- //This code can't go without acknowledging the woman who made it all
2245- //possible. I know this file in itself is not much but it seemed
2246- //like a good place to put this. You have always supported me Kristin.
2247- //You have put up with the late nights of me hacking away at this and many
2248- //many other parts of Do. You showed amazing patience and you
2249- //have even showed interest from time to time. I love you baby girl.
2250- //Without you I never would have gotten this far.
2251-
2252- public class WindowActionAction : Act
2253- {
2254- protected Dictionary<string, List<Window>> procList;
2255- protected Dictionary<string, List<Window>> procListDyn;
2256- protected Dictionary<string, string> matchList;
2257- protected Screen scrn;
2258-
2259- public WindowActionAction()
2260- {
2261- Gtk.Application.Init ();
2262-
2263- scrn = Screen.Default;
2264-
2265- WindowListItems.GetList (out procList);
2266- WindowListItems.GetList (out procListDyn);
2267- matchList = new Dictionary<string,string> ();
2268-
2269- WindowListItems.ListUpdated += UpdateList;
2270- }
2271-
2272- public override string Name {
2273- get { return Catalog.GetString ("Action Window"); }
2274- }
2275-
2276- public override string Description {
2277- get { return Catalog.GetString ("Action a Window."); }
2278- }
2279-
2280- public override string Icon {
2281- get { return "eog"; } //fixme
2282- }
2283-
2284- public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem)
2285- {
2286- return true;
2287- }
2288-
2289- public override bool ModifierItemsOptional {
2290- get { return true; }
2291- }
2292-
2293- protected void UpdateList ()
2294- {
2295- WindowListItems.GetList (out procList);
2296- WindowListItems.GetList (out procListDyn);
2297- }
2298-
2299- public override IEnumerable<Type> SupportedModifierItemTypes {
2300- get { return new Type [] {
2301- typeof (IWindowItem)};
2302- }
2303- }
2304-
2305- public override IEnumerable<Item> DynamicModifierItemsForItem (Item item)
2306- {
2307- Item[] items;
2308-
2309- if (item is IApplicationItem) {
2310- string application = (item as IApplicationItem).Exec;
2311- application = application.Split (new char[] {' '})[0];
2312-
2313- if (!procList.ContainsKey (application)) return null;
2314-
2315- List<Window> winList;
2316- procList.TryGetValue(application, out winList);
2317-
2318- items = new Item[winList.Count];
2319- for (int i = 0; i < winList.Count; i++) {
2320- items[i] = new WindowItem (winList[i], item.Icon);
2321- }
2322- } else if (item.GetType () == typeof (GenericWindowItem)) {
2323- items = new Item [1];
2324-
2325- items[0] = new WindowItem (WindowListItems.CurrentWindow,
2326- "gnome-window-manager");
2327- } else {
2328- return null;
2329- }
2330- return items;
2331- }
2332-
2333- public override IEnumerable<Type> SupportedItemTypes {
2334- get { return new Type[] {
2335- typeof (IApplicationItem),
2336- typeof (GenericWindowItem) };
2337- }
2338- }
2339-
2340- public override bool SupportsItem (Item item)
2341- {
2342- if (item is GenericWindowItem) return true;
2343-
2344- if (!(item is IApplicationItem)) return false;
2345-
2346- string application = (item as IApplicationItem).Exec;
2347- application = application.Split (new char[] {' '})[0];
2348-
2349- return WindowUtils.GetApplicationList (application).Any ();
2350- }
2351-
2352- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
2353- {
2354- return null;
2355- }
2356- }
2357-
2358- //Most actions that are toggleable have identical logic for what to do with differnt types
2359- //of groups. So lets just put it all here.
2360- public abstract class WindowTogglableAction : WindowActionAction
2361- {
2362- public abstract void ToggleGroup (List<Window> windows);
2363- public abstract void ToggleWindow (Window window);
2364-
2365- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
2366- {
2367- if (modItems.Any ()) {
2368- Window w = (modItems.First () as WindowItem).Window;
2369-
2370- ToggleWindow (w);
2371- } else {
2372- if (items.First () is IApplicationItem) {
2373- List<Window> windows = new List<Window> ();
2374- foreach (Wnck.Application app in WindowUtils.GetApplicationList ((items.First () as IApplicationItem).Exec))
2375- windows.AddRange (app.Windows);
2376- ToggleGroup (windows);
2377- } else if (items.First () is GenericWindowItem) {
2378- GenericWindowItem generic;
2379- generic = (items.First () as GenericWindowItem);
2380-
2381- if (generic.WindowType == GenericWindowType.CurrentWindow) {
2382- ToggleWindow (WindowListItems.CurrentWindow);
2383- } else if (generic.WindowType == GenericWindowType.CurrentApplication) {
2384- ToggleGroup (WindowListItems.CurrentApplication);
2385- } else if (generic.WindowType == GenericWindowType.PreviousWindow) {
2386- ToggleWindow (WindowListItems.PreviousWindow);
2387- } else if (generic.WindowType == GenericWindowType.PreviousApplication) {
2388- ToggleGroup (WindowListItems.PreviousApplication);
2389- }
2390- }
2391- }
2392-
2393- return null;
2394- }
2395-
2396- }
2397-
2398- public class WindowMaximizeAction : WindowTogglableAction
2399- {
2400- public override string Name {
2401- get { return Catalog.GetString ("Maximize"); }
2402- }
2403-
2404- public override string Description {
2405- get { return Catalog.GetString ("Make a window consume the whole screen"); }
2406- }
2407-
2408- public override string Icon {
2409- get { return "up"; }
2410- }
2411-
2412- public override void ToggleGroup (List<Window> windows)
2413- {
2414- if (!windows.Any ())
2415- return;
2416- WindowControl.MaximizeWindow (windows.First ());
2417- }
2418-
2419- public override void ToggleWindow (Window window)
2420- {
2421- WindowControl.MaximizeWindow (window);
2422- }
2423- }
2424-
2425- public class WindowMinimizeAction : WindowTogglableAction
2426- {
2427- public override string Name {
2428- get { return Catalog.GetString ("Minimize/Restore"); }
2429- }
2430-
2431- public override string Description {
2432- get { return Catalog.GetString ("Minimize/Restore a Window"); }
2433- }
2434-
2435- public override string Icon {
2436- get { return "down"; }
2437- }
2438-
2439- public override void ToggleWindow (Window window)
2440- {
2441- WindowControl.MinimizeRestoreWindows (window);
2442- }
2443-
2444- public override void ToggleGroup (List<Window> windows)
2445- {
2446- WindowControl.MinimizeRestoreWindows (windows);
2447- }
2448- }
2449-
2450- public class WindowCloseAction : WindowActionAction
2451- {
2452- public override string Name {
2453- get { return Catalog.GetString ("Close All"); }
2454- }
2455-
2456- public override string Description {
2457- get { return Catalog.GetString ("Close your current window."); }
2458- }
2459-
2460- public override string Icon {
2461- get { return Gtk.Stock.Quit; }
2462- }
2463-
2464- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
2465- {
2466- if (modItems.Any ()) {
2467- Wnck.Window w = (modItems.First () as WindowItem).Window;
2468-
2469- w.Close (Gtk.Global.CurrentEventTime);
2470- } else {
2471- if (items.First () is IApplicationItem) {
2472- string application = (items.First () as IApplicationItem).Exec;
2473- List<Application> apps = WindowUtils.GetApplicationList (application);
2474-
2475- WindowControl.CloseWindows (apps.SelectMany (app => app.Windows));
2476-
2477- }
2478- }
2479- return null;
2480- }
2481-
2482- }
2483-}
2484
2485=== removed file 'WindowManager/src/WindowListItems.cs'
2486--- WindowManager/src/WindowListItems.cs 2008-06-19 02:52:35 +0000
2487+++ WindowManager/src/WindowListItems.cs 1970-01-01 00:00:00 +0000
2488@@ -1,205 +0,0 @@
2489-// WindowListItems.cs
2490-//
2491-//GNOME Do is the legal property of its developers. Please refer to the
2492-//COPYRIGHT file distributed with this
2493-//source distribution.
2494-//
2495-// This program is free software; you can redistribute it and/or modify
2496-// it under the terms of the GNU General Public License as published by
2497-// the Free Software Foundation; either version 2 of the License, or
2498-// (at your option) any later version.
2499-//
2500-// This program is distributed in the hope that it will be useful,
2501-// but WITHOUT ANY WARRANTY; without even the implied warranty of
2502-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2503-// GNU General Public License for more details.
2504-//
2505-// You should have received a copy of the GNU General Public License
2506-// along with this program; if not, write to the Free Software
2507-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2508-//
2509-//
2510-
2511-using System;
2512-using System.Collections.Generic;
2513-using System.Diagnostics;
2514-using System.Threading;
2515-
2516-using Do.Universe;
2517-using Wnck;
2518-
2519-namespace WindowManager
2520-{
2521- public class WindowListItems
2522- {
2523- private static Dictionary<string, List<Window>> windowList;
2524- private static Wnck.Screen scrn;
2525- private static object listLock = new object ();
2526- private static Window currentWindow;
2527- private static Window previousWindow;
2528-
2529- public static Window CurrentWindow {
2530- get {
2531- return currentWindow;
2532- }
2533- }
2534-
2535- public static Window PreviousWindow {
2536- get {
2537- return previousWindow;
2538- }
2539- }
2540-
2541- public static List<Window> CurrentApplication {
2542- get {
2543- int pid;
2544- List<Window> outList;
2545-
2546- pid = CurrentWindow.Pid;
2547- outList = new List<Window> ();
2548-
2549- foreach (Window w in scrn.WindowsStacked) {
2550- if (w.Pid == pid && !w.IsSkipTasklist)
2551- outList.Add(w);
2552- }
2553-
2554- return outList;
2555- }
2556- }
2557-
2558- public static List<Window> PreviousApplication {
2559- get {
2560- int pid;
2561- List<Window> outList;
2562-
2563- pid = PreviousWindow.Pid;
2564- outList = new List<Window> ();
2565-
2566- foreach (Window w in scrn.WindowsStacked) {
2567- if (w.Pid == pid && !w.IsSkipTasklist)
2568- outList.Add(w);
2569- }
2570-
2571- return outList;
2572- }
2573- }
2574-
2575- static WindowListItems ()
2576- {
2577- Gtk.Application.Init (); //why do i HAVE to do this?
2578-
2579- windowList = new Dictionary<string,List<Window>> ();
2580-
2581- scrn = Screen.Default;
2582- scrn.WindowOpened += OnWindowOpened;
2583- scrn.WindowClosed += OnWindowClosed;
2584- scrn.ActiveWindowChanged += OnActiveWindowChanged;
2585- }
2586-
2587- public static void GetList (out Dictionary<string, List<Window>> winList)
2588- {
2589- winList = new Dictionary<string,List<Window>> ();
2590-
2591- foreach (KeyValuePair<string, List<Window>> kvp in windowList) {
2592- winList.Add (kvp.Key, kvp.Value);
2593- }
2594- }
2595-
2596- public static List<Window> GetApplication (string application)
2597- {
2598- List<Window> windows;
2599-
2600- windowList.TryGetValue (application, out windows);
2601-
2602- return windows;
2603- }
2604-
2605- private static void OnActiveWindowChanged (object o, ActiveWindowChangedArgs args)
2606- {
2607- try {
2608- if (!scrn.ActiveWindow.IsSkipTasklist) {
2609- previousWindow = currentWindow;
2610- currentWindow = scrn.ActiveWindow;
2611- }
2612- }
2613- catch {
2614-
2615- }
2616- }
2617-
2618- private static void OnWindowOpened (object o, WindowOpenedArgs args)
2619- {
2620- if (args.Window.IsSkipTasklist) return;
2621-
2622- // there is a reason, but its stupid and unimportant. Wnck reports a window
2623- // open/close event if things minimize/restore really fast. The window also gets
2624- // temporarily dropped from the list for some reason. To account for this, a 2 second
2625- // lag on our updates lets Wnck unfuck itself.
2626- GLib.Timeout.Add (2000, delegate {
2627- Thread updateRunner = new Thread (new ThreadStart (UpdateList));
2628-
2629- updateRunner.Start ();
2630- return false;
2631- });
2632- }
2633-
2634- private static void OnWindowClosed (object o, WindowClosedArgs args)
2635- {
2636- if (args.Window.IsSkipTasklist) return;
2637-
2638- // there is a reason, see above
2639- GLib.Timeout.Add (2000, delegate {
2640- Thread updateRunner = new Thread (new ThreadStart (UpdateList));
2641-
2642- updateRunner.Start ();
2643- return false;
2644- });
2645- }
2646-
2647- private static void UpdateList ()
2648- {
2649- if (!Monitor.TryEnter (listLock))
2650- return;
2651-
2652- windowList.Clear ();
2653-
2654- ProcessStartInfo st = new ProcessStartInfo ("ps");
2655- st.RedirectStandardOutput = true;
2656- st.UseShellExecute = false;
2657-
2658- Process process;
2659- string processName;
2660-
2661- foreach (Window w in scrn.WindowsStacked) {
2662- if (w.Pid == 0) continue;
2663-
2664- if (w.IsSkipTasklist) continue;
2665-
2666- st.Arguments = "c -o cmd --no-headers " + w.Pid;
2667-
2668- process = Process.Start (st);
2669-
2670- process.WaitForExit (2000);
2671- if (process.ExitCode != 0) continue;
2672-
2673- processName = process.StandardOutput.ReadLine ();
2674- if (windowList.ContainsKey (processName)) {
2675- List<Window> winList;
2676- windowList.TryGetValue (processName, out winList);
2677- winList.Add (w);
2678- } else {
2679- List<Window> winList = new List<Window> ();
2680- winList.Add (w);
2681- windowList.Add (processName, winList);
2682- }
2683- }
2684-
2685- ListUpdated ();
2686- Monitor.Exit (listLock);
2687- }
2688-
2689- public static event ListUpdatedDelegate ListUpdated;
2690-
2691- public delegate void ListUpdatedDelegate ();
2692- }
2693-}

Subscribers

People subscribed via source and target branches