annotate audacious/util.c @ 2235:72d593e5d7e4 trunk

[svn] - remove everything relating to GtkItemFactory.
author nenolod
date Tue, 02 Jan 2007 21:52:19 -0800
parents 894f7aa46f83
children 329fb2453c87
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 * find <file> in directory <dirname> or subdirectories. return
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 * pointer to complete filename which has to be freed by calling
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 * "g_free()" after use. Returns NULL if file could not be found.
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 typedef struct {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 const gchar *to_match;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 gchar *match;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 gboolean found;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 } FindFileContext;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 find_file_func(const gchar * path, const gchar * basename, gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 FindFileContext *context = data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 if (strlen(path) > FILENAME_MAX) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 g_warning("Ignoring path: name too long (%s)", path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 if (!strcasecmp(basename, context->to_match)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 context->match = g_strdup(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 context->found = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 else if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 dir_foreach(path, find_file_func, context, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 if (context->found)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 return TRUE;
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 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 find_file_recursively(const gchar * path, const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 FindFileContext context;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 context.to_match = filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 context.match = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 context.found = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 dir_foreach(path, find_file_func, &context, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 return context.match;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 typedef enum {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 ARCHIVE_UNKNOWN = 0,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 ARCHIVE_DIR,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 ARCHIVE_TAR,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 ARCHIVE_TGZ,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 ARCHIVE_ZIP,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 ARCHIVE_TBZ2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 } ArchiveType;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 typedef gchar *(*ArchiveExtractFunc) (const gchar *, const gchar *);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 typedef struct {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 ArchiveType type;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 const gchar *ext;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 } ArchiveExtensionType;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 static ArchiveExtensionType archive_extensions[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 {ARCHIVE_TAR, ".tar"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 {ARCHIVE_ZIP, ".wsz"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 {ARCHIVE_ZIP, ".zip"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 {ARCHIVE_TGZ, ".tar.gz"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 {ARCHIVE_TGZ, ".tgz"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 {ARCHIVE_TBZ2, ".tar.bz2"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 {ARCHIVE_TBZ2, ".bz2"},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 {ARCHIVE_UNKNOWN, NULL}
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 static gchar *archive_extract_tar(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 static gchar *archive_extract_zip(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 static gchar *archive_extract_tgz(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 static gchar *archive_extract_tbz2(const gchar * archive, const gchar * dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 static ArchiveExtractFunc archive_extract_funcs[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 archive_extract_tar,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 archive_extract_tgz,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 archive_extract_zip,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 archive_extract_tbz2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 /* FIXME: these functions can be generalised into a function using a
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 * command lookup table */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 static const gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 get_tar_command(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 static const gchar *command = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 if (!command) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 if (!(command = getenv("TARCMD")))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 command = "tar";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 return command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 static const gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 get_unzip_command(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 static const gchar *command = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 if (!command) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 if (!(command = getenv("UNZIPCMD")))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 command = "unzip";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 return command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 archive_extract_tar(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 return g_strdup_printf("%s >/dev/null xf \"%s\" -C %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 get_tar_command(), archive, dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 archive_extract_zip(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 return g_strdup_printf("%s >/dev/null -o -j \"%s\" -d %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 get_unzip_command(), archive, dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 archive_extract_tgz(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 return g_strdup_printf("%s >/dev/null xzf \"%s\" -C %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 get_tar_command(), archive, dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 static gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 archive_extract_tbz2(const gchar * archive, const gchar * dest)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 return g_strdup_printf("bzip2 -dc \"%s\" | %s >/dev/null xf - -C %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 archive, get_tar_command(), dest);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 ArchiveType
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 archive_get_type(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 gint i = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 if (g_file_test(filename, G_FILE_TEST_IS_DIR))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 return ARCHIVE_DIR;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 while (archive_extensions[i].ext) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 if (g_str_has_suffix(filename, archive_extensions[i].ext)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 return archive_extensions[i].type;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 i++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 return ARCHIVE_UNKNOWN;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 file_is_archive(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 return (archive_get_type(filename) > ARCHIVE_DIR);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 archive_basename(const gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 gint i = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 while (archive_extensions[i].ext) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 if (str_has_suffix_nocase(str, archive_extensions[i].ext)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 const gchar *end = g_strrstr(str, archive_extensions[i].ext);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 if (end) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 return g_strndup(str, end - str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 i++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 decompress_archive
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 Decompresses the archive "filename" to a temporary directory,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 returns the path to the temp dir, or NULL if failed,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 watch out tho, doesn't actually check if the system command succeeds :-|
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 archive_decompress(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 gchar *tmpdir, *cmd, *escaped_filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 ArchiveType type;
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
277 mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 if ((type = archive_get_type(filename)) <= ARCHIVE_DIR)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
282 #ifdef HAVE_MKDTEMP
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
283 tmpdir = g_build_filename(g_get_tmp_dir(), "audacious.XXXXXXXX", NULL);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 if (!mkdtemp(tmpdir)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 g_free(tmpdir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 g_message("Unable to load skin: Failed to create temporary "
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 "directory: %s", g_strerror(errno));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 }
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
290 #else
1891
46576f74b3a1 [svn] - use rand() instead
nenolod
parents: 1890
diff changeset
291 tmpdir = g_strdup_printf("%s/audacious.%ld", g_get_tmp_dir(), rand());
1890
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
292 make_directory(tmpdir, mode755);
90d95cd7edb5 [svn] - remove mkdtemp().
nenolod
parents: 1887
diff changeset
293 #endif
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 escaped_filename = escape_shell_chars(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 cmd = archive_extract_funcs[type] (escaped_filename, tmpdir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 g_free(escaped_filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 if (!cmd) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 g_message("extraction function is NULL!");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 g_free(tmpdir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 system(cmd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 g_free(cmd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 return tmpdir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 #ifdef HAVE_FTS_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 del_directory(const gchar * dirname)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 gchar *const argv[2] = { (gchar *) dirname, NULL };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 FTS *fts;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 FTSENT *p;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 fts = fts_open(argv, FTS_PHYSICAL, (gint(*)())NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 while ((p = fts_read(fts))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 switch (p->fts_info) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324 case FTS_D:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 case FTS_DNR:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327 case FTS_ERR:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 case FTS_DP:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 rmdir(p->fts_accpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333 unlink(p->fts_accpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337 fts_close(fts);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 #else /* !HAVE_FTS */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 del_directory_func(const gchar * path, const gchar * basename,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 gpointer params)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 if (!strcmp(basename, ".") || !strcmp(path, ".."))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 dir_foreach(path, del_directory_func, NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 rmdir(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 unlink(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 del_directory(const gchar * path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 dir_foreach(path, del_directory_func, NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 rmdir(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 #endif /* ifdef HAVE_FTS */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 read_ini_string(const gchar * filename, const gchar * section,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 const gchar * key)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 {
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
373 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
374 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
375 gchar *ret_buffer = NULL;
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
376 gint found_section = 0, len = 0;
1193
03414b9d2507 [svn] filesize must be cached, otherwise lookup loop will crash.
yaz
parents: 1166
diff changeset
377 static gsize filesize = 0;
03414b9d2507 [svn] filesize must be cached, otherwise lookup loop will crash.
yaz
parents: 1166
diff changeset
378 gsize off = 0;
245
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
379 gchar *outbuf;
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
380 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
381 guint counter;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 if (!filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385
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
386 /*
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
387 * 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
388 * 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
389 * 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
390 * 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
391 *
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
392 * 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
393 * 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
394 * - 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
395 */
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
396 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
397 {
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
398 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
399 {
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
400 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
401 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
402 }
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
403
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
404 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
405 {
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
406 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
407 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
408 }
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
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
410 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
411 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
412
36e8431d8e19 [svn] - optimise for multiple lookups of a single INI file, by caching the contents of the INI file.
nenolod
parents: 1123
diff changeset
413 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
414 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415
245
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
416 /*
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
417 * 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
418 * 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
419 */
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
420 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
421 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
422
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
423 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
424 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
425 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
426 else
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
427 return NULL;
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
428
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
429 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
430
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
431 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
432 g_free(buffer);
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
433 buffer = outbuf;
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
434 } else {
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
435 g_free(outbuf);
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
436 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
437 }
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
438 }
1d8012046612 [svn] Convert UTF-16 (windows-1252) into something useful. Original patch by incomp@#audacious,
nenolod
parents: 86
diff changeset
439
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
440 while (!ret_buffer && off < filesize) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
441 while (off < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
442 (buffer[off] == '\r' || buffer[off] == '\n' ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
443 buffer[off] == ' ' || buffer[off] == '\t'))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
444 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 if (off >= filesize)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
446 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
447 if (buffer[off] == '[') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
448 gint slen = strlen(section);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
450 found_section = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
451 if (off + slen + 1 < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
452 !strncasecmp(section, &buffer[off], slen)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
453 off += slen;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
454 if (buffer[off] == ']') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
455 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
456 found_section = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
457 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
458 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
459 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
460 else if (found_section && off + strlen(key) < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
461 !strncasecmp(key, &buffer[off], strlen(key))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
462 off += strlen(key);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
463 while (off < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
464 (buffer[off] == ' ' || buffer[off] == '\t'))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
465 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
466 if (off >= filesize)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
467 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
468 if (buffer[off] == '=') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
469 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
470 while (off < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
471 (buffer[off] == ' ' || buffer[off] == '\t'))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
472 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
473 if (off >= filesize)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
474 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
475 len = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
476 while (off + len < filesize &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477 buffer[off + len] != '\r' &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478 buffer[off + len] != '\n' && buffer[off + len] != ';')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 len++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480 ret_buffer = g_strndup(&buffer[off], len);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481 off += len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 while (off < filesize && buffer[off] != '\r' && buffer[off] != '\n')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 off++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488 return ret_buffer;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491 GArray *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 string_to_garray(const gchar * str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494 GArray *array;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 gint temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496 const gchar *ptr = str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497 gchar *endptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499 array = g_array_new(FALSE, TRUE, sizeof(gint));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 for (;;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 temp = strtol(ptr, &endptr, 10);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502 if (ptr == endptr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504 g_array_append_val(array, temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505 ptr = endptr;
1717
837983bac90f [svn] Fixed a lot of warnings that only showed up on *BSD.
js
parents: 1653
diff changeset
506 while (!isdigit((int) *ptr) && (*ptr) != '\0')
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507 ptr++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 if (*ptr == '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511 return (array);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514 GArray *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 read_ini_array(const gchar * filename, const gchar * section,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516 const gchar * key)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518 gchar *temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 GArray *a;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521 if ((temp = read_ini_string(filename, section, key)) == NULL) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 g_free(temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 a = string_to_garray(temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526 g_free(temp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 return a;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531 glist_movedown(GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533 gpointer temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 if (g_list_next(list)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536 temp = list->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 list->data = list->next->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 list->next->data = temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
540 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543 glist_moveup(GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545 gpointer temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547 if (g_list_previous(list)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 temp = list->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549 list->data = list->prev->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550 list->prev->data = temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556 util_menu_position(GtkMenu * menu, gint * x, gint * y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 gboolean * push_in, gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559 GtkRequisition requisition;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560 gint screen_width;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561 gint screen_height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 MenuPos *pos = data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 gtk_widget_size_request(GTK_WIDGET(menu), &requisition);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566 screen_width = gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 screen_height = gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 *x = CLAMP(pos->x - 2, 0, MAX(0, screen_width - requisition.width));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 *y = CLAMP(pos->y - 2, 0, MAX(0, screen_height - requisition.height));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573 #define URL_HISTORY_MAX_SIZE 30
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576 util_add_url_callback(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 GtkEntry * entry)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 const gchar *text;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 text = gtk_entry_get_text(entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582 if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585 cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587 while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588 GList *node = g_list_last(cfg.url_history);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589 g_free(node->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590 cfg.url_history = g_list_delete_link(cfg.url_history, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594 GtkWidget *
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
595 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
596 GCallback enqueue_func)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597 {
2210
165a62fdb49e [svn] - improve the presentation of the URL entry dialog
nenolod
parents: 2184
diff changeset
598 GtkWidget *win, *vbox, *bbox, *enqueue, *ok, *cancel, *combo, *entry,
165a62fdb49e [svn] - improve the presentation of the URL entry dialog
nenolod
parents: 2184
diff changeset
599 *label;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 GList *url;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2227
649e3418aac2 [svn] - mark several tooltips in Preferences as translatable.
nenolod
parents: 2210
diff changeset
603 gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog"));
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604 gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606 gtk_window_set_default_size(GTK_WINDOW(win), 400, -1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 gtk_container_set_border_width(GTK_CONTAINER(win), 12);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609 vbox = gtk_vbox_new(FALSE, 10);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610 gtk_container_add(GTK_CONTAINER(win), vbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611
2210
165a62fdb49e [svn] - improve the presentation of the URL entry dialog
nenolod
parents: 2184
diff changeset
612 label = gtk_label_new(caption);
165a62fdb49e [svn] - improve the presentation of the URL entry dialog
nenolod
parents: 2184
diff changeset
613 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
165a62fdb49e [svn] - improve the presentation of the URL entry dialog
nenolod
parents: 2184
diff changeset
614 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
165a62fdb49e [svn] - improve the presentation of the URL entry dialog
nenolod
parents: 2184
diff changeset
615
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616 combo = gtk_combo_box_entry_new_text();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619 entry = gtk_bin_get_child(GTK_BIN(combo));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620 gtk_window_set_focus(GTK_WINDOW(win), entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 gtk_entry_set_text(GTK_ENTRY(entry), "");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
623 for (url = cfg.url_history; url; url = g_list_next(url))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), (const gchar *) url->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
625
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626 g_signal_connect(entry, "activate",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627 G_CALLBACK(util_add_url_callback),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 g_signal_connect(entry, "activate",
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
630 G_CALLBACK(ok_func),
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632 g_signal_connect_swapped(entry, "activate",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
636 bbox = gtk_hbutton_box_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640
86
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
641 ok = gtk_button_new_from_stock(GTK_STOCK_OPEN);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
642 g_signal_connect(ok, "clicked",
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
643 G_CALLBACK(util_add_url_callback), entry);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
644 g_signal_connect(ok, "clicked",
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
645 G_CALLBACK(ok_func), entry);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
646 g_signal_connect_swapped(ok, "clicked",
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
647 G_CALLBACK(gtk_widget_destroy),
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
648 win);
2d8234ea45e8 [svn] - Add a few things to the main menu.
nenolod
parents: 0
diff changeset
649 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
650
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651 enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652 gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 g_signal_connect(enqueue, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
655 G_CALLBACK(util_add_url_callback),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
656 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
657 g_signal_connect(enqueue, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
658 G_CALLBACK(enqueue_func),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
659 entry);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
660 g_signal_connect_swapped(enqueue, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
661 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
662 win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
663
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
664 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
665 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
666
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
667 g_signal_connect_swapped(cancel, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
668 G_CALLBACK(gtk_widget_destroy),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
669 win);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
670
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
671 gtk_widget_show_all(vbox);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
672
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
673 return win;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
674 }
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 filebrowser_add_files(GtkFileChooser * browser,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
678 GSList * files)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
679 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
680 GSList *cur;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
681 gchar *ptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
682 guint ctr = 0;
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
683 Playlist *playlist = playlist_get_active();
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
684
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
685 if (GTK_IS_WIDGET(mainwin_jtf))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
686 gtk_widget_set_sensitive(mainwin_jtf, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
687
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
688 for (cur = files; cur; cur = g_slist_next(cur)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
689
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
690 if (g_file_test(cur->data,G_FILE_TEST_IS_DIR)) {
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
691 playlist_add_dir(playlist, (const gchar *) cur->data);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
692 } else {
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
693 playlist_add(playlist, (const gchar *) cur->data);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
694 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
695
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
696 if (++ctr == 20) {
2140
299651a8f107 [svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents: 2105
diff changeset
697 playlistwin_update_list(playlist);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
698 ctr = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
699 while (gtk_events_pending() ) gtk_main_iteration();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
700 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
701 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
702
2140
299651a8f107 [svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents: 2105
diff changeset
703 playlistwin_update_list(playlist);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
704
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
705 if (GTK_IS_WIDGET(mainwin_jtf))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
706 gtk_widget_set_sensitive(mainwin_jtf, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
707
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
708 ptr = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
709
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
710 g_free(cfg.filesel_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
711 cfg.filesel_path = ptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
712 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
713
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
714 static void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
715 filebrowser_add(GtkFileChooser *browser)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
716 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
717 GSList *files;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
718
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
719 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
720
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
721 if (!files) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
722 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
723 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
724
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
725 filebrowser_add_files(browser, files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
726 g_slist_foreach(files, (GFunc) g_free, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
727 g_slist_free(files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
728 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
729
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
730 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
731 filebrowser_play(GtkFileChooser * browser)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
732 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
733 GSList *files;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
734
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
735 files = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
736
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
737 if (!files) return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
738
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
739 playlist_clear(playlist_get_active());
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
740
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
741 filebrowser_add_files(browser, files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
742 g_slist_foreach(files, (GFunc) g_free, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
743 g_slist_free(files);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
744
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2227
diff changeset
745 playback_initiate();
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
746 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
747
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
748
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
749 static void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
750 _filebrowser_add_gtk2(GtkWidget *widget,
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
751 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
752 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
753 filebrowser_add(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
754 gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
755 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
756
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
757 static void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
758 _filebrowser_play_gtk2(GtkWidget *widget, gpointer data)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
759 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
760 filebrowser_play(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
761 gtk_file_chooser_unselect_all(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
762 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
763
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
764 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
765 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
766 filebrowser_on_response(GtkFileChooser * browser,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
767 gint response,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
768 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
769 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
770 gtk_widget_hide(GTK_WIDGET(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
771 switch (response) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
772 case GTK_RESPONSE_OK:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
773 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
774 case GTK_RESPONSE_ACCEPT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
775 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
776 case GTK_RESPONSE_CLOSE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
777 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
778 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
779 gtk_widget_destroy(GTK_WIDGET(browser));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
780
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
781 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
782
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
783 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
784
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
785 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
786 _filebrowser_check_hide_add(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
787 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
788 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
789 cfg.close_dialog_add = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
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 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
793 _filebrowser_check_hide_open(GtkWidget * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
794 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
795 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
796 cfg.close_dialog_open = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
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
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
800
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
801 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
802 filebrowser_on_keypress(GtkWidget * browser,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
803 GdkEventKey * event,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
804 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
805 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
806 if (event->keyval == GDK_Escape) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
807 /* FIXME: this crashes BMP for some reason */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
808 /* g_signal_emit_by_name(browser, "delete-event"); */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
809 gtk_widget_hide(browser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
810 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
811 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
812
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
813 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
814 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
815
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
816 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
817 _filebrowser_do_hide_add(GtkWidget *widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
818 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
819 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
820 if (cfg.close_dialog_add)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
821 gtk_widget_hide(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
822 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
823
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
824 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
825 _filebrowser_do_hide_open(GtkWidget *widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
826 gpointer data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
827 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
828 if (cfg.close_dialog_open)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
829 gtk_widget_hide(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
830 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
831
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
832 void
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
833 util_run_filebrowser_gtk2style(gboolean play_button)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
834 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
835 static GladeXML *xml = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
836 static GtkWidget *dialog = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
837 static GtkWidget *chooser = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
838
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
839 static GtkWidget *button_add;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
840 static GtkWidget *button_select_all, *button_deselect_all;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
841 static GtkWidget *toggle;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
842
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
843 static gulong handlerid, handlerid_check, handlerid_do;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
844 static gulong handlerid_activate, handlerid_do_activate;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
845
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
846 if (!xml) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
847 /* FIXME: Creating a file chooser dialog manually using
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
848 libglade because there's no way to stop
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
849 GtkFileChooserDialog from resizing the buttons to the same
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
850 size. The long toggle button title causes the buttons to
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
851 turn unnecessarily elongated and fugly. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
852
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
853 GtkWidget *alignment;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
854
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
855 xml = glade_xml_new_or_die(_("Add/Open Files dialog"),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
856 DATA_DIR "/glade/addfiles.glade",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
857 NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
858 glade_xml_signal_autoconnect(xml);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
859
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
860 dialog = glade_xml_get_widget(xml, "add_files_dialog");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
861
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
862 /* FIXME: Creating file chooser widget here because libglade <= 2.4.0 does
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
863 not support GtkFileChooserWidget */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
864
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
865 chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
866 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
867
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
868 if (cfg.filesel_path)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
869 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
870 cfg.filesel_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
871
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
872 alignment = glade_xml_get_widget(xml, "alignment2");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
873 gtk_container_add(GTK_CONTAINER(alignment), chooser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
874
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
875 toggle = glade_xml_get_widget(xml, "close_on_action");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
876 button_select_all = glade_xml_get_widget(xml, "select_all");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
877 button_deselect_all = glade_xml_get_widget(xml, "deselect_all");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
878 button_add = glade_xml_get_widget(xml, "action");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
879
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
880 g_signal_connect_swapped(button_select_all, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
881 G_CALLBACK(gtk_file_chooser_select_all),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
882 chooser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
883 g_signal_connect_swapped(button_deselect_all, "clicked",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
884 G_CALLBACK(gtk_file_chooser_unselect_all),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
885 chooser);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
886
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
887 g_signal_connect(dialog, "key_press_event",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
888 G_CALLBACK(filebrowser_on_keypress),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
889 NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
890
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
891 gtk_widget_show_all(dialog);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
892 } /* !xml */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
893 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
894 g_signal_handler_disconnect(button_add, handlerid);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
895 g_signal_handler_disconnect(toggle, handlerid_check);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
896 g_signal_handler_disconnect(chooser, handlerid_activate);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
897 g_signal_handler_disconnect(button_add, handlerid_do);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
898 g_signal_handler_disconnect(chooser, handlerid_do_activate);
1752
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
899
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
900 if (cfg.refresh_file_list)
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
901 {
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
902 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
903 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
904
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
905 g_free(tmp);
be1c5774f675 [svn] - fix a memory leak in util_run_filebrowser()
nenolod
parents: 1717
diff changeset
906 }
0
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 if (play_button) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
910 gtk_window_set_title(GTK_WINDOW(dialog), _("Open Files"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
911
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
912 gtk_button_set_label(GTK_BUTTON(button_add), GTK_STOCK_OPEN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
913
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
914 gtk_button_set_label(GTK_BUTTON(toggle), _("Close dialog on Open"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
915 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), cfg.close_dialog_open);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
916
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
917 handlerid = g_signal_connect(button_add, "clicked", G_CALLBACK(_filebrowser_play_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
918 handlerid_check = g_signal_connect(toggle, "toggled", G_CALLBACK(_filebrowser_check_hide_open), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
919 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
920 handlerid_activate = g_signal_connect(chooser, "file-activated", G_CALLBACK(_filebrowser_play_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
921 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
922 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
923 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
924 gtk_window_set_title(GTK_WINDOW(dialog), _("Add Files"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
925
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
926 gtk_button_set_label(GTK_BUTTON(button_add), GTK_STOCK_ADD);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
927
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
928 gtk_button_set_label(GTK_BUTTON(toggle), _("Close dialog on Add"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
929 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), cfg.close_dialog_add);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
930
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
931 handlerid = g_signal_connect(button_add, "clicked", G_CALLBACK(_filebrowser_add_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
932 handlerid_check = g_signal_connect(toggle, "toggled", G_CALLBACK(_filebrowser_check_hide_add), NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
933 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
934 handlerid_activate = g_signal_connect(chooser, "file-activated", G_CALLBACK(_filebrowser_add_gtk2), chooser);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
935 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
936 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
937
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
938 gtk_window_present(GTK_WINDOW(dialog));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
939 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
940
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
941 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
942 * Derived from Beep Media Player 0.9.6.1.
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
943 * Which is (C) 2003 - 2006 Milosz Derezynski &c
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
944 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
945 * Although I changed it quite a bit. -nenolod
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
946 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
947 static void filebrowser_changed_classic(GtkFileSelection * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
948 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
949 GList *list;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
950 GList *node;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
951 char *filename = (char *)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
952 gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
953 GtkListStore *store;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
954 GtkTreeIter iter;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
955
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
956 if ((list = input_scan_dir(filename)) != NULL) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
957 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
958 * 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
959 * input-plugin. This is used by the CDDA plugin
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
960 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
961 store =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
962 GTK_LIST_STORE(gtk_tree_view_get_model
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
963 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
964 gtk_list_store_clear(store);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
965
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
966 node = list;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
967 while (node) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
968
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
969 gtk_list_store_append(store, &iter);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
970 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
971 g_free(node->data);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
972 node = g_list_next(node);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
973 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
974 g_list_free(list);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
975 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
976 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
977
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
978 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
979 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
980 filebrowser_changed_classic(GTK_FILE_SELECTION(data));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
981 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
982
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
983 gboolean util_filebrowser_is_dir_classic(GtkFileSelection * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
984 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
985 char *text;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
986 struct stat buf;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
987 gboolean retv = FALSE;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
988
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
989 text = g_strdup(gtk_file_selection_get_filename(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
990
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
991 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
992 /* Selected directory */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
993 int len = strlen(text);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
994 if (len > 3 && !strcmp(text + len - 4, "/../")) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
995 if (len == 4)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
996 /* At the root already */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
997 *(text + len - 3) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
998 else {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
999 char *ptr;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1000 *(text + len - 4) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1001 ptr = strrchr(text, '/');
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1002 *(ptr + 1) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1003 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1004 } else if (len > 2 && !strcmp(text + len - 3, "/./"))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1005 *(text + len - 2) = '\0';
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1006 gtk_file_selection_set_filename(filesel, text);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1007 retv = TRUE;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1008 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1009 g_free(text);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1010 return retv;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1011 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1012
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1013 static void filebrowser_add_files_classic(gchar ** files,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1014 GtkFileSelection * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1015 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1016 int ctr = 0;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1017 char *ptr;
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
1018 Playlist *playlist = playlist_get_active();
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1019
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1020 if (GTK_IS_WIDGET(mainwin_jtf))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1021 gtk_widget_set_sensitive(mainwin_jtf, FALSE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1022
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1023 while (files[ctr] != NULL) {
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
1024 playlist_add(playlist, files[ctr++]);
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1025 }
2140
299651a8f107 [svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents: 2105
diff changeset
1026 playlistwin_update_list(playlist);
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1027
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1028 if (GTK_IS_WIDGET(mainwin_jtf))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1029 gtk_widget_set_sensitive(mainwin_jtf, TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1030
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1031 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
1032 &ptr);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1033
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1034 /* 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
1035 cfg.filesel_path = g_strconcat(ptr, "/", NULL);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1036 }
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 static void filebrowser_ok_classic(GtkWidget * w, GtkWidget * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1039 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1040 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1041
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1042 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
1043 return;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1044 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
1045 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1046 gtk_widget_destroy(filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1047 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1048
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1049 static void filebrowser_play_classic(GtkWidget * w, GtkWidget * filesel)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1050 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1051 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1052
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1053 if (util_filebrowser_is_dir_classic
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1054 (GTK_FILE_SELECTION(GTK_FILE_SELECTION(filesel))))
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1055 return;
2087
bc47a2129067 [svn] - update these files
nenolod
parents: 2074
diff changeset
1056 playlist_clear(playlist_get_active());
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1057 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
1058 filebrowser_add_files_classic(files, GTK_FILE_SELECTION(filesel));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1059 gtk_widget_destroy(filesel);
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2227
diff changeset
1060 playback_initiate();
1905
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
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1063 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
1064 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1065 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1066
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1067 GtkFileSelection *filesel = GTK_FILE_SELECTION(data);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1068 files = gtk_file_selection_get_selections(filesel);
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 filebrowser_add_files_classic(files, filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1071 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
1072 (GTK_TREE_VIEW(filesel->file_list)));
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 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), "");
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
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1077 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
1078 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1079 gchar **files;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1080 GtkFileSelection *filesel;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1081
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1082 filesel = data;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1083 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
1084 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1085 files = gtk_file_selection_get_selections(filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1086 filebrowser_add_files_classic(files, filesel);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1087 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
1088 (GTK_TREE_VIEW(filesel->file_list)));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1089 gtk_entry_set_text(GTK_ENTRY(filesel->selection_entry), "");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1090 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1091
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1092 void
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1093 util_run_filebrowser_classic(gboolean play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1094 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1095 static GtkWidget *dialog;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1096 GtkWidget *button_add_selected, *button_add_all, *button_close,
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1097 *button_add;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1098 char *title;
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 if (dialog != NULL) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1101 gtk_window_present(GTK_WINDOW(dialog));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1102 return;
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1103 }
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 if (play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1106 title = _("Play files");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1107 else
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1108 title = _("Load files");
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1109
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1110 dialog = gtk_file_selection_new(title);
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 gtk_file_selection_set_select_multiple
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1113 (GTK_FILE_SELECTION(dialog), TRUE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1114
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1115 if (cfg.filesel_path)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1116 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1117 cfg.filesel_path);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1118
1907
d7301ba54f70 [svn] - remove useless fileop buttons from the GTK1-like dialog.
nenolod
parents: 1905
diff changeset
1119 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
1120 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
1121
1905
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1122 gtk_widget_hide(GTK_FILE_SELECTION(dialog)->ok_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1123 gtk_widget_destroy(GTK_FILE_SELECTION(dialog)->cancel_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1124
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1125 /*
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1126 * 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
1127 * plus kinda easy to use
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1128 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1129 button_add_selected =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1130 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add selected",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1131 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1132 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
1133 g_signal_connect(G_OBJECT(button_add_selected), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1134 G_CALLBACK(filebrowser_add_selected_files_classic), dialog);
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 button_add_all =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1137 gtk_dialog_add_button(GTK_DIALOG(dialog), "Add all",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1138 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1139 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
1140 g_signal_connect(G_OBJECT(button_add_all), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1141 G_CALLBACK(filebrowser_add_all_files_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1142
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1143 if (play_button) {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1144 button_add =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1145 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
1146 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1147 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
1148 g_signal_connect(G_OBJECT(button_add), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1149 G_CALLBACK(filebrowser_play_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1150 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
1151 "clicked", G_CALLBACK(filebrowser_play_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1152 } else {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1153 button_add =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1154 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
1155 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1156 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
1157 g_signal_connect(G_OBJECT(button_add), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1158 G_CALLBACK(filebrowser_ok_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1159 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
1160 "clicked", G_CALLBACK(filebrowser_ok_classic), dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1161 }
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 button_close =
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1164 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
1165 GTK_RESPONSE_NONE);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1166 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
1167 g_signal_connect_swapped(G_OBJECT(button_close), "clicked",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1168 G_CALLBACK(gtk_widget_destroy),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1169 G_OBJECT(dialog));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1170
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1171 gtk_widget_set_size_request(dialog, 600, 450);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1172 gtk_widget_realize(dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1173
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1174 g_signal_connect(G_OBJECT
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1175 (GTK_FILE_SELECTION(dialog)->history_pulldown),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1176 "changed", G_CALLBACK(filebrowser_entry_changed_classic),
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1177 dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1178
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1179 g_signal_connect(G_OBJECT(dialog), "destroy",
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1180 G_CALLBACK(gtk_widget_destroyed), &dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1181
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1182 filebrowser_changed_classic(GTK_FILE_SELECTION(dialog));
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1183
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1184 gtk_widget_show(dialog);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1185 }
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 * util_run_filebrowser(gboolean play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1189 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1190 * Inputs:
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1191 * - whether or not a play button should be used
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1192 *
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1193 * Outputs:
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1194 * - none
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 * Side Effects:
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1197 * - either a GTK1 or a GTK2 fileselector is launched
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1198 */
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1199 void
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1200 util_run_filebrowser(gboolean play_button)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1201 {
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1202 if (!cfg.use_xmms_style_fileselector)
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1203 util_run_filebrowser_gtk2style(play_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1204 else
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1205 util_run_filebrowser_classic(play_button);
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1206 }
6b4116c34489 [svn] - change "Transparency" to "Miscillaneous UI Features" in prefswin
nenolod
parents: 1891
diff changeset
1207
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1208 GdkFont *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1209 util_font_load(const gchar * name)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1210 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1211 GdkFont *font;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1212 PangoFontDescription *desc;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1213
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1214 desc = pango_font_description_from_string(name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1215 font = gdk_font_from_description(desc);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1216
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1217 return font;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1218 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1219
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1220 #ifdef ENABLE_NLS
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1221 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1222 bmp_menu_translate(const gchar * path, gpointer func_data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1223 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1224 gchar *translation = gettext(path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1225
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1226 if (!translation || *translation != '/') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1227 g_warning("Bad translation for menupath: %s", path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1228 translation = (gchar *) path;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1229 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1230
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1231 return translation;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1232 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1233 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1234
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1235 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1236 util_set_cursor(GtkWidget * window)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1237 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1238 static GdkCursor *cursor = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1239
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1240 if (!window) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1241 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
1242 gdk_cursor_unref(cursor);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1243 cursor = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1244 }
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
1245
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1246 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1247 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1248
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1249 if (!cursor)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1250 cursor = gdk_cursor_new(GDK_LEFT_PTR);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1251
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1252 gdk_window_set_cursor(window->window, cursor);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1253 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1254
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1255 /* text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1256 * Mattis et al */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1257 gboolean
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1258 text_get_extents(const gchar * fontname,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1259 const gchar * text,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1260 gint * width, gint * height, gint * ascent, gint * descent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1261 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1262 PangoFontDescription *font_desc;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1263 PangoLayout *layout;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1264 PangoRectangle rect;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1265
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1266 g_return_val_if_fail(fontname != NULL, FALSE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1267 g_return_val_if_fail(text != NULL, FALSE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1268
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1269 /* FIXME: resolution */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1270 layout = gtk_widget_create_pango_layout(GTK_WIDGET(mainwin), text);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1271
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1272 font_desc = pango_font_description_from_string(fontname);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1273 pango_layout_set_font_description(layout, font_desc);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1274 pango_font_description_free(font_desc);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1275 pango_layout_get_pixel_extents(layout, NULL, &rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1276
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1277 if (width)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1278 *width = rect.width;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1279 if (height)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1280 *height = rect.height;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1281
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1282 if (ascent || descent) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1283 PangoLayoutIter *iter;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1284 PangoLayoutLine *line;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1285
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1286 iter = pango_layout_get_iter(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1287 line = pango_layout_iter_get_line(iter);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1288 pango_layout_iter_free(iter);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1289
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1290 pango_layout_line_get_pixel_extents(line, NULL, &rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1291
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1292 if (ascent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1293 *ascent = PANGO_ASCENT(rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1294 if (descent)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1295 *descent = -PANGO_DESCENT(rect);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1296 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1297
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1298 g_object_unref(layout);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1299
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1300 return TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1301 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1302
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1303 /* counts number of digits in a gint */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1304 guint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1305 gint_count_digits(gint n)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1306 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1307 guint count = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1308
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1309 n = ABS(n);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1310 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1311 count++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1312 n /= 10;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1313 } while (n > 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1314
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1315 return count;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1316 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1317
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1318 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1319 dir_foreach(const gchar * path, DirForeachFunc function,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1320 gpointer user_data, GError ** error)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1321 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1322 GError *error_out = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1323 GDir *dir;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1324 const gchar *entry;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1325 gchar *entry_fullpath;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1326
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1327 if (!(dir = g_dir_open(path, 0, &error_out))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1328 g_propagate_error(error, error_out);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1329 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1330 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1331
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1332 while ((entry = g_dir_read_name(dir))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1333 entry_fullpath = g_build_filename(path, entry, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1334
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1335 if ((*function) (entry_fullpath, entry, user_data)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1336 g_free(entry_fullpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1337 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1338 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1339
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1340 g_free(entry_fullpath);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1341 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1342
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1343 g_dir_close(dir);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1344
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1345 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1346 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1347
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1348 GtkWidget *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1349 make_filebrowser(const gchar * title,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1350 gboolean save)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1351 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1352 GtkWidget *dialog;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1353 GtkWidget *button;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1354 GtkWidget *button_close;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1355
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1356 g_return_val_if_fail(title != NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1357
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1358 dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1359 GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1360 if (save)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1361 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1362 GTK_FILE_CHOOSER_ACTION_SAVE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1363
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1364 if (!save)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1365 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1366
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1367 g_signal_connect(dialog, "destroy",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1368 G_CALLBACK(gtk_widget_destroyed), &dialog);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1369
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1370 button_close = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1371 GTK_RESPONSE_REJECT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1372 gtk_button_set_use_stock(GTK_BUTTON(button_close), TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1373 GTK_WIDGET_SET_FLAGS(button_close, GTK_CAN_DEFAULT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1374 g_signal_connect_swapped(button_close, "clicked",
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1375 G_CALLBACK(gtk_widget_destroy), dialog);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1376
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1377 button = gtk_dialog_add_button(GTK_DIALOG(dialog), save ?
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1378 GTK_STOCK_SAVE : GTK_STOCK_OPEN,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1379 GTK_RESPONSE_ACCEPT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1380 gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1381 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1382 gtk_window_set_default(GTK_WINDOW(dialog), button);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1383
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1384 gtk_widget_show(dialog);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1385
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1386 return dialog;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1387 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
1388
1851
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1389 /*
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1390 * Resizes a GDK pixmap.
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1391 */
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1392 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
1393 {
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1394 GdkPixmap *out;
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1395 gint owidth, oheight;
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1396
1887
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1397 g_return_val_if_fail(src != NULL, NULL);
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1398 g_return_val_if_fail(src_gc != NULL, NULL);
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1399 g_return_val_if_fail(in != NULL, NULL);
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1400 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
1401
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1402 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
1403
1852
01103f911aa5 [svn] - avoid unnecessary resizing
nenolod
parents: 1851
diff changeset
1404 if (oheight == height && owidth == width)
1887
94795106c541 [svn] - icc warning fixes (pass 1)
nenolod
parents: 1852
diff changeset
1405 return NULL;
1852
01103f911aa5 [svn] - avoid unnecessary resizing
nenolod
parents: 1851
diff changeset
1406
1851
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1407 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
1408
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1409 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
1410
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1411 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
1412 g_object_unref(src);
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1413
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1414 return out;
aceb472cce6c [svn] - add audacious_pixmap_resize() for resizing a skin pixmap on demand.
nenolod
parents: 1752
diff changeset
1415 }
1938
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1416
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1417 GdkImage *create_dblsize_image(GdkImage * img)
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1418 {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1419 GdkImage *dblimg;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1420 register guint x, y;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1421
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1422 /*
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1423 * This needs to be optimized
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1424 */
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1425
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1426 dblimg =
1972
edc01e85648d [svn] - in particular X environment, double size caused a bad match X error.
yaz
parents: 1938
diff changeset
1427 gdk_image_new(GDK_IMAGE_NORMAL, gdk_visual_get_system(),
1938
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1428 img->width << 1, img->height << 1);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1429 if (dblimg->bpp == 1) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1430 register guint8 *srcptr, *ptr, *ptr2, pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1431
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1432 srcptr = GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1433 ptr = GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1434 ptr2 = ptr + dblimg->bpl;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1435
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1436 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1437 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1438 pix = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1439 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1440 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1441 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1442 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1443 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1444 srcptr += img->bpl - img->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1445 ptr += (dblimg->bpl << 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1446 ptr2 += (dblimg->bpl << 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1447 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1448 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1449 if (dblimg->bpp == 2) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1450 guint16 *srcptr, *ptr, *ptr2, pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1451
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1452 srcptr = (guint16 *) GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1453 ptr = (guint16 *) GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1454 ptr2 = ptr + (dblimg->bpl >> 1);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1455
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1456 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1457 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1458 pix = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1459 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1460 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1461 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1462 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1463 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1464 srcptr += (img->bpl >> 1) - img->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1465 ptr += (dblimg->bpl) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1466 ptr2 += (dblimg->bpl) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1467 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1468 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1469 if (dblimg->bpp == 3) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1470 register guint8 *srcptr, *ptr, *ptr2, pix1, pix2, pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1471
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1472 srcptr = GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1473 ptr = GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1474 ptr2 = ptr + dblimg->bpl;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1475
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1476 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1477 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1478 pix1 = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1479 pix2 = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1480 pix3 = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1481 *ptr++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1482 *ptr++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1483 *ptr++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1484 *ptr++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1485 *ptr++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1486 *ptr++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1487 *ptr2++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1488 *ptr2++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1489 *ptr2++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1490 *ptr2++ = pix1;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1491 *ptr2++ = pix2;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1492 *ptr2++ = pix3;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1493
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1494 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1495 srcptr += img->bpl - (img->width * 3);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1496 ptr += (dblimg->bpl << 1) - (dblimg->width * 3);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1497 ptr2 += (dblimg->bpl << 1) - (dblimg->width * 3);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1498 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1499 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1500 if (dblimg->bpp == 4) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1501 register guint32 *srcptr, *ptr, *ptr2, pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1502
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1503 srcptr = (guint32 *) GDK_IMAGE_XIMAGE(img)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1504 ptr = (guint32 *) GDK_IMAGE_XIMAGE(dblimg)->data;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1505 ptr2 = ptr + (dblimg->bpl >> 2);
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1506
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1507 for (y = 0; y < img->height; y++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1508 for (x = 0; x < img->width; x++) {
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1509 pix = *srcptr++;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1510 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1511 *ptr++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1512 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1513 *ptr2++ = pix;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1514 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1515 srcptr += (img->bpl >> 2) - img->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1516 ptr += (dblimg->bpl >> 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1517 ptr2 += (dblimg->bpl >> 1) - dblimg->width;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1518 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1519 }
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1520 return dblimg;
1d9c1026d9f8 [svn] - DoubleSize support.
nenolod
parents: 1936
diff changeset
1521 }
2074
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1522
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1523 /* 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
1524 gchar *
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1525 xmms_urldecode_path(const gchar * encoded_path)
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1526 {
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1527 const gchar *cur, *ext;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1528 gchar *path, *tmp;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1529 gint realchar;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1530
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1531 if (!encoded_path)
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1532 return NULL;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1533
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1534 if (!str_has_prefix_nocase(encoded_path, "file:"))
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1535 return NULL;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1536
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1537 cur = encoded_path + 5;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1538
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1539 if (str_has_prefix_nocase(cur, "//localhost"))
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1540 cur += 11;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1541
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1542 if (*cur == '/')
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1543 while (cur[1] == '/')
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1544 cur++;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1545
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1546 tmp = g_malloc0(strlen(cur) + 1);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1547
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1548 while ((ext = strchr(cur, '%')) != NULL) {
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1549 strncat(tmp, cur, ext - cur);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1550 ext++;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1551 cur = ext + 2;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1552 if (!sscanf(ext, "%2x", &realchar)) {
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1553 /* Assume it is a literal '%'. Several file
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1554 * managers send unencoded file: urls on drag
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1555 * and drop. */
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1556 realchar = '%';
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1557 cur -= 2;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1558 }
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1559 tmp[strlen(tmp)] = realchar;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1560 }
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1561
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1562 path = g_strconcat(tmp, cur, NULL);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1563 g_free(tmp);
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1564 return path;
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1565 }
c725daec3849 [svn] - move xmms_urldecode_path() back into main binary
nenolod
parents: 2019
diff changeset
1566