Mercurial > audlegacy-plugins
annotate src/song_change/song_change.c @ 2498:194c2f8c2a92
Include cleanups, part #3.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 15:11:29 +0300 |
parents | ed6c81bd9016 |
children | 769e17da93dd |
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/auddrct.h> |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
21 #include "formatter.h" |
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
406
diff
changeset
|
22 #include <audacious/i18n.h> |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
23 #include <audacious/hook.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 static void init(void); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 static void cleanup(void); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 static GtkWidget *configure(void); |
594
424d51558e0a
[svn] - Adapted song_change plugin to new hook functions
mf0102
parents:
552
diff
changeset
|
28 static void songchange_playback_begin(gpointer unused, gpointer unused2); |
424d51558e0a
[svn] - Adapted song_change plugin to new hook functions
mf0102
parents:
552
diff
changeset
|
29 static void songchange_playback_end(gpointer unused, gpointer unused2); |
424d51558e0a
[svn] - Adapted song_change plugin to new hook functions
mf0102
parents:
552
diff
changeset
|
30 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
|
31 static void songchange_playback_ttc(gpointer, gpointer); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
32 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
33 typedef struct |
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 gchar *title; |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
36 gchar *filename; |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
37 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
38 songchange_playback_ttc_prevs_t; |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
39 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
|
40 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 static char *cmd_line = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 static char *cmd_line_after = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 static char *cmd_line_end = NULL; |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
44 static char *cmd_line_ttc = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
46 static GtkWidget *configure_vbox = NULL; |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
47 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
|
48 static GtkWidget *cmd_warn_label, *cmd_warn_img; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 GeneralPlugin sc_gp = |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
51 { |
2149 | 52 .description = "Song Change " PACKAGE_VERSION, |
53 .init = init, | |
54 .cleanup = cleanup, | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
56 |
1119 | 57 GeneralPlugin *songchange_gplist[] = { &sc_gp, NULL }; |
2149 | 58 SIMPLE_GENERAL_PLUGIN(songchange, songchange_gplist); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
59 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
60 static void bury_child(int signal) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
61 { |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
62 waitpid(-1, NULL, WNOHANG); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
63 } |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
64 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
65 static void execute_command(char *cmd) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
66 { |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
67 char *argv[4] = {"/bin/sh", "-c", NULL, NULL}; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
68 int i; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
69 argv[2] = cmd; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
70 signal(SIGCHLD, bury_child); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
71 if (fork() == 0) |
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 /* 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
|
74 for (i = 3; i < 255; i++) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
75 close(i); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
76 execv("/bin/sh", argv); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
77 } |
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 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
80 /* Format codes: |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
81 * |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
82 * F - frequency (in hertz) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
83 * c - number of channels |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
84 * f - filename (full path) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
85 * l - length (in milliseconds) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
86 * n - name |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
87 * r - rate (in bits per second) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
88 * s - name (since everyone's used to it) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
89 * t - playlist position (%02d) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
90 * p - currently playing (1 or 0) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
91 */ |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
92 /* 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
|
93 @cmd: command to run |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
94 @current_file: file name of current song |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
95 @pos: playlist_pos */ |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
96 static void |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
97 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
|
98 { |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
99 int length, rate, freq, nch; |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
100 char *str, *shstring = NULL, *temp, numbuf[32]; |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
101 gboolean playing; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
102 Formatter *formatter; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
103 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
104 if (cmd && strlen(cmd) > 0) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
105 { |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
106 formatter = formatter_new(); |
1024 | 107 str = audacious_drct_pl_get_title(pos); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
108 if (str) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
109 { |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1952
diff
changeset
|
110 temp = aud_escape_shell_chars(str); |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
111 formatter_associate(formatter, 's', temp); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
112 formatter_associate(formatter, 'n', temp); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
113 g_free(str); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
114 g_free(temp); |
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 else |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
117 { |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
118 formatter_associate(formatter, 's', ""); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
119 formatter_associate(formatter, 'n', ""); |
549
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 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
122 if (current_file) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
123 { |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1952
diff
changeset
|
124 temp = aud_escape_shell_chars(current_file); |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
125 formatter_associate(formatter, 'f', temp); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
126 g_free(temp); |
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 else |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
129 formatter_associate(formatter, 'f', ""); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
130 g_snprintf(numbuf, sizeof(numbuf), "%02d", pos + 1); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
131 formatter_associate(formatter, 't', numbuf); |
1024 | 132 length = audacious_drct_pl_get_time(pos); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
133 if (length != -1) |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
134 { |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
135 g_snprintf(numbuf, sizeof(numbuf), "%d", length); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
136 formatter_associate(formatter, 'l', numbuf); |
549
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 else |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
139 formatter_associate(formatter, 'l', "0"); |
1024 | 140 audacious_drct_get_info(&rate, &freq, &nch); |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
141 g_snprintf(numbuf, sizeof(numbuf), "%d", rate); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
142 formatter_associate(formatter, 'r', numbuf); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
143 g_snprintf(numbuf, sizeof(numbuf), "%d", freq); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
144 formatter_associate(formatter, 'F', numbuf); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
145 g_snprintf(numbuf, sizeof(numbuf), "%d", nch); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
146 formatter_associate(formatter, 'c', numbuf); |
1024 | 147 playing = audacious_drct_get_playing(); |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
148 g_snprintf(numbuf, sizeof(numbuf), "%d", playing); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
149 formatter_associate(formatter, 'p', numbuf); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
150 shstring = formatter_format(formatter, cmd); |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
151 formatter_destroy(formatter); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
152 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
153 if (shstring) |
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 execute_command(shstring); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
156 /* FIXME: This can possibly be freed too early */ |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
157 g_free(shstring); |
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 } |
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 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
162 static void read_config(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 ConfigDb *db; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 |
2124 | 166 db = aud_cfg_db_open(); |
167 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line", &cmd_line) ) | |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
168 cmd_line = g_strdup(""); |
2124 | 169 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line_after", &cmd_line_after) ) |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
170 cmd_line_after = g_strdup(""); |
2124 | 171 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line_end", &cmd_line_end) ) |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
172 cmd_line_end = g_strdup(""); |
2124 | 173 if ( !aud_cfg_db_get_string(db, "song_change", "cmd_line_ttc", &cmd_line_ttc) ) |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
174 cmd_line_ttc = g_strdup(""); |
2124 | 175 aud_cfg_db_close(db); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
176 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
178 static void cleanup(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 { |
2060 | 180 aud_hook_dissociate("playback begin", songchange_playback_begin); |
181 aud_hook_dissociate("playback end", songchange_playback_end); | |
182 aud_hook_dissociate("playlist end reached", songchange_playlist_eof); | |
183 aud_hook_dissociate( "playlist set info" , songchange_playback_ttc); | |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
184 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
185 if ( ttc_prevs != NULL ) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
186 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
187 if ( ttc_prevs->title != NULL ) g_free( ttc_prevs->title ); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
188 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
|
189 g_free( ttc_prevs ); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
190 ttc_prevs = NULL; |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
191 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 g_free(cmd_line); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 g_free(cmd_line_after); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
195 g_free(cmd_line_end); |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
196 g_free(cmd_line_ttc); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
197 cmd_line = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 cmd_line_after = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 cmd_line_end = NULL; |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
200 cmd_line_ttc = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 signal(SIGCHLD, SIG_DFL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 |
2071 | 203 aud_prefswin_page_destroy(configure_vbox); |
0
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
206 static void save_and_close(GtkWidget *w, gpointer data) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
207 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
208 ConfigDb *db; |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
209 char *cmd, *cmd_after, *cmd_end, *cmd_ttc; |
0
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 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
|
212 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
|
213 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
|
214 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
|
215 |
2124 | 216 db = aud_cfg_db_open(); |
217 aud_cfg_db_set_string(db, "song_change", "cmd_line", cmd); | |
218 aud_cfg_db_set_string(db, "song_change", "cmd_line_after", cmd_after); | |
219 aud_cfg_db_set_string(db, "song_change", "cmd_line_end", cmd_end); | |
220 aud_cfg_db_set_string(db, "song_change", "cmd_line_ttc", cmd_ttc); | |
221 aud_cfg_db_close(db); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
222 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
223 if (cmd_line != NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
224 g_free(cmd_line); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
225 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
226 cmd_line = g_strdup(cmd); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
227 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
228 if (cmd_line_after != NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
229 g_free(cmd_line_after); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
230 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
231 cmd_line_after = g_strdup(cmd_after); |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
232 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
233 if (cmd_line_end != NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 g_free(cmd_line_end); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
235 |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
236 cmd_line_end = g_strdup(cmd_end); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
238 if (cmd_line_ttc != NULL) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
239 g_free(cmd_line_ttc); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
240 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
241 cmd_line_ttc = g_strdup(cmd_ttc); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
242 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
243 g_free(cmd); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 g_free(cmd_after); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
245 g_free(cmd_end); |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
246 g_free(cmd_ttc); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
247 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
249 static int check_command(char *command) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
251 const char *dangerous = "fns"; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
252 char *c; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
253 int qu = 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 for (c = command; *c != '\0'; c++) |
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 if (*c == '"' && (c == command || *(c - 1) != '\\')) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
258 qu = !qu; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
259 else if (*c == '%' && !qu && strchr(dangerous, *(c + 1))) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 return -1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
262 return 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 static void configure_ok_cb(GtkWidget *w, gpointer data) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 { |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
267 char *cmd, *cmd_after, *cmd_end, *cmd_ttc; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
268 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 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
|
273 |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
274 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
|
275 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
|
276 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 gtk_widget_show(cmd_warn_img); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
278 gtk_widget_show(cmd_warn_label); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
279 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
280 else |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 gtk_widget_hide(cmd_warn_img); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 gtk_widget_hide(cmd_warn_label); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
284 save_and_close(NULL, NULL); |
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 g_free(cmd); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 g_free(cmd_after); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 g_free(cmd_end); |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
290 g_free(cmd_ttc); |
0
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 static GtkWidget *configure(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 { |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
296 GtkWidget *sep1, *sep2, *sep3, *sep4; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
297 GtkWidget *cmd_hbox, *cmd_label; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
298 GtkWidget *cmd_after_hbox, *cmd_after_label; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 GtkWidget *cmd_end_hbox, *cmd_end_label; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
300 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
|
301 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
|
302 GtkWidget *song_frame, *song_vbox; |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
303 GtkWidget *bbox_hbox; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
304 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
|
305 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 read_config(); |
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 configure_vbox = gtk_vbox_new(FALSE, 12); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 song_frame = gtk_frame_new(_("Commands")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
311 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
|
312 song_vbox = gtk_vbox_new(FALSE, 12); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 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
|
314 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
|
315 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 cmd_desc = gtk_label_new(_( |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 "Command to run when Audacious starts a new song.")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 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
|
319 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
|
320 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
|
321 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
|
322 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 cmd_hbox = gtk_hbox_new(FALSE, 6); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 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
|
325 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 cmd_label = gtk_label_new(_("Command:")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
327 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
|
328 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 cmd_entry = gtk_entry_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
330 if (cmd_line) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
331 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
|
332 gtk_widget_set_usize(cmd_entry, 200, -1); |
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_entry, TRUE, TRUE, 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 sep1 = gtk_hseparator_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
336 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
|
337 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
338 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 cmd_after_desc = gtk_label_new(_( |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 "Command to run toward the end of a song.")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 cmd_after_hbox = gtk_hbox_new(FALSE, 6); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
346 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
|
347 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
348 cmd_after_label = gtk_label_new(_("Command:")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
349 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
|
350 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
351 cmd_after_entry = gtk_entry_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
352 if (cmd_line_after) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 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
|
354 gtk_widget_set_usize(cmd_after_entry, 200, -1); |
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_entry, TRUE, TRUE, 0); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
356 sep2 = gtk_hseparator_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 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
|
358 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
359 cmd_end_desc = gtk_label_new(_( |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
360 "Command to run when Audacious reaches the end " |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
361 "of the playlist.")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
362 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
|
363 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
|
364 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
|
365 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
366 cmd_end_hbox = gtk_hbox_new(FALSE, 6); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
367 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
|
368 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
369 cmd_end_label = gtk_label_new(_("Command:")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
370 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
|
371 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
372 cmd_end_entry = gtk_entry_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
373 if (cmd_line_end) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 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
|
375 gtk_widget_set_usize(cmd_end_entry, 200, -1); |
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_entry, TRUE, TRUE, 0); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 sep3 = gtk_hseparator_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
378 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
|
379 |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
380 cmd_ttc_desc = gtk_label_new(_( |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
381 "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
|
382 "(i.e. network streams titles).")); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
383 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
|
384 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
|
385 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
|
386 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
387 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
|
388 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
|
389 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
390 cmd_ttc_label = gtk_label_new(_("Command:")); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
391 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
|
392 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
393 cmd_ttc_entry = gtk_entry_new(); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
394 if (cmd_line_ttc) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 sep4 = gtk_hseparator_new(); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
399 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
|
400 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 temp = g_strdup_printf( |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 _("You can use the following format strings which\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
403 "will be substituted before calling the command\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 "(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
|
405 "%%F: Frequency (in hertz)\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
406 "%%c: Number of channels\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
407 "%%f: filename (full path)\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 "%%l: length (in milliseconds)\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
409 "%%n or %%s: Song name\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 "%%r: Rate (in bits per second)\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 "%%t: Playlist position (%%02d)\n" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 "%%p: Currently playing (1 or 0)")); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 f_desc = gtk_label_new(temp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
414 g_free(temp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
416 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
|
417 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
|
418 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
|
419 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 bbox_hbox = gtk_hbox_new(FALSE, 6); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 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
|
422 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
423 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
|
424 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
|
425 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 temp = g_strdup_printf( |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
427 _("<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
|
428 cmd_warn_label = gtk_label_new(temp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 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
|
430 gtk_box_pack_start(GTK_BOX(bbox_hbox), cmd_warn_label, FALSE, FALSE, 0); |
2269
c44b90b6322e
Fixes memory leak in song change plugin when applying configuration (Bugzilla #48)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2149
diff
changeset
|
431 g_free(temp); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
432 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
433 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
|
434 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
|
435 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
|
436 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
|
437 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
438 gtk_widget_show_all(configure_vbox); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
439 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
440 return configure_vbox; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
441 } |
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 static void init(void) |
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 read_config(); |
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 configure_vbox = configure(); |
2071 | 448 aud_prefswin_page_new(configure_vbox, "Song Change", DATA_DIR "/images/plugins.png"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
449 |
2060 | 450 aud_hook_associate("playback begin", songchange_playback_begin, NULL); |
451 aud_hook_associate("playback end", songchange_playback_end, NULL); | |
452 aud_hook_associate("playlist end reached", songchange_playlist_eof, NULL); | |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
453 |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
454 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
|
455 ttc_prevs->title = NULL; |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
456 ttc_prevs->filename = NULL; |
2060 | 457 aud_hook_associate( "playlist set info" , songchange_playback_ttc , ttc_prevs ); |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
458 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
459 configure_ok_cb(NULL, NULL); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
460 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
461 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
462 static void |
594
424d51558e0a
[svn] - Adapted song_change plugin to new hook functions
mf0102
parents:
552
diff
changeset
|
463 songchange_playback_begin(gpointer unused, gpointer unused2) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
464 { |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
465 int pos; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
466 char *current_file; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
467 |
1024 | 468 pos = audacious_drct_pl_get_pos(); |
469 current_file = audacious_drct_pl_get_file(pos); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
470 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
471 do_command(cmd_line, current_file, pos); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
473 g_free(current_file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
474 } |
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 static void |
594
424d51558e0a
[svn] - Adapted song_change plugin to new hook functions
mf0102
parents:
552
diff
changeset
|
477 songchange_playback_end(gpointer unused, gpointer unused2) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
478 { |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
479 int pos; |
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
480 char *current_file; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
481 |
1024 | 482 pos = audacious_drct_pl_get_pos(); |
483 current_file = audacious_drct_pl_get_file(pos); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
484 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
485 do_command(cmd_line_after, current_file, pos); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
486 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
487 g_free(current_file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
488 } |
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 static void |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
491 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
|
492 { |
2058
fffa7e3d39e0
use aud_ip_state (replacement to ip_data).
William Pitcock <nenolod@atheme.org>
parents:
2051
diff
changeset
|
493 if ( ( aud_ip_state->playing ) && ( strcmp(cmd_line_ttc,"") ) ) |
1212
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
494 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
495 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
|
496 PlaylistEntry *pl_entry = plentry_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 /* 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
|
499 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
500 if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) ) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
501 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
502 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
|
503 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
504 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
|
505 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
506 int pos = audacious_drct_pl_get_pos(); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
507 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
|
508 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
|
509 g_free(current_file); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
510 g_free(prevs->title); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
511 prevs->title = g_strdup(pl_entry->title); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
512 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
513 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
514 else |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
515 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
516 g_free(prevs->filename); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
517 prevs->filename = g_strdup(pl_entry->filename); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
518 /* if filename changes, reset title as well */ |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
519 if ( prevs->title != NULL ) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
520 g_free(prevs->title); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
521 prevs->title = g_strdup(pl_entry->title); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
522 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
523 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
524 else |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
525 { |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
526 if ( prevs->title != NULL ) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
527 g_free(prevs->title); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
528 prevs->title = g_strdup(pl_entry->title); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
529 if ( prevs->filename != NULL ) |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
530 g_free(prevs->filename); |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
531 prevs->filename = g_strdup(pl_entry->filename); |
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 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
534 } |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
535 |
36cc5e56246e
Added title changes event for songchange plugin
Giacomo Lozito <james@develia.org>
parents:
1119
diff
changeset
|
536 static void |
594
424d51558e0a
[svn] - Adapted song_change plugin to new hook functions
mf0102
parents:
552
diff
changeset
|
537 songchange_playlist_eof(gpointer unused, gpointer unused2) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
538 { |
2480
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
539 gint pos; |
f88dd72c9156
Moved formatter stuff to the only plugin that actually used it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2269
diff
changeset
|
540 gchar *current_file; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
541 |
1024 | 542 pos = audacious_drct_pl_get_pos(); |
543 current_file = audacious_drct_pl_get_file(pos); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
544 |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
545 do_command(cmd_line_end, current_file, pos); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
546 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
547 g_free(current_file); |
549
f4b8032d08f1
[svn] - songchange: use asynchronous hooks instead of a polling event
nenolod
parents:
527
diff
changeset
|
548 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
549 |