annotate src/song_change/song_change.c @ 2202:f76e846d53d9

updating TLEN frame returned
author Eugene Zagidullin <e.asphyx@gmail.com>
date Mon, 03 Dec 2007 01:26:57 +0300
parents cf20f1bd2f1e
children c44b90b6322e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Audacious: A cross-platform multimedia player.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 * Copyright (c) 2005 Audacious Team
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 #include "config.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 #include <gtk/gtk.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 #include <sys/types.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 #include <sys/wait.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 #include <signal.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 #include <unistd.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 #include <stdio.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1395
diff changeset
18 #include <audacious/plugin.h>
1952
17a6441c71b6 Some missed #include "" to <> changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1950
diff changeset
19 #include <audacious/ui_preferences.h>
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1395
diff changeset
20 #include <audacious/configdb.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1395
diff changeset
21 #include <audacious/auddrct.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1395
diff changeset
22 #include <audacious/formatter.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 406
diff changeset
23 #include <audacious/i18n.h>
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
24 #include <audacious/hook.h>
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
25 #include <audacious/playlist.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 static void init(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28 static void cleanup(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29 static GtkWidget *configure(void);
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
30 static void songchange_playback_begin(gpointer unused, gpointer unused2);
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
31 static void songchange_playback_end(gpointer unused, gpointer unused2);
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
32 static void songchange_playlist_eof(gpointer unused, gpointer unused2);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
33 static void songchange_playback_ttc(gpointer, gpointer);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
34
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
35 typedef struct
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
36 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
37 gchar *title;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
38 gchar *filename;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
39 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
40 songchange_playback_ttc_prevs_t;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
41 static songchange_playback_ttc_prevs_t *ttc_prevs = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
42
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
43 static char *cmd_line = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 static char *cmd_line_after = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45 static char *cmd_line_end = NULL;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
46 static char *cmd_line_ttc = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48 static GtkWidget *configure_vbox = NULL;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
49 static GtkWidget *cmd_entry, *cmd_after_entry, *cmd_end_entry, *cmd_ttc_entry;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
50 static GtkWidget *cmd_warn_label, *cmd_warn_img;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52 GeneralPlugin sc_gp =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
53 {
2149
cf20f1bd2f1e - updated German translation
mf0102 <0102@gmx.at>
parents: 2124
diff changeset
54 .description = "Song Change " PACKAGE_VERSION,
cf20f1bd2f1e - updated German translation
mf0102 <0102@gmx.at>
parents: 2124
diff changeset
55 .init = init,
cf20f1bd2f1e - updated German translation
mf0102 <0102@gmx.at>
parents: 2124
diff changeset
56 .cleanup = cleanup,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
57 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
58
1119
751a95e21a08 [svn] - songchange: converted to v2 plugin system
giacomo
parents: 1060
diff changeset
59 GeneralPlugin *songchange_gplist[] = { &sc_gp, NULL };
2149
cf20f1bd2f1e - updated German translation
mf0102 <0102@gmx.at>
parents: 2124
diff changeset
60 SIMPLE_GENERAL_PLUGIN(songchange, songchange_gplist);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
62 static void bury_child(int signal)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
63 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
64 waitpid(-1, NULL, WNOHANG);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
65 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
66
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
67 static void execute_command(char *cmd)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
68 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
69 char *argv[4] = {"/bin/sh", "-c", NULL, NULL};
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
70 int i;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
71 argv[2] = cmd;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
72 signal(SIGCHLD, bury_child);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
73 if (fork() == 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
74 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
75 /* We don't want this process to hog the audio device etc */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
76 for (i = 3; i < 255; i++)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
77 close(i);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
78 execv("/bin/sh", argv);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
79 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
80 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
81
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
82 /* Format codes:
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
83 *
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
84 * F - frequency (in hertz)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
85 * c - number of channels
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
86 * f - filename (full path)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
87 * l - length (in milliseconds)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
88 * n - name
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
89 * r - rate (in bits per second)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
90 * s - name (since everyone's used to it)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
91 * t - playlist position (%02d)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
92 * p - currently playing (1 or 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
93 */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
94 /* do_command(): do @cmd after replacing the format codes
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
95 @cmd: command to run
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
96 @current_file: file name of current song
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
97 @pos: playlist_pos */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
98 static void
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
99 do_command(char *cmd, const char *current_file, int pos)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
100 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
101 int length, rate, freq, nch;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
102 char *str, *shstring = NULL, *temp, numbuf[16];
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
103 gboolean playing;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
104 Formatter *formatter;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
105
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
106 if (cmd && strlen(cmd) > 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
107 {
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
108 formatter = aud_formatter_new();
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
109 str = audacious_drct_pl_get_title(pos);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
110 if (str)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
111 {
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1952
diff changeset
112 temp = aud_escape_shell_chars(str);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
113 aud_formatter_associate(formatter, 's', temp);
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
114 aud_formatter_associate(formatter, 'n', temp);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
115 g_free(str);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
116 g_free(temp);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
117 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
118 else
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
119 {
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
120 aud_formatter_associate(formatter, 's', "");
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
121 aud_formatter_associate(formatter, 'n', "");
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
122 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
123
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
124 if (current_file)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
125 {
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1952
diff changeset
126 temp = aud_escape_shell_chars(current_file);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
127 aud_formatter_associate(formatter, 'f', temp);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
128 g_free(temp);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
129 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
130 else
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
131 aud_formatter_associate(formatter, 'f', "");
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
132 sprintf(numbuf, "%02d", pos + 1);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
133 aud_formatter_associate(formatter, 't', numbuf);
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
134 length = audacious_drct_pl_get_time(pos);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
135 if (length != -1)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
136 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
137 sprintf(numbuf, "%d", length);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
138 aud_formatter_associate(formatter, 'l', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
139 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
140 else
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
141 aud_formatter_associate(formatter, 'l', "0");
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
142 audacious_drct_get_info(&rate, &freq, &nch);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
143 sprintf(numbuf, "%d", rate);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
144 aud_formatter_associate(formatter, 'r', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
145 sprintf(numbuf, "%d", freq);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
146 aud_formatter_associate(formatter, 'F', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
147 sprintf(numbuf, "%d", nch);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
148 aud_formatter_associate(formatter, 'c', numbuf);
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
149 playing = audacious_drct_get_playing();
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
150 sprintf(numbuf, "%d", playing);
2072
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
151 aud_formatter_associate(formatter, 'p', numbuf);
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
152 shstring = aud_formatter_format(formatter, cmd);
e7acdde315ca formatter shit
William Pitcock <nenolod@atheme.org>
parents: 2071
diff changeset
153 aud_formatter_destroy(formatter);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
154
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
155 if (shstring)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
156 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
157 execute_command(shstring);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
158 /* FIXME: This can possibly be freed too early */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
159 g_free(shstring);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
160 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
161 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
162 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
163
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
164 static void read_config(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
165 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
166 ConfigDb *db;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
167
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
168 db = aud_cfg_db_open();
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
169 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line", &cmd_line) )
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
170 cmd_line = g_strdup("");
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
171 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line_after", &cmd_line_after) )
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
172 cmd_line_after = g_strdup("");
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
173 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line_end", &cmd_line_end) )
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
174 cmd_line_end = g_strdup("");
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
175 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line_ttc", &cmd_line_ttc) )
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
176 cmd_line_ttc = g_strdup("");
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
177 aud_cfg_db_close(db);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
178 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
179
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
180 static void cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
181 {
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
182 aud_hook_dissociate("playback begin", songchange_playback_begin);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
183 aud_hook_dissociate("playback end", songchange_playback_end);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
184 aud_hook_dissociate("playlist end reached", songchange_playlist_eof);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
185 aud_hook_dissociate( "playlist set info" , songchange_playback_ttc);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
186
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
187 if ( ttc_prevs != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
188 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
189 if ( ttc_prevs->title != NULL ) g_free( ttc_prevs->title );
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
190 if ( ttc_prevs->filename != NULL ) g_free( ttc_prevs->filename );
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
191 g_free( ttc_prevs );
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
192 ttc_prevs = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
193 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
194
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
195 g_free(cmd_line);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
196 g_free(cmd_line_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
197 g_free(cmd_line_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
198 g_free(cmd_line_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 cmd_line = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200 cmd_line_after = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201 cmd_line_end = NULL;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
202 cmd_line_ttc = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203 signal(SIGCHLD, SIG_DFL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204
2071
f235b4a365a6 prefswin shit
William Pitcock <nenolod@atheme.org>
parents: 2060
diff changeset
205 aud_prefswin_page_destroy(configure_vbox);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
206 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
207
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208 static void save_and_close(GtkWidget *w, gpointer data)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
209 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
210 ConfigDb *db;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
211 char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
213 cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_entry)));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 cmd_after = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_after_entry)));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
215 cmd_end = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_end_entry)));
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
216 cmd_ttc = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_ttc_entry)));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
217
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
218 db = aud_cfg_db_open();
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
219 aud_cfg_db_set_string(db, "song_change", "cmd_line", cmd);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
220 aud_cfg_db_set_string(db, "song_change", "cmd_line_after", cmd_after);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
221 aud_cfg_db_set_string(db, "song_change", "cmd_line_end", cmd_end);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
222 aud_cfg_db_set_string(db, "song_change", "cmd_line_ttc", cmd_ttc);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
223 aud_cfg_db_close(db);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
224
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
225 if (cmd_line != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226 g_free(cmd_line);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
227
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
228 cmd_line = g_strdup(cmd);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
229
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
230 if (cmd_line_after != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
231 g_free(cmd_line_after);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
232
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
233 cmd_line_after = g_strdup(cmd_after);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
234
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
235 if (cmd_line_end != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236 g_free(cmd_line_end);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
237
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
238 cmd_line_end = g_strdup(cmd_end);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
240 if (cmd_line_ttc != NULL)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
241 g_free(cmd_line_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
242
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
243 cmd_line_ttc = g_strdup(cmd_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
244
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245 g_free(cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246 g_free(cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
247 g_free(cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
248 g_free(cmd_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
249 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
251 static int check_command(char *command)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
252 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
253 const char *dangerous = "fns";
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254 char *c;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255 int qu = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
256
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
257 for (c = command; *c != '\0'; c++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
258 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259 if (*c == '"' && (c == command || *(c - 1) != '\\'))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
260 qu = !qu;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
261 else if (*c == '%' && !qu && strchr(dangerous, *(c + 1)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
262 return -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
263 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
264 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
265 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
266
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
267 static void configure_ok_cb(GtkWidget *w, gpointer data)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
268 {
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
269 char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
270
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
271 cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_entry)));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
272 cmd_after = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_after_entry)));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
273 cmd_end = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_end_entry)));
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
274 cmd_ttc = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_ttc_entry)));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
275
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
276 if (check_command(cmd) < 0 || check_command(cmd_after) < 0 ||
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
277 check_command(cmd_end) < 0 || check_command(cmd_ttc) < 0)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
278 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
279 gtk_widget_show(cmd_warn_img);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
280 gtk_widget_show(cmd_warn_label);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
281 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
282 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
283 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
284 gtk_widget_hide(cmd_warn_img);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
285 gtk_widget_hide(cmd_warn_label);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286 save_and_close(NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
287 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
288
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 g_free(cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
290 g_free(cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 g_free(cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
292 g_free(cmd_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
293 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
296 static GtkWidget *configure(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
297 {
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
298 GtkWidget *sep1, *sep2, *sep3, *sep4;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299 GtkWidget *cmd_hbox, *cmd_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
300 GtkWidget *cmd_after_hbox, *cmd_after_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301 GtkWidget *cmd_end_hbox, *cmd_end_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
302 GtkWidget *cmd_desc, *cmd_after_desc, *cmd_end_desc, *f_desc;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
303 GtkWidget *cmd_ttc_hbox, *cmd_ttc_label, *cmd_ttc_desc;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304 GtkWidget *song_frame, *song_vbox;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
305 GtkWidget *bbox_hbox;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
306 char *temp;
1369
6d87598ff8a9 Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents: 1212
diff changeset
307
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 read_config();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310 configure_vbox = gtk_vbox_new(FALSE, 12);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
311
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
312 song_frame = gtk_frame_new(_("Commands"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
313 gtk_box_pack_start(GTK_BOX(configure_vbox), song_frame, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
314 song_vbox = gtk_vbox_new(FALSE, 12);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
315 gtk_container_set_border_width(GTK_CONTAINER(song_vbox), 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
316 gtk_container_add(GTK_CONTAINER(song_frame), song_vbox);
1369
6d87598ff8a9 Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents: 1212
diff changeset
317
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
318 cmd_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319 "Command to run when Audacious starts a new song."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
320 gtk_label_set_justify(GTK_LABEL(cmd_desc), GTK_JUSTIFY_LEFT);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
321 gtk_misc_set_alignment(GTK_MISC(cmd_desc), 0, 0.5);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_desc, FALSE, FALSE, 0);
1369
6d87598ff8a9 Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents: 1212
diff changeset
323 gtk_label_set_line_wrap(GTK_LABEL(cmd_desc), FALSE);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
324
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
325 cmd_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_hbox, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
327
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328 cmd_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
329 gtk_box_pack_start(GTK_BOX(cmd_hbox), cmd_label, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
331 cmd_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332 if (cmd_line)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
333 gtk_entry_set_text(GTK_ENTRY(cmd_entry), cmd_line);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
334 gtk_widget_set_usize(cmd_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 gtk_box_pack_start(GTK_BOX(cmd_hbox), cmd_entry, TRUE, TRUE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337 sep1 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 gtk_box_pack_start(GTK_BOX(song_vbox), sep1, TRUE, TRUE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
340
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341 cmd_after_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342 "Command to run toward the end of a song."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 gtk_label_set_justify(GTK_LABEL(cmd_after_desc), GTK_JUSTIFY_LEFT);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344 gtk_misc_set_alignment(GTK_MISC(cmd_after_desc), 0, 0.5);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_after_desc, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
346
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
347 cmd_after_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
348 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_after_hbox, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
349
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
350 cmd_after_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
351 gtk_box_pack_start(GTK_BOX(cmd_after_hbox), cmd_after_label, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
352
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
353 cmd_after_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
354 if (cmd_line_after)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
355 gtk_entry_set_text(GTK_ENTRY(cmd_after_entry), cmd_line_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
356 gtk_widget_set_usize(cmd_after_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
357 gtk_box_pack_start(GTK_BOX(cmd_after_hbox), cmd_after_entry, TRUE, TRUE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
358 sep2 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
359 gtk_box_pack_start(GTK_BOX(song_vbox), sep2, TRUE, TRUE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
360
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
361 cmd_end_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
362 "Command to run when Audacious reaches the end "
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
363 "of the playlist."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
364 gtk_label_set_justify(GTK_LABEL(cmd_end_desc), GTK_JUSTIFY_LEFT);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
365 gtk_misc_set_alignment(GTK_MISC(cmd_end_desc), 0, 0.5);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
366 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_end_desc, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
367
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
368 cmd_end_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
369 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_end_hbox, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
370
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
371 cmd_end_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
372 gtk_box_pack_start(GTK_BOX(cmd_end_hbox), cmd_end_label, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
373
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
374 cmd_end_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
375 if (cmd_line_end)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
376 gtk_entry_set_text(GTK_ENTRY(cmd_end_entry), cmd_line_end);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
377 gtk_widget_set_usize(cmd_end_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
378 gtk_box_pack_start(GTK_BOX(cmd_end_hbox), cmd_end_entry, TRUE, TRUE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
379 sep3 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
380 gtk_box_pack_start(GTK_BOX(song_vbox), sep3, TRUE, TRUE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
381
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
382 cmd_ttc_desc = gtk_label_new(_(
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
383 "Command to run when title changes for a song "
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
384 "(i.e. network streams titles)."));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
385 gtk_label_set_justify(GTK_LABEL(cmd_ttc_desc), GTK_JUSTIFY_LEFT);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
386 gtk_misc_set_alignment(GTK_MISC(cmd_ttc_desc), 0, 0.5);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
387 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_ttc_desc, FALSE, FALSE, 0);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
388
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
389 cmd_ttc_hbox = gtk_hbox_new(FALSE, 6);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
390 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_ttc_hbox, FALSE, FALSE, 0);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
391
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
392 cmd_ttc_label = gtk_label_new(_("Command:"));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
393 gtk_box_pack_start(GTK_BOX(cmd_ttc_hbox), cmd_ttc_label, FALSE, FALSE, 0);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
394
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
395 cmd_ttc_entry = gtk_entry_new();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
396 if (cmd_line_ttc)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
397 gtk_entry_set_text(GTK_ENTRY(cmd_ttc_entry), cmd_line_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
398 gtk_widget_set_usize(cmd_ttc_entry, 200, -1);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
399 gtk_box_pack_start(GTK_BOX(cmd_ttc_hbox), cmd_ttc_entry, TRUE, TRUE, 0);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
400 sep4 = gtk_hseparator_new();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
401 gtk_box_pack_start(GTK_BOX(song_vbox), sep4, TRUE, TRUE, 0);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
402
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
403 temp = g_strdup_printf(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
404 _("You can use the following format strings which\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
405 "will be substituted before calling the command\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
406 "(not all are useful for the end-of-playlist command).\n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
407 "%%F: Frequency (in hertz)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
408 "%%c: Number of channels\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
409 "%%f: filename (full path)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
410 "%%l: length (in milliseconds)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
411 "%%n or %%s: Song name\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
412 "%%r: Rate (in bits per second)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
413 "%%t: Playlist position (%%02d)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
414 "%%p: Currently playing (1 or 0)"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
415 f_desc = gtk_label_new(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
416 g_free(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
417
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
418 gtk_label_set_justify(GTK_LABEL(f_desc), GTK_JUSTIFY_LEFT);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
419 gtk_misc_set_alignment(GTK_MISC(f_desc), 0, 0.5);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
420 gtk_box_pack_start(GTK_BOX(song_vbox), f_desc, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
421
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
422 bbox_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
423 gtk_box_pack_start(GTK_BOX(configure_vbox), bbox_hbox, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
424
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
425 cmd_warn_img = gtk_image_new_from_stock("gtk-dialog-warning", GTK_ICON_SIZE_MENU);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
426 gtk_box_pack_start(GTK_BOX(bbox_hbox), cmd_warn_img, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
427
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
428 temp = g_strdup_printf(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
429 _("<span size='small'>Parameters passed to the shell should be encapsulated in quotes. Doing otherwise is a security risk.</span>"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
430 cmd_warn_label = gtk_label_new(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
431 gtk_label_set_markup(GTK_LABEL(cmd_warn_label), temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
432 gtk_box_pack_start(GTK_BOX(bbox_hbox), cmd_warn_label, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
433
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
434 g_signal_connect(GTK_OBJECT(cmd_entry), "changed", GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
435 g_signal_connect(GTK_OBJECT(cmd_after_entry), "changed", GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
436 g_signal_connect(GTK_OBJECT(cmd_end_entry), "changed", GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
437 g_signal_connect(GTK_OBJECT(cmd_ttc_entry), "changed", GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
438
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
439 gtk_widget_show_all(configure_vbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
440
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
441 return configure_vbox;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
442 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
444 static void init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
445 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
446 read_config();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
447
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
448 configure_vbox = configure();
2071
f235b4a365a6 prefswin shit
William Pitcock <nenolod@atheme.org>
parents: 2060
diff changeset
449 aud_prefswin_page_new(configure_vbox, "Song Change", DATA_DIR "/images/plugins.png");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
450
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
451 aud_hook_associate("playback begin", songchange_playback_begin, NULL);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
452 aud_hook_associate("playback end", songchange_playback_end, NULL);
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
453 aud_hook_associate("playlist end reached", songchange_playlist_eof, NULL);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
454
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
455 ttc_prevs = g_malloc0(sizeof(songchange_playback_ttc_prevs_t));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
456 ttc_prevs->title = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
457 ttc_prevs->filename = NULL;
2060
0803fba87da8 hook shit
William Pitcock <nenolod@atheme.org>
parents: 2058
diff changeset
458 aud_hook_associate( "playlist set info" , songchange_playback_ttc , ttc_prevs );
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
459
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
460 configure_ok_cb(NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
461 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
462
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
463 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
464 songchange_playback_begin(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
465 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
466 int pos;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
467 char *current_file;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
468
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
469 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
470 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
471
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
472 do_command(cmd_line, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
473
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
474 g_free(current_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
475 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
476
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
477 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
478 songchange_playback_end(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
479 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
480 int pos;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
481 char *current_file;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
483 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
484 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
486 do_command(cmd_line_after, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
487
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
488 g_free(current_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
489 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
490
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
491 static void
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
492 songchange_playback_ttc(gpointer plentry_gp, gpointer prevs_gp)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
493 {
2058
fffa7e3d39e0 use aud_ip_state (replacement to ip_data).
William Pitcock <nenolod@atheme.org>
parents: 2051
diff changeset
494 if ( ( aud_ip_state->playing ) && ( strcmp(cmd_line_ttc,"") ) )
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
495 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
496 songchange_playback_ttc_prevs_t *prevs = prevs_gp;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
497 PlaylistEntry *pl_entry = plentry_gp;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
498
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
499 /* same filename but title changed, useful to detect http stream song changes */
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
500
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
501 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
502 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
503 if ( ( pl_entry->filename != NULL ) && ( !strcmp(pl_entry->filename,prevs->filename) ) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
504 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
505 if ( ( pl_entry->title != NULL ) && ( strcmp(pl_entry->title,prevs->title) ) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
506 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
507 int pos = audacious_drct_pl_get_pos();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
508 char *current_file = audacious_drct_pl_get_file(pos);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
509 do_command(cmd_line_ttc, current_file, pos);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
510 g_free(current_file);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
511 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
512 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
513 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
514 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
515 else
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
516 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
517 g_free(prevs->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
518 prevs->filename = g_strdup(pl_entry->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
519 /* if filename changes, reset title as well */
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
520 if ( prevs->title != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
521 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
522 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
523 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
524 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
525 else
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
526 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
527 if ( prevs->title != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
528 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
529 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
530 if ( prevs->filename != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
531 g_free(prevs->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
532 prevs->filename = g_strdup(pl_entry->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
533 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
534 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
535 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
536
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
537 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
538 songchange_playlist_eof(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
539 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
540 int pos;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
541 char *current_file;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
542
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
543 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
544 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
545
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
546 do_command(cmd_line_end, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
547
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
548 g_free(current_file);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
549 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
550