Merge lp:~xapantu/beat-box/albumview into lp:beat-box

Proposed by xapantu
Status: Rejected
Rejected by: Scott Ringwelski
Proposed branch: lp:~xapantu/beat-box/albumview
Merge into: lp:beat-box
Diff against target: 206 lines (+55/-88)
1 file modified
src/Widgets/FilterView.vala (+55/-88)
To merge this branch: bzr merge lp:~xapantu/beat-box/albumview
Reviewer Review Type Date Requested Status
Scott Ringwelski Pending
Review via email: mp+64301@code.launchpad.net

Description of the change

Add a new album view based on cairo, see http://xapantu.users.sourceforge.net/out-11.ogv

Improvements:
- It uses the gtk theme/fonts/colors
- It will avoid beatbox to depend on WebKit (at least by default, maybe the plugins will need it)

To post a comment you must log in.
lp:~xapantu/beat-box/albumview updated
209. By xapantu

iconview

210. By xapantu

Auto resize icon view

211. By xapantu

Item activated support, all should work now

212. By xapantu

Avoid gtkwarnings

Revision history for this message
xapantu (xapantu) wrote :

I updated a few things, all should work fine now (the resizing and the selection) :)

lp:~xapantu/beat-box/albumview updated
213. By xapantu

Fix search

214. By xapantu

Code cleanup

Unmerged revisions

214. By xapantu

Code cleanup

213. By xapantu

Fix search

212. By xapantu

Avoid gtkwarnings

211. By xapantu

Item activated support, all should work now

210. By xapantu

Auto resize icon view

209. By xapantu

