annotate src/song_change/song_change.c @ 2051:d8e453d09ee4

unbreak song_change
author William Pitcock <nenolod@atheme.org>
date Sat, 13 Oct 2007 20:12:45 -0500
parents 2ffc6a69fcd1
children fffa7e3d39e0
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 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
54 NULL, /* handle */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55 NULL, /* filename */
1119
751a95e21a08 [svn] - songchange: converted to v2 plugin system
giacomo
parents: 1060
diff changeset
56 "Song Change " PACKAGE_VERSION, /* Description */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
57 init,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
58 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
59 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60 cleanup,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
62
1119
751a95e21a08 [svn] - songchange: converted to v2 plugin system
giacomo
parents: 1060
diff changeset
63 GeneralPlugin *songchange_gplist[] = { &sc_gp, NULL };
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1369
diff changeset
64 DECLARE_PLUGIN(songchange, NULL, NULL, NULL, NULL, NULL, songchange_gplist, NULL, NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
65
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
66 static void bury_child(int signal)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
67 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
68 waitpid(-1, NULL, WNOHANG);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
69 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
70
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
71 static void execute_command(char *cmd)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
72 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
73 char *argv[4] = {"/bin/sh", "-c", NULL, NULL};
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
74 int i;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
75 argv[2] = cmd;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
76 signal(SIGCHLD, bury_child);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
77 if (fork() == 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
78 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
79 /* 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
80 for (i = 3; i < 255; i++)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
81 close(i);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
82 execv("/bin/sh", argv);
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 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
85
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
86 /* Format codes:
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
87 *
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
88 * F - frequency (in hertz)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
89 * c - number of channels
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
90 * f - filename (full path)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
91 * l - length (in milliseconds)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
92 * n - name
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
93 * r - rate (in bits per second)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
94 * s - name (since everyone's used to it)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
95 * t - playlist position (%02d)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
96 * p - currently playing (1 or 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
97 */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
98 /* 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
99 @cmd: command to run
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
100 @current_file: file name of current song
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
101 @pos: playlist_pos */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
102 static void
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
103 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
104 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
105 int length, rate, freq, nch;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
106 char *str, *shstring = NULL, *temp, numbuf[16];
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
107 gboolean playing;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
108 Formatter *formatter;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
109
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
110 if (cmd && strlen(cmd) > 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
111 {
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
112 formatter = formatter_new();
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
113 str = audacious_drct_pl_get_title(pos);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
114 if (str)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
115 {
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1952
diff changeset
116 temp = aud_escape_shell_chars(str);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
117 formatter_associate(formatter, 's', temp);
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
118 formatter_associate(formatter, 'n', temp);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
119 g_free(str);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
120 g_free(temp);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
121 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
122 else
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
123 {
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
124 formatter_associate(formatter, 's', "");
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
125 formatter_associate(formatter, 'n', "");
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
126 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
127
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
128 if (current_file)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
129 {
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1952
diff changeset
130 temp = aud_escape_shell_chars(current_file);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
131 formatter_associate(formatter, 'f', temp);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
132 g_free(temp);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
133 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
134 else
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
135 formatter_associate(formatter, 'f', "");
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
136 sprintf(numbuf, "%02d", pos + 1);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
137 formatter_associate(formatter, 't', numbuf);
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
138 length = audacious_drct_pl_get_time(pos);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
139 if (length != -1)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
140 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
141 sprintf(numbuf, "%d", length);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
142 formatter_associate(formatter, 'l', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
143 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
144 else
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
145 formatter_associate(formatter, 'l', "0");
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
146 audacious_drct_get_info(&rate, &freq, &nch);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
147 sprintf(numbuf, "%d", rate);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
148 formatter_associate(formatter, 'r', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
149 sprintf(numbuf, "%d", freq);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
150 formatter_associate(formatter, 'F', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
151 sprintf(numbuf, "%d", nch);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
152 formatter_associate(formatter, 'c', numbuf);
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
153 playing = audacious_drct_get_playing();
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
154 sprintf(numbuf, "%d", playing);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
155 formatter_associate(formatter, 'p', numbuf);
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
156 shstring = formatter_format(formatter, cmd);
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
157 formatter_destroy(formatter);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
158
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
159 if (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 execute_command(shstring);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
162 /* FIXME: This can possibly be freed too early */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
163 g_free(shstring);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
164 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
165 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
166 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
167
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
168 static void read_config(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
169 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
170 ConfigDb *db;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
171
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
172 db = bmp_cfg_db_open();
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
173 if ( !bmp_cfg_db_get_string(db, "song_change", "cmd_line", &cmd_line) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
174 cmd_line = g_strdup("");
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
175 if ( !bmp_cfg_db_get_string(db, "song_change", "cmd_line_after", &cmd_line_after) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
176 cmd_line_after = g_strdup("");
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
177 if ( !bmp_cfg_db_get_string(db, "song_change", "cmd_line_end", &cmd_line_end) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
178 cmd_line_end = g_strdup("");
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
179 if ( !bmp_cfg_db_get_string(db, "song_change", "cmd_line_ttc", &cmd_line_ttc) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
180 cmd_line_ttc = g_strdup("");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
181 bmp_cfg_db_close(db);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
183
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
184 static void cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
185 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
186 hook_dissociate("playback begin", songchange_playback_begin);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
187 hook_dissociate("playback end", songchange_playback_end);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
188 hook_dissociate("playlist end reached", songchange_playlist_eof);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
189 hook_dissociate( "playlist set info" , songchange_playback_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
190
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
191 if ( ttc_prevs != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
192 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
193 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
194 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
195 g_free( ttc_prevs );
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
196 ttc_prevs = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
197 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 g_free(cmd_line);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200 g_free(cmd_line_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201 g_free(cmd_line_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
202 g_free(cmd_line_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203 cmd_line = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204 cmd_line_after = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 cmd_line_end = NULL;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
206 cmd_line_ttc = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
207 signal(SIGCHLD, SIG_DFL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
209 prefswin_page_destroy(configure_vbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
210 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
211
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212 static void save_and_close(GtkWidget *w, gpointer data)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
213 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 ConfigDb *db;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
215 char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
216
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
217 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
218 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
219 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
220 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
221
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
222 db = bmp_cfg_db_open();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223 bmp_cfg_db_set_string(db, "song_change", "cmd_line", cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
224 bmp_cfg_db_set_string(db, "song_change", "cmd_line_after", cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
225 bmp_cfg_db_set_string(db, "song_change", "cmd_line_end", cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
226 bmp_cfg_db_set_string(db, "song_change", "cmd_line_ttc", cmd_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 bmp_cfg_db_close(db);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
228
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
229 if (cmd_line != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
230 g_free(cmd_line);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
231
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
232 cmd_line = g_strdup(cmd);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
233
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
234 if (cmd_line_after != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
235 g_free(cmd_line_after);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
236
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
237 cmd_line_after = g_strdup(cmd_after);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
238
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
239 if (cmd_line_end != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240 g_free(cmd_line_end);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
241
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
242 cmd_line_end = g_strdup(cmd_end);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
243
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
244 if (cmd_line_ttc != NULL)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
245 g_free(cmd_line_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
246
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
247 cmd_line_ttc = g_strdup(cmd_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
248
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
249 g_free(cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250 g_free(cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
251 g_free(cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
252 g_free(cmd_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
253 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255 static int check_command(char *command)
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 const char *dangerous = "fns";
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
258 char *c;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259 int qu = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
260
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
261 for (c = command; *c != '\0'; c++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
262 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
263 if (*c == '"' && (c == command || *(c - 1) != '\\'))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
264 qu = !qu;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
265 else if (*c == '%' && !qu && strchr(dangerous, *(c + 1)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
266 return -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
267 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
268 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
269 }
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 static void configure_ok_cb(GtkWidget *w, gpointer data)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
272 {
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
273 char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
274
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
275 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
276 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
277 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
278 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
279
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
280 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
281 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
282 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
283 gtk_widget_show(cmd_warn_img);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
284 gtk_widget_show(cmd_warn_label);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
285 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286 else
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 gtk_widget_hide(cmd_warn_img);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 gtk_widget_hide(cmd_warn_label);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
290 save_and_close(NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
292
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
293 g_free(cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 g_free(cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295 g_free(cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
296 g_free(cmd_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
297 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
298
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
300 static GtkWidget *configure(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301 {
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
302 GtkWidget *sep1, *sep2, *sep3, *sep4;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
303 GtkWidget *cmd_hbox, *cmd_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304 GtkWidget *cmd_after_hbox, *cmd_after_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305 GtkWidget *cmd_end_hbox, *cmd_end_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
306 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
307 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
308 GtkWidget *song_frame, *song_vbox;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
309 GtkWidget *bbox_hbox;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310 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
311
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
312 read_config();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
313
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
314 configure_vbox = gtk_vbox_new(FALSE, 12);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
315
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
316 song_frame = gtk_frame_new(_("Commands"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
317 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
318 song_vbox = gtk_vbox_new(FALSE, 12);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319 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
320 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
321
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322 cmd_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
323 "Command to run when Audacious starts a new song."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
324 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
325 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
326 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
327 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
328
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
329 cmd_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330 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
331
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332 cmd_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
333 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
334
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 cmd_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336 if (cmd_line)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337 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
338 gtk_widget_set_usize(cmd_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339 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
340
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341 sep1 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342 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
343
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345 cmd_after_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
346 "Command to run toward the end of a song."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
347 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
348 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
349 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
350
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
351 cmd_after_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
352 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
353
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
354 cmd_after_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
355 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
356
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
357 cmd_after_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
358 if (cmd_line_after)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
359 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
360 gtk_widget_set_usize(cmd_after_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
361 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
362 sep2 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
363 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
364
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
365 cmd_end_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
366 "Command to run when Audacious reaches the end "
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
367 "of the playlist."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
368 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
369 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
370 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
371
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
372 cmd_end_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
373 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
374
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
375 cmd_end_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
376 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
377
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
378 cmd_end_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
379 if (cmd_line_end)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
380 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
381 gtk_widget_set_usize(cmd_end_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
382 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
383 sep3 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
384 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
385
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
386 cmd_ttc_desc = gtk_label_new(_(
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
387 "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
388 "(i.e. network streams titles)."));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
389 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
390 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
391 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
392
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
393 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
394 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
395
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
396 cmd_ttc_label = gtk_label_new(_("Command:"));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
397 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
398
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
399 cmd_ttc_entry = gtk_entry_new();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
400 if (cmd_line_ttc)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
401 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
402 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
403 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
404 sep4 = gtk_hseparator_new();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
405 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
406
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
407 temp = g_strdup_printf(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
408 _("You can use the following format strings which\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
409 "will be substituted before calling the command\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
410 "(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
411 "%%F: Frequency (in hertz)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
412 "%%c: Number of channels\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
413 "%%f: filename (full path)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
414 "%%l: length (in milliseconds)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
415 "%%n or %%s: Song name\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
416 "%%r: Rate (in bits per second)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
417 "%%t: Playlist position (%%02d)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
418 "%%p: Currently playing (1 or 0)"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
419 f_desc = gtk_label_new(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
420 g_free(temp);
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 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
423 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
424 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
425
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
426 bbox_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
427 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
428
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
429 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
430 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
431
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
432 temp = g_strdup_printf(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
433 _("<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
434 cmd_warn_label = gtk_label_new(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
435 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
436 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
437
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
438 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
439 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
440 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
441 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
442
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443 gtk_widget_show_all(configure_vbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
444
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
445 return configure_vbox;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
446 }
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 static void init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
449 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
450 read_config();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
451
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
452 configure_vbox = configure();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
453 prefswin_page_new(configure_vbox, "Song Change", DATA_DIR "/images/plugins.png");
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
454
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
455 hook_associate("playback begin", songchange_playback_begin, NULL);
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
456 hook_associate("playback end", songchange_playback_end, NULL);
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
457 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
458
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
459 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
460 ttc_prevs->title = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
461 ttc_prevs->filename = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
462 hook_associate( "playlist set info" , songchange_playback_ttc , ttc_prevs );
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
463
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
464 configure_ok_cb(NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
465 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
466
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
467 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
468 songchange_playback_begin(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
469 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
470 int pos;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
471 char *current_file;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
472
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
473 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
474 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
475
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
476 do_command(cmd_line, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
478 g_free(current_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
479 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
480
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
481 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
482 songchange_playback_end(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
483 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
484 int pos;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
485 char *current_file;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
486
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
487 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
488 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
489
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
490 do_command(cmd_line_after, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
491
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
492 g_free(current_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
493 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
494
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
495 static void
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
496 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
497 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
498 if ( ( ip_data.playing ) && ( strcmp(cmd_line_ttc,"") ) )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
499 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
500 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
501 PlaylistEntry *pl_entry = plentry_gp;
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 /* 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
504
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
505 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
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 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
508 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
509 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
510 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
511 int pos = audacious_drct_pl_get_pos();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
512 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
513 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
514 g_free(current_file);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
515 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
516 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
517 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
518 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
519 else
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
520 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
521 g_free(prevs->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
522 prevs->filename = g_strdup(pl_entry->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
523 /* if filename changes, reset title as well */
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
524 if ( prevs->title != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
525 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
526 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
527 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
528 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
529 else
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
530 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
531 if ( prevs->title != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
532 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
533 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
534 if ( prevs->filename != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
535 g_free(prevs->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
536 prevs->filename = g_strdup(pl_entry->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
537 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
538 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
539 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
540
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
541 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
542 songchange_playlist_eof(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
543 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
544 int pos;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
545 char *current_file;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
546
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
547 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
548 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
549
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
550 do_command(cmd_line_end, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
551
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
552 g_free(current_file);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
553 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
554