Merge lp:~marcus-lundgren/noise/compilation_warnings_and_clean_up into lp:~elementary-apps/noise/trunk

Proposed by Marcus Lundgren
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
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.

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) wrote :

>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());

success = GPod.iTunesDB.cp_track_to_ipod (added, File.new_for_uri (s.uri).get_path ());

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.

review: Needs Fixing
1501. By Marcus Lundgren

Turn tabs to spaces and fix some legacy code style issues.

Revision history for this message
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.

Revision history for this message
David Gomes (davidgomes) wrote :

Yeah that's exactly what you should do, don't do mixed-actions per commit.

Revision history for this message
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.

review: Approve
Revision history for this message
Julián Unrrein (junrrein) wrote :

I test-compiled this branch on elementary Luna, with no problems.

Here is the configuration and compilation logs -> http://pastebin.com/QxxskuEb.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'core/GStreamer/Pipeline.vala'
--- core/GStreamer/Pipeline.vala 2013-02-26 21:56:08 +0000
+++ core/GStreamer/Pipeline.vala 2013-07-26 20:46:25 +0000
@@ -29,91 +29,73 @@
29 */29 */
3030
31public class Noise.Pipeline : GLib.Object {31public class Noise.Pipeline : GLib.Object {
32 public Gst.Pipeline pipe;32 public Gst.Pipeline pipe;
33 public Equalizer eq;33 public Equalizer eq;
34 34
35 public dynamic Gst.Bus bus;35 public dynamic Gst.Bus bus;
36 //Pad teepad;36 public Gst.Pad pad;
37 public Gst.Pad pad;37
38 38 public dynamic Gst.Element audiosink;
39 public dynamic Gst.Element audiosink;39 public dynamic Gst.Element audiosinkqueue;
40 public dynamic Gst.Element audiosinkqueue;40 public dynamic Gst.Element eq_audioconvert;
41 public dynamic Gst.Element eq_audioconvert;41 public dynamic Gst.Element eq_audioconvert2;
42 public dynamic Gst.Element eq_audioconvert2; 42
43 43 public dynamic Gst.Element playbin;
44 public dynamic Gst.Element playbin;44 public dynamic Gst.Element audiotee;
45 public dynamic Gst.Element audiotee;45 public dynamic Gst.Element audiobin;
46 public dynamic Gst.Element audiobin;46 public dynamic Gst.Element preamp;
47 public dynamic Gst.Element preamp;47
48 //dynamic Gst.Element volume;48 public Pipeline() {
49 //dynamic Gst.Element rgvolume;49
50 50 pipe = new Gst.Pipeline("pipeline");
51 public Pipeline() {51 playbin = Gst.ElementFactory.make("playbin2", "play");
52 52
53 pipe = new Gst.Pipeline("pipeline");53 audiosink = Gst.ElementFactory.make("autoaudiosink", "audio-sink");
54 playbin = Gst.ElementFactory.make("playbin2", "play");54
55 55 audiobin = new Gst.Bin("audiobin"); // this holds the real primary sink
56 audiosink = Gst.ElementFactory.make("autoaudiosink", "audio-sink");56
57 //audiosink.set("profile", 1); // says we handle music and movies57 audiotee = Gst.ElementFactory.make("tee", null);
58 58 audiosinkqueue = Gst.ElementFactory.make("queue", null);
59 audiobin = new Gst.Bin("audiobin"); // this holds the real primary sink59
60 60 eq = new Equalizer();
61 audiotee = Gst.ElementFactory.make("tee", null);61 if(eq.element != null) {
62 audiosinkqueue = Gst.ElementFactory.make("queue", null);62 eq_audioconvert = Gst.ElementFactory.make("audioconvert", null);
63 63 eq_audioconvert2 = Gst.ElementFactory.make("audioconvert", null);
64 eq = new Equalizer();64 preamp = Gst.ElementFactory.make("volume", "preamp");
65 if(eq.element != null) {65
66 eq_audioconvert = Gst.ElementFactory.make("audioconvert", null);66 ((Gst.Bin)audiobin).add_many(eq.element, eq_audioconvert, eq_audioconvert2, preamp);
67 eq_audioconvert2 = Gst.ElementFactory.make("audioconvert", null);67 }
68 preamp = Gst.ElementFactory.make("volume", "preamp");68
69 69 ((Gst.Bin)audiobin).add_many(audiotee, audiosinkqueue, audiosink);
70 ((Gst.Bin)audiobin).add_many(eq.element, eq_audioconvert, eq_audioconvert2, preamp);70
71 }71 audiobin.add_pad(new Gst.GhostPad("sink", audiotee.get_pad("sink")));
72 72
73 ((Gst.Bin)audiobin).add_many(audiotee, audiosinkqueue, audiosink);73 if (eq.element != null)
74 74 audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink);
75 audiobin.add_pad(new Gst.GhostPad("sink", audiotee.get_pad("sink")));75 else
76 76 audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink
77 if (eq.element != null)77
78 audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink);78 playbin.set("audio-sink", audiobin);
79 else79 bus = playbin.get_bus();
80 audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink80
81 81 // Link the first tee pad to the primary audio sink queue
82 playbin.set("audio-sink", audiobin); 82 Gst.Pad sinkpad = audiosinkqueue.get_pad("sink");
83 bus = playbin.get_bus();83 pad = audiotee.get_request_pad("src%d");
84 84 audiotee.set("alloc-pad", pad);
85 // Link the first tee pad to the primary audio sink queue85 pad.link(sinkpad);
86 Gst.Pad sinkpad = audiosinkqueue.get_pad("sink");86 }
87 pad = audiotee.get_request_pad("src%d");87
88 audiotee.set("alloc-pad", pad);88 public void enableEqualizer() {
89 pad.link(sinkpad);89 if (eq.element != null) {
90 90 audiosinkqueue.unlink_many(audiosink); // link the queue with the real audio sink
91 //bus.add_watch(busCallback);91 audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink);
92 /*play.audio_tags_changed.connect(audioTagsChanged);92 }
93 play.text_tags_changed.connect(textTagsChanged);*/93 }
94 }94
9595 public void disableEqualizer() {
96/*96 if (eq.element != null) {
97 private void audioTagsChanged(Gst.Element sender, int stream_number) {97 audiosinkqueue.unlink_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink);
98 98 audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink
99 }99 }
100100 }
101 /*private void textTagsChanged(Gst.Element sender, int stream_number) {
102
103 }
104*/
105
106 public void enableEqualizer() {
107 if (eq.element != null) {
108 audiosinkqueue.unlink_many(audiosink); // link the queue with the real audio sink
109 audiosinkqueue.link_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink);
110 }
111 }
112
113 public void disableEqualizer() {
114 if (eq.element != null) {
115 audiosinkqueue.unlink_many(eq_audioconvert, preamp, eq.element, eq_audioconvert2, audiosink);
116 audiosinkqueue.link_many(audiosink); // link the queue with the real audio sink
117 }
118 }
119}101}
120102
=== modified file 'plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala'
--- plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala 2013-06-02 17:35:04 +0000
+++ plugins/Devices/AudioPlayers/AudioPlayerLibrary.vala 2013-07-26 20:46:25 +0000
@@ -55,13 +55,13 @@
55 55
56 tagger = new GStreamerTagger();56 tagger = new GStreamerTagger();
57 57
58 tagger.media_imported.connect(media_imported);58 tagger.media_imported.connect (media_imported_from_tagger);
59 tagger.import_error.connect(import_error);59 tagger.import_error.connect (import_error);
60 tagger.queue_finished.connect(queue_finished);60 tagger.queue_finished.connect (queue_finished);
61 notification_manager.progress_canceled.connect( () => {operation_cancelled = true;});61 notification_manager.progress_canceled.connect( () => {operation_cancelled = true;});
62 }62 }
63 63
64 void media_imported (Media m) {64 void media_imported_from_tagger (Media m) {
65 m.isTemporary = true;65 m.isTemporary = true;
66 this.medias.add(m);66 this.medias.add(m);
67 m.rowid = medias_rowid;67 m.rowid = medias_rowid;
@@ -80,7 +80,6 @@
80 is_initialized = true;80 is_initialized = true;
81 device.initialized (device);81 device.initialized (device);
82 search_medias ("");82 search_medias ("");
83 //load_playlists ();
84 }83 }
85 }84 }
86 85
@@ -88,26 +87,6 @@
88 87
89 }88 }
90 89
91 private void load_playlists () {
92 var imported_pl = new Gee.LinkedList<string> ();
93 FileUtils.count_playlists_files (GLib.File.new_for_uri (device.get_music_folder () + "/Playlists/"), ref imported_pl);
94 var playlists = new Gee.HashMap<string, Gee.LinkedList<string>> ();
95 foreach (var file in imported_pl) {
96 if(file != "") {
97 var f = GLib.File.new_for_uri (file);
98 var infos = f.query_info (GLib.FileAttribute.STANDARD_DISPLAY_NAME, FileQueryInfoFlags.NONE);
99 var name = infos.get_display_name ();
100 var paths = new Gee.LinkedList<string> ();
101 if (file.has_suffix(".m3u")) {
102 name = name.replace (".m3u", "");
103 PlaylistsUtils.parse_paths_from_m3u(file, ref paths);
104 }
105 playlists.set (name, paths);
106 }
107 }
108 PlaylistsUtils.import_from_playlist_file_info(playlists, this);
109 }
110
111 public override void add_files_to_library (Gee.Collection<string> files) {90 public override void add_files_to_library (Gee.Collection<string> files) {
112 91
113 }92 }
11493
=== modified file 'plugins/Devices/iPod/iPodLibrary.vala'
--- plugins/Devices/iPod/iPodLibrary.vala 2013-06-02 17:35:04 +0000
+++ plugins/Devices/iPod/iPodLibrary.vala 2013-07-26 20:46:25 +0000
@@ -40,7 +40,6 @@
40 Device device;40 Device device;
41 bool operation_cancelled = false;41 bool operation_cancelled = false;
42 bool is_doing_file_operations = false;42 bool is_doing_file_operations = false;
43 bool queue_is_finished = false;
44 43
45 public iPodLibrary (GPod.iTunesDB db, Device device) {44 public iPodLibrary (GPod.iTunesDB db, Device device) {
46 this.db = db;45 this.db = db;
@@ -202,7 +201,7 @@
202 201
203 bool success = false;202 bool success = false;
204 try {203 try {
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 ());
206 debug ("Copied media %s to ipod\n", added.title);205 debug ("Copied media %s to ipod\n", added.title);
207 } catch(Error err) {206 } catch(Error err) {
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);
209208
=== modified file 'src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala'
--- src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala 2013-06-25 18:24:42 +0000
+++ src/Views/ListView/ColumnBrowser/BrowserColumnModel.vala 2013-07-26 20:46:25 +0000
@@ -20,350 +20,350 @@
20using Gtk;20using Gtk;
2121
22public class Noise.BrowserColumnModel : Object, TreeModel, TreeSortable {22public class Noise.BrowserColumnModel : Object, TreeModel, TreeSortable {
23 /* all iters must match this */23 /* all iters must match this */
24 private int stamp = (int)Random.next_int ();24 private int stamp = (int)Random.next_int ();
2525
26 public int n_items { get { return rows.get_length () - 1; } } // Doesn't count the first ("All..") item26 public int n_items { get { return rows.get_length () - 1; } } // Doesn't count the first ("All..") item
2727
28 /* data storage variables */28 /* data storage variables */
29 private Sequence<string> rows;29 private Sequence<string> rows;
3030
31 /* first iter. This helps us to track the "All" row */31 /* first iter. This helps us to track the "All" row */
32 TreeIter? first_iter;32 TreeIter? first_iter;
3333
34 /* treesortable stuff */34 /* treesortable stuff */
35 private int sort_column_id;35 private int sort_column_id;
36 private SortType sort_direction;36 private SortType sort_direction;
37 private unowned TreeIterCompareFunc default_sort_func;37 private unowned TreeIterCompareFunc default_sort_func;
3838
39 private BrowserColumn.Category category;39 private BrowserColumn.Category category;
4040
41 /** Initialize data storage, columns, etc. **/41 /** Initialize data storage, columns, etc. **/
42 public BrowserColumnModel (BrowserColumn.Category category) {42 public BrowserColumnModel (BrowserColumn.Category category) {
43 rows = new Sequence<string> ();43 rows = new Sequence<string> ();
4444
45 this.category = category;45 this.category = category;
4646
47 sort_column_id = -2;47 sort_column_id = -2;
48 sort_direction = SortType.ASCENDING;48 sort_direction = SortType.ASCENDING;
49 }49 }
5050
51 /** Returns a set of flags supported by this interface **/51 /** Returns a set of flags supported by this interface **/
52 public TreeModelFlags get_flags () {52 public TreeModelFlags get_flags () {
53 return TreeModelFlags.LIST_ONLY;53 return TreeModelFlags.LIST_ONLY;
54 }54 }
5555
56 /** Sets iter to a valid iterator pointing to path **/56 /** Sets iter to a valid iterator pointing to path **/
57 public bool get_iter (out TreeIter iter, TreePath path) {57 public bool get_iter (out TreeIter iter, TreePath path) {
58 iter = TreeIter ();58 iter = TreeIter ();
59 int path_index = path.get_indices ()[0];59 int path_index = path.get_indices ()[0];
6060
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 ())
62 return false;62 return false;
6363
64 var seq_iter = rows.get_iter_at_pos (path_index);64 var seq_iter = rows.get_iter_at_pos (path_index);
65 if (seq_iter == null)65 if (seq_iter == null)
66 return false;66 return false;
6767
68 iter.stamp = this.stamp;68 iter.stamp = this.stamp;
69 iter.user_data = seq_iter;69 iter.user_data = seq_iter;
7070
71 return true;71 return true;
72 }72 }
7373
74 /** Returns the number of columns supported by tree_model. **/74 /** Returns the number of columns supported by tree_model. **/
75 public int get_n_columns () {75 public int get_n_columns () {
76 return 1;76 return 1;
77 }77 }
7878
79 public Type get_column_type (int col) {79 public Type get_column_type (int col) {
80 return typeof (string);80 return typeof (string);
81 }81 }
8282
83 /** Returns a newly-created Gtk.TreePath referenced by iter. **/83 /** Returns a newly-created Gtk.TreePath referenced by iter. **/
84 public TreePath? get_path (TreeIter iter) {84 public TreePath? get_path (TreeIter iter) {
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 ());
86 }86 }
8787
88 /** Initializes and sets value to that at column. **/88 /** Initializes and sets value to that at column. **/
89 public void get_value (TreeIter iter, int column, out Value val) {89 public void get_value (TreeIter iter, int column, out Value val) {
90 val = Value (typeof (string));90 val = Value (typeof (string));
91 if (iter.stamp != this.stamp || column < 0 || column >= 1)91 if (iter.stamp != this.stamp || column < 0 || column >= 1)
92 return;92 return;
9393
94 if (! ( (SequenceIter<string>) iter.user_data).is_end ())94 if (! ( (SequenceIter<string>) iter.user_data).is_end ())
95 val = rows.get ( ( (SequenceIter<string>) iter.user_data));95 val = Sequence<string>.get (((SequenceIter<string>) iter.user_data));
96 }96 }
9797
98 /** Sets iter to point to the first child of parent. **/98 /** Sets iter to point to the first child of parent. **/
99 public bool iter_children (out TreeIter iter, TreeIter? parent) {99 public bool iter_children (out TreeIter iter, TreeIter? parent) {
100 iter = TreeIter ();100 iter = TreeIter ();
101101
102 return false;102 return false;
103 }103 }
104104
105 /** Returns true if iter has children, false otherwise. **/105 /** Returns true if iter has children, false otherwise. **/
106 public bool iter_has_child (TreeIter iter) {106 public bool iter_has_child (TreeIter iter) {
107107
108 return false;108 return false;
109 }109 }
110110
111 /** Returns the number of children that iter has. **/111 /** Returns the number of children that iter has. **/
112 public int iter_n_children (TreeIter? iter) {112 public int iter_n_children (TreeIter? iter) {
113 if (iter == null)113 if (iter == null)
114 return rows.get_length ();114 return rows.get_length ();
115115
116 return 0;116 return 0;
117 }117 }
118118
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. **/
120 public bool iter_next (ref TreeIter iter) {120 public bool iter_next (ref TreeIter iter) {
121 if (iter.stamp != this.stamp)121 if (iter.stamp != this.stamp)
122 return false;122 return false;
123123
124 iter.user_data = ( (SequenceIter)iter.user_data).next ();124 iter.user_data = ( (SequenceIter)iter.user_data).next ();
125125
126 if ( ( (SequenceIter)iter.user_data).is_end ())126 if ( ( (SequenceIter)iter.user_data).is_end ())
127 return false;127 return false;
128128
129 return true;129 return true;
130 }130 }
131131
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. **/
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) {
134 iter = TreeIter ();134 iter = TreeIter ();
135 if (n < 0 || n >= rows.get_length () || parent != null)135 if (n < 0 || n >= rows.get_length () || parent != null)
136 return false;136 return false;
137137
138 iter.stamp = this.stamp;138 iter.stamp = this.stamp;
139 iter.user_data = rows.get_iter_at_pos (n);139 iter.user_data = rows.get_iter_at_pos (n);
140140
141 return true;141 return true;
142 }142 }
143143
144 /** Sets iter to be the parent of child. **/144 /** Sets iter to be the parent of child. **/
145 public bool iter_parent (out TreeIter iter, TreeIter child) {145 public bool iter_parent (out TreeIter iter, TreeIter child) {
146 iter = TreeIter ();146 iter = TreeIter ();
147147
148 return false;148 return false;
149 }149 }
150150
151 /** Lets the tree ref the node. **/151 /** Lets the tree ref the node. **/
152 public void ref_node (TreeIter iter) {}152 public void ref_node (TreeIter iter) {}
153153
154 /** Lets the tree unref the node. **/154 /** Lets the tree unref the node. **/
155 public void unref_node (TreeIter iter) {}155 public void unref_node (TreeIter iter) {}
156156
157 /** simply adds iter to the model **/157 /** simply adds iter to the model **/
158 public void append (out TreeIter iter) {158 public void append (out TreeIter iter) {
159 iter = TreeIter ();159 iter = TreeIter ();
160 SequenceIter<string> added = rows.append ("");160 SequenceIter<string> added = rows.append ("");
161 iter.stamp = this.stamp;161 iter.stamp = this.stamp;
162 iter.user_data = added;162 iter.user_data = added;
163 }163 }
164164
165 /** convenience method to insert strings into the model. No iters returned. **/165 /** convenience method to insert strings into the model. No iters returned. **/
166 public void append_items (Gee.Collection<string> strings, bool emit) {166 public void append_items (Gee.Collection<string> strings, bool emit) {
167 if (first_iter == null)167 if (first_iter == null)
168 add_first_element ();168 add_first_element ();
169169
170 foreach (string s in strings) {170 foreach (string s in strings) {
171 SequenceIter<string> added = rows.append (s);171 SequenceIter<string> added = rows.append (s);
172172
173 if (emit) {173 if (emit) {
174 var path = new TreePath.from_string (added.get_position ().to_string ());174 var path = new TreePath.from_string (added.get_position ().to_string ());
175 var iter = TreeIter ();175 var iter = TreeIter ();
176176
177 iter.stamp = this.stamp;177 iter.stamp = this.stamp;
178 iter.user_data = added;178 iter.user_data = added;
179179
180 row_inserted (path, iter);180 row_inserted (path, iter);
181 }181 }
182 }182 }
183183
184 update_first_item ();184 update_first_item ();
185 }185 }
186186
187 /* Add the "All" item */187 /* Add the "All" item */
188 private void add_first_element () {188 private void add_first_element () {
189 SequenceIter<string> added = rows.append ("All");189 SequenceIter<string> added = rows.append ("All");
190190
191 first_iter = TreeIter ();191 first_iter = TreeIter ();
192192
193 first_iter.stamp = this.stamp;193 first_iter.stamp = this.stamp;
194 first_iter.user_data = added;194 first_iter.user_data = added;
195 }195 }
196196
197 /* Updates the "All" item */197 /* Updates the "All" item */
198 private void update_first_item () {198 private void update_first_item () {
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));
200 }200 }
201201
202202
203 // The text to use for the first item.203 // The text to use for the first item.
204 private string get_first_item_text (int n_items) {204 private string get_first_item_text (int n_items) {
205 string rv = "";205 string rv = "";
206206
207 switch (category) {207 switch (category) {
208 case BrowserColumn.Category.GENRE:208 case BrowserColumn.Category.GENRE:
209 if (n_items == 1)209 if (n_items == 1)
210 rv = _ ("All Genres");210 rv = _ ("All Genres");
211 else if (n_items > 1)211 else if (n_items > 1)
212 rv = _ ("All %i Genres").printf (n_items);212 rv = _ ("All %i Genres").printf (n_items);
213 else213 else
214 rv = _ ("No Genres");214 rv = _ ("No Genres");
215 break;215 break;
216216
217 case BrowserColumn.Category.ARTIST:217 case BrowserColumn.Category.ARTIST:
218 if (n_items == 1)218 if (n_items == 1)
219 rv = _ ("All Artists");219 rv = _ ("All Artists");
220 else if (n_items > 1)220 else if (n_items > 1)
221 rv = _ ("All %i Artists").printf (n_items);221 rv = _ ("All %i Artists").printf (n_items);
222 else222 else
223 rv = _ ("No Artists");223 rv = _ ("No Artists");
224 break;224 break;
225225
226 case BrowserColumn.Category.ALBUM:226 case BrowserColumn.Category.ALBUM:
227 if (n_items == 1)227 if (n_items == 1)
228 rv = _ ("All Albums");228 rv = _ ("All Albums");
229 else if (n_items > 1)229 else if (n_items > 1)
230 rv = _ ("All %i Albums").printf (n_items);230 rv = _ ("All %i Albums").printf (n_items);
231 else231 else
232 rv = _ ("No Albums");232 rv = _ ("No Albums");
233 break;233 break;
234234
235 case BrowserColumn.Category.YEAR:235 case BrowserColumn.Category.YEAR:
236 if (n_items == 1)236 if (n_items == 1)
237 rv = _ ("All Years");237 rv = _ ("All Years");
238 else if (n_items > 1)238 else if (n_items > 1)
239 rv = _ ("All %i Years").printf (n_items);239 rv = _ ("All %i Years").printf (n_items);
240 else240 else
241 rv = _ ("No Years");241 rv = _ ("No Years");
242 break;242 break;
243243
244 case BrowserColumn.Category.RATING:244 case BrowserColumn.Category.RATING:
245 if (n_items >= 1)245 if (n_items >= 1)
246 rv = _ ("All Ratings");246 rv = _ ("All Ratings");
247 else247 else
248 rv = _ ("No Ratings");248 rv = _ ("No Ratings");
249 break;249 break;
250250
251 case BrowserColumn.Category.GROUPING:251 case BrowserColumn.Category.GROUPING:
252 if (n_items == 1)252 if (n_items == 1)
253 rv = _ ("All Groupings");253 rv = _ ("All Groupings");
254 else if (n_items > 1)254 else if (n_items > 1)
255 rv = _ ("All %i Groupings").printf (n_items);255 rv = _ ("All %i Groupings").printf (n_items);
256 else256 else
257 rv = _ ("No Groupings");257 rv = _ ("No Groupings");
258 break;258 break;
259259
260 case BrowserColumn.Category.COMPOSER:260 case BrowserColumn.Category.COMPOSER:
261 if (n_items == 1)261 if (n_items == 1)
262 rv = _ ("All Composers");262 rv = _ ("All Composers");
263 else if (n_items > 1)263 else if (n_items > 1)
264 rv = _ ("All %i Composers").printf (n_items);264 rv = _ ("All %i Composers").printf (n_items);
265 else265 else
266 rv = _ ("No Composers");266 rv = _ ("No Composers");
267 break;267 break;
268 }268 }
269269
270 return rv;270 return rv;
271 }271 }
272272
273273
274 public new void set (TreeIter iter, ...) {274 public new void set (TreeIter iter, ...) {
275 if (iter.stamp != this.stamp)275 if (iter.stamp != this.stamp)
276 return;276 return;
277277
278 var args = va_list (); // now call args.arg () to poll278 var args = va_list (); // now call args.arg () to poll
279279
280 while (true) {280 while (true) {
281 int col = args.arg ();281 int col = args.arg ();
282 if (col < 0 || col >= 1)282 if (col < 0 || col >= 1)
283 return;283 return;
284 else if (col == 0) {284 else if (col == 0) {
285 string val = args.arg ();285 string val = args.arg ();
286 rows.set ( (SequenceIter<string>)iter.user_data, val);286 Sequence<string>.set ( (SequenceIter<string>)iter.user_data, val);
287 }287 }
288 }288 }
289 }289 }
290290
291 public void remove (TreeIter iter) {291 public void remove (TreeIter iter) {
292 if (iter.stamp != this.stamp)292 if (iter.stamp != this.stamp)
293 return;293 return;
294294
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 ());
296 rows.remove ( (SequenceIter<string>)iter.user_data);296 Sequence<string>.remove ( (SequenceIter<string>)iter.user_data);
297 row_deleted (path);297 row_deleted (path);
298 }298 }
299299
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. **/
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) {
302 sort_column_id = this.sort_column_id;302 sort_column_id = this.sort_column_id;
303 order = sort_direction;303 order = sort_direction;
304304
305 return true;305 return true;
306 }306 }
307307
308 /** Returns true if the model has a default sort function. **/308 /** Returns true if the model has a default sort function. **/
309 public bool has_default_sort_func () {309 public bool has_default_sort_func () {
310 return (default_sort_func != null);310 return (default_sort_func != null);
311 }311 }
312312
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. **/
314 public void set_default_sort_func (owned TreeIterCompareFunc sort_func) {314 public void set_default_sort_func (owned TreeIterCompareFunc sort_func) {
315 default_sort_func = sort_func;315 default_sort_func = sort_func;
316 }316 }
317317
318 /** Sets the current sort column to be sort_column_id. **/318 /** Sets the current sort column to be sort_column_id. **/
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) {
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);
321321
322 this.sort_column_id = sort_column_id;322 this.sort_column_id = sort_column_id;
323 sort_direction = order;323 sort_direction = order;
324324
325 if (changed && sort_column_id >= 0) {325 if (changed && sort_column_id >= 0) {
326 /* do the sort for reals */326 /* do the sort for reals */
327 rows.sort_iter (sequenceIterCompareFunc);327 rows.sort_iter (sequenceIterCompareFunc);
328328
329 sort_column_changed ();329 sort_column_changed ();
330 }330 }
331 }331 }
332332
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) {
334334
335 }335 }
336336
337337
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 **/
339 public int sequenceIterCompareFunc (SequenceIter<string> a, SequenceIter<string> b) {339 public int sequenceIterCompareFunc (SequenceIter<string> a, SequenceIter<string> b) {
340 int rv = 1;340 int rv = 1;
341341
342 if (sort_column_id < 0)342 if (sort_column_id < 0)
343 return 0;343 return 0;
344344
345 if (sort_column_id == 0) {345 if (sort_column_id == 0) {
346 var first_sequence_iter = (SequenceIter)first_iter.user_data;346 var first_sequence_iter = (SequenceIter)first_iter.user_data;
347347
348 // "All" is always the first348 // "All" is always the first
349 if (a == first_sequence_iter) {349 if (a == first_sequence_iter) {
350 rv = -1;350 rv = -1;
351 }351 }
352 else if (b == first_sequence_iter) {352 else if (b == first_sequence_iter) {
353 rv = 1;353 rv = 1;
354 }354 }
355 else {355 else {
356 if (category == BrowserColumn.Category.ARTIST || category == BrowserColumn.Category.ALBUM)356 if (category == BrowserColumn.Category.ARTIST || category == BrowserColumn.Category.ALBUM)
357 rv = String.compare (rows.get (a), rows.get (b));357 rv = String.compare (Sequence<string>.get (a), Sequence<string>.get (b));
358 else358 else
359 rv = String.compare (rows.get (a), rows.get (b));359 rv = String.compare (Sequence<string>.get (a), Sequence<string>.get (b));
360 }360 }
361 }361 }
362362
363 if (sort_direction == SortType.DESCENDING)363 if (sort_direction == SortType.DESCENDING)
364 rv = (rv > 0) ? -1 : 1;364 rv = (rv > 0) ? -1 : 1;
365365
366 return rv;366 return rv;
367 }367 }
368}368}
369369

Subscribers

People subscribed via source and target branches