annotate src/song_change/song_change.c @ 1367:c75fd6894758

wav-sndfile, wav: convert to new threading model
author William Pitcock <nenolod@atheme-project.org>
date Wed, 25 Jul 2007 16:06:17 -0500
parents 36cc5e56246e
children 6d87598ff8a9
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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 #include "audacious/plugin.h"
402
1d50eb0b5a0a [svn] - chase prefswin -> ui_preferences in audacious core
nenolod
parents: 12
diff changeset
19 #include "audacious/ui_preferences.h"
3
088092a52fea [svn] - move from (internal) libaudacious/ include path to audacious/ include path
nenolod
parents: 0
diff changeset
20 #include "audacious/configdb.h"
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
21 #include "audacious/auddrct.h"
3
088092a52fea [svn] - move from (internal) libaudacious/ include path to audacious/ include path
nenolod
parents: 0
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 };
751a95e21a08 [svn] - songchange: converted to v2 plugin system
giacomo
parents: 1060
diff changeset
64 DECLARE_PLUGIN(songchange, NULL, NULL, NULL, NULL, NULL, songchange_gplist, 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 /*
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
87 * escape_shell_chars()
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
88 *
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
89 * Escapes characters that are special to the shell inside double quotes.
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
90 */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
91 static char* escape_shell_chars(const char *string)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
92 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
93 const char *special = "$`\"\\"; /* Characters to escape */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
94 const char *in = string;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
95 char *out;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
96 char *escaped;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
97 int num = 0;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
98
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
99 while (*in != '\0')
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
100 if (strchr(special, *in++))
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
101 num++;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
102
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
103 escaped = g_malloc(strlen(string) + num + 1);
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 in = string;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
106 out = escaped;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
107
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
108 while (*in != '\0')
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 (strchr(special, *in))
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
111 *out++ = '\\';
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
112 *out++ = *in++;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
113 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
114 *out = '\0';
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
115
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
116 return escaped;
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
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
119 /* Format codes:
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
120 *
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
121 * F - frequency (in hertz)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
122 * c - number of channels
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
123 * f - filename (full path)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
124 * l - length (in milliseconds)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
125 * n - name
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
126 * r - rate (in bits per second)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
127 * s - name (since everyone's used to it)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
128 * t - playlist position (%02d)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
129 * p - currently playing (1 or 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
130 */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
131 /* 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
132 @cmd: command to run
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
133 @current_file: file name of current song
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
134 @pos: playlist_pos */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
135 static void
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
136 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
137 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
138 int length, rate, freq, nch;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
139 char *str, *shstring = NULL, *temp, numbuf[16];
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
140 gboolean playing;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
141 Formatter *formatter;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
142
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
143 if (cmd && strlen(cmd) > 0)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
144 {
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
145 formatter = formatter_new();
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
146 str = audacious_drct_pl_get_title(pos);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
147 if (str)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
148 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
149 temp = escape_shell_chars(str);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
150 formatter_associate(formatter, 's', temp);
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
151 formatter_associate(formatter, 'n', temp);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
152 g_free(str);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
153 g_free(temp);
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 else
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
156 {
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
157 formatter_associate(formatter, 's', "");
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
158 formatter_associate(formatter, 'n', "");
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
159 }
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 if (current_file)
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 temp = escape_shell_chars(current_file);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
164 formatter_associate(formatter, 'f', temp);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
165 g_free(temp);
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 else
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
168 formatter_associate(formatter, 'f', "");
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
169 sprintf(numbuf, "%02d", pos + 1);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
170 formatter_associate(formatter, 't', numbuf);
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
171 length = audacious_drct_pl_get_time(pos);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
172 if (length != -1)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
173 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
174 sprintf(numbuf, "%d", length);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
175 formatter_associate(formatter, 'l', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
176 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
177 else
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
178 formatter_associate(formatter, 'l', "0");
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
179 audacious_drct_get_info(&rate, &freq, &nch);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
180 sprintf(numbuf, "%d", rate);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
181 formatter_associate(formatter, 'r', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
182 sprintf(numbuf, "%d", freq);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
183 formatter_associate(formatter, 'F', numbuf);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
184 sprintf(numbuf, "%d", nch);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
185 formatter_associate(formatter, 'c', numbuf);
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
186 playing = audacious_drct_get_playing();
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
187 sprintf(numbuf, "%d", playing);
552
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
188 formatter_associate(formatter, 'p', numbuf);
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
189 shstring = formatter_format(formatter, cmd);
91bc67e7800b [svn] - adapted plugin to use new formatter (without xmms_ prefix)
mf0102
parents: 549
diff changeset
190 formatter_destroy(formatter);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
191
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
192 if (shstring)
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
193 {
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
194 execute_command(shstring);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
195 /* FIXME: This can possibly be freed too early */
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
196 g_free(shstring);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
197 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
198 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
199 }
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
200
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201 static void read_config(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
202 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203 ConfigDb *db;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 db = bmp_cfg_db_open();
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
206 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
207 cmd_line = g_strdup("");
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
208 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
209 cmd_line_after = g_strdup("");
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
210 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
211 cmd_line_end = g_strdup("");
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
212 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
213 cmd_line_ttc = g_strdup("");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 bmp_cfg_db_close(db);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
215 }
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 static void cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
218 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
219 hook_dissociate("playback begin", songchange_playback_begin);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
220 hook_dissociate("playback end", songchange_playback_end);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
221 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
222 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
223
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
224 if ( ttc_prevs != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
225 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
226 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
227 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
228 g_free( ttc_prevs );
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
229 ttc_prevs = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
230 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
231
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
232 g_free(cmd_line);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
233 g_free(cmd_line_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 g_free(cmd_line_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
235 g_free(cmd_line_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236 cmd_line = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
237 cmd_line_after = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238 cmd_line_end = NULL;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
239 cmd_line_ttc = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240 signal(SIGCHLD, SIG_DFL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
242 prefswin_page_destroy(configure_vbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
243 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
244
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245 static void save_and_close(GtkWidget *w, gpointer data)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
247 ConfigDb *db;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
248 char *cmd, *cmd_after, *cmd_end, *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 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
251 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
252 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
253 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
254
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255 db = bmp_cfg_db_open();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
256 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
257 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
258 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
259 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
260 bmp_cfg_db_close(db);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
261
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
262 if (cmd_line != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
263 g_free(cmd_line);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
264
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
265 cmd_line = g_strdup(cmd);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
266
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
267 if (cmd_line_after != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
268 g_free(cmd_line_after);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
269
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
270 cmd_line_after = g_strdup(cmd_after);
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
271
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
272 if (cmd_line_end != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
273 g_free(cmd_line_end);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
274
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
275 cmd_line_end = g_strdup(cmd_end);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
276
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
277 if (cmd_line_ttc != NULL)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
278 g_free(cmd_line_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
279
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
280 cmd_line_ttc = g_strdup(cmd_ttc);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
281
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
282 g_free(cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
283 g_free(cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
284 g_free(cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
285 g_free(cmd_ttc);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286 }
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 static int check_command(char *command)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
290 const char *dangerous = "fns";
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 char *c;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
292 int qu = 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 for (c = command; *c != '\0'; c++)
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 if (*c == '"' && (c == command || *(c - 1) != '\\'))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
297 qu = !qu;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
298 else if (*c == '%' && !qu && strchr(dangerous, *(c + 1)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299 return -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
300 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
302 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
303
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304 static void configure_ok_cb(GtkWidget *w, gpointer data)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305 {
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
306 char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 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
309 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
310 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
311 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
312
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
313 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
314 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
315 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
316 gtk_widget_show(cmd_warn_img);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
317 gtk_widget_show(cmd_warn_label);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
318 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
320 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
321 gtk_widget_hide(cmd_warn_img);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322 gtk_widget_hide(cmd_warn_label);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
323 save_and_close(NULL, NULL);
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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 g_free(cmd);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
327 g_free(cmd_after);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328 g_free(cmd_end);
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
329 g_free(cmd_ttc);
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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
333 static GtkWidget *configure(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
334 {
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
335 GtkWidget *sep1, *sep2, *sep3, *sep4;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336 GtkWidget *cmd_hbox, *cmd_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337 GtkWidget *cmd_after_hbox, *cmd_after_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 GtkWidget *cmd_end_hbox, *cmd_end_label;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339 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
340 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
341 GtkWidget *song_frame, *song_vbox;
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
342 GtkWidget *bbox_hbox;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 char *temp;
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 read_config();
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 configure_vbox = gtk_vbox_new(FALSE, 12);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
348
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
349 song_frame = gtk_frame_new(_("Commands"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
350 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
351 song_vbox = gtk_vbox_new(FALSE, 12);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
352 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
353 gtk_container_add(GTK_CONTAINER(song_frame), song_vbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
354
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
355 cmd_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
356 "Command to run when Audacious starts a new song."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
357 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
358 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
359 gtk_box_pack_start(GTK_BOX(song_vbox), cmd_desc, FALSE, FALSE, 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
360 gtk_label_set_line_wrap(GTK_LABEL(cmd_desc), TRUE);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
361
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
362 cmd_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
363 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
364
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
365 cmd_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
366 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
367
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
368 cmd_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
369 if (cmd_line)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
370 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
371 gtk_widget_set_usize(cmd_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
372 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
373
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
374 sep1 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
375 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
376
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_after_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
379 "Command to run toward the end of a song."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
380 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
381 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
382 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
383
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
384 cmd_after_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
385 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
386
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
387 cmd_after_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
388 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
389
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
390 cmd_after_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
391 if (cmd_line_after)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
392 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
393 gtk_widget_set_usize(cmd_after_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
394 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
395 sep2 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
396 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
397
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
398 cmd_end_desc = gtk_label_new(_(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
399 "Command to run when Audacious reaches the end "
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
400 "of the playlist."));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
401 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
402 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
403 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
404
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
405 cmd_end_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
406 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
407
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
408 cmd_end_label = gtk_label_new(_("Command:"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
409 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
410
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
411 cmd_end_entry = gtk_entry_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
412 if (cmd_line_end)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
413 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
414 gtk_widget_set_usize(cmd_end_entry, 200, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
415 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
416 sep3 = gtk_hseparator_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
417 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
418
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
419 cmd_ttc_desc = gtk_label_new(_(
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
420 "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
421 "(i.e. network streams titles)."));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
422 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
423 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
424 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
425
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
426 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
427 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
428
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
429 cmd_ttc_label = gtk_label_new(_("Command:"));
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
430 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
431
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
432 cmd_ttc_entry = gtk_entry_new();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
433 if (cmd_line_ttc)
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
434 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
435 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
436 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
437 sep4 = gtk_hseparator_new();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
438 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
439
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
440 temp = g_strdup_printf(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
441 _("You can use the following format strings which\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
442 "will be substituted before calling the command\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443 "(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
444 "%%F: Frequency (in hertz)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
445 "%%c: Number of channels\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
446 "%%f: filename (full path)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
447 "%%l: length (in milliseconds)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
448 "%%n or %%s: Song name\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
449 "%%r: Rate (in bits per second)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
450 "%%t: Playlist position (%%02d)\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
451 "%%p: Currently playing (1 or 0)"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
452 f_desc = gtk_label_new(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
453 g_free(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
454
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
455 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
456 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
457 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
458
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
459 bbox_hbox = gtk_hbox_new(FALSE, 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
460 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
461
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
462 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
463 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
464
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
465 temp = g_strdup_printf(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
466 _("<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
467 cmd_warn_label = gtk_label_new(temp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
468 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
469 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
470
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
471 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
472 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
473 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
474 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
475
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
476 gtk_widget_show_all(configure_vbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
478 return configure_vbox;
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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
481 static void init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
483 read_config();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
484
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485 configure_vbox = configure();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
486 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
487
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
488 hook_associate("playback begin", songchange_playback_begin, NULL);
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
489 hook_associate("playback end", songchange_playback_end, NULL);
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
490 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
491
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
492 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
493 ttc_prevs->title = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
494 ttc_prevs->filename = NULL;
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
495 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
496
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
497 configure_ok_cb(NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
498 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
499
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
500 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
501 songchange_playback_begin(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
502 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
503 int pos;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
504 char *current_file;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
505
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
506 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
507 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
508
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
509 do_command(cmd_line, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
510
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
511 g_free(current_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
512 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
513
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
514 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
515 songchange_playback_end(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
516 {
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
517 int pos;
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
518 char *current_file;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
519
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
520 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
521 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
522
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
523 do_command(cmd_line_after, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
524
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
525 g_free(current_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
526 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
527
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
528 static void
1212
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
529 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
530 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
531 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
532 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
533 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
534 PlaylistEntry *pl_entry = plentry_gp;
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 /* 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
537
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
538 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
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 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
541 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
542 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
543 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
544 int pos = audacious_drct_pl_get_pos();
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
545 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
546 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
547 g_free(current_file);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
548 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
549 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
550 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
551 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
552 else
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
553 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
554 g_free(prevs->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
555 prevs->filename = g_strdup(pl_entry->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
556 /* if filename changes, reset title as well */
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
557 if ( prevs->title != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
558 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
559 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
560 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
561 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
562 else
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
563 {
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
564 if ( prevs->title != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
565 g_free(prevs->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
566 prevs->title = g_strdup(pl_entry->title);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
567 if ( prevs->filename != NULL )
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
568 g_free(prevs->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
569 prevs->filename = g_strdup(pl_entry->filename);
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
570 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
571 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
572 }
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
573
36cc5e56246e Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents: 1119
diff changeset
574 static void
594
424d51558e0a [svn] - Adapted song_change plugin to new hook functions
mf0102
parents: 552
diff changeset
575 songchange_playlist_eof(gpointer unused, gpointer unused2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
576 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
577 int pos;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
578 char *current_file;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
579
1024
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
580 pos = audacious_drct_pl_get_pos();
7cd2050c6f82 [svn] - migrate to audacious_drct API.
yaz
parents: 594
diff changeset
581 current_file = audacious_drct_pl_get_file(pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
582
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
583 do_command(cmd_line_end, current_file, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
584
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
585 g_free(current_file);
549
f4b8032d08f1 [svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents: 527
diff changeset
586 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
587