Do

Merge lp:~psybers/do/escape-painters into lp:do

Proposed by Robert Dyer
Status: Merged
Approved by: Alex Launi
Approved revision: 1295
Merged at revision: 1294
Proposed branch: lp:~psybers/do/escape-painters
Merge into: lp:do
Diff against target: None lines
To merge this branch: bzr merge lp:~psybers/do/escape-painters
Reviewer Review Type Date Requested Status
Robert Dyer (community) Approve
Review via email: mp+10361@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Dyer (psybers) wrote :

Let's painters close by pressing the Escape key (or whatever key 'Clear' is bound to by the user).

Moved the KeyEventToString method into the key services, as it was needed in Docky and seems logical.

lp:~psybers/do/escape-painters updated
1295. By Robert Dyer <rdyer@yamuna>

cleaning the code for cszikszoy

Revision history for this message
Robert Dyer (psybers) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs'
2--- Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-06-17 04:41:30 +0000
3+++ Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-08-19 07:27:08 +0000
4@@ -276,6 +276,8 @@
5 DnDTracker.DragEnded += HandleDragEnded;
6 DnDTracker.DrawRequired += HandleDrawRequired;
7
8+ window.KeyPressEvent += HandleKeyPressEvent;
9+
10 StyleSet += (o, a) => {
11 if (IsRealized)
12 GdkWindow.SetBackPixmap (null, false);
13@@ -308,6 +310,8 @@
14
15 DnDTracker.DragEnded -= HandleDragEnded;
16 DnDTracker.DrawRequired -= HandleDrawRequired;
17+
18+ window.KeyPressEvent -= HandleKeyPressEvent;
19 }
20
21 void BuildAnimationStateEngine ()
22@@ -333,6 +337,16 @@
23 DateTime.UtcNow - showhide_time < SummonTime);
24 }
25
26+ void HandleKeyPressEvent (Gdk.EventKey key)
27+ {
28+ KeyBinding clearKeyBinding = null;
29+ if (Services.Keybinder.Bindings.Where(p => p.Description == Mono.Unix.Catalog.GetString ("Clear")).Any())
30+ clearKeyBinding = Services.Keybinder.Bindings.Where(p => p.Description == Mono.Unix.Catalog.GetString ("Clear")).First();
31+ if (PainterOverlayVisible &&
32+ clearKeyBinding != null && Services.Keybinder.KeyEventToString (key) == clearKeyBinding.KeyString)
33+ InterruptPainter ();
34+ }
35+
36 void HandleCursorUpdated (object sender, CursorUpdatedArgs args)
37 {
38 if (PopupMenu.Visible)
39
40=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs'
41--- Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs 2009-06-21 02:20:30 +0000
42+++ Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs 2009-08-19 07:27:08 +0000
43@@ -194,7 +194,7 @@
44
45 protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
46 {
47- if (Visible)
48+ if (Visible || dock_area.PainterOverlayVisible)
49 KeyPressEvent (evnt);
50 return base.OnKeyPressEvent (evnt);
51 }
52
53=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs'
54--- Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-08-08 05:48:10 +0000
55+++ Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-08-19 07:27:08 +0000
56@@ -96,6 +96,37 @@
57
58 return true;
59 }
60+
61+ /// <summary>
62+ /// Converts a keypress into a human readable string for comparing
63+ /// against values in GConf.
64+ /// </summary>
65+ /// <param name="evnt">
66+ /// A <see cref="EventKey"/>
67+ /// </param>
68+ /// <returns>
69+ /// A <see cref="System.String"/> in the form "<Modifier>key"
70+ /// </returns>
71+ public string KeyEventToString (Gdk.EventKey evnt) {
72+ string modifier = "";
73+ if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
74+ modifier += "<Control>";
75+ }
76+ if ((evnt.State & Gdk.ModifierType.SuperMask) != 0) {
77+ modifier += "<Super>";
78+ }
79+ if ((evnt.State & Gdk.ModifierType.Mod1Mask) != 0) {
80+ modifier += "<Alt>";
81+ }
82+ if ((evnt.State & Gdk.ModifierType.ShiftMask) != 0) {
83+ modifier += "<Shift>";
84+ //if we're pressing shift, and the key is ISO_Left_Tab,
85+ //just make it Tab
86+ if (evnt.Key == Gdk.Key.ISO_Left_Tab)
87+ return string.Format ("{0}{1}", modifier, Gdk.Key.Tab);
88+ }
89+ return string.Format ("{0}{1}", modifier, Gtk.Accelerator.Name (evnt.KeyValue, Gdk.ModifierType.None));
90+ }
91 #endregion
92 }
93-}
94\ No newline at end of file
95+}
96
97=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs'
98--- Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 2009-07-27 01:25:19 +0000
99+++ Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 2009-08-19 07:27:08 +0000
100@@ -16,6 +16,9 @@
101 public bool SetKeyString (KeyBinding binding, string keyString) {
102 return false;
103 }
104+ public string KeyEventToString (Gdk.EventKey evnt) {
105+ return "";
106+ }
107 public List<KeyBinding> Bindings { get { return new List<KeyBinding> (); } }
108 public void Initialize () {
109 }
110
111=== modified file 'Do.Platform/src/Do.Platform/IKeyBindingService.cs'
112--- Do.Platform/src/Do.Platform/IKeyBindingService.cs 2009-07-27 01:25:19 +0000
113+++ Do.Platform/src/Do.Platform/IKeyBindingService.cs 2009-08-19 07:27:08 +0000
114@@ -15,5 +15,6 @@
115 bool RegisterKeyBinding (KeyBinding evnt);
116 bool SetKeyString (KeyBinding binding, string keyString);
117 List<KeyBinding> Bindings { get; }
118+ string KeyEventToString (EventKey evnt);
119 }
120 }
121
122=== modified file 'Do/src/Do.Core/Controller.cs'
123--- Do/src/Do.Core/Controller.cs 2009-08-09 00:54:16 +0000
124+++ Do/src/Do.Core/Controller.cs 2009-08-19 07:27:08 +0000
125@@ -465,9 +465,9 @@
126 } else if (key == Key.Delete ||
127 key == Key.BackSpace) {
128 OnDeleteKeyPressEvent (evnt);
129- } else if (Services.Keybinder.Bindings.Any (k => k.KeyString == KeyEventToString (evnt))) {
130+ } else if (Services.Keybinder.Bindings.Any (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt))) {
131 // User set keybindings
132- Services.Keybinder.Bindings.First (k => k.KeyString == KeyEventToString (evnt)).Callback (evnt);
133+ Services.Keybinder.Bindings.First (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt)).Callback (evnt);
134 } else {
135 OnInputKeyPressEvent (evnt);
136 }
137@@ -704,37 +704,6 @@
138 im_context.Reset ();
139 SearchController.Cursor += 5;
140 }
141-
142- /// <summary>
143- /// Converts a keypress into a human readable string for comparing
144- /// against values in GConf.
145- /// </summary>
146- /// <param name="evnt">
147- /// A <see cref="EventKey"/>
148- /// </param>
149- /// <returns>
150- /// A <see cref="System.String"/> in the form "<Modifier>key"
151- /// </returns>
152- string KeyEventToString (EventKey evnt) {
153- string modifier = "";
154- if ((evnt.State & ModifierType.ControlMask) != 0) {
155- modifier += "<Control>";
156- }
157- if ((evnt.State & ModifierType.SuperMask) != 0) {
158- modifier += "<Super>";
159- }
160- if ((evnt.State & ModifierType.Mod1Mask) != 0) {
161- modifier += "<Alt>";
162- }
163- if ((evnt.State & ModifierType.ShiftMask) != 0) {
164- modifier += "<Shift>";
165- //if we're pressing shift, and the key is ISO_Left_Tab,
166- //just make it Tab
167- if (evnt.Key == Key.ISO_Left_Tab)
168- return string.Format ("{0}{1}", modifier, Key.Tab);
169- }
170- return string.Format ("{0}{1}", modifier, Gtk.Accelerator.Name (evnt.KeyValue, Gdk.ModifierType.None));
171- }
172 #endregion
173
174 /// <summary>