annotate audacious/util.c @ 2105:f18a5b617c34 trunk

[svn] - move to GPLv2-only. Based on my interpretation of the license, we are allowed to do this, so we are.
author nenolod
date Tue, 12 Dec 2006 08:38:32 -0800
parents bc47a2129067
children 299651a8f107
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
2105
f18a5b617c34 [svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents: 2087
diff changeset
9 * the Free Software Foundation; under version 2 of the License.
0
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
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20
245
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
21 #define WEIRD_UTF_16_PLAYLIST_ENCODING
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
22
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #define NEED_GLADE
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "util.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <glib/gi18n.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include <glade/glade.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include <gtk/gtk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 #include <ctype.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
1640
6e477dd65024 [svn] - gtkquartz compatibility, pass 1
nenolod
parents: 1613
diff changeset
39 #include "platform/smartinclude.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 #include <gdk/gdkkeysyms.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 #include <X11/Xlib.h>
287
2d919c756941 [svn] - attach -Iaudacious to libaudcore build crap.
nenolod
parents: 284
diff changeset
42 //#include <sys/ipc.h>
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 #include <unistd.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 #include <errno.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 #ifdef HAVE_FTS_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 # include <fts.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 #include "glade.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 #include "input.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 #include "main.h"
538
e4e897d20791 [svn] remove libaudcore, we never did anything with it
nenolod
parents: 383
diff changeset
53 #include "playback.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 #include "playlist.h"
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
55 #include "ui_playlist.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
57 #ifdef USE_CHARDET
1106
f12a2a0556cf [svn] chardet build error fix.
yaz
parents: 1105
diff changeset
58 #include "../libguess/libguess.h"
1613
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
59 #include "../librcd/librcd.h"
1106
f12a2a0556cf [svn] chardet build error fix.
yaz
parents: 1105
diff changeset
60 #ifdef HAVE_UDET
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
61 #include <libudet_c.h>
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
62 #endif
1106
f12a2a0556cf [svn] chardet build error fix.
yaz
parents: 1105
diff changeset
63 #endif
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 static GQuark quark_popup_data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 * escape_shell_chars()
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 * Escapes characters that are special to the shell inside double quotes.
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 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 escape_shell_chars(const gchar * string)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 const gchar *special = "$`\"\\"; /* Characters to escape */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 const gchar *in = string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 gchar *out, *escaped;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 gint num = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 while (*in != '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 if (strchr(special, *in++))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 num++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 escaped = g_malloc(strlen(string) + num + 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 in = string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 out = escaped;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 while (*in != '\0') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 if (strchr(special, *in))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 *out++ = '\\';
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 *out++ = *in++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 *out = '\0';
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 return escaped;
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
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 * find <file> in directory <dirname> or subdirectories. return
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 * pointer to complete filename which has to be freed by calling
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 * "g_free()" after use. Returns NULL if file could not be found.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 typedef struct {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 const gchar *to_match;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 gchar *match;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 gboolean found;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 } FindFileContext;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 find_file_func(const gchar * path, const gchar * basename, gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 FindFileContext *context = data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 if (strlen(path) > FILENAME_MAX) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 g_warning("Ignoring path: name too long (%s)", path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 if (!strcasecmp(basename, context->to_match)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 context->match = g_strdup(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 context->found = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 else if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 dir_foreach(path, find_file_func, context, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 if (context->found)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 find_file_recursively(const gchar * path, const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 FindFileContext context;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 context.to_match = filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 context.match = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 context.found = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 dir_foreach(path, find_file_func, &context, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 return context.match;
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
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 typedef enum {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 ARCHIVE_UNKNOWN = 0,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 ARCHIVE_DIR,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 ARCHIVE_TAR,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 ARCHIVE_TGZ,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 ARCHIVE_ZIP,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 ARCHIVE_TBZ2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 } ArchiveType;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 typedef gchar *(*ArchiveExtractFunc) (const gchar *, const gchar *);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 typedef struct {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 ArchiveType type;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 const gchar *ext;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 } ArchiveExtensionType;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 static ArchiveExtensionType archive_extensions[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 {ARCHIVE_TAR, ".tar"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 {ARCHIVE_ZIP, ".wsz"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 {ARCHIVE_ZIP, ".zip"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 {ARCHIVE_TGZ, ".tar.gz"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 {ARCHIVE_TGZ, ".tgz"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 {ARCHIVE_TBZ2, ".tar.bz2"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 {ARCHIVE_TBZ2, ".bz2"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 {ARCHIVE_UNKNOWN, NULL}
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 static gchar *archive_extract_tar(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 static gchar *archive_extract_zip(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 static gchar *archive_extract_tgz(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 static gchar *archive_extract_tbz2(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 static ArchiveExtractFunc archive_extract_funcs[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 archive_extract_tar,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 archive_extract_tgz,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 archive_extract_zip,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 archive_extract_tbz2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 /* FIXME: these functions can be generalised into a function using a
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 * command lookup table */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 static const gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 get_tar_command(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 static const gchar *command = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 if (!command) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 if (!(command = getenv("TARCMD")))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 command = "tar";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 return command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 static const gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 get_unzip_command(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 static const gchar *command = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 if (!command) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 if (!(command = getenv("UNZIPCMD")))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 command = "unzip";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 return command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 archive_extract_tar(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 return g_strdup_printf("%s >/dev/null xf \"%s\" -C %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 get_tar_command(), archive, dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 archive_extract_zip(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 return g_strdup_printf("%s >/dev/null -o -j \"%s\" -d %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 get_unzip_command(), archive, dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 archive_extract_tgz(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 return g_strdup_printf("%s >/dev/null xzf \"%s\" -C %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 get_tar_command(), archive, dest);
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 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 archive_extract_tbz2(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 return g_strdup_printf("bzip2 -dc \"%s\" | %s >/dev/null xf - -C %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 archive, get_tar_command(), dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 ArchiveType
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 archive_get_type(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 gint i = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 if (g_file_test(filename, G_FILE_TEST_IS_DIR))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 return ARCHIVE_DIR;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 while (archive_extensions[i].ext) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 if (g_str_has_suffix(filename, archive_extensions[i].ext)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 return archive_extensions[i].type;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 i++;
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 return ARCHIVE_UNKNOWN;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 file_is_archive(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 return (archive_get_type(filename) > ARCHIVE_DIR);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 archive_basename(const gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 gint i = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 while (archive_extensions[i].ext) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 if (str_has_suffix_nocase(str, archive_extensions[i].ext)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 const gchar *end = g_strrstr(str, archive_extensions[i].ext);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 if (end) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 return g_strndup(str, end - str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 i++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 decompress_archive
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 Decompresses the archive "filename" to a temporary directory,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 returns the path to the temp dir, or NULL if failed,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 watch out tho, doesn't actually check if the system command succeeds :-|
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 archive_decompress(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 gchar *tmpdir, *cmd, *escaped_filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310 ArchiveType type;
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
311 mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313 if ((type = archive_get_type(filename)) <= ARCHIVE_DIR)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
316 #ifdef HAVE_MKDTEMP
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
317 tmpdir = g_build_filename(g_get_tmp_dir(), "audacious.XXXXXXXX", NULL);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 if (!mkdtemp(tmpdir)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 g_free(tmpdir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320 g_message("Unable to load skin: Failed to create temporary "
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 "directory: %s", g_strerror(errno));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 }
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
324 #else
1891
46576f74b3a1 [svn] - use rand() instead
nenolod
parents: 1890
diff changeset
325 tmpdir = g_strdup_printf("%s/audacious.%ld", g_get_tmp_dir(), rand());
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
326 make_directory(tmpdir, mode755);
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
327 #endif
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 escaped_filename = escape_shell_chars(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 cmd = archive_extract_funcs[type] (escaped_filename, tmpdir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 g_free(escaped_filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333 if (!cmd) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 g_message("extraction function is NULL!");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 g_free(tmpdir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 system(cmd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 g_free(cmd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 return tmpdir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 #ifdef HAVE_FTS_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 del_directory(const gchar * dirname)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 gchar *const argv[2] = { (gchar *) dirname, NULL };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 FTS *fts;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 FTSENT *p;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 fts = fts_open(argv, FTS_PHYSICAL, (gint(*)())NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 while ((p = fts_read(fts))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 switch (p->fts_info) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 case FTS_D:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 case FTS_DNR:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 case FTS_ERR:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 case FTS_DP:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 rmdir(p->fts_accpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 unlink(p->fts_accpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 fts_close(fts);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 #else /* !HAVE_FTS */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 del_directory_func(const gchar * path, const gchar * basename,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 gpointer params)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 if (!strcmp(basename, ".") || !strcmp(path, ".."))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 dir_foreach(path, del_directory_func, NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 rmdir(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
387 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
388
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
389 unlink(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
390
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
391 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
392 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
393
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
394 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
395 del_directory(const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 dir_foreach(path, del_directory_func, NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398 rmdir(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
401 #endif /* ifdef HAVE_FTS */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
402
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
403 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
404 read_ini_string(const gchar * filename, const gchar * section,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
405 const gchar * key)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
406 {
1166
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
407 static gchar *buffer = NULL;
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
408 static gchar *open_buffer = NULL;
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
409 gchar *ret_buffer = NULL;
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
410 gint found_section = 0, len = 0;
1193
03414b9d2507 [svn] filesize must be cached, otherwise lookup loop will crash.
yaz
parents: 1166
diff changeset
411 static gsize filesize = 0;
03414b9d2507 [svn] filesize must be cached, otherwise lookup loop will crash.
yaz
parents: 1166
diff changeset
412 gsize off = 0;
245
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
413 gchar *outbuf;
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
414 unsigned char x[] = { 0xff, 0xfe, 0x00 };
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
415 guint counter;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 if (!filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419
1166
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
420 /*
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
421 * We optimise for the condition that we may be reading from the
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
422 * same ini-file multiple times. This is fairly common; it happens
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
423 * on .pls playlist loads. To do otherwise would take entirely too
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
424 * long, as fstat() can be very slow when done 21,000 times too many.
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
425 *
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
426 * Therefore, we optimise by keeping the last ini file in memory.
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
427 * Yes, this is a memory leak, but it is not too bad, hopefully.
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
428 * - nenolod
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
429 */
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
430 if (open_buffer == NULL || strcasecmp(filename, open_buffer))
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
431 {
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
432 if (buffer != NULL)
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
433 {
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
434 g_free(buffer);
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
435 buffer = NULL;
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
436 }
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
437
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
438 if (open_buffer != NULL)
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
439 {
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
440 g_free(open_buffer);
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
441 open_buffer = NULL;
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
442 }
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
443
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
444 if (!g_file_get_contents(filename, &buffer, &filesize, NULL))
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
445 return NULL;
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
446
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
447 open_buffer = g_strdup(filename);
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
448 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449
245
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
450 /*
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
451 * Convert UTF-16 into something useful. Original implementation
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
452 * by incomp@#audacious. Cleanups \nenolod
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
453 */
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
454 if (!memcmp(&buffer[0],&x,2)) {
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
455 outbuf = g_malloc (filesize); /* it's safe to waste memory. */
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
456
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
457 for (counter = 2; counter < filesize; counter += 2)
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
458 if (!memcmp(&buffer[counter+1], &x[2], 1))
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
459 outbuf[(counter-2)/2] = buffer[counter];
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
460 else
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
461 return NULL;
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
462
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
463 outbuf[(counter-2)/2] = '\0';
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
464
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
465 if ((filesize - 2) / 2 == (counter - 2) / 2) {
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
466 g_free(buffer);
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
467 buffer = outbuf;
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
468 } else {
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
469 g_free(outbuf);
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
470 return NULL; /* XXX wrong encoding */
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
471 }
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
472 }
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
473
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
474 while (!ret_buffer && off < filesize) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
475 while (off < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
476 (buffer[off] == '\r' || buffer[off] == '\n' ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477 buffer[off] == ' ' || buffer[off] == '\t'))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 if (off >= filesize)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481 if (buffer[off] == '[') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 gint slen = strlen(section);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 found_section = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 if (off + slen + 1 < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 !strncasecmp(section, &buffer[off], slen)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487 off += slen;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488 if (buffer[off] == ']') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490 found_section = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494 else if (found_section && off + strlen(key) < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 !strncasecmp(key, &buffer[off], strlen(key))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496 off += strlen(key);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497 while (off < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498 (buffer[off] == ' ' || buffer[off] == '\t'))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 if (off >= filesize)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502 if (buffer[off] == '=') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504 while (off < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505 (buffer[off] == ' ' || buffer[off] == '\t'))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
506 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507 if (off >= filesize)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 len = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 while (off + len < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511 buffer[off + len] != '\r' &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 buffer[off + len] != '\n' && buffer[off + len] != ';')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513 len++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514 ret_buffer = g_strndup(&buffer[off], len);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 off += len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518 while (off < filesize && buffer[off] != '\r' && buffer[off] != '\n')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 return ret_buffer;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 GArray *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526 string_to_garray(const gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 GArray *array;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529 gint temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 const gchar *ptr = str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531 gchar *endptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533 array = g_array_new(FALSE, TRUE, sizeof(gint));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534 for (;;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 temp = strtol(ptr, &endptr, 10);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536 if (ptr == endptr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 g_array_append_val(array, temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 ptr = endptr;
1717
837983bac90f [svn] Fixed a lot of warnings that only showed up on *BSD.
js
parents: 1653
diff changeset
540 while (!isdigit((int) *ptr) && (*ptr) != '\0')
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541 ptr++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542 if (*ptr == '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545 return (array);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 GArray *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549 read_ini_array(const gchar * filename, const gchar * section,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550 const gchar * key)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 gchar *temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553 GArray *a;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 if ((temp = read_ini_string(filename, section, key)) == NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556 g_free(temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559 a = string_to_garray(temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560 g_free(temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561 return a;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565 glist_movedown(GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 gpointer temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 if (g_list_next(list)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 temp = list->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571 list->data = list->next->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572 list->next->data = temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 glist_moveup(GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 gpointer temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 if (g_list_previous(list)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582 temp = list->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 list->data = list->prev->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584 list->prev->data = temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590 util_menu_position(GtkMenu * menu, gint * x, gint * y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591 gboolean * push_in, gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593 GtkRequisition requisition;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594 gint screen_width;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
595 gint screen_height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
596 MenuPos *pos = data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
598 gtk_widget_size_request(GTK_WIDGET(menu), &requisition);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
599
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 screen_width = gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601 screen_height = gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
603 *x = CLAMP(pos->x - 2, 0, MAX(0, screen_width - requisition.width));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604 *y = CLAMP(pos->y - 2, 0, MAX(0, screen_height - requisition.height));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608 util_menu_delete_popup_data(GtkObject * object, GtkItemFactory * ifactory)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610 gtk_signal_disconnect_by_func(object,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611 GTK_SIGNAL_FUNC
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
612 (util_menu_delete_popup_data), ifactory);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
613 gtk_object_remove_data_by_id(GTK_OBJECT(ifactory), quark_popup_data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
614 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
615
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618 * util_item_factory_popup[_with_data]() is a replacement for
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619 * gtk_item_factory_popup[_with_data]().
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 * The difference is that the menu is always popped up whithin the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622 * screen. This means it does not neccesarily pop up at (x,y).
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
623 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
625 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626 util_item_factory_popup_with_data(GtkItemFactory * ifactory,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627 gpointer data,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 GtkDestroyNotify destroy, guint x,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 guint y, guint mouse_button, guint32 time)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
630 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 static GQuark quark_user_menu_pos = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632 MenuPos *pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 if (!quark_user_menu_pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635 quark_user_menu_pos = g_quark_from_static_string("user_menu_pos");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
636
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 if (!quark_popup_data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 quark_popup_data =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639 g_quark_from_static_string("GtkItemFactory-popup-data");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
641 pos = g_object_get_qdata(G_OBJECT(ifactory), quark_user_menu_pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
642 if (!pos) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
643 pos = g_new0(MenuPos, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
644
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
645 g_object_set_qdata_full(G_OBJECT(ifactory->widget),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
646 quark_user_menu_pos, pos, g_free);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
647 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
648 pos->x = x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
649 pos->y = y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
650
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652 if (data != NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653 g_object_set_qdata_full(G_OBJECT(ifactory),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 quark_popup_data, data, destroy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
655 g_signal_connect(G_OBJECT(ifactory->widget),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
656 "selection-done",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
657 G_CALLBACK(util_menu_delete_popup_data), ifactory);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
658 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
659
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
660 gtk_menu_popup(GTK_MENU(ifactory->widget), NULL, NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
661 (GtkMenuPositionFunc) util_menu_position,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
662 pos, mouse_button, time);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
663 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
664
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
665 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
666 util_item_factory_popup(GtkItemFactory * ifactory, guint x, guint y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
667 guint mouse_button, guint32 time)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
668 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
669 util_item_factory_popup_with_data(ifactory, NULL, NULL, x, y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
670 mouse_button, time);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
671 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
672
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
673
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
674 #define URL_HISTORY_MAX_SIZE 30
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
675
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
676 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
677 util_add_url_callback(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
678 GtkEntry * entry)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
679 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
680 const gchar *text;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
681
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
682 text = gtk_entry_get_text(entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
683 if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
684 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
685
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
686 cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
687
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
688 while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
689 GList *node = g_list_last(cfg.url_history);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
690 g_free(node->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
691 cfg.url_history = g_list_delete_link(cfg.url_history, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
692 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
693 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
694
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
695 GtkWidget *
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
696 util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
697 GCallback enqueue_func)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
698 {
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
699 GtkWidget *win, *vbox, *bbox, *enqueue, *ok, *cancel, *combo, *entry;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
700 GList *url;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
701
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
702 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
703 gtk_window_set_title(GTK_WINDOW(win), caption);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
704 gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
705 gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
706 gtk_window_set_default_size(GTK_WINDOW(win), 400, -1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
707 gtk_container_set_border_width(GTK_CONTAINER(win), 12);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
708
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
709 vbox = gtk_vbox_new(FALSE, 10);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
710 gtk_container_add(GTK_CONTAINER(win), vbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
711
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
712 combo = gtk_combo_box_entry_new_text();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
713 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
714
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
715 entry = gtk_bin_get_child(GTK_BIN(combo));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
716 gtk_window_set_focus(GTK_WINDOW(win), entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
717 gtk_entry_set_text(GTK_ENTRY(entry), "");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
718
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
719 for (url = cfg.url_history; url; url = g_list_next(url))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
720 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (const gchar *) url->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
721
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
722 g_signal_connect(entry, "activate",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
723 G_CALLBACK(util_add_url_callback),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
724 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
725 g_signal_connect(entry, "activate",
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
726 G_CALLBACK(ok_func),
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
727 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
728 g_signal_connect_swapped(entry, "activate",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
729 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
730 win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
731
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
732 bbox = gtk_hbutton_box_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
733 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
734 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
735 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
736
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
737 ok = gtk_button_new_from_stock(GTK_STOCK_OPEN);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
738 g_signal_connect(ok, "clicked",
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
739 G_CALLBACK(util_add_url_callback), entry);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
740 g_signal_connect(ok, "clicked",
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
741 G_CALLBACK(ok_func), entry);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
742 g_signal_connect_swapped(ok, "clicked",
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
743 G_CALLBACK(gtk_widget_destroy),
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
744 win);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
745 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
746
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
747 enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
748 gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
749
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
750 g_signal_connect(enqueue, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
751 G_CALLBACK(util_add_url_callback),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
752 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
753 g_signal_connect(enqueue, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
754 G_CALLBACK(enqueue_func),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
755 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
756 g_signal_connect_swapped(enqueue, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
757 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
758 win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
759
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
760 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
761 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
762
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
763 g_signal_connect_swapped(cancel, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
764 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
765 win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
766
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
767 gtk_widget_show_all(vbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
768
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
769 return win;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
770 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
771
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
772 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
773 filebrowser_add_files(GtkFileChooser * browser,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
774 GSList * files)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
775 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
776 GSList *cur;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
777 gchar *ptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
778 guint ctr = 0;
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
779 Playlist *playlist = playlist_get_active();
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
780
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
781 if (GTK_IS_WIDGET(mainwin_jtf))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
782 gtk_widget_set_sensitive(mainwin_jtf, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
783
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
784 for (cur = files; cur; cur = g_slist_next(cur)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
785
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
786 if (g_file_test(cur->data,G_FILE_TEST_IS_DIR)) {
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
787 playlist_add_dir(playlist, (const gchar *) cur->data);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
788 } else {
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
789 playlist_add(playlist, (const gchar *) cur->data);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
790 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
791
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
792 if (++ctr == 20) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
793 playlistwin_update_list();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
794 ctr = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
795 while (gtk_events_pending() ) gtk_main_iteration();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
796 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
797 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
798
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
799 playlistwin_update_list();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
800
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
801 if (GTK_IS_WIDGET(mainwin_jtf))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
802 gtk_widget_set_sensitive(mainwin_jtf, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
803
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
804 ptr = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
805
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
806 g_free(cfg.filesel_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
807 cfg.filesel_path = ptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
808 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
809
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
810 static void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
811 filebrowser_add(GtkFileChooser *browser)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
812 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
813 GSList *files;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
814
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
815 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
816
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
817 if (!files) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
818 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
819 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
820
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
821 filebrowser_add_files(browser, files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
822 g_slist_foreach(files, (GFunc) g_free, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
823 g_slist_free(files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
824 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
825
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
826 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
827 filebrowser_play(GtkFileChooser * browser)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
828 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
829 GSList *files;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
830
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
831 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
832
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
833 if (!files) return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
834
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
835 playlist_clear(playlist_get_active());
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
836
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
837 filebrowser_add_files(browser, files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
838 g_slist_foreach(files, (GFunc) g_free, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
839 g_slist_free(files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
840
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
841 bmp_playback_initiate();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
842 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
843
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
844
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
845 static void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
846 _filebrowser_add_gtk2(GtkWidget *widget,
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
847 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
848 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
849 filebrowser_add(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
850 gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
851 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
852
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
853 static void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
854 _filebrowser_play_gtk2(GtkWidget *widget, gpointer data)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
855 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
856 filebrowser_play(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
857 gtk_file_chooser_unselect_all(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
858 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
859
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
860 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
861 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
862 filebrowser_on_response(GtkFileChooser * browser,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
863 gint response,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
864 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
865 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
866 gtk_widget_hide(GTK_WIDGET(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
867 switch (response) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
868 case GTK_RESPONSE_OK:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
869 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
870 case GTK_RESPONSE_ACCEPT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
871 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
872 case GTK_RESPONSE_CLOSE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
873 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
874 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
875 gtk_widget_destroy(GTK_WIDGET(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
876
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
877 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
878
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
879 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
880
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
881 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
882 _filebrowser_check_hide_add(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
883 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
884 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
885 cfg.close_dialog_add = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
886 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
887
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
888 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
889 _filebrowser_check_hide_open(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
890 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
891 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
892 cfg.close_dialog_open = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
893 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
894
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
895
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
896
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
897 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
898 filebrowser_on_keypress(GtkWidget * browser,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
899 GdkEventKey * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
900 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
901 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
902 if (event->keyval == GDK_Escape) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
903 /* FIXME: this crashes BMP for some reason */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
904 /* g_signal_emit_by_name(browser, "delete-event"); */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
905 gtk_widget_hide(browser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
906 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
907 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
908
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
909 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
910 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
911
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
912 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
913 _filebrowser_do_hide_add(GtkWidget *widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
914 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
915 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
916 if (cfg.close_dialog_add)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
917 gtk_widget_hide(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
918 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
919
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
920 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
921 _filebrowser_do_hide_open(GtkWidget *widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
922 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
923 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
924 if (cfg.close_dialog_open)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
925 gtk_widget_hide(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
926 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
927
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
928 void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
929 util_run_filebrowser_gtk2style(gboolean play_button)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
930 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
931 static GladeXML *xml = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
932 static GtkWidget *dialog = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
933 static GtkWidget *chooser = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
934
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
935 static GtkWidget *button_add;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
936 static GtkWidget *button_select_all, *button_deselect_all;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
937 static GtkWidget *toggle;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
938
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
939 static gulong handlerid, handlerid_check, handlerid_do;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
940 static gulong handlerid_activate, handlerid_do_activate;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
941
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
942 if (!xml) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
943 /* FIXME: Creating a file chooser dialog manually using
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
944 libglade because there's no way to stop
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
945 GtkFileChooserDialog from resizing the buttons to the same
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
946 size. The long toggle button title causes the buttons to
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
947 turn unnecessarily elongated and fugly. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
948
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
949 GtkWidget *alignment;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
950
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
951 xml = glade_xml_new_or_die(_("Add/Open Files dialog"),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
952 DATA_DIR "/glade/addfiles.glade",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
953 NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
954 glade_xml_signal_autoconnect(xml);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
955
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
956 dialog = glade_xml_get_widget(xml, "add_files_dialog");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
957
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
958 /* FIXME: Creating file chooser widget here because libglade <= 2.4.0 does
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
959 not support GtkFileChooserWidget */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
960
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
961 chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
962 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
963
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
964 if (cfg.filesel_path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
965 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
966 cfg.filesel_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
967
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
968 alignment = glade_xml_get_widget(xml, "alignment2");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
969 gtk_container_add(GTK_CONTAINER(alignment), chooser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
970
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
971 toggle = glade_xml_get_widget(xml, "close_on_action");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
972 button_select_all = glade_xml_get_widget(xml, "select_all");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
973 button_deselect_all = glade_xml_get_widget(xml, "deselect_all");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
974 button_add = glade_xml_get_widget(xml, "action");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
975
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
976 g_signal_connect_swapped(button_select_all, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
977 G_CALLBACK(gtk_file_chooser_select_all),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
978 chooser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
979 g_signal_connect_swapped(button_deselect_all, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
980 G_CALLBACK(gtk_file_chooser_unselect_all),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
981 chooser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
982
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
983 g_signal_connect(dialog, "key_press_event",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
984 G_CALLBACK(filebrowser_on_keypress),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
985 NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
986
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
987 gtk_widget_show_all(dialog);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
988 } /* !xml */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
989 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
990 g_signal_handler_disconnect(button_add, handlerid);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
991 g_signal_handler_disconnect(toggle, handlerid_check);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
992 g_signal_handler_disconnect(chooser, handlerid_activate);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
993 g_signal_handler_disconnect(button_add, handlerid_do);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
994 g_signal_handler_disconnect(chooser, handlerid_do_activate);
1752
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
995
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
996 if (cfg.refresh_file_list)
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
997 {
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
998 gchar *tmp = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(chooser));
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
999 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), tmp);
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
1000
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
1001 g_free(tmp);
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
1002 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1003 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1004
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1005 if (play_button) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1006 gtk_window_set_title(GTK_WINDOW(dialog), _("Open Files"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1007
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1008 gtk_button_set_label(GTK_BUTTON(button_add), GTK_STOCK_OPEN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1009
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1010 gtk_button_set_label(GTK_BUTTON(toggle), _("Close dialog on Open"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1011 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), cfg.close_dialog_open);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1012
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1013 handlerid = g_signal_connect(button_add, "clicked", G_CALLBACK(_filebrowser_play_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1014 handlerid_check = g_signal_connect(toggle, "toggled", G_CALLBACK(_filebrowser_check_hide_open), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1015 handlerid_do = g_signal_connect_after(button_add, "clicked", G_CALLBACK(_filebrowser_do_hide_open), dialog);
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1016 handlerid_activate = g_signal_connect(chooser, "file-activated", G_CALLBACK(_filebrowser_play_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1017 handlerid_do_activate = g_signal_connect_after(chooser,"file_activated", G_CALLBACK(_filebrowser_do_hide_open), dialog);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1018 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1019 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1020 gtk_window_set_title(GTK_WINDOW(dialog), _("Add Files"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1021
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1022 gtk_button_set_label(GTK_BUTTON(button_add), GTK_STOCK_ADD);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1023
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1024 gtk_button_set_label(GTK_BUTTON(toggle), _("Close dialog on Add"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1025 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), cfg.close_dialog_add);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1026
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1027 handlerid = g_signal_connect(button_add, "clicked", G_CALLBACK(_filebrowser_add_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1028 handlerid_check = g_signal_connect(toggle, "toggled", G_CALLBACK(_filebrowser_check_hide_add), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1029 handlerid_do = g_signal_connect_after(button_add, "clicked", G_CALLBACK(_filebrowser_do_hide_add), dialog);
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1030 handlerid_activate = g_signal_connect(chooser, "file-activated", G_CALLBACK(_filebrowser_add_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1031 handlerid_do_activate = g_signal_connect_after(chooser,"file_activated", G_CALLBACK(_filebrowser_do_hide_add), dialog);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1032 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1033
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1034 gtk_window_present(GTK_WINDOW(dialog));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1035 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1036
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1037 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1038 * Derived from Beep Media Player 0.9.6.1.
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1039 * Which is (C) 2003 - 2006 Milosz Derezynski &c
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1040 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1041 * Although I changed it quite a bit. -nenolod
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1042 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1043 static void filebrowser_changed_classic(GtkFileSelection * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1044 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1045 GList *list;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1046 GList *node;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1047 char *filename = (char *)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1048 gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1049 GtkListStore *store;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1050 GtkTreeIter iter;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1051
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1052 if ((list = input_scan_dir(filename)) != NULL) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1053 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1054 * We enter a directory that has been "hijacked" by an
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1055 * input-plugin. This is used by the CDDA plugin
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1056 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1057 store =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1058 GTK_LIST_STORE(gtk_tree_view_get_model
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1059 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1060 gtk_list_store_clear(store);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1061
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1062 node = list;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1063 while (node) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1064
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1065 gtk_list_store_append(store, &iter);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1066 gtk_list_store_set(store, &iter, 0, node->data, -1);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1067 g_free(node->data);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1068 node = g_list_next(node);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1069 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1070 g_list_free(list);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1071 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1072 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1073
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1074 static void filebrowser_entry_changed_classic(GtkEditable * entry, gpointer data)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1075 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1076 filebrowser_changed_classic(GTK_FILE_SELECTION(data));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1077 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1078
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1079 gboolean util_filebrowser_is_dir_classic(GtkFileSelection * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1080 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1081 char *text;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1082 struct stat buf;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1083 gboolean retv = FALSE;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1084
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1085 text = g_strdup(gtk_file_selection_get_filename(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1086
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1087 if (stat(text, &buf) == 0 && S_ISDIR(buf.st_mode)) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1088 /* Selected directory */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1089 int len = strlen(text);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1090 if (len > 3 && !strcmp(text + len - 4, "/../")) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1091 if (len == 4)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1092 /* At the root already */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1093 *(text + len - 3) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1094 else {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1095 char *ptr;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1096 *(text + len - 4) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1097 ptr = strrchr(text, '/');
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1098 *(ptr + 1) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1099 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1100 } else if (len > 2 && !strcmp(text + len - 3, "/./"))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1101 *(text + len - 2) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1102 gtk_file_selection_set_filename(filesel, text);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1103 retv = TRUE;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1104 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1105 g_free(text);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1106 return retv;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1107 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1108
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1109 static void filebrowser_add_files_classic(gchar ** files,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1110 GtkFileSelection * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1111 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1112 int ctr = 0;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1113 char *ptr;
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
1114 Playlist *playlist = playlist_get_active();
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1115
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1116 if (GTK_IS_WIDGET(mainwin_jtf))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1117 gtk_widget_set_sensitive(mainwin_jtf, FALSE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1118
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1119 while (files[ctr] != NULL) {
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
1120 playlist_add(playlist, files[ctr++]);
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1121 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1122 playlistwin_update_list();
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1123
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1124 if (GTK_IS_WIDGET(mainwin_jtf))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1125 gtk_widget_set_sensitive(mainwin_jtf, TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1126
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1127 gtk_label_get(GTK_LABEL(GTK_BIN(filesel->history_pulldown)->child),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1128 &ptr);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1129
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1130 /* This will give an extra slash if the current dir is the root. */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1131 cfg.filesel_path = g_strconcat(ptr, "/", NULL);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1132 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1133
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1134 static void filebrowser_ok_classic(GtkWidget * w, GtkWidget * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1135 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1136 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1137
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1138 if (util_filebrowser_is_dir_classic(GTK_FILE_SELECTION(filesel)))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1139 return;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1140 files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1141 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1142 gtk_widget_destroy(filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1143 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1144
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1145 static void filebrowser_play_classic(GtkWidget * w, GtkWidget * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1146 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1147 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1148
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1149 if (util_filebrowser_is_dir_classic
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1150 (GTK_FILE_SELECTION(GTK_FILE_SELECTION(filesel))))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1151 return;
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
1152 playlist_clear(playlist_get_active());
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1153 files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1154 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1155 gtk_widget_destroy(filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1156 bmp_playback_initiate();
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1157 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1158
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1159 static void filebrowser_add_selected_files_classic(GtkWidget * w, gpointer data)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1160 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1161 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1162
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1163 GtkFileSelection *filesel = GTK_FILE_SELECTION(data);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1164 files = gtk_file_selection_get_selections(filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1165
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1166 filebrowser_add_files_classic(files, filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1167 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1168 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1169
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1170 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), "");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1171 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1172
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1173 static void filebrowser_add_all_files_classic(GtkWidget * w, gpointer data)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1174 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1175 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1176 GtkFileSelection *filesel;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1177
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1178 filesel = data;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1179 gtk_tree_selection_select_all(gtk_tree_view_get_selection
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1180 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1181 files = gtk_file_selection_get_selections(filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1182 filebrowser_add_files_classic(files, filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1183 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1184 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1185 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), "");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1186 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1187
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1188 void
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1189 util_run_filebrowser_classic(gboolean play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1190 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1191 static GtkWidget *dialog;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1192 GtkWidget *button_add_selected, *button_add_all, *button_close,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1193 *button_add;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1194 char *title;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1195
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1196 if (dialog != NULL) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1197 gtk_window_present(GTK_WINDOW(dialog));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1198 return;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1199 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1200
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1201 if (play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1202 title = _("Play files");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1203 else
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1204 title = _("Load files");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1205
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1206 dialog = gtk_file_selection_new(title);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1207
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1208 gtk_file_selection_set_select_multiple
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1209 (GTK_FILE_SELECTION(dialog), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1210
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1211 if (cfg.filesel_path)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1212 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1213 cfg.filesel_path);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1214
1907
d7301ba54f70 [svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents: 1905
diff changeset
1215 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog));
d7301ba54f70 [svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents: 1905
diff changeset
1216 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
d7301ba54f70 [svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents: 1905
diff changeset
1217
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1218 gtk_widget_hide(GTK_FILE_SELECTION(dialog)->ok_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1219 gtk_widget_destroy(GTK_FILE_SELECTION(dialog)->cancel_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1220
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1221 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1222 * The mnemonics are quite unorthodox, but that should guarantee they're unique in any locale
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1223 * plus kinda easy to use
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1224 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1225 button_add_selected =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1226 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add selected",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1227 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1228 gtk_button_set_use_underline(GTK_BUTTON(button_add_selected), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1229 g_signal_connect(G_OBJECT(button_add_selected), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1230 G_CALLBACK(filebrowser_add_selected_files_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1231
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1232 button_add_all =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1233 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add all",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1234 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1235 gtk_button_set_use_underline(GTK_BUTTON(button_add_all), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1236 g_signal_connect(G_OBJECT(button_add_all), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1237 G_CALLBACK(filebrowser_add_all_files_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1238
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1239 if (play_button) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1240 button_add =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1241 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_MEDIA_PLAY,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1242 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1243 gtk_button_set_use_stock(GTK_BUTTON(button_add), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1244 g_signal_connect(G_OBJECT(button_add), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1245 G_CALLBACK(filebrowser_play_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1246 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1247 "clicked", G_CALLBACK(filebrowser_play_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1248 } else {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1249 button_add =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1250 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_ADD,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1251 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1252 gtk_button_set_use_stock(GTK_BUTTON(button_add), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1253 g_signal_connect(G_OBJECT(button_add), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1254 G_CALLBACK(filebrowser_ok_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1255 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1256 "clicked", G_CALLBACK(filebrowser_ok_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1257 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1258
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1259 button_close =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1260 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1261 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1262 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1263 g_signal_connect_swapped(G_OBJECT(button_close), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1264 G_CALLBACK(gtk_widget_destroy),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1265 G_OBJECT(dialog));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1266
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1267 gtk_widget_set_size_request(dialog, 600, 450);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1268 gtk_widget_realize(dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1269
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1270 g_signal_connect(G_OBJECT
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1271 (GTK_FILE_SELECTION(dialog)->history_pulldown),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1272 "changed", G_CALLBACK(filebrowser_entry_changed_classic),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1273 dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1274
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1275 g_signal_connect(G_OBJECT(dialog), "destroy",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1276 G_CALLBACK(gtk_widget_destroyed), &dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1277
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1278 filebrowser_changed_classic(GTK_FILE_SELECTION(dialog));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1279
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1280 gtk_widget_show(dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1281 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1282
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1283 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1284 * util_run_filebrowser(gboolean play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1285 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1286 * Inputs:
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1287 * - whether or not a play button should be used
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1288 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1289 * Outputs:
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1290 * - none
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1291 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1292 * Side Effects:
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1293 * - either a GTK1 or a GTK2 fileselector is launched
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1294 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1295 void
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1296 util_run_filebrowser(gboolean play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1297 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1298 if (!cfg.use_xmms_style_fileselector)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1299 util_run_filebrowser_gtk2style(play_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1300 else
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1301 util_run_filebrowser_classic(play_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1302 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1303
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1304 GdkFont *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1305 util_font_load(const gchar * name)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1306 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1307 GdkFont *font;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1308 PangoFontDescription *desc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1309
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1310 desc = pango_font_description_from_string(name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1311 font = gdk_font_from_description(desc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1312
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1313 return font;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1314 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1315
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1316 #ifdef ENABLE_NLS
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1317 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1318 bmp_menu_translate(const gchar * path, gpointer func_data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1319 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1320 gchar *translation = gettext(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1321
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1322 if (!translation || *translation != '/') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1323 g_warning("Bad translation for menupath: %s", path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1324 translation = (gchar *) path;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1325 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1326
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1327 return translation;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1328 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1329 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1330
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1331 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1332 util_set_cursor(GtkWidget * window)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1333 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1334 static GdkCursor *cursor = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1335
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1336 if (!window) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1337 if (cursor) {
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 625
diff changeset
1338 gdk_cursor_unref(cursor);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1339 cursor = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1340 }
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 625
diff changeset
1341
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1342 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1343 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1344
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1345 if (!cursor)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1346 cursor = gdk_cursor_new(GDK_LEFT_PTR);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1347
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1348 gdk_window_set_cursor(window->window, cursor);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1349 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1350
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1351 /* text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1352 * Mattis et al */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1353 gboolean
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1354 text_get_extents(const gchar * fontname,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1355 const gchar * text,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1356 gint * width, gint * height, gint * ascent, gint * descent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1357 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1358 PangoFontDescription *font_desc;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1359 PangoLayout *layout;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1360 PangoRectangle rect;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1361
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1362 g_return_val_if_fail(fontname != NULL, FALSE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1363 g_return_val_if_fail(text != NULL, FALSE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1364
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1365 /* FIXME: resolution */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1366 layout = gtk_widget_create_pango_layout(GTK_WIDGET(mainwin), text);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1367
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1368 font_desc = pango_font_description_from_string(fontname);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1369 pango_layout_set_font_description(layout, font_desc);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1370 pango_font_description_free(font_desc);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1371 pango_layout_get_pixel_extents(layout, NULL, &rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1372
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1373 if (width)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1374 *width = rect.width;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1375 if (height)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1376 *height = rect.height;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1377
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1378 if (ascent || descent) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1379 PangoLayoutIter *iter;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1380 PangoLayoutLine *line;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1381
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1382 iter = pango_layout_get_iter(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1383 line = pango_layout_iter_get_line(iter);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1384 pango_layout_iter_free(iter);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1385
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1386 pango_layout_line_get_pixel_extents(line, NULL, &rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1387
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1388 if (ascent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1389 *ascent = PANGO_ASCENT(rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1390 if (descent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1391 *descent = -PANGO_DESCENT(rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1392 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1393
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1394 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1395
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1396 return TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1397 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1398
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1399 /* counts number of digits in a gint */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1400 guint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1401 gint_count_digits(gint n)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1402 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1403 guint count = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1404
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1405 n = ABS(n);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1406 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1407 count++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1408 n /= 10;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1409 } while (n > 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1410
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1411 return count;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1412 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1413
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1414 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1415 str_twenty_to_space(gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1416 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1417 gchar *match, *match_end;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1418
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1419 g_return_val_if_fail(str != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1420
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1421 while ((match = strstr(str, "%20"))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1422 match_end = match + 3;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1423 *match++ = ' ';
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1424 while (*match_end)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1425 *match++ = *match_end++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1426 *match = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1427 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1428
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1429 return str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1430 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1431
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1432 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1433 str_replace_char(gchar * str, gchar old, gchar new)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1434 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1435 gchar *match;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1436
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1437 g_return_val_if_fail(str != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1438
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1439 match = str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1440 while ((match = strchr(match, old)))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1441 *match = new;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1442
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1443 return str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1444 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1445
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1446 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1447 str_append(gchar * str, const gchar * add_str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1448 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1449 return str_replace(str, g_strconcat(str, add_str, NULL));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1450 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1451
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1452 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1453 str_replace(gchar * str, gchar * new_str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1454 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1455 g_free(str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1456 return new_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1457 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1458
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1459 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1460 str_replace_in(gchar ** str, gchar * new_str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1461 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1462 *str = str_replace(*str, new_str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1463 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1464
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1465
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1466 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1467 str_has_prefix_nocase(const gchar * str, const gchar * prefix)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1468 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1469 return (strncasecmp(str, prefix, strlen(prefix)) == 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1470 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1471
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1472 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1473 str_has_suffix_nocase(const gchar * str, const gchar * suffix)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1474 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1475 return (strcasecmp(str + strlen(str) - strlen(suffix), suffix) == 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1476 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1477
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1478 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1479 str_has_suffixes_nocase(const gchar * str, gchar * const *suffixes)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1480 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1481 gchar *const *suffix;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1482
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1483 g_return_val_if_fail(str != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1484 g_return_val_if_fail(suffixes != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1485
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1486 for (suffix = suffixes; *suffix; suffix++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1487 if (str_has_suffix_nocase(str, *suffix))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1488 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1489
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1490 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1491 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1492
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1493 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1494 str_to_utf8_fallback(const gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1495 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1496 gchar *out_str, *convert_str, *chr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1497
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1498 /* NULL in NULL out */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1499 if (!str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1500 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1501
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1502 convert_str = g_strdup(str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1503 for (chr = convert_str; *chr; chr++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1504 if (*chr & 0x80)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1505 *chr = '?';
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1506 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1507
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1508 out_str = g_strconcat(convert_str, _(" (invalid UTF-8)"), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1509 g_free(convert_str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1510
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1511 return out_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1512 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1513
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1514 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1515 filename_to_utf8(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1516 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1517 gchar *out_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1518
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1519 /* NULL in NULL out */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1520 if (!filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1521 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1522
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1523 if ((out_str = g_filename_to_utf8(filename, -1, NULL, NULL, NULL)))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1524 return out_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1525
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1526 return str_to_utf8_fallback(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1527 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1528
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1529 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1530 str_to_utf8(const gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1531 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1532 gchar *out_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1533
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1534 /* NULL in NULL out */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1535 if (!str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1536 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1537
1324
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1538 /* Note: Currently, playlist calls this function repeatedly, even
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1539 * if the string is already converted into utf-8.
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1540 * chardet_to_utf8() would convert a valid utf-8 string into a
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1541 * different utf-8 string, if fallback encodings were supplied and
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1542 * the given string could be treated as a string in one of fallback
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1543 * encodings. To avoid this, the order of evaluation has been
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1544 * changed. (It might cause a drawback?)
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1545 */
2015
200970e7a3b1 [svn] - run chardet against even valid UTF-8 strings, as they may be non-UTF-8
nenolod
parents: 1972
diff changeset
1546 /* chardet encoding detector */
200970e7a3b1 [svn] - run chardet against even valid UTF-8 strings, as they may be non-UTF-8
nenolod
parents: 1972
diff changeset
1547 if ((out_str = chardet_to_utf8(str, strlen(str), NULL, NULL, NULL)))
200970e7a3b1 [svn] - run chardet against even valid UTF-8 strings, as they may be non-UTF-8
nenolod
parents: 1972
diff changeset
1548 return out_str;
200970e7a3b1 [svn] - run chardet against even valid UTF-8 strings, as they may be non-UTF-8
nenolod
parents: 1972
diff changeset
1549
1324
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1550 /* already UTF-8? */
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1551 if (g_utf8_validate(str, -1, NULL))
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1552 return g_strdup(str);
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1553
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1554 /* assume encoding associated with locale */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1555 if ((out_str = g_locale_to_utf8(str, -1, NULL, NULL, NULL)))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1556 return out_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1557
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1558 /* all else fails, we mask off character codes >= 128,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1559 replace with '?' */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1560 return str_to_utf8_fallback(str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1561 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1562
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1563
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1564 const gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1565 str_skip_chars(const gchar * str, const gchar * chars)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1566 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1567 while (strchr(chars, *str))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1568 str++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1569 return str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1570 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1571
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1572 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1573 convert_title_text(gchar * title)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1574 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1575 g_return_val_if_fail(title != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1576
2019
d3a62e1075e2 [svn] Allow \ to / conversion to be switched on & off, by external contributor Chris Kehler <cbkehler@sympatico.ca>.
chainsaw
parents: 2015
diff changeset
1577 if (cfg.convert_slash)
d3a62e1075e2 [svn] Allow \ to / conversion to be switched on & off, by external contributor Chris Kehler <cbkehler@sympatico.ca>.
chainsaw
parents: 2015
diff changeset
1578 str_replace_char(title, '\\', '/');
d3a62e1075e2 [svn] Allow \ to / conversion to be switched on & off, by external contributor Chris Kehler <cbkehler@sympatico.ca>.
chainsaw
parents: 2015
diff changeset
1579
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1580 if (cfg.convert_underscore)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1581 str_replace_char(title, '_', ' ');
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1582
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1583 if (cfg.convert_twenty)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1584 str_twenty_to_space(title);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1585
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1586 return title;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1587 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1588
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1589
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1590 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1591 dir_foreach(const gchar * path, DirForeachFunc function,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1592 gpointer user_data, GError ** error)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1593 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1594 GError *error_out = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1595 GDir *dir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1596 const gchar *entry;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1597 gchar *entry_fullpath;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1598
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1599 if (!(dir = g_dir_open(path, 0, &error_out))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1600 g_propagate_error(error, error_out);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1601 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1602 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1603
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1604 while ((entry = g_dir_read_name(dir))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1605 entry_fullpath = g_build_filename(path, entry, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1606
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1607 if ((*function) (entry_fullpath, entry, user_data)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1608 g_free(entry_fullpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1609 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1610 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1611
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1612 g_free(entry_fullpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1613 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1614
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1615 g_dir_close(dir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1616
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1617 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1618 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1619
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1620 GtkWidget *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1621 make_filebrowser(const gchar * title,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1622 gboolean save)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1623 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1624 GtkWidget *dialog;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1625 GtkWidget *button;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1626 GtkWidget *button_close;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1627
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1628 g_return_val_if_fail(title != NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1629
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1630 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1631 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1632 if (save)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1633 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1634 GTK_FILE_CHOOSER_ACTION_SAVE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1635
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1636 if (!save)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1637 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1638
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1639 g_signal_connect(dialog, "destroy",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1640 G_CALLBACK(gtk_widget_destroyed), &dialog);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1641
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1642 button_close = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1643 GTK_RESPONSE_REJECT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1644 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1645 GTK_WIDGET_SET_FLAGS(button_close, GTK_CAN_DEFAULT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1646 g_signal_connect_swapped(button_close, "clicked",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1647 G_CALLBACK(gtk_widget_destroy), dialog);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1648
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1649 button = gtk_dialog_add_button(GTK_DIALOG(dialog), save ?
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1650 GTK_STOCK_SAVE : GTK_STOCK_OPEN,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1651 GTK_RESPONSE_ACCEPT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1652 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1653 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1654 gtk_window_set_default(GTK_WINDOW(dialog), button);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1655
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1656 gtk_widget_show(dialog);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1657
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1658 return dialog;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1659 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1660
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1661
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1662 GtkItemFactory *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1663 create_menu(GtkItemFactoryEntry *entries,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1664 guint n_entries,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1665 GtkAccelGroup *accel)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1666 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1667 GtkItemFactory *menu;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1668
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1669 menu = gtk_item_factory_new(GTK_TYPE_MENU, "<Main>", accel);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1670 gtk_item_factory_set_translate_func(menu, bmp_menu_translate, NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1671 NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1672 gtk_item_factory_create_items(menu, n_entries, entries, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1673
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1674 return menu;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1675 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1676
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1677
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1678 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1679 make_submenu(GtkItemFactory *menu,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1680 const gchar *item_path,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1681 GtkItemFactory *submenu)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1682 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1683 GtkWidget *item, *menu_;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1684
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1685 item = gtk_item_factory_get_widget(menu, item_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1686 menu_ = gtk_item_factory_get_widget(submenu, "");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1687 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu_);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1688 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1689
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1690
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1691 gchar *chardet_to_utf8(const gchar *str, gssize len,
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1692 gsize *arg_bytes_read, gsize *arg_bytes_write, GError **arg_error)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1693 {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1694 #ifdef USE_CHARDET
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1695 char *det = NULL, *encoding = NULL;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1696 #endif
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1697 gchar *ret = NULL;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1698 gsize *bytes_read, *bytes_write;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1699 GError **error;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1700 gsize my_bytes_read, my_bytes_write;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1701
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1702 bytes_read = arg_bytes_read ? arg_bytes_read : &my_bytes_read;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1703 bytes_write = arg_bytes_write ? arg_bytes_write : &my_bytes_write;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1704 error = arg_error ? arg_error : NULL;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1705
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1706 #ifdef USE_CHARDET
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1707 if(cfg.chardet_detector)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1708 det = cfg.chardet_detector;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1709
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1710 if(det){
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1711 if(!strncasecmp("japanese", det, sizeof("japanese"))) {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1712 encoding = (char *)guess_jp(str, strlen(str));
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1713 if (!encoding)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1714 goto fallback;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1715 } else if(!strncasecmp("taiwanese", det, sizeof("taiwanese"))) {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1716 encoding = (char *)guess_tw(str, strlen(str));
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1717 if (!encoding)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1718 goto fallback;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1719 } else if(!strncasecmp("chinese", det, sizeof("chinese"))) {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1720 encoding = (char *)guess_cn(str, strlen(str));
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1721 if (!encoding)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1722 goto fallback;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1723 } else if(!strncasecmp("korean", det, sizeof("korean"))) {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1724 encoding = (char *)guess_kr(str, strlen(str));
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1725 if (!encoding)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1726 goto fallback;
1613
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1727 } else if(!strncasecmp("russian", det, sizeof("russian"))) {
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1728 rcd_russian_charset res = rcdGetRussianCharset(str, strlen(str));
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1729 switch(res) {
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1730 case RUSSIAN_CHARSET_WIN:
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1731 encoding = "CP1251";
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1732 break;
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1733 case RUSSIAN_CHARSET_ALT:
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1734 encoding = "CP866";
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1735 break;
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1736 case RUSSIAN_CHARSET_KOI:
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1737 encoding = "KOI8-R";
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1738 break;
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1739 case RUSSIAN_CHARSET_UTF8:
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1740 encoding = "UTF-8";
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1741 break;
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1742 }
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1743 if (!encoding)
9becbe564217 [svn] - chardet patch for Russian language witten by Valentine Sinitsyn.
yaz
parents: 1459
diff changeset
1744 goto fallback;
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1745 #ifdef HAVE_UDET
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1746 } else if (!strncasecmp("universal", det, sizeof("universal"))) {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1747 encoding = (char *)detectCharset((char *)str, strlen(str));
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1748 if (!encoding)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1749 goto fallback;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1750 #endif
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1751 } else /* none, invalid */
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1752 goto fallback;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1753
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1754 ret = g_convert(str, len, "UTF-8", encoding, bytes_read, bytes_write, error);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1755 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1756
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1757 fallback:
1123
170f9b68dd03 [svn] The fallback label is not used unless detection is defined. Move endif down to reflect that.
chainsaw
parents: 1106
diff changeset
1758 #endif
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1759 if(!ret && cfg.chardet_fallback){
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1760 gchar **encs=NULL, **enc=NULL;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1761 encs = g_strsplit_set(cfg.chardet_fallback, " ,:;|/", 0);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1762
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1763 if(encs){
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1764 enc = encs;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1765 for(enc=encs; *enc ; enc++){
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1766 ret = g_convert(str, len, "UTF-8", *enc, bytes_read, bytes_write, error);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1767 if(len == *bytes_read){
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1768 break;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1769 }
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1770 }
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1771 g_strfreev(encs);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1772 }
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1773 }
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1774
1324
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1775 #ifdef USE_CHARDET
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1776 /* many tag libraries return 2byte latin1 utf8 character as
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1777 converted 8bit iso-8859-1 character, if they are asked to return
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1778 latin1 string.
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1779 */
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1780 if(!ret){
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1781 ret = g_convert(str, len, "UTF-8", "ISO-8859-1", bytes_read, bytes_write, error);
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1782 }
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1783 #endif
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1784
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1785 if(ret){
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1786 if(g_utf8_validate(ret, -1, NULL))
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1787 return ret;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1788 else {
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1789 g_free(ret);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1790 ret = NULL;
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1791 }
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1792 }
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1793
1324
99454d030722 [svn] try to avoid malconversion of latin1 character when chardet has been enabled.
yaz
parents: 1193
diff changeset
1794 return NULL; /* if I have no idea, return NULL. */
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1067
diff changeset
1795 }
1851
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1796
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1797 /*
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1798 * Resizes a GDK pixmap.
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1799 */
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1800 GdkPixmap *audacious_pixmap_resize(GdkWindow *src, GdkGC *src_gc, GdkPixmap *in, gint width, gint height)
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1801 {
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1802 GdkPixmap *out;
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1803 gint owidth, oheight;
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1804
1887
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1805 g_return_val_if_fail(src != NULL, NULL);
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1806 g_return_val_if_fail(src_gc != NULL, NULL);
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1807 g_return_val_if_fail(in != NULL, NULL);
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1808 g_return_val_if_fail(width > 0 && height > 0, NULL);
1851
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1809
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1810 gdk_drawable_get_size(in, &owidth, &oheight);
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1811
1852
01103f911aa5 [svn] - avoid unnecessary resizing
nenolod
parents: 1851
diff changeset
1812 if (oheight == height && owidth == width)
1887
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1813 return NULL;
1852
01103f911aa5 [svn] - avoid unnecessary resizing
nenolod
parents: 1851
diff changeset
1814
1851
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1815 out = gdk_pixmap_new(src, width, height, -1);
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1816
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1817 gdk_draw_rectangle(out, src_gc, TRUE, 0, 0, width, height);
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1818
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1819 gdk_window_copy_area(out, src_gc, 0, 0, in, 0, 0, owidth, oheight);
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1820 g_object_unref(src);
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1821
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1822 return out;
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1823 }
1938
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1824
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1825 GdkImage *create_dblsize_image(GdkImage * img)
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1826 {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1827 GdkImage *dblimg;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1828 register guint x, y;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1829
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1830 /*
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1831 * This needs to be optimized
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1832 */
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1833
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1834 dblimg =
1972
edc01e85648d [svn] - in particular X environment, double size caused a bad match X error.
yaz
parents: 1938
diff changeset
1835 gdk_image_new(GDK_IMAGE_NORMAL, gdk_visual_get_system(),
1938
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1836 img->width << 1, img->height << 1);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1837 if (dblimg->bpp == 1) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1838 register guint8 *srcptr, *ptr, *ptr2, pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1839
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1840 srcptr = GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1841 ptr = GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1842 ptr2 = ptr + dblimg->bpl;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1843
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1844 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1845 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1846 pix = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1847 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1848 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1849 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1850 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1851 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1852 srcptr += img->bpl - img->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1853 ptr += (dblimg->bpl << 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1854 ptr2 += (dblimg->bpl << 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1855 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1856 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1857 if (dblimg->bpp == 2) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1858 guint16 *srcptr, *ptr, *ptr2, pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1859
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1860 srcptr = (guint16 *) GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1861 ptr = (guint16 *) GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1862 ptr2 = ptr + (dblimg->bpl >> 1);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1863
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1864 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1865 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1866 pix = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1867 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1868 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1869 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1870 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1871 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1872 srcptr += (img->bpl >> 1) - img->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1873 ptr += (dblimg->bpl) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1874 ptr2 += (dblimg->bpl) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1875 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1876 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1877 if (dblimg->bpp == 3) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1878 register guint8 *srcptr, *ptr, *ptr2, pix1, pix2, pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1879
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1880 srcptr = GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1881 ptr = GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1882 ptr2 = ptr + dblimg->bpl;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1883
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1884 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1885 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1886 pix1 = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1887 pix2 = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1888 pix3 = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1889 *ptr++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1890 *ptr++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1891 *ptr++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1892 *ptr++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1893 *ptr++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1894 *ptr++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1895 *ptr2++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1896 *ptr2++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1897 *ptr2++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1898 *ptr2++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1899 *ptr2++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1900 *ptr2++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1901
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1902 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1903 srcptr += img->bpl - (img->width * 3);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1904 ptr += (dblimg->bpl << 1) - (dblimg->width * 3);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1905 ptr2 += (dblimg->bpl << 1) - (dblimg->width * 3);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1906 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1907 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1908 if (dblimg->bpp == 4) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1909 register guint32 *srcptr, *ptr, *ptr2, pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1910
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1911 srcptr = (guint32 *) GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1912 ptr = (guint32 *) GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1913 ptr2 = ptr + (dblimg->bpl >> 2);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1914
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1915 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1916 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1917 pix = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1918 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1919 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1920 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1921 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1922 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1923 srcptr += (img->bpl >> 2) - img->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1924 ptr += (dblimg->bpl >> 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1925 ptr2 += (dblimg->bpl >> 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1926 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1927 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1928 return dblimg;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1929 }
2074
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1930
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1931 /* URL-decode a file: URL path, return NULL if it's not what we expect */
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1932 gchar *
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1933 xmms_urldecode_path(const gchar * encoded_path)
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1934 {
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1935 const gchar *cur, *ext;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1936 gchar *path, *tmp;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1937 gint realchar;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1938
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1939 if (!encoded_path)
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1940 return NULL;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1941
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1942 if (!str_has_prefix_nocase(encoded_path, "file:"))
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1943 return NULL;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1944
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1945 cur = encoded_path + 5;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1946
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1947 if (str_has_prefix_nocase(cur, "//localhost"))
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1948 cur += 11;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1949
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1950 if (*cur == '/')
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1951 while (cur[1] == '/')
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1952 cur++;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1953
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1954 tmp = g_malloc0(strlen(cur) + 1);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1955
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1956 while ((ext = strchr(cur, '%')) != NULL) {
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1957 strncat(tmp, cur, ext - cur);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1958 ext++;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1959 cur = ext + 2;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1960 if (!sscanf(ext, "%2x", &realchar)) {
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1961 /* Assume it is a literal '%'. Several file
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1962 * managers send unencoded file: urls on drag
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1963 * and drop. */
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1964 realchar = '%';
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1965 cur -= 2;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1966 }
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1967 tmp[strlen(tmp)] = realchar;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1968 }
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1969
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1970 path = g_strconcat(tmp, cur, NULL);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1971 g_free(tmp);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1972 return path;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1973 }
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1974