61
|
1 /* BMP - Cross-platform multimedia player
|
|
2 * Copyright (C) 2003-2004 BMP development team.
|
|
3 *
|
|
4 * Based on XMMS:
|
|
5 * Copyright (C) 1998-2003 XMMS development team.
|
|
6 *
|
|
7 * This program is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
1459
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
61
|
20 */
|
|
21
|
|
22 #include "esdout.h"
|
|
23
|
|
24 #include <glib.h>
|
|
25 #include <glib/gi18n.h>
|
|
26 #include <gtk/gtk.h>
|
|
27 #include <stdlib.h>
|
|
28
|
|
29 #include <libaudacious/configdb.h>
|
|
30
|
|
31
|
|
32 static GtkWidget *configure_win;
|
|
33 static GtkWidget *server_use_remote, *server_oss_mixer, *server_host_entry;
|
|
34 static GtkWidget *server_port_entry, *buffer_size_spin, *buffer_pre_spin;
|
|
35
|
|
36
|
|
37 static void
|
|
38 configure_win_ok_cb(GtkWidget * w, gpointer data)
|
|
39 {
|
|
40 ConfigDb *db;
|
|
41
|
|
42 esd_cfg.use_remote =
|
|
43 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(server_use_remote));
|
|
44 esd_cfg.use_oss_mixer =
|
|
45 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(server_oss_mixer));
|
|
46 if (esd_cfg.server)
|
|
47 g_free(esd_cfg.server);
|
|
48 esd_cfg.server =
|
|
49 g_strdup(gtk_entry_get_text(GTK_ENTRY(server_host_entry)));
|
|
50 esd_cfg.port = atoi(gtk_entry_get_text(GTK_ENTRY(server_port_entry)));
|
|
51 esd_cfg.buffer_size =
|
|
52 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_spin));
|
|
53 esd_cfg.prebuffer =
|
|
54 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_pre_spin));
|
|
55
|
|
56 db = bmp_cfg_db_open();
|
|
57
|
|
58 bmp_cfg_db_set_bool(db, "ESD", "use_remote", esd_cfg.use_remote);
|
|
59 bmp_cfg_db_set_bool(db, "ESD", "use_oss_mixer", esd_cfg.use_oss_mixer);
|
|
60 bmp_cfg_db_set_string(db, "ESD", "remote_host", esd_cfg.server);
|
|
61 bmp_cfg_db_set_int(db, "ESD", "remote_port", esd_cfg.port);
|
|
62 bmp_cfg_db_set_int(db, "ESD", "buffer_size", esd_cfg.buffer_size);
|
|
63 bmp_cfg_db_set_int(db, "ESD", "prebuffer", esd_cfg.prebuffer);
|
|
64 bmp_cfg_db_close(db);
|
|
65
|
|
66 }
|
|
67
|
|
68 static void
|
|
69 use_remote_cb(GtkWidget * w, gpointer data)
|
|
70 {
|
|
71 gboolean use_remote;
|
|
72 GtkWidget *box = data;
|
|
73
|
|
74 use_remote =
|
|
75 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(server_use_remote));
|
|
76
|
|
77 gtk_widget_set_sensitive(box, use_remote);
|
|
78 }
|
|
79
|
|
80 void
|
|
81 esdout_configure(void)
|
|
82 {
|
|
83 GtkWidget *vbox, *notebook;
|
|
84 GtkWidget *server_frame, *server_vbox, *server_hbox, *server_btn_hbox;
|
|
85 GtkWidget *server_host_label, *server_port_label;
|
|
86 GtkWidget *buffer_frame, *buffer_vbox, *buffer_table;
|
|
87 GtkWidget *buffer_size_box, *buffer_size_label;
|
|
88 GtkObject *buffer_size_adj, *buffer_pre_adj;
|
|
89 GtkWidget *buffer_pre_box, *buffer_pre_label;
|
|
90 GtkWidget *bbox, *ok, *cancel;
|
|
91 gchar *temp;
|
|
92
|
|
93 if (configure_win) {
|
|
94 gtk_window_present(GTK_WINDOW(configure_win));
|
|
95 return;
|
|
96 }
|
|
97
|
|
98 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
99 g_signal_connect(G_OBJECT(configure_win), "destroy",
|
|
100 G_CALLBACK(gtk_widget_destroyed), &configure_win);
|
|
101 gtk_window_set_title(GTK_WINDOW(configure_win),
|
|
102 _("ESD Output Plugin configuration"));
|
|
103 gtk_window_set_type_hint(GTK_WINDOW(configure_win),
|
|
104 GDK_WINDOW_TYPE_HINT_DIALOG);
|
|
105 gtk_window_set_resizable(GTK_WINDOW(configure_win), FALSE);
|
|
106 gtk_container_border_width(GTK_CONTAINER(configure_win), 10);
|
|
107
|
|
108 vbox = gtk_vbox_new(FALSE, 10);
|
|
109 gtk_container_add(GTK_CONTAINER(configure_win), vbox);
|
|
110
|
|
111 notebook = gtk_notebook_new();
|
|
112 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
|
|
113
|
|
114 server_frame = gtk_frame_new(_("Host:"));
|
|
115 gtk_container_set_border_width(GTK_CONTAINER(server_frame), 5);
|
|
116
|
|
117 server_vbox = gtk_vbox_new(FALSE, 5);
|
|
118 gtk_container_set_border_width(GTK_CONTAINER(server_vbox), 5);
|
|
119 gtk_container_add(GTK_CONTAINER(server_frame), server_vbox);
|
|
120
|
|
121 server_btn_hbox = gtk_hbox_new(FALSE, 5);
|
|
122 gtk_box_pack_start(GTK_BOX(server_vbox),
|
|
123 server_btn_hbox, FALSE, FALSE, 0);
|
|
124
|
|
125 server_use_remote = gtk_check_button_new_with_label(_("Use remote host"));
|
|
126 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(server_use_remote),
|
|
127 esd_cfg.use_remote);
|
|
128 gtk_box_pack_start(GTK_BOX(server_btn_hbox), server_use_remote,
|
|
129 FALSE, FALSE, 0);
|
|
130
|
|
131 server_oss_mixer =
|
|
132 gtk_check_button_new_with_label(_("Volume controls OSS mixer"));
|
|
133 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(server_oss_mixer),
|
|
134 esd_cfg.use_oss_mixer);
|
|
135 gtk_box_pack_start(GTK_BOX(server_btn_hbox),
|
|
136 server_oss_mixer, TRUE, TRUE, 0);
|
|
137 #if !defined(HAVE_SYS_SOUNDCARD_H) && !defined(HAVE_MACHINE_SOUNDCARD_H)
|
|
138 gtk_widget_set_sensitive(server_oss_mixer, FALSE);
|
|
139 #endif
|
|
140 server_hbox = gtk_hbox_new(FALSE, 5);
|
|
141 gtk_widget_set_sensitive(server_hbox, esd_cfg.use_remote);
|
|
142 gtk_box_pack_start(GTK_BOX(server_vbox), server_hbox, FALSE, FALSE, 0);
|
|
143
|
|
144 server_host_label = gtk_label_new(_("Host:"));
|
|
145 gtk_box_pack_start(GTK_BOX(server_hbox), server_host_label,
|
|
146 FALSE, FALSE, 0);
|
|
147
|
|
148 server_host_entry = gtk_entry_new();
|
|
149 gtk_entry_set_text(GTK_ENTRY(server_host_entry), esd_cfg.server);
|
|
150 gtk_box_pack_start(GTK_BOX(server_hbox), server_host_entry,
|
|
151 TRUE, TRUE, 0);
|
|
152
|
|
153 server_port_label = gtk_label_new(_("Port:"));
|
|
154 gtk_box_pack_start(GTK_BOX(server_hbox), server_port_label,
|
|
155 FALSE, FALSE, 0);
|
|
156
|
|
157 server_port_entry = gtk_entry_new();
|
|
158 gtk_widget_set_usize(server_port_entry, 50, -1);
|
|
159 temp = g_strdup_printf("%d", esd_cfg.port);
|
|
160 gtk_entry_set_text(GTK_ENTRY(server_port_entry), temp);
|
|
161 g_free(temp);
|
|
162 gtk_box_pack_start(GTK_BOX(server_hbox), server_port_entry,
|
|
163 FALSE, FALSE, 0);
|
|
164
|
|
165 g_signal_connect(G_OBJECT(server_use_remote), "clicked",
|
|
166 G_CALLBACK(use_remote_cb), server_hbox);
|
|
167
|
|
168 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), server_frame,
|
|
169 gtk_label_new(_("Server")));
|
|
170
|
|
171 buffer_frame = gtk_frame_new(_("Buffering:"));
|
|
172 gtk_container_set_border_width(GTK_CONTAINER(buffer_frame), 5);
|
|
173
|
|
174 buffer_vbox = gtk_vbox_new(FALSE, 0);
|
|
175 gtk_container_add(GTK_CONTAINER(buffer_frame), buffer_vbox);
|
|
176
|
|
177 buffer_table = gtk_table_new(2, 1, TRUE);
|
|
178 gtk_container_set_border_width(GTK_CONTAINER(buffer_table), 5);
|
|
179 gtk_box_pack_start(GTK_BOX(buffer_vbox), buffer_table, FALSE, FALSE, 0);
|
|
180
|
|
181 buffer_size_box = gtk_hbox_new(FALSE, 5);
|
|
182 gtk_table_attach_defaults(GTK_TABLE(buffer_table),
|
|
183 buffer_size_box, 0, 1, 0, 1);
|
|
184 buffer_size_label = gtk_label_new(_("Buffer size (ms):"));
|
|
185 gtk_box_pack_start(GTK_BOX(buffer_size_box),
|
|
186 buffer_size_label, FALSE, FALSE, 0);
|
|
187 buffer_size_adj = gtk_adjustment_new(esd_cfg.buffer_size,
|
|
188 200, 10000, 100, 100, 100);
|
|
189 buffer_size_spin =
|
|
190 gtk_spin_button_new(GTK_ADJUSTMENT(buffer_size_adj), 8, 0);
|
|
191 gtk_widget_set_usize(buffer_size_spin, 60, -1);
|
|
192 gtk_box_pack_start(GTK_BOX(buffer_size_box),
|
|
193 buffer_size_spin, FALSE, FALSE, 0);
|
|
194
|
|
195 buffer_pre_box = gtk_hbox_new(FALSE, 5);
|
|
196 gtk_table_attach_defaults(GTK_TABLE(buffer_table),
|
|
197 buffer_pre_box, 1, 2, 0, 1);
|
|
198 buffer_pre_label = gtk_label_new(_("Pre-buffer (percent):"));
|
|
199 gtk_box_pack_start(GTK_BOX(buffer_pre_box),
|
|
200 buffer_pre_label, FALSE, FALSE, 0);
|
|
201 buffer_pre_adj = gtk_adjustment_new(esd_cfg.prebuffer, 0, 90, 1, 1, 1);
|
|
202 buffer_pre_spin =
|
|
203 gtk_spin_button_new(GTK_ADJUSTMENT(buffer_pre_adj), 1, 0);
|
|
204 gtk_widget_set_usize(buffer_pre_spin, 60, -1);
|
|
205 gtk_box_pack_start(GTK_BOX(buffer_pre_box),
|
|
206 buffer_pre_spin, FALSE, FALSE, 0);
|
|
207
|
|
208 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
|
|
209 buffer_frame, gtk_label_new(_("Buffering")));
|
|
210
|
|
211 bbox = gtk_hbutton_box_new();
|
|
212 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
|
213 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
|
|
214 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
215
|
|
216 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
|
217 g_signal_connect_swapped(G_OBJECT(cancel), "clicked",
|
|
218 G_CALLBACK(gtk_widget_destroy),
|
|
219 GTK_OBJECT(configure_win));
|
|
220 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
|
|
221 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
|
|
222
|
|
223 ok = gtk_button_new_from_stock(GTK_STOCK_APPLY);
|
|
224 g_signal_connect(G_OBJECT(ok), "clicked",
|
|
225 G_CALLBACK(configure_win_ok_cb), NULL);
|
|
226 GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
|
|
227 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
|
|
228 gtk_widget_grab_default(ok);
|
|
229
|
|
230 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_CENTER);
|
|
231 gtk_widget_show_all(configure_win);
|
|
232 }
|