Merge lp:~docky-core/docky/gio-cleanup into lp:docky
- gio-cleanup
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~docky-core/docky/gio-cleanup |
Merge into: | lp:docky |
Diff against target: |
833 lines (+214/-406) 10 files modified
Docky.Items/Docky.Items/FileDockItem.cs (+1/-1) Docky.Services/Docky.Services.csproj (+0/-1) Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs (+128/-59) Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs (+0/-122) Docky.Services/Docky.Services/NativeInterop.cs (+69/-82) Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs (+0/-92) Docky.Services/Makefile.am (+1/-3) Docky/Docky/Interface/DockPreferences.cs (+13/-44) StandardPlugins/Trash/src/TrashDockItem.cs (+1/-1) m4/intltool.m4 (+1/-1) |
To merge this branch: | bzr merge lp:~docky-core/docky/gio-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris S. | Pending | ||
Review via email: mp+27247@code.launchpad.net |
Commit message
Description of the change
This branch intends to remove all deprecated and obsolete GLib and GIO calls after the introduction of the new gio-sharp 2.22
- 1455. By Rico Tzschichholz
-
merge trunk 1473
- 1456. By Chris S.
-
remove AsyncReadyCallb
ackNative - 1457. By Rico Tzschichholz
-
merge trunk 1595
- 1458. By Chris S.
-
terminal is a bit beyond our target user base for a default application
- 1459. By Chris S.
-
merge trunk
- 1460. By Chris S.
-
remove reference to terminal launcher
- 1461. By Chris S.
-
merge trunk
- 1462. By Chris S.
-
get preferred apps from gconf
- 1463. By Chris S.
-
fix preferred list
- 1464. By Chris S.
-
bind file enumerator methods, also add sample of how to use
- 1465. By Chris S.
-
merge trunk
- 1466. By Chris S.
-
use file enumerator for listing subdirectories
- 1467. By Chris S.
-
add unreadable dirs to the list, but don't try to recuse into them
- 1468. By Rico Tzschichholz
-
subdirs: use unix::inode instead of id::file
- 1469. By Rico Tzschichholz
-
merge trunk 1623
- 1470. By Rico Tzschichholz
-
some more replacements
- 1471. By Rico Tzschichholz
-
merge trunk 1631
- 1472. By Rico Tzschichholz
-
merge trunk 1642
Unmerged revisions
- 1472. By Rico Tzschichholz
-
merge trunk 1642
- 1471. By Rico Tzschichholz
-
merge trunk 1631
- 1470. By Rico Tzschichholz
-
some more replacements
- 1469. By Rico Tzschichholz
-
merge trunk 1623
- 1468. By Rico Tzschichholz
-
subdirs: use unix::inode instead of id::file
- 1467. By Chris S.
-
add unreadable dirs to the list, but don't try to recuse into them
- 1466. By Chris S.
-
use file enumerator for listing subdirectories
- 1465. By Chris S.
-
merge trunk
- 1464. By Chris S.
-
bind file enumerator methods, also add sample of how to use
- 1463. By Chris S.
-
fix preferred list
Preview Diff
1 | === modified file 'Docky.Items/Docky.Items/FileDockItem.cs' |
2 | --- Docky.Items/Docky.Items/FileDockItem.cs 2010-07-29 04:44:03 +0000 |
3 | +++ Docky.Items/Docky.Items/FileDockItem.cs 2010-09-23 09:03:02 +0000 |
4 | @@ -225,7 +225,7 @@ |
5 | }); |
6 | } else { |
7 | note.Summary = Catalog.GetString ("Copying") + string.Format (" {0}...", file.Basename); |
8 | - file.Copy_Recurse (OwnedFile.GetChild (nameAfterMove), 0, (current, total) => { |
9 | + file.CopyRecursive (OwnedFile.GetChild (nameAfterMove), 0, (current, total) => { |
10 | cur = current; |
11 | tot = total; |
12 | }); |
13 | |
14 | === modified file 'Docky.Services/Docky.Services.csproj' |
15 | --- Docky.Services/Docky.Services.csproj 2010-08-06 07:49:04 +0000 |
16 | +++ Docky.Services/Docky.Services.csproj 2010-09-23 09:03:02 +0000 |
17 | @@ -106,7 +106,6 @@ |
18 | <Compile Include="Docky.Services\Extensions\GdkPixbufExtension.cs" /> |
19 | <Compile Include="gtk-gui\generated.cs" /> |
20 | <Compile Include="GLibSharp\AsyncReadyCallbackNative.cs" /> |
21 | - <Compile Include="Docky.Services\Extensions\GLibMountExtension.cs" /> |
22 | <Compile Include="Gtk\MountOperation.cs" /> |
23 | <Compile Include="Docky.Services\HelperService.cs" /> |
24 | <Compile Include="Docky.Services\Extensions\GtkIconThemeExtension.cs" /> |
25 | |
26 | === modified file 'Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs' |
27 | --- Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs 2010-06-02 06:23:31 +0000 |
28 | +++ Docky.Services/Docky.Services/Extensions/GLibFileExtension.cs 2010-09-23 09:03:02 +0000 |
29 | @@ -120,11 +120,18 @@ |
30 | return NativeInterop.GFileInfoQueryULong (info, attribute); |
31 | } |
32 | |
33 | + // by default, we only query info for the exact file, no following symlinks |
34 | public static FileType QueryFileType (this GLib.File file) |
35 | { |
36 | - return file.QueryFileType (0, null); |
37 | + return file.QueryFileType (FileQueryInfoFlags.NofollowSymlinks, null); |
38 | } |
39 | |
40 | + // if we want to follow symlinks, use this method and supply FileQueryInfoFlags.None |
41 | + public static FileType QueryFileType (this GLib.File file, FileQueryInfoFlags flags) |
42 | + { |
43 | + return file.QueryFileType (flags, null); |
44 | + } |
45 | + |
46 | // Recursively list all of the subdirs for a given directory |
47 | public static IEnumerable<GLib.File> SubDirs (this GLib.File file) |
48 | { |
49 | @@ -134,26 +141,48 @@ |
50 | // list all of the subdirs for a given directory |
51 | public static IEnumerable<GLib.File> SubDirs (this GLib.File file, bool recurse) |
52 | { |
53 | - if (!IO.Directory.Exists (file.Path)) |
54 | - return Enumerable.Empty<GLib.File> (); |
55 | - |
56 | - try { |
57 | - // ignore symlinks |
58 | - if ((IO.File.GetAttributes (file.Path) & IO.FileAttributes.ReparsePoint) != 0) |
59 | - return Enumerable.Empty<GLib.File> (); |
60 | - |
61 | - // get all dirs contained in this dir |
62 | - List<GLib.File> dirs = IO.Directory.GetDirectories (file.Path) |
63 | - .Select (d => GLib.FileFactory.NewForPath (d)).ToList (); |
64 | - |
65 | - // if we are recursing, for each dir we found get its subdirs |
66 | - if (recurse) |
67 | - dirs.AddRange (dirs.SelectMany (d => d.SubDirs (true))); |
68 | - |
69 | - return dirs; |
70 | - } catch { |
71 | - return Enumerable.Empty<GLib.File> (); |
72 | + return file.SubDirs (recurse, new List<ulong> ()); |
73 | + } |
74 | + |
75 | + private static IEnumerable<GLib.File> SubDirs (this GLib.File file, bool recurse, List<ulong> seen) |
76 | + { |
77 | + IntPtr enumerator = NativeInterop.GFileEnumerateChildren (file, "standard::name,access::can-read,unix::inode", |
78 | + FileQueryInfoFlags.None, null); |
79 | + |
80 | + List<GLib.File> dirs = new List<GLib.File> (); |
81 | + IntPtr info = IntPtr.Zero; |
82 | + |
83 | + while (true) { |
84 | + try { |
85 | + info = NativeInterop.GFileEnumeratorNextFile (enumerator, null); |
86 | + } catch (Exception e) { |
87 | + Log.Error ("Error enumerating children of '{0}': {1}", file.Path, e.Message); |
88 | + Log.Debug (e.ToString ()); |
89 | + } |
90 | + if (info == IntPtr.Zero) |
91 | + break; |
92 | + |
93 | + ulong inode = QueryULongAttr (info, "unix::inode"); |
94 | + // check if we've seen this file |
95 | + if (seen.Contains (inode)) |
96 | + continue; |
97 | + // if not, add this file to our list of seen files |
98 | + seen.Add (inode); |
99 | + |
100 | + File child = file.GetChild (QueryStringAttr (info, "standard::name")); |
101 | + |
102 | + // follow symlinks to add directories |
103 | + if (child.QueryFileType (FileQueryInfoFlags.None) == FileType.Directory) { |
104 | + dirs.Add (child); |
105 | + if (recurse && QueryBoolAttr (info, "access::can-read")) |
106 | + dirs.AddRange (child.SubDirs (recurse, seen)); |
107 | + } |
108 | + |
109 | + NativeInterop.GObjectUnref (info); |
110 | } |
111 | + |
112 | + NativeInterop.GFileEnumeratorClose (enumerator, null); |
113 | + return dirs.AsEnumerable (); |
114 | } |
115 | |
116 | public static IEnumerable<GLib.File> GetFiles (this GLib.File file) |
117 | @@ -164,15 +193,38 @@ |
118 | // gets all files under the given GLib.File (directory) with the extension of extension |
119 | public static IEnumerable<GLib.File> GetFiles (this GLib.File file, string extension) |
120 | { |
121 | - if (!IO.Directory.Exists (file.Path)) |
122 | - return Enumerable.Empty<GLib.File> (); |
123 | - |
124 | - try { |
125 | - return IO.Directory.GetFiles (file.Path, string.Format ("*{0}", extension)) |
126 | - .Select (f => GLib.FileFactory.NewForPath (f)); |
127 | - } catch { |
128 | - return Enumerable.Empty<GLib.File> (); |
129 | + IntPtr enumerator = NativeInterop.GFileEnumerateChildren (file, "standard::name", |
130 | + FileQueryInfoFlags.None, null); |
131 | + |
132 | + List<GLib.File> files = new List<GLib.File> (); |
133 | + IntPtr info = IntPtr.Zero; |
134 | + |
135 | + while (true) { |
136 | + try { |
137 | + info = NativeInterop.GFileEnumeratorNextFile (enumerator, null); |
138 | + } catch (Exception e) { |
139 | + Log.Error ("Error enumerating children of '{0}': {1}", file.Path, e.Message); |
140 | + Log.Debug (e.ToString ()); |
141 | + } |
142 | + if (info == IntPtr.Zero) |
143 | + break; |
144 | + |
145 | + string name = QueryStringAttr (info, "standard::name"); |
146 | + if (!string.IsNullOrEmpty (extension) && !name.EndsWith (extension)) |
147 | + continue; |
148 | + |
149 | + File child = file.GetChild (name); |
150 | + |
151 | + // filter directories |
152 | + if (child.QueryFileType (FileQueryInfoFlags.None) != FileType.Directory) { |
153 | + files.Add (child); |
154 | + } |
155 | + |
156 | + NativeInterop.GObjectUnref (info); |
157 | } |
158 | + |
159 | + NativeInterop.GFileEnumeratorClose (enumerator, null); |
160 | + return files.AsEnumerable (); |
161 | } |
162 | |
163 | /// <summary> |
164 | @@ -182,30 +234,35 @@ |
165 | /// <param name="file"> |
166 | /// A <see cref="GLib.File"/> |
167 | /// </param> |
168 | - public static void Delete_Recurse (this GLib.File file) |
169 | + public static void DeleteRecursive (this GLib.File file) |
170 | { |
171 | - FileEnumerator enumerator = file.EnumerateChildren ("standard::type,standard::name,access::can-delete", FileQueryInfoFlags.NofollowSymlinks, null); |
172 | - |
173 | - if (enumerator == null) |
174 | - return; |
175 | - |
176 | - FileInfo info; |
177 | - |
178 | - while ((info = enumerator.NextFile ()) != null) { |
179 | - File child = file.GetChild (info.Name); |
180 | - |
181 | - if (info.FileType == FileType.Directory) |
182 | - Delete_Recurse (child); |
183 | - |
184 | - if (info.GetAttributeBoolean ("access::can-delete")) |
185 | + IntPtr enumerator = NativeInterop.GFileEnumerateChildren (file, "standard::name,access::can-delete", |
186 | + FileQueryInfoFlags.NofollowSymlinks, null); |
187 | + |
188 | + IntPtr info = IntPtr.Zero; |
189 | + |
190 | + while (true) { |
191 | + try { |
192 | + info = NativeInterop.GFileEnumeratorNextFile (enumerator, null); |
193 | + } catch (Exception e) { |
194 | + Log.Error ("Error enumerating children of '{0}': {1}", file.Path, e.Message); |
195 | + Log.Debug (e.ToString ()); |
196 | + } |
197 | + if (info == IntPtr.Zero) |
198 | + break; |
199 | + |
200 | + File child = file.GetChild (QueryStringAttr (info, "standard::name")); |
201 | + |
202 | + if (child.QueryFileType (FileQueryInfoFlags.NofollowSymlinks) == FileType.Directory) |
203 | + DeleteRecursive (child); |
204 | + |
205 | + if (QueryBoolAttr (info, "access::can-delete")) |
206 | child.Delete (null); |
207 | - |
208 | - info.Dispose (); |
209 | + |
210 | + NativeInterop.GObjectUnref (info); |
211 | } |
212 | |
213 | - if (info != null) |
214 | - info.Dispose (); |
215 | - enumerator.Close (null); |
216 | + NativeInterop.GFileEnumeratorClose (enumerator, null); |
217 | } |
218 | |
219 | // This is the recursive equivalent of GLib.File.Copy () |
220 | @@ -225,7 +282,7 @@ |
221 | /// <param name="progress_cb"> |
222 | /// A <see cref="FileProgressCallback"/> |
223 | /// </param> |
224 | - public static void Copy_Recurse (this GLib.File source, GLib.File dest, FileCopyFlags flags, FileProgressCallback progress_cb) |
225 | + public static void CopyRecursive (this GLib.File source, GLib.File dest, FileCopyFlags flags, FileProgressCallback progress_cb) |
226 | { |
227 | long totalBytes = source.GetSize (); |
228 | long copiedBytes = 0; |
229 | @@ -247,11 +304,25 @@ |
230 | /// </returns> |
231 | public static bool DirectoryHasFiles (this GLib.File file) |
232 | { |
233 | - IO.DirectoryInfo dir = new IO.DirectoryInfo (file.Path); |
234 | - |
235 | - if (dir.GetFiles ().Count () > 0 || dir.GetDirectories ().Count () > 0) |
236 | - return true; |
237 | - return false; |
238 | + IntPtr enumerator = NativeInterop.GFileEnumerateChildren (file, "standard::name", |
239 | + FileQueryInfoFlags.NofollowSymlinks, null); |
240 | + |
241 | + IntPtr info = IntPtr.Zero; |
242 | + bool result = false; |
243 | + |
244 | + try { |
245 | + info = NativeInterop.GFileEnumeratorNextFile (enumerator, null); |
246 | + } catch (Exception e) { |
247 | + Log.Error ("Error enumerating children of '{0}': {1}", file.Path, e.Message); |
248 | + Log.Debug (e.ToString ()); |
249 | + } |
250 | + |
251 | + result = (info != IntPtr.Zero); |
252 | + |
253 | + NativeInterop.GObjectUnref (info); |
254 | + NativeInterop.GFileEnumeratorClose (enumerator, null); |
255 | + |
256 | + return result; |
257 | } |
258 | |
259 | public static string NewFileName (this GLib.File fileToMove, File dest) |
260 | @@ -278,7 +349,7 @@ |
261 | |
262 | static void Recursive_Copy (GLib.File source, GLib.File dest, FileCopyFlags flags, ref long copiedBytes, long totalBytes, FileProgressCallback progress_cb) |
263 | { |
264 | - if (IO.File.Exists (source.Path)) { |
265 | + if (source.Exists && source.QueryFileType (FileQueryInfoFlags.NofollowSymlinks) != FileType.Directory) { |
266 | source.Copy (dest, flags, null, (current, total) => { |
267 | progress_cb.Invoke (current, totalBytes); |
268 | }); |
269 | @@ -315,14 +386,12 @@ |
270 | public static long GetSize (this GLib.File file) |
271 | { |
272 | // if file is a regular file (not a directory), return the size |
273 | - if (IO.File.Exists (file.Path)) |
274 | + if (file.Exists && file.QueryFileType (FileQueryInfoFlags.NofollowSymlinks) != FileType.Directory) |
275 | return file.Size (); |
276 | |
277 | // otherwise treat it as a directory, and aggregate the size of all files in all subdirs (recursive) |
278 | long size = 0; |
279 | - IEnumerable<GLib.File> files = IO.Directory.GetFiles (file.Path, "*", IO.SearchOption.AllDirectories) |
280 | - .Select (f => FileFactory.NewForPath (f)); |
281 | - foreach (File f in files) |
282 | + foreach (File f in file.GetFiles ()) |
283 | size += f.GetSize (); |
284 | return size; |
285 | } |
286 | |
287 | === removed file 'Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs' |
288 | --- Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs 2010-04-09 14:26:19 +0000 |
289 | +++ Docky.Services/Docky.Services/Extensions/GLibMountExtension.cs 1970-01-01 00:00:00 +0000 |
290 | @@ -1,122 +0,0 @@ |
291 | -// |
292 | -// Copyright (C) 2009 Chris Szikszoy |
293 | -// |
294 | -// This program is free software: you can redistribute it and/or modify |
295 | -// it under the terms of the GNU General Public License as published by |
296 | -// the Free Software Foundation, either version 3 of the License, or |
297 | -// (at your option) any later version. |
298 | -// |
299 | -// This program is distributed in the hope that it will be useful, |
300 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
301 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
302 | -// GNU General Public License for more details. |
303 | -// |
304 | -// You should have received a copy of the GNU General Public License |
305 | -// along with this program. If not, see <http://www.gnu.org/licenses/>. |
306 | -// |
307 | - |
308 | -using System; |
309 | -using IO = System.IO; |
310 | -using System.Collections.Generic; |
311 | - |
312 | -using GLib; |
313 | -using Gtk; |
314 | - |
315 | -namespace Docky.Services |
316 | -{ |
317 | - |
318 | - public static class GLibMountExtension |
319 | - { |
320 | - |
321 | - const string EmptyTrashTitle = "Do you want to empty the trash before you unmount?"; |
322 | - const string EmptyTrashMessage = "In order to regain the free space on this volume " + |
323 | - "the trash must be emptied. All trashed items on the volume will be permanently lost."; |
324 | - |
325 | - // as of GLib 2.22, Mount.UnMount and Mount.Eject are deprecated. These should be used instead. |
326 | - public static void UnmountWithOperation (this GLib.Mount m, MountUnmountFlags flags, GLib.MountOperation operation, |
327 | - Cancellable cancellable, AsyncReadyCallback callback) |
328 | - { |
329 | - m.MaybeEmptyTrashWithAction (() => { |
330 | - NativeInterop.UnmountWithOperation (m, flags, operation, cancellable, callback); |
331 | - }); |
332 | - } |
333 | - |
334 | - public static void EjectWithOperation (this GLib.Mount m, MountUnmountFlags flags, GLib.MountOperation operation, |
335 | - Cancellable cancellable, AsyncReadyCallback callback) |
336 | - { |
337 | - m.MaybeEmptyTrashWithAction (() => { |
338 | - NativeInterop.EjectWithOperation (m, flags, operation, cancellable, callback); |
339 | - }); |
340 | - } |
341 | - |
342 | - public static bool EjectWithOperationFinish (this GLib.Mount m, AsyncResult result) |
343 | - { |
344 | - return NativeInterop.EjectWithOperationFinish (m, result); |
345 | - } |
346 | - |
347 | - public static bool UnmountWithOperationFinish (this GLib.Mount m, AsyncResult result) |
348 | - { |
349 | - return NativeInterop.UnmountWithOperation (m, result); |
350 | - } |
351 | - |
352 | - static void MaybeEmptyTrashWithAction (this Mount m, System.Action act) |
353 | - { |
354 | - bool perform = true; |
355 | - |
356 | - if (m.TrashHasFiles ()) { |
357 | - MessageDialog dialog; |
358 | - ResponseType response = m.PromptEmptyTrash (out dialog); |
359 | - if (response == ResponseType.Accept) { |
360 | - foreach (File dir in m.TrashDirs ()) { |
361 | - IO.DirectoryInfo info = new IO.DirectoryInfo (dir.Path); |
362 | - info.Delete (true); |
363 | - } |
364 | - } else if (response == ResponseType.Cancel) { |
365 | - perform = false; |
366 | - } |
367 | - dialog.Hide (); |
368 | - dialog.Destroy (); |
369 | - } |
370 | - if (perform) |
371 | - act.Invoke (); |
372 | - } |
373 | - |
374 | - public static bool TrashHasFiles (this Mount m) |
375 | - { |
376 | - foreach (File f in m.TrashDirs ()) { |
377 | - if (f.QueryExists (null) && f.DirectoryHasFiles ()) |
378 | - return true; |
379 | - } |
380 | - return false; |
381 | - } |
382 | - |
383 | - static IEnumerable<File> TrashDirs (this Mount m) |
384 | - { |
385 | - File root = m.Root; |
386 | - if (root == null) |
387 | - yield break; |
388 | - |
389 | - if (root.IsNative) { |
390 | - IO.DirectoryInfo rootInfo = new IO.DirectoryInfo (root.Path); |
391 | - foreach (IO.DirectoryInfo d in rootInfo.GetDirectories (".Trash*", IO.SearchOption.TopDirectoryOnly)) { |
392 | - yield return FileFactory.NewForPath (root.GetChild (d.Name).GetChild ("files").Path); |
393 | - yield return FileFactory.NewForPath (root.GetChild (d.Name).GetChild ("info").Path); |
394 | - } |
395 | - } |
396 | - } |
397 | - |
398 | - static ResponseType PromptEmptyTrash (this Mount m, out MessageDialog dialog) |
399 | - { |
400 | - dialog = new Gtk.MessageDialog (null, DialogFlags.Modal, MessageType.Question, |
401 | - ButtonsType.None, EmptyTrashMessage); |
402 | - dialog.Title = EmptyTrashTitle; |
403 | - dialog.AddButton ("Do _not Empty Trash", ResponseType.Reject); |
404 | - dialog.AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); |
405 | - dialog.AddButton ("Empty _Trash", ResponseType.Accept); |
406 | - dialog.DefaultResponse = ResponseType.Accept; |
407 | - dialog.SkipTaskbarHint = true; |
408 | - |
409 | - return (ResponseType) dialog.Run (); |
410 | - } |
411 | - } |
412 | -} |
413 | |
414 | === modified file 'Docky.Services/Docky.Services/NativeInterop.cs' |
415 | --- Docky.Services/Docky.Services/NativeInterop.cs 2010-06-02 07:30:16 +0000 |
416 | +++ Docky.Services/Docky.Services/NativeInterop.cs 2010-09-23 09:03:02 +0000 |
417 | @@ -34,22 +34,6 @@ |
418 | [DllImport("libc")] |
419 | private static extern int prctl (int option, byte[] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5); |
420 | |
421 | - // these next 4 methods are not yet in GIO#. The methods in GIO# (Unmount, Eject, UnmountFinish, EjectFinish) |
422 | - // have been marked as deprecated since 2.22. Once GIO# gets these methods we can remove these. |
423 | - [DllImport("gio-2.0")] |
424 | - private static extern void g_mount_unmount_with_operation (IntPtr mount, int flags, IntPtr mount_operation, |
425 | - IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative callback, IntPtr user_data); |
426 | - |
427 | - [DllImport("gio-2.0")] |
428 | - private static extern void g_mount_eject_with_operation (IntPtr mount, int flags, IntPtr mount_operation, |
429 | - IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative callback, IntPtr user_data); |
430 | - |
431 | - [DllImport("gio-2.0")] |
432 | - private static extern bool g_mount_unmount_with_operation_finish (IntPtr mount, IntPtr result, out IntPtr error); |
433 | - |
434 | - [DllImport("gio-2.0")] |
435 | - private static extern bool g_mount_eject_with_operation_finish (IntPtr mount, IntPtr result, out IntPtr error); |
436 | - |
437 | // GTK# seems not to have lookup_by_gicon... I need it... |
438 | [DllImport("libgtk-x11-2.0", CallingConvention = CallingConvention.Cdecl)] |
439 | private static extern IntPtr gtk_icon_theme_lookup_by_gicon (IntPtr icon_theme, IntPtr icon, int size, int flags); |
440 | @@ -89,19 +73,28 @@ |
441 | private static extern IntPtr g_file_info_get_attribute_byte_string (IntPtr info, string attribute); |
442 | |
443 | [DllImport("gio-2.0")] |
444 | - static extern uint g_file_info_get_attribute_uint32 (IntPtr info, string attribute); |
445 | - |
446 | - [DllImport("gio-2.0")] |
447 | - static extern ulong g_file_info_get_attribute_uint64 (IntPtr info, string attribute); |
448 | - |
449 | - [DllImport("gio-2.0")] |
450 | - static extern bool g_file_info_get_attribute_boolean (IntPtr info, string attribute); |
451 | - |
452 | - [DllImport("gio-2.0")] |
453 | - static extern long g_file_info_get_size (IntPtr info); |
454 | - |
455 | - [DllImport("gio-2.0")] |
456 | - static extern IntPtr g_file_info_get_icon (IntPtr info); |
457 | + private static extern uint g_file_info_get_attribute_uint32 (IntPtr info, string attribute); |
458 | + |
459 | + [DllImport("gio-2.0")] |
460 | + private static extern ulong g_file_info_get_attribute_uint64 (IntPtr info, string attribute); |
461 | + |
462 | + [DllImport("gio-2.0")] |
463 | + private static extern bool g_file_info_get_attribute_boolean (IntPtr info, string attribute); |
464 | + |
465 | + [DllImport("gio-2.0")] |
466 | + private static extern IntPtr g_file_enumerate_children (IntPtr file, string attributes, int flags, IntPtr cancellable, out IntPtr error); |
467 | + |
468 | + [DllImport("gio-2.0")] |
469 | + private static extern bool g_file_enumerator_close (IntPtr enumerator, IntPtr cancellable, out IntPtr error); |
470 | + |
471 | + [DllImport("gio-2.0")] |
472 | + private static extern IntPtr g_file_enumerator_next_file (IntPtr enumerator, IntPtr cancellable, out IntPtr error); |
473 | + |
474 | + [DllImport("gio-2.0")] |
475 | + private static extern long g_file_info_get_size (IntPtr info); |
476 | + |
477 | + [DllImport("gio-2.0")] |
478 | + private static extern IntPtr g_file_info_get_icon (IntPtr info); |
479 | |
480 | #endregion |
481 | |
482 | @@ -125,57 +118,6 @@ |
483 | "Failed to set process name: {0}"); |
484 | } |
485 | |
486 | - public static void UnmountWithOperation (Mount mount, MountUnmountFlags flags, MountOperation op, |
487 | - Cancellable cancellable, AsyncReadyCallback cb) |
488 | - { |
489 | - NativeHelper (() => |
490 | - { |
491 | - GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb); |
492 | - g_mount_unmount_with_operation (mount.Handle, (int) flags, op == null ? IntPtr.Zero : op.Handle, |
493 | - cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero); |
494 | - }, GIO_NOT_FOUND, |
495 | - "Failed to unmount with operation: {0}"); |
496 | - } |
497 | - |
498 | - public static void EjectWithOperation (Mount mount, MountUnmountFlags flags, MountOperation op, |
499 | - Cancellable cancellable, AsyncReadyCallback cb) |
500 | - { |
501 | - NativeHelper (() => |
502 | - { |
503 | - GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb); |
504 | - g_mount_eject_with_operation (mount.Handle, (int) flags, op == null ? IntPtr.Zero : op.Handle, |
505 | - cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero); |
506 | - }, GIO_NOT_FOUND, |
507 | - "Failed to eject with operation name: {0}"); |
508 | - } |
509 | - |
510 | - public static bool EjectWithOperationFinish (Mount mount, AsyncResult result) |
511 | - { |
512 | - return NativeHelper<bool> (() => |
513 | - { |
514 | - IntPtr error = IntPtr.Zero; |
515 | - bool success = g_mount_eject_with_operation_finish (mount.Handle, result == null ? IntPtr.Zero : |
516 | - ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error); |
517 | - if (error != IntPtr.Zero) |
518 | - throw new GLib.GException (error); |
519 | - return success; |
520 | - }, false, GIO_NOT_FOUND, |
521 | - "Failed to eject with operation finish name: {0}"); |
522 | - } |
523 | - |
524 | - public static bool UnmountWithOperation (Mount mount, AsyncResult result) |
525 | - { |
526 | - return NativeHelper<bool> (() => |
527 | - { |
528 | - IntPtr error = IntPtr.Zero; |
529 | - 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); |
530 | - if (error != IntPtr.Zero) |
531 | - throw new GLib.GException (error); |
532 | - return success; |
533 | - }, false, GIO_NOT_FOUND, |
534 | - "Failed to unmount with operation finish name: {0}"); |
535 | - } |
536 | - |
537 | public static Gtk.IconInfo IconThemeLookUpByGIcon (Gtk.IconTheme theme, GLib.Icon icon, int size, int flags) |
538 | { |
539 | return NativeHelper<Gtk.IconInfo> (() => |
540 | @@ -191,6 +133,51 @@ |
541 | |
542 | #region Workaround for GLib.FileInfo leaks... |
543 | |
544 | + public static IntPtr GFileEnumerateChildren (GLib.File file, string attributes, FileQueryInfoFlags flags, Cancellable cancellable) |
545 | + { |
546 | + return NativeHelper<IntPtr> (() => |
547 | + { |
548 | + IntPtr error; |
549 | + IntPtr enumerator = g_file_enumerate_children (file.Handle, attributes, (int) flags, |
550 | + cancellable == null ? IntPtr.Zero : cancellable.Handle, out error); |
551 | + |
552 | + if (error != IntPtr.Zero) |
553 | + throw new GException (error); |
554 | + return enumerator; |
555 | + }, IntPtr.Zero, GIO_NOT_FOUND, |
556 | + string.Format ("Failed to enumerate children for '{0}': ", file.Path) + "{0}"); |
557 | + } |
558 | + |
559 | + public static IntPtr GFileEnumeratorNextFile (IntPtr enumerator, Cancellable cancellable) |
560 | + { |
561 | + return NativeHelper<IntPtr> (() => |
562 | + { |
563 | + IntPtr error; |
564 | + IntPtr info = g_file_enumerator_next_file (enumerator, cancellable == null ? |
565 | + IntPtr.Zero : cancellable.Handle, out error); |
566 | + |
567 | + if (error != IntPtr.Zero) |
568 | + throw new GException (error); |
569 | + return info; |
570 | + }, IntPtr.Zero, GIO_NOT_FOUND, |
571 | + "Failed to enumerate next file: {0}"); |
572 | + } |
573 | + |
574 | + public static bool GFileEnumeratorClose (IntPtr enumerator, Cancellable cancellable) |
575 | + { |
576 | + return NativeHelper<bool> (() => |
577 | + { |
578 | + IntPtr error; |
579 | + bool ret = g_file_enumerator_close (enumerator, cancellable == null ? |
580 | + IntPtr.Zero : cancellable.Handle, out error); |
581 | + |
582 | + if (error != IntPtr.Zero) |
583 | + throw new GException (error); |
584 | + return ret; |
585 | + }, false, GIO_NOT_FOUND, |
586 | + "Failed to close file enumerator: {0}"); |
587 | + } |
588 | + |
589 | public static IntPtr GFileQueryInfo (GLib.File file, string attributes, FileQueryInfoFlags flags, Cancellable cancellable) |
590 | { |
591 | return NativeHelper<IntPtr> (() => |
592 | @@ -199,10 +186,10 @@ |
593 | IntPtr info; |
594 | if (attributes.StartsWith ("filesystem::")) |
595 | info = g_file_query_filesystem_info (file.Handle, attributes, |
596 | - cancellable == null ? IntPtr.Zero : cancellable.Handle, out error); |
597 | + cancellable == null ? IntPtr.Zero : cancellable.Handle, out error); |
598 | else |
599 | info = g_file_query_info (file.Handle, attributes, (int) flags, |
600 | - cancellable == null ? IntPtr.Zero : cancellable.Handle, out error); |
601 | + cancellable == null ? IntPtr.Zero : cancellable.Handle, out error); |
602 | |
603 | if (error != IntPtr.Zero) |
604 | throw new GException (error); |
605 | |
606 | === removed directory 'Docky.Services/GLibSharp' |
607 | === removed file 'Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs' |
608 | --- Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs 2009-11-10 07:27:41 +0000 |
609 | +++ Docky.Services/GLibSharp/AsyncReadyCallbackNative.cs 1970-01-01 00:00:00 +0000 |
610 | @@ -1,92 +0,0 @@ |
611 | -// This file was generated by the Gtk# code generator. |
612 | -// Any changes made will be lost if regenerated. |
613 | - |
614 | -namespace GLibSharp { |
615 | - |
616 | - using System; |
617 | - using System.Runtime.InteropServices; |
618 | - |
619 | -#region Autogenerated code |
620 | - [UnmanagedFunctionPointer (CallingConvention.Cdecl)] |
621 | - internal delegate void AsyncReadyCallbackNative(IntPtr source_object, IntPtr res, IntPtr user_data); |
622 | - |
623 | - internal class AsyncReadyCallbackInvoker { |
624 | - |
625 | - AsyncReadyCallbackNative native_cb; |
626 | - IntPtr __data; |
627 | - GLib.DestroyNotify __notify; |
628 | - |
629 | - ~AsyncReadyCallbackInvoker () |
630 | - { |
631 | - if (__notify == null) |
632 | - return; |
633 | - __notify (__data); |
634 | - } |
635 | - |
636 | - internal AsyncReadyCallbackInvoker (AsyncReadyCallbackNative native_cb) : this (native_cb, IntPtr.Zero, null) {} |
637 | - |
638 | - internal AsyncReadyCallbackInvoker (AsyncReadyCallbackNative native_cb, IntPtr data) : this (native_cb, data, null) {} |
639 | - |
640 | - internal AsyncReadyCallbackInvoker (AsyncReadyCallbackNative native_cb, IntPtr data, GLib.DestroyNotify notify) |
641 | - { |
642 | - this.native_cb = native_cb; |
643 | - __data = data; |
644 | - __notify = notify; |
645 | - } |
646 | - |
647 | - internal GLib.AsyncReadyCallback Handler { |
648 | - get { |
649 | - return new GLib.AsyncReadyCallback(InvokeNative); |
650 | - } |
651 | - } |
652 | - |
653 | - void InvokeNative (GLib.Object source_object, GLib.AsyncResult res) |
654 | - { |
655 | - 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); |
656 | - } |
657 | - } |
658 | - |
659 | - internal class AsyncReadyCallbackWrapper { |
660 | - |
661 | - public void NativeCallback (IntPtr source_object, IntPtr res, IntPtr user_data) |
662 | - { |
663 | - try { |
664 | - managed (GLib.Object.GetObject (source_object), GLib.AsyncResultAdapter.GetObject (res, false)); |
665 | - if (release_on_call) |
666 | - gch.Free (); |
667 | - } catch (Exception e) { |
668 | - GLib.ExceptionManager.RaiseUnhandledException (e, false); |
669 | - } |
670 | - } |
671 | - |
672 | - bool release_on_call = false; |
673 | - GCHandle gch; |
674 | - |
675 | - public void PersistUntilCalled () |
676 | - { |
677 | - release_on_call = true; |
678 | - gch = GCHandle.Alloc (this); |
679 | - } |
680 | - |
681 | - internal AsyncReadyCallbackNative NativeDelegate; |
682 | - GLib.AsyncReadyCallback managed; |
683 | - |
684 | - public AsyncReadyCallbackWrapper (GLib.AsyncReadyCallback managed) |
685 | - { |
686 | - this.managed = managed; |
687 | - if (managed != null) |
688 | - NativeDelegate = new AsyncReadyCallbackNative (NativeCallback); |
689 | - } |
690 | - |
691 | - public static GLib.AsyncReadyCallback GetManagedDelegate (AsyncReadyCallbackNative native) |
692 | - { |
693 | - if (native == null) |
694 | - return null; |
695 | - AsyncReadyCallbackWrapper wrapper = (AsyncReadyCallbackWrapper) native.Target; |
696 | - if (wrapper == null) |
697 | - return null; |
698 | - return wrapper.managed; |
699 | - } |
700 | - } |
701 | -#endregion |
702 | -} |
703 | |
704 | === modified file 'Docky.Services/Makefile.am' |
705 | --- Docky.Services/Makefile.am 2010-08-06 07:59:35 +0000 |
706 | +++ Docky.Services/Makefile.am 2010-09-23 09:03:02 +0000 |
707 | @@ -15,7 +15,6 @@ |
708 | Docky.Services/Helpers/HelperMetadata.cs \ |
709 | Docky.Services/Extensions/GdkPixbufExtension.cs \ |
710 | Docky.Services/Extensions/GLibFileExtension.cs \ |
711 | - Docky.Services/Extensions/GLibMountExtension.cs \ |
712 | Docky.Services/Extensions/GtkIconThemeExtension.cs \ |
713 | Docky.Services/Extensions/WnckWindowExtension.cs \ |
714 | Docky.Services/Logging/ConsoleCrayon.cs \ |
715 | @@ -42,8 +41,7 @@ |
716 | Docky.Services/SystemService.cs \ |
717 | Docky.Services/ThemeService.cs \ |
718 | Docky.Services/WindowMatcherService.cs \ |
719 | - Gtk/MountOperation.cs \ |
720 | - GLibSharp/AsyncReadyCallbackNative.cs |
721 | + Gtk/MountOperation.cs |
722 | |
723 | RESOURCES = \ |
724 | Resources/background.svg \ |
725 | |
726 | === modified file 'Docky/Docky/Interface/DockPreferences.cs' |
727 | --- Docky/Docky/Interface/DockPreferences.cs 2010-08-03 02:44:47 +0000 |
728 | +++ Docky/Docky/Interface/DockPreferences.cs 2010-09-23 09:03:02 +0000 |
729 | @@ -32,6 +32,7 @@ |
730 | using Docky.Items; |
731 | using Docky.Services; |
732 | using Docky.Services.Prefs; |
733 | +using Docky.Services.Applications; |
734 | |
735 | namespace Docky.Interface |
736 | { |
737 | @@ -449,7 +450,6 @@ |
738 | |
739 | public bool SetName (string name) |
740 | { |
741 | - |
742 | return false; |
743 | } |
744 | |
745 | @@ -590,50 +590,19 @@ |
746 | if (FirstRun) { |
747 | WindowManager = true; |
748 | |
749 | - // TODO optimize this better, right now we try to find files and |
750 | - // pick the first one we find (which sorta works) |
751 | - // ideally, we should query the system for the 'default web browser' |
752 | - // etc and then use that |
753 | - |
754 | - // browser |
755 | - string launcher_browser = new[] { |
756 | - "file:///usr/share/applications/firefox.desktop", |
757 | - "file:///usr/share/applications/chromium-browser.desktop", |
758 | - "file:///usr/local/share/applications/google-chrome.desktop", |
759 | - "file:///usr/share/applications/epiphany.desktop", |
760 | - "file:///usr/share/applications/kde4/konqbrowser.desktop", |
761 | - }.Where (s => System.IO.File.Exists (new Uri (s).LocalPath)).FirstOrDefault (); |
762 | - |
763 | - // terminal |
764 | - string launcher_terminal = new[] { |
765 | - "file:///usr/share/applications/terminator.desktop", |
766 | - "file:///usr/share/applications/gnome-terminal.desktop", |
767 | - "file:///usr/share/applications/kde4/konsole.desktop", |
768 | - }.Where (s => System.IO.File.Exists (new Uri (s).LocalPath)).FirstOrDefault (); |
769 | - |
770 | - // music player |
771 | - string launcher_music = new[] { |
772 | - "file:///usr/share/applications/exaile.desktop", |
773 | - "file:///usr/share/applications/songbird.desktop", |
774 | - "file:///usr/share/applications/banshee-1.desktop", |
775 | - "file:///usr/share/applications/rhythmbox.desktop", |
776 | - "file:///usr/share/applications/kde4/amarok.desktop", |
777 | - }.Where (s => System.IO.File.Exists (new Uri (s).LocalPath)).FirstOrDefault (); |
778 | - |
779 | - // IM client |
780 | - string launcher_im = new[] { |
781 | - "file:///usr/share/applications/pidgin.desktop", |
782 | - "file:///usr/share/applications/empathy.desktop", |
783 | - }.Where (s => System.IO.File.Exists (new Uri (s).LocalPath)).FirstOrDefault (); |
784 | - |
785 | - Launchers = new[] { |
786 | - launcher_browser, |
787 | - launcher_terminal, |
788 | - launcher_music, |
789 | - launcher_im, |
790 | - }.Where (s => !String.IsNullOrEmpty (s)); |
791 | + // grab the default apps from gconf |
792 | + |
793 | + IPreferences gnomePrefs = DockServices.Preferences.Get ("/desktop/gnome"); |
794 | + |
795 | + string preferredBrowser = gnomePrefs.Get<string> ("applications/browser/exec", ""); |
796 | + string preferredMedia = gnomePrefs.Get<string> ("applications/media/exec", ""); |
797 | + string preferredMail = gnomePrefs.Get<string> ("url-handlers/mailto/command", ""); |
798 | + |
799 | + Launchers = new [] { preferredBrowser, preferredMedia, preferredMail }.Select (app => app.Split (new [] {' '})[0]) |
800 | + .Select (exec => DockServices.DesktopItems.DesktopItemsFromExec (exec).FirstOrDefault ()) |
801 | + .Select (di => di.Path); |
802 | } |
803 | - |
804 | + |
805 | foreach (string launcher in Launchers) { |
806 | DefaultProvider.InsertItem (launcher); |
807 | } |
808 | |
809 | === modified file 'StandardPlugins/Trash/src/TrashDockItem.cs' |
810 | --- StandardPlugins/Trash/src/TrashDockItem.cs 2010-08-03 02:44:47 +0000 |
811 | +++ StandardPlugins/Trash/src/TrashDockItem.cs 2010-09-23 09:03:02 +0000 |
812 | @@ -251,7 +251,7 @@ |
813 | TrashMonitor.Changed -= HandleChanged; |
814 | |
815 | DockServices.System.RunOnMainThread (() => { |
816 | - OwnedFile.Delete_Recurse (); |
817 | + OwnedFile.DeleteRecursive (); |
818 | }); |
819 | |
820 | // eneble events again |
821 | |
822 | === modified file 'm4/intltool.m4' |
823 | --- m4/intltool.m4 2010-06-25 13:06:51 +0000 |
824 | +++ m4/intltool.m4 2010-09-23 09:03:02 +0000 |
825 | @@ -172,7 +172,7 @@ |
826 | AC_DEFUN([IT_PO_SUBDIR], |
827 | [AC_PREREQ([2.53])dnl We use ac_top_srcdir inside AC_CONFIG_COMMANDS. |
828 | dnl |
829 | -dnl The following CONFIG_COMMANDS should be exetuted at the very end |
830 | +dnl The following CONFIG_COMMANDS should be executed at the very end |
831 | dnl of config.status. |
832 | AC_CONFIG_COMMANDS_PRE([ |
833 | AC_CONFIG_COMMANDS([$1/stamp-it], [ |