iconview

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/FilterView.vala'
2--- src/Widgets/FilterView.vala 2011-06-08 21:43:10 +0000
3+++ src/Widgets/FilterView.vala 2011-06-11 19:11:29 +0000
4@@ -1,22 +1,58 @@
5 using Gtk;
6 using Gee;
7-using WebKit;
8
9-public class ArtistItem : Widget {
10- Label artistLabel;
11+public class BeatBox.AlbumView : IconView {
12+ Gtk.ListStore listmodel;
13+ public AlbumView()
14+ {
15+ listmodel = new Gtk.ListStore(4, typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
16+ set_model(listmodel);
17+ set_markup_column(1);
18+ set_pixbuf_column(0);
19+ item_width = 150;
20+ }
21+
22+ public void add_album(string album_, string artist_, string image_path)
23+ {
24+ var album = album_.replace("&", "&"); /* to avoid gtk warnings */
25+ var artist = artist_.replace("&", "&");
26+ Gdk.Pixbuf pix = null;
27+ try
28+ {
29+ pix = new Gdk.Pixbuf.from_file_at_scale(image_path, 120, 120, true);
30+ }
31+ catch(Error e)
32+ {
33+ warning("Couldn't load this image: %s\n", image_path);
34+ }
35+ TreeIter iter;
36+ listmodel.append (out iter);
37+ listmodel.set(iter,
38+ 0, pix,
39+ 1, "%s\n<span color='%s'>%s</span>".printf(album,
40+ get_style().text[StateType.INSENSITIVE].to_string(),
41+ artist),
42+ 2, album,
43+ 3, artist);
44+ }
45+
46+ public void clear()
47+ {
48+ listmodel.clear();
49+ }
50 }
51
52 public class BeatBox.FilterView : ScrolledWindow {
53 LibraryManager lm;
54 LibraryWindow lw;
55 LinkedList<int> songs;
56-
57- WebView view;
58+
59 Table table;
60
61 private Collection<int> showingSongs;
62 private string last_search;
63 LinkedList<string> timeout_search;
64+ AlbumView albums;
65
66 string defaultPath;
67
68@@ -42,34 +78,22 @@
69 }
70
71 public void buildUI() {
72- view = new WebView();
73- Viewport v = new Viewport(null, null);
74-
75 set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
76-
77- view.settings.enable_default_context_menu = false;
78-
79- v.set_shadow_type(ShadowType.NONE);
80- v.add(view);
81- add(v);
82+
83+ albums = new AlbumView();
84+ albums.item_activated.connect( (tree_path) => {
85+ TreeIter iter;
86+ albums.get_model().get_iter(out iter, tree_path);
87+ string album_name, album_artist;
88+ albums.get_model().get(iter, 2, out album_name, 3, out album_artist);
89+ itemClicked(album_name, album_artist);
90+ });
91+ add(albums);
92
93 show_all();
94-
95- view.navigation_requested.connect(navigationRequested);
96 lw.searchField.changed.connect(searchFieldChanged);
97 }
98
99- public static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) {
100- var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f);
101- alignment.top_padding = top;
102- alignment.right_padding = right;
103- alignment.bottom_padding = bottom;
104- alignment.left_padding = left;
105-
106- alignment.add(widget);
107- return alignment;
108- }
109-
110 /** Goes through the hashmap and generates html. If artist,album, or genre
111 * is set, makes sure that only items that fit those filters are
112 * shown
113@@ -82,69 +106,25 @@
114 * loading of lists/icon lists */
115 if(showingSongs.size == toShow.size)
116 return;
117-
118- string html = """<!DOCTYPE html> <html lang="en"><head>
119- <style media="screen" type="text/css">
120- body {
121- background: #fff;
122- font-family: "Droid Sans",sans-serif;
123- margin-top: 10px;
124- }
125- #main {
126- width: 100%;
127- margin: 0px auto;
128- }
129- #main ul {
130- padding-bottom: 10px;
131- margin: auto;
132- }
133- #main ul li {
134- float: left;
135- width: 150px;
136- height: 200px;
137- display: inline-block;
138- list-style-type: none;
139- padding-right: 10px;
140- padding-left: 10px;
141- padding-bottom: 5px;
142- overflow: hidden;
143- }
144- #main ul li img {
145- width: 150px;
146- height: 150px;
147- }
148- #main ul li p {
149- clear: both;
150- overflow: hidden;
151- text-align: center;
152- margin-top: 0px;
153- font-size: 12px;
154- margin-bottom: 0px;
155- }
156- </style></head><body><div id="main"><ul>""";
157
158 stdout.printf("sorting songs\n");
159 // first sort the songs so we know they are grouped by artists, then albums
160 toShow.sort((CompareFunc)songCompareFunc);
161+ albums.clear();
162
163 string previousAlbum = "";
164 stdout.printf("creating html with loop\n");
165 // NOTE: things to keep in mind are search, miller column, artist="", album="" cases
166 foreach(Song s in toShow) {
167 if(s.album != previousAlbum) {
168- html += "<li><a href=\"" + s.album + "<seperater>" + s.artist + "\"><img width=\"150\" height=\"150\" src=\"file://" + (GLib.File.new_for_path(s.getAlbumArtPath()).query_exists() ? s.getAlbumArtPath() : defaultPath) + "\" /></a><p>" + ( (s.album == "") ? "Miscellaneous" : s.album) + "</p><p>" + s.artist + "</p></li>";
169+ albums.add_album(s.album, s.artist, (GLib.File.new_for_path(s.getAlbumArtPath()).query_exists() ? s.getAlbumArtPath() : defaultPath));
170+
171 previousAlbum = s.album;
172 }
173 }
174
175- html += "</ul></div></body></html>"; // finish up the last song, finish up html
176-
177- stdout.printf("loading string\n");
178- view.load_string(html, "text/html", "utf8", "file://");
179- needsUpdate = false;
180- stdout.printf("loaded\n");
181-
182 showingSongs = toShow;
183+ show_all();
184 }
185
186 public static int songCompareFunc(Song a, Song b) {
187@@ -154,19 +134,6 @@
188 return (a.artist.down() > b.artist.down()) ? 1 : -1;
189 }
190
191- public virtual NavigationResponse navigationRequested(WebFrame frame, NetworkRequest request) {
192- if(request.uri.contains("<seperater>")) {
193- // switch the view
194- string[] splitUp = request.uri.split("<seperater>", 0);
195-
196- itemClicked(splitUp[0], splitUp[1]);
197-
198- return WebKit.NavigationResponse.IGNORE;
199- }
200-
201- return WebKit.NavigationResponse.ACCEPT;
202- }
203-
204 public virtual void searchFieldChanged() {
205 if(isCurrentView && lw.searchField.get_text().length != 1) {
206 timeout_search.offer_head(lw.searchField.get_text().down());

Subscribers

People subscribed via source and target branches