16
16
#include <string.h>
18
#include <audacious/configdb.h>
19
#include <audacious/drct.h>
20
#include <audacious/i18n.h>
18
21
#include <audacious/plugin.h>
19
#include <audacious/ui_preferences.h>
20
#include <audacious/auddrct.h>
22
#include <audacious/preferences.h>
23
#include <libaudcore/hook.h>
24
#include <libaudcore/audstrings.h>
21
26
#include "formatter.h"
22
#include <audacious/i18n.h>
23
#include <audacious/hook.h>
24
#include <audacious/preferences.h>
26
28
static PluginPreferences preferences;
98
100
do_command(char *cmd, const char *current_file, int pos)
100
int length, rate, freq, nch;
101
103
char *str, *shstring = NULL, *temp, numbuf[32];
102
104
gboolean playing;
103
105
Formatter *formatter;
105
107
if (cmd && strlen(cmd) > 0)
107
109
formatter = formatter_new();
108
str = audacious_drct_pl_get_title(pos);
110
str = aud_drct_pl_get_title(pos);
111
temp = aud_escape_shell_chars(str);
113
temp = escape_shell_chars(str);
112
114
formatter_associate(formatter, 's', temp);
113
115
formatter_associate(formatter, 'n', temp);
130
132
formatter_associate(formatter, 'f', "");
131
133
g_snprintf(numbuf, sizeof(numbuf), "%02d", pos + 1);
132
134
formatter_associate(formatter, 't', numbuf);
133
length = audacious_drct_pl_get_time(pos);
135
length = aud_drct_pl_get_time(pos);
134
136
if (length != -1)
136
138
g_snprintf(numbuf, sizeof(numbuf), "%d", length);
140
142
formatter_associate(formatter, 'l', "0");
141
audacious_drct_get_info(&rate, &freq, &nch);
142
g_snprintf(numbuf, sizeof(numbuf), "%d", rate);
143
formatter_associate(formatter, 'r', numbuf);
144
g_snprintf(numbuf, sizeof(numbuf), "%d", freq);
145
formatter_associate(formatter, 'F', numbuf);
146
g_snprintf(numbuf, sizeof(numbuf), "%d", nch);
147
formatter_associate(formatter, 'c', numbuf);
148
playing = audacious_drct_get_playing();
144
playing = aud_drct_get_playing();
149
145
g_snprintf(numbuf, sizeof(numbuf), "%d", playing);
150
146
formatter_associate(formatter, 'p', numbuf);
150
int brate, srate, chans;
151
aud_drct_get_info (& brate, & srate, & chans);
152
snprintf (numbuf, sizeof numbuf, "%d", brate);
153
formatter_associate (formatter, 'r', numbuf);
154
snprintf (numbuf, sizeof numbuf, "%d", srate);
155
formatter_associate (formatter, 'F', numbuf);
156
snprintf (numbuf, sizeof numbuf, "%d", chans);
157
formatter_associate (formatter, 'c', numbuf);
151
160
shstring = formatter_format(formatter, cmd);
152
161
formatter_destroy(formatter);
179
188
static void cleanup(void)
181
aud_hook_dissociate("playback begin", songchange_playback_begin);
182
aud_hook_dissociate("playback end", songchange_playback_end);
183
aud_hook_dissociate("playlist end reached", songchange_playlist_eof);
184
// aud_hook_dissociate( "playlist set info" , songchange_playback_ttc);
190
hook_dissociate("playback begin", songchange_playback_begin);
191
hook_dissociate("playback end", songchange_playback_end);
192
hook_dissociate("playlist end reached", songchange_playlist_eof);
193
// hook_dissociate( "playlist set info" , songchange_playback_ttc);
186
195
if ( ttc_prevs != NULL )
257
aud_hook_associate("playback begin", songchange_playback_begin, NULL);
258
aud_hook_associate("playback end", songchange_playback_end, NULL);
259
aud_hook_associate("playlist end reached", songchange_playlist_eof, NULL);
266
hook_associate("playback begin", songchange_playback_begin, NULL);
267
hook_associate("playback end", songchange_playback_end, NULL);
268
hook_associate("playlist end reached", songchange_playlist_eof, NULL);
261
270
ttc_prevs = g_malloc0(sizeof(songchange_playback_ttc_prevs_t));
262
271
ttc_prevs->title = NULL;
263
272
ttc_prevs->filename = NULL;
264
// aud_hook_associate( "playlist set info" , songchange_playback_ttc , ttc_prevs );
273
// hook_associate( "playlist set info" , songchange_playback_ttc , ttc_prevs );
271
280
char *current_file;
273
pos = audacious_drct_pl_get_pos();
274
current_file = audacious_drct_pl_get_file(pos);
282
pos = aud_drct_pl_get_pos();
283
current_file = aud_drct_pl_get_file(pos);
276
285
do_command(cmd_line, current_file, pos);
285
294
char *current_file;
287
pos = audacious_drct_pl_get_pos();
288
current_file = audacious_drct_pl_get_file(pos);
296
pos = aud_drct_pl_get_pos();
297
current_file = aud_drct_pl_get_file(pos);
290
299
do_command(cmd_line_after, current_file, pos);
310
319
if ( ( pl_entry->title != NULL ) && ( strcmp(pl_entry->title,prevs->title) ) )
312
int pos = audacious_drct_pl_get_pos();
313
char *current_file = audacious_drct_pl_get_file(pos);
321
int pos = aud_drct_pl_get_pos();
322
char *current_file = aud_drct_pl_get_file(pos);
314
323
do_command(cmd_line_ttc, current_file, pos);
315
324
g_free(current_file);
316
325
g_free(prevs->title);
347
356
gchar *current_file;
349
pos = audacious_drct_pl_get_pos();
350
current_file = audacious_drct_pl_get_file(pos);
358
pos = aud_drct_pl_get_pos();
359
current_file = aud_drct_pl_get_file(pos);
352
361
do_command(cmd_line_end, current_file, pos);
366
375
static void configure_ok_cb()
368
377
char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
370
378
cmd = g_strdup(config.cmd);
371
379
cmd_after = g_strdup(config.cmd_after);
372
380
cmd_end = g_strdup(config.cmd_end);
421
429
"%p: Currently playing (1 or 0)"), NULL, NULL, NULL, FALSE},
432
/* static GtkWidget * custom_warning (void) */
433
static void * custom_warning (void)
427
435
GtkWidget *bbox_hbox;
483
491
.imgurl = DATA_DIR "/images/plugins.png",
484
492
.prefs = settings,
485
493
.n_prefs = G_N_ELEMENTS(settings),
486
.type = PREFERENCES_PAGE,
487
494
.init = configure_init,
488
/* TODO: .apply = configure_apply, */
489
495
.cleanup = configure_cleanup,