~ubuntu-branches/ubuntu/karmic/aqualung/karmic

« back to all changes in this revision

Viewing changes to src/search_playlist.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Cécile (Le_Vert)
  • Date: 2007-10-04 14:03:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071004140326-h00cr9l1jibc74j0
Tags: 0.9~beta8-2
* Improve debian/menu (Closes: #445126).
* Improve .desktop to fit current FreeDesktop specifications.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    along with this program; if not, write to the Free Software
16
16
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
17
 
18
 
    $Id: search_playlist.c 583 2007-02-10 16:36:41Z peterszilagyi $
 
18
    $Id: search_playlist.c 639 2007-05-30 02:03:18Z peterszilagyi $
19
19
*/
20
20
 
21
21
#include <config.h>
42
42
 
43
43
extern GtkWidget* gui_stock_label_button(gchar *blabel, const gchar *bstock);
44
44
 
45
 
extern GtkListStore * play_store;
46
 
extern GtkWidget * play_list;
47
 
 
48
45
extern GtkWidget * playlist_window;
49
46
extern GtkWidget * main_window;
 
47
extern GList * playlists;
50
48
 
51
49
static GtkWidget * search_window = NULL;
52
50
static GtkWidget * searchkey_entry;
73
71
 
74
72
static void
75
73
clear_search_store(void) {
 
74
 
76
75
        int i;
77
76
        GtkTreeIter iter;
78
77
 
126
125
        get_toggle_buttons_state();
127
126
 
128
127
        if (selectfc) {
129
 
 
130
128
                gtk_widget_hide(sres_list);
131
129
                gtk_window_resize(GTK_WINDOW(search_window), 420, 138);
132
130
 
133
131
        } else {
134
 
 
135
132
                gtk_window_resize(GTK_WINDOW(search_window), 420, 355);
136
133
                gtk_widget_show(sres_list);
137
 
 
138
134
        }
139
135
 
140
136
        return TRUE;
142
138
 
143
139
 
144
140
void
145
 
search_foreach(GPatternSpec * pattern, GtkTreeIter * list_iter) {
 
141
search_foreach(playlist_t * pl, GPatternSpec * pattern, GtkTreeIter * list_iter) {
146
142
 
147
143
        char * text;
148
144
        char * tmp = NULL;
149
145
 
150
 
        gtk_tree_model_get(GTK_TREE_MODEL(play_store), list_iter, 0, &text, -1);
 
146
        gtk_tree_model_get(GTK_TREE_MODEL(pl->store), list_iter, PL_COL_TRACK_NAME, &text, -1);
151
147
 
152
148
        if (casesens) {
153
149
                tmp = strdup(text);
160
156
                GtkTreeIter iter;
161
157
                GtkTreePath * path;
162
158
 
163
 
                path = gtk_tree_model_get_path(GTK_TREE_MODEL(play_store), list_iter);
 
159
                path = gtk_tree_model_get_path(GTK_TREE_MODEL(pl->store), list_iter);
164
160
                gtk_list_store_append(search_store, &iter);
165
 
                gtk_list_store_set(search_store, &iter, 0, text, 1, (gpointer)path, -1);
 
161
                gtk_list_store_set(search_store, &iter, 0, text,
 
162
                                   1, (gpointer)path, 2, pl->name, 3, (gpointer)pl, -1);
166
163
        }
167
164
 
168
165
        g_free(tmp);
169
166
        g_free(text);
170
 
        deflicker();
171
167
}
172
168
 
173
169
static gint
182
178
        GtkTreeIter list_iter;
183
179
        GtkTreeIter sfac_iter;
184
180
 
 
181
        GList * node = NULL;
 
182
 
 
183
 
185
184
        get_toggle_buttons_state();
186
185
 
187
186
        clear_search_store();
209
208
 
210
209
        pattern = g_pattern_spec_new(key);
211
210
 
212
 
        i = 0;
213
 
        while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(play_store), &list_iter, NULL, i++)) {
214
 
 
215
 
                if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(play_store), &list_iter)) {
216
 
 
217
 
                        int j = 0;
218
 
                        GtkTreeIter iter;
219
 
 
220
 
                        while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(play_store),
221
 
                                                             &iter, &list_iter, j++)) {
222
 
                                search_foreach(pattern, &iter);
 
211
        for (node = playlists; node; node = node->next) {
 
212
 
 
213
                playlist_t * pl = (playlist_t *)node->data;
 
214
 
 
215
                i = 0;
 
216
                while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pl->store),
 
217
                                                     &list_iter, NULL, i++)) {
 
218
 
 
219
                        if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(pl->store), &list_iter)) {
 
220
 
 
221
                                int j = 0;
 
222
                                GtkTreeIter iter;
 
223
 
 
224
                                while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pl->store),
 
