Merge lp://qastaging/~cszikszoy/docky/mountop into lp://qastaging/docky

Proposed by Chris S.
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~cszikszoy/docky/mountop
Merge into: lp://qastaging/docky
Diff against target: 748 lines (+577/-23)
11 files modified
Docky.Services/Docky.Services.csproj (+11/-0)
Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs (+12/-5)
Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs (+123/-0)
Docky.Services/Docky.Services/NativeInterop.cs (+58/-2)
Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs (+92/-0)
Docky.Services/Gtk/MountOperation.cs (+162/-0)
Docky.Services/Makefile.am (+5/-2)
Docky.Services/gtk-gui/generated.cs (+81/-0)
Docky.Services/gtk-gui/gui.stetic (+11/-0)
StandardPlugins/Bookmarks/Bookmarks.csproj (+1/-0)
StandardPlugins/Mounter/src/MountItem.cs (+21/-14)
To merge this branch: bzr merge lp://qastaging/~cszikszoy/docky/mountop
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+14685@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

- in GlibMountExtension: return m.TrashDirs ().Any (f => f.QueryExists (null) && f.DirectoryHasFiles ());
- you dont need to yield break at the end of enumerators its implicit
- please move const strings to the top of the file
-the "EmtpyTrashMessage" looks like its missing a space around that + sign

