annotate libaudacious/titlestring.c @ 2192:9f9db9b5c696 trunk

[svn] - Allow radiobuttons/checkboxes in the visualization menu to be updated correctly on startup with the addition of the Voiceprint mode.
author nhjm449
date Fri, 22 Dec 2006 00:52:22 -0800
parents 27aa778eb73c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2001, Espen Skoglund <esk@ira.uka.de>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 * Copyright (C) 2001, Haavard Kvaalen <havardk@xmms.org>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 * modify it under the terms of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * as published by the Free Software Foundation; either version 2
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * of the License, or (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
1458
f12d7e208b43 [svn] Update FSF address in copyright notices. Update autotools templates.
chainsaw
parents: 1350
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
18 * 02110-1301, USA.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25
751
6636d328fa38 [svn] more progress
nenolod
parents: 0
diff changeset
26 #define GETTEXT_PACKAGE PACKAGE_NAME
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <glib/gi18n-lib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <gtk/gtk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include "titlestring.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #define CHECK(input, field) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 (((gchar *) &input->field - (gchar *) input) < input->__size)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 #define VS(input, field) (CHECK(input, field) ? input->field : NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 #define VI(input, field) (CHECK(input, field) ? input->field : 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41
2050
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
42 /**
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
43 * bmp_title_input_new:
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
44 *
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
45 * #BmpTitleInput tuple factory.
2051
27aa778eb73c [svn] - add some missing docs
nenolod
parents: 2050
diff changeset
46 *
27aa778eb73c [svn] - add some missing docs
nenolod
parents: 2050
diff changeset
47 * Return value: A #BmpTitleInput object.
2050
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
48 **/
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 BmpTitleInput *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 bmp_title_input_new()
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 BmpTitleInput *input;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 input = g_new0(BmpTitleInput, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 input->__size = XMMS_TITLEINPUT_SIZE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 input->__version = XMMS_TITLEINPUT_VERSION;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 return input;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58
2050
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
59 /**
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
60 * bmp_title_input_free:
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
61 * @input: A #BmpTitleInput tuple to destroy.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
62 *
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
63 * Destroys a #BmpTitleInput tuple.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
64 **/
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 bmp_title_input_free(BmpTitleInput * input)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 {
1350
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
68 if (input == NULL)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70
1350
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
71 if (input->performer != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
72 g_free(input->performer);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
73
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
74 if (input->album_name != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
75 g_free(input->album_name);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
76
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
77 if (input->track_name != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
78 g_free(input->track_name);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
79
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
80 if (input->date != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
81 g_free(input->date);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
82
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
83 if (input->genre != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
84 g_free(input->genre);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
85
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
86 if (input->comment != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
87 g_free(input->comment);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
88
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
89 if (input->file_name != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
90 g_free(input->file_name);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
91
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
92 if (input->file_path != NULL)
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
93 g_free(input->file_path);
ca5d03c4b3f1 [svn] - extra sanity checking keeps the double-free away
nenolod
parents: 751
diff changeset
94
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 g_free(input);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97
2050
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
98 /**
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
99 * xmms_get_titlestring:
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
100 * @fmt: A format string.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
101 * @input: A tuple to use for data.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
102 *
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
103 * Generates a formatted string from a tuple.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
104 *
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
105 * Return value: A formatted tuple string.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
106 **/
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 xmms_get_titlestring(const gchar * fmt, TitleInput * input)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 GString *outstr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 const gchar *string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 gchar c, convert[16];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 gint numdigits, numpr, val, i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 gint f_left, f_space, f_zero, someflag, width, precision;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 gboolean did_output = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 gchar digits[] = "0123456789";
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 #define PUTCH(ch) g_string_append_c(outstr, ch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 #define LEFTPAD(num) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 G_STMT_START { \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 gint cnt = (num); \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 if ( ! f_left && cnt > 0 ) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 while ( cnt-- > 0 ) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 PUTCH(f_zero ? '0' : ' '); \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 } G_STMT_END;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 #define RIGHTPAD(num) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 G_STMT_START { \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 gint cnt = (num); \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 if ( f_left && cnt > 0 ) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 while ( cnt-- > 0 ) \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 PUTCH( ' ' ); \
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 } G_STMT_END;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135
1658
fda280358660 [svn] avoid segfaults
lu_zero
parents: 1594
diff changeset
136 if (fmt == NULL || input == NULL)
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 outstr = g_string_new("");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 for (;;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 /* Copy characters until we encounter '%'. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 while ((c = *fmt++) != '%') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 if (c == '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 goto Done;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 g_string_append_c(outstr, c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 f_left = f_space = f_zero = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 someflag = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 /* Parse flags. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 while (someflag) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 switch (*fmt) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 case '-':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 f_left = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 fmt++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 case ' ':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 f_space = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 fmt++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 case '0':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 f_zero = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 fmt++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 someflag = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 /* Parse field width. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 if ((c = *fmt) >= '0' && c <= '9') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 width = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 while ((c = *fmt++) >= '0' && c <= '9') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 width *= 10;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 width += c - '0';
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 fmt--;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 width = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 /* Parse precision. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 if (*fmt == '.') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 if ((c = *++fmt) >= '0' && c <= '9') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 precision = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 while ((c = *fmt++) >= '0' && c <= '9') {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 precision *= 10;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 precision += c - '0';
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 fmt--;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 precision = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 precision = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 /* Parse format conversion. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 switch (c = *fmt++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 case '}': /* close optional, just ignore */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 case '{':{ /* optional entry: %{n:...%} */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 char n = *fmt++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 if (!((n == 'a' && VS(input, album_name)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 (n == 'c' && VS(input, comment)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 (n == 'd' && VS(input, date)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 (n == 'e' && VS(input, file_ext)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 (n == 'f' && VS(input, file_name)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 (n == 'F' && VS(input, file_path)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 (n == 'g' && VS(input, genre)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 (n == 'n' && VI(input, track_number)) ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 (n == 'p' && VS(input, performer)) ||
2011
90cc014f8fdc [svn] - fix for custom format bug. closes #664.
yaz
parents: 1658
diff changeset
220 (n == 't' && VS(input, track_name)) ||
90cc014f8fdc [svn] - fix for custom format bug. closes #664.
yaz
parents: 1658
diff changeset
221 (n == 'y' && VI(input, year)))) {
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 int nl = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 char c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 while ((c = *fmt++)) /* until end of string */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 if (c == '}') /* if end of opt */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 if (!nl)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 break; /* if outmost indent level */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 --nl; /* else reduce indent */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 else if (c == '{')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 ++nl; /* increase indent */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 ++fmt;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 case 'a':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 string = VS(input, album_name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 case 'c':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 string = VS(input, comment);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 case 'd':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 string = VS(input, date);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 case 'e':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 string = VS(input, file_ext);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 case 'f':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 string = VS(input, file_name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 case 'F':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 string = VS(input, file_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 case 'g':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 string = VS(input, genre);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 case 'n':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 val = VI(input, track_number);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 goto Print_number;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 case 'p':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 string = VS(input, performer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 goto Print_string;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 case 't':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 string = VS(input, track_name);
2011
90cc014f8fdc [svn] - fix for custom format bug. closes #664.
yaz
parents: 1658
diff changeset
267 goto Print_string;
90cc014f8fdc [svn] - fix for custom format bug. closes #664.
yaz
parents: 1658
diff changeset
268 case 'y':
90cc014f8fdc [svn] - fix for custom format bug. closes #664.
yaz
parents: 1658
diff changeset
269 val = VI(input, year);
90cc014f8fdc [svn] - fix for custom format bug. closes #664.
yaz
parents: 1658
diff changeset
270 goto Print_number;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 Print_string:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 if (string == NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 did_output = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 numpr = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 if (width > 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 /* Calculate printed size. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 numpr = strlen(string);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 if (precision >= 0 && precision < numpr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 numpr = precision;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 LEFTPAD(width - numpr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 /* Insert string. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 if (precision >= 0) {
1594
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
289 glong offset_max = precision, offset;
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
290 gchar *uptr = NULL;
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
291 const gchar *tmpstring = string;
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
292 while (precision > 0) {
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
293 offset = offset_max - precision;
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
294 uptr = g_utf8_offset_to_pointer(tmpstring, offset);
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
295 if (*uptr == '\0')
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
296 break;
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
297 g_string_append_unichar(outstr, g_utf8_get_char(uptr));
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
298 precision--;
44f67f556b60 [svn] - precision in title format is regarded as character count, not byte count.
yaz
parents: 1459
diff changeset
299 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 while ((c = *string++) != '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 PUTCH(c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 RIGHTPAD(width - numpr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 Print_number:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310 if (val == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 if (c != 'N')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313 did_output = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 /* Create reversed number string. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 numdigits = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 convert[numdigits++] = digits[val % 10];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 val /= 10;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 while (val > 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 numpr = numdigits > precision ? numdigits : precision;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 /* Insert left padding. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 if (!f_left && width > numpr) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327 if (f_zero)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 numpr = width;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 for (i = width - numpr; i-- > 0;)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 PUTCH(' ');
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 /* Insert zero padding. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 for (i = numpr - numdigits; i-- > 0;)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 PUTCH('0');
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338 /* Insert number. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 while (numdigits > 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 PUTCH(convert[--numdigits]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 RIGHTPAD(width - numpr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 case '%':
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 PUTCH('%');
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 PUTCH('%');
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 PUTCH(c);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 break;
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
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 Done:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 if (did_output)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 return g_string_free(outstr, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 struct _TagDescription {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 gchar tag;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 gchar *description;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 typedef struct _TagDescription TagDescription;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 static TagDescription tag_descriptions[] = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 {'p', N_("Performer/Artist")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 {'a', N_("Album")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 {'g', N_("Genre")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 {'f', N_("File name")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 {'F', N_("File path")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 {'e', N_("File extension")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 {'t', N_("Track name")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 {'n', N_("Track number")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 {'d', N_("Date")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 {'y', N_("Year")},
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 {'c', N_("Comment")}
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 gint tag_descriptions_length =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 sizeof(tag_descriptions) / sizeof(TagDescription);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386
2050
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
387 /**
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
388 * xmms_titlestring_descriptions:
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
389 * @tags: A list of formatters to provide.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
390 * @columns: A number of columns to arrange them in.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
391 *
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
392 * Generates a box explaining how to use the formatters.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
393 *
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
394 * Return value: A GtkWidget containing the table.
e6b15b72feac [svn] - document the tuple system
nenolod
parents: 2011
diff changeset
395 **/
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396 GtkWidget *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 xmms_titlestring_descriptions(gchar * tags, gint columns)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 GtkWidget *table, *label;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400 gchar tag_str[5];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
401 gint num = strlen(tags);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
402 gint r = 0, c, i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
403
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
404 g_return_val_if_fail(tags != NULL, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
405 g_return_val_if_fail(columns <= num, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
406
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
407 table = gtk_table_new((num + columns - 1) / columns, columns * 2, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
408 gtk_table_set_row_spacings(GTK_TABLE(table), 2);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
409 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
410
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
411 for (c = 0; c < columns; c++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
412 for (r = 0; r < (num + columns - 1 - c) / columns; r++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
413 g_snprintf(tag_str, sizeof(tag_str), "%%%c:", *tags);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
414 label = gtk_label_new(tag_str);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416 gtk_table_attach(GTK_TABLE(table), label, 2 * c, 2 * c + 1, r,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 r + 1, GTK_FILL, GTK_FILL, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 gtk_widget_show(label);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420 for (i = 0; i < tag_descriptions_length; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
421 if (*tags == tag_descriptions[i].tag) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
422 label = gtk_label_new(_(tag_descriptions[i].description));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
423 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
424 gtk_table_attach(GTK_TABLE(table), label, 2 * c + 1,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
425 2 * c + 2, r, r + 1,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
426 GTK_EXPAND | GTK_FILL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
427 GTK_EXPAND | GTK_FILL, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
428 gtk_widget_show(label);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
429 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
430 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
431 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
432
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
433 if (i == tag_descriptions_length)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
434 g_warning("Invalid tag: %c", *tags);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
435
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
436 tags++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
437 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
439 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
440
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
441 label = gtk_label_new(_("%{n:...%}: Display \"...\" only if element "
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
442 "%n is present"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
443 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
444 gtk_table_attach(GTK_TABLE(table), label, 0, r + 1,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 r + 1, r + 2, GTK_FILL, GTK_FILL, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
446 gtk_widget_show(label);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
447
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
448 return table;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449 }