Merge lp:~marcus-lundgren/noise/compilation_warnings_and_clean_up into lp:~elementary-apps/noise/trunk
- compilation_warnings_and_clean_up
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | David Gomes |
Approved revision: | 1501 |
Merged at revision: | 1511 |
Proposed branch: | lp:~marcus-lundgren/noise/compilation_warnings_and_clean_up |
Merge into: | lp:~elementary-apps/noise/trunk |
Diff against target: |
941 lines (+419/-459) 4 files modified
core/GStreamer/Pipeline.vala (+69/-87) plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala (+5/-26) plugins/Devices/iPod/iPodLibrary.vala (+1/-2) src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala (+344/-344) |
To merge this branch: | bzr merge lp:~marcus-lundgren/noise/compilation_warnings_and_clean_up |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Gomes (community) | Approve | ||
Review via email: mp+176069@code.launchpad.net |
Commit message
Fixed some compilation warnings and removed some commented out code.
Description of the change
Fixed some compilation warnings and removed some commented out code.
- 1501. By Marcus Lundgren
-
Turn tabs to spaces and fix some legacy code style issues.
Marcus Lundgren (marcus-lundgren) wrote : | # |
The tabs have been turned into spaces (as this seems to be the standard in the files in src/.
I fixed the code style issues on the lines that I've actually touched, which excludes the lines that only had tabs turned into spaces. The code style issues on the other lines weren't fixed, as the intent of the branch was to only fix compilation warnings, and the issues should therefor be fixed in a separate branch.
David Gomes (davidgomes) wrote : | # |
Yeah that's exactly what you should do, don't do mixed-actions per commit.
David Gomes (davidgomes) wrote : | # |
I'm approving but I'll run a code style fix after this branch is merged and I need someone to confirm to me this builds on 12.04, since I'm on 13.04 and it doesn't build due to SQLHeavy errors.
Julián Unrrein (junrrein) wrote : | # |
I test-compiled this branch on elementary Luna, with no problems.
Here is the configuration and compilation logs -> http://
Preview Diff
1 | === modified file 'core/GStreamer/Pipeline.vala' |
2 | --- core/GStreamer/Pipeline.vala 2013-02-26 21:56:08 +0000 |
3 | +++ core/GStreamer/Pipeline.vala 2013-07-26 20:46:25 +0000 |
4 | @@ -29,91 +29,73 @@ |
5 | */ |
6 | |
7 | public class Noise.Pipeline : GLib.Object { |
8 | - public Gst.Pipeline pipe; |
9 | - public Equalizer eq; |
10 | - |
11 | - public dynamic Gst.Bus bus; |
12 | - //Pad teepad; |
13 | - public Gst.Pad pad; |
14 | - |
15 | - public dynamic Gst.Element audiosink; |
16 | - public dynamic Gst.Element audiosinkqueue; |
17 | - public dynamic Gst.Element eq_audioconvert; |
18 | - public dynamic Gst.Element eq_audioconvert2; |
19 | - |
20 | - public dynamic Gst.Element playbin; |
21 | - public dynamic Gst.Element audiotee; |
22 | - public dynamic Gst.Element audiobin; |
23 | - public dynamic Gst.Element preamp; |
24 | - //dynamic Gst.Element volume; |
25 | - //dynamic Gst.Element rgvolume; |
26 | - |
27 | - public Pipeline() { |
28 | - |
29 | - pipe = new Gst.Pipeline("pipeline"); |
30 | - playbin = Gst.ElementFactory.make("playbin2", "play"); |
31 | - |
32 | - audiosink = Gst.ElementFactory.make("autoaudiosink", "audio-sink"); |
33 | - //audiosink.set("profile", 1); // says we handle music and movies |
34 | - |
35 | - audiobin = new Gst.Bin("audiobin"); // this holds the real primary sink |
36 | - |
37 | - audiotee = Gst.ElementFactory.make("tee", null); |
38 | - audiosinkqueue = Gst.ElementFactory.make("queue", null); |
39 | - |
40 | - eq = new Equalizer(); |
41 | - if(eq.element != null) { |
42 | - eq_audioconvert = Gst.ElementFactory.make("audioconvert", null); |
43 | - eq_audioconvert2 = Gst.ElementFactory.make("audioconvert", null); |
44 | - preamp = Gst.ElementFactory.make("volume", "preamp"); |
45 | - |
46 | - ((Gst.Bin)audiobin).add_many(eq.element, eq_audioconvert, eq_audioconvert2, preamp); |
47 | - } |
48 | - |
49 | - ((Gst.Bin)audiobin).add_many(audiotee, audiosinkqueue, audiosink); |
50 | - |
51 | - audiobin.add_pad(new Gst.GhostPad("sink", audiotee.get_pad("sink"))); |
52 | - |
53 | - if (eq.element != null) |
54 | - audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
55 | - else |
56 | - audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink |
57 | - |
58 | - playbin.set("audio-sink", audiobin); |
59 | - bus = playbin.get_bus(); |
60 | - |
61 | - // Link the first tee pad to the primary audio sink queue |
62 | - Gst.Pad sinkpad = audiosinkqueue.get_pad("sink"); |
63 | - pad = audiotee.get_request_pad("src%d"); |
64 | - audiotee.set("alloc-pad", pad); |
65 | - pad.link(sinkpad); |
66 | - |
67 | - //bus.add_watch(busCallback); |
68 | - /*play.audio_tags_changed.connect(audioTagsChanged); |
69 | - play.text_tags_changed.connect(textTagsChanged);*/ |
70 | - } |
71 | - |
72 | -/* |
73 | - private void audioTagsChanged(Gst.Element sender, int stream_number) { |
74 | - |
75 | - } |
76 | - |
77 | - /*private void textTagsChanged(Gst.Element sender, int stream_number) { |
78 | - |
79 | - } |
80 | -*/ |
81 | - |
82 | - public void enableEqualizer() { |
83 | - if (eq.element != null) { |
84 | - audiosinkqueue.unlink_many(audiosink); // link the queue with the real audio sink |
85 | - audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
86 | - } |
87 | - } |
88 | - |
89 | - public void disableEqualizer() { |
90 | - if (eq.element != null) { |
91 | - audiosinkqueue.unlink_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
92 | - audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink |
93 | - } |
94 | - } |
95 | + public Gst.Pipeline pipe; |
96 | + public Equalizer eq; |
97 | + |
98 | + public dynamic Gst.Bus bus; |
99 | + public Gst.Pad pad; |
100 | + |
101 | + public dynamic Gst.Element audiosink; |
102 | + public dynamic Gst.Element audiosinkqueue; |
103 | + public dynamic Gst.Element eq_audioconvert; |
104 | + public dynamic Gst.Element eq_audioconvert2; |
105 | + |
106 | + public dynamic Gst.Element playbin; |
107 | + public dynamic Gst.Element audiotee; |
108 | + public dynamic Gst.Element audiobin; |
109 | + public dynamic Gst.Element preamp; |
110 | + |
111 | + public Pipeline() { |
112 | + |
113 | + pipe = new Gst.Pipeline("pipeline"); |
114 | + playbin = Gst.ElementFactory.make("playbin2", "play"); |
115 | + |
116 | + audiosink = Gst.ElementFactory.make("autoaudiosink", "audio-sink"); |
117 | + |
118 | + audiobin = new Gst.Bin("audiobin"); // this holds the real primary sink |
119 | + |
120 | + audiotee = Gst.ElementFactory.make("tee", null); |
121 | + audiosinkqueue = Gst.ElementFactory.make("queue", null); |
122 | + |
123 | + eq = new Equalizer(); |
124 | + if(eq.element != null) { |
125 | + eq_audioconvert = Gst.ElementFactory.make("audioconvert", null); |
126 | + eq_audioconvert2 = Gst.ElementFactory.make("audioconvert", null); |
127 | + preamp = Gst.ElementFactory.make("volume", "preamp"); |
128 | + |
129 | + ((Gst.Bin)audiobin).add_many(eq.element, eq_audioconvert, eq_audioconvert2, preamp); |
130 | + } |
131 | + |
132 | + ((Gst.Bin)audiobin).add_many(audiotee, audiosinkqueue, audiosink); |
133 | + |
134 | + audiobin.add_pad(new Gst.GhostPad("sink", audiotee.get_pad("sink"))); |
135 | + |
136 | + if (eq.element != null) |
137 | + audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
138 | + else |
139 | + audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink |
140 | + |
141 | + playbin.set("audio-sink", audiobin); |
142 | + bus = playbin.get_bus(); |
143 | + |
144 | + // Link the first tee pad to the primary audio sink queue |
145 | + Gst.Pad sinkpad = audiosinkqueue.get_pad("sink"); |
146 | + pad = audiotee.get_request_pad("src%d"); |
147 | + audiotee.set("alloc-pad", pad); |
148 | + pad.link(sinkpad); |
149 | + } |
150 | + |
151 | + public void enableEqualizer() { |
152 | + if (eq.element != null) { |
153 | + audiosinkqueue.unlink_many(audiosink); // link the queue with the real audio sink |
154 | + audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
155 | + } |
156 | + } |
157 | + |
158 | + public void disableEqualizer() { |
159 | + if (eq.element != null) { |
160 | + audiosinkqueue.unlink_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
161 | + audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink |
162 | + } |
163 | + } |
164 | } |
165 | |
166 | === modified file 'plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala' |
167 | --- plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala 2013-06-02 17:35:04 +0000 |
168 | +++ plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala 2013-07-26 20:46:25 +0000 |
169 | @@ -55,13 +55,13 @@ |
170 | |
171 | tagger = new GStreamerTagger(); |
172 | |
173 | - tagger.media_imported.connect(media_imported); |
174 | - tagger.import_error.connect(import_error); |
175 | - tagger.queue_finished.connect(queue_finished); |
176 | + tagger.media_imported.connect (media_imported_from_tagger); |
177 | + tagger.import_error.connect (import_error); |
178 | + tagger.queue_finished.connect (queue_finished); |
179 | notification_manager.progress_canceled.connect( () => {operation_cancelled = true;}); |
180 | } |
181 | - |
182 | - void media_imported (Media m) { |
183 | + |
184 | + void media_imported_from_tagger (Media m) { |
185 | m.isTemporary = true; |
186 | this.medias.add(m); |
187 | m.rowid = medias_rowid; |
188 | @@ -80,7 +80,6 @@ |
189 | is_initialized = true; |
190 | device.initialized (device); |
191 | search_medias (""); |
192 | - //load_playlists (); |
193 | } |
194 | } |
195 | |
196 | @@ -88,26 +87,6 @@ |
197 | |
198 | } |
199 | |
200 | - private void load_playlists () { |
201 | - var imported_pl = new Gee.LinkedList<string> (); |
202 | - FileUtils.count_playlists_files (GLib.File.new_for_uri (device.get_music_folder () + "/Playlists/"), ref imported_pl); |
203 | - var playlists = new Gee.HashMap<string, Gee.LinkedList<string>> (); |
204 | - foreach (var file in imported_pl) { |
205 | - if(file != "") { |
206 | - var f = GLib.File.new_for_uri (file); |
207 | - var infos = f.query_info (GLib.FileAttribute.STANDARD_DISPLAY_NAME, FileQueryInfoFlags.NONE); |
208 | - var name = infos.get_display_name (); |
209 | - var paths = new Gee.LinkedList<string> (); |
210 | - if (file.has_suffix(".m3u")) { |
211 | - name = name.replace (".m3u", ""); |
212 | - PlaylistsUtils.parse_paths_from_m3u(file, ref paths); |
213 | - } |
214 | - playlists.set (name, paths); |
215 | - } |
216 | - } |
217 | - PlaylistsUtils.import_from_playlist_file_info(playlists, this); |
218 | - } |
219 | - |
220 | public override void add_files_to_library (Gee.Collection<string> files) { |
221 | |
222 | } |
223 | |
224 | === modified file 'plugins/Devices/iPod/iPodLibrary.vala' |
225 | --- plugins/Devices/iPod/iPodLibrary.vala 2013-06-02 17:35:04 +0000 |
226 | +++ plugins/Devices/iPod/iPodLibrary.vala 2013-07-26 20:46:25 +0000 |
227 | @@ -40,7 +40,6 @@ |
228 | Device device; |
229 | bool operation_cancelled = false; |
230 | bool is_doing_file_operations = false; |
231 | - bool queue_is_finished = false; |
232 | |
233 | public iPodLibrary (GPod.iTunesDB db, Device device) { |
234 | this.db = db; |
235 | @@ -202,7 +201,7 @@ |
236 | |
237 | bool success = false; |
238 | try { |
239 | - success = db.cp_track_to_ipod(added, File.new_for_uri(s.uri).get_path()); |
240 | + success = GPod.iTunesDB.cp_track_to_ipod (added, File.new_for_uri (s.uri).get_path ()); |
241 | debug ("Copied media %s to ipod\n", added.title); |
242 | } catch(Error err) { |
243 | warning ("Error adding/copying song %s to iPod: %s\n", s.title, err.message); |
244 | |
245 | === modified file 'src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala' |
246 | --- src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala 2013-06-25 18:24:42 +0000 |
247 | +++ src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala 2013-07-26 20:46:25 +0000 |
248 | @@ -20,350 +20,350 @@ |
249 | using Gtk; |
250 | |
251 | public class Noise.BrowserColumnModel : Object, TreeModel, TreeSortable { |
252 | - /* all iters must match this */ |
253 | - private int stamp = (int)Random.next_int (); |
254 | - |
255 | - public int n_items { get { return rows.get_length () - 1; } } // Doesn't count the first ("All..") item |
256 | - |
257 | - /* data storage variables */ |
258 | - private Sequence<string> rows; |
259 | - |
260 | - /* first iter. This helps us to track the "All" row */ |
261 | - TreeIter? first_iter; |
262 | - |
263 | - /* treesortable stuff */ |
264 | - private int sort_column_id; |
265 | - private SortType sort_direction; |
266 | - private unowned TreeIterCompareFunc default_sort_func; |
267 | - |
268 | - private BrowserColumn.Category category; |
269 | - |
270 | - /** Initialize data storage, columns, etc. **/ |
271 | - public BrowserColumnModel (BrowserColumn.Category category) { |
272 | - rows = new Sequence<string> (); |
273 | - |
274 | - this.category = category; |
275 | - |
276 | - sort_column_id = -2; |
277 | - sort_direction = SortType.ASCENDING; |
278 | - } |
279 | - |
280 | - /** Returns a set of flags supported by this interface **/ |
281 | - public TreeModelFlags get_flags () { |
282 | - return TreeModelFlags.LIST_ONLY; |
283 | - } |
284 | - |
285 | - /** Sets iter to a valid iterator pointing to path **/ |
286 | - public bool get_iter (out TreeIter iter, TreePath path) { |
287 | - iter = TreeIter (); |
288 | - int path_index = path.get_indices ()[0]; |
289 | - |
290 | - if (rows.get_length () == 0 || path_index < 0 || path_index >= rows.get_length ()) |
291 | - return false; |
292 | - |
293 | - var seq_iter = rows.get_iter_at_pos (path_index); |
294 | - if (seq_iter == null) |
295 | - return false; |
296 | - |
297 | - iter.stamp = this.stamp; |
298 | - iter.user_data = seq_iter; |
299 | - |
300 | - return true; |
301 | - } |
302 | - |
303 | - /** Returns the number of columns supported by tree_model. **/ |
304 | - public int get_n_columns () { |
305 | - return 1; |
306 | - } |
307 | - |
308 | - public Type get_column_type (int col) { |
309 | - return typeof (string); |
310 | - } |
311 | - |
312 | - /** Returns a newly-created Gtk.TreePath referenced by iter. **/ |
313 | - public TreePath? get_path (TreeIter iter) { |
314 | - return new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); |
315 | - } |
316 | - |
317 | - /** Initializes and sets value to that at column. **/ |
318 | - public void get_value (TreeIter iter, int column, out Value val) { |
319 | - val = Value (typeof (string)); |
320 | - if (iter.stamp != this.stamp || column < 0 || column >= 1) |
321 | - return; |
322 | - |
323 | - if (! ( (SequenceIter<string>) iter.user_data).is_end ()) |
324 | - val = rows.get ( ( (SequenceIter<string>) iter.user_data)); |
325 | - } |
326 | - |
327 | - /** Sets iter to point to the first child of parent. **/ |
328 | - public bool iter_children (out TreeIter iter, TreeIter? parent) { |
329 | - iter = TreeIter (); |
330 | - |
331 | - return false; |
332 | - } |
333 | - |
334 | - /** Returns true if iter has children, false otherwise. **/ |
335 | - public bool iter_has_child (TreeIter iter) { |
336 | - |
337 | - return false; |
338 | - } |
339 | - |
340 | - /** Returns the number of children that iter has. **/ |
341 | - public int iter_n_children (TreeIter? iter) { |
342 | - if (iter == null) |
343 | - return rows.get_length (); |
344 | - |
345 | - return 0; |
346 | - } |
347 | - |
348 | - /** Sets iter to point to the node following it at the current level. **/ |
349 | - public bool iter_next (ref TreeIter iter) { |
350 | - if (iter.stamp != this.stamp) |
351 | - return false; |
352 | - |
353 | - iter.user_data = ( (SequenceIter)iter.user_data).next (); |
354 | - |
355 | - if ( ( (SequenceIter)iter.user_data).is_end ()) |
356 | - return false; |
357 | - |
358 | - return true; |
359 | - } |
360 | - |
361 | - /** Sets iter to be the child of parent, using the given index. **/ |
362 | - public bool iter_nth_child (out TreeIter iter, TreeIter? parent, int n) { |
363 | - iter = TreeIter (); |
364 | - if (n < 0 || n >= rows.get_length () || parent != null) |
365 | - return false; |
366 | - |
367 | - iter.stamp = this.stamp; |
368 | - iter.user_data = rows.get_iter_at_pos (n); |
369 | - |
370 | - return true; |
371 | - } |
372 | - |
373 | - /** Sets iter to be the parent of child. **/ |
374 | - public bool iter_parent (out TreeIter iter, TreeIter child) { |
375 | - iter = TreeIter (); |
376 | - |
377 | - return false; |
378 | - } |
379 | - |
380 | - /** Lets the tree ref the node. **/ |
381 | - public void ref_node (TreeIter iter) {} |
382 | - |
383 | - /** Lets the tree unref the node. **/ |
384 | - public void unref_node (TreeIter iter) {} |
385 | - |
386 | - /** simply adds iter to the model **/ |
387 | - public void append (out TreeIter iter) { |
388 | - iter = TreeIter (); |
389 | - SequenceIter<string> added = rows.append (""); |
390 | - iter.stamp = this.stamp; |
391 | - iter.user_data = added; |
392 | - } |
393 | - |
394 | - /** convenience method to insert strings into the model. No iters returned. **/ |
395 | - public void append_items (Gee.Collection<string> strings, bool emit) { |
396 | + /* all iters must match this */ |
397 | + private int stamp = (int)Random.next_int (); |
398 | + |
399 | + public int n_items { get { return rows.get_length () - 1; } } // Doesn't count the first ("All..") item |
400 | + |
401 | + /* data storage variables */ |
402 | + private Sequence<string> rows; |
403 | + |
404 | + /* first iter. This helps us to track the "All" row */ |
405 | + TreeIter? first_iter; |
406 | + |
407 | + /* treesortable stuff */ |
408 | + private int sort_column_id; |
409 | + private SortType sort_direction; |
410 | + private unowned TreeIterCompareFunc default_sort_func; |
411 | + |
412 | + private BrowserColumn.Category category; |
413 | + |
414 | + /** Initialize data storage, columns, etc. **/ |
415 | + public BrowserColumnModel (BrowserColumn.Category category) { |
416 | + rows = new Sequence<string> (); |
417 | + |
418 | + this.category = category; |
419 | + |
420 | + sort_column_id = -2; |
421 | + sort_direction = SortType.ASCENDING; |
422 | + } |
423 | + |
424 | + /** Returns a set of flags supported by this interface **/ |
425 | + public TreeModelFlags get_flags () { |
426 | + return TreeModelFlags.LIST_ONLY; |
427 | + } |
428 | + |
429 | + /** Sets iter to a valid iterator pointing to path **/ |
430 | + public bool get_iter (out TreeIter iter, TreePath path) { |
431 | + iter = TreeIter (); |
432 | + int path_index = path.get_indices ()[0]; |
433 | + |
434 | + if (rows.get_length () == 0 || path_index < 0 || path_index >= rows.get_length ()) |
435 | + return false; |
436 | + |
437 | + var seq_iter = rows.get_iter_at_pos (path_index); |
438 | + if (seq_iter == null) |
439 | + return false; |
440 | + |
441 | + iter.stamp = this.stamp; |
442 | + iter.user_data = seq_iter; |
443 | + |
444 | + return true; |
445 | + } |
446 | + |
447 | + /** Returns the number of columns supported by tree_model. **/ |
448 | + public int get_n_columns () { |
449 | + return 1; |
450 | + } |
451 | + |
452 | + public Type get_column_type (int col) { |
453 | + return typeof (string); |
454 | + } |
455 | + |
456 | + /** Returns a newly-created Gtk.TreePath referenced by iter. **/ |
457 | + public TreePath? get_path (TreeIter iter) { |
458 | + return new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); |
459 | + } |
460 | + |
461 | + /** Initializes and sets value to that at column. **/ |
462 | + public void get_value (TreeIter iter, int column, out Value val) { |
463 | + val = Value (typeof (string)); |
464 | + if (iter.stamp != this.stamp || column < 0 || column >= 1) |
465 | + return; |
466 | + |
467 | + if (! ( (SequenceIter<string>) iter.user_data).is_end ()) |
468 | + val = Sequence<string>.get (((SequenceIter<string>) iter.user_data)); |
469 | + } |
470 | + |
471 | + /** Sets iter to point to the first child of parent. **/ |
472 | + public bool iter_children (out TreeIter iter, TreeIter? parent) { |
473 | + iter = TreeIter (); |
474 | + |
475 | + return false; |
476 | + } |
477 | + |
478 | + /** Returns true if iter has children, false otherwise. **/ |
479 | + public bool iter_has_child (TreeIter iter) { |
480 | + |
481 | + return false; |
482 | + } |
483 | + |
484 | + /** Returns the number of children that iter has. **/ |
485 | + public int iter_n_children (TreeIter? iter) { |
486 | + if (iter == null) |
487 | + return rows.get_length (); |
488 | + |
489 | + return 0; |
490 | + } |
491 | + |
492 | + /** Sets iter to point to the node following it at the current level. **/ |
493 | + public bool iter_next (ref TreeIter iter) { |
494 | + if (iter.stamp != this.stamp) |
495 | + return false; |
496 | + |
497 | + iter.user_data = ( (SequenceIter)iter.user_data).next (); |
498 | + |
499 | + if ( ( (SequenceIter)iter.user_data).is_end ()) |
500 | + return false; |
501 | + |
502 | + return true; |
503 | + } |
504 | + |
505 | + /** Sets iter to be the child of parent, using the given index. **/ |
506 | + public bool iter_nth_child (out TreeIter iter, TreeIter? parent, int n) { |
507 | + iter = TreeIter (); |
508 | + if (n < 0 || n >= rows.get_length () || parent != null) |
509 | + return false; |
510 | + |
511 | + iter.stamp = this.stamp; |
512 | + iter.user_data = rows.get_iter_at_pos (n); |
513 | + |
514 | + return true; |
515 | + } |
516 | + |
517 | + /** Sets iter to be the parent of child. **/ |
518 | + public bool iter_parent (out TreeIter iter, TreeIter child) { |
519 | + iter = TreeIter (); |
520 | + |
521 | + return false; |
522 | + } |
523 | + |
524 | + /** Lets the tree ref the node. **/ |
525 | + public void ref_node (TreeIter iter) {} |
526 | + |
527 | + /** Lets the tree unref the node. **/ |
528 | + public void unref_node (TreeIter iter) {} |
529 | + |
530 | + /** simply adds iter to the model **/ |
531 | + public void append (out TreeIter iter) { |
532 | + iter = TreeIter (); |
533 | + SequenceIter<string> added = rows.append (""); |
534 | + iter.stamp = this.stamp; |
535 | + iter.user_data = added; |
536 | + } |
537 | + |
538 | + /** convenience method to insert strings into the model. No iters returned. **/ |
539 | + public void append_items (Gee.Collection<string> strings, bool emit) { |
540 | if (first_iter == null) |
541 | - add_first_element (); |
542 | - |
543 | - foreach (string s in strings) { |
544 | - SequenceIter<string> added = rows.append (s); |
545 | - |
546 | - if (emit) { |
547 | - var path = new TreePath.from_string (added.get_position ().to_string ()); |
548 | - var iter = TreeIter (); |
549 | - |
550 | - iter.stamp = this.stamp; |
551 | - iter.user_data = added; |
552 | - |
553 | - row_inserted (path, iter); |
554 | - } |
555 | - } |
556 | - |
557 | - update_first_item (); |
558 | - } |
559 | - |
560 | - /* Add the "All" item */ |
561 | - private void add_first_element () { |
562 | - SequenceIter<string> added = rows.append ("All"); |
563 | - |
564 | - first_iter = TreeIter (); |
565 | - |
566 | - first_iter.stamp = this.stamp; |
567 | - first_iter.user_data = added; |
568 | - } |
569 | - |
570 | - /* Updates the "All" item */ |
571 | - private void update_first_item () { |
572 | - rows.set ( (SequenceIter<string>)first_iter.user_data, get_first_item_text (n_items)); |
573 | - } |
574 | - |
575 | - |
576 | - // The text to use for the first item. |
577 | - private string get_first_item_text (int n_items) { |
578 | - string rv = ""; |
579 | - |
580 | - switch (category) { |
581 | - case BrowserColumn.Category.GENRE: |
582 | - if (n_items == 1) |
583 | - rv = _ ("All Genres"); |
584 | - else if (n_items > 1) |
585 | - rv = _ ("All %i Genres").printf (n_items); |
586 | - else |
587 | - rv = _ ("No Genres"); |
588 | - break; |
589 | - |
590 | - case BrowserColumn.Category.ARTIST: |
591 | - if (n_items == 1) |
592 | - rv = _ ("All Artists"); |
593 | - else if (n_items > 1) |
594 | - rv = _ ("All %i Artists").printf (n_items); |
595 | - else |
596 | - rv = _ ("No Artists"); |
597 | - break; |
598 | - |
599 | - case BrowserColumn.Category.ALBUM: |
600 | - if (n_items == 1) |
601 | - rv = _ ("All Albums"); |
602 | - else if (n_items > 1) |
603 | - rv = _ ("All %i Albums").printf (n_items); |
604 | - else |
605 | - rv = _ ("No Albums"); |
606 | - break; |
607 | - |
608 | - case BrowserColumn.Category.YEAR: |
609 | - if (n_items == 1) |
610 | - rv = _ ("All Years"); |
611 | - else if (n_items > 1) |
612 | - rv = _ ("All %i Years").printf (n_items); |
613 | - else |
614 | - rv = _ ("No Years"); |
615 | - break; |
616 | - |
617 | - case BrowserColumn.Category.RATING: |
618 | - if (n_items >= 1) |
619 | - rv = _ ("All Ratings"); |
620 | - else |
621 | - rv = _ ("No Ratings"); |
622 | - break; |
623 | - |
624 | - case BrowserColumn.Category.GROUPING: |
625 | - if (n_items == 1) |
626 | - rv = _ ("All Groupings"); |
627 | - else if (n_items > 1) |
628 | - rv = _ ("All %i Groupings").printf (n_items); |
629 | - else |
630 | - rv = _ ("No Groupings"); |
631 | - break; |
632 | - |
633 | - case BrowserColumn.Category.COMPOSER: |
634 | - if (n_items == 1) |
635 | - rv = _ ("All Composers"); |
636 | - else if (n_items > 1) |
637 | - rv = _ ("All %i Composers").printf (n_items); |
638 | - else |
639 | - rv = _ ("No Composers"); |
640 | - break; |
641 | - } |
642 | - |
643 | - return rv; |
644 | - } |
645 | - |
646 | - |
647 | - public new void set (TreeIter iter, ...) { |
648 | - if (iter.stamp != this.stamp) |
649 | - return; |
650 | - |
651 | - var args = va_list (); // now call args.arg () to poll |
652 | - |
653 | - while (true) { |
654 | - int col = args.arg (); |
655 | - if (col < 0 || col >= 1) |
656 | - return; |
657 | - else if (col == 0) { |
658 | - string val = args.arg (); |
659 | - rows.set ( (SequenceIter<string>)iter.user_data, val); |
660 | - } |
661 | - } |
662 | - } |
663 | - |
664 | - public void remove (TreeIter iter) { |
665 | - if (iter.stamp != this.stamp) |
666 | - return; |
667 | - |
668 | - var path = new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); |
669 | - rows.remove ( (SequenceIter<string>)iter.user_data); |
670 | - row_deleted (path); |
671 | - } |
672 | - |
673 | - /** Fills in sort_column_id and order with the current sort column and the order. **/ |
674 | - public bool get_sort_column_id (out int sort_column_id, out SortType order) { |
675 | - sort_column_id = this.sort_column_id; |
676 | - order = sort_direction; |
677 | - |
678 | - return true; |
679 | - } |
680 | - |
681 | - /** Returns true if the model has a default sort function. **/ |
682 | - public bool has_default_sort_func () { |
683 | - return (default_sort_func != null); |
684 | - } |
685 | - |
686 | - /** Sets the default comparison function used when sorting to be sort_func. **/ |
687 | - public void set_default_sort_func (owned TreeIterCompareFunc sort_func) { |
688 | - default_sort_func = sort_func; |
689 | - } |
690 | - |
691 | - /** Sets the current sort column to be sort_column_id. **/ |
692 | - public void set_sort_column_id (int sort_column_id, SortType order) { |
693 | - bool changed = (this.sort_column_id != sort_column_id || order != sort_direction); |
694 | - |
695 | - this.sort_column_id = sort_column_id; |
696 | - sort_direction = order; |
697 | - |
698 | - if (changed && sort_column_id >= 0) { |
699 | - /* do the sort for reals */ |
700 | - rows.sort_iter (sequenceIterCompareFunc); |
701 | - |
702 | - sort_column_changed (); |
703 | - } |
704 | - } |
705 | - |
706 | - public void set_sort_func (int sort_column_id, owned TreeIterCompareFunc sort_func) { |
707 | - |
708 | - } |
709 | - |
710 | - |
711 | - /** Custom function to use built in sort in Sequence to our advantage **/ |
712 | - public int sequenceIterCompareFunc (SequenceIter<string> a, SequenceIter<string> b) { |
713 | - int rv = 1; |
714 | - |
715 | - if (sort_column_id < 0) |
716 | - return 0; |
717 | - |
718 | - if (sort_column_id == 0) { |
719 | - var first_sequence_iter = (SequenceIter)first_iter.user_data; |
720 | - |
721 | - // "All" is always the first |
722 | - if (a == first_sequence_iter) { |
723 | - rv = -1; |
724 | - } |
725 | - else if (b == first_sequence_iter) { |
726 | - rv = 1; |
727 | - } |
728 | - else { |
729 | - if (category == BrowserColumn.Category.ARTIST || category == BrowserColumn.Category.ALBUM) |
730 | - rv = String.compare (rows.get (a), rows.get (b)); |
731 | - else |
732 | - rv = String.compare (rows.get (a), rows.get (b)); |
733 | - } |
734 | - } |
735 | - |
736 | - if (sort_direction == SortType.DESCENDING) |
737 | - rv = (rv > 0) ? -1 : 1; |
738 | - |
739 | - return rv; |
740 | - } |
741 | + add_first_element (); |
742 | + |
743 | + foreach (string s in strings) { |
744 | + SequenceIter<string> added = rows.append (s); |
745 | + |
746 | + if (emit) { |
747 | + var path = new TreePath.from_string (added.get_position ().to_string ()); |
748 | + var iter = TreeIter (); |
749 | + |
750 | + iter.stamp = this.stamp; |
751 | + iter.user_data = added; |
752 | + |
753 | + row_inserted (path, iter); |
754 | + } |
755 | + } |
756 | + |
757 | + update_first_item (); |
758 | + } |
759 | + |
760 | + /* Add the "All" item */ |
761 | + private void add_first_element () { |
762 | + SequenceIter<string> added = rows.append ("All"); |
763 | + |
764 | + first_iter = TreeIter (); |
765 | + |
766 | + first_iter.stamp = this.stamp; |
767 | + first_iter.user_data = added; |
768 | + } |
769 | + |
770 | + /* Updates the "All" item */ |
771 | + private void update_first_item () { |
772 | + Sequence<string>.set ( (SequenceIter<string>)first_iter.user_data, get_first_item_text (n_items)); |
773 | + } |
774 | + |
775 | + |
776 | + // The text to use for the first item. |
777 | + private string get_first_item_text (int n_items) { |
778 | + string rv = ""; |
779 | + |
780 | + switch (category) { |
781 | + case BrowserColumn.Category.GENRE: |
782 | + if (n_items == 1) |
783 | + rv = _ ("All Genres"); |
784 | + else if (n_items > 1) |
785 | + rv = _ ("All %i Genres").printf (n_items); |
786 | + else |
787 | + rv = _ ("No Genres"); |
788 | + break; |
789 | + |
790 | + case BrowserColumn.Category.ARTIST: |
791 | + if (n_items == 1) |
792 | + rv = _ ("All Artists"); |
793 | + else if (n_items > 1) |
794 | + rv = _ ("All %i Artists").printf (n_items); |
795 | + else |
796 | + rv = _ ("No Artists"); |
797 | + break; |
798 | + |
799 | + case BrowserColumn.Category.ALBUM: |
800 | + if (n_items == 1) |
801 | + rv = _ ("All Albums"); |
802 | + else if (n_items > 1) |
803 | + rv = _ ("All %i Albums").printf (n_items); |
804 | + else |
805 | + rv = _ ("No Albums"); |
806 | + break; |
807 | + |
808 | + case BrowserColumn.Category.YEAR: |
809 | + if (n_items == 1) |
810 | + rv = _ ("All Years"); |
811 | + else if (n_items > 1) |
812 | + rv = _ ("All %i Years").printf (n_items); |
813 | + else |
814 | + rv = _ ("No Years"); |
815 | + break; |
816 | + |
817 | + case BrowserColumn.Category.RATING: |
818 | + if (n_items >= 1) |
819 | + rv = _ ("All Ratings"); |
820 | + else |
821 | + rv = _ ("No Ratings"); |
822 | + break; |
823 | + |
824 | + case BrowserColumn.Category.GROUPING: |
825 | + if (n_items == 1) |
826 | + rv = _ ("All Groupings"); |
827 | + else if (n_items > 1) |
828 | + rv = _ ("All %i Groupings").printf (n_items); |
829 | + else |
830 | + rv = _ ("No Groupings"); |
831 | + break; |
832 | + |
833 | + case BrowserColumn.Category.COMPOSER: |
834 | + if (n_items == 1) |
835 | + rv = _ ("All Composers"); |
836 | + else if (n_items > 1) |
837 | + rv = _ ("All %i Composers").printf (n_items); |
838 | + else |
839 | + rv = _ ("No Composers"); |
840 | + break; |
841 | + } |
842 | + |
843 | + return rv; |
844 | + } |
845 | + |
846 | + |
847 | + public new void set (TreeIter iter, ...) { |
848 | + if (iter.stamp != this.stamp) |
849 | + return; |
850 | + |
851 | + var args = va_list (); // now call args.arg () to poll |
852 | + |
853 | + while (true) { |
854 | + int col = args.arg (); |
855 | + if (col < 0 || col >= 1) |
856 | + return; |
857 | + else if (col == 0) { |
858 | + string val = args.arg (); |
859 | + Sequence<string>.set ( (SequenceIter<string>)iter.user_data, val); |
860 | + } |
861 | + } |
862 | + } |
863 | + |
864 | + public void remove (TreeIter iter) { |
865 | + if (iter.stamp != this.stamp) |
866 | + return; |
867 | + |
868 | + var path = new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); |
869 | + Sequence<string>.remove ( (SequenceIter<string>)iter.user_data); |
870 | + row_deleted (path); |
871 | + } |
872 | + |
873 | + /** Fills in sort_column_id and order with the current sort column and the order. **/ |
874 | + public bool get_sort_column_id (out int sort_column_id, out SortType order) { |
875 | + sort_column_id = this.sort_column_id; |
876 | + order = sort_direction; |
877 | + |
878 | + return true; |
879 | + } |
880 | + |
881 | + /** Returns true if the model has a default sort function. **/ |
882 | + public bool has_default_sort_func () { |
883 | + return (default_sort_func != null); |
884 | + } |
885 | + |
886 | + /** Sets the default comparison function used when sorting to be sort_func. **/ |
887 | + public void set_default_sort_func (owned TreeIterCompareFunc sort_func) { |
888 | + default_sort_func = sort_func; |
889 | + } |
890 | + |
891 | + /** Sets the current sort column to be sort_column_id. **/ |
892 | + public void set_sort_column_id (int sort_column_id, SortType order) { |
893 | + bool changed = (this.sort_column_id != sort_column_id || order != sort_direction); |
894 | + |
895 | + this.sort_column_id = sort_column_id; |
896 | + sort_direction = order; |
897 | + |
898 | + if (changed && sort_column_id >= 0) { |
899 | + /* do the sort for reals */ |
900 | + rows.sort_iter (sequenceIterCompareFunc); |
901 | + |
902 | + sort_column_changed (); |
903 | + } |
904 | + } |
905 | + |
906 | + public void set_sort_func (int sort_column_id, owned TreeIterCompareFunc sort_func) { |
907 | + |
908 | + } |
909 | + |
910 | + |
911 | + /** Custom function to use built in sort in Sequence to our advantage **/ |
912 | + public int sequenceIterCompareFunc (SequenceIter<string> a, SequenceIter<string> b) { |
913 | + int rv = 1; |
914 | + |
915 | + if (sort_column_id < 0) |
916 | + return 0; |
917 | + |
918 | + if (sort_column_id == 0) { |
919 | + var first_sequence_iter = (SequenceIter)first_iter.user_data; |
920 | + |
921 | + // "All" is always the first |
922 | + if (a == first_sequence_iter) { |
923 | + rv = -1; |
924 | + } |
925 | + else if (b == first_sequence_iter) { |
926 | + rv = 1; |
927 | + } |
928 | + else { |
929 | + if (category == BrowserColumn.Category.ARTIST || category == BrowserColumn.Category.ALBUM) |
930 | + rv = String.compare (Sequence<string>.get (a), Sequence<string>.get (b)); |
931 | + else |
932 | + rv = String.compare (Sequence<string>.get (a), Sequence<string>.get (b)); |
933 | + } |
934 | + } |
935 | + |
936 | + if (sort_direction == SortType.DESCENDING) |
937 | + rv = (rv > 0) ? -1 : 1; |
938 | + |
939 | + return rv; |
940 | + } |
941 | } |
942 |
>val = Sequence< string> .get ( ( (SequenceIter< string> ) iter.user_data));
Always put a space before a parenthese '(' unless there are two or more in a row, so the above line should be:
>val = Sequence< string> .get (((SequenceIter <string> ) iter.user_data));
Another example:
success = GPod.iTunesDB. cp_track_ to_ipod( added, File.new_ for_uri( s.uri). get_path( )); cp_track_ to_ipod (added, File.new_for_uri (s.uri).get_path ());
↓
success = GPod.iTunesDB.
Also, you're mixing tabs and spaces for indentation, I know it's not entirely your fault, because the file was probably a mess already, but if you could turn all to spaces (or all to tabs if that's what tintou is using), I'd really like it.