Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder | |
ebcfbfef | 3 | * Copyright (C) 2008 Richard Kettlewell |
460b9539 | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
18 | * USA | |
19 | */ | |
b9bdafc7 RK |
20 | /** @file disobedience/choose.c |
21 | * @brief Hierarchical track selection and search | |
22 | * | |
ebcfbfef RK |
23 | * We now use an ordinary GtkTreeStore/GtkTreeView. |
24 | * | |
ebcfbfef RK |
25 | * We don't want to pull the entire tree in memory, but we want directories to |
26 | * show up as having children. Therefore we give directories a placeholder | |
a98fd571 RK |
27 | * child and replace their children when they are opened. Placeholders have |
28 | * TRACK_COLUMN="" and ISFILE_COLUMN=FALSE (so that they don't get check boxes, | |
29 | * lengths, etc). | |
ebcfbfef RK |
30 | * |
31 | * TODO We do a period sweep which kills contracted nodes, putting back | |
32 | * placeholders, and updating expanded nodes to keep up with server-side | |
33 | * changes. (We could trigger the latter off rescan complete notifications?) | |
34 | * | |
35 | * TODO: | |
36 | * - sweep up contracted nodes | |
37 | * - update when content may have changed (e.g. after a rescan) | |
b9bdafc7 | 38 | */ |
460b9539 | 39 | |
40 | #include "disobedience.h" | |
6982880f | 41 | #include "choose.h" |
16e145a5 | 42 | |
ebcfbfef | 43 | /** @brief The current selection tree */ |
6982880f | 44 | GtkTreeStore *choose_store; |
16e145a5 | 45 | |
ebcfbfef | 46 | /** @brief The view onto the selection tree */ |
6982880f | 47 | GtkWidget *choose_view; |
16e145a5 | 48 | |
ebcfbfef | 49 | /** @brief The selection tree's selection */ |
6982880f | 50 | GtkTreeSelection *choose_selection; |
460b9539 | 51 | |
2a9a65e4 RK |
52 | /** @brief Count of file listing operations in flight */ |
53 | static int choose_list_in_flight; | |
54 | ||
55 | /** @brief Count of files inserted in current batch of listing operations */ | |
56 | static int choose_inserted; | |
57 | ||
a98fd571 RK |
58 | static char *choose_get_string(GtkTreeIter *iter, int column) { |
59 | gchar *gs; | |
60 | gtk_tree_model_get(GTK_TREE_MODEL(choose_store), iter, | |
61 | column, &gs, | |
62 | -1); | |
63 | char *s = xstrdup(gs); | |
64 | g_free(gs); | |
65 | return s; | |
6a06a735 RK |
66 | } |
67 | ||
a98fd571 RK |
68 | char *choose_get_track(GtkTreeIter *iter) { |
69 | char *s = choose_get_string(iter, TRACK_COLUMN); | |
70 | return *s ? s : 0; /* Placeholder -> NULL */ | |
71 | } | |
72 | ||
73 | char *choose_get_sort(GtkTreeIter *iter) { | |
74 | return choose_get_string(iter, SORT_COLUMN); | |
75 | } | |
76 | ||
659201af RK |
77 | char *choose_get_display(GtkTreeIter *iter) { |
78 | return choose_get_string(iter, NAME_COLUMN); | |
79 | } | |
80 | ||
a98fd571 RK |
81 | int choose_is_file(GtkTreeIter *iter) { |
82 | gboolean isfile; | |
83 | gtk_tree_model_get(GTK_TREE_MODEL(choose_store), iter, | |
84 | ISFILE_COLUMN, &isfile, | |
85 | -1); | |
86 | return isfile; | |
87 | } | |
88 | ||
89 | int choose_is_dir(GtkTreeIter *iter) { | |
90 | gboolean isfile; | |
91 | gtk_tree_model_get(GTK_TREE_MODEL(choose_store), iter, | |
92 | ISFILE_COLUMN, &isfile, | |
93 | -1); | |
94 | if(isfile) | |
95 | return FALSE; | |
96 | return !choose_is_placeholder(iter); | |
97 | } | |
98 | ||
99 | int choose_is_placeholder(GtkTreeIter *iter) { | |
100 | return choose_get_string(iter, TRACK_COLUMN)[0] == 0; | |
e8a26cdd RK |
101 | } |
102 | ||
ebcfbfef RK |
103 | /** @brief Remove node @p it and all its children |
104 | * @param Iterator, updated to point to next | |
105 | * @return True if iterator remains valid | |
659201af RK |
106 | * |
107 | * TODO is this necessary? gtk_tree_store_remove() does not document what | |
108 | * happens to children. | |
16e145a5 | 109 | */ |
ebcfbfef RK |
110 | static gboolean choose_remove_node(GtkTreeIter *it) { |
111 | GtkTreeIter child[1]; | |
112 | gboolean childv = gtk_tree_model_iter_children(GTK_TREE_MODEL(choose_store), | |
113 | child, | |
114 | it); | |
115 | while(childv) | |
116 | childv = choose_remove_node(child); | |
ebcfbfef RK |
117 | return gtk_tree_store_remove(choose_store, it); |
118 | } | |
119 | ||
ad47bd4c RK |
120 | /** @brief Update length and state fields */ |
121 | static gboolean choose_set_state_callback(GtkTreeModel attribute((unused)) *model, | |
122 | GtkTreePath attribute((unused)) *path, | |
123 | GtkTreeIter *it, | |
124 | gpointer attribute((unused)) data) { | |
a98fd571 RK |
125 | if(choose_is_file(it)) { |
126 | const char *track = choose_get_track(it); | |
127 | const long l = namepart_length(track); | |
ad47bd4c RK |
128 | char length[64]; |
129 | if(l > 0) | |
130 | byte_snprintf(length, sizeof length, "%ld:%02ld", l / 60, l % 60); | |
131 | else | |
132 | length[0] = 0; | |
133 | gtk_tree_store_set(choose_store, it, | |
134 | LENGTH_COLUMN, length, | |
a98fd571 | 135 | STATE_COLUMN, queued(track), |
ad47bd4c | 136 | -1); |
cfa78eaa RK |
137 | if(choose_is_search_result(track)) |
138 | gtk_tree_store_set(choose_store, it, | |
b96f65cf RK |
139 | BG_COLUMN, SEARCH_RESULT_BG, |
140 | FG_COLUMN, SEARCH_RESULT_FG, | |
cfa78eaa RK |
141 | -1); |
142 | else | |
143 | gtk_tree_store_set(choose_store, it, | |
144 | BG_COLUMN, (char *)0, | |
145 | FG_COLUMN, (char *)0, | |
146 | -1); | |
ad47bd4c RK |
147 | } |
148 | return FALSE; /* continue walking */ | |
149 | } | |
150 | ||
151 | /** @brief Called when the queue or playing track change */ | |
152 | static void choose_set_state(const char attribute((unused)) *event, | |
153 | void attribute((unused)) *eventdata, | |
154 | void attribute((unused)) *callbackdata) { | |
155 | gtk_tree_model_foreach(GTK_TREE_MODEL(choose_store), | |
156 | choose_set_state_callback, | |
157 | NULL); | |
158 | } | |
159 | ||
ebcfbfef RK |
160 | /** @brief (Re-)populate a node |
161 | * @param parent_ref Node to populate or NULL to fill root | |
162 | * @param nvec Number of children to add | |
163 | * @param vec Children | |
a98fd571 | 164 | * @param files 1 if children are files, 0 if directories |
b9bdafc7 | 165 | * |
ebcfbfef RK |
166 | * Adjusts the set of files (or directories) below @p parent_ref to match those |
167 | * listed in @p nvec and @p vec. | |
fcc8b9f7 | 168 | * |
ebcfbfef | 169 | * @parent_ref will be destroyed. |
fcc8b9f7 | 170 | */ |
ebcfbfef RK |
171 | static void choose_populate(GtkTreeRowReference *parent_ref, |
172 | int nvec, char **vec, | |
a98fd571 | 173 | int isfile) { |
659201af RK |
174 | if(!nvec) |
175 | return; | |
2fadbbc6 | 176 | const char *type = isfile ? "track" : "dir"; |
ebcfbfef RK |
177 | /* Compute parent_* */ |
178 | GtkTreeIter pit[1], *parent_it; | |
179 | GtkTreePath *parent_path; | |
180 | if(parent_ref) { | |
181 | parent_path = gtk_tree_row_reference_get_path(parent_ref); | |
182 | parent_it = pit; | |
183 | gboolean pitv = gtk_tree_model_get_iter(GTK_TREE_MODEL(choose_store), | |
184 | pit, parent_path); | |
185 | assert(pitv); | |
186 | /*fprintf(stderr, "choose_populate %s: parent path is [%s]\n", | |
2fadbbc6 | 187 | type, |
ebcfbfef | 188 | gtk_tree_path_to_string(parent_path));*/ |
460b9539 | 189 | } else { |
ebcfbfef RK |
190 | parent_path = 0; |
191 | parent_it = 0; | |
192 | /*fprintf(stderr, "choose_populate %s: populating the root\n", | |
2fadbbc6 | 193 | type);*/ |
ebcfbfef | 194 | } |
659201af RK |
195 | /* Both td[] and the current node set are sorted so we can do a single linear |
196 | * pass to insert new nodes and remove unwanted ones. The total performance | |
197 | * may be worse than linear depending on the performance of GTK+'s insert and | |
198 | * delete operations. */ | |
199 | //fprintf(stderr, "sorting tracks\n"); | |
2fadbbc6 | 200 | struct tracksort_data *td = tracksort_init(nvec, vec, type); |
ebcfbfef RK |
201 | GtkTreeIter it[1]; |
202 | gboolean itv = gtk_tree_model_iter_children(GTK_TREE_MODEL(choose_store), | |
203 | it, | |
204 | parent_it); | |
659201af RK |
205 | int inserted = 0, deleted_placeholder = 0; |
206 | //fprintf(stderr, "inserting tracks type=%s\n", type); | |
207 | while(nvec > 0 || itv) { | |
208 | /*fprintf(stderr, "td[] = %s, it=%s [%s]\n", | |
209 | nvec > 0 ? td->track : "(none)", | |
210 | itv ? choose_get_track(it) : "(!itv)", | |
211 | itv ? (choose_is_file(it) ? "file" : "dir") : "");*/ | |
212 | enum { INSERT, DELETE, SKIP_TREE, SKIP_BOTH } action; | |
213 | const char *track = itv ? choose_get_track(it) : 0; | |
214 | if(itv && !track) { | |
215 | //fprintf(stderr, " placeholder\n"); | |
216 | action = DELETE; | |
217 | ++deleted_placeholder; | |
218 | } else if(nvec > 0 && itv) { | |
219 | /* There's both a tree row and a td[] entry */ | |
220 | const int cmp = compare_tracks(td->sort, choose_get_sort(it), | |
221 | td->display, choose_get_display(it), | |
222 | td->track, track); | |
223 | //fprintf(stderr, " cmp=%d\n", cmp); | |
224 | if(cmp < 0) | |
225 | /* td < it, so we insert td before it */ | |
226 | action = INSERT; | |
227 | else if(cmp > 0) { | |
228 | /* td > it, so we must either delete it (if the same type) or skip it */ | |
229 | if(choose_is_file(it) == isfile) | |
230 | action = DELETE; | |
231 | else | |
232 | action = SKIP_TREE; | |
233 | } else | |
234 | /* td = it, so we step past both */ | |
235 | action = SKIP_BOTH; | |
236 | } else if(nvec > 0) { | |
237 | /* We've reached the end of the tree rows, but new have tracks left in | |
238 | * td[] */ | |
239 | //fprintf(stderr, " inserting\n"); | |
240 | action = INSERT; | |
6a06a735 | 241 | } else { |
659201af RK |
242 | /* We've reached the end of the new tracks from td[], but there are |
243 | * further tracks in the tree */ | |
244 | //fprintf(stderr, " deleting\n"); | |
d62c03cd RK |
245 | if(choose_is_file(it) == isfile) |
246 | action = DELETE; | |
247 | else | |
248 | action = SKIP_TREE; | |
460b9539 | 249 | } |
659201af RK |
250 | |
251 | switch(action) { | |
252 | case INSERT: { | |
253 | //fprintf(stderr, " INSERT %s\n", td->track); | |
254 | /* Insert a new row from td[] before it, or at the end if it is no longer | |
255 | * valid */ | |
256 | GtkTreeIter child[1]; | |
257 | gtk_tree_store_insert_before(choose_store, | |
258 | child, /* new row */ | |
259 | parent_it, /* parent */ | |
260 | itv ? it : NULL); /* successor */ | |
261 | gtk_tree_store_set(choose_store, child, | |
262 | NAME_COLUMN, td->display, | |
a98fd571 | 263 | ISFILE_COLUMN, isfile, |
659201af RK |
264 | TRACK_COLUMN, td->track, |
265 | SORT_COLUMN, td->sort, | |
ebcfbfef | 266 | -1); |
ad47bd4c RK |
267 | /* Update length and state; we expect this to kick off length lookups |
268 | * rather than necessarily get the right value the first time round. */ | |
659201af | 269 | choose_set_state_callback(0, 0, child, 0); |
ebcfbfef RK |
270 | /* If we inserted a directory, insert a placeholder too, so it appears to |
271 | * have children; it will be deleted when we expand the directory. */ | |
a98fd571 | 272 | if(!isfile) { |
ebcfbfef RK |
273 | //fprintf(stderr, " inserting a placeholder\n"); |
274 | GtkTreeIter placeholder[1]; | |
275 | ||
659201af | 276 | gtk_tree_store_append(choose_store, placeholder, child); |
ebcfbfef RK |
277 | gtk_tree_store_set(choose_store, placeholder, |
278 | NAME_COLUMN, "Waddling...", | |
a98fd571 RK |
279 | TRACK_COLUMN, "", |
280 | ISFILE_COLUMN, FALSE, | |
ebcfbfef | 281 | -1); |
e9b70a84 | 282 | } |
659201af RK |
283 | ++inserted; |
284 | ++td; | |
285 | --nvec; | |
286 | break; | |
287 | } | |
288 | case SKIP_BOTH: | |
289 | //fprintf(stderr, " SKIP_BOTH\n"); | |
290 | ++td; | |
291 | --nvec; | |
292 | /* fall thru */ | |
293 | case SKIP_TREE: | |
294 | //fprintf(stderr, " SKIP_TREE\n"); | |
295 | itv = gtk_tree_model_iter_next(GTK_TREE_MODEL(choose_store), it); | |
296 | break; | |
297 | case DELETE: | |
298 | //fprintf(stderr, " DELETE\n"); | |
299 | itv = choose_remove_node(it); | |
300 | break; | |
460b9539 | 301 | } |
460b9539 | 302 | } |
659201af RK |
303 | /*fprintf(stderr, "inserted=%d deleted_placeholder=%d\n\n", |
304 | inserted, deleted_placeholder);*/ | |
ebcfbfef RK |
305 | if(parent_ref) { |
306 | /* If we deleted a placeholder then we must re-expand the row */ | |
659201af RK |
307 | if(deleted_placeholder) |
308 | gtk_tree_view_expand_row(GTK_TREE_VIEW(choose_view), parent_path, FALSE); | |
ebcfbfef RK |
309 | gtk_tree_row_reference_free(parent_ref); |
310 | gtk_tree_path_free(parent_path); | |
460b9539 | 311 | } |
2a9a65e4 RK |
312 | /* We only notify others that we've inserted tracks when there are no more |
313 | * insertions pending, so that they don't have to keep track of how many | |
314 | * requests they've made. */ | |
315 | choose_inserted += inserted; | |
316 | if(--choose_list_in_flight == 0) { | |
317 | /* Notify interested parties that we inserted some tracks, AFTER making | |
318 | * sure that the row is properly expanded */ | |
319 | if(choose_inserted) { | |
320 | event_raise("choose-inserted-tracks", parent_it); | |
321 | choose_inserted = 0; | |
322 | } | |
323 | } | |
460b9539 | 324 | } |
325 | ||
ebcfbfef RK |
326 | static void choose_dirs_completed(void *v, |
327 | const char *error, | |
328 | int nvec, char **vec) { | |
329 | if(error) { | |
330 | popup_protocol_error(0, error); | |
331 | return; | |
460b9539 | 332 | } |
a98fd571 | 333 | choose_populate(v, nvec, vec, 0/*!isfile*/); |
460b9539 | 334 | } |
335 | ||
ebcfbfef RK |
336 | static void choose_files_completed(void *v, |
337 | const char *error, | |
338 | int nvec, char **vec) { | |
339 | if(error) { | |
53fa91bb | 340 | popup_protocol_error(0, error); |
ebcfbfef | 341 | return; |
460b9539 | 342 | } |
a98fd571 | 343 | choose_populate(v, nvec, vec, 1/*isfile*/); |
460b9539 | 344 | } |
345 | ||
a3602333 RK |
346 | void choose_play_completed(void attribute((unused)) *v, |
347 | const char *error) { | |
348 | if(error) | |
349 | popup_protocol_error(0, error); | |
350 | } | |
351 | ||
352 | static void choose_state_toggled | |
353 | (GtkCellRendererToggle attribute((unused)) *cell_renderer, | |
354 | gchar *path_str, | |
355 | gpointer attribute((unused)) user_data) { | |
356 | GtkTreeIter it[1]; | |
357 | /* Identify the track */ | |
358 | gboolean itv = | |
359 | gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(choose_store), | |
360 | it, | |
361 | path_str); | |
362 | if(!itv) | |
363 | return; | |
a98fd571 | 364 | if(!choose_is_file(it)) |
a3602333 | 365 | return; |
a98fd571 RK |
366 | const char *track = choose_get_track(it); |
367 | if(queued(track)) | |
a3602333 | 368 | return; |
a98fd571 | 369 | disorder_eclient_play(client, track, choose_play_completed, 0); |
a3602333 RK |
370 | |
371 | } | |
372 | ||
ebcfbfef RK |
373 | static void choose_row_expanded(GtkTreeView attribute((unused)) *treeview, |
374 | GtkTreeIter *iter, | |
375 | GtkTreePath *path, | |
460b9539 | 376 | gpointer attribute((unused)) user_data) { |
659201af | 377 | /*fprintf(stderr, "row-expanded path=[%s]\n\n", |
ebcfbfef RK |
378 | gtk_tree_path_to_string(path));*/ |
379 | /* We update a node's contents whenever it is expanded, even if it was | |
380 | * already populated; the effect is that contracting and expanding a node | |
381 | * suffices to update it to the latest state on the server. */ | |
a98fd571 | 382 | const char *track = choose_get_track(iter); |
ebcfbfef | 383 | disorder_eclient_files(client, choose_files_completed, |
a98fd571 | 384 | track, |
ebcfbfef RK |
385 | NULL, |
386 | gtk_tree_row_reference_new(GTK_TREE_MODEL(choose_store), | |
387 | path)); | |
388 | disorder_eclient_dirs(client, choose_dirs_completed, | |
a98fd571 | 389 | track, |
ebcfbfef RK |
390 | NULL, |
391 | gtk_tree_row_reference_new(GTK_TREE_MODEL(choose_store), | |
392 | path)); | |
393 | /* The row references are destroyed in the _completed handlers. */ | |
2a9a65e4 | 394 | choose_list_in_flight += 2; |
ebcfbfef RK |
395 | } |
396 | ||
ebcfbfef | 397 | /** @brief Create the choose tab */ |
460b9539 | 398 | GtkWidget *choose_widget(void) { |
ebcfbfef | 399 | /* Create the tree store. */ |
a98fd571 | 400 | choose_store = gtk_tree_store_new(CHOOSE_COLUMNS, |
ad47bd4c RK |
401 | G_TYPE_BOOLEAN, |
402 | G_TYPE_STRING, | |
ebcfbfef | 403 | G_TYPE_STRING, |
a3602333 | 404 | G_TYPE_BOOLEAN, |
a98fd571 | 405 | G_TYPE_STRING, |
cfa78eaa RK |
406 | G_TYPE_STRING, |
407 | G_TYPE_STRING, | |
a98fd571 | 408 | G_TYPE_STRING); |
ebcfbfef RK |
409 | |
410 | /* Create the view */ | |
411 | choose_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(choose_store)); | |
ad47bd4c | 412 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(choose_view), TRUE); |
ebcfbfef RK |
413 | |
414 | /* Create cell renderers and columns */ | |
ad47bd4c RK |
415 | /* TODO use a table */ |
416 | { | |
e9a72659 | 417 | GtkCellRenderer *r = gtk_cell_renderer_toggle_new(); |
ad47bd4c | 418 | GtkTreeViewColumn *c = gtk_tree_view_column_new_with_attributes |
e9a72659 | 419 | ("Queued", |
ad47bd4c | 420 | r, |
e9a72659 RK |
421 | "active", STATE_COLUMN, |
422 | "visible", ISFILE_COLUMN, | |
ad47bd4c RK |
423 | (char *)0); |
424 | gtk_tree_view_column_set_resizable(c, TRUE); | |
425 | gtk_tree_view_column_set_reorderable(c, TRUE); | |
ad47bd4c | 426 | gtk_tree_view_append_column(GTK_TREE_VIEW(choose_view), c); |
e9a72659 RK |
427 | g_signal_connect(r, "toggled", |
428 | G_CALLBACK(choose_state_toggled), 0); | |
ad47bd4c RK |
429 | } |
430 | { | |
431 | GtkCellRenderer *r = gtk_cell_renderer_text_new(); | |
432 | GtkTreeViewColumn *c = gtk_tree_view_column_new_with_attributes | |
433 | ("Length", | |
434 | r, | |
435 | "text", LENGTH_COLUMN, | |
436 | (char *)0); | |
437 | gtk_tree_view_column_set_resizable(c, TRUE); | |
438 | gtk_tree_view_column_set_reorderable(c, TRUE); | |
a3602333 | 439 | g_object_set(r, "xalign", (gfloat)1.0, (char *)0); |
ad47bd4c RK |
440 | gtk_tree_view_append_column(GTK_TREE_VIEW(choose_view), c); |
441 | } | |
442 | { | |
e9a72659 | 443 | GtkCellRenderer *r = gtk_cell_renderer_text_new(); |
ad47bd4c | 444 | GtkTreeViewColumn *c = gtk_tree_view_column_new_with_attributes |
e9a72659 | 445 | ("Track", |
ad47bd4c | 446 | r, |
e9a72659 RK |
447 | "text", NAME_COLUMN, |
448 | "background", BG_COLUMN, | |
449 | "foreground", FG_COLUMN, | |
ad47bd4c RK |
450 | (char *)0); |
451 | gtk_tree_view_column_set_resizable(c, TRUE); | |
452 | gtk_tree_view_column_set_reorderable(c, TRUE); | |
e9a72659 | 453 | g_object_set(c, "expand", TRUE, (char *)0); |
ad47bd4c | 454 | gtk_tree_view_append_column(GTK_TREE_VIEW(choose_view), c); |
e9a72659 | 455 | gtk_tree_view_set_expander_column(GTK_TREE_VIEW(choose_view), c); |
ad47bd4c | 456 | } |
460b9539 | 457 | |
ebcfbfef RK |
458 | /* The selection should support multiple things being selected */ |
459 | choose_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(choose_view)); | |
460 | gtk_tree_selection_set_mode(choose_selection, GTK_SELECTION_MULTIPLE); | |
461 | ||
462 | /* Catch button presses */ | |
6982880f RK |
463 | g_signal_connect(choose_view, "button-press-event", |
464 | G_CALLBACK(choose_button_event), 0); | |
465 | g_signal_connect(choose_view, "button-release-event", | |
466 | G_CALLBACK(choose_button_event), 0); | |
ebcfbfef RK |
467 | /* Catch row expansions so we can fill in placeholders */ |
468 | g_signal_connect(choose_view, "row-expanded", | |
469 | G_CALLBACK(choose_row_expanded), 0); | |
ad47bd4c RK |
470 | |
471 | event_register("queue-list-changed", choose_set_state, 0); | |
472 | event_register("playing-track-changed", choose_set_state, 0); | |
cfa78eaa | 473 | event_register("search-results-changed", choose_set_state, 0); |
3efa1d16 RK |
474 | event_register("lookups-completed", choose_set_state, 0); |
475 | ||
ebcfbfef RK |
476 | /* Fill the root */ |
477 | disorder_eclient_files(client, choose_files_completed, "", NULL, NULL); | |
478 | disorder_eclient_dirs(client, choose_dirs_completed, "", NULL, NULL); | |
cfa78eaa | 479 | |
ebcfbfef RK |
480 | /* Make the widget scrollable */ |
481 | GtkWidget *scrolled = scroll_widget(choose_view); | |
cfa78eaa RK |
482 | |
483 | /* Pack vertically with the search widget */ | |
484 | GtkWidget *vbox = gtk_vbox_new(FALSE/*homogenous*/, 1/*spacing*/); | |
485 | gtk_box_pack_start(GTK_BOX(vbox), scrolled, | |
486 | TRUE/*expand*/, TRUE/*fill*/, 0/*padding*/); | |
487 | gtk_box_pack_end(GTK_BOX(vbox), choose_search_widget(), | |
488 | FALSE/*expand*/, FALSE/*fill*/, 0/*padding*/); | |
489 | ||
490 | g_object_set_data(G_OBJECT(vbox), "type", (void *)&choose_tabtype); | |
491 | return vbox; | |
460b9539 | 492 | } |
493 | ||
494 | /* | |
495 | Local Variables: | |
496 | c-basic-offset:2 | |
497 | comment-column:40 | |
498 | fill-column:79 | |
499 | indent-tabs-mode:nil | |
500 | End: | |
501 | */ |