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 | 29 | */ | 29 | */ |
6 | 30 | 30 | ||
7 | 31 | public class Noise.Pipeline : GLib.Object { | 31 | public class Noise.Pipeline : GLib.Object { |
95 | 32 | public Gst.Pipeline pipe; | 32 | public Gst.Pipeline pipe; |
96 | 33 | public Equalizer eq; | 33 | public Equalizer eq; |
97 | 34 | 34 | ||
98 | 35 | public dynamic Gst.Bus bus; | 35 | public dynamic Gst.Bus bus; |
99 | 36 | //Pad teepad; | 36 | public Gst.Pad pad; |
100 | 37 | public Gst.Pad pad; | 37 | |
101 | 38 | 38 | public dynamic Gst.Element audiosink; | |
102 | 39 | public dynamic Gst.Element audiosink; | 39 | public dynamic Gst.Element audiosinkqueue; |
103 | 40 | public dynamic Gst.Element audiosinkqueue; | 40 | public dynamic Gst.Element eq_audioconvert; |
104 | 41 | public dynamic Gst.Element eq_audioconvert; | 41 | public dynamic Gst.Element eq_audioconvert2; |
105 | 42 | public dynamic Gst.Element eq_audioconvert2; | 42 | |
106 | 43 | 43 | public dynamic Gst.Element playbin; | |
107 | 44 | public dynamic Gst.Element playbin; | 44 | public dynamic Gst.Element audiotee; |
108 | 45 | public dynamic Gst.Element audiotee; | 45 | public dynamic Gst.Element audiobin; |
109 | 46 | public dynamic Gst.Element audiobin; | 46 | public dynamic Gst.Element preamp; |
110 | 47 | public dynamic Gst.Element preamp; | 47 | |
111 | 48 | //dynamic Gst.Element volume; | 48 | public Pipeline() { |
112 | 49 | //dynamic Gst.Element rgvolume; | 49 | |
113 | 50 | 50 | pipe = new Gst.Pipeline("pipeline"); | |
114 | 51 | public Pipeline() { | 51 | playbin = Gst.ElementFactory.make("playbin2", "play"); |
115 | 52 | 52 | ||
116 | 53 | pipe = new Gst.Pipeline("pipeline"); | 53 | audiosink = Gst.ElementFactory.make("autoaudiosink", "audio-sink"); |
117 | 54 | playbin = Gst.ElementFactory.make("playbin2", "play"); | 54 | |
118 | 55 | 55 | audiobin = new Gst.Bin("audiobin"); // this holds the real primary sink | |
119 | 56 | audiosink = Gst.ElementFactory.make("autoaudiosink", "audio-sink"); | 56 | |
120 | 57 | //audiosink.set("profile", 1); // says we handle music and movies | 57 | audiotee = Gst.ElementFactory.make("tee", null); |
121 | 58 | 58 | audiosinkqueue = Gst.ElementFactory.make("queue", null); | |
122 | 59 | audiobin = new Gst.Bin("audiobin"); // this holds the real primary sink | 59 | |
123 | 60 | 60 | eq = new Equalizer(); | |
124 | 61 | audiotee = Gst.ElementFactory.make("tee", null); | 61 | if(eq.element != null) { |
125 | 62 | audiosinkqueue = Gst.ElementFactory.make("queue", null); | 62 | eq_audioconvert = Gst.ElementFactory.make("audioconvert", null); |
126 | 63 | 63 | eq_audioconvert2 = Gst.ElementFactory.make("audioconvert", null); | |
127 | 64 | eq = new Equalizer(); | 64 | preamp = Gst.ElementFactory.make("volume", "preamp"); |
128 | 65 | if(eq.element != null) { | 65 | |
129 | 66 | eq_audioconvert = Gst.ElementFactory.make("audioconvert", null); | 66 | ((Gst.Bin)audiobin).add_many(eq.element, eq_audioconvert, eq_audioconvert2, preamp); |
130 | 67 | eq_audioconvert2 = Gst.ElementFactory.make("audioconvert", null); | 67 | } |
131 | 68 | preamp = Gst.ElementFactory.make("volume", "preamp"); | 68 | |
132 | 69 | 69 | ((Gst.Bin)audiobin).add_many(audiotee, audiosinkqueue, audiosink); | |
133 | 70 | ((Gst.Bin)audiobin).add_many(eq.element, eq_audioconvert, eq_audioconvert2, preamp); | 70 | |
134 | 71 | } | 71 | audiobin.add_pad(new Gst.GhostPad("sink", audiotee.get_pad("sink"))); |
135 | 72 | 72 | ||
136 | 73 | ((Gst.Bin)audiobin).add_many(audiotee, audiosinkqueue, audiosink); | 73 | if (eq.element != null) |
137 | 74 | 74 | audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); | |
138 | 75 | audiobin.add_pad(new Gst.GhostPad("sink", audiotee.get_pad("sink"))); | 75 | else |
139 | 76 | 76 | audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink | |
140 | 77 | if (eq.element != null) | 77 | |
141 | 78 | audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); | 78 | playbin.set("audio-sink", audiobin); |
142 | 79 | else | 79 | bus = playbin.get_bus(); |
143 | 80 | audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink | 80 | |
144 | 81 | 81 | // Link the first tee pad to the primary audio sink queue | |
145 | 82 | playbin.set("audio-sink", audiobin); | 82 | Gst.Pad sinkpad = audiosinkqueue.get_pad("sink"); |
146 | 83 | bus = playbin.get_bus(); | 83 | pad = audiotee.get_request_pad("src%d"); |
147 | 84 | 84 | audiotee.set("alloc-pad", pad); | |
148 | 85 | // Link the first tee pad to the primary audio sink queue | 85 | pad.link(sinkpad); |
149 | 86 | Gst.Pad sinkpad = audiosinkqueue.get_pad("sink"); | 86 | } |
150 | 87 | pad = audiotee.get_request_pad("src%d"); | 87 | |
151 | 88 | audiotee.set("alloc-pad", pad); | 88 | public void enableEqualizer() { |
152 | 89 | pad.link(sinkpad); | 89 | if (eq.element != null) { |
153 | 90 | 90 | audiosinkqueue.unlink_many(audiosink); // link the queue with the real audio sink | |
154 | 91 | //bus.add_watch(busCallback); | 91 | audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
155 | 92 | /*play.audio_tags_changed.connect(audioTagsChanged); | 92 | } |
156 | 93 | play.text_tags_changed.connect(textTagsChanged);*/ | 93 | } |
157 | 94 | } | 94 | |
158 | 95 | 95 | public void disableEqualizer() { | |
159 | 96 | /* | 96 | if (eq.element != null) { |
160 | 97 | private void audioTagsChanged(Gst.Element sender, int stream_number) { | 97 | audiosinkqueue.unlink_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); |
161 | 98 | 98 | audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink | |
162 | 99 | } | 99 | } |
163 | 100 | 100 | } | |
77 | 101 | /*private void textTagsChanged(Gst.Element sender, int stream_number) { | ||
78 | 102 | |||
79 | 103 | } | ||
80 | 104 | */ | ||
81 | 105 | |||
82 | 106 | public void enableEqualizer() { | ||
83 | 107 | if (eq.element != null) { | ||
84 | 108 | audiosinkqueue.unlink_many(audiosink); // link the queue with the real audio sink | ||
85 | 109 | audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); | ||
86 | 110 | } | ||
87 | 111 | } | ||
88 | 112 | |||
89 | 113 | public void disableEqualizer() { | ||
90 | 114 | if (eq.element != null) { | ||
91 | 115 | audiosinkqueue.unlink_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink); | ||
92 | 116 | audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink | ||
93 | 117 | } | ||
94 | 118 | } | ||
164 | 119 | } | 101 | } |
165 | 120 | 102 | ||
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 | 55 | 55 | ||
171 | 56 | tagger = new GStreamerTagger(); | 56 | tagger = new GStreamerTagger(); |
172 | 57 | 57 | ||
176 | 58 | tagger.media_imported.connect(media_imported); | 58 | tagger.media_imported.connect (media_imported_from_tagger); |
177 | 59 | tagger.import_error.connect(import_error); | 59 | tagger.import_error.connect (import_error); |
178 | 60 | tagger.queue_finished.connect(queue_finished); | 60 | tagger.queue_finished.connect (queue_finished); |
179 | 61 | notification_manager.progress_canceled.connect( () => {operation_cancelled = true;}); | 61 | notification_manager.progress_canceled.connect( () => {operation_cancelled = true;}); |
180 | 62 | } | 62 | } |
183 | 63 | 63 | ||
184 | 64 | void media_imported (Media m) { | 64 | void media_imported_from_tagger (Media m) { |
185 | 65 | m.isTemporary = true; | 65 | m.isTemporary = true; |
186 | 66 | this.medias.add(m); | 66 | this.medias.add(m); |
187 | 67 | m.rowid = medias_rowid; | 67 | m.rowid = medias_rowid; |
188 | @@ -80,7 +80,6 @@ | |||
189 | 80 | is_initialized = true; | 80 | is_initialized = true; |
190 | 81 | device.initialized (device); | 81 | device.initialized (device); |
191 | 82 | search_medias (""); | 82 | search_medias (""); |
192 | 83 | //load_playlists (); | ||
193 | 84 | } | 83 | } |
194 | 85 | } | 84 | } |
195 | 86 | 85 | ||
196 | @@ -88,26 +87,6 @@ | |||
197 | 88 | 87 | ||
198 | 89 | } | 88 | } |
199 | 90 | 89 | ||
200 | 91 | private void load_playlists () { | ||
201 | 92 | var imported_pl = new Gee.LinkedList<string> (); | ||
202 | 93 | FileUtils.count_playlists_files (GLib.File.new_for_uri (device.get_music_folder () + "/Playlists/"), ref imported_pl); | ||
203 | 94 | var playlists = new Gee.HashMap<string, Gee.LinkedList<string>> (); | ||
204 | 95 | foreach (var file in imported_pl) { | ||
205 | 96 | if(file != "") { | ||
206 | 97 | var f = GLib.File.new_for_uri (file); | ||
207 | 98 | var infos = f.query_info (GLib.FileAttribute.STANDARD_DISPLAY_NAME, FileQueryInfoFlags.NONE); | ||
208 | 99 | var name = infos.get_display_name (); | ||
209 | 100 | var paths = new Gee.LinkedList<string> (); | ||
210 | 101 | if (file.has_suffix(".m3u")) { | ||
211 | 102 | name = name.replace (".m3u", ""); | ||
212 | 103 | PlaylistsUtils.parse_paths_from_m3u(file, ref paths); | ||
213 | 104 | } | ||
214 | 105 | playlists.set (name, paths); | ||
215 | 106 | } | ||
216 | 107 | } | ||
217 | 108 | PlaylistsUtils.import_from_playlist_file_info(playlists, this); | ||
218 | 109 | } | ||
219 | 110 | |||
220 | 111 | public override void add_files_to_library (Gee.Collection<string> files) { | 90 | public override void add_files_to_library (Gee.Collection<string> files) { |
221 | 112 | 91 | ||
222 | 113 | } | 92 | } |
223 | 114 | 93 | ||
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 | 40 | Device device; | 40 | Device device; |
229 | 41 | bool operation_cancelled = false; | 41 | bool operation_cancelled = false; |
230 | 42 | bool is_doing_file_operations = false; | 42 | bool is_doing_file_operations = false; |
231 | 43 | bool queue_is_finished = false; | ||
232 | 44 | 43 | ||
233 | 45 | public iPodLibrary (GPod.iTunesDB db, Device device) { | 44 | public iPodLibrary (GPod.iTunesDB db, Device device) { |
234 | 46 | this.db = db; | 45 | this.db = db; |
235 | @@ -202,7 +201,7 @@ | |||
236 | 202 | 201 | ||
237 | 203 | bool success = false; | 202 | bool success = false; |
238 | 204 | try { | 203 | try { |
240 | 205 | success = db.cp_track_to_ipod(added, File.new_for_uri(s.uri).get_path()); | 204 | success = GPod.iTunesDB.cp_track_to_ipod (added, File.new_for_uri (s.uri).get_path ()); |
241 | 206 | debug ("Copied media %s to ipod\n", added.title); | 205 | debug ("Copied media %s to ipod\n", added.title); |
242 | 207 | } catch(Error err) { | 206 | } catch(Error err) { |
243 | 208 | warning ("Error adding/copying song %s to iPod: %s\n", s.title, err.message); | 207 | warning ("Error adding/copying song %s to iPod: %s\n", s.title, err.message); |
244 | 209 | 208 | ||
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 | 20 | using Gtk; | 20 | using Gtk; |
250 | 21 | 21 | ||
251 | 22 | public class Noise.BrowserColumnModel : Object, TreeModel, TreeSortable { | 22 | public class Noise.BrowserColumnModel : Object, TreeModel, TreeSortable { |
396 | 23 | /* all iters must match this */ | 23 | /* all iters must match this */ |
397 | 24 | private int stamp = (int)Random.next_int (); | 24 | private int stamp = (int)Random.next_int (); |
398 | 25 | 25 | ||
399 | 26 | public int n_items { get { return rows.get_length () - 1; } } // Doesn't count the first ("All..") item | 26 | public int n_items { get { return rows.get_length () - 1; } } // Doesn't count the first ("All..") item |
400 | 27 | 27 | ||
401 | 28 | /* data storage variables */ | 28 | /* data storage variables */ |
402 | 29 | private Sequence<string> rows; | 29 | private Sequence<string> rows; |
403 | 30 | 30 | ||
404 | 31 | /* first iter. This helps us to track the "All" row */ | 31 | /* first iter. This helps us to track the "All" row */ |
405 | 32 | TreeIter? first_iter; | 32 | TreeIter? first_iter; |
406 | 33 | 33 | ||
407 | 34 | /* treesortable stuff */ | 34 | /* treesortable stuff */ |
408 | 35 | private int sort_column_id; | 35 | private int sort_column_id; |
409 | 36 | private SortType sort_direction; | 36 | private SortType sort_direction; |
410 | 37 | private unowned TreeIterCompareFunc default_sort_func; | 37 | private unowned TreeIterCompareFunc default_sort_func; |
411 | 38 | 38 | ||
412 | 39 | private BrowserColumn.Category category; | 39 | private BrowserColumn.Category category; |
413 | 40 | 40 | ||
414 | 41 | /** Initialize data storage, columns, etc. **/ | 41 | /** Initialize data storage, columns, etc. **/ |
415 | 42 | public BrowserColumnModel (BrowserColumn.Category category) { | 42 | public BrowserColumnModel (BrowserColumn.Category category) { |
416 | 43 | rows = new Sequence<string> (); | 43 | rows = new Sequence<string> (); |
417 | 44 | 44 | ||
418 | 45 | this.category = category; | 45 | this.category = category; |
419 | 46 | 46 | ||
420 | 47 | sort_column_id = -2; | 47 | sort_column_id = -2; |
421 | 48 | sort_direction = SortType.ASCENDING; | 48 | sort_direction = SortType.ASCENDING; |
422 | 49 | } | 49 | } |
423 | 50 | 50 | ||
424 | 51 | /** Returns a set of flags supported by this interface **/ | 51 | /** Returns a set of flags supported by this interface **/ |
425 | 52 | public TreeModelFlags get_flags () { | 52 | public TreeModelFlags get_flags () { |
426 | 53 | return TreeModelFlags.LIST_ONLY; | 53 | return TreeModelFlags.LIST_ONLY; |
427 | 54 | } | 54 | } |
428 | 55 | 55 | ||
429 | 56 | /** Sets iter to a valid iterator pointing to path **/ | 56 | /** Sets iter to a valid iterator pointing to path **/ |
430 | 57 | public bool get_iter (out TreeIter iter, TreePath path) { | 57 | public bool get_iter (out TreeIter iter, TreePath path) { |
431 | 58 | iter = TreeIter (); | 58 | iter = TreeIter (); |
432 | 59 | int path_index = path.get_indices ()[0]; | 59 | int path_index = path.get_indices ()[0]; |
433 | 60 | 60 | ||
434 | 61 | if (rows.get_length () == 0 || path_index < 0 || path_index >= rows.get_length ()) | 61 | if (rows.get_length () == 0 || path_index < 0 || path_index >= rows.get_length ()) |
435 | 62 | return false; | 62 | return false; |
436 | 63 | 63 | ||
437 | 64 | var seq_iter = rows.get_iter_at_pos (path_index); | 64 | var seq_iter = rows.get_iter_at_pos (path_index); |
438 | 65 | if (seq_iter == null) | 65 | if (seq_iter == null) |
439 | 66 | return false; | 66 | return false; |
440 | 67 | 67 | ||
441 | 68 | iter.stamp = this.stamp; | 68 | iter.stamp = this.stamp; |
442 | 69 | iter.user_data = seq_iter; | 69 | iter.user_data = seq_iter; |
443 | 70 | 70 | ||
444 | 71 | return true; | 71 | return true; |
445 | 72 | } | 72 | } |
446 | 73 | 73 | ||
447 | 74 | /** Returns the number of columns supported by tree_model. **/ | 74 | /** Returns the number of columns supported by tree_model. **/ |
448 | 75 | public int get_n_columns () { | 75 | public int get_n_columns () { |
449 | 76 | return 1; | 76 | return 1; |
450 | 77 | } | 77 | } |
451 | 78 | 78 | ||
452 | 79 | public Type get_column_type (int col) { | 79 | public Type get_column_type (int col) { |
453 | 80 | return typeof (string); | 80 | return typeof (string); |
454 | 81 | } | 81 | } |
455 | 82 | 82 | ||
456 | 83 | /** Returns a newly-created Gtk.TreePath referenced by iter. **/ | 83 | /** Returns a newly-created Gtk.TreePath referenced by iter. **/ |
457 | 84 | public TreePath? get_path (TreeIter iter) { | 84 | public TreePath? get_path (TreeIter iter) { |
458 | 85 | return new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); | 85 | return new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); |
459 | 86 | } | 86 | } |
460 | 87 | 87 | ||
461 | 88 | /** Initializes and sets value to that at column. **/ | 88 | /** Initializes and sets value to that at column. **/ |
462 | 89 | public void get_value (TreeIter iter, int column, out Value val) { | 89 | public void get_value (TreeIter iter, int column, out Value val) { |
463 | 90 | val = Value (typeof (string)); | 90 | val = Value (typeof (string)); |
464 | 91 | if (iter.stamp != this.stamp || column < 0 || column >= 1) | 91 | if (iter.stamp != this.stamp || column < 0 || column >= 1) |
465 | 92 | return; | 92 | return; |
466 | 93 | 93 | ||
467 | 94 | if (! ( (SequenceIter<string>) iter.user_data).is_end ()) | 94 | if (! ( (SequenceIter<string>) iter.user_data).is_end ()) |
468 | 95 | val = rows.get ( ( (SequenceIter<string>) iter.user_data)); | 95 | val = Sequence<string>.get (((SequenceIter<string>) iter.user_data)); |
469 | 96 | } | 96 | } |
470 | 97 | 97 | ||
471 | 98 | /** Sets iter to point to the first child of parent. **/ | 98 | /** Sets iter to point to the first child of parent. **/ |
472 | 99 | public bool iter_children (out TreeIter iter, TreeIter? parent) { | 99 | public bool iter_children (out TreeIter iter, TreeIter? parent) { |
473 | 100 | iter = TreeIter (); | 100 | iter = TreeIter (); |
474 | 101 | 101 | ||
475 | 102 | return false; | 102 | return false; |
476 | 103 | } | 103 | } |
477 | 104 | 104 | ||
478 | 105 | /** Returns true if iter has children, false otherwise. **/ | 105 | /** Returns true if iter has children, false otherwise. **/ |
479 | 106 | public bool iter_has_child (TreeIter iter) { | 106 | public bool iter_has_child (TreeIter iter) { |
480 | 107 | 107 | ||
481 | 108 | return false; | 108 | return false; |
482 | 109 | } | 109 | } |
483 | 110 | 110 | ||
484 | 111 | /** Returns the number of children that iter has. **/ | 111 | /** Returns the number of children that iter has. **/ |
485 | 112 | public int iter_n_children (TreeIter? iter) { | 112 | public int iter_n_children (TreeIter? iter) { |
486 | 113 | if (iter == null) | 113 | if (iter == null) |
487 | 114 | return rows.get_length (); | 114 | return rows.get_length (); |
488 | 115 | 115 | ||
489 | 116 | return 0; | 116 | return 0; |
490 | 117 | } | 117 | } |
491 | 118 | 118 | ||
492 | 119 | /** Sets iter to point to the node following it at the current level. **/ | 119 | /** Sets iter to point to the node following it at the current level. **/ |
493 | 120 | public bool iter_next (ref TreeIter iter) { | 120 | public bool iter_next (ref TreeIter iter) { |
494 | 121 | if (iter.stamp != this.stamp) | 121 | if (iter.stamp != this.stamp) |
495 | 122 | return false; | 122 | return false; |
496 | 123 | 123 | ||
497 | 124 | iter.user_data = ( (SequenceIter)iter.user_data).next (); | 124 | iter.user_data = ( (SequenceIter)iter.user_data).next (); |
498 | 125 | 125 | ||
499 | 126 | if ( ( (SequenceIter)iter.user_data).is_end ()) | 126 | if ( ( (SequenceIter)iter.user_data).is_end ()) |
500 | 127 | return false; | 127 | return false; |
501 | 128 | 128 | ||
502 | 129 | return true; | 129 | return true; |
503 | 130 | } | 130 | } |
504 | 131 | 131 | ||
505 | 132 | /** Sets iter to be the child of parent, using the given index. **/ | 132 | /** Sets iter to be the child of parent, using the given index. **/ |
506 | 133 | public bool iter_nth_child (out TreeIter iter, TreeIter? parent, int n) { | 133 | public bool iter_nth_child (out TreeIter iter, TreeIter? parent, int n) { |
507 | 134 | iter = TreeIter (); | 134 | iter = TreeIter (); |
508 | 135 | if (n < 0 || n >= rows.get_length () || parent != null) | 135 | if (n < 0 || n >= rows.get_length () || parent != null) |
509 | 136 | return false; | 136 | return false; |
510 | 137 | 137 | ||
511 | 138 | iter.stamp = this.stamp; | 138 | iter.stamp = this.stamp; |
512 | 139 | iter.user_data = rows.get_iter_at_pos (n); | 139 | iter.user_data = rows.get_iter_at_pos (n); |
513 | 140 | 140 | ||
514 | 141 | return true; | 141 | return true; |
515 | 142 | } | 142 | } |
516 | 143 | 143 | ||
517 | 144 | /** Sets iter to be the parent of child. **/ | 144 | /** Sets iter to be the parent of child. **/ |
518 | 145 | public bool iter_parent (out TreeIter iter, TreeIter child) { | 145 | public bool iter_parent (out TreeIter iter, TreeIter child) { |
519 | 146 | iter = TreeIter (); | 146 | iter = TreeIter (); |
520 | 147 | 147 | ||
521 | 148 | return false; | 148 | return false; |
522 | 149 | } | 149 | } |
523 | 150 | 150 | ||
524 | 151 | /** Lets the tree ref the node. **/ | 151 | /** Lets the tree ref the node. **/ |
525 | 152 | public void ref_node (TreeIter iter) {} | 152 | public void ref_node (TreeIter iter) {} |
526 | 153 | 153 | ||
527 | 154 | /** Lets the tree unref the node. **/ | 154 | /** Lets the tree unref the node. **/ |
528 | 155 | public void unref_node (TreeIter iter) {} | 155 | public void unref_node (TreeIter iter) {} |
529 | 156 | 156 | ||
530 | 157 | /** simply adds iter to the model **/ | 157 | /** simply adds iter to the model **/ |
531 | 158 | public void append (out TreeIter iter) { | 158 | public void append (out TreeIter iter) { |
532 | 159 | iter = TreeIter (); | 159 | iter = TreeIter (); |
533 | 160 | SequenceIter<string> added = rows.append (""); | 160 | SequenceIter<string> added = rows.append (""); |
534 | 161 | iter.stamp = this.stamp; | 161 | iter.stamp = this.stamp; |
535 | 162 | iter.user_data = added; | 162 | iter.user_data = added; |
536 | 163 | } | 163 | } |
537 | 164 | 164 | ||
538 | 165 | /** convenience method to insert strings into the model. No iters returned. **/ | 165 | /** convenience method to insert strings into the model. No iters returned. **/ |
539 | 166 | public void append_items (Gee.Collection<string> strings, bool emit) { | 166 | public void append_items (Gee.Collection<string> strings, bool emit) { |
540 | 167 | if (first_iter == null) | 167 | if (first_iter == null) |
741 | 168 | add_first_element (); | 168 | add_first_element (); |
742 | 169 | 169 | ||
743 | 170 | foreach (string s in strings) { | 170 | foreach (string s in strings) { |
744 | 171 | SequenceIter<string> added = rows.append (s); | 171 | SequenceIter<string> added = rows.append (s); |
745 | 172 | 172 | ||
746 | 173 | if (emit) { | 173 | if (emit) { |
747 | 174 | var path = new TreePath.from_string (added.get_position ().to_string ()); | 174 | var path = new TreePath.from_string (added.get_position ().to_string ()); |
748 | 175 | var iter = TreeIter (); | 175 | var iter = TreeIter (); |
749 | 176 | 176 | ||
750 | 177 | iter.stamp = this.stamp; | 177 | iter.stamp = this.stamp; |
751 | 178 | iter.user_data = added; | 178 | iter.user_data = added; |
752 | 179 | 179 | ||
753 | 180 | row_inserted (path, iter); | 180 | row_inserted (path, iter); |
754 | 181 | } | 181 | } |
755 | 182 | } | 182 | } |
756 | 183 | 183 | ||
757 | 184 | update_first_item (); | 184 | update_first_item (); |
758 | 185 | } | 185 | } |
759 | 186 | 186 | ||
760 | 187 | /* Add the "All" item */ | 187 | /* Add the "All" item */ |
761 | 188 | private void add_first_element () { | 188 | private void add_first_element () { |
762 | 189 | SequenceIter<string> added = rows.append ("All"); | 189 | SequenceIter<string> added = rows.append ("All"); |
763 | 190 | 190 | ||
764 | 191 | first_iter = TreeIter (); | 191 | first_iter = TreeIter (); |
765 | 192 | 192 | ||
766 | 193 | first_iter.stamp = this.stamp; | 193 | first_iter.stamp = this.stamp; |
767 | 194 | first_iter.user_data = added; | 194 | first_iter.user_data = added; |
768 | 195 | } | 195 | } |
769 | 196 | 196 | ||
770 | 197 | /* Updates the "All" item */ | 197 | /* Updates the "All" item */ |
771 | 198 | private void update_first_item () { | 198 | private void update_first_item () { |
772 | 199 | rows.set ( (SequenceIter<string>)first_iter.user_data, get_first_item_text (n_items)); | 199 | Sequence<string>.set ( (SequenceIter<string>)first_iter.user_data, get_first_item_text (n_items)); |
773 | 200 | } | 200 | } |
774 | 201 | 201 | ||
775 | 202 | 202 | ||
776 | 203 | // The text to use for the first item. | 203 | // The text to use for the first item. |
777 | 204 | private string get_first_item_text (int n_items) { | 204 | private string get_first_item_text (int n_items) { |
778 | 205 | string rv = ""; | 205 | string rv = ""; |
779 | 206 | 206 | ||
780 | 207 | switch (category) { | 207 | switch (category) { |
781 | 208 | case BrowserColumn.Category.GENRE: | 208 | case BrowserColumn.Category.GENRE: |
782 | 209 | if (n_items == 1) | 209 | if (n_items == 1) |
783 | 210 | rv = _ ("All Genres"); | 210 | rv = _ ("All Genres"); |
784 | 211 | else if (n_items > 1) | 211 | else if (n_items > 1) |
785 | 212 | rv = _ ("All %i Genres").printf (n_items); | 212 | rv = _ ("All %i Genres").printf (n_items); |
786 | 213 | else | 213 | else |
787 | 214 | rv = _ ("No Genres"); | 214 | rv = _ ("No Genres"); |
788 | 215 | break; | 215 | break; |
789 | 216 | 216 | ||
790 | 217 | case BrowserColumn.Category.ARTIST: | 217 | case BrowserColumn.Category.ARTIST: |
791 | 218 | if (n_items == 1) | 218 | if (n_items == 1) |
792 | 219 | rv = _ ("All Artists"); | 219 | rv = _ ("All Artists"); |
793 | 220 | else if (n_items > 1) | 220 | else if (n_items > 1) |
794 | 221 | rv = _ ("All %i Artists").printf (n_items); | 221 | rv = _ ("All %i Artists").printf (n_items); |
795 | 222 | else | 222 | else |
796 | 223 | rv = _ ("No Artists"); | 223 | rv = _ ("No Artists"); |
797 | 224 | break; | 224 | break; |
798 | 225 | 225 | ||
799 | 226 | case BrowserColumn.Category.ALBUM: | 226 | case BrowserColumn.Category.ALBUM: |
800 | 227 | if (n_items == 1) | 227 | if (n_items == 1) |
801 | 228 | rv = _ ("All Albums"); | 228 | rv = _ ("All Albums"); |
802 | 229 | else if (n_items > 1) | 229 | else if (n_items > 1) |
803 | 230 | rv = _ ("All %i Albums").printf (n_items); | 230 | rv = _ ("All %i Albums").printf (n_items); |
804 | 231 | else | 231 | else |
805 | 232 | rv = _ ("No Albums"); | 232 | rv = _ ("No Albums"); |
806 | 233 | break; | 233 | break; |
807 | 234 | 234 | ||
808 | 235 | case BrowserColumn.Category.YEAR: | 235 | case BrowserColumn.Category.YEAR: |
809 | 236 | if (n_items == 1) | 236 | if (n_items == 1) |
810 | 237 | rv = _ ("All Years"); | 237 | rv = _ ("All Years"); |
811 | 238 | else if (n_items > 1) | 238 | else if (n_items > 1) |
812 | 239 | rv = _ ("All %i Years").printf (n_items); | 239 | rv = _ ("All %i Years").printf (n_items); |
813 | 240 | else | 240 | else |
814 | 241 | rv = _ ("No Years"); | 241 | rv = _ ("No Years"); |
815 | 242 | break; | 242 | break; |
816 | 243 | 243 | ||
817 | 244 | case BrowserColumn.Category.RATING: | 244 | case BrowserColumn.Category.RATING: |
818 | 245 | if (n_items >= 1) | 245 | if (n_items >= 1) |
819 | 246 | rv = _ ("All Ratings"); | 246 | rv = _ ("All Ratings"); |
820 | 247 | else | 247 | else |
821 | 248 | rv = _ ("No Ratings"); | 248 | rv = _ ("No Ratings"); |
822 | 249 | break; | 249 | break; |
823 | 250 | 250 | ||
824 | 251 | case BrowserColumn.Category.GROUPING: | 251 | case BrowserColumn.Category.GROUPING: |
825 | 252 | if (n_items == 1) | 252 | if (n_items == 1) |
826 | 253 | rv = _ ("All Groupings"); | 253 | rv = _ ("All Groupings"); |
827 | 254 | else if (n_items > 1) | 254 | else if (n_items > 1) |
828 | 255 | rv = _ ("All %i Groupings").printf (n_items); | 255 | rv = _ ("All %i Groupings").printf (n_items); |
829 | 256 | else | 256 | else |
830 | 257 | rv = _ ("No Groupings"); | 257 | rv = _ ("No Groupings"); |
831 | 258 | break; | 258 | break; |
832 | 259 | 259 | ||
833 | 260 | case BrowserColumn.Category.COMPOSER: | 260 | case BrowserColumn.Category.COMPOSER: |
834 | 261 | if (n_items == 1) | 261 | if (n_items == 1) |
835 | 262 | rv = _ ("All Composers"); | 262 | rv = _ ("All Composers"); |
836 | 263 | else if (n_items > 1) | 263 | else if (n_items > 1) |
837 | 264 | rv = _ ("All %i Composers").printf (n_items); | 264 | rv = _ ("All %i Composers").printf (n_items); |
838 | 265 | else | 265 | else |
839 | 266 | rv = _ ("No Composers"); | 266 | rv = _ ("No Composers"); |
840 | 267 | break; | 267 | break; |
841 | 268 | } | 268 | } |
842 | 269 | 269 | ||
843 | 270 | return rv; | 270 | return rv; |
844 | 271 | } | 271 | } |
845 | 272 | 272 | ||
846 | 273 | 273 | ||
847 | 274 | public new void set (TreeIter iter, ...) { | 274 | public new void set (TreeIter iter, ...) { |
848 | 275 | if (iter.stamp != this.stamp) | 275 | if (iter.stamp != this.stamp) |
849 | 276 | return; | 276 | return; |
850 | 277 | 277 | ||
851 | 278 | var args = va_list (); // now call args.arg () to poll | 278 | var args = va_list (); // now call args.arg () to poll |
852 | 279 | 279 | ||
853 | 280 | while (true) { | 280 | while (true) { |
854 | 281 | int col = args.arg (); | 281 | int col = args.arg (); |
855 | 282 | if (col < 0 || col >= 1) | 282 | if (col < 0 || col >= 1) |
856 | 283 | return; | 283 | return; |
857 | 284 | else if (col == 0) { | 284 | else if (col == 0) { |
858 | 285 | string val = args.arg (); | 285 | string val = args.arg (); |
859 | 286 | rows.set ( (SequenceIter<string>)iter.user_data, val); | 286 | Sequence<string>.set ( (SequenceIter<string>)iter.user_data, val); |
860 | 287 | } | 287 | } |
861 | 288 | } | 288 | } |
862 | 289 | } | 289 | } |
863 | 290 | 290 | ||
864 | 291 | public void remove (TreeIter iter) { | 291 | public void remove (TreeIter iter) { |
865 | 292 | if (iter.stamp != this.stamp) | 292 | if (iter.stamp != this.stamp) |
866 | 293 | return; | 293 | return; |
867 | 294 | 294 | ||
868 | 295 | var path = new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); | 295 | var path = new TreePath.from_string ( ( (SequenceIter)iter.user_data).get_position ().to_string ()); |
869 | 296 | rows.remove ( (SequenceIter<string>)iter.user_data); | 296 | Sequence<string>.remove ( (SequenceIter<string>)iter.user_data); |
870 | 297 | row_deleted (path); | 297 | row_deleted (path); |
871 | 298 | } | 298 | } |
872 | 299 | 299 | ||
873 | 300 | /** Fills in sort_column_id and order with the current sort column and the order. **/ | 300 | /** Fills in sort_column_id and order with the current sort column and the order. **/ |
874 | 301 | public bool get_sort_column_id (out int sort_column_id, out SortType order) { | 301 | public bool get_sort_column_id (out int sort_column_id, out SortType order) { |
875 | 302 | sort_column_id = this.sort_column_id; | 302 | sort_column_id = this.sort_column_id; |
876 | 303 | order = sort_direction; | 303 | order = sort_direction; |
877 | 304 | 304 | ||
878 | 305 | return true; | 305 | return true; |
879 | 306 | } | 306 | } |
880 | 307 | 307 | ||
881 | 308 | /** Returns true if the model has a default sort function. **/ | 308 | /** Returns true if the model has a default sort function. **/ |
882 | 309 | public bool has_default_sort_func () { | 309 | public bool has_default_sort_func () { |
883 | 310 | return (default_sort_func != null); | 310 | return (default_sort_func != null); |
884 | 311 | } | 311 | } |
885 | 312 | 312 | ||
886 | 313 | /** Sets the default comparison function used when sorting to be sort_func. **/ | 313 | /** Sets the default comparison function used when sorting to be sort_func. **/ |
887 | 314 | public void set_default_sort_func (owned TreeIterCompareFunc sort_func) { | 314 | public void set_default_sort_func (owned TreeIterCompareFunc sort_func) { |
888 | 315 | default_sort_func = sort_func; | 315 | default_sort_func = sort_func; |
889 | 316 | } | 316 | } |
890 | 317 | 317 | ||
891 | 318 | /** Sets the current sort column to be sort_column_id. **/ | 318 | /** Sets the current sort column to be sort_column_id. **/ |
892 | 319 | public void set_sort_column_id (int sort_column_id, SortType order) { | 319 | public void set_sort_column_id (int sort_column_id, SortType order) { |
893 | 320 | bool changed = (this.sort_column_id != sort_column_id || order != sort_direction); | 320 | bool changed = (this.sort_column_id != sort_column_id || order != sort_direction); |
894 | 321 | 321 | ||
895 | 322 | this.sort_column_id = sort_column_id; | 322 | this.sort_column_id = sort_column_id; |
896 | 323 | sort_direction = order; | 323 | sort_direction = order; |
897 | 324 | 324 | ||
898 | 325 | if (changed && sort_column_id >= 0) { | 325 | if (changed && sort_column_id >= 0) { |
899 | 326 | /* do the sort for reals */ | 326 | /* do the sort for reals */ |
900 | 327 | rows.sort_iter (sequenceIterCompareFunc); | 327 | rows.sort_iter (sequenceIterCompareFunc); |
901 | 328 | 328 | ||
902 | 329 | sort_column_changed (); | 329 | sort_column_changed (); |
903 | 330 | } | 330 | } |
904 | 331 | } | 331 | } |
905 | 332 | 332 | ||
906 | 333 | public void set_sort_func (int sort_column_id, owned TreeIterCompareFunc sort_func) { | 333 | public void set_sort_func (int sort_column_id, owned TreeIterCompareFunc sort_func) { |
907 | 334 | 334 | ||
908 | 335 | } | 335 | } |
909 | 336 | 336 | ||
910 | 337 | 337 | ||
911 | 338 | /** Custom function to use built in sort in Sequence to our advantage **/ | 338 | /** Custom function to use built in sort in Sequence to our advantage **/ |
912 | 339 | public int sequenceIterCompareFunc (SequenceIter<string> a, SequenceIter<string> b) { | 339 | public int sequenceIterCompareFunc (SequenceIter<string> a, SequenceIter<string> b) { |
913 | 340 | int rv = 1; | 340 | int rv = 1; |
914 | 341 | 341 | ||
915 | 342 | if (sort_column_id < 0) | 342 | if (sort_column_id < 0) |
916 | 343 | return 0; | 343 | return 0; |
917 | 344 | 344 | ||
918 | 345 | if (sort_column_id == 0) { | 345 | if (sort_column_id == 0) { |
919 | 346 | var first_sequence_iter = (SequenceIter)first_iter.user_data; | 346 | var first_sequence_iter = (SequenceIter)first_iter.user_data; |
920 | 347 | 347 | ||
921 | 348 | // "All" is always the first | 348 | // "All" is always the first |
922 | 349 | if (a == first_sequence_iter) { | 349 | if (a == first_sequence_iter) { |
923 | 350 | rv = -1; | 350 | rv = -1; |
924 | 351 | } | 351 | } |
925 | 352 | else if (b == first_sequence_iter) { | 352 | else if (b == first_sequence_iter) { |
926 | 353 | rv = 1; | 353 | rv = 1; |
927 | 354 | } | 354 | } |
928 | 355 | else { | 355 | else { |
929 | 356 | if (category == BrowserColumn.Category.ARTIST || category == BrowserColumn.Category.ALBUM) | 356 | if (category == BrowserColumn.Category.ARTIST || category == BrowserColumn.Category.ALBUM) |
930 | 357 | rv = String.compare (rows.get (a), rows.get (b)); | 357 | rv = String.compare (Sequence<string>.get (a), Sequence<string>.get (b)); |
931 | 358 | else | 358 | else |
932 | 359 | rv = String.compare (rows.get (a), rows.get (b)); | 359 | rv = String.compare (Sequence<string>.get (a), Sequence<string>.get (b)); |
933 | 360 | } | 360 | } |
934 | 361 | } | 361 | } |
935 | 362 | 362 | ||
936 | 363 | if (sort_direction == SortType.DESCENDING) | 363 | if (sort_direction == SortType.DESCENDING) |
937 | 364 | rv = (rv > 0) ? -1 : 1; | 364 | rv = (rv > 0) ? -1 : 1; |
938 | 365 | 365 | ||
939 | 366 | return rv; | 366 | return rv; |
940 | 367 | } | 367 | } |
941 | 368 | } | 368 | } |
942 | 369 | 369 |
>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.