address the above issues and +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Docky.Services/Docky.Services.csproj'
2--- Docky.Services/Docky.Services.csproj 2009-10-29 04:25:58 +0000
3+++ Docky.Services/Docky.Services.csproj 2009-11-10 07:35:20 +0000
4@@ -94,11 +94,22 @@
5 <Compile Include="AssemblyInfo.cs" />
6 <Compile Include="Docky.Services\NativeInterop.cs" />
7 <Compile Include="Docky.Services\Extensions\GLibFileExtension.cs" />
8+ <Compile Include="gtk-gui\generated.cs" />
9+ <Compile Include="Gtk\MountOperation.cs" />
10+ <Compile Include="GLibSharp\AsyncReadyCallbackNative.cs" />
11+ <Compile Include="Docky.Services\Extensions\GLibMountExtension.cs" />
12 </ItemGroup>
13 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
14 <ItemGroup>
15 <Folder Include="Docky.Services\" />
16 <Folder Include="Docky.Services\Logging\" />
17 <Folder Include="Docky.Services\Extensions\" />
18+ <Folder Include="Gtk\" />
19+ <Folder Include="GLibSharp\" />
20+ </ItemGroup>
21+ <ItemGroup>
22+ <EmbeddedResource Include="gtk-gui\gui.stetic">
23+ <LogicalName>gui.stetic</LogicalName>
24+ </EmbeddedResource>
25 </ItemGroup>
26 </Project>
27
28=== modified file 'Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs'
29--- Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs 2009-11-04 05:06:05 +0000
30+++ Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs 2009-11-10 07:35:20 +0000
31@@ -15,6 +15,7 @@
32 // along with this program. If not, see <http://www.gnu.org/licenses/>.
33 //
34 using System;
35+using System.Linq;
36 using System.Collections.Generic;
37
38 using GLib;
39@@ -72,6 +73,15 @@
40 Recursive_Copy (source, dest, ref copiedBytes, totalBytes, progress_cb);
41 }
42
43+ public static bool DirectoryHasFiles (this GLib.File file)
44+ {
45+ System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo (file.Path);
46+
47+ if (dir.GetFiles ().Count () > 0 || dir.GetDirectories ().Count () > 0)
48+ return true;
49+ return false;
50+ }
51+
52 static void Recursive_Copy (GLib.File source, GLib.File dest, ref long copiedBytes, long totalBytes, FileProgressCallback progress_cb)
53 {
54 FileInfo fileInfo = source.QueryInfo ("standard::type", FileQueryInfoFlags.NofollowSymlinks, null);
55@@ -156,7 +166,8 @@
56
57 public static void MountWithActionAndFallback (this GLib.File file, Action success, Action failed)
58 {
59- file.MountEnclosingVolume (0, null, null, (o, result) => {
60+ file.MountEnclosingVolume (0, new Gtk.MountOperation (null), null, (o, result) =>
61+ {
62 // wait for the mount to finish
63 try {
64 if (file.MountEnclosingVolumeFinish (result)) {
65@@ -169,10 +180,6 @@
66 // an exception can be thrown here if we are trying to mount an already mounted file
67 // in that case, resort to the fallback
68 } catch (GLib.GException) {
69- // FIXME
70- // need to use GLib.MountOperation for mounting to be able to specify credentials
71- // until we have a proper way to determine if mount was successful or not,
72- // make sure this doesn't crash
73 try {
74 failed.Invoke ();
75 } catch {}
76
77=== added file 'Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs'
78--- Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs 1970-01-01 00:00:00 +0000
79+++ Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs 2009-11-10 07:35:20 +0000
80@@ -0,0 +1,123 @@
81+//
82+// Copyright (C) 2009 Jason Smith
83+//
84+// This program is free software: you can redistribute it and/or modify
85+// it under the terms of the GNU General Public License as published by
86+// the Free Software Foundation, either version 3 of the License, or
87+// (at your option) any later version.
88+//
89+// This program is distributed in the hope that it will be useful,
90+// but WITHOUT ANY WARRANTY; without even the implied warranty of
91+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92+// GNU General Public License for more details.
93+//
94+// You should have received a copy of the GNU General Public License
95+// along with this program. If not, see <http://www.gnu.org/licenses/>.
96+//
97+
98+using System;
99+using IO = System.IO;
100+using System.Collections.Generic;
101+
102+using GLib;
103+using Gtk;
104+
105+namespace Docky.Services
106+{
107+
108+ public static class GLibMountExtension
109+ {
110+
111+ // as of GLib 2.22, Mount.UnMount and Mount.Eject are deprecated. These should be used instead.
112+ public static void UnmountWithOperation (this GLib.Mount m, MountUnmountFlags flags, GLib.MountOperation operation,
113+ Cancellable cancellable, AsyncReadyCallback callback)
114+ {
115+ m.MaybeEmptyTrashWithAction (() => {
116+ NativeInterop.UnmountWithOperation (m, flags, operation, cancellable, callback);
117+ });
118+ }
119+
120+ public static void EjectWithOperation (this GLib.Mount m, MountUnmountFlags flags, GLib.MountOperation operation,
121+ Cancellable cancellable, AsyncReadyCallback callback)
122+ {
123+ m.MaybeEmptyTrashWithAction (() => {
124+ NativeInterop.EjectWithOperation (m, flags, operation, cancellable, callback);
125+ });
126+ }
127+
128+ public static bool EjectWithOperationFinish (this GLib.Mount m, AsyncResult result)
129+ {
130+ return NativeInterop.EjectWithOperationFinish (m, result);
131+ }
132+
133+ public static bool UnmountWithOperationFinish (this GLib.Mount m, AsyncResult result)
134+ {
135+ return NativeInterop.UnmountWithOperation (m, result);
136+ }
137+
138+ static void MaybeEmptyTrashWithAction (this Mount m, System.Action act)
139+ {
140+ bool perform = true;
141+
142+ if (m.TrashHasFiles ()) {
143+ MessageDialog dialog;
144+ ResponseType response = m.PromptEmptyTrash (out dialog);
145+ if (response == ResponseType.Accept) {
146+ foreach (File dir in m.TrashDirs ()) {
147+ IO.DirectoryInfo info = new IO.DirectoryInfo (dir.Path);
148+ info.Delete (true);
149+ }
150+ } else if (response == ResponseType.Cancel) {
151+ perform = false;
152+ }
153+ dialog.Hide ();
154+ dialog.Destroy ();
155+ }
156+ if (perform)
157+ act.Invoke ();
158+ }
159+
160+ public static bool TrashHasFiles (this Mount m)
161+ {
162+ foreach (File f in m.TrashDirs ()) {
163+ if (f.QueryExists (null) && f.DirectoryHasFiles ())
164+ return true;
165+ }
166+ return false;
167+ }
168+
169+ static IEnumerable<File> TrashDirs (this Mount m)
170+ {
171+ File root = m.Root;
172+ if (root == null)
173+ yield break;
174+
175+ if (root.IsNative) {
176+ IO.DirectoryInfo rootInfo = new IO.DirectoryInfo (root.Path);
177+ foreach (IO.DirectoryInfo d in rootInfo.GetDirectories (".Trash*", IO.SearchOption.TopDirectoryOnly)) {
178+ yield return FileFactory.NewForPath (root.GetChild (d.Name).GetChild ("files").Path);
179+ yield return FileFactory.NewForPath (root.GetChild (d.Name).GetChild ("info").Path);
180+ }
181+ }
182+ yield break;
183+ }
184+
185+ const string EmptyTrashTitle = "Do you want to empty the trash before you unmount?";
186+ const string EmptyTrashMessage = "In order to regain the free space on this volume" +
187+ "the trash must be emptied. All trashed items on the volume will be permanently lost.";
188+
189+ static ResponseType PromptEmptyTrash (this Mount m, out MessageDialog dialog)
190+ {
191+ dialog = new Gtk.MessageDialog (null, DialogFlags.Modal, MessageType.Question,
192+ ButtonsType.None, EmptyTrashMessage);
193+ dialog.Title = EmptyTrashTitle;
194+ dialog.AddButton ("Do _not Empty Trash", ResponseType.Reject);
195+ dialog.AddButton ("_Cancel", ResponseType.Cancel);
196+ dialog.AddButton ("Empty _Trash", ResponseType.Accept);
197+ dialog.DefaultResponse = ResponseType.Accept;
198+ dialog.SkipTaskbarHint = true;
199+
200+ return (ResponseType) dialog.Run ();
201+ }
202+ }
203+}
204
205=== modified file 'Docky.Services/Docky.Services/NativeInterop.cs'
206--- Docky.Services/Docky.Services/NativeInterop.cs 2009-11-04 00:00:30 +0000
207+++ Docky.Services/Docky.Services/NativeInterop.cs 2009-11-10 07:35:20 +0000
208@@ -18,6 +18,8 @@
209 using System;
210 using System.Runtime.InteropServices;
211
212+using GLib;
213+
214 namespace Docky.Services
215 {
216
217@@ -29,7 +31,24 @@
218 [DllImport("libc")]
219 private static extern int prctl (int option, byte[] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
220
221- public static string StrUri (GLib.File file)
222+
223+ // these next 4 methods are not yet in GIO#. The methods in GIO# (Unmount, Eject, UnmountFinish, EjectFinish)
224+ // have been marked as deprecated since 2.22. Once GIO# gets these methods we can remove these.
225+ [DllImport("gio-2.0")]
226+ private static extern void g_mount_unmount_with_operation (IntPtr mount, int flags, IntPtr mount_operation,
227+ IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative callback, IntPtr user_data);
228+
229+ [DllImport("gio-2.0")]
230+ private static extern void g_mount_eject_with_operation (IntPtr mount, int flags, IntPtr mount_operation,
231+ IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative callback, IntPtr user_data);
232+
233+ [DllImport("gio-2.0")]
234+ private static extern bool g_mount_unmount_with_operation_finish (IntPtr mount, IntPtr result, out IntPtr error);
235+
236+ [DllImport("gio-2.0")]
237+ private static extern bool g_mount_eject_with_operation_finish (IntPtr mount, IntPtr result, out IntPtr error);
238+
239+ public static string StrUri (File file)
240 {
241 try {
242 return Marshal.PtrToStringAuto (g_file_get_uri (file.Handle));
243@@ -49,7 +68,7 @@
244 try {
245 return prctl (option, System.Text.Encoding.ASCII.GetBytes (arg2 + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
246 } catch (DllNotFoundException e) {
247- Log<NativeInterop>.Fatal ("Could not load libc, please report immediately.");
248+ Log<NativeInterop>.Fatal ("Could not find libc, please report immediately.");
249 Log<NativeInterop>.Info (e.StackTrace);
250 return -1;
251 } catch (Exception e) {
252@@ -58,5 +77,42 @@
253 return -1;
254 }
255 }
256+
257+ public static void UnmountWithOperation (Mount mount, MountUnmountFlags flags, MountOperation op,
258+ Cancellable cancellable, AsyncReadyCallback cb)
259+ {
260+ GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
261+ g_mount_unmount_with_operation (mount.Handle, (int) flags, op == null ? IntPtr.Zero : op.Handle,
262+ cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
263+ }
264+
265+ public static void EjectWithOperation (Mount mount, MountUnmountFlags flags, MountOperation op,
266+ Cancellable cancellable, AsyncReadyCallback cb)
267+ {
268+ GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
269+ g_mount_eject_with_operation (mount.Handle, (int) flags, op == null ? IntPtr.Zero : op.Handle,
270+ cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
271+ }
272+
273+ public static bool EjectWithOperationFinish (Mount mount, AsyncResult result)
274+ {
275+ IntPtr error = IntPtr.Zero;
276+ bool success = g_mount_eject_with_operation_finish (mount.Handle, result == null ? IntPtr.Zero :
277+ ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
278+ bool ret = success;
279+ if (error != IntPtr.Zero)
280+ throw new GLib.GException (error);
281+ return ret;
282+ }
283+
284+ public static bool UnmountWithOperation (Mount mount, AsyncResult result)
285+ {
286+ IntPtr error = IntPtr.Zero;
287+ bool success = g_mount_unmount_with_operation_finish (mount.Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
288+ bool ret = success;
289+ if (error != IntPtr.Zero)
290+ throw new GLib.GException (error);
291+ return ret;
292+ }
293 }
294 }
295
296=== added directory 'Docky.Services/GLibSharp'
297=== added file 'Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs'
298--- Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs 1970-01-01 00:00:00 +0000
299+++ Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs 2009-11-10 07:35:20 +0000
300@@ -0,0 +1,92 @@
301+// This file was generated by the Gtk# code generator.
302+// Any changes made will be lost if regenerated.
303+
304+namespace GLibSharp {
305+
306+ using System;
307+ using System.Runtime.InteropServices;
308+
309+#region Autogenerated code
310+ [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
311+ internal delegate void AsyncReadyCallbackNative(IntPtr source_object, IntPtr res, IntPtr user_data);
312+
313+ internal class AsyncReadyCallbackInvoker {
314+
315+ AsyncReadyCallbackNative native_cb;
316+ IntPtr __data;
317+ GLib.DestroyNotify __notify;
318+
319+ ~AsyncReadyCallbackInvoker ()
320+ {
321+ if (__notify == null)
322+ return;
323+ __notify (__data);
324+ }
325+
326+ internal AsyncReadyCallbackInvoker (AsyncReadyCallbackNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
327+
328+ internal AsyncReadyCallbackInvoker (AsyncReadyCallbackNative native_cb, IntPtr data) : this (native_cb, data, null) {}
329+
330+ internal AsyncReadyCallbackInvoker (AsyncReadyCallbackNative native_cb, IntPtr data, GLib.DestroyNotify notify)
331+ {
332+ this.native_cb = native_cb;
333+ __data = data;
334+ __notify = notify;
335+ }
336+
337+ internal GLib.AsyncReadyCallback Handler {
338+ get {
339+ return new GLib.AsyncReadyCallback(InvokeNative);
340+ }
341+ }
342+
343+ void InvokeNative (GLib.Object source_object, GLib.AsyncResult res)
344+ {
345+ native_cb (source_object == null ? IntPtr.Zero : source_object.Handle, res == null ? IntPtr.Zero : ((res is GLib.Object) ? (res as GLib.Object).Handle : (res as GLib.AsyncResultAdapter).Handle), __data);
346+ }
347+ }
348+
349+ internal class AsyncReadyCallbackWrapper {
350+
351+ public void NativeCallback (IntPtr source_object, IntPtr res, IntPtr user_data)
352+ {
353+ try {
354+ managed (GLib.Object.GetObject (source_object), GLib.AsyncResultAdapter.GetObject (res, false));
355+ if (release_on_call)
356+ gch.Free ();
357+ } catch (Exception e) {
358+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
359+ }
360+ }
361+
362+ bool release_on_call = false;
363+ GCHandle gch;
364+
365+ public void PersistUntilCalled ()
366+ {
367+ release_on_call = true;
368+ gch = GCHandle.Alloc (this);
369+ }
370+
371+ internal AsyncReadyCallbackNative NativeDelegate;
372+ GLib.AsyncReadyCallback managed;
373+
374+ public AsyncReadyCallbackWrapper (GLib.AsyncReadyCallback managed)
375+ {
376+ this.managed = managed;
377+ if (managed != null)
378+ NativeDelegate = new AsyncReadyCallbackNative (NativeCallback);
379+ }
380+
381+ public static GLib.AsyncReadyCallback GetManagedDelegate (AsyncReadyCallbackNative native)
382+ {
383+ if (native == null)
384+ return null;
385+ AsyncReadyCallbackWrapper wrapper = (AsyncReadyCallbackWrapper) native.Target;
386+ if (wrapper == null)
387+ return null;
388+ return wrapper.managed;
389+ }
390+ }
391+#endregion
392+}
393
394=== added directory 'Docky.Services/Gtk'
395=== added file 'Docky.Services/Gtk/MountOperation.cs'
396--- Docky.Services/Gtk/MountOperation.cs 1970-01-01 00:00:00 +0000
397+++ Docky.Services/Gtk/MountOperation.cs 2009-11-10 07:35:20 +0000
398@@ -0,0 +1,162 @@
399+// This file was generated by the Gtk# code generator.
400+// Any changes made will be lost if regenerated.
401+
402+namespace Gtk {
403+
404+ using System;
405+ using System.Collections;
406+ using System.Runtime.InteropServices;
407+
408+ public static class Extensions
409+ {
410+ struct GTypeQuery
411+ {
412+ public IntPtr type;
413+ public IntPtr type_name;
414+ public uint class_size;
415+ public uint instance_size;
416+ }
417+
418+ [DllImport ("libgobject-2.0", CallingConvention = CallingConvention.Cdecl)]
419+ static extern IntPtr g_type_class_peek (IntPtr gtype);
420+
421+ [DllImport ("libgobject-2.0", CallingConvention = CallingConvention.Cdecl)]
422+ static extern IntPtr g_type_class_ref (IntPtr gtype);
423+
424+ [DllImport("libgobject-2.0", CallingConvention = CallingConvention.Cdecl)]
425+ static extern void g_type_query (IntPtr type, out GTypeQuery query);
426+
427+ public static IntPtr GetClassPtr (this GLib.GType type)
428+ {
429+ IntPtr klass = g_type_class_peek (type.Val);
430+ if (klass == IntPtr.Zero)
431+ klass = g_type_class_ref (type.Val);
432+ return klass;
433+ }
434+
435+ public static uint GetClassSize (this GLib.GType type)
436+ {
437+ GTypeQuery query;
438+ g_type_query (type.Val, out query);
439+ return query.class_size;
440+ }
441+ }
442+
443+#region Autogenerated code
444+ public partial class MountOperation : GLib.MountOperation {
445+
446+ public MountOperation(IntPtr raw) : base(raw) {}
447+
448+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
449+ static extern IntPtr gtk_mount_operation_new(IntPtr parent);
450+
451+ public MountOperation (Gtk.Window parent) : base (IntPtr.Zero)
452+ {
453+ if (GetType () != typeof (MountOperation)) {
454+ ArrayList vals = new ArrayList();
455+ ArrayList names = new ArrayList();
456+ if (parent != null) {
457+ names.Add ("parent");
458+ vals.Add (new GLib.Value (parent));
459+ }
460+ CreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value)));
461+ return;
462+ }
463+ Raw = gtk_mount_operation_new(parent == null ? IntPtr.Zero : parent.Handle);
464+ }
465+
466+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
467+ static extern IntPtr gtk_mount_operation_get_parent(IntPtr raw);
468+
469+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
470+ static extern void gtk_mount_operation_set_parent(IntPtr raw, IntPtr parent);
471+
472+ [GLib.Property ("parent")]
473+ public Gtk.Window Parent {
474+ get {
475+ IntPtr raw_ret = gtk_mount_operation_get_parent(Handle);
476+ Gtk.Window ret = GLib.Object.GetObject(raw_ret) as Gtk.Window;
477+ return ret;
478+ }
479+ set {
480+ gtk_mount_operation_set_parent(Handle, value == null ? IntPtr.Zero : value.Handle);
481+ }
482+ }
483+
484+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
485+ static extern IntPtr gtk_mount_operation_get_screen(IntPtr raw);
486+
487+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
488+ static extern void gtk_mount_operation_set_screen(IntPtr raw, IntPtr screen);
489+
490+ [GLib.Property ("screen")]
491+ public Gdk.Screen Screen {
492+ get {
493+ IntPtr raw_ret = gtk_mount_operation_get_screen(Handle);
494+ Gdk.Screen ret = GLib.Object.GetObject(raw_ret) as Gdk.Screen;
495+ return ret;
496+ }
497+ set {
498+ gtk_mount_operation_set_screen(Handle, value == null ? IntPtr.Zero : value.Handle);
499+ }
500+ }
501+
502+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
503+ static extern bool gtk_mount_operation_is_showing(IntPtr raw);
504+
505+ [GLib.Property ("is-showing")]
506+ public bool IsShowing {
507+ get {
508+ bool raw_ret = gtk_mount_operation_is_showing(Handle);
509+ bool ret = raw_ret;
510+ return ret;
511+ }
512+ }
513+
514+ [StructLayout (LayoutKind.Sequential)]
515+ struct GtkMountOperationClass {
516+ IntPtr GtkReserved1;
517+ IntPtr GtkReserved2;
518+ IntPtr GtkReserved3;
519+ IntPtr GtkReserved4;
520+ }
521+
522+ static uint class_offset = ((GLib.GType) typeof (GLib.MountOperation)).GetClassSize ();
523+ static Hashtable class_structs;
524+
525+ static GtkMountOperationClass GetClassStruct (GLib.GType gtype, bool use_cache)
526+ {
527+ if (class_structs == null)
528+ class_structs = new Hashtable ();
529+
530+ if (use_cache && class_structs.Contains (gtype))
531+ return (GtkMountOperationClass) class_structs [gtype];
532+ else {
533+ IntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);
534+ GtkMountOperationClass class_struct = (GtkMountOperationClass) Marshal.PtrToStructure (class_ptr, typeof (GtkMountOperationClass));
535+ if (use_cache)
536+ class_structs.Add (gtype, class_struct);
537+ return class_struct;
538+ }
539+ }
540+
541+ static void OverrideClassStruct (GLib.GType gtype, GtkMountOperationClass class_struct)
542+ {
543+ IntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);
544+ Marshal.StructureToPtr (class_struct, class_ptr, false);
545+ }
546+
547+ [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)]
548+ static extern IntPtr gtk_mount_operation_get_type();
549+
550+ public static new GLib.GType GType {
551+ get {
552+ IntPtr raw_ret = gtk_mount_operation_get_type();
553+ GLib.GType ret = new GLib.GType(raw_ret);
554+ return ret;
555+ }
556+ }
557+
558+#endregion
559+ }
560+}
561
562=== modified file 'Docky.Services/Makefile.am'
563--- Docky.Services/Makefile.am 2009-10-26 09:39:21 +0000
564+++ Docky.Services/Makefile.am 2009-11-10 07:35:20 +0000
565@@ -9,6 +9,7 @@
566 FILES = \
567 AssemblyInfo.cs \
568 Docky.Services/Extensions/GLibFileExtension.cs \
569+ Docky.Services/Extensions/GLibMountExtension.cs \
570 Docky.Services/Logging/ConsoleCrayon.cs \
571 Docky.Services/Logging/LogBase.cs \
572 Docky.Services/Logging/ConsoleLog.cs \
573@@ -22,8 +23,10 @@
574 Docky.Services/DrawingService.cs \
575 Docky.Services/NotificationService.cs \
576 Docky.Services/Preferences.cs \
577- Docky.Services/NativeInterop.cs
578-
579+ Docky.Services/NativeInterop.cs \
580+ Gtk/MountOperation.cs \
581+ GLibSharp/AsyncReadyCallbackNative.cs
582+
583 REFERENCES = \
584 System \
585 System.Core \
586
587=== added directory 'Docky.Services/gtk-gui'
588=== added file 'Docky.Services/gtk-gui/generated.cs'
589--- Docky.Services/gtk-gui/generated.cs 1970-01-01 00:00:00 +0000
590+++ Docky.Services/gtk-gui/generated.cs 2009-11-10 07:35:20 +0000
591@@ -0,0 +1,81 @@
592+// ------------------------------------------------------------------------------
593+// <autogenerated>
594+// This code was generated by a tool.
595+//
596+//
597+// Changes to this file may cause incorrect behavior and will be lost if
598+// the code is regenerated.
599+// </autogenerated>
600+// ------------------------------------------------------------------------------
601+
602+namespace Stetic {
603+
604+ internal class Gui {
605+
606+ private static bool initialized;
607+
608+ internal static void Initialize(Gtk.Widget iconRenderer) {
609+ if ((Stetic.Gui.initialized == false)) {
610+ Stetic.Gui.initialized = true;
611+ }
612+ }
613+ }
614+
615+ internal class BinContainer {
616+
617+ private Gtk.Widget child;
618+
619+ private Gtk.UIManager uimanager;
620+
621+ public static BinContainer Attach(Gtk.Bin bin) {
622+ BinContainer bc = new BinContainer();
623+ bin.SizeRequested += new Gtk.SizeRequestedHandler(bc.OnSizeRequested);
624+ bin.SizeAllocated += new Gtk.SizeAllocatedHandler(bc.OnSizeAllocated);
625+ bin.Added += new Gtk.AddedHandler(bc.OnAdded);
626+ return bc;
627+ }
628+
629+ private void OnSizeRequested(object sender, Gtk.SizeRequestedArgs args) {
630+ if ((this.child != null)) {
631+ args.Requisition = this.child.SizeRequest();
632+ }
633+ }
634+
635+ private void OnSizeAllocated(object sender, Gtk.SizeAllocatedArgs args) {
636+ if ((this.child != null)) {
637+ this.child.Allocation = args.Allocation;
638+ }
639+ }
640+
641+ private void OnAdded(object sender, Gtk.AddedArgs args) {
642+ this.child = args.Widget;
643+ }
644+
645+ public void SetUiManager(Gtk.UIManager uim) {
646+ this.uimanager = uim;
647+ this.child.Realized += new System.EventHandler(this.OnRealized);
648+ }
649+
650+ private void OnRealized(object sender, System.EventArgs args) {
651+ if ((this.uimanager != null)) {
652+ Gtk.Widget w;
653+ w = this.child.Toplevel;
654+ if (((w != null) && typeof(Gtk.Window).IsInstanceOfType(w))) {
655+ ((Gtk.Window)(w)).AddAccelGroup(this.uimanager.AccelGroup);
656+ this.uimanager = null;
657+ }
658+ }
659+ }
660+ }
661+
662+ internal class ActionGroups {
663+
664+ public static Gtk.ActionGroup GetActionGroup(System.Type type) {
665+ return Stetic.ActionGroups.GetActionGroup(type.FullName);
666+ }
667+
668+ public static Gtk.ActionGroup GetActionGroup(string name) {
669+ return null;
670+ }
671+ }
672+}
673
674=== added file 'Docky.Services/gtk-gui/gui.stetic'
675--- Docky.Services/gtk-gui/gui.stetic 1970-01-01 00:00:00 +0000
676+++ Docky.Services/gtk-gui/gui.stetic 2009-11-10 07:35:21 +0000
677@@ -0,0 +1,11 @@
678+<?xml version="1.0" encoding="utf-8"?>
679+<stetic-interface>
680+ <configuration>
681+ <images-root-path>..</images-root-path>
682+ <target-gtk-version>2.12</target-gtk-version>
683+ </configuration>
684+ <import>
685+ <widget-library name="notify-sharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=2df29c54e245917a" />
686+ <widget-library name="../bin/Debug/Docky.Services.dll" internal="true" />
687+ </import>
688+</stetic-interface>
689\ No newline at end of file
690
691=== modified file 'StandardPlugins/Bookmarks/Bookmarks.csproj'
692--- StandardPlugins/Bookmarks/Bookmarks.csproj 2009-10-31 03:57:40 +0000
693+++ StandardPlugins/Bookmarks/Bookmarks.csproj 2009-11-10 07:35:21 +0000
694@@ -41,6 +41,7 @@
695 <SpecificVersion>False</SpecificVersion>
696 <HintPath>..\..\build\gio-sharp.dll</HintPath>
697 </Reference>
698+ <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
699 </ItemGroup>
700 <ItemGroup>
701 <Compile Include="src\BookmarkDockItem.cs" />
702
703=== modified file 'StandardPlugins/Mounter/src/MountItem.cs'
704--- StandardPlugins/Mounter/src/MountItem.cs 2009-11-07 04:49:51 +0000
705+++ StandardPlugins/Mounter/src/MountItem.cs 2009-11-10 07:35:21 +0000
706@@ -65,21 +65,28 @@
707
708 public void UnMount ()
709 {
710- Log<MountItem>.Debug ("Trying to unmount {0}.", Mnt.Name);
711 if (Mnt.CanEject ())
712- Mnt.Eject (MountUnmountFlags.Force, null, new AsyncReadyCallback (HandleMountFinished));
713- else
714- Mnt.Unmount (MountUnmountFlags.Force, null, new AsyncReadyCallback (HandleMountFinished));
715- }
716-
717- void HandleMountFinished (GLib.Object sender, AsyncResult result)
718- {
719- string unmountMessage = "Unmount of {0} {1}.";
720-
721- if (!Mnt.UnmountFinish (result))
722- Log<MountItem>.Notify (unmountMessage, Mnt.Name, "Failed");
723- else
724- Log<MountItem>.Debug (unmountMessage, Mnt.Name, "Succeeded");
725+ Mnt.EjectWithOperation (MountUnmountFlags.Force, new Gtk.MountOperation (null), null, (s, result) =>
726+ {
727+ try {
728+ if (!Mnt.EjectWithOperationFinish (result))
729+ Log<MountItem>.Error ("Failed to eject {0}", Mnt.Name);
730+ } catch (Exception e) {
731+ Log<MountItem>.Error ("An error when ejecting {0} was encountered: {1}", Mnt.Name, e.Message);
732+ Log<MountItem>.Debug (e.StackTrace);
733+ }
734+ });
735+ else
736+ Mnt.UnmountWithOperation (MountUnmountFlags.Force, new Gtk.MountOperation (null), null, (s, result) =>
737+ {
738+ try {
739+ if (!Mnt.UnmountWithOperationFinish (result))
740+ Log<MountItem>.Error ("Failed to unmount {0}", Mnt.Name);
741+ } catch (Exception e) {
742+ Log<MountItem>.Error ("An error when unmounting {0} was encountered: {1}", Mnt.Name, e.Message);
743+ Log<MountItem>.Debug (e.StackTrace);
744+ }
745+ });
746 }
747
748 public override MenuList GetMenuItems ()

Subscribers

People subscribed via source and target branches

to status/vote changes: