annotate libaudacious/dirbrowser.c @ 890:ed26947bbf57 trunk

[svn] Gapless support. This comes with a few caveats, that I will mention here: 1) It is not really gapless, it just removes any delays caused by resetting the output device. Mileage depends on source performance. However, this commit reduces any gaps I have to a period of time that is unnoticable to me. (Of course, I have a 15k RPM SATA drive too.)
author nenolod
date Mon, 27 Mar 2006 13:05:09 -0800
parents cb178e5ad177
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* XMMS - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 1998-2002 Peter Alm, Mikael Alm, Olle Hallnas,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 * Thomas Nilsson and 4Front Technologies
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Copyright (C) 1999-2002 Haavard Kvaalen
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #define GETTEXT_PACKAGE PACKAGE
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <glib/gi18n-lib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <gtk/gtk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include <unistd.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include <dirent.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include <sys/types.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #include <sys/stat.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 /* XPM */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 static gchar *folder[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 "16 16 16 1",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 " c None",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 ". c #f4f7e4",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 "X c #dee4b5",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 "o c #e1e7b9",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 "O c #c6cba4",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 "+ c #dce2b8",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 "@ c #e9e9ec",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 "# c #d3d8ae",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 "$ c #d8daca",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 "% c #b2b2b5",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 "& c #767862",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 "* c #e3e6c3",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 "= c #1b1b1a",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 "- c #939684",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 "; c #555555",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 ": c #000000",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 " ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 " ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 " :::: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 " :.@@O: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 ":-&&&&&::::: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 ":.@@@@@*$O#O= ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 ":@*+XXXX+##O: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 ":.*#oooXXXXX: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 ":@+XoXXXXXX#: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 ":@*ooXXXXXX#: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 ":@**XXXXXXX#: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 ":@*XXXXXXXX%: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 ":$.*OOOOOO%-: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 " ;::::::::::: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 " ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 " "
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 /* Icon by Jakub Steiner <jimmac@ximian.com> */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 /* XPM */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 static gchar *ofolder[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 "16 16 16 1",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 " c None",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 ". c #a9ad93",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 "X c #60634d",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 "o c #dee4b5",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 "O c #9ca085",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 "+ c #0c0d04",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 "@ c #2f2f31",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 "# c #3b3d2c",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 "$ c #c8cda2",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 "% c #e6e6e9",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 "& c #b3b5a5",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 "* c #80826d",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 "= c #292a1c",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 "- c #fefef6",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 "; c #8f937b",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 ": c #000000",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 " ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 " ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 " :::: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 " :-%%&: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 ":-;;;OX::::: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 ":-;;;;O;O;&.: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 ":-*X##@@@@@=#: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 ":%*+-%%ooooooO: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 ":%X;%ooooooo.*: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 ":.+-%oooooooO: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 ":*O-oooooooo*: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 ":O-oooooooo.: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 ":*-%$$$$$$OX: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 " ::::::::::: ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 " ",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 " "
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 #define NODE_SPACING 4
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 typedef void (*db_handler_t) (char *);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 static GdkPixmap *folder_pixmap = NULL, *ofolder_pixmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 static GdkBitmap *folder_mask, *ofolder_mask;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 struct dirnode {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 guint scanned:1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 gchar *path;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 check_for_subdir(gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 DIR *dir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 struct dirent *dirent;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 struct stat statbuf;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 gchar *npath;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 if ((dir = opendir(path)) != NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 while ((dirent = readdir(dir)) != NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 if (dirent->d_name[0] == '.')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 npath = g_strconcat(path, dirent->d_name, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 if (stat(npath, &statbuf) != -1 && S_ISDIR(statbuf.st_mode)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 g_free(npath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 closedir(dir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 g_free(npath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 closedir(dir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 destroy_cb(gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 struct dirnode *node = data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 g_free(node->path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 g_free(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 add_dir(GtkCTree * tree, GtkCTreeNode * pnode, gchar * parent, gchar * dir)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 struct stat statbuf;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 gchar *path;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 /* Don't show hidden dirs, nor . and .. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 if (dir[0] == '.')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 path = g_strconcat(parent, dir, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 if (stat(path, &statbuf) != -1 && S_ISDIR(statbuf.st_mode)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 gboolean has_subdir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 gchar *text = "";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 GtkCTreeNode *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 struct dirnode *dirnode = g_new0(struct dirnode, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 dirnode->path = g_strconcat(path, "/", NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 has_subdir = check_for_subdir(dirnode->path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 node = gtk_ctree_insert_node(tree, pnode, NULL, &dir,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 NODE_SPACING, folder_pixmap,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 folder_mask, ofolder_pixmap,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 ofolder_mask, !has_subdir, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 gtk_ctree_node_set_row_data_full(tree, node, dirnode, destroy_cb);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 if (has_subdir)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 gtk_ctree_insert_node(tree, node, NULL, &text,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 NODE_SPACING, NULL, NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 NULL, NULL, FALSE, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 g_free(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 expand_cb(GtkWidget * widget, GtkCTreeNode * parent_node)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 struct dirent *dirent;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 GtkCTree *tree = GTK_CTREE(widget);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 struct dirnode *parent_dirnode;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 parent_dirnode = gtk_ctree_node_get_row_data(tree, parent_node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 if (!parent_dirnode->scanned) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 DIR *dir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 gtk_clist_freeze(GTK_CLIST(widget));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 gtk_ctree_remove_node(tree, GTK_CTREE_ROW(parent_node)->children);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 if ((dir = opendir(parent_dirnode->path)) != NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 while ((dirent = readdir(dir)) != NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 add_dir(tree, parent_node,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 parent_dirnode->path, dirent->d_name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 closedir(dir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 gtk_ctree_sort_node(tree, parent_node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 gtk_clist_thaw(GTK_CLIST(widget));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 parent_dirnode->scanned = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 select_row_cb(GtkWidget * widget, gint row, gint column,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 GdkEventButton * bevent, gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 struct dirnode *dirnode;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 GtkCTreeNode *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 db_handler_t handler;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 if (bevent && bevent->type == GDK_2BUTTON_PRESS) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 dirnode = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 handler = (db_handler_t) gtk_object_get_user_data(GTK_OBJECT(widget));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 if (handler)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 handler(dirnode->path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 show_cb(GtkWidget * widget, gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 GtkCTree *tree = GTK_CTREE(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 GtkCTreeNode *node = gtk_object_get_data(GTK_OBJECT(tree),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 "selected_node");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 if (node)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 gtk_ctree_node_moveto(tree, node, -1, 0.6, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 ok_clicked(GtkWidget * widget, GtkWidget * tree)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 GtkCTreeNode *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 struct dirnode *dirnode;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 GList *list_node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 GtkWidget *window;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 db_handler_t handler;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 window = gtk_object_get_user_data(GTK_OBJECT(widget));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 gtk_widget_hide(window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 list_node = GTK_CLIST(tree)->selection;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 while (list_node) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 node = list_node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 dirnode = gtk_ctree_node_get_row_data(GTK_CTREE(tree), node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 handler = (db_handler_t) gtk_object_get_user_data(GTK_OBJECT(tree));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 if (handler)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 handler(dirnode->path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 list_node = g_list_next(list_node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 gtk_widget_destroy(window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 GtkWidget *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 xmms_create_dir_browser(gchar * title, gchar * current_path,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 GtkSelectionMode mode, void (*handler) (gchar *))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 GtkWidget *window, *scroll_win, *tree, *vbox, *bbox, *ok, *cancel, *sep;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 gchar *root_text = "/", *text = "";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 GtkCTreeNode *root_node, *node, *selected_node = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 GtkCTree *ctree;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 struct dirnode *dirnode;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 gtk_window_set_title(GTK_WINDOW(window), title);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 gtk_container_border_width(GTK_CONTAINER(window), 10);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 vbox = gtk_vbox_new(FALSE, 10);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 gtk_container_add(GTK_CONTAINER(window), vbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 scroll_win = gtk_scrolled_window_new(NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 GTK_POLICY_AUTOMATIC,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 GTK_POLICY_AUTOMATIC);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294 gtk_widget_set_usize(scroll_win, 450, 400);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 gtk_box_pack_start(GTK_BOX(vbox), scroll_win, TRUE, TRUE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 gtk_widget_show(scroll_win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 gtk_widget_realize(window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 if (!folder_pixmap) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 folder_pixmap = gdk_pixmap_create_from_xpm_d(window->window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 &folder_mask,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 NULL, folder);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 ofolder_pixmap = gdk_pixmap_create_from_xpm_d(window->window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 &ofolder_mask,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 NULL, ofolder);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 tree = gtk_ctree_new(1, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 ctree = GTK_CTREE(tree);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310 gtk_clist_set_column_auto_resize(GTK_CLIST(tree), 0, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 gtk_clist_set_selection_mode(GTK_CLIST(tree), mode);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 gtk_ctree_set_line_style(ctree, GTK_CTREE_LINES_DOTTED);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313 g_signal_connect(G_OBJECT(tree), "tree_expand",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 G_CALLBACK(expand_cb), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 g_signal_connect(G_OBJECT(tree), "select_row",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 G_CALLBACK(select_row_cb), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 g_signal_connect(G_OBJECT(window), "show", G_CALLBACK(show_cb), tree);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 gtk_container_add(GTK_CONTAINER(scroll_win), tree);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 gtk_object_set_user_data(GTK_OBJECT(tree), (void *) handler);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 root_node = gtk_ctree_insert_node(ctree, NULL, NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 &root_text, NODE_SPACING,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 folder_pixmap, folder_mask,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324 ofolder_pixmap, ofolder_mask,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 FALSE, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 dirnode = g_new0(struct dirnode, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327 dirnode->path = g_strdup(G_DIR_SEPARATOR_S);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 gtk_ctree_node_set_row_data_full(ctree, root_node, dirnode, destroy_cb);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 node = gtk_ctree_insert_node(ctree, root_node, NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 &text, 4, NULL, NULL, NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 NULL, TRUE, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 gtk_ctree_expand(ctree, root_node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333 gtk_widget_show(tree);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 sep = gtk_hseparator_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337 gtk_widget_show(sep);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 bbox = gtk_hbutton_box_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 ok = gtk_button_new_from_stock(GTK_STOCK_OK);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 gtk_object_set_user_data(GTK_OBJECT(ok), window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 gtk_window_set_default(GTK_WINDOW(window), ok);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 g_signal_connect(G_OBJECT(ok), "clicked", G_CALLBACK(ok_clicked), tree);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 gtk_widget_show(ok);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 g_signal_connect_swapped(G_OBJECT(cancel), "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 GTK_OBJECT(window));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 gtk_widget_show(cancel);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 gtk_widget_show(bbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 gtk_widget_show(vbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 if (current_path && *current_path) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 gchar **dir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 dir = g_strsplit(current_path, G_DIR_SEPARATOR_S, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 node = root_node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 for (i = 0; dir[i] != NULL; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 if (dir[i][0] == '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 for (node = GTK_CTREE_ROW(node)->children; node != NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 node = GTK_CTREE_ROW(node)->sibling) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 gchar *tmp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 if (gtk_ctree_node_get_pixtext(ctree, node, 0,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 &tmp, NULL, NULL, NULL))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 if (!strcmp(dir[i], tmp))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 if (!node)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 if (!GTK_CTREE_ROW(node)->is_leaf && dir[i + 1])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 gtk_ctree_expand(ctree, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386 selected_node = node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
387 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
388 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
389 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
390 g_strfreev(dir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
391 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
392
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
393 if (!selected_node)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
394 selected_node = root_node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
395
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396 gtk_ctree_select(ctree, selected_node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 gtk_object_set_data(GTK_OBJECT(tree), "selected_node", selected_node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 return window;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400 }