Merge lp:~awn-core/libdesktop-agnostic/various-fixes into lp:libdesktop-agnostic
- various-fixes
- Merge into trunk
Status: | Merged | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 399 | ||||||||||||||||||||||||||||||||
Proposed branch: | lp:~awn-core/libdesktop-agnostic/various-fixes | ||||||||||||||||||||||||||||||||
Merge into: | lp:libdesktop-agnostic | ||||||||||||||||||||||||||||||||
Diff against target: |
2099 lines (+1062/-186) 37 files modified
debian/control (+3/-3) docs/known-issues.rst (+1/-1) libdesktop-agnostic/config-bridge.vala (+4/-6) libdesktop-agnostic/config-client.vala (+2/-3) libdesktop-agnostic/config-impl-gconf.vala (+0/-1) libdesktop-agnostic/config-impl-keyfile.vala (+4/-1) libdesktop-agnostic/config-impl-memory.vala (+0/-1) libdesktop-agnostic/config-impl-null.vala (+0/-1) libdesktop-agnostic/config-schema.vala (+2/-1) libdesktop-agnostic/config-type-color.vala (+0/-1) libdesktop-agnostic/desktop-entry-impl-gio.vala (+394/-0) libdesktop-agnostic/desktop-entry-impl-glib.vala (+53/-1) libdesktop-agnostic/desktop-entry-impl-gnome.vala (+0/-1) libdesktop-agnostic/ui-color-button.vala (+1/-1) libdesktop-agnostic/ui-icon-chooser-dialog.vala (+147/-64) libdesktop-agnostic/ui-launcher-editor-dialog.vala (+123/-53) libdesktop-agnostic/vfs-bookmarks-gtk.vala (+1/-1) libdesktop-agnostic/vfs-file-impl-gio.vala (+65/-0) libdesktop-agnostic/vfs-file-impl-gnome-vfs.vala (+18/-0) libdesktop-agnostic/vfs-file-impl-thunar-vfs.vala (+18/-0) libdesktop-agnostic/vfs-file.vala (+42/-0) libdesktop-agnostic/vfs-impl-gio.vala (+0/-1) libdesktop-agnostic/vfs-impl-gnome-vfs.vala (+0/-1) libdesktop-agnostic/vfs-impl-thunar-vfs.vala (+0/-1) libdesktop-agnostic/vfs-trash-impl-gio.vala (+1/-1) libdesktop-agnostic/vfs-trash-impl-thunar-vfs.vala (+1/-1) libdesktop-agnostic/vfs-volume-impl-gio.vala (+4/-4) libdesktop-agnostic/vfs-volume-impl-gnome-vfs.vala (+1/-2) libdesktop-agnostic/vfs-volume-impl-thunar-vfs.vala (+1/-1) libdesktop-agnostic/wscript (+14/-5) python/desktopagnostic.override (+22/-14) python/fdo.override (+15/-3) python/ui.override (+5/-1) python/vfs.defs (+38/-0) python/vfs.override (+70/-6) tools/lda-desktop-entry-editor.vala (+2/-2) wscript (+10/-3) |
||||||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~awn-core/libdesktop-agnostic/various-fixes | ||||||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mark Lee | style, build system | Needs Fixing | |
Julien Lavergne | Approve | ||
Review via email: mp+45033@code.launchpad.net |
Commit message
Description of the change
Could we please merge this into trunk. I understand it may not be perfect but we have a large number of users of awn trunk who need this... many who have been waiting very patiently. I'd be really happy if this could be merged and a snapshot release made. dave_largo is running out of a release window and may be stuck with releasing awn 0.4.0 to his users if something isn't done soon.
Michal Hruby (mhr3) wrote : | # |
I'd like Mark to look at the addition of "--disable-gi" configure option, I'm sure it could use some cleanup. Other than that I think this should be good to go (wonder why there's no diff here)...
Mark Lee (malept) wrote : | # |
> I'd like Mark to look at the addition of "--disable-gi" configure option,
> I'm sure it could use some cleanup.
Done, among other things:
=== libdesktop-
> + if bld.env[
Two lines, please (PEP8 applies). Same for all of the other instances.
=== python/
+ if (ret != NULL)
+ g_object_unref (ret);
Could someone please add curly braces to all of the statements which don't have them?
=== wscript:
+ opt.add_
+ dest='no_gi', default=False)
I generally don't like the idea of variable names with negatives in them. Could it change to be "dest='enable_gi', default=True)"?
> (wonder why there's no diff here)...
It looks like it's because the parent branch doesn't take into account my changing of the owner. I couldn't even `bzr branch` until I temporarily changed the owner of the main branch back to myself. Really stupid.
Michal Hruby (mhr3) wrote : | # |
> It looks like it's because the parent branch doesn't take into account my changing of the owner. I couldn't even `bzr branch` until I temporarily changed the owner of the main branch back to myself. Really stupid.
Got LP guys to fix it.
- 424. By Michal Hruby
-
Whoops, did I remove gilir's commit?
- 425. By Michal Hruby
-
PEP8 changes to wscript
Michal Hruby (mhr3) wrote : | # |
> > I'd like Mark to look at the addition of "--disable-gi" configure option,
> > I'm sure it could use some cleanup.
>
> Done, among other things:
>
> === libdesktop-
> > + if bld.env[
>
> Two lines, please (PEP8 applies). Same for all of the other instances.
Done.
>
> === python/
> + if (ret != NULL)
> + g_object_unref (ret);
>
> Could someone please add curly braces to all of the statements which don't
> have them?
This is the style rest of the python code generation uses.
>
> === wscript:
>
> + opt.add_
> + dest='no_gi', default=False)
>
> I generally don't like the idea of variable names with negatives in them.
> Could it change to be "dest='enable_gi', default=True)"?
>
I tried, but waf is too stupid to figure out that --disable-xyz is opposite of --enable-xyz. And no it doesn't support --enable-
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2010-04-18 20:00:06 +0000 |
3 | +++ debian/control 2011-02-13 20:22:06 +0000 |
4 | @@ -9,9 +9,9 @@ |
5 | intltool, |
6 | valac (>= 0.7.10), |
7 | gobject-introspection (>= 0.6.3), |
8 | - gobject-introspection-glib-2.0, |
9 | - gobject-introspection-freedesktop, |
10 | - gobject-introspection-repository, |
11 | + gir-repository-dev (>= 0.6.3) | gobject-introspection-glib-2.0, |
12 | + gir-repository-dev (>= 0.6.3) | gobject-introspection-freedesktop, |
13 | + gir-repository-dev (>= 0.6.3) | gobject-introspection-repository, |
14 | libgirepository1.0-dev (>= 0.6.3), |
15 | libglib2.0-dev (>= 2.16.0), |
16 | libgtk2.0-dev, |
17 | |
18 | === modified file 'docs/known-issues.rst' |
19 | --- docs/known-issues.rst 2009-08-18 17:29:21 +0000 |
20 | +++ docs/known-issues.rst 2011-02-13 20:22:06 +0000 |
21 | @@ -19,7 +19,7 @@ |
22 | config-bridge.vala:164: warning: pointer targets in passing argument 2 of ‘g_object_class_list_properties’ differ in signedness |
23 | desktop-entry-impl-glib.c:306: warning: pointer targets in passing argument 4 of ‘g_key_file_get_string_list’ differ in signedness |
24 | |
25 | -.. [1] See `GNOME Bug #582092`_. |
26 | +.. [1] See `GNOME Bug #582092`_ (fixed in Vala 0.9.1). |
27 | .. [2] See `GNOME Bug #529866`_ (fixed in Vala 0.7.6). |
28 | .. [3] See `GNOME Bug #592108`_ (fixed in Vala 0.7.6). |
29 | |
30 | |
31 | === modified file 'libdesktop-agnostic/config-bridge.vala' |
32 | --- libdesktop-agnostic/config-bridge.vala 2010-03-31 20:31:44 +0000 |
33 | +++ libdesktop-agnostic/config-bridge.vala 2011-02-13 20:22:06 +0000 |
34 | @@ -202,14 +202,13 @@ |
35 | string key, ParamSpec spec, |
36 | NotifyFuncHandler func) throws GLib.Error |
37 | { |
38 | - unowned BindingNotifier notifier; |
39 | - notifier = (BindingNotifier*) config.get_data ("lda-binding-notifier"); |
40 | + unowned BindingNotifier? notifier; |
41 | + notifier = config.get_data ("lda-binding-notifier"); |
42 | if (notifier == null) |
43 | { |
44 | BindingNotifier new_notifier = new BindingNotifier (config); |
45 | notifier = new_notifier; |
46 | - config.set_data_full ("lda-binding-notifier", notifier.@ref (), |
47 | - Object.unref); |
48 | + config.set_data ("lda-binding-notifier", notifier); |
49 | } |
50 | |
51 | if (spec.value_type == typeof (bool) || |
52 | @@ -353,8 +352,7 @@ |
53 | uint pos = -1; |
54 | string binding_key; |
55 | |
56 | - unowned BindingListWrapper? obj_bindings = |
57 | - (BindingListWrapper*) obj.get_data ("lda-bindings"); |
58 | + unowned BindingListWrapper? obj_bindings = obj.get_data ("lda-bindings"); |
59 | binding_key = "%s/%s/%s".printf (config.instance_id, group, key); |
60 | bindings_list = this.bindings.get_data (binding_key); |
61 | bindings_to_remove = new SList<uint> (); |
62 | |
63 | === modified file 'libdesktop-agnostic/config-client.vala' |
64 | --- libdesktop-agnostic/config-client.vala 2010-04-07 22:45:37 +0000 |
65 | +++ libdesktop-agnostic/config-client.vala 2011-02-13 20:22:06 +0000 |
66 | @@ -101,13 +101,12 @@ |
67 | // constructors |
68 | public Client (string schema_filename) |
69 | { |
70 | - this.schema_filename = schema_filename; |
71 | + GLib.Object (schema_filename: schema_filename); |
72 | } |
73 | public Client.for_instance (string schema_filename, |
74 | string instance_id) throws GLib.Error |
75 | { |
76 | - this.schema_filename = schema_filename; |
77 | - this.instance_id = instance_id; |
78 | + GLib.Object (schema_filename: schema_filename, instance_id: instance_id); |
79 | } |
80 | /** |
81 | * Auto-determines whether an instance config object should be created. |
82 | |
83 | === modified file 'libdesktop-agnostic/config-impl-gconf.vala' |
84 | --- libdesktop-agnostic/config-impl-gconf.vala 2010-02-04 22:08:30 +0000 |
85 | +++ libdesktop-agnostic/config-impl-gconf.vala 2011-02-13 20:22:06 +0000 |
86 | @@ -654,7 +654,6 @@ |
87 | } |
88 | } |
89 | |
90 | -[ModuleInit] |
91 | public Type |
92 | register_plugin () |
93 | { |
94 | |
95 | === modified file 'libdesktop-agnostic/config-impl-keyfile.vala' |
96 | --- libdesktop-agnostic/config-impl-keyfile.vala 2009-10-21 18:48:42 +0000 |
97 | +++ libdesktop-agnostic/config-impl-keyfile.vala 2011-02-13 20:22:06 +0000 |
98 | @@ -697,6 +697,10 @@ |
99 | |
100 | if (value.n_values == 0) |
101 | { |
102 | + if (!this._data.has_group (group)) |
103 | + { |
104 | + return; |
105 | + } |
106 | if (this._data.has_key (group, key)) |
107 | { |
108 | // set_*_list() doesn't like NULL lists, so just unset the key. |
109 | @@ -764,7 +768,6 @@ |
110 | } |
111 | } |
112 | } |
113 | -[ModuleInit] |
114 | public Type |
115 | register_plugin () |
116 | { |
117 | |
118 | === modified file 'libdesktop-agnostic/config-impl-memory.vala' |
119 | --- libdesktop-agnostic/config-impl-memory.vala 2009-08-15 18:26:33 +0000 |
120 | +++ libdesktop-agnostic/config-impl-memory.vala 2011-02-13 20:22:06 +0000 |
121 | @@ -226,7 +226,6 @@ |
122 | } |
123 | } |
124 | } |
125 | -[ModuleInit] |
126 | public Type |
127 | register_plugin () |
128 | { |
129 | |
130 | === modified file 'libdesktop-agnostic/config-impl-null.vala' |
131 | --- libdesktop-agnostic/config-impl-null.vala 2009-08-06 06:38:30 +0000 |
132 | +++ libdesktop-agnostic/config-impl-null.vala 2011-02-13 20:22:06 +0000 |
133 | @@ -121,7 +121,6 @@ |
134 | } |
135 | } |
136 | } |
137 | -[ModuleInit] |
138 | public Type |
139 | register_plugin () |
140 | { |
141 | |
142 | === modified file 'libdesktop-agnostic/config-schema.vala' |
143 | --- libdesktop-agnostic/config-schema.vala 2009-09-26 20:13:40 +0000 |
144 | +++ libdesktop-agnostic/config-schema.vala 2011-02-13 20:22:06 +0000 |
145 | @@ -188,7 +188,8 @@ |
146 | */ |
147 | public Schema (string filename) throws GLib.Error |
148 | { |
149 | - this.filename = filename; |
150 | + GLib.Object (filename: filename); |
151 | + |
152 | unowned HashTable<string,Value?> backend_metadata_keys; |
153 | this.options = Datalist<SchemaOption> (); |
154 | this.keys = new HashTable<string,List<string>> (str_hash, str_equal); |
155 | |
156 | === modified file 'libdesktop-agnostic/config-type-color.vala' |
157 | --- libdesktop-agnostic/config-type-color.vala 2009-07-31 06:50:20 +0000 |
158 | +++ libdesktop-agnostic/config-type-color.vala 2011-02-13 20:22:06 +0000 |
159 | @@ -120,7 +120,6 @@ |
160 | dest_value = ct.deserialize ((string)src_value); |
161 | } |
162 | } |
163 | -[ModuleInit] |
164 | public Type |
165 | register_plugin () |
166 | { |
167 | |
168 | === added file 'libdesktop-agnostic/desktop-entry-impl-gio.vala' |
169 | --- libdesktop-agnostic/desktop-entry-impl-gio.vala 1970-01-01 00:00:00 +0000 |
170 | +++ libdesktop-agnostic/desktop-entry-impl-gio.vala 2011-02-13 20:22:06 +0000 |
171 | @@ -0,0 +1,394 @@ |
172 | +/* |
173 | + * Desktop Agnostic Library: Desktop Entry implementation using GLib. |
174 | + * |
175 | + * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com> |
176 | + * |
177 | + * This library is free software; you can redistribute it and/or |
178 | + * modify it under the terms of the GNU Lesser General Public |
179 | + * License as published by the Free Software Foundation; either |
180 | + * version 2.1 of the License, or (at your option) any later version. |
181 | + * |
182 | + * This library is distributed in the hope that it will be useful, |
183 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
184 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
185 | + * Lesser General Public License for more details. |
186 | + * |
187 | + * You should have received a copy of the GNU Lesser General Public |
188 | + * License along with this library; if not, write to the Free Software |
189 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
190 | + * |
191 | + * Author : Michal Hruby <michal.mhr@gmail.com> |
192 | + */ |
193 | + |
194 | +using DesktopAgnostic; |
195 | + |
196 | +namespace DesktopAgnostic.FDO |
197 | +{ |
198 | + private const string GROUP = "Desktop Entry"; |
199 | + public class DesktopEntryGio : DesktopEntry, Object |
200 | + { |
201 | + private KeyFile _keyfile = new KeyFile (); |
202 | + private bool loaded = false; |
203 | + private VFS.File _file = null; |
204 | + |
205 | + public VFS.File? file |
206 | + { |
207 | + get |
208 | + { |
209 | + return this._file; |
210 | + } |
211 | + set construct |
212 | + { |
213 | + if (value != null) |
214 | + { |
215 | + if (this.loaded) |
216 | + { |
217 | + warning ("The desktop entry has already been initialized."); |
218 | + } |
219 | + else if (value.exists ()) |
220 | + { |
221 | + string? path; |
222 | + |
223 | + this._file = value; |
224 | + path = value.path; |
225 | + if (path == null) |
226 | + { |
227 | + string data; |
228 | + size_t data_len; |
229 | + |
230 | + this._file.load_contents (out data, out data_len); |
231 | + this._keyfile.load_from_data (data, data_len, |
232 | + KeyFileFlags.KEEP_TRANSLATIONS); |
233 | + } |
234 | + else |
235 | + { |
236 | + this._keyfile.load_from_file (path, KeyFileFlags.KEEP_TRANSLATIONS); |
237 | + } |
238 | + this.loaded = true; |
239 | + } |
240 | + } |
241 | + } |
242 | + } |
243 | + |
244 | + public KeyFile keyfile |
245 | + { |
246 | + get |
247 | + { |
248 | + return this._keyfile; |
249 | + } |
250 | + set construct |
251 | + { |
252 | + if (value != null) |
253 | + { |
254 | + if (this.loaded) |
255 | + { |
256 | + warning ("The desktop entry has already been initialized."); |
257 | + } |
258 | + else |
259 | + { |
260 | + string data; |
261 | + size_t length; |
262 | + |
263 | + data = value.to_data (out length); |
264 | + this._keyfile.load_from_data (data, length, |
265 | + KeyFileFlags.KEEP_TRANSLATIONS); |
266 | + this.loaded = true; |
267 | + } |
268 | + } |
269 | + } |
270 | + } |
271 | + |
272 | + public string data |
273 | + { |
274 | + set construct |
275 | + { |
276 | + if (value != null && value != "") |
277 | + { |
278 | + if (this.loaded) |
279 | + { |
280 | + warning ("The desktop entry has already been initialized."); |
281 | + } |
282 | + else |
283 | + { |
284 | + this._keyfile.load_from_data (value, value.size (), |
285 | + KeyFileFlags.KEEP_TRANSLATIONS); |
286 | + this.loaded = true; |
287 | + } |
288 | + } |
289 | + } |
290 | + } |
291 | + |
292 | + public DesktopEntryType entry_type |
293 | + { |
294 | + get |
295 | + { |
296 | + string type = this.get_string ("Type"); |
297 | + switch (type) |
298 | + { |
299 | + case "Application": |
300 | + return DesktopEntryType.APPLICATION; |
301 | + case "Link": |
302 | + return DesktopEntryType.LINK; |
303 | + case "Directory": |
304 | + return DesktopEntryType.DIRECTORY; |
305 | + default: |
306 | + return DesktopEntryType.UNKNOWN; |
307 | + } |
308 | + } |
309 | + set |
310 | + { |
311 | + this.set_string ("Type", desktop_entry_type_to_string (value)); |
312 | + } |
313 | + } |
314 | + |
315 | + public string name |
316 | + { |
317 | + owned get |
318 | + { |
319 | + return this.get_string ("Name"); |
320 | + } |
321 | + set |
322 | + { |
323 | + this.set_string ("Name", value); |
324 | + } |
325 | + } |
326 | + |
327 | + public string? icon |
328 | + { |
329 | + /** |
330 | + * If a path is provided then return the given value. Otherwise, |
331 | + * strip any extension (.xpm, .svg, .png). |
332 | + */ |
333 | + owned get |
334 | + { |
335 | + string? icon_name = this.get_string ("Icon"); |
336 | + |
337 | + if (icon_name != null && Path.get_basename (icon_name) == icon_name) |
338 | + { |
339 | + icon_name = icon_name.split (".png", 2)[0]; |
340 | + icon_name = icon_name.split (".svg", 2)[0]; |
341 | + icon_name = icon_name.split (".xpm", 2)[0]; |
342 | + } |
343 | + |
344 | + return icon_name; |
345 | + } |
346 | + set |
347 | + { |
348 | + if (value == null) |
349 | + { |
350 | + warning ("Cannot set a NULL value for 'Icon'."); |
351 | + } |
352 | + else |
353 | + { |
354 | + this.set_string ("Icon", value); |
355 | + } |
356 | + } |
357 | + } |
358 | + |
359 | + public bool |
360 | + key_exists (string key) |
361 | + { |
362 | + return this._keyfile.has_group (GROUP) && |
363 | + this._keyfile.has_key (GROUP, key); |
364 | + } |
365 | + |
366 | + public bool |
367 | + get_boolean (string key) |
368 | + { |
369 | + try |
370 | + { |
371 | + return this._keyfile.get_boolean (GROUP, key); |
372 | + } |
373 | + catch (KeyFileError err) |
374 | + { |
375 | + warning ("Error trying to retrieve '%s': %s", key, err.message); |
376 | + return false; |
377 | + } |
378 | + } |
379 | + |
380 | + public void |
381 | + set_boolean (string key, bool value) |
382 | + { |
383 | + this._keyfile.set_boolean (GROUP, key, value); |
384 | + } |
385 | + |
386 | + public string? |
387 | + get_string (string key) |
388 | + { |
389 | + try |
390 | + { |
391 | + return this._keyfile.get_string (GROUP, key); |
392 | + } |
393 | + catch (KeyFileError err) |
394 | + { |
395 | + warning ("Error trying to retrieve '%s': %s", key, err.message); |
396 | + return null; |
397 | + } |
398 | + } |
399 | + |
400 | + public void |
401 | + set_string (string key, string value) |
402 | + { |
403 | + this._keyfile.set_string (GROUP, key, value); |
404 | + } |
405 | + |
406 | + public string? |
407 | + get_localestring (string key, string? locale) |
408 | + { |
409 | + try |
410 | + { |
411 | + return this._keyfile.get_locale_string (GROUP, key, locale); |
412 | + } |
413 | + catch (KeyFileError err) |
414 | + { |
415 | + warning ("Error trying to retrieve '%s[%s]': %s", key, locale, |
416 | + err.message); |
417 | + return null; |
418 | + } |
419 | + } |
420 | + |
421 | + public void |
422 | + set_localestring (string key, string locale, string value) |
423 | + { |
424 | + this._keyfile.set_locale_string (GROUP, key, locale, value); |
425 | + } |
426 | + |
427 | + [CCode (array_length = false, array_null_terminated = true)] |
428 | + public string[]? |
429 | + get_string_list (string key) |
430 | + { |
431 | + try |
432 | + { |
433 | + return this._keyfile.get_string_list (GROUP, key); |
434 | + } |
435 | + catch (KeyFileError err) |
436 | + { |
437 | + warning ("Error trying to retrieve '%s': %s", key, err.message); |
438 | + return null; |
439 | + } |
440 | + } |
441 | + |
442 | + public void |
443 | + set_string_list (string key, [CCode (array_length = false, array_null_terminated = true)] string[] value) |
444 | + { |
445 | + this._keyfile.set_string_list (GROUP, key, value); |
446 | + } |
447 | + |
448 | + /** |
449 | + * Based on EggDesktopFile's egg_desktop_file_can_launch(). |
450 | + */ |
451 | + public bool |
452 | + exists () |
453 | + { |
454 | + switch (this.entry_type) |
455 | + { |
456 | + case DesktopEntryType.APPLICATION: |
457 | + if (this._keyfile.has_key (GROUP, "TryExec")) |
458 | + { |
459 | + if (Environment.find_program_in_path (this.get_string ("TryExec")) != null) |
460 | + { |
461 | + return true; |
462 | + } |
463 | + } |
464 | + string? exec; |
465 | + string[] argv = null;; |
466 | + exec = this.get_string ("Exec"); |
467 | + if (exec == null || !Shell.parse_argv (exec, out argv)) |
468 | + { |
469 | + return false; |
470 | + } |
471 | + return Environment.find_program_in_path (argv[0]) != null; |
472 | + case DesktopEntryType.LINK: |
473 | + if (this._keyfile.has_key (GROUP, "URL")) |
474 | + { |
475 | + string uri = this._keyfile.get_string (GROUP, "URL"); |
476 | + VFS.File file = VFS.file_new_for_uri (uri); |
477 | + return file.exists (); |
478 | + } |
479 | + else |
480 | + { |
481 | + return false; |
482 | + } |
483 | + default: |
484 | + return false; |
485 | + } |
486 | + } |
487 | + |
488 | + /** |
489 | + * Launch desktop entry. |
490 | + * @return always zero. |
491 | + */ |
492 | + public Pid |
493 | + launch (DesktopEntryLaunchFlags flags, |
494 | + SList<string>? documents) throws GLib.Error |
495 | + { |
496 | + List<unowned string> uris = new List<unowned string> (); |
497 | + foreach (unowned string s in documents) |
498 | + { |
499 | + uris.append (s); |
500 | + } |
501 | + |
502 | + // interesting that GIO 2.26 supports only APPLICATION |
503 | + switch (this.entry_type) |
504 | + { |
505 | + case DesktopEntryType.APPLICATION: |
506 | + AppInfo info; |
507 | + if (this._file != null) |
508 | + { |
509 | + info = new DesktopAppInfo.from_filename (this._file.path); |
510 | + } |
511 | + else |
512 | + { |
513 | + info = new DesktopAppInfo.from_keyfile (this._keyfile); |
514 | + } |
515 | + |
516 | + //var context = new AppLaunchContext (); |
517 | + info.launch_uris (uris, null); |
518 | + |
519 | + break; |
520 | + case DesktopEntryType.LINK: |
521 | + if (this._keyfile.has_key (GROUP, "URL")) |
522 | + { |
523 | + string uri = this._keyfile.get_string (GROUP, "URL"); |
524 | + AppInfo.launch_default_for_uri (uri, null); |
525 | + } |
526 | + else |
527 | + { |
528 | + throw new DesktopEntryError.NOT_LAUNCHABLE ("Invalid desktop entry."); |
529 | + } |
530 | + break; |
531 | + default: |
532 | + throw new DesktopEntryError.NOT_LAUNCHABLE ("Unknown desktop entry type."); |
533 | + } |
534 | + |
535 | + return (Pid) 0; |
536 | + } |
537 | + |
538 | + public void |
539 | + save (VFS.File? new_file) throws GLib.Error |
540 | + { |
541 | + VFS.File? file = null; |
542 | + if (new_file != null) |
543 | + { |
544 | + file = new_file; |
545 | + } |
546 | + else if (this._file != null) |
547 | + { |
548 | + file = this._file; |
549 | + } |
550 | + else |
551 | + { |
552 | + throw new DesktopEntryError.INVALID_FILE ("No filename specified."); |
553 | + } |
554 | + file.replace_contents (this._keyfile.to_data ()); |
555 | + } |
556 | + } |
557 | +} |
558 | + |
559 | +public Type |
560 | +register_plugin () |
561 | +{ |
562 | + return typeof (DesktopAgnostic.FDO.DesktopEntryGio); |
563 | +} |
564 | + |
565 | +// vim: set ts=2 sts=2 sw=2 et ai cindent : |
566 | |
567 | === modified file 'libdesktop-agnostic/desktop-entry-impl-glib.vala' |
568 | --- libdesktop-agnostic/desktop-entry-impl-glib.vala 2010-03-26 22:45:36 +0000 |
569 | +++ libdesktop-agnostic/desktop-entry-impl-glib.vala 2011-02-13 20:22:06 +0000 |
570 | @@ -531,6 +531,59 @@ |
571 | throw new DesktopEntryError.NOT_LAUNCHABLE ("Could not parse Exec key."); |
572 | } |
573 | |
574 | + if (this._keyfile.has_key (GROUP, "Terminal") && |
575 | + this.get_boolean ("Terminal")) |
576 | + { |
577 | + string[] term_argv = new string[argv.length + 2]; |
578 | + |
579 | + // based on the code for GDesktopAppInfo |
580 | + string? check = null; |
581 | + check = Environment.find_program_in_path ("gnome-terminal"); |
582 | + if (check != null) |
583 | + { |
584 | + term_argv[0] = check; |
585 | + term_argv[1] = "-x"; |
586 | + } |
587 | + else |
588 | + { |
589 | + if (check == null) |
590 | + { |
591 | + check = Environment.find_program_in_path ("nxterm"); |
592 | + } |
593 | + if (check == null) |
594 | + { |
595 | + check = Environment.find_program_in_path ("color-xterm"); |
596 | + } |
597 | + if (check == null) |
598 | + { |
599 | + check = Environment.find_program_in_path ("rxvt"); |
600 | + } |
601 | + if (check == null) |
602 | + { |
603 | + check = Environment.find_program_in_path ("xterm"); |
604 | + } |
605 | + if (check == null) |
606 | + { |
607 | + check = Environment.find_program_in_path ("dtterm"); |
608 | + } |
609 | + if (check == null) |
610 | + { |
611 | + check = "xterm"; |
612 | + warning ("couldn't find a terminal, falling back to xterm"); |
613 | + } |
614 | + |
615 | + term_argv[0] = check; |
616 | + term_argv[1] = "-e"; |
617 | + } |
618 | + |
619 | + for (int i = 0; i < argv.length; i++) |
620 | + { |
621 | + term_argv[i+2] = argv[i]; |
622 | + } |
623 | + |
624 | + argv = (owned) term_argv; |
625 | + } |
626 | + |
627 | Process.spawn_async_with_pipes (working_dir, argv, null, flags, null, out pid); |
628 | return pid; |
629 | } |
630 | @@ -614,7 +667,6 @@ |
631 | } |
632 | } |
633 | |
634 | -[ModuleInit] |
635 | public Type |
636 | register_plugin () |
637 | { |
638 | |
639 | === modified file 'libdesktop-agnostic/desktop-entry-impl-gnome.vala' |
640 | --- libdesktop-agnostic/desktop-entry-impl-gnome.vala 2010-03-26 22:45:36 +0000 |
641 | +++ libdesktop-agnostic/desktop-entry-impl-gnome.vala 2011-02-13 20:22:06 +0000 |
642 | @@ -305,7 +305,6 @@ |
643 | } |
644 | } |
645 | |
646 | -[ModuleInit] |
647 | public Type |
648 | register_plugin () |
649 | { |
650 | |
651 | === modified file 'libdesktop-agnostic/ui-color-button.vala' |
652 | --- libdesktop-agnostic/ui-color-button.vala 2009-10-29 05:26:26 +0000 |
653 | +++ libdesktop-agnostic/ui-color-button.vala 2011-02-13 20:22:06 +0000 |
654 | @@ -38,7 +38,7 @@ |
655 | this.on_color_set (); |
656 | } |
657 | |
658 | - private override void |
659 | + protected override void |
660 | constructed () |
661 | { |
662 | this.use_alpha = true; |
663 | |
664 | === modified file 'libdesktop-agnostic/ui-icon-chooser-dialog.vala' |
665 | --- libdesktop-agnostic/ui-icon-chooser-dialog.vala 2010-02-04 22:24:49 +0000 |
666 | +++ libdesktop-agnostic/ui-icon-chooser-dialog.vala 2011-02-13 20:22:06 +0000 |
667 | @@ -35,13 +35,40 @@ |
668 | FILE |
669 | } |
670 | |
671 | + private class LazyPixbufRenderer : CellRendererPixbuf |
672 | + { |
673 | + public bool item_ready { get; set; default = false; } |
674 | + |
675 | + public signal void prepare_pixbuf (TreePath path); |
676 | + |
677 | + public override void render (Gdk.Window window, |
678 | + Gtk.Widget widget, |
679 | + Gdk.Rectangle background_area, |
680 | + Gdk.Rectangle cell_area, |
681 | + Gdk.Rectangle expose_area, |
682 | + Gtk.CellRendererState flags) |
683 | + { |
684 | + if (!item_ready) |
685 | + { |
686 | + int x, y; |
687 | + var view = widget as Gtk.IconView; |
688 | + x = cell_area.x + cell_area.width / 2; |
689 | + y = cell_area.y + cell_area.height / 2; |
690 | + var path = view.get_path_at_pos (x, y); |
691 | + prepare_pixbuf (path); |
692 | + } |
693 | + base.render (window, widget, |
694 | + background_area, cell_area, expose_area, flags); |
695 | + } |
696 | + } |
697 | + |
698 | public class IconChooserDialog : Dialog |
699 | { |
700 | private RadioButton _file; |
701 | private RadioButton _themed; |
702 | private FileChooserButton _directory; |
703 | private ComboBox _themed_context; |
704 | - private IconView _file_viewer; |
705 | + private IconView? _file_viewer = null; |
706 | private IconView? _themed_viewer = null; |
707 | private unowned IconView _viewer; |
708 | public string selected_icon { get; private set; default = null; } |
709 | @@ -53,16 +80,26 @@ |
710 | PIXBUF, |
711 | NAME, |
712 | DATA, |
713 | + PIXBUF_READY, |
714 | COUNT |
715 | } |
716 | |
717 | public signal void icon_selected (); |
718 | |
719 | + private static Gdk.Pixbuf NO_ICON; |
720 | + |
721 | + static construct |
722 | + { |
723 | + var flags = IconLookupFlags.FORCE_SIZE | IconLookupFlags.GENERIC_FALLBACK; |
724 | + NO_ICON = IconTheme.get_default ().load_icon ("gtk-file", 48, flags); |
725 | + } |
726 | + |
727 | construct |
728 | { |
729 | this.response.connect (this.on_response); |
730 | this.title = _ ("Select Icon"); |
731 | this.icon_name = STOCK_FIND; |
732 | + this.set_default_size (375, 375); |
733 | this.create_ui (); |
734 | } |
735 | |
736 | @@ -72,27 +109,17 @@ |
737 | HBox choices; |
738 | |
739 | choices = new HBox (false, 5); |
740 | - this._file = new RadioButton.with_mnemonic (null, _ ("From File")); |
741 | + this._themed = new RadioButton.with_mnemonic (null, _ ("From Theme")); |
742 | + choices.add (this._themed); |
743 | + this._file = new RadioButton.with_mnemonic_from_widget (this._themed, |
744 | + _ ("From File")); |
745 | + this._themed.active = true; |
746 | + this._themed.toggled.connect (this.on_icon_type_toggled); |
747 | choices.add (this._file); |
748 | - this._themed = new RadioButton.with_mnemonic_from_widget (this._file, |
749 | - _ ("From Theme")); |
750 | - this._themed.active = false; |
751 | - this._themed.toggled.connect (this.on_icon_type_toggled); |
752 | - choices.add (this._themed); |
753 | this.vbox.pack_start (choices, false, false, 5); |
754 | choices.show_all (); |
755 | |
756 | - this._directory = new FileChooserButton (_ ("Select icon folder"), |
757 | - FileChooserAction.SELECT_FOLDER); |
758 | - this._directory.current_folder_changed.connect (this.on_folder_changed); |
759 | - this.vbox.pack_start (this._directory, false, false, 5); |
760 | - this._directory.show (); |
761 | - |
762 | - this.add_icon_viewer (ref this._file_viewer, false); |
763 | - this._file_viewer.parent.show_all (); |
764 | - this._viewer = this._file_viewer; |
765 | - |
766 | - this.on_folder_changed (this._directory); |
767 | + this.on_icon_type_toggled (); |
768 | |
769 | this.add_buttons (STOCK_CANCEL, ResponseType.CANCEL, |
770 | STOCK_OK, ResponseType.OK); |
771 | @@ -115,30 +142,64 @@ |
772 | create_icon_viewer (bool themed) |
773 | { |
774 | IconView viewer; |
775 | - CellRendererPixbuf cell_pixbuf; |
776 | + LazyPixbufRenderer cell_pixbuf; |
777 | CellRendererText cell_text; |
778 | |
779 | viewer = new IconView.with_model (this.create_model ()); |
780 | - viewer.item_width = 72; |
781 | - viewer.columns = 4; |
782 | - viewer.column_spacing = 5; |
783 | - viewer.set_size_request (325, 300); |
784 | - viewer.tooltip_column = Column.DATA; |
785 | - cell_pixbuf = new CellRendererPixbuf (); |
786 | + // without this the IconView is not shrinkable after expanding it |
787 | + viewer.set_size_request (108, -1); |
788 | + viewer.set_item_width (108); |
789 | + viewer.set_column_spacing (5); |
790 | + viewer.set_tooltip_column (Column.DATA); |
791 | + |
792 | + cell_pixbuf = new LazyPixbufRenderer (); |
793 | cell_pixbuf.xalign = 0.5f; |
794 | cell_pixbuf.yalign = 0.5f; |
795 | cell_pixbuf.width = 48; |
796 | + |
797 | viewer.pack_start (cell_pixbuf, false); |
798 | viewer.add_attribute (cell_pixbuf, "pixbuf", Column.PIXBUF); |
799 | + viewer.add_attribute (cell_pixbuf, "item-ready", Column.PIXBUF_READY); |
800 | + |
801 | + cell_pixbuf.prepare_pixbuf.connect ((p) => |
802 | + { |
803 | + TreeIter iter; |
804 | + Value val; |
805 | + var store = this._viewer.model as ListStore; |
806 | + store.get_iter (out iter, p); |
807 | + store.get_value (iter, Column.DATA, out val); |
808 | + |
809 | + string icon_name = val.get_string (); |
810 | + IconTheme icon_theme = IconTheme.get_default (); |
811 | + var info = icon_theme.lookup_icon (icon_name, 48, 0); |
812 | + string? name = info.get_display_name (); |
813 | + if (name == null) |
814 | + { |
815 | + name = icon_name.replace ("-", " "); |
816 | + } |
817 | + try |
818 | + { |
819 | + var pixbuf = info.load_icon (); |
820 | + store.set (iter, Column.NAME, name, Column.PIXBUF, pixbuf, |
821 | + Column.PIXBUF_READY, true, -1); |
822 | + } |
823 | + catch (Error err) |
824 | + { |
825 | + warning ("Could not load %s: %s", icon_name, err.message); |
826 | + store.set (iter, Column.NAME, name, Column.PIXBUF_READY, true, -1); |
827 | + } |
828 | + }); |
829 | + |
830 | cell_text = new CellRendererText (); |
831 | cell_text.xalign = 0.5f; |
832 | - cell_text.yalign = 0; |
833 | + cell_text.yalign = 0.0f; |
834 | cell_text.wrap_mode = Pango.WrapMode.WORD; |
835 | - cell_text.wrap_width = 72; |
836 | - cell_text.width = 72; |
837 | - cell_text.ellipsize = Pango.EllipsizeMode.START; |
838 | + int wrap_width = viewer.item_width - viewer.item_padding * 2; |
839 | + cell_text.wrap_width = wrap_width; |
840 | + cell_text.width = wrap_width; |
841 | + cell_text.ellipsize = Pango.EllipsizeMode.MIDDLE; |
842 | viewer.pack_start (cell_text, true); |
843 | - viewer.add_attribute (cell_text, "text", 1); |
844 | + viewer.add_attribute (cell_text, "text", Column.NAME); |
845 | viewer.selection_mode = SelectionMode.SINGLE; |
846 | |
847 | return viewer; |
848 | @@ -148,20 +209,24 @@ |
849 | create_model () |
850 | { |
851 | // icon, name, data |
852 | - return new ListStore (Column.COUNT, typeof (Gdk.Pixbuf), typeof (string), |
853 | - typeof (string)); |
854 | + return new ListStore (Column.COUNT, |
855 | + typeof (Gdk.Pixbuf), |
856 | + typeof (string), |
857 | + typeof (string), |
858 | + typeof (bool)); |
859 | } |
860 | |
861 | private void |
862 | - on_icon_type_toggled (ToggleButton themed) |
863 | + on_icon_type_toggled () |
864 | { |
865 | if (this._themed.active) |
866 | { |
867 | if (this._themed_viewer == null) |
868 | { |
869 | unowned IconTheme icon_theme; |
870 | - unowned List<string> context_list; |
871 | + List<string> context_list; |
872 | |
873 | + // "From Theme" widgets -> context combobox + icon view |
874 | this._themed_context = new ComboBox.text (); |
875 | this._themed_context.changed.connect (this.on_icon_context_changed); |
876 | this.vbox.pack_start (this._themed_context, false, false, 5); |
877 | @@ -171,21 +236,52 @@ |
878 | icon_theme = IconTheme.get_default (); |
879 | context_list = icon_theme.list_contexts (); |
880 | context_list.sort ((CompareFunc)strcmp); |
881 | + |
882 | + int active_index = 0; |
883 | + int cur_index = 0; |
884 | foreach (unowned string context in context_list) |
885 | { |
886 | this._themed_context.append_text (context); |
887 | + // try to make "Applications" context active by default |
888 | + if (context == "Applications") |
889 | + { |
890 | + active_index = cur_index; |
891 | + } |
892 | + cur_index++; |
893 | } |
894 | - } |
895 | - this._file_viewer.parent.hide (); |
896 | - this._directory.hide (); |
897 | + this._themed_context.set_active (active_index); |
898 | + } |
899 | + |
900 | + if (this._file_viewer != null) |
901 | + { |
902 | + this._file_viewer.parent.hide (); |
903 | + this._directory.hide (); |
904 | + } |
905 | this._themed_viewer.parent.show (); |
906 | this._themed_context.show (); |
907 | this._viewer = this._themed_viewer; |
908 | } |
909 | else |
910 | { |
911 | - this._themed_viewer.parent.hide (); |
912 | - this._themed_context.hide (); |
913 | + if (this._file_viewer == null) |
914 | + { |
915 | + // "From File" widgets -> directory chooser + icon view |
916 | + this._directory = new FileChooserButton (_ ("Select icon folder"), |
917 | + FileChooserAction.SELECT_FOLDER); |
918 | + this._directory.current_folder_changed.connect (this.on_folder_changed); |
919 | + this.vbox.pack_start (this._directory, false, false, 5); |
920 | + this._directory.show (); |
921 | + |
922 | + this.add_icon_viewer (ref this._file_viewer, false); |
923 | + |
924 | + this.on_folder_changed (this._directory); |
925 | + } |
926 | + |
927 | + if (this._themed_viewer != null) |
928 | + { |
929 | + this._themed_viewer.parent.hide (); |
930 | + this._themed_context.hide (); |
931 | + } |
932 | this._file_viewer.parent.show (); |
933 | this._directory.show (); |
934 | this._viewer = this._file_viewer; |
935 | @@ -225,7 +321,9 @@ |
936 | pixbuf = new Gdk.Pixbuf.from_file_at_scale (path, 48, -1, true); |
937 | |
938 | model.append (out iter); |
939 | - model.set (iter, Column.PIXBUF, pixbuf, |
940 | + model.set (iter, |
941 | + Column.PIXBUF, pixbuf, |
942 | + Column.PIXBUF_READY, true, |
943 | Column.NAME, Path.get_basename (path), |
944 | Column.DATA, path); |
945 | } |
946 | @@ -246,7 +344,7 @@ |
947 | { |
948 | unowned ListStore model; |
949 | unowned IconTheme icon_theme; |
950 | - unowned List<string> icon_list; |
951 | + List<string> icon_list; |
952 | |
953 | model = this._themed_viewer.model as ListStore; |
954 | model.clear (); |
955 | @@ -256,29 +354,14 @@ |
956 | icon_list.sort ((CompareFunc)strcmp); |
957 | foreach (unowned string icon_name in icon_list) |
958 | { |
959 | - try |
960 | - { |
961 | - IconInfo info; |
962 | - Gdk.Pixbuf pixbuf; |
963 | - string? name; |
964 | - TreeIter iter; |
965 | + TreeIter iter; |
966 | |
967 | - info = icon_theme.lookup_icon (icon_name, 48, 0); |
968 | - pixbuf = info.load_icon (); |
969 | - name = info.get_display_name (); |
970 | - if (name == null) |
971 | - { |
972 | - name = icon_name.replace ("-", " "); |
973 | - } |
974 | - model.append (out iter); |
975 | - model.set (iter, Column.PIXBUF, pixbuf, |
976 | - Column.NAME, name, |
977 | - Column.DATA, icon_name); |
978 | - } |
979 | - catch (Error err) |
980 | - { |
981 | - warning ("Could not load %s: %s", icon_name, err.message); |
982 | - } |
983 | + model.append (out iter); |
984 | + model.set (iter, |
985 | + Column.PIXBUF, NO_ICON, |
986 | + Column.PIXBUF_READY, false, |
987 | + Column.NAME, icon_name, |
988 | + Column.DATA, icon_name); |
989 | } |
990 | } |
991 | |
992 | @@ -297,7 +380,7 @@ |
993 | |
994 | msg = _ ("Please select an icon."); |
995 | dialog = new MessageDialog (this, DialogFlags.MODAL, MessageType.ERROR, |
996 | - ButtonsType.OK, msg); |
997 | + ButtonsType.OK, "%s", msg); |
998 | dialog.title = _ ("Error"); |
999 | dialog.run (); |
1000 | dialog.destroy (); |
1001 | |
1002 | === modified file 'libdesktop-agnostic/ui-launcher-editor-dialog.vala' |
1003 | --- libdesktop-agnostic/ui-launcher-editor-dialog.vala 2009-10-27 07:36:10 +0000 |
1004 | +++ libdesktop-agnostic/ui-launcher-editor-dialog.vala 2011-02-13 20:22:06 +0000 |
1005 | @@ -53,51 +53,45 @@ |
1006 | this.attach (widget, left_attach, right_attach, top_attach, bottom_attach, |
1007 | AttachOptions.FILL, 0, 0, 0); |
1008 | } |
1009 | + |
1010 | + public void |
1011 | + attach_expand (Widget widget, uint left_attach, uint right_attach, |
1012 | + uint top_attach, uint bottom_attach) |
1013 | + { |
1014 | + this.attach (widget, left_attach, right_attach, top_attach, bottom_attach, |
1015 | + AttachOptions.FILL | AttachOptions.EXPAND, 0, 0, 0); |
1016 | + } |
1017 | } |
1018 | |
1019 | public class LauncherEditorDialog : Dialog |
1020 | { |
1021 | + private ComboBox _type_combo; |
1022 | private IconButton _icon; |
1023 | private Entry _name; |
1024 | private Entry _desc; |
1025 | private Entry _exec; |
1026 | + private Expander _advanced; |
1027 | private CheckButton _terminal; |
1028 | private CheckButton _startup_notification; |
1029 | + private unowned Label _command_label; |
1030 | public unowned VFS.File file { get; construct; } |
1031 | public VFS.File? output { get; construct; } |
1032 | - private bool _standalone; |
1033 | + public bool entry_type_sensitive { get; construct set; default = false; } |
1034 | private DesktopEntry _entry; |
1035 | |
1036 | - public LauncherEditorDialog (VFS.File file, VFS.File? output, bool standalone) |
1037 | + public LauncherEditorDialog (VFS.File file, VFS.File? output = null, |
1038 | + bool entry_type_sensitive = true) |
1039 | { |
1040 | - WindowType type; |
1041 | - |
1042 | - if (standalone) |
1043 | - { |
1044 | - type = WindowType.TOPLEVEL; |
1045 | - } |
1046 | - else |
1047 | - { |
1048 | - type = WindowType.POPUP; |
1049 | - } |
1050 | - this.type = type; |
1051 | - this._standalone = standalone; |
1052 | - this.file = file; |
1053 | - this.output = output; |
1054 | + GLib.Object (file: file, output: output, |
1055 | + border_width: 4, |
1056 | + entry_type_sensitive: entry_type_sensitive); |
1057 | } |
1058 | |
1059 | - private override void |
1060 | + protected override void |
1061 | constructed () |
1062 | { |
1063 | this.title = _ ("Desktop Entry Editor"); |
1064 | this.icon_name = "gtk-preferences"; |
1065 | - if (this._standalone) |
1066 | - { |
1067 | - this.delete_event.connect((widget, event) => { |
1068 | - main_quit (); |
1069 | - return true; |
1070 | - }); |
1071 | - } |
1072 | if (this._output == null) |
1073 | { |
1074 | this._output = file; |
1075 | @@ -113,10 +107,10 @@ |
1076 | string icon; |
1077 | Button exec_button; |
1078 | Image exec_image; |
1079 | - Label name_label, desc_label, exec_label; |
1080 | + Label type_label, name_label, desc_label, exec_label; |
1081 | HBox exec_hbox; |
1082 | - Expander advanced; |
1083 | VBox advanced_vbox; |
1084 | + bool is_application = true; |
1085 | |
1086 | // Action bar |
1087 | this.add_buttons (STOCK_CANCEL, ResponseType.CANCEL, |
1088 | @@ -125,12 +119,12 @@ |
1089 | this.response.connect (this.on_response); |
1090 | |
1091 | // Form container |
1092 | - table = new FixedTable (4, 3); |
1093 | + table = new FixedTable (3, 5); |
1094 | // FIXME Table.row_spacing needs [NoAccessorMethod] in the VAPI, in |
1095 | // Vala 0.7.6 |
1096 | //table.row_spacing = 5; |
1097 | table.set_row_spacings (5); |
1098 | - table.column_spacing = 5; |
1099 | + table.column_spacing = 6; |
1100 | |
1101 | // Icon |
1102 | if (this._entry.key_exists ("Icon")) |
1103 | @@ -143,11 +137,48 @@ |
1104 | } |
1105 | this._icon = new IconButton (icon); |
1106 | this._icon.icon_selected.connect (this.on_icon_changed); |
1107 | - table.attach_defaults (this._icon, 0, 1, 0, 3); |
1108 | + table.attach_defaults (this._icon, 0, 1, 0, 4); |
1109 | + |
1110 | + // Entry Type |
1111 | + if (this._entry.key_exists ("Type")) |
1112 | + { |
1113 | + is_application = this._entry.entry_type == DesktopEntryType.APPLICATION; |
1114 | + } |
1115 | + else |
1116 | + { |
1117 | + // if type is unset, use application |
1118 | + this._entry.entry_type = DesktopEntryType.APPLICATION; |
1119 | + } |
1120 | + type_label = new Label.with_mnemonic (_ ("T_ype:")); |
1121 | + type_label.xalign = 1.0f; |
1122 | + table.attach_defaults (type_label, 1, 2, 0, 1); |
1123 | + this._type_combo = new ComboBox.text (); |
1124 | + this._type_combo.append_text (_ ("Application")); |
1125 | + this._type_combo.append_text (_ ("Location")); |
1126 | + type_label.set_mnemonic_widget (this._type_combo); |
1127 | + |
1128 | + int active_index = -1; |
1129 | + switch (this._entry.entry_type) |
1130 | + { |
1131 | + case DesktopEntryType.APPLICATION: |
1132 | + active_index = 0; |
1133 | + break; |
1134 | + case DesktopEntryType.LINK: |
1135 | + active_index = 1; |
1136 | + break; |
1137 | + } |
1138 | + this._type_combo.set_active (active_index); |
1139 | + this._type_combo.set_sensitive (entry_type_sensitive); |
1140 | + this.notify["entry-type-sensitive"].connect ( |
1141 | + () => { this._type_combo.set_sensitive (this.entry_type_sensitive); } |
1142 | + ); |
1143 | + this._type_combo.changed.connect (this.on_type_changed); |
1144 | + table.attach_expand (this._type_combo, 2, 3, 0, 1); |
1145 | |
1146 | // Name |
1147 | name_label = new Label.with_mnemonic (_ ("_Name:")); |
1148 | - table.attach_defaults (name_label, 1, 2, 0, 1); |
1149 | + name_label.xalign = 1.0f; |
1150 | + table.attach_defaults (name_label, 1, 2, 1, 2); |
1151 | this._name = new Entry (); |
1152 | name_label.set_mnemonic_widget (this._name); |
1153 | if (this._entry.key_exists ("Name")) |
1154 | @@ -155,11 +186,12 @@ |
1155 | this._name.set_text (this._entry.name); |
1156 | } |
1157 | this._name.changed.connect (this.on_name_changed); |
1158 | - table.attach_defaults (this._name, 2, 3, 0, 1); |
1159 | + table.attach_expand (this._name, 2, 3, 1, 2); |
1160 | |
1161 | // Description |
1162 | desc_label = new Label.with_mnemonic (_ ("_Description:")); |
1163 | - table.attach_defaults (desc_label, 1, 2, 1, 2); |
1164 | + desc_label.xalign = 1.0f; |
1165 | + table.attach_defaults (desc_label, 1, 2, 2, 3); |
1166 | this._desc = new Entry (); |
1167 | desc_label.set_mnemonic_widget (this._desc); |
1168 | if (this._entry.key_exists ("Comment")) |
1169 | @@ -167,31 +199,36 @@ |
1170 | this._desc.set_text (this._entry.get_string ("Comment")); |
1171 | } |
1172 | this._desc.changed.connect (this.on_desc_changed); |
1173 | - table.attach_defaults (this._desc, 2, 3, 1, 2); |
1174 | + table.attach_expand (this._desc, 2, 3, 2, 3); |
1175 | |
1176 | // Exec |
1177 | exec_label = new Label.with_mnemonic (_ ("_Command:")); |
1178 | - table.attach_defaults (exec_label, 1, 2, 2, 3); |
1179 | + _command_label = exec_label; |
1180 | + exec_label.xalign = 1.0f; |
1181 | + table.attach_defaults (exec_label, 1, 2, 3, 4); |
1182 | exec_hbox = new HBox (false, 5); |
1183 | this._exec = new Entry (); |
1184 | exec_label.set_mnemonic_widget (this._exec); |
1185 | - if (this._entry.key_exists ("Exec")) |
1186 | + |
1187 | + string key_name = is_application ? "Exec" : "URL"; |
1188 | + if (this._entry.key_exists (key_name)) |
1189 | { |
1190 | - this._exec.set_text (this._entry.get_string ("Exec")); |
1191 | + this._exec.set_text (this._entry.get_string (key_name)); |
1192 | } |
1193 | + |
1194 | this._exec.changed.connect (this.on_exec_changed); |
1195 | - exec_hbox.add (this._exec); |
1196 | + exec_hbox.pack_start (this._exec, true); |
1197 | exec_button = new Button.with_mnemonic (_ ("_Browse...")); |
1198 | exec_image = new Image.from_stock (STOCK_OPEN, IconSize.BUTTON); |
1199 | exec_button.set_image (exec_image); |
1200 | exec_button.clicked.connect (this.on_exec_browse); |
1201 | - exec_hbox.add (exec_button); |
1202 | - table.attach_defaults (exec_hbox, 2, 3, 2, 3); |
1203 | + exec_hbox.pack_start (exec_button, false); |
1204 | + table.attach_expand (exec_hbox, 2, 3, 3, 4); |
1205 | |
1206 | // Advanced options |
1207 | // TODO look into ResizeMode so that the window shrinks when the expander |
1208 | // is un-expanded. |
1209 | - advanced = new Expander.with_mnemonic (_ ("_Advanced")); |
1210 | + this._advanced = new Expander.with_mnemonic (_ ("_Advanced")); |
1211 | advanced_vbox = new VBox (false, 5); |
1212 | this._terminal = new CheckButton.with_mnemonic (_ ("Run in _terminal")); |
1213 | if (this._entry.key_exists ("Terminal")) |
1214 | @@ -207,8 +244,20 @@ |
1215 | } |
1216 | this._startup_notification.toggled.connect (this.on_startup_notification_toggled); |
1217 | advanced_vbox.add (this._startup_notification); |
1218 | - advanced.add (advanced_vbox); |
1219 | - table.attach_fill (advanced, 0, 3, 3, 4); |
1220 | + this._advanced.add (advanced_vbox); |
1221 | + table.attach_expand (this._advanced, 0, 3, 4, 5); |
1222 | + |
1223 | + // make sure widgets are properly set up |
1224 | + on_type_changed (this._type_combo); |
1225 | + |
1226 | + List<unowned Widget> focus_chain_list = new List<unowned Widget> (); |
1227 | + focus_chain_list.append (this._type_combo); |
1228 | + focus_chain_list.append (this._name); |
1229 | + focus_chain_list.append (this._desc); |
1230 | + focus_chain_list.append (exec_hbox); |
1231 | + focus_chain_list.append (this._icon); |
1232 | + focus_chain_list.append (this._advanced); |
1233 | + table.set_focus_chain (focus_chain_list); |
1234 | |
1235 | this.vbox.add (table); |
1236 | } |
1237 | @@ -220,6 +269,29 @@ |
1238 | } |
1239 | |
1240 | private void |
1241 | + on_type_changed (ComboBox combo) |
1242 | + { |
1243 | + switch (combo.get_active ()) |
1244 | + { |
1245 | + case 0: this._entry.entry_type = DesktopEntryType.APPLICATION; break; |
1246 | + case 1: this._entry.entry_type = DesktopEntryType.LINK; break; |
1247 | + } |
1248 | + |
1249 | + if (this._entry.entry_type == DesktopEntryType.LINK) |
1250 | + { |
1251 | + this._command_label.set_markup_with_mnemonic (_ ("_Location:")); |
1252 | + this._advanced.hide (); |
1253 | + this._advanced.set_no_show_all (true); |
1254 | + } |
1255 | + else |
1256 | + { |
1257 | + this._command_label.set_markup_with_mnemonic (_ ("_Command:")); |
1258 | + this._advanced.set_no_show_all (false); |
1259 | + this._advanced.show (); |
1260 | + } |
1261 | + } |
1262 | + |
1263 | + private void |
1264 | on_name_changed (Editable editable) |
1265 | { |
1266 | Entry entry = editable as Entry; |
1267 | @@ -237,7 +309,9 @@ |
1268 | on_exec_changed (Editable editable) |
1269 | { |
1270 | Entry entry = editable as Entry; |
1271 | - this._entry.set_string ("Exec", entry.text); |
1272 | + string key_name = |
1273 | + this._entry.entry_type == DesktopEntryType.LINK ? "URL" : "Exec"; |
1274 | + this._entry.set_string (key_name, entry.text); |
1275 | } |
1276 | |
1277 | private void |
1278 | @@ -246,14 +320,17 @@ |
1279 | FileChooserDialog dialog; |
1280 | int response; |
1281 | |
1282 | - dialog = new FileChooserDialog (_ ("Locate Command"), this, |
1283 | + bool is_link = this._entry.entry_type == DesktopEntryType.LINK; |
1284 | + string title = is_link ? _ ("Locate a file") : _ ("Locate Command"); |
1285 | + |
1286 | + dialog = new FileChooserDialog (title, this, |
1287 | FileChooserAction.OPEN, |
1288 | STOCK_CANCEL, ResponseType.CANCEL, |
1289 | STOCK_OK, ResponseType.OK); |
1290 | response = dialog.run (); |
1291 | if (response == ResponseType.OK) |
1292 | { |
1293 | - this._exec.text = dialog.get_filename (); |
1294 | + this._exec.text = is_link ? dialog.get_uri () : dialog.get_filename (); |
1295 | } |
1296 | dialog.destroy (); |
1297 | } |
1298 | @@ -345,14 +422,7 @@ |
1299 | } |
1300 | } |
1301 | } |
1302 | - if (this._standalone) |
1303 | - { |
1304 | - main_quit (); |
1305 | - } |
1306 | - else |
1307 | - { |
1308 | - this.hide (); |
1309 | - } |
1310 | + this.hide (); |
1311 | } |
1312 | } |
1313 | } |
1314 | |
1315 | === modified file 'libdesktop-agnostic/vfs-bookmarks-gtk.vala' |
1316 | --- libdesktop-agnostic/vfs-bookmarks-gtk.vala 2009-07-18 08:06:58 +0000 |
1317 | +++ libdesktop-agnostic/vfs-bookmarks-gtk.vala 2011-02-13 20:22:06 +0000 |
1318 | @@ -77,7 +77,7 @@ |
1319 | */ |
1320 | public GtkBookmarks (File? file = null, bool monitor = true) |
1321 | { |
1322 | - this.file = file; |
1323 | + GLib.Object (file: file); |
1324 | if (this._file.exists ()) |
1325 | { |
1326 | this.parse (); |
1327 | |
1328 | === modified file 'libdesktop-agnostic/vfs-file-impl-gio.vala' |
1329 | --- libdesktop-agnostic/vfs-file-impl-gio.vala 2010-03-26 22:45:36 +0000 |
1330 | +++ libdesktop-agnostic/vfs-file-impl-gio.vala 2011-02-13 20:22:06 +0000 |
1331 | @@ -239,6 +239,71 @@ |
1332 | } |
1333 | return this._file.delete (null); |
1334 | } |
1335 | + |
1336 | + public override bool is_native () |
1337 | + { |
1338 | + return this._file.is_native (); |
1339 | + } |
1340 | + |
1341 | + public override string get_mime_type () throws Error |
1342 | + { |
1343 | + var fi = this._file.query_info (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, |
1344 | + 0, null); |
1345 | + return fi.get_content_type (); |
1346 | + } |
1347 | + |
1348 | + public override string[] get_icon_names () throws Error |
1349 | + { |
1350 | + var fi = this._file.query_info (FILE_ATTRIBUTE_STANDARD_ICON, |
1351 | + 0, null); |
1352 | + GLib.Icon icon = fi.get_icon (); |
1353 | + if (icon != null) |
1354 | + { |
1355 | + if (icon is ThemedIcon) |
1356 | + { |
1357 | + // wow! Vala sucks! |
1358 | + Value v = Value (typeof (string[])); |
1359 | + icon.get_property ("names", ref v); |
1360 | + string[] names = (string[]) v; |
1361 | + |
1362 | + // this should be fixed in vala 0.12 |
1363 | + //names = (icon as ThemedIcon).get_names (); |
1364 | + |
1365 | + return names; |
1366 | + } |
1367 | + |
1368 | + if (icon is FileIcon) |
1369 | + { |
1370 | + string path = (icon as FileIcon).get_file ().get_path (); |
1371 | + string[] result = { path }; |
1372 | + |
1373 | + return result; |
1374 | + } |
1375 | + } |
1376 | + |
1377 | + // hmm... what now? |
1378 | + string[] unknown = {}; |
1379 | + return unknown; |
1380 | + } |
1381 | + |
1382 | + public override string? |
1383 | + get_thumbnail_path () |
1384 | + { |
1385 | + try |
1386 | + { |
1387 | + var fi = this._file.query_info (FILE_ATTRIBUTE_THUMBNAIL_PATH, |
1388 | + 0, null); |
1389 | + if (fi.has_attribute (FILE_ATTRIBUTE_THUMBNAIL_PATH)) |
1390 | + { |
1391 | + return fi.get_attribute_byte_string (FILE_ATTRIBUTE_THUMBNAIL_PATH); |
1392 | + } |
1393 | + } |
1394 | + catch (GLib.Error err) |
1395 | + { |
1396 | + warning ("%s", err.message); |
1397 | + } |
1398 | + return null; |
1399 | + } |
1400 | } |
1401 | } |
1402 | |
1403 | |
1404 | === modified file 'libdesktop-agnostic/vfs-file-impl-gnome-vfs.vala' |
1405 | --- libdesktop-agnostic/vfs-file-impl-gnome-vfs.vala 2010-03-26 22:45:36 +0000 |
1406 | +++ libdesktop-agnostic/vfs-file-impl-gnome-vfs.vala 2011-02-13 20:22:06 +0000 |
1407 | @@ -322,6 +322,24 @@ |
1408 | } |
1409 | return (GnomeVFS.unlink_from_uri (this._uri) == GnomeVFS.Result.OK); |
1410 | } |
1411 | + |
1412 | + public override bool |
1413 | + is_native () |
1414 | + { |
1415 | + return this._uri_str.has_prefix ("file:"); |
1416 | + } |
1417 | + |
1418 | + public override string |
1419 | + get_mime_type () throws Error |
1420 | + { |
1421 | + return GnomeVFS.get_mime_type_from_uri (this._uri); |
1422 | + } |
1423 | + |
1424 | + public override string[] |
1425 | + get_icon_names () throws Error |
1426 | + { |
1427 | + return get_icon_names_for_mime_type (this.get_mime_type ()); |
1428 | + } |
1429 | } |
1430 | } |
1431 | |
1432 | |
1433 | === modified file 'libdesktop-agnostic/vfs-file-impl-thunar-vfs.vala' |
1434 | --- libdesktop-agnostic/vfs-file-impl-thunar-vfs.vala 2009-10-27 07:29:55 +0000 |
1435 | +++ libdesktop-agnostic/vfs-file-impl-thunar-vfs.vala 2011-02-13 20:22:06 +0000 |
1436 | @@ -247,6 +247,24 @@ |
1437 | } |
1438 | return (FileUtils.unlink (this.impl_path) == 0); |
1439 | } |
1440 | + |
1441 | + public override bool |
1442 | + is_native () |
1443 | + { |
1444 | + return this._uri.has_prefix ("file:"); |
1445 | + } |
1446 | + |
1447 | + public override string |
1448 | + get_mime_type () throws Error |
1449 | + { |
1450 | + return this._info.mime_info.get_name (); |
1451 | + } |
1452 | + |
1453 | + public override string[] |
1454 | + get_icon_names () throws Error |
1455 | + { |
1456 | + return get_icon_names_for_mime_type (this.get_mime_type ()); |
1457 | + } |
1458 | } |
1459 | } |
1460 | |
1461 | |
1462 | === modified file 'libdesktop-agnostic/vfs-file.vala' |
1463 | --- libdesktop-agnostic/vfs-file.vala 2009-10-27 07:29:55 +0000 |
1464 | +++ libdesktop-agnostic/vfs-file.vala 2011-02-13 20:22:06 +0000 |
1465 | @@ -190,6 +190,34 @@ |
1466 | * @return %TRUE on success, %FALSE on failure. |
1467 | */ |
1468 | public abstract bool remove () throws Error; |
1469 | + |
1470 | + /** |
1471 | + * Checks to see if a file is native to the platform. |
1472 | + * @return %TRUE if file is native, %FALSE otherwise. |
1473 | + */ |
1474 | + public abstract bool is_native (); |
1475 | + |
1476 | + /** |
1477 | + * Gets the file's mime type. (might block) |
1478 | + * @return String containing file's mime type. |
1479 | + */ |
1480 | + public abstract string get_mime_type () throws Error; |
1481 | + |
1482 | + /** |
1483 | + * Gets list of possible icon names representing this file. (might block) |
1484 | + * @return List of possible icon names. |
1485 | + */ |
1486 | + public abstract string[] get_icon_names () throws Error; |
1487 | + |
1488 | + /** |
1489 | + * Get path to thumbnail representing this file. (might block) |
1490 | + * @return Path to file with thumbnail or %null if thumbnail cannot be |
1491 | + * found or backend doesn't support it. |
1492 | + */ |
1493 | + public virtual string? get_thumbnail_path () |
1494 | + { |
1495 | + return null; |
1496 | + } |
1497 | } |
1498 | |
1499 | public File? |
1500 | @@ -219,6 +247,20 @@ |
1501 | return (File)Object.new (vfs.file_type, "uri", uri); |
1502 | } |
1503 | } |
1504 | + |
1505 | + public static string[] |
1506 | + get_icon_names_for_mime_type (string mime_type) |
1507 | + { |
1508 | + string[] names = null; |
1509 | + |
1510 | + return_val_if_fail (mime_type != "", null); |
1511 | + |
1512 | + names += mime_type.replace ("/", "-"); |
1513 | + names += "gnome-mime-%s".printf (names[0]); |
1514 | + names += "%s-x-generic".printf (Regex.split_simple ("/.*", mime_type)[0]); |
1515 | + |
1516 | + return names; |
1517 | + } |
1518 | } |
1519 | |
1520 | // vim: set et ts=2 sts=2 sw=2 ai : |
1521 | |
1522 | === modified file 'libdesktop-agnostic/vfs-impl-gio.vala' |
1523 | --- libdesktop-agnostic/vfs-impl-gio.vala 2009-07-18 02:12:37 +0000 |
1524 | +++ libdesktop-agnostic/vfs-impl-gio.vala 2011-02-13 20:22:06 +0000 |
1525 | @@ -89,7 +89,6 @@ |
1526 | } |
1527 | } |
1528 | } |
1529 | -[ModuleInit] |
1530 | public Type |
1531 | register_plugin () |
1532 | { |
1533 | |
1534 | === modified file 'libdesktop-agnostic/vfs-impl-gnome-vfs.vala' |
1535 | --- libdesktop-agnostic/vfs-impl-gnome-vfs.vala 2009-07-18 02:12:37 +0000 |
1536 | +++ libdesktop-agnostic/vfs-impl-gnome-vfs.vala 2011-02-13 20:22:06 +0000 |
1537 | @@ -92,7 +92,6 @@ |
1538 | } |
1539 | } |
1540 | } |
1541 | -[ModuleInit] |
1542 | public Type |
1543 | register_plugin () |
1544 | { |
1545 | |
1546 | === modified file 'libdesktop-agnostic/vfs-impl-thunar-vfs.vala' |
1547 | --- libdesktop-agnostic/vfs-impl-thunar-vfs.vala 2009-07-18 02:12:37 +0000 |
1548 | +++ libdesktop-agnostic/vfs-impl-thunar-vfs.vala 2011-02-13 20:22:06 +0000 |
1549 | @@ -92,7 +92,6 @@ |
1550 | } |
1551 | } |
1552 | } |
1553 | -[ModuleInit] |
1554 | public Type |
1555 | register_plugin () |
1556 | { |
1557 | |
1558 | === modified file 'libdesktop-agnostic/vfs-trash-impl-gio.vala' |
1559 | --- libdesktop-agnostic/vfs-trash-impl-gio.vala 2009-11-02 06:42:05 +0000 |
1560 | +++ libdesktop-agnostic/vfs-trash-impl-gio.vala 2011-02-13 20:22:06 +0000 |
1561 | @@ -77,7 +77,7 @@ |
1562 | |
1563 | try |
1564 | { |
1565 | - file_info = dir.query_info_finish (res); |
1566 | + file_info = dir.query_info_async.end (res); |
1567 | this._file_count = file_info.get_attribute_uint32 (FILE_ATTRIBUTE_TRASH_ITEM_COUNT); |
1568 | this.file_count_changed (); |
1569 | } |
1570 | |
1571 | === modified file 'libdesktop-agnostic/vfs-trash-impl-thunar-vfs.vala' |
1572 | --- libdesktop-agnostic/vfs-trash-impl-thunar-vfs.vala 2009-09-21 17:53:13 +0000 |
1573 | +++ libdesktop-agnostic/vfs-trash-impl-thunar-vfs.vala 2011-02-13 20:22:06 +0000 |
1574 | @@ -53,7 +53,7 @@ |
1575 | { |
1576 | Monitor monitor; |
1577 | this.trash = ThunarVfs.Path.get_for_trash (); |
1578 | - this.dbus = Bus.get (BusType.SESSION); |
1579 | + this.dbus = DBus.Bus.get (DBus.BusType.SESSION); |
1580 | this.xfce_trash = |
1581 | (Xfce.Trash)this.dbus.get_object ("org.xfce.Thunar", |
1582 | "/org/xfce/FileManager"); |
1583 | |
1584 | === modified file 'libdesktop-agnostic/vfs-volume-impl-gio.vala' |
1585 | --- libdesktop-agnostic/vfs-volume-impl-gio.vala 2009-09-24 16:36:40 +0000 |
1586 | +++ libdesktop-agnostic/vfs-volume-impl-gio.vala 2011-02-13 20:22:06 +0000 |
1587 | @@ -121,7 +121,7 @@ |
1588 | bool result = false; |
1589 | try |
1590 | { |
1591 | - result = this.vol.mount_finish (this.async_result); |
1592 | + result = this.vol.mount.end (this.async_result); |
1593 | } |
1594 | catch (GLib.Error err) |
1595 | { |
1596 | @@ -156,7 +156,7 @@ |
1597 | bool result = false; |
1598 | try |
1599 | { |
1600 | - result = this.vol.get_mount ().unmount_finish (this.async_result); |
1601 | + result = this.vol.get_mount ().unmount.end (this.async_result); |
1602 | } |
1603 | catch (GLib.Error err) |
1604 | { |
1605 | @@ -192,7 +192,7 @@ |
1606 | bool result = false; |
1607 | try |
1608 | { |
1609 | - result = this.vol.eject_finish (this.async_result); |
1610 | + result = this.vol.eject.end (this.async_result); |
1611 | } |
1612 | catch (GLib.Error err) |
1613 | { |
1614 | @@ -211,7 +211,7 @@ |
1615 | this.monitor = GLib.VolumeMonitor.get (); |
1616 | this._volumes = new HashTable<GLib.Volume,VFS.Volume> (direct_hash, |
1617 | direct_equal); |
1618 | - unowned List<GLib.Volume> vols = this.monitor.get_volumes (); |
1619 | + List<GLib.Volume> vols = this.monitor.get_volumes (); |
1620 | foreach (unowned GLib.Volume gvol in vols) |
1621 | { |
1622 | VFS.Volume vol = this.create_volume (gvol); |
1623 | |
1624 | === modified file 'libdesktop-agnostic/vfs-volume-impl-gnome-vfs.vala' |
1625 | --- libdesktop-agnostic/vfs-volume-impl-gnome-vfs.vala 2009-09-24 16:36:40 +0000 |
1626 | +++ libdesktop-agnostic/vfs-volume-impl-gnome-vfs.vala 2011-02-13 20:22:06 +0000 |
1627 | @@ -190,8 +190,7 @@ |
1628 | this.monitor = GnomeVFS.get_volume_monitor (); |
1629 | this._volumes = new HashTable<GnomeVFS.Drive,VFS.Volume> (direct_hash, |
1630 | direct_equal); |
1631 | - unowned List<GnomeVFS.Drive> drives = |
1632 | - this.monitor.get_connected_drives (); |
1633 | + List<GnomeVFS.Drive> drives = this.monitor.get_connected_drives (); |
1634 | foreach (unowned GnomeVFS.Drive drive in drives) |
1635 | { |
1636 | VFS.Volume vol = this.create_volume (drive); |
1637 | |
1638 | === modified file 'libdesktop-agnostic/vfs-volume-impl-thunar-vfs.vala' |
1639 | --- libdesktop-agnostic/vfs-volume-impl-thunar-vfs.vala 2009-09-24 16:36:40 +0000 |
1640 | +++ libdesktop-agnostic/vfs-volume-impl-thunar-vfs.vala 2011-02-13 20:22:06 +0000 |
1641 | @@ -63,7 +63,7 @@ |
1642 | } |
1643 | public VolumeThunarVFS.for_implementation (ThunarVfs.Volume impl) |
1644 | { |
1645 | - this.implementation = impl; |
1646 | + GLib.Object (implementation: impl); |
1647 | } |
1648 | public bool |
1649 | is_mounted () |
1650 | |
1651 | === modified file 'libdesktop-agnostic/wscript' |
1652 | --- libdesktop-agnostic/wscript 2010-04-10 23:17:55 +0000 |
1653 | +++ libdesktop-agnostic/wscript 2011-02-13 20:22:06 +0000 |
1654 | @@ -34,6 +34,10 @@ |
1655 | } |
1656 | }, |
1657 | 'fdo': { |
1658 | + 'gio': { |
1659 | + 'uselib': 'GIO_UNIX', |
1660 | + 'packages': 'gio-unix-2.0', |
1661 | + }, |
1662 | 'gnome': { |
1663 | 'uselib': 'GNOME_DESKTOP', |
1664 | 'packages': 'gnome-desktop-2.0', |
1665 | @@ -113,7 +117,8 @@ |
1666 | ]) |
1667 | lib.packages = 'gdk-2.0 gmodule-2.0' |
1668 | lib.target = 'desktop-agnostic' |
1669 | - lib.gir = 'DesktopAgnostic-1.0' |
1670 | + if bld.env['INTROSPECTION']: |
1671 | + lib.gir = 'DesktopAgnostic-1.0' |
1672 | lib.uselib = 'M GDK GMODULE' |
1673 | lib.packages_private = 'build' |
1674 | lib.includes = '..' |
1675 | @@ -133,7 +138,8 @@ |
1676 | vfs.packages = 'desktop-agnostic posix' |
1677 | vfs.target = 'desktop-agnostic-vfs' |
1678 | vfs.header = 'vfs' |
1679 | - vfs.gir = 'DesktopAgnosticVFS-1.0' |
1680 | + if bld.env['INTROSPECTION']: |
1681 | + vfs.gir = 'DesktopAgnosticVFS-1.0' |
1682 | vfs.uselib_local = 'desktop-agnostic' |
1683 | vfs.packages_private = 'posix-glob' |
1684 | vfs.includes = '..' |
1685 | @@ -152,7 +158,8 @@ |
1686 | cfg.packages = 'desktop-agnostic-vfs' |
1687 | cfg.target = 'desktop-agnostic-cfg' |
1688 | cfg.header = 'config' |
1689 | - cfg.gir = 'DesktopAgnosticConfig-1.0' |
1690 | + if bld.env['INTROSPECTION']: |
1691 | + cfg.gir = 'DesktopAgnosticConfig-1.0' |
1692 | cfg.uselib_local = 'desktop-agnostic-vfs' |
1693 | cfg.packages_private = 'hashtable-gtype-key' |
1694 | cfg.includes = '..' |
1695 | @@ -166,7 +173,8 @@ |
1696 | fdo.packages = 'desktop-agnostic-vfs' |
1697 | fdo.target = 'desktop-agnostic-fdo' |
1698 | fdo.header = 'fdo' |
1699 | - fdo.gir = 'DesktopAgnosticFDO-1.0' |
1700 | + if bld.env['INTROSPECTION']: |
1701 | + fdo.gir = 'DesktopAgnosticFDO-1.0' |
1702 | fdo.uselib_local = 'desktop-agnostic-vfs' |
1703 | fdo.vapi_dirs = '.' |
1704 | fdo.includes = '..' |
1705 | @@ -183,7 +191,8 @@ |
1706 | ui.packages_private = 'build' |
1707 | ui.target = 'desktop-agnostic-ui' |
1708 | ui.header = 'ui' |
1709 | - ui.gir = 'DesktopAgnosticUI-1.0' |
1710 | + if bld.env['INTROSPECTION']: |
1711 | + ui.gir = 'DesktopAgnosticUI-1.0' |
1712 | ui.uselib = 'GTK' |
1713 | ui.uselib_local = 'desktop-agnostic-fdo' |
1714 | ui.vapi_dirs = '. ../vapi' |
1715 | |
1716 | === modified file 'python/desktopagnostic.override' |
1717 | --- python/desktopagnostic.override 2009-08-25 22:11:31 +0000 |
1718 | +++ python/desktopagnostic.override 2011-02-13 20:22:06 +0000 |
1719 | @@ -98,19 +98,23 @@ |
1720 | _wrap_desktop_agnostic_color_from_values (PyObject *self, PyObject *args, |
1721 | PyObject *kwargs) |
1722 | { |
1723 | - static char *kwlist[] = { "red", "green", "blue", "alpha", NULL }; |
1724 | - int red, green, blue, alpha; |
1725 | - DesktopAgnosticColor *ret; |
1726 | - |
1727 | - if (!PyArg_ParseTupleAndKeywords (args, kwargs, |
1728 | - "iiii:color_new_from_values", kwlist, |
1729 | - &red, &green, &blue, &alpha)) |
1730 | - return NULL; |
1731 | - |
1732 | - ret = desktop_agnostic_color_new_from_values (red, green, blue, alpha); |
1733 | - |
1734 | - /* pygobject_new handles NULL checking */ |
1735 | - return pygobject_new ((GObject *)ret); |
1736 | + static char *kwlist[] = { "red", "green", "blue", "alpha", NULL }; |
1737 | + int red, green, blue, alpha; |
1738 | + DesktopAgnosticColor *ret; |
1739 | + PyObject *py_ret; |
1740 | + |
1741 | + if (!PyArg_ParseTupleAndKeywords (args, kwargs, |
1742 | + "iiii:color_new_from_values", kwlist, |
1743 | + &red, &green, &blue, &alpha)) |
1744 | + return NULL; |
1745 | + |
1746 | + ret = desktop_agnostic_color_new_from_values (red, green, blue, alpha); |
1747 | + |
1748 | + /* pygobject_new handles NULL checking */ |
1749 | + py_ret = pygobject_new ((GObject *)ret); |
1750 | + if (ret != NULL) |
1751 | + g_object_unref (ret); |
1752 | + return py_ret; |
1753 | } |
1754 | %% |
1755 | define DesktopAgnosticColor.from_string kwargs staticmethod |
1756 | @@ -122,6 +126,7 @@ |
1757 | char *spec; |
1758 | GError *error = NULL; |
1759 | DesktopAgnosticColor *ret; |
1760 | + PyObject *py_ret; |
1761 | |
1762 | if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s:color_new_from_string", |
1763 | kwlist, &spec)) |
1764 | @@ -137,7 +142,10 @@ |
1765 | } |
1766 | |
1767 | /* pygobject_new handles NULL checking */ |
1768 | - return pygobject_new ((GObject *)ret); |
1769 | + py_ret = pygobject_new ((GObject *)ret); |
1770 | + if (ret != NULL) |
1771 | + g_object_unref (ret); |
1772 | + return py_ret; |
1773 | } |
1774 | %% |
1775 | override-slot DesktopAgnosticColor.tp_str |
1776 | |
1777 | === modified file 'python/fdo.override' |
1778 | --- python/fdo.override 2009-10-06 18:53:45 +0000 |
1779 | +++ python/fdo.override 2011-02-13 20:22:06 +0000 |
1780 | @@ -197,6 +197,7 @@ |
1781 | { |
1782 | DesktopAgnosticFDODesktopEntry *ret; |
1783 | GError *error = NULL; |
1784 | + PyObject *py_ret; |
1785 | |
1786 | ret = desktop_agnostic_fdo_desktop_entry_new (&error); |
1787 | |
1788 | @@ -206,7 +207,10 @@ |
1789 | } |
1790 | |
1791 | /* pygobject_new handles NULL checking */ |
1792 | - return pygobject_new ((GObject *)ret); |
1793 | + py_ret = pygobject_new ((GObject *)ret); |
1794 | + if (ret != NULL) |
1795 | + g_object_unref (ret); |
1796 | + return py_ret; |
1797 | } |
1798 | %% |
1799 | define DesktopAgnosticFDODesktopEntry.for_data kwargs staticmethod |
1800 | @@ -218,6 +222,7 @@ |
1801 | static char *kwlist[] = { "data", NULL }; |
1802 | char *data; |
1803 | DesktopAgnosticFDODesktopEntry *ret; |
1804 | + PyObject *py_ret; |
1805 | GError *error = NULL; |
1806 | |
1807 | if (!PyArg_ParseTupleAndKeywords (args, kwargs, |
1808 | @@ -235,7 +240,10 @@ |
1809 | } |
1810 | |
1811 | /* pygobject_new handles NULL checking */ |
1812 | - return pygobject_new ((GObject *)ret); |
1813 | + py_ret = pygobject_new ((GObject *)ret); |
1814 | + if (ret != NULL) |
1815 | + g_object_unref (ret); |
1816 | + return py_ret; |
1817 | } |
1818 | %% |
1819 | define DesktopAgnosticFDODesktopEntry.for_file onearg staticmethod |
1820 | @@ -244,6 +252,7 @@ |
1821 | PyGObject *file) |
1822 | { |
1823 | DesktopAgnosticFDODesktopEntry *ret; |
1824 | + PyObject *py_ret; |
1825 | GError *error = NULL; |
1826 | |
1827 | ret = desktop_agnostic_fdo_desktop_entry_new_for_file (DESKTOP_AGNOSTIC_VFS_FILE(file->obj), |
1828 | @@ -255,7 +264,10 @@ |
1829 | } |
1830 | |
1831 | /* pygobject_new handles NULL checking */ |
1832 | - return pygobject_new ((GObject *)ret); |
1833 | + py_ret = pygobject_new ((GObject *)ret); |
1834 | + if (ret != NULL) |
1835 | + g_object_unref (ret); |
1836 | + return py_ret; |
1837 | } |
1838 | %% |
1839 | define DesktopAgnosticFDODesktopEntry.type_to_string onearg staticmethod |
1840 | |
1841 | === modified file 'python/ui.override' |
1842 | --- python/ui.override 2009-10-21 22:09:04 +0000 |
1843 | +++ python/ui.override 2011-02-13 20:22:06 +0000 |
1844 | @@ -46,9 +46,13 @@ |
1845 | PyGObject *color) |
1846 | { |
1847 | DesktopAgnosticUIColorButton *ret; |
1848 | + PyObject *py_ret; |
1849 | |
1850 | ret = desktop_agnostic_ui_color_button_new_with_color (DESKTOP_AGNOSTIC_COLOR(color->obj)); |
1851 | |
1852 | /* pygobject_new handles NULL checking */ |
1853 | - return pygobject_new((GObject *)ret); |
1854 | + py_ret = pygobject_new ((GObject *)ret); |
1855 | + if (ret != NULL) |
1856 | + g_object_unref (ret); |
1857 | + return py_ret; |
1858 | } |
1859 | |
1860 | === modified file 'python/vfs.defs' |
1861 | --- python/vfs.defs 2009-09-08 03:28:50 +0000 |
1862 | +++ python/vfs.defs 2011-02-13 20:22:06 +0000 |
1863 | @@ -199,6 +199,36 @@ |
1864 | ) |
1865 | ) |
1866 | |
1867 | +(define-method is_native |
1868 | + (of-object "DesktopAgnosticVFSFile") |
1869 | + (c-name "desktop_agnostic_vfs_file_is_native") |
1870 | + (return-type "gboolean") |
1871 | +) |
1872 | + |
1873 | +(define-method get_mime_type |
1874 | + (of-object "DesktopAgnosticVFSFile") |
1875 | + (c-name "desktop_agnostic_vfs_file_get_mime_type") |
1876 | + (return-type "char*") |
1877 | + (parameters |
1878 | + '("GError**" "error") |
1879 | + ) |
1880 | +) |
1881 | + |
1882 | +(define-method get_icon_names |
1883 | + (of-object "DesktopAgnosticVFSFile") |
1884 | + (c-name "desktop_agnostic_vfs_file_get_icon_names") |
1885 | + (return-type "GStrv") |
1886 | + (parameters |
1887 | + '("GError**" "error") |
1888 | + ) |
1889 | +) |
1890 | + |
1891 | +(define-method get_thumbnail_path |
1892 | + (of-object "DesktopAgnosticVFSFile") |
1893 | + (c-name "desktop_agnostic_vfs_file_get_thumbnail_path") |
1894 | + (return-type "char*") |
1895 | +) |
1896 | + |
1897 | (define-function file_new_for_path |
1898 | (c-name "desktop_agnostic_vfs_file_new_for_path") |
1899 | (return-type "DesktopAgnosticVFSFile*") |
1900 | @@ -217,6 +247,14 @@ |
1901 | ) |
1902 | ) |
1903 | |
1904 | +(define-function get_icon_names_for_mime_type |
1905 | + (c-name "desktop_agnostic_vfs_get_icon_names_for_mime_type") |
1906 | + (return-type "char*") |
1907 | + (parameters |
1908 | + '("const-char*" "mime_type") |
1909 | + ) |
1910 | +) |
1911 | + |
1912 | (define-method changed |
1913 | (of-object "DesktopAgnosticVFSFileMonitor") |
1914 | (c-name "desktop_agnostic_vfs_file_monitor_emit") |
1915 | |
1916 | === modified file 'python/vfs.override' |
1917 | --- python/vfs.override 2009-09-08 03:28:50 +0000 |
1918 | +++ python/vfs.override 2011-02-13 20:22:06 +0000 |
1919 | @@ -117,6 +117,7 @@ |
1920 | { |
1921 | char *path; |
1922 | DesktopAgnosticVFSFile *ret; |
1923 | + PyObject *py_ret; |
1924 | GError *error = NULL; |
1925 | |
1926 | if (!PyString_Check (arg)) |
1927 | @@ -136,16 +137,20 @@ |
1928 | } |
1929 | |
1930 | /* pygobject_new handles NULL checking */ |
1931 | - return pygobject_new ((GObject *)ret); |
1932 | + py_ret = pygobject_new ((GObject *)ret); |
1933 | + if (ret != NULL) |
1934 | + g_object_unref (ret); |
1935 | + return py_ret; |
1936 | } |
1937 | %% |
1938 | define DesktopAgnosticVFSFile.for_uri onearg staticmethod |
1939 | static PyObject * |
1940 | _wrap_desktop_agnostic_v_f_s_file_for_uri (PyObject *self, PyObject *arg) |
1941 | { |
1942 | - char *uri; |
1943 | - DesktopAgnosticVFSFile *ret; |
1944 | - GError *error = NULL; |
1945 | + char *uri; |
1946 | + DesktopAgnosticVFSFile *ret; |
1947 | + PyObject *py_ret; |
1948 | + GError *error = NULL; |
1949 | |
1950 | if (!PyString_Check (arg)) |
1951 | { |
1952 | @@ -164,8 +169,39 @@ |
1953 | } |
1954 | |
1955 | /* pygobject_new handles NULL checking */ |
1956 | - return pygobject_new ((GObject *)ret); |
1957 | -} |
1958 | + py_ret = pygobject_new ((GObject *)ret); |
1959 | + if (ret != NULL) |
1960 | + g_object_unref (ret); |
1961 | + return py_ret; |
1962 | +} |
1963 | +%% |
1964 | +override desktop_agnostic_vfs_get_icon_names_for_mime_type kwargs |
1965 | +static PyObject * |
1966 | +_wrap_desktop_agnostic_vfs_get_icon_names_for_mime_type(PyObject *self, PyObject *args, PyObject *kwargs) |
1967 | +{ |
1968 | + static char *kwlist[] = { "mime_type", NULL }; |
1969 | + char *mime_type; |
1970 | + gchar **ret; |
1971 | + int ret_length = 0; |
1972 | + int i; |
1973 | + PyObject *py_ret; |
1974 | + |
1975 | + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:get_icon_names_for_mime_type", kwlist, &mime_type)) |
1976 | + return NULL; |
1977 | + |
1978 | + ret = desktop_agnostic_vfs_get_icon_names_for_mime_type(mime_type, &ret_length); |
1979 | + |
1980 | + py_ret = PyList_New (ret_length); |
1981 | + if (ret) { |
1982 | + for (i=0; i<ret_length; i++) { |
1983 | + PyList_SetItem (py_ret, i, PyString_FromString (ret[i])); |
1984 | + g_free (ret[i]); |
1985 | + } |
1986 | + g_free(ret); |
1987 | + } |
1988 | + return py_ret; |
1989 | +} |
1990 | + |
1991 | %% |
1992 | override desktop_agnostic_vfs_file_enumerate_children noargs |
1993 | static PyObject * |
1994 | @@ -209,6 +245,34 @@ |
1995 | return PyString_FromStringAndSize (data, length); |
1996 | } |
1997 | %% |
1998 | +override desktop_agnostic_vfs_file_get_icon_names noargs |
1999 | +static PyObject * |
2000 | +_wrap_desktop_agnostic_vfs_file_get_icon_names (PyGObject *self) |
2001 | +{ |
2002 | + int i, res_length; |
2003 | + char **result; |
2004 | + PyObject *py_result; |
2005 | + GError *error = NULL; |
2006 | + |
2007 | + result = desktop_agnostic_vfs_file_get_icon_names (DESKTOP_AGNOSTIC_VFS_FILE (self->obj), |
2008 | + &res_length, &error); |
2009 | + |
2010 | + if (pyg_error_check (&error)) |
2011 | + { |
2012 | + return NULL; |
2013 | + } |
2014 | + |
2015 | + py_result = PyList_New (res_length); |
2016 | + for (i=0; i<res_length; i++) |
2017 | + { |
2018 | + PyList_SetItem (py_result, i, PyString_FromString (result[i])); |
2019 | + g_free (result[i]); |
2020 | + } |
2021 | + if (result != NULL) g_free (result); |
2022 | + |
2023 | + return py_result; |
2024 | +} |
2025 | +%% |
2026 | define DesktopAgnosticVFSTrash.get_default noargs staticmethod |
2027 | static PyObject * |
2028 | _wrap_desktop_agnostic_v_f_s_trash_get_default (PyObject *self) |
2029 | |
2030 | === modified file 'tools/lda-desktop-entry-editor.vala' |
2031 | --- tools/lda-desktop-entry-editor.vala 2009-10-21 22:09:04 +0000 |
2032 | +++ tools/lda-desktop-entry-editor.vala 2011-02-13 20:22:06 +0000 |
2033 | @@ -51,9 +51,9 @@ |
2034 | { |
2035 | output = VFS.file_new_for_path (args[2]); |
2036 | } |
2037 | - editor = new LauncherEditorDialog (file, output, true); |
2038 | + editor = new LauncherEditorDialog (file, output); |
2039 | editor.show_all (); |
2040 | - Gtk.main (); |
2041 | + editor.run (); |
2042 | |
2043 | VFS.shutdown (); |
2044 | } |
2045 | |
2046 | === modified file 'wscript' |
2047 | --- wscript 2010-04-18 20:00:06 +0000 |
2048 | +++ wscript 2011-02-13 20:22:06 +0000 |
2049 | @@ -15,7 +15,7 @@ |
2050 | API_VERSION = '1.0' |
2051 | |
2052 | # the following two variables are used by the target "waf dist" |
2053 | -VERSION = '0.3.90' |
2054 | +VERSION = '0.3.91' |
2055 | VNUM = '0.4.0' |
2056 | |
2057 | CFG_BACKENDS = ','.join(['gconf', 'keyfile']) |
2058 | @@ -70,6 +70,8 @@ |
2059 | dest='profiling', default=False, |
2060 | help='Enables the library to be built so that it is ' |
2061 | 'instrumented to measure performance.') |
2062 | + opt.add_option('--disable-gi', action='store_true', |
2063 | + dest='no_gi', default=False) |
2064 | |
2065 | |
2066 | def configure(conf): |
2067 | @@ -88,12 +90,13 @@ |
2068 | conf.env['DEBUG'] = Options.options.debug |
2069 | conf.env['EXTRA_WARNINGS'] = Options.options.extra_warnings |
2070 | conf.env['PROFILING'] = Options.options.profiling |
2071 | + conf.env['INTROSPECTION'] = not Options.options.no_gi |
2072 | conf.env['VNUM'] = str(VNUM) |
2073 | |
2074 | conf.check_tool('gnu_dirs') |
2075 | conf.check_tool('compiler_cc intltool misc python vala') |
2076 | |
2077 | - MIN_VALA_VERSION = (0, 7, 10) |
2078 | + MIN_VALA_VERSION = (0, 8, 1) |
2079 | |
2080 | conf.check_cfg(package='gmodule-2.0', uselib_store='GMODULE', |
2081 | atleast_version='2.6.0', mandatory=True, |
2082 | @@ -131,12 +134,16 @@ |
2083 | conf.check_cfg(package='gnome-vfs-2.0', uselib_store='GNOME_VFS', |
2084 | atleast_version='2.6.0', mandatory=True, |
2085 | args='--cflags --libs') |
2086 | + if 'gio' in conf.env['BACKENDS_DE']: |
2087 | + conf.check_cfg(package='gio-unix-2.0', uselib_store='GIO_UNIX', |
2088 | + atleast_version='2.18.0', mandatory=True, |
2089 | + args='--cflags --libs') |
2090 | if 'gnome' in conf.env['BACKENDS_DE']: |
2091 | conf.check_cfg(package='gnome-desktop-2.0', |
2092 | uselib_store='GNOME_DESKTOP', mandatory=True, |
2093 | args='--cflags --libs') |
2094 | # make sure we have the proper Vala version |
2095 | - if conf.env['VALAC_VERSION'] != MIN_VALA_VERSION and \ |
2096 | + if conf.env['VALAC_VERSION'] < MIN_VALA_VERSION and \ |
2097 | not os.path.isdir(os.path.join(conf.curdir, GEN_SRC_DIR)): |
2098 | conf.fatal('''\ |
2099 | Your Vala compiler version %s is too old. The project requires |
I'm using this branch in Ubuntu for quite some time, without any problems. I'm for it, but I can't review the code itself for the merge.