Merge lp:~jassmith/do/docky-file-drag-and-drop into lp:do
- docky-file-drag-and-drop
- Merge into trunk
Proposed by
Jason Smith
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~jassmith/do/docky-file-drag-and-drop |
Merge into: | lp:do |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~jassmith/do/docky-file-drag-and-drop |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Launi (community) | Approve | ||
Review via email: mp+6233@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
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.Core/Docky.Core.Default/ItemsService.cs' |
2 | --- Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/ItemsService.cs 2009-04-28 08:08:21 +0000 |
3 | +++ Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/ItemsService.cs 2009-05-05 03:44:50 +0000 |
4 | @@ -259,7 +259,13 @@ |
5 | } |
6 | if (writeable && Path.GetDirectoryName (identifier) != DesktopFilesDirectory) { |
7 | string newFile = Path.Combine (DesktopFilesDirectory, Path.GetFileName (identifier)); |
8 | - File.Copy (identifier, newFile); |
9 | + try { |
10 | + Log<ItemsService>.Error ("Could not add custom item with id: {0}, File already exists", identifier); |
11 | + File.Copy (identifier, newFile); |
12 | + } catch { |
13 | + |
14 | + return null; |
15 | + } |
16 | identifier = newFile; |
17 | } |
18 | Item o = Services.UniverseFactory.NewApplicationItem (identifier) as Item; |
19 | @@ -307,8 +313,8 @@ |
20 | |
21 | Dictionary<string, int> sortDictionary = ReadSortDictionary (); |
22 | foreach (ItemDockItem item in OrderedItems.Where (di => di is ItemDockItem)) { |
23 | - if (sortDictionary.ContainsKey (item.Element.UniqueId)) |
24 | - item.Position = sortDictionary [item.Element.UniqueId]; |
25 | + if (sortDictionary.ContainsKey (item.Item.UniqueId)) |
26 | + item.Position = sortDictionary [item.Item.UniqueId]; |
27 | } |
28 | |
29 | CustomItemsRead = true; |
30 | @@ -336,11 +342,11 @@ |
31 | |
32 | DateTime currentTime = DateTime.UtcNow; |
33 | foreach (Item item in mostUsedItems) { |
34 | - if (local_cust.Any (di => di.Element.UniqueId == item.UniqueId)) |
35 | + if (local_cust.Any (di => di.Item.UniqueId == item.UniqueId)) |
36 | continue; |
37 | |
38 | - if (old_items.Any (di => di.Element == item)) { |
39 | - stat_items.AddRange (old_items.Where (di => di.Element.UniqueId == item.UniqueId).Cast<AbstractDockItem> ()); |
40 | + if (old_items.Any (di => di.Item == item)) { |
41 | + stat_items.AddRange (old_items.Where (di => di.Item.UniqueId == item.UniqueId).Cast<AbstractDockItem> ()); |
42 | } else { |
43 | ItemDockItem di = new ItemDockItem (item); |
44 | RegisterDockItem (di); |
45 | @@ -482,7 +488,7 @@ |
46 | |
47 | using (StreamWriter writer = new StreamWriter (SortDictionaryPath)) { |
48 | foreach (ItemDockItem di in OrderedItems.Where (di => di is ItemDockItem)) { |
49 | - writer.WriteLine ("{0}|{1}", di.Element.UniqueId, di.Position); |
50 | + writer.WriteLine ("{0}|{1}", di.Item.UniqueId, di.Position); |
51 | } |
52 | } |
53 | } catch (Exception e) { |
54 | @@ -750,7 +756,7 @@ |
55 | |
56 | if (DockItems [item].WindowCount == 0) { |
57 | if (GetIconSource (DockItems [item]) == IconSource.Statistics && DockItems [item] is ItemDockItem) { |
58 | - DockPreferences.AddBlacklistItem ((DockItems [item] as ItemDockItem).Element.UniqueId); |
59 | + DockPreferences.AddBlacklistItem ((DockItems [item] as ItemDockItem).Item.UniqueId); |
60 | DockPreferences.AutomaticIcons = Math.Max (0, DockPreferences.AutomaticIcons - 1); |
61 | UpdateItems (); |
62 | ret_val = true; |
63 | |
64 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/AutohideTracker.cs' |
65 | --- Do.Interface.Linux.Docky/src/Docky.Interface/AutohideTracker.cs 2009-05-02 18:42:09 +0000 |
66 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/AutohideTracker.cs 2009-05-05 07:59:11 +0000 |
67 | @@ -57,6 +57,18 @@ |
68 | { |
69 | this.parent = parent; |
70 | Wnck.Screen.Default.ActiveWindowChanged += HandleActiveWindowChanged; |
71 | + Wnck.Screen.Default.WindowClosed += WnckScreenDefaultWindowClosed; |
72 | + Wnck.Screen.Default.WindowOpened += WnckScreenDefaultWindowOpened; |
73 | + } |
74 | + |
75 | + void WnckScreenDefaultWindowOpened (object o, WindowOpenedArgs args) |
76 | + { |
77 | + UpdateWindowIntersect (); |
78 | + } |
79 | + |
80 | + void WnckScreenDefaultWindowClosed (object o, WindowClosedArgs args) |
81 | + { |
82 | + UpdateWindowIntersect (); |
83 | } |
84 | |
85 | void HandleGeometryChanged (object sender, EventArgs e) |
86 | |
87 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs' |
88 | --- Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-05-03 00:32:23 +0000 |
89 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-05-05 06:30:38 +0000 |
90 | @@ -381,7 +381,7 @@ |
91 | window.Reposition (); |
92 | } |
93 | |
94 | - void HandleSizeChanged(object sender, EventArgs e) |
95 | + void HandleSizeChanged (object sender, EventArgs e) |
96 | { |
97 | Reconfigure (); |
98 | } |
99 | @@ -400,7 +400,7 @@ |
100 | AnimatedDraw (); |
101 | } |
102 | |
103 | - void HandleUniverseInitialized(object sender, EventArgs e) |
104 | + void HandleUniverseInitialized (object sender, EventArgs e) |
105 | { |
106 | GLib.Timeout.Add (2000, delegate { |
107 | DockServices.ItemsService.ForceUpdate (); |
108 | |
109 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_DragAndDrop.cs' |
110 | --- Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_DragAndDrop.cs 2009-04-28 07:15:19 +0000 |
111 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_DragAndDrop.cs 2009-05-05 06:30:38 +0000 |
112 | @@ -60,10 +60,16 @@ |
113 | Gdk.CursorType cursor_type; |
114 | |
115 | Gdk.Window drag_proxy; |
116 | + |
117 | + Gdk.DragContext drag_context; |
118 | |
119 | + IEnumerable<string> uri_list; |
120 | + |
121 | DragState DragState { get; set; } |
122 | |
123 | bool GtkDragging { get; set; } |
124 | + |
125 | + bool PreviewIsDesktopFile { get; set; } |
126 | |
127 | bool CursorNearTopDraggableEdge { |
128 | get { |
129 | @@ -106,14 +112,14 @@ |
130 | void RegisterGtkDragSource () |
131 | { |
132 | gtk_drag_source_set = true; |
133 | - TargetEntry te = new TargetEntry ("text/uri-list", TargetFlags.OtherApp, 0); |
134 | + TargetEntry te = new TargetEntry ("text/uri-list", TargetFlags.OtherApp | TargetFlags.App, 0); |
135 | Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask, new [] {te}, DragAction.Copy); |
136 | } |
137 | |
138 | void RegisterGtkDragDest () |
139 | { |
140 | TargetEntry dest_te = new TargetEntry ("text/uri-list", 0, 0); |
141 | - Gtk.Drag.DestSet (this, DestDefaults.Motion | DestDefaults.Drop, new [] {dest_te}, Gdk.DragAction.Copy); |
142 | + Gtk.Drag.DestSet (this, 0, new [] {dest_te}, Gdk.DragAction.Copy); |
143 | } |
144 | |
145 | void UnregisterGtkDragSource () |
146 | @@ -155,8 +161,9 @@ |
147 | |
148 | void DragCursorUpdate () |
149 | { |
150 | - if (GtkDragging && (CursorModifier & ModifierType.Button1Mask) != ModifierType.Button1Mask) |
151 | + if (GtkDragging && (CursorModifier & ModifierType.Button1Mask) != ModifierType.Button1Mask) { |
152 | GtkDragging = false; |
153 | + } |
154 | SetDragProxy (); |
155 | } |
156 | |
157 | @@ -178,36 +185,61 @@ |
158 | } while (false); |
159 | |
160 | AnimatedDraw (); |
161 | - return base.OnDragMotion (context, x, y, time); |
162 | + |
163 | + if (drag_context != context) { |
164 | + Gdk.Atom target = Gtk.Drag.DestFindTarget (this, context, null); |
165 | + Gtk.Drag.GetData (this, context, target, Gtk.Global.CurrentEventTime); |
166 | + drag_context = context; |
167 | + } |
168 | + |
169 | + Gdk.Drag.Status (context, DragAction.Copy, time); |
170 | + base.OnDragMotion (context, x, y, time); |
171 | + return true; |
172 | + } |
173 | + |
174 | + protected override bool OnDragDrop (Gdk.DragContext context, int x, int y, uint time) |
175 | + { |
176 | + int index = PositionProvider.IndexAtPosition (Cursor); |
177 | + if (CursorIsOverDockArea && index >= 0 && index < DockItems.Count) { |
178 | + foreach (string uri in uri_list) { |
179 | + if (CurrentDockItem != null && CurrentDockItem.IsAcceptingDrops && !uri.EndsWith (".desktop")) { |
180 | + CurrentDockItem.ReceiveItem (uri); |
181 | + } else { |
182 | + Gdk.Point center = PositionProvider.IconUnzoomedPosition (index); |
183 | + if (center.X < Cursor.X && index < DockItems.Count - 1) |
184 | + index++; |
185 | + DockServices.ItemsService.AddItemToDock (uri, index); |
186 | + } |
187 | + } |
188 | + } |
189 | + |
190 | + Gtk.Drag.Finish (context, true, true, time); |
191 | + return base.OnDragDrop (context, x, y, time); |
192 | } |
193 | |
194 | protected override void OnDragDataReceived (Gdk.DragContext context, int x, int y, |
195 | Gtk.SelectionData selectionData, uint info, uint time) |
196 | { |
197 | - if (!CursorIsOverDockArea) return; |
198 | - |
199 | - string data = System.Text.Encoding.UTF8.GetString ( selectionData.Data ); |
200 | - data = System.Uri.UnescapeDataString (data); |
201 | - //sometimes we get a null at the end, and it crashes us |
202 | - data = data.TrimEnd ('\0'); |
203 | - |
204 | - IEnumerable<string> uriList = Regex.Split (data, "\r\n") |
205 | - .Where (uri => uri.StartsWith ("file://")) |
206 | - .Select (uri => uri.Substring ("file://".Length)); |
207 | - |
208 | - if (CurrentDockItem != null && CurrentDockItem.IsAcceptingDrops) { |
209 | - uriList.ForEach (uri => CurrentDockItem.ReceiveItem (uri)); |
210 | - } else { |
211 | - int index = PositionProvider.IndexAtPosition (Cursor); |
212 | - Gdk.Point center = PositionProvider.IconUnzoomedPosition (index); |
213 | - if (center.X < Cursor.X) |
214 | - index++; |
215 | - uriList.ForEach (uri => DockServices.ItemsService.AddItemToDock (uri, index)); |
216 | + IEnumerable<string> uriList; |
217 | + try { |
218 | + string data = System.Text.Encoding.UTF8.GetString (selectionData.Data); |
219 | + data = System.Uri.UnescapeDataString (data); |
220 | + //sometimes we get a null at the end, and it crashes us |
221 | + data = data.TrimEnd ('\0'); |
222 | + |
223 | + uriList = Regex.Split (data, "\r\n") |
224 | + .Where (uri => uri.StartsWith ("file://")) |
225 | + .Select (uri => uri.Substring ("file://".Length)); |
226 | + } catch { |
227 | + uriList = Enumerable.Empty<string> (); |
228 | } |
229 | |
230 | + |
231 | + uri_list = uriList; |
232 | + |
233 | + PreviewIsDesktopFile = !uriList.Any () || uriList.Any (s => s.EndsWith (".desktop")); |
234 | + |
235 | base.OnDragDataReceived (context, x, y, selectionData, info, time); |
236 | - GtkDragging = false; |
237 | - SetDragProxy (); |
238 | } |
239 | |
240 | protected override void OnDragBegin (Gdk.DragContext context) |
241 | @@ -235,7 +267,6 @@ |
242 | |
243 | protected override void OnDragEnd (Gdk.DragContext context) |
244 | { |
245 | - |
246 | if (CursorIsOverDockArea) { |
247 | int currentPosition = PositionProvider.IndexAtPosition (Cursor); |
248 | if (currentPosition != -1) |
249 | @@ -243,13 +274,15 @@ |
250 | } else { |
251 | DockServices.ItemsService.RemoveItem (DragState.DragItem); |
252 | } |
253 | + |
254 | DragState.IsFinished = true; |
255 | GtkDragging = false; |
256 | + SetDragProxy (); |
257 | |
258 | AnimatedDraw (); |
259 | base.OnDragEnd (context); |
260 | } |
261 | - |
262 | + |
263 | void BuildDragAndDrop () |
264 | { |
265 | cursor_type = CursorType.LeftPtr; |
266 | @@ -302,13 +335,8 @@ |
267 | { |
268 | drag_edge = DragEdge.None; |
269 | drag_resizing = false; |
270 | - SetIconRegions (); |
271 | - window.SetStruts (); |
272 | - |
273 | - AnimatedDraw (); |
274 | |
275 | ResetCursorTimer (); |
276 | - |
277 | Reconfigure (); |
278 | } |
279 | |
280 | |
281 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_Rendering.cs' |
282 | --- Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_Rendering.cs 2009-05-02 19:07:49 +0000 |
283 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_Rendering.cs 2009-05-05 06:30:38 +0000 |
284 | @@ -68,9 +68,8 @@ |
285 | |
286 | bool CanFastRender { |
287 | get { |
288 | - bool result = next_fast_render; |
289 | - next_fast_render = !RenderData.ForceFullRender && |
290 | - RenderData.ZoomIn == 1 && |
291 | + bool result = next_fast_render && !RenderData.ForceFullRender; |
292 | + next_fast_render = RenderData.ZoomIn == 1 && |
293 | ZoomIn == 1 && |
294 | !AnimationState [Animations.IconInsert] && |
295 | !AnimationState [Animations.UrgencyChanged] && |
296 | @@ -407,7 +406,7 @@ |
297 | iconPosition.X / scale, iconPosition.Y / scale); |
298 | cr.PaintWithAlpha (fadeInOpacity); |
299 | |
300 | - bool shade_light = GtkDragging && |
301 | + bool shade_light = GtkDragging && !PreviewIsDesktopFile && CursorIsOverDockArea && |
302 | dockItem.IsAcceptingDrops && icon == PositionProvider.IndexAtPosition (Cursor); |
303 | |
304 | bool shade_dark = animationType == ClickAnimationType.Darken; |
305 | @@ -692,8 +691,9 @@ |
306 | |
307 | void RequestFullRender () |
308 | { |
309 | - if (RenderData != null) |
310 | + if (RenderData != null) { |
311 | RenderData.ForceFullRender = true; |
312 | + } |
313 | } |
314 | |
315 | void ResetBuffers() |
316 | |
317 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/AbstractDockItem.cs' |
318 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/AbstractDockItem.cs 2009-05-02 18:42:09 +0000 |
319 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/AbstractDockItem.cs 2009-05-04 21:34:50 +0000 |
320 | @@ -188,6 +188,11 @@ |
321 | /// </param> |
322 | public virtual void Clicked (uint button, ModifierType state, PointD position) |
323 | { |
324 | + SetLastClick (); |
325 | + } |
326 | + |
327 | + protected void SetLastClick () |
328 | + { |
329 | LastClick = DateTime.UtcNow; |
330 | time_since_click_overdue = false; |
331 | } |
332 | |
333 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ApplicationDockItem.cs' |
334 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ApplicationDockItem.cs 2009-04-11 04:33:50 +0000 |
335 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ApplicationDockItem.cs 2009-05-04 21:34:50 +0000 |
336 | @@ -88,6 +88,12 @@ |
337 | } |
338 | } |
339 | |
340 | + public override Item Item { |
341 | + get { |
342 | + return Launcher as Item; |
343 | + } |
344 | + } |
345 | + |
346 | string Exec { |
347 | get { |
348 | string exec; |
349 | |
350 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ItemDockItem.cs' |
351 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ItemDockItem.cs 2009-04-29 06:22:41 +0000 |
352 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ItemDockItem.cs 2009-05-04 21:34:50 +0000 |
353 | @@ -43,25 +43,17 @@ |
354 | |
355 | public class ItemDockItem : WnckDockItem, IRightClickable |
356 | { |
357 | - const string ErrorMessage = "Docky could not move the file to the requested Directory. " + |
358 | - "Please check file name and permissions and try again"; |
359 | - |
360 | - Item element; |
361 | + Item item; |
362 | int window_count; |
363 | uint handle_timer; |
364 | - bool accepting_drops; |
365 | Gdk.Pixbuf drag_pixbuf; |
366 | Gdk.Rectangle icon_region; |
367 | List<Wnck.Window> windows; |
368 | |
369 | public event EventHandler RemoveClicked; |
370 | |
371 | - public override bool IsAcceptingDrops { |
372 | - get { return accepting_drops; } |
373 | - } |
374 | - |
375 | protected override string Icon { |
376 | - get { return element.Icon; } |
377 | + get { return item.Icon; } |
378 | } |
379 | |
380 | string Name { |
381 | @@ -72,12 +64,12 @@ |
382 | if (VisibleWindows.Any () && WindowCount == 1) |
383 | return VisibleWindows.First ().Name; |
384 | |
385 | - return Element.Name; |
386 | + return Item.Name; |
387 | } |
388 | } |
389 | |
390 | - public Item Element { |
391 | - get { return element; } |
392 | + public override Item Item { |
393 | + get { return item; } |
394 | } |
395 | |
396 | public override IEnumerable<Wnck.Window> Windows { |
397 | @@ -96,56 +88,24 @@ |
398 | get { return window_count; } |
399 | } |
400 | |
401 | - public ItemDockItem (Item element) : base () |
402 | + public ItemDockItem (Item item) : base () |
403 | { |
404 | Position = -1; |
405 | - this.element = element; |
406 | + this.item = item; |
407 | windows = new List<Wnck.Window> (); |
408 | |
409 | UpdateApplication (); |
410 | NeedsAttention = DetermineUrgencyStatus (); |
411 | |
412 | - if (element is IFileItem && Directory.Exists ((element as IFileItem).Path)) |
413 | - accepting_drops = true; |
414 | - else |
415 | - accepting_drops = false; |
416 | - |
417 | SetText (Name); |
418 | } |
419 | |
420 | - public override bool ReceiveItem (string item) |
421 | - { |
422 | - bool result = false; |
423 | - if (!IsAcceptingDrops) |
424 | - return result; |
425 | - |
426 | - if (item.StartsWith ("file://")) |
427 | - item = item.Substring ("file://".Length); |
428 | - |
429 | - if (File.Exists (item)) { |
430 | - try { |
431 | - File.Move (item, System.IO.Path.Combine ((Element as IFileItem).Path, System.IO.Path.GetFileName (item))); |
432 | - result = true; |
433 | - } catch { |
434 | - Services.Notifications.Notify ("Docky Error", ErrorMessage); |
435 | - } |
436 | - } else if (Directory.Exists (item)) { |
437 | - try { |
438 | - Directory.Move (item, System.IO.Path.Combine ((Element as IFileItem).Path, System.IO.Path.GetFileName (item))); |
439 | - result = true; |
440 | - } catch { |
441 | - Services.Notifications.Notify ("Docky Error", ErrorMessage); |
442 | - } |
443 | - } |
444 | - return result; |
445 | - } |
446 | - |
447 | public void UpdateApplication () |
448 | { |
449 | UnregisterWindowEvents (); |
450 | |
451 | - if (element is IApplicationItem) { |
452 | - windows = WindowUtils.WindowListForCmd ((element as IApplicationItem).Exec); |
453 | + if (item is IApplicationItem) { |
454 | + windows = WindowUtils.WindowListForCmd ((item as IApplicationItem).Exec); |
455 | window_count = windows.Where (w => !w.IsSkipTasklist).Count (); |
456 | } |
457 | |
458 | @@ -218,8 +178,8 @@ |
459 | |
460 | List<AbstractDockItem> dockitems = new List<AbstractDockItem> (); |
461 | |
462 | - foreach (Act act in ActionsForItem (element)) { |
463 | - dockitems.Add (new ActionDockItem (act, element)); |
464 | + foreach (Act act in ActionsForItem (item)) { |
465 | + dockitems.Add (new ActionDockItem (act, item)); |
466 | } |
467 | |
468 | Docky.Core.DockServices.ItemsService.HotSeatItem (this, dockitems); |
469 | @@ -235,10 +195,10 @@ |
470 | |
471 | protected override void Launch () |
472 | { |
473 | - if (Element is IFileItem) |
474 | - Services.Core.PerformDefaultAction (Element as Item, new [] { typeof (OpenAction), }); |
475 | + if (Item is IFileItem) |
476 | + Services.Core.PerformDefaultAction (Item as Item, new [] { typeof (OpenAction), }); |
477 | else |
478 | - Services.Core.PerformDefaultAction (Element as Item, Type.EmptyTypes); |
479 | + Services.Core.PerformDefaultAction (Item as Item, Type.EmptyTypes); |
480 | } |
481 | |
482 | public override void SetIconRegion (Gdk.Rectangle region) |
483 | @@ -258,7 +218,7 @@ |
484 | if (other == null) return false; |
485 | |
486 | ItemDockItem di = other as ItemDockItem; |
487 | - return di != null && di.Element != null && Element != null && di.Element.UniqueId == Element.UniqueId; |
488 | + return di != null && di.Item != null && Item != null && di.Item.UniqueId == Item.UniqueId; |
489 | } |
490 | |
491 | #region IDisposable implementation |
492 | @@ -266,7 +226,7 @@ |
493 | public override void Dispose () |
494 | { |
495 | UnregisterWindowEvents (); |
496 | - element = null; |
497 | + item = null; |
498 | windows.Clear (); |
499 | |
500 | if (drag_pixbuf != null) |
501 | @@ -286,11 +246,11 @@ |
502 | yield return new SeparatorMenuButtonArgs (); |
503 | |
504 | if (hasApps) { |
505 | - foreach (Act act in ActionsForItem (element)) |
506 | - yield return new LaunchMenuButtonArgs (act, element, act.Name, act.Icon).AsDark (); |
507 | + foreach (Act act in ActionsForItem (item)) |
508 | + yield return new LaunchMenuButtonArgs (act, item, act.Name, act.Icon).AsDark (); |
509 | } else { |
510 | - foreach (Act act in ActionsForItem (element)) |
511 | - yield return new LaunchMenuButtonArgs (act, element, act.Name, act.Icon); |
512 | + foreach (Act act in ActionsForItem (item)) |
513 | + yield return new LaunchMenuButtonArgs (act, item, act.Name, act.Icon); |
514 | } |
515 | |
516 | if (hasApps) { |
517 | |
518 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/WnckDockItem.cs' |
519 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/WnckDockItem.cs 2009-04-29 06:22:41 +0000 |
520 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/WnckDockItem.cs 2009-05-04 21:34:50 +0000 |
521 | @@ -42,6 +42,9 @@ |
522 | |
523 | public abstract class WnckDockItem : AbstractDockItem |
524 | { |
525 | + const string ErrorMessage = "Docky could not move the file to the requested Directory. " + |
526 | + "Please check file name and permissions and try again"; |
527 | + |
528 | // a bad hack, but it works |
529 | static string [] blacklist = new [] { |
530 | "CopyToClipboardAction", |
531 | @@ -49,12 +52,15 @@ |
532 | }; |
533 | |
534 | int last_raised; |
535 | - |
536 | + bool? accepting_drops; |
537 | + |
538 | DateTime last_scroll = new DateTime (0); |
539 | TimeSpan scroll_rate = new TimeSpan (0, 0, 0, 0, 200); |
540 | |
541 | public abstract IEnumerable<Wnck.Window> Windows { get; } |
542 | |
543 | + public abstract Item Item { get; } |
544 | + |
545 | protected IEnumerable<Wnck.Window> VisibleWindows { |
546 | get { return Windows.Where (w => !w.IsSkipTasklist); } |
547 | } |
548 | @@ -67,6 +73,15 @@ |
549 | } |
550 | } |
551 | |
552 | + public override bool IsAcceptingDrops { |
553 | + get { |
554 | + if (!accepting_drops.HasValue) { |
555 | + accepting_drops = (Item is IFileItem && Directory.Exists ((Item as IFileItem).Path)) || (Item is IApplicationItem); |
556 | + } |
557 | + return accepting_drops.Value; |
558 | + } |
559 | + } |
560 | + |
561 | public WnckDockItem() : base () |
562 | { |
563 | last_raised = 0; |
564 | @@ -143,5 +158,43 @@ |
565 | else if (last_raised < 0) |
566 | last_raised = WindowCount - 1; |
567 | } |
568 | + |
569 | + public override bool ReceiveItem (string item) |
570 | + { |
571 | + bool result = false; |
572 | + if (!IsAcceptingDrops) |
573 | + return result; |
574 | + |
575 | + if (item.StartsWith ("file://")) |
576 | + item = item.Substring ("file://".Length); |
577 | + |
578 | + if (File.Exists (item)) { |
579 | + if (Item is IApplicationItem) { |
580 | + try { |
581 | + (Item as IApplicationItem).LaunchWithFiles (Do.Platform.Services.UniverseFactory.NewFileItem (item).Cons (null)); |
582 | + SetLastClick (); |
583 | + AnimationType = ClickAnimationType.Bounce; |
584 | + result = true; |
585 | + } catch { |
586 | + Services.Notifications.Notify ("Docky Error", "Docky could not launch application"); |
587 | + } |
588 | + } else { |
589 | + try { |
590 | + File.Move (item, System.IO.Path.Combine ((Item as IFileItem).Path, System.IO.Path.GetFileName (item))); |
591 | + result = true; |
592 | + } catch { |
593 | + Services.Notifications.Notify ("Docky Error", ErrorMessage); |
594 | + } |
595 | + } |
596 | + } else if (Directory.Exists (item)) { |
597 | + try { |
598 | + Directory.Move (item, System.IO.Path.Combine ((Item as IFileItem).Path, System.IO.Path.GetFileName (item))); |
599 | + result = true; |
600 | + } catch { |
601 | + Services.Notifications.Notify ("Docky Error", ErrorMessage); |
602 | + } |
603 | + } |
604 | + return result; |
605 | + } |
606 | } |
607 | } |
cool stuff, works for me.