225
                                                                     &iter, &list_iter, j++)) {
 
226
                                        search_foreach(pl, pattern, &iter);
 
227
                                }
 
228
                        } else {
 
229
                                search_foreach(pl, pattern, &list_iter);
223
230
                        }
224
 
                } else {
225
 
                        search_foreach(pattern, &list_iter);
226
231
                }
227
232
        }
228
233
 
246
251
        GtkTreeIter iter;
247
252
        GtkTreePath * path;
248
253
        GtkTreePath * path_up;
249
 
        gpointer gptr;
 
254
        gpointer gptr1;
 
255
        gpointer gptr2;
 
256
        playlist_t * pl;
250
257
 
251
258
        if (!gtk_tree_selection_get_selected(search_select, NULL, &iter)) {
252
259
                return;
253
260
        }
254
261
 
255
262
        gtk_tree_model_get(GTK_TREE_MODEL(search_store), &iter,
256
 
                           1, &gptr, -1);
 
263
                           1, &gptr1, 3, &gptr2, -1);
257
264
 
258
 
        path = (GtkTreePath *)gptr;
 
265
        path = (GtkTreePath *)gptr1;
259
266
        path_up = gtk_tree_path_copy(path);
260
267
 
 
268
        pl = (playlist_t *)gptr2;
 
269
 
261
270
        if (gtk_tree_path_up(path_up)) {
262
 
                gtk_tree_view_expand_row(GTK_TREE_VIEW(play_list), path_up, FALSE);
 
271
                gtk_tree_view_expand_row(GTK_TREE_VIEW(pl->view), path_up, FALSE);
263
272
        }
264
273
 
265
 
        gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(play_list), path, NULL, TRUE, 0.5f, 0.5f);
266
 
        gtk_tree_view_set_cursor(GTK_TREE_VIEW(play_list), path, NULL, FALSE);
 
274
        gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(pl->view), path, NULL, TRUE, 0.5f, 0.5f);
 
275
        gtk_tree_view_set_cursor(GTK_TREE_VIEW(pl->view), path, NULL, FALSE);
 
276
 
 
277
        playlist_set_current(pl);
267
278
 
268
279
        gtk_tree_path_free(path_up);
269
280
}
386
397
        gtk_container_add(GTK_CONTAINER(search_viewport), search_scrwin);
387
398
 
388
399
 
389
 
        search_store = gtk_list_store_new(2,
 
400
        search_store = gtk_list_store_new(4,
390
401
                                          G_TYPE_STRING,   /* title */
391
 
                                          G_TYPE_POINTER); /* GtkTreePath */
 
402
                                          G_TYPE_POINTER,  /* GtkTreePath */
 
403
                                          G_TYPE_STRING,   /* playlist name */
 
404
                                          G_TYPE_POINTER); /* playlist_t pointer */
392
405
 
393
406
        gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search_store), 0, GTK_SORT_ASCENDING);
394
407
 
402
415
                         G_CALLBACK(search_selection_changed), NULL);
403
416
 
404
417
        search_renderer = gtk_cell_renderer_text_new();
 
418
        search_column = gtk_tree_view_column_new_with_attributes(_("Playlist"),
 
419
                                                             search_renderer,
 
420
                                                             "text", 2,
 
421
                                                             NULL);
 
422
        gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(search_column),
 
423
                                        GTK_TREE_VIEW_COLUMN_AUTOSIZE);
 
424
        gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(search_column), TRUE);
 
425
        gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(search_column), 2);
 
426
        gtk_tree_view_append_column(GTK_TREE_VIEW(search_list), search_column);
 
427
 
 
428
        search_renderer = gtk_cell_renderer_text_new();
405
429
        search_column = gtk_tree_view_column_new_with_attributes(_("Title"),
406
430
                                                             search_renderer,
407
431
                                                             "text", 0,
409
433
        gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(search_column),
410
434
                                        GTK_TREE_VIEW_COLUMN_AUTOSIZE);
411
435
        gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(search_column), TRUE);
412
 
        gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(search_column), 0);
 
436
        gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(search_column), 2);
413
437
        gtk_tree_view_append_column(GTK_TREE_VIEW(search_list), search_column);
414
438
 
415
439
        hseparator = gtk_hseparator_new ();