comparison src/skins/ui_main.c @ 2592:8f5999909416

add ui_main - with huge amount of #if 0 to sort out later
author Tomasz Mon <desowin@gmail.com>
date Tue, 20 May 2008 22:12:14 +0200
parents
children 7cd898f08f31
comparison
equal deleted inserted replaced
2591:e6f015ac0421 2592:8f5999909416
1 /* Audacious - Cross-platform multimedia player
2 * Copyright (C) 2005-2006 Audacious development team.
3 *
4 * BMP - Cross-platform multimedia player
5 * Copyright (C) 2003-2004 BMP development team.
6 *
7 * Based on XMMS:
8 * Copyright (C) 1998-2003 XMMS development team.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; under version 3 of the License.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
21 *
22 * The Audacious team does not consider modular code linking to
23 * Audacious or using our public API to be a derived work.
24 */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include <glib/gprintf.h>
33 #include <gtk/gtk.h>
34 #include <gtk/gtkmessagedialog.h>
35 #include <math.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <sys/types.h>
39
40 /* GDK including */
41 #include "platform/smartinclude.h"
42
43 #if defined(USE_REGEX_ONIGURUMA)
44 #include <onigposix.h>
45 #elif defined(USE_REGEX_PCRE)
46 #include <pcreposix.h>
47 #else
48 #include <regex.h>
49 #endif
50
51 #include "ui_main.h"
52 #include "ui_dock.h"
53 #if 0
54 #include "icons-stock.h"
55 #include "actions-mainwin.h"
56 #include "configdb.h"
57 #include "dnd.h"
58 #include "input.h"
59 #include "main.h"
60 #include "playback.h"
61 #include "playlist.h"
62 #include "pluginenum.h"
63 #include "strings.h"
64 #include "ui_credits.h"
65 #include "ui_dock.h"
66 #include "ui_equalizer.h"
67 #include "ui_fileinfo.h"
68 #include "ui_fileopener.h"
69 #include "ui_hints.h"
70 #include "ui_jumptotrack.h"
71 #include "ui_main_evlisteners.h"
72 #include "ui_manager.h"
73 #include "ui_playlist.h"
74 #include "ui_preferences.h"
75 #include "ui_skinselector.h"
76 #include "ui_urlopener.h"
77 #include "util.h"
78 #include "visualization.h"
79 #endif
80 #include "ui_skinned_window.h"
81 #include "ui_skinned_button.h"
82 #include "ui_skinned_textbox.h"
83 #include "ui_skinned_number.h"
84 #include "ui_skinned_horizontal_slider.h"
85 #include "ui_skinned_menurow.h"
86 #include "ui_skinned_playstatus.h"
87 #include "ui_skinned_monostereo.h"
88 #if 0
89 #include "ui_skinned_playlist.h"
90 #endif
91 #include <audacious/plugin.h>
92 #include "skins_cfg.h"
93
94 static GTimeVal cb_time;
95 static const int TRISTATE_THRESHOLD = 200;
96
97 enum {
98 MAINWIN_SEEK_REV = -1,
99 MAINWIN_SEEK_NIL,
100 MAINWIN_SEEK_FWD
101 };
102
103 GtkWidget *mainwin = NULL;
104
105 static gint balance;
106
107 static GtkWidget *mainwin_jtt = NULL;
108
109 static gint seek_state = MAINWIN_SEEK_NIL;
110 static gint seek_initial_pos = 0;
111
112 static GtkWidget *mainwin_menubtn;
113 static GtkWidget *mainwin_minimize, *mainwin_shade, *mainwin_close;
114
115 static GtkWidget *mainwin_rew, *mainwin_fwd;
116 static GtkWidget *mainwin_eject;
117 static GtkWidget *mainwin_play, *mainwin_pause, *mainwin_stop;
118
119 static GtkWidget *mainwin_shuffle, *mainwin_repeat;
120 GtkWidget *mainwin_eq, *mainwin_pl;
121
122 GtkWidget *mainwin_info;
123 GtkWidget *mainwin_stime_min, *mainwin_stime_sec;
124
125 static GtkWidget *mainwin_rate_text, *mainwin_freq_text, *mainwin_othertext;
126
127 GtkWidget *mainwin_playstatus;
128
129 GtkWidget *mainwin_minus_num, *mainwin_10min_num, *mainwin_min_num;
130 GtkWidget *mainwin_10sec_num, *mainwin_sec_num;
131
132 GtkWidget *mainwin_vis;
133 GtkWidget *mainwin_svis;
134
135 GtkWidget *mainwin_sposition = NULL;
136
137 static GtkWidget *mainwin_menurow;
138 static GtkWidget *mainwin_volume, *mainwin_balance;
139 GtkWidget *mainwin_position;
140
141 static GtkWidget *mainwin_monostereo;
142 static GtkWidget *mainwin_srew, *mainwin_splay, *mainwin_spause;
143 static GtkWidget *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about;
144
145 static gint mainwin_timeout_id;
146
147 static gboolean mainwin_info_text_locked = FALSE;
148 static guint mainwin_volume_release_timeout = 0;
149
150 static int ab_position_a = -1;
151 static int ab_position_b = -1;
152
153 static void mainwin_refresh_visible(void);
154 static gint mainwin_idle_func(gpointer data);
155
156 static void set_timer_mode_menu_cb(TimerMode mode);
157 static void set_timer_mode(TimerMode mode);
158 static void change_timer_mode(void);
159
160 static void mainwin_position_motion_cb(GtkWidget *widget, gint pos);
161 static void mainwin_position_release_cb(GtkWidget *widget, gint pos);
162
163 static void set_scaled(gboolean scaled);
164 static void mainwin_eq_pushed(gboolean toggled);
165 static void mainwin_pl_pushed(gboolean toggled);
166
167 static void
168 mainwin_set_title_scroll(gboolean scroll)
169 {
170 config.autoscroll = scroll;
171 ui_skinned_textbox_set_scroll(mainwin_info, config.autoscroll);
172 }
173
174
175 void
176 mainwin_set_always_on_top(gboolean always)
177 {
178 #if 0
179 GtkAction *action = gtk_action_group_get_action(toggleaction_group_others,
180 "view always on top");
181 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , always );
182 #endif
183 }
184
185 static void
186 mainwin_set_shade(gboolean shaded)
187 {
188 #if 0
189 GtkAction *action = gtk_action_group_get_action(toggleaction_group_others,
190 "roll up player");
191 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded );
192 #endif
193 }
194
195 static void
196 mainwin_set_shade_menu_cb(gboolean shaded)
197 {
198 config.player_shaded = shaded;
199
200 if (shaded) {
201 dock_shade(get_dock_window_list(), GTK_WINDOW(mainwin),
202 MAINWIN_SHADED_HEIGHT * MAINWIN_SCALE_FACTOR);
203 } else {
204 gint height = !aud_active_skin->properties.mainwin_height ? MAINWIN_HEIGHT :
205 aud_active_skin->properties.mainwin_height;
206
207 dock_shade(get_dock_window_list(), GTK_WINDOW(mainwin), height * MAINWIN_SCALE_FACTOR);
208 }
209
210 mainwin_refresh_hints();
211 ui_skinned_set_push_button_data(mainwin_shade, 0, config.player_shaded ? 27 : 18, 9, config.player_shaded ? 27 : 18);
212 gtk_widget_shape_combine_mask(mainwin, skin_get_mask(aud_active_skin, SKIN_MASK_MAIN + config.player_shaded), 0, 0);
213 }
214
215 static void
216 mainwin_vis_set_refresh(RefreshRate rate)
217 {
218 config.vis_refresh = rate;
219 }
220
221 static void
222 mainwin_vis_set_afalloff(FalloffSpeed speed)
223 {
224 config.analyzer_falloff = speed;
225 }
226
227 static void
228 mainwin_vis_set_pfalloff(FalloffSpeed speed)
229 {
230 config.peaks_falloff = speed;
231 }
232
233 static void
234 mainwin_vis_set_analyzer_mode(AnalyzerMode mode)
235 {
236 config.analyzer_mode = mode;
237 }
238
239 static void
240 mainwin_vis_set_analyzer_type(AnalyzerType mode)
241 {
242 config.analyzer_type = mode;
243 }
244
245 void
246 mainwin_vis_set_type(VisType mode)
247 {
248 #if 0
249 GtkAction *action;
250
251 switch ( mode )
252 {
253 case VIS_ANALYZER:
254 action = gtk_action_group_get_action(radioaction_group_vismode,
255 "vismode analyzer");
256 break;
257 case VIS_SCOPE:
258 action = gtk_action_group_get_action(radioaction_group_vismode,
259 "vismode scope");
260 break;
261 case VIS_VOICEPRINT:
262 action = gtk_action_group_get_action(radioaction_group_vismode,
263 "vismode voiceprint");
264 break;
265 case VIS_OFF:
266 default:
267 action = gtk_action_group_get_action(radioaction_group_vismode,
268 "vismode off");
269 break;
270 }
271
272 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE );
273 #endif
274 }
275
276 static void
277 mainwin_vis_set_type_menu_cb(VisType mode)
278 {
279 config.vis_type = mode;
280
281 if (mode == VIS_OFF) {
282 if (config.player_shaded) {
283 ui_svis_set_visible(mainwin_svis, FALSE);
284 ui_vis_set_visible(mainwin_vis, TRUE);
285 } else {
286 ui_svis_set_visible(mainwin_svis, TRUE);
287 ui_vis_set_visible(mainwin_vis, FALSE);
288 }
289 }
290 if (mode == VIS_ANALYZER || mode == VIS_SCOPE || mode == VIS_VOICEPRINT) {
291 if (config.player_shaded) {
292 ui_svis_clear_data(mainwin_svis);
293 ui_svis_set_visible(mainwin_svis, TRUE);
294 ui_vis_clear_data(mainwin_vis);
295 ui_vis_set_visible(mainwin_vis, FALSE);
296 } else {
297 ui_svis_clear_data(mainwin_svis);
298 ui_svis_set_visible(mainwin_svis, FALSE);
299 ui_vis_clear_data(mainwin_vis);
300 ui_vis_set_visible(mainwin_vis, TRUE);
301 }
302 }
303 }
304
305 static void
306 mainwin_menubtn_cb(void)
307 {
308 #if 0
309 gint x, y;
310 gtk_window_get_position(GTK_WINDOW(mainwin), &x, &y);
311 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu),
312 x + 6 * MAINWIN_SCALE_FACTOR ,
313 y + MAINWIN_SHADED_HEIGHT * MAINWIN_SCALE_FACTOR,
314 1, GDK_CURRENT_TIME);
315 #endif
316 }
317
318 void
319 mainwin_minimize_cb(void)
320 {
321 if (!mainwin)
322 return;
323
324 gtk_window_iconify(GTK_WINDOW(mainwin));
325 }
326
327 static void
328 mainwin_shade_toggle(void)
329 {
330 mainwin_set_shade(!config.player_shaded);
331 }
332
333 void
334 mainwin_quit_cb(void)
335 {
336 if (mainwin_timeout_id)
337 g_source_remove(mainwin_timeout_id);
338
339 audacious_drct_quit();
340 }
341
342 gboolean
343 mainwin_vis_cb(GtkWidget *widget, GdkEventButton *event)
344 {
345 if (event->button == 1) {
346 config.vis_type++;
347
348 if (config.vis_type > VIS_OFF)
349 config.vis_type = VIS_ANALYZER;
350
351 mainwin_vis_set_type(config.vis_type);
352 } else if (event->button == 3) {
353 #if 0
354 ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu),
355 event->x_root, event->y_root, 3,
356 event->time);
357 #endif
358 }
359 return TRUE;
360 }
361
362 static void
363 mainwin_destroy(GtkWidget * widget, gpointer data)
364 {
365 mainwin_quit_cb();
366 }
367
368 static gchar *mainwin_tb_old_text = NULL;
369
370 void
371 mainwin_lock_info_text(const gchar * text)
372 {
373 if (mainwin_info_text_locked != TRUE)
374 mainwin_tb_old_text = g_strdup(aud_active_skin->properties.mainwin_othertext_is_status ?
375 UI_SKINNED_TEXTBOX(mainwin_othertext)->text : UI_SKINNED_TEXTBOX(mainwin_info)->text);
376
377 mainwin_info_text_locked = TRUE;
378 if (aud_active_skin->properties.mainwin_othertext_is_status)
379 ui_skinned_textbox_set_text(mainwin_othertext, text);
380 else
381 ui_skinned_textbox_set_text(mainwin_info, text);
382 }
383
384 void
385 mainwin_release_info_text(void)
386 {
387 mainwin_info_text_locked = FALSE;
388
389 if (mainwin_tb_old_text != NULL)
390 {
391 if (aud_active_skin->properties.mainwin_othertext_is_status)
392 ui_skinned_textbox_set_text(mainwin_othertext, mainwin_tb_old_text);
393 else
394 ui_skinned_textbox_set_text(mainwin_info, mainwin_tb_old_text);
395 g_free(mainwin_tb_old_text);
396 mainwin_tb_old_text = NULL;
397 }
398 }
399
400
401 static gchar *
402 make_mainwin_title(const gchar * title)
403 {
404 if (title)
405 return g_strdup_printf(_("%s - Audacious"), title);
406 else
407 return g_strdup(_("Audacious"));
408 }
409
410 void
411 mainwin_set_song_title(const gchar * title)
412 {
413 gchar *mainwin_title_text = make_mainwin_title(title);
414 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text);
415 g_free(mainwin_title_text);
416 }
417
418 static void
419 mainwin_refresh_visible(void)
420 {
421 if (!aud_active_skin || !config.player_visible)
422 return;
423
424 gtk_widget_show_all(mainwin);
425
426 if (!aud_active_skin->properties.mainwin_text_visible)
427 gtk_widget_hide(mainwin_info);
428
429 if (!aud_active_skin->properties.mainwin_vis_visible)
430 gtk_widget_hide(mainwin_vis);
431
432 if (!aud_active_skin->properties.mainwin_menurow_visible)
433 gtk_widget_hide(mainwin_menurow);
434
435 if (aud_active_skin->properties.mainwin_othertext) {
436 gtk_widget_hide(mainwin_rate_text);
437 gtk_widget_hide(mainwin_freq_text);
438 gtk_widget_hide(mainwin_monostereo);
439
440 if (!aud_active_skin->properties.mainwin_othertext_visible)
441 gtk_widget_hide(mainwin_othertext);
442 } else {
443 gtk_widget_hide(mainwin_othertext);
444 }
445
446 if (!aud_active_skin->properties.mainwin_vis_visible)
447 gtk_widget_hide(mainwin_vis);
448
449 if (!audacious_drct_get_playing()) {
450 gtk_widget_hide(mainwin_minus_num);
451 gtk_widget_hide(mainwin_10min_num);
452 gtk_widget_hide(mainwin_min_num);
453 gtk_widget_hide(mainwin_10sec_num);
454 gtk_widget_hide(mainwin_sec_num);
455
456 gtk_widget_hide(mainwin_stime_min);
457 gtk_widget_hide(mainwin_stime_sec);
458
459 gtk_widget_hide(mainwin_position);
460 gtk_widget_hide(mainwin_sposition);
461 }
462
463 if (config.player_shaded) {
464 ui_svis_clear_data(mainwin_svis);
465 if (config.vis_type != VIS_OFF)
466 ui_svis_set_visible(mainwin_svis, TRUE);
467 else
468 ui_svis_set_visible(mainwin_svis, FALSE);
469
470 ui_skinned_textbox_set_scroll(mainwin_info, FALSE);
471 if (!audacious_drct_get_playing()) {
472 gtk_widget_hide(mainwin_sposition);
473 gtk_widget_hide(mainwin_stime_min);
474 gtk_widget_hide(mainwin_stime_sec);
475 }
476 } else {
477 gtk_widget_hide(mainwin_srew);
478 gtk_widget_hide(mainwin_splay);
479 gtk_widget_hide(mainwin_spause);
480 gtk_widget_hide(mainwin_sstop);
481 gtk_widget_hide(mainwin_sfwd);
482 gtk_widget_hide(mainwin_seject);
483 gtk_widget_hide(mainwin_stime_min);
484 gtk_widget_hide(mainwin_stime_sec);
485 gtk_widget_hide(mainwin_svis);
486 gtk_widget_hide(mainwin_sposition);
487 ui_vis_clear_data(mainwin_vis);
488 if (config.vis_type != VIS_OFF)
489 ui_vis_set_visible(mainwin_vis, TRUE);
490 else
491 ui_vis_set_visible(mainwin_vis, FALSE);
492
493 ui_skinned_textbox_set_scroll(mainwin_info, config.autoscroll);
494 }
495 }
496
497 void
498 mainwin_refresh_hints(void)
499 {
500 /* positioning and size attributes */
501 if (aud_active_skin->properties.mainwin_vis_x && aud_active_skin->properties.mainwin_vis_y)
502 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_vis), aud_active_skin->properties.mainwin_vis_x,
503 aud_active_skin->properties.mainwin_vis_y);
504
505 if (aud_active_skin->properties.mainwin_vis_width)
506 gtk_widget_set_size_request(mainwin_vis, aud_active_skin->properties.mainwin_vis_width * MAINWIN_SCALE_FACTOR,
507 UI_VIS(mainwin_vis)->height* MAINWIN_SCALE_FACTOR);
508
509 if (aud_active_skin->properties.mainwin_text_x && aud_active_skin->properties.mainwin_text_y)
510 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_info), aud_active_skin->properties.mainwin_text_x,
511 aud_active_skin->properties.mainwin_text_y);
512
513 if (aud_active_skin->properties.mainwin_text_width) {
514 UI_SKINNED_TEXTBOX(mainwin_info)->width = aud_active_skin->properties.mainwin_text_width;
515 gtk_widget_set_size_request(mainwin_info, aud_active_skin->properties.mainwin_text_width * MAINWIN_SCALE_FACTOR,
516 UI_SKINNED_TEXTBOX(mainwin_info)->height * MAINWIN_SCALE_FACTOR );
517 }
518
519 if (aud_active_skin->properties.mainwin_infobar_x && aud_active_skin->properties.mainwin_infobar_y)
520 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_othertext), aud_active_skin->properties.mainwin_infobar_x,
521 aud_active_skin->properties.mainwin_infobar_y);
522
523 if (aud_active_skin->properties.mainwin_number_0_x && aud_active_skin->properties.mainwin_number_0_y)
524 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_minus_num), aud_active_skin->properties.mainwin_number_0_x,
525 aud_active_skin->properties.mainwin_number_0_y);
526
527 if (aud_active_skin->properties.mainwin_number_1_x && aud_active_skin->properties.mainwin_number_1_y)
528 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_10min_num), aud_active_skin->properties.mainwin_number_1_x,
529 aud_active_skin->properties.mainwin_number_1_y);
530
531 if (aud_active_skin->properties.mainwin_number_2_x && aud_active_skin->properties.mainwin_number_2_y)
532 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_min_num), aud_active_skin->properties.mainwin_number_2_x,
533 aud_active_skin->properties.mainwin_number_2_y);
534
535 if (aud_active_skin->properties.mainwin_number_3_x && aud_active_skin->properties.mainwin_number_3_y)
536 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_10sec_num), aud_active_skin->properties.mainwin_number_3_x,
537 aud_active_skin->properties.mainwin_number_3_y);
538
539 if (aud_active_skin->properties.mainwin_number_4_x && aud_active_skin->properties.mainwin_number_4_y)
540 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_sec_num), aud_active_skin->properties.mainwin_number_4_x,
541 aud_active_skin->properties.mainwin_number_4_y);
542
543 if (aud_active_skin->properties.mainwin_playstatus_x && aud_active_skin->properties.mainwin_playstatus_y)
544 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), mainwin_playstatus, aud_active_skin->properties.mainwin_playstatus_x,
545 aud_active_skin->properties.mainwin_playstatus_y);
546
547 if (aud_active_skin->properties.mainwin_volume_x && aud_active_skin->properties.mainwin_volume_y)
548 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_volume), aud_active_skin->properties.mainwin_volume_x,
549 aud_active_skin->properties.mainwin_volume_y);
550
551 if (aud_active_skin->properties.mainwin_balance_x && aud_active_skin->properties.mainwin_balance_y)
552 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_balance), aud_active_skin->properties.mainwin_balance_x,
553 aud_active_skin->properties.mainwin_balance_y);
554
555 if (aud_active_skin->properties.mainwin_position_x && aud_active_skin->properties.mainwin_position_y)
556 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_position), aud_active_skin->properties.mainwin_position_x,
557 aud_active_skin->properties.mainwin_position_y);
558
559 if (aud_active_skin->properties.mainwin_previous_x && aud_active_skin->properties.mainwin_previous_y)
560 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), mainwin_rew, aud_active_skin->properties.mainwin_previous_x,
561 aud_active_skin->properties.mainwin_previous_y);
562
563 if (aud_active_skin->properties.mainwin_play_x && aud_active_skin->properties.mainwin_play_y)
564 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_play), aud_active_skin->properties.mainwin_play_x,
565 aud_active_skin->properties.mainwin_play_y);
566
567 if (aud_active_skin->properties.mainwin_pause_x && aud_active_skin->properties.mainwin_pause_y)
568 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_pause), aud_active_skin->properties.mainwin_pause_x,
569 aud_active_skin->properties.mainwin_pause_y);
570
571 if (aud_active_skin->properties.mainwin_stop_x && aud_active_skin->properties.mainwin_stop_y)
572 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_stop), aud_active_skin->properties.mainwin_stop_x,
573 aud_active_skin->properties.mainwin_stop_y);
574
575 if (aud_active_skin->properties.mainwin_next_x && aud_active_skin->properties.mainwin_next_y)
576 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_fwd), aud_active_skin->properties.mainwin_next_x,
577 aud_active_skin->properties.mainwin_next_y);
578
579 if (aud_active_skin->properties.mainwin_eject_x && aud_active_skin->properties.mainwin_eject_y)
580 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_eject), aud_active_skin->properties.mainwin_eject_x,
581 aud_active_skin->properties.mainwin_eject_y);
582
583 if (aud_active_skin->properties.mainwin_eqbutton_x && aud_active_skin->properties.mainwin_eqbutton_y)
584 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_eq), aud_active_skin->properties.mainwin_eqbutton_x,
585 aud_active_skin->properties.mainwin_eqbutton_y);
586
587 if (aud_active_skin->properties.mainwin_plbutton_x && aud_active_skin->properties.mainwin_plbutton_y)
588 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_pl), aud_active_skin->properties.mainwin_plbutton_x,
589 aud_active_skin->properties.mainwin_plbutton_y);
590
591 if (aud_active_skin->properties.mainwin_shuffle_x && aud_active_skin->properties.mainwin_shuffle_y)
592 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_shuffle), aud_active_skin->properties.mainwin_shuffle_x,
593 aud_active_skin->properties.mainwin_shuffle_y);
594
595 if (aud_active_skin->properties.mainwin_repeat_x && aud_active_skin->properties.mainwin_repeat_y)
596 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_repeat), aud_active_skin->properties.mainwin_repeat_x,
597 aud_active_skin->properties.mainwin_repeat_y);
598
599 if (aud_active_skin->properties.mainwin_about_x && aud_active_skin->properties.mainwin_about_y)
600 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_about), aud_active_skin->properties.mainwin_about_x,
601 aud_active_skin->properties.mainwin_about_y);
602
603 if (aud_active_skin->properties.mainwin_minimize_x && aud_active_skin->properties.mainwin_minimize_y)
604 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_minimize), config.player_shaded ? 244 : aud_active_skin->properties.mainwin_minimize_x,
605 config.player_shaded ? 3 : aud_active_skin->properties.mainwin_minimize_y);
606
607 if (aud_active_skin->properties.mainwin_shade_x && aud_active_skin->properties.mainwin_shade_y)
608 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_shade), config.player_shaded ? 254 : aud_active_skin->properties.mainwin_shade_x,
609 config.player_shaded ? 3 : aud_active_skin->properties.mainwin_shade_y);
610
611 if (aud_active_skin->properties.mainwin_close_x && aud_active_skin->properties.mainwin_close_y)
612 gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_close), config.player_shaded ? 264 : aud_active_skin->properties.mainwin_close_x,
613 config.player_shaded ? 3 : aud_active_skin->properties.mainwin_close_y);
614
615 mainwin_refresh_visible();
616
617 /* window size, mainwinWidth && mainwinHeight properties */
618 if (aud_active_skin->properties.mainwin_height && aud_active_skin->properties.mainwin_width)
619 {
620 dock_window_resize(GTK_WINDOW(mainwin), config.player_shaded ? MAINWIN_SHADED_WIDTH * MAINWIN_SCALE_FACTOR : aud_active_skin->properties.mainwin_width * MAINWIN_SCALE_FACTOR,
621 config.player_shaded ? MAINWIN_SHADED_HEIGHT * MAINWIN_SCALE_FACTOR : aud_active_skin->properties.mainwin_height * MAINWIN_SCALE_FACTOR,
622 aud_active_skin->properties.mainwin_width * MAINWIN_SCALE_FACTOR,
623 aud_active_skin->properties.mainwin_height * MAINWIN_SCALE_FACTOR);
624
625 gdk_flush();
626 }
627 }
628
629 void
630 mainwin_set_song_info(gint bitrate,
631 gint frequency,
632 gint n_channels)
633 {
634 #if 0
635 gchar *text;
636 gchar *title;
637 Playlist *playlist = aud_playlist_get_active();
638
639 playback_set_sample_params(bitrate, frequency, n_channels);
640
641 GDK_THREADS_ENTER();
642 if (bitrate != -1) {
643 bitrate /= 1000;
644
645 if (bitrate < 1000) {
646 /* Show bitrate in 1000s */
647 text = g_strdup_printf("%3d", bitrate);
648 }
649 else {
650 /* Show bitrate in 100,000s */
651 text = g_strdup_printf("%2dH", bitrate / 100);
652 }
653 ui_skinned_textbox_set_text(mainwin_rate_text, text);
654 g_free(text);
655 }
656 else
657 ui_skinned_textbox_set_text(mainwin_rate_text, _("VBR"));
658
659 /* Show sampling frequency in kHz */
660 text = g_strdup_printf("%2d", frequency / 1000);
661 ui_skinned_textbox_set_text(mainwin_freq_text, text);
662 g_free(text);
663
664 ui_skinned_monostereo_set_num_channels(mainwin_monostereo, n_channels);
665
666 if (!audacious_drct_get_paused() && mainwin_playstatus != NULL)
667 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
668
669 if (aud_active_skin && aud_active_skin->properties.mainwin_othertext)
670 {
671 if (bitrate != -1)
672 text = g_strdup_printf("%d kbps, %0.1f kHz, %s",
673 bitrate,
674 (gfloat) frequency / 1000,
675 (n_channels > 1) ? _("stereo") : _("mono"));
676 else
677 text = g_strdup_printf("VBR, %0.1f kHz, %s",
678 (gfloat) frequency / 1000,
679 (n_channels > 1) ? _("stereo") : _("mono"));
680
681 ui_skinned_textbox_set_text(mainwin_othertext, text);
682 g_free(text);
683 }
684
685 title = playlist_get_info_text(playlist);
686 mainwin_set_song_title(title);
687 g_free(title);
688 GDK_THREADS_LEAVE();
689 #endif
690 }
691
692 void
693 mainwin_clear_song_info(void)
694 {
695 #if 0
696 if (!mainwin)
697 return;
698
699 /* clear title */
700 mainwin_set_song_title(NULL);
701
702 /* clear sampling parameters */
703 playback_set_sample_params(0, 0, 0);
704
705 UI_SKINNED_HORIZONTAL_SLIDER(mainwin_position)->pressed = FALSE;
706 UI_SKINNED_HORIZONTAL_SLIDER(mainwin_sposition)->pressed = FALSE;
707
708 /* clear sampling parameter displays */
709 ui_skinned_textbox_set_text(mainwin_rate_text, " ");
710 ui_skinned_textbox_set_text(mainwin_freq_text, " ");
711 ui_skinned_monostereo_set_num_channels(mainwin_monostereo, 0);
712
713 if (mainwin_playstatus != NULL)
714 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_STOP);
715
716 mainwin_refresh_visible();
717
718 playlistwin_hide_timer();
719 #endif
720 ui_vis_clear_data(mainwin_vis);
721 ui_svis_clear_data(mainwin_svis);
722 }
723
724 void
725 mainwin_disable_seekbar(void)
726 {
727 if (!mainwin)
728 return;
729
730 gtk_widget_hide(mainwin_position);
731 gtk_widget_hide(mainwin_sposition);
732 }
733
734 static gboolean
735 mainwin_mouse_button_release(GtkWidget * widget,
736 GdkEventButton * event,
737 gpointer callback_data)
738 {
739 if (dock_is_moving(GTK_WINDOW(mainwin))) {
740 dock_move_release(GTK_WINDOW(mainwin));
741 }
742
743 return FALSE;
744 }
745
746 void
747 mainwin_scrolled(GtkWidget *widget, GdkEventScroll *event,
748 gpointer callback_data)
749 {
750 Playlist *playlist = aud_playlist_get_active();
751
752 switch (event->direction) {
753 case GDK_SCROLL_UP:
754 mainwin_set_volume_diff(config.mouse_change);
755 break;
756 case GDK_SCROLL_DOWN:
757 mainwin_set_volume_diff(-config.mouse_change);
758 break;
759 case GDK_SCROLL_LEFT:
760 if (aud_playlist_get_current_length(playlist) != -1)
761 audacious_drct_seek(CLAMP(audacious_drct_get_time() - 1000,
762 0, aud_playlist_get_current_length(playlist)) / 1000);
763 break;
764 case GDK_SCROLL_RIGHT:
765 if (aud_playlist_get_current_length(playlist) != -1)
766 audacious_drct_seek(CLAMP(audacious_drct_get_time() + 1000,
767 0, aud_playlist_get_current_length(playlist)) / 1000);
768 break;
769 }
770 }
771
772 static gboolean
773 mainwin_widget_contained(GdkEventButton *event, int x, int y, int w, int h)
774 {
775 if ((event->x > x && event->y > y) &&
776 (event->x < x+w && event->y < y+h))
777 return TRUE;
778
779 return FALSE;
780 }
781
782 static gboolean
783 mainwin_mouse_button_press(GtkWidget * widget,
784 GdkEventButton * event,
785 gpointer callback_data)
786 {
787 if (config.scaled) {
788 /*
789 * A hack to make scaling transparent to callbacks.
790 * We should make a copy of this data instead of
791 * tampering with the data we get from gtk+
792 */
793 event->x /= config.scale_factor;
794 event->y /= config.scale_factor;
795 }
796
797 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && event->y < 14) {
798 mainwin_set_shade(!config.player_shaded);
799 if (dock_is_moving(GTK_WINDOW(mainwin)))
800 dock_move_release(GTK_WINDOW(mainwin));
801 return TRUE;
802 }
803
804 if (event->button == 3) {
805 /* Pop up playback menu if right clicked over playback-control widgets,
806 * otherwise popup general menu
807 */
808 if (mainwin_widget_contained(event, aud_active_skin->properties.mainwin_position_x,
809 aud_active_skin->properties.mainwin_position_y, 248, 10) ||
810 mainwin_widget_contained(event, aud_active_skin->properties.mainwin_previous_x,
811 aud_active_skin->properties.mainwin_previous_y, 23, 18) ||
812 mainwin_widget_contained(event, aud_active_skin->properties.mainwin_play_x,
813 aud_active_skin->properties.mainwin_play_y, 23, 18) ||
814 mainwin_widget_contained(event, aud_active_skin->properties.mainwin_pause_x,
815 aud_active_skin->properties.mainwin_pause_y, 23, 18) ||
816 mainwin_widget_contained(event, aud_active_skin->properties.mainwin_stop_x,
817 aud_active_skin->properties.mainwin_stop_y, 23, 18) ||
818 mainwin_widget_contained(event, aud_active_skin->properties.mainwin_next_x,
819 aud_active_skin->properties.mainwin_next_y, 23, 18))
820 {
821 #if 0
822 ui_manager_popup_menu_show(GTK_MENU(mainwin_playback_menu),
823 event->x_root,
824 event->y_root, 3, event->time);
825 #endif
826 } else {
827 /*
828 * Pop up the main menu a few pixels down.
829 * This will avoid that anything is selected
830 * if one right-clicks to focus the window
831 * without raising it.
832 *
833 ***MD I think the above is stupid, people don't expect this
834 *
835 */
836 #if 0
837 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu),
838 event->x_root,
839 event->y_root, 3, event->time);
840 #endif
841 }
842 return TRUE;
843 }
844
845 return FALSE;
846 }
847
848 static gboolean
849 mainwin_keypress(GtkWidget * grab_widget,
850 GdkEventKey * event,
851 gpointer data)
852 {
853 Playlist *playlist = aud_playlist_get_active();
854
855 switch (event->keyval) {
856
857 case GDK_Up:
858 case GDK_KP_Up:
859 case GDK_KP_8:
860 mainwin_set_volume_diff(2);
861 break;
862 case GDK_Down:
863 case GDK_KP_Down:
864 case GDK_KP_2:
865 mainwin_set_volume_diff(-2);
866 break;
867 case GDK_Left:
868 case GDK_KP_Left:
869 case GDK_KP_7:
870 if (aud_playlist_get_current_length(playlist) != -1)
871 audacious_drct_seek(CLAMP
872 (audacious_drct_get_time() - 5000, 0,
873 aud_playlist_get_current_length(playlist)) / 1000);
874 break;
875 case GDK_Right:
876 case GDK_KP_Right:
877 case GDK_KP_9:
878 if (aud_playlist_get_current_length(playlist) != -1)
879 audacious_drct_seek(CLAMP
880 (audacious_drct_get_time() + 5000, 0,
881 aud_playlist_get_current_length(playlist)) / 1000);
882 break;
883 case GDK_KP_4:
884 aud_playlist_prev(playlist);
885 break;
886 case GDK_KP_6:
887 aud_playlist_next(playlist);
888 break;
889 case GDK_KP_Insert:
890 #if 0
891 ui_jump_to_track();
892 #endif
893 break;
894 case GDK_Return:
895 case GDK_KP_Enter:
896 case GDK_KP_5:
897 mainwin_play_pushed();
898 break;
899 case GDK_space:
900 audacious_drct_pause();
901 break;
902 case GDK_Escape:
903 mainwin_minimize_cb();
904 break;
905 case GDK_Tab:
906 #if 0
907 if (event->state & GDK_CONTROL_MASK) {
908 if (config.equalizer_visible)
909 gtk_window_present(GTK_WINDOW(equalizerwin));
910 else if (config.playlist_visible)
911 gtk_window_present(GTK_WINDOW(playlistwin));
912 }
913 #endif
914 break;
915 case GDK_c:
916 if (event->state & GDK_CONTROL_MASK) {
917 Playlist *playlist = aud_playlist_get_active();
918 gint pos = playlist_get_position(playlist);
919 gchar *title = playlist_get_songtitle(playlist, pos);
920
921 if (title != NULL) {
922 GtkClipboard *clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
923 gtk_clipboard_set_text(clip, title, -1);
924 gtk_clipboard_store(clip);
925 }
926
927 return TRUE;
928 }
929 return FALSE;
930 default:
931 return FALSE;
932 }
933
934 return TRUE;
935 }
936
937 static void
938 mainwin_jump_to_time_cb(GtkWidget * widget,
939 GtkWidget * entry)
940 {
941 guint min = 0, sec = 0, params;
942 gint time;
943 Playlist *playlist = aud_playlist_get_active();
944
945 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u",
946 &min, &sec);
947 if (params == 2)
948 time = (min * 60) + sec;
949 else if (params == 1)
950 time = min;
951 else
952 return;
953
954 if (aud_playlist_get_current_length(playlist) > -1 &&
955 time <= (aud_playlist_get_current_length(playlist) / 1000))
956 {
957 audacious_drct_seek(time);
958 gtk_widget_destroy(mainwin_jtt);
959 }
960 }
961
962
963 void
964 mainwin_jump_to_time(void)
965 {
966 GtkWidget *vbox, *hbox_new, *hbox_total;
967 GtkWidget *time_entry, *label, *bbox, *jump, *cancel;
968 GtkWidget *dialog;
969 guint tindex;
970 gchar time_str[10];
971
972 if (!audacious_drct_get_playing()) {
973 dialog =
974 gtk_message_dialog_new (GTK_WINDOW (mainwin),
975 GTK_DIALOG_DESTROY_WITH_PARENT,
976 GTK_MESSAGE_ERROR,
977 GTK_BUTTONS_CLOSE,
978 _("Can't jump to time when no track is being played.\n"));
979 gtk_dialog_run (GTK_DIALOG (dialog));
980 gtk_widget_destroy (dialog);
981 return;
982 }
983
984 if (mainwin_jtt) {
985 gtk_window_present(GTK_WINDOW(mainwin_jtt));
986 return;
987 }
988
989 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL);
990 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt),
991 GDK_WINDOW_TYPE_HINT_DIALOG);
992
993 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time"));
994 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER);
995 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt),
996 GTK_WINDOW(mainwin));
997
998 g_signal_connect(mainwin_jtt, "destroy",
999 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt);
1000 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10);
1001
1002 vbox = gtk_vbox_new(FALSE, 5);
1003 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox);
1004
1005 hbox_new = gtk_hbox_new(FALSE, 0);
1006 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5);
1007
1008 time_entry = gtk_entry_new();
1009 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5);
1010 g_signal_connect(time_entry, "activate",
1011 G_CALLBACK(mainwin_jump_to_time_cb), time_entry);
1012
1013 gtk_widget_set_size_request(time_entry, 70, -1);
1014 label = gtk_label_new(_("minutes:seconds"));
1015 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5);
1016
1017 hbox_total = gtk_hbox_new(FALSE, 0);
1018 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5);
1019 gtk_widget_show(hbox_total);
1020
1021 /* FIXME: Disable display of current track length. It's not
1022 updated when track changes */
1023 #if 0
1024 label = gtk_label_new(_("Track length:"));
1025 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5);
1026
1027 len = aud_playlist_get_current_length() / 1000;
1028 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60);
1029 label = gtk_label_new(time_str);
1030
1031 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10);
1032 #endif
1033
1034 bbox = gtk_hbutton_box_new();
1035 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0);
1036 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
1037 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
1038
1039 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
1040 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
1041 gtk_container_add(GTK_CONTAINER(bbox), cancel);
1042 g_signal_connect_swapped(cancel, "clicked",
1043 G_CALLBACK(gtk_widget_destroy), mainwin_jtt);
1044
1045 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO);
1046 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT);
1047 gtk_container_add(GTK_CONTAINER(bbox), jump);
1048 g_signal_connect(jump, "clicked",
1049 G_CALLBACK(mainwin_jump_to_time_cb), time_entry);
1050
1051 tindex = audacious_drct_get_time() / 1000;
1052 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60,
1053 tindex % 60);
1054 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str);
1055
1056 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str));
1057
1058 gtk_widget_show_all(mainwin_jtt);
1059
1060 gtk_widget_grab_focus(time_entry);
1061 gtk_widget_grab_default(jump);
1062 }
1063
1064 /*
1065 * Rewritten 09/13/06:
1066 *
1067 * Remove all of this flaky iter/sourcelist/strsplit stuff.
1068 * All we care about is the filepath.
1069 *
1070 * We can figure this out and easily pass it to g_filename_from_uri().
1071 * - nenolod
1072 */
1073 void
1074 mainwin_drag_data_received(GtkWidget * widget,
1075 GdkDragContext * context,
1076 gint x,
1077 gint y,
1078 GtkSelectionData * selection_data,
1079 guint info,
1080 guint time,
1081 gpointer user_data)
1082 {
1083 #if 0
1084 Playlist *playlist = aud_playlist_get_active();
1085
1086 g_return_if_fail(selection_data != NULL);
1087 g_return_if_fail(selection_data->data != NULL);
1088
1089 if (aud_str_has_prefix_nocase((gchar *) selection_data->data, "fonts:///"))
1090 {
1091 gchar *path = (gchar *) selection_data->data;
1092 gchar *decoded = g_filename_from_uri(path, NULL, NULL);
1093
1094 if (decoded == NULL)
1095 return;
1096
1097 aud_cfg->playlist_font = g_strconcat(decoded, strrchr(aud_cfg->playlist_font, ' '), NULL);
1098 ui_skinned_playlist_set_font(aud_cfg->playlist_font);
1099 playlistwin_update_list(playlist);
1100
1101 g_free(decoded);
1102
1103 return;
1104 }
1105
1106 /* perhaps make suffix check case-insensitive -- desowin */
1107 if (aud_str_has_prefix_nocase((char*)selection_data->data, "file:///")) {
1108 if (str_has_suffix_nocase((char*)selection_data->data, ".wsz\r\n") ||
1109 str_has_suffix_nocase((char*)selection_data->data, ".zip\r\n")) {
1110 on_skin_view_drag_data_received(GTK_WIDGET(user_data), context, x, y, selection_data, info, time, NULL);
1111 return;
1112 }
1113 }
1114
1115 aud_playlist_clear(playlist);
1116 aud_playlist_add_url(playlist, (gchar *) selection_data->data);
1117 playback_initiate();
1118 #endif
1119 }
1120
1121 static void
1122 on_add_url_add_clicked(GtkWidget * widget,
1123 GtkWidget * entry)
1124 {
1125 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
1126 if (text && *text)
1127 aud_playlist_add_url(aud_playlist_get_active(), text);
1128 }
1129
1130 static void
1131 on_add_url_ok_clicked(GtkWidget * widget,
1132 GtkWidget * entry)
1133 {
1134 Playlist *playlist = aud_playlist_get_active();
1135 #if 0
1136 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
1137 if (text && *text)
1138 {
1139 aud_playlist_clear(playlist);
1140 aud_playlist_add_url(playlist, text);
1141 playback_initiate();
1142 }
1143 #endif
1144 }
1145
1146 static void
1147 on_visibility_warning_toggle(GtkToggleButton *tbt, gpointer unused)
1148 {
1149 config.warn_about_win_visibility = !gtk_toggle_button_get_active(tbt);
1150 }
1151
1152 static void
1153 on_visibility_warning_response(GtkDialog *dlg, gint r_id, gpointer unused)
1154 {
1155 switch (r_id)
1156 {
1157 case GTK_RESPONSE_OK:
1158 mainwin_show(TRUE);
1159 break;
1160 case GTK_RESPONSE_CANCEL:
1161 default:
1162 break;
1163 }
1164 gtk_widget_destroy(GTK_WIDGET(dlg));
1165 }
1166
1167 void
1168 mainwin_show_visibility_warning(void)
1169 {
1170 if (config.warn_about_win_visibility)
1171 {
1172 GtkWidget *label, *checkbt, *vbox;
1173 GtkWidget *warning_dlg =
1174 gtk_dialog_new_with_buttons( _("Audacious - visibility warning") ,
1175 GTK_WINDOW(mainwin) ,
1176 GTK_DIALOG_DESTROY_WITH_PARENT ,
1177 _("Show main player window") ,
1178 GTK_RESPONSE_OK , _("Ignore") ,
1179 GTK_RESPONSE_CANCEL , NULL );
1180
1181 vbox = gtk_vbox_new( FALSE , 4 );
1182 gtk_container_set_border_width( GTK_CONTAINER(vbox) , 4 );
1183 gtk_box_pack_start( GTK_BOX(GTK_DIALOG(warning_dlg)->vbox) , vbox , TRUE , TRUE , 0 );
1184 label = gtk_label_new( _("Audacious has been started with all of its windows hidden.\n"
1185 "You may want to show the player window again to control Audacious; "
1186 "otherwise, you'll have to control it remotely via audtool or "
1187 "enabled plugins (such as the statusicon plugin).") );
1188 gtk_label_set_line_wrap( GTK_LABEL(label) , TRUE );
1189 gtk_misc_set_alignment( GTK_MISC(label) , 0.0 , 0.0 );
1190 checkbt = gtk_check_button_new_with_label( _("Always ignore, show/hide is controlled remotely") );
1191 gtk_box_pack_start( GTK_BOX(vbox) , label , TRUE , TRUE , 0 );
1192 gtk_box_pack_start( GTK_BOX(vbox) , checkbt , TRUE , TRUE , 0 );
1193 g_signal_connect( G_OBJECT(checkbt) , "toggled" ,
1194 G_CALLBACK(on_visibility_warning_toggle) , NULL );
1195 g_signal_connect( G_OBJECT(warning_dlg) , "response" ,
1196 G_CALLBACK(on_visibility_warning_response) , NULL );
1197 gtk_widget_show_all(warning_dlg);
1198 }
1199 }
1200
1201 static void
1202 on_broken_gtk_engine_warning_toggle(GtkToggleButton *tbt, gpointer unused)
1203 {
1204 config.warn_about_broken_gtk_engines = !gtk_toggle_button_get_active(tbt);
1205 }
1206
1207 void
1208 ui_main_check_theme_engine(void)
1209 {
1210 GtkSettings *settings;
1211 GtkWidget *widget;
1212 gchar *theme = NULL;
1213
1214 widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1215 gtk_widget_ensure_style(widget);
1216
1217 settings = gtk_settings_get_default();
1218 g_object_get(G_OBJECT(settings), "gtk-theme-name", &theme, NULL);
1219 gtk_widget_destroy(widget);
1220
1221 if (theme == NULL)
1222 return;
1223
1224 if (g_ascii_strcasecmp(theme, "Qt"))
1225 {
1226 g_free(theme);
1227 return;
1228 }
1229
1230 if (config.warn_about_broken_gtk_engines)
1231 {
1232 gchar *msg;
1233 GtkWidget *label, *checkbt, *vbox;
1234 GtkWidget *warning_dlg =
1235 gtk_dialog_new_with_buttons( _("Audacious - broken GTK engine usage warning") ,
1236 GTK_WINDOW(mainwin) , GTK_DIALOG_DESTROY_WITH_PARENT ,
1237 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL );
1238 vbox = gtk_vbox_new( FALSE , 4 );
1239 gtk_container_set_border_width( GTK_CONTAINER(vbox) , 4 );
1240 gtk_box_pack_start( GTK_BOX(GTK_DIALOG(warning_dlg)->vbox) , vbox ,
1241 TRUE , TRUE , 0 );
1242
1243 msg = g_strdup_printf(_("<big><b>Broken GTK engine in use</b></big>\n\n"
1244 "Audacious has detected that you are using a broken GTK engine.\n\n"
1245 "The theme engine you are using, <i>%s</i>, is incompatible with some of the features "
1246 "used by modern skins. The incompatible features have been disabled for this session.\n\n"
1247 "To use these features, please consider using a different GTK theme engine."), theme);
1248 label = gtk_label_new(msg);
1249 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1250 g_free(msg);
1251
1252 gtk_label_set_line_wrap( GTK_LABEL(label) , TRUE );
1253 gtk_misc_set_alignment( GTK_MISC(label) , 0.0 , 0.0 );
1254 checkbt = gtk_check_button_new_with_label( _("Do not display this warning again") );
1255 gtk_box_pack_start( GTK_BOX(vbox) , label , TRUE , TRUE , 0 );
1256 gtk_box_pack_start( GTK_BOX(vbox) , checkbt , TRUE , TRUE , 0 );
1257 g_signal_connect( G_OBJECT(checkbt) , "toggled" ,
1258 G_CALLBACK(on_broken_gtk_engine_warning_toggle) , NULL );
1259 g_signal_connect( G_OBJECT(warning_dlg) , "response" ,
1260 G_CALLBACK(gtk_widget_destroy) , NULL );
1261 gtk_widget_show_all(warning_dlg);
1262 gtk_window_stick(GTK_WINDOW(warning_dlg));
1263 }
1264
1265 config.disable_inline_gtk = TRUE;
1266
1267 g_free(theme);
1268 }
1269
1270 void
1271 mainwin_show_add_url_window(void)
1272 {
1273 #if 0
1274 static GtkWidget *url_window = NULL;
1275
1276 if (!url_window) {
1277 url_window =
1278 util_add_url_dialog_new(_("Enter location to play:"),
1279 G_CALLBACK(on_add_url_ok_clicked),
1280 G_CALLBACK(on_add_url_add_clicked));
1281 gtk_window_set_transient_for(GTK_WINDOW(url_window),
1282 GTK_WINDOW(mainwin));
1283 g_signal_connect(url_window, "destroy",
1284 G_CALLBACK(gtk_widget_destroyed),
1285 &url_window);
1286 }
1287
1288 gtk_window_present(GTK_WINDOW(url_window));
1289 #endif
1290 }
1291
1292 static void
1293 check_set( GtkActionGroup * action_group ,
1294 const gchar * action_name ,
1295 gboolean is_on )
1296 {
1297 /* check_set noew uses gtkaction */
1298 GtkAction *action = gtk_action_group_get_action( action_group , action_name );
1299 if ( action != NULL )
1300 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , is_on );
1301 return;
1302 }
1303
1304 void
1305 mainwin_eject_pushed(void)
1306 {
1307 #if 0
1308 run_filebrowser(PLAY_BUTTON);
1309 #endif
1310 }
1311
1312 void
1313 mainwin_rev_pushed(void)
1314 {
1315 g_get_current_time(&cb_time);
1316
1317 seek_initial_pos = ui_skinned_horizontal_slider_get_position(mainwin_position);
1318 seek_state = MAINWIN_SEEK_REV;
1319 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL,
1320 (GSourceFunc) mainwin_idle_func, NULL);
1321 }
1322
1323 void
1324 mainwin_rev_release(void)
1325 {
1326 GTimeVal now_time;
1327 GTimeVal delta_time;
1328 gulong now_dur;
1329
1330 g_get_current_time(&now_time);
1331
1332 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec;
1333 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec;
1334
1335 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000));
1336
1337 if ( now_dur <= TRISTATE_THRESHOLD )
1338 {
1339 /* interpret as 'skip to previous song' */
1340 aud_playlist_prev(aud_playlist_get_active());
1341 }
1342 else
1343 {
1344 /* interpret as 'seek' */
1345 mainwin_position_release_cb( mainwin_position, ui_skinned_horizontal_slider_get_position(mainwin_position) );
1346 }
1347
1348 seek_state = MAINWIN_SEEK_NIL;
1349
1350 g_source_remove(mainwin_timeout_id);
1351 mainwin_timeout_id = 0;
1352 }
1353
1354 void
1355 mainwin_fwd_pushed(void)
1356 {
1357 g_get_current_time(&cb_time);
1358
1359 seek_initial_pos = ui_skinned_horizontal_slider_get_position(mainwin_position);
1360 seek_state = MAINWIN_SEEK_FWD;
1361 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL,
1362 (GSourceFunc) mainwin_idle_func, NULL);
1363 }
1364
1365 void
1366 mainwin_fwd_release(void)
1367 {
1368 GTimeVal now_time;
1369 GTimeVal delta_time;
1370 gulong now_dur;
1371
1372 g_get_current_time(&now_time);
1373
1374 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec;
1375 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec;
1376
1377 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000));
1378
1379 if ( now_dur <= TRISTATE_THRESHOLD )
1380 {
1381 /* interpret as 'skip to next song' */
1382 aud_playlist_next(aud_playlist_get_active());
1383 }
1384 else
1385 {
1386 /* interpret as 'seek' */
1387 mainwin_position_release_cb( mainwin_position, ui_skinned_horizontal_slider_get_position(mainwin_position) );
1388 }
1389
1390 seek_state = MAINWIN_SEEK_NIL;
1391
1392 g_source_remove(mainwin_timeout_id);
1393 mainwin_timeout_id = 0;
1394 }
1395
1396 void
1397 mainwin_play_pushed(void)
1398 {
1399 if (ab_position_a != -1)
1400 audacious_drct_seek(ab_position_a / 1000);
1401 if (audacious_drct_get_paused()) {
1402 audacious_drct_pause();
1403 return;
1404 }
1405 #if 0
1406 if (playlist_get_length(aud_playlist_get_active()))
1407 playback_initiate();
1408 else
1409 mainwin_eject_pushed();
1410 #endif
1411 }
1412
1413 void
1414 mainwin_stop_pushed(void)
1415 {
1416 #if 0
1417 ip_data.stop = TRUE;
1418 audacious_drct_stop();
1419 mainwin_clear_song_info();
1420 ab_position_a = ab_position_b = -1;
1421 ip_data.stop = FALSE;
1422 #endif
1423 }
1424
1425 void
1426 mainwin_shuffle_pushed(gboolean toggled)
1427 {
1428 #if 0
1429 check_set( toggleaction_group_others , "playback shuffle" , toggled );
1430 #endif
1431 }
1432
1433 void mainwin_shuffle_pushed_cb(void) {
1434 mainwin_shuffle_pushed(UI_SKINNED_BUTTON(mainwin_shuffle)->inside);
1435 }
1436
1437 void
1438 mainwin_repeat_pushed(gboolean toggled)
1439 {
1440 #if 0
1441 check_set( toggleaction_group_others , "playback repeat" , toggled );
1442 #endif
1443 }
1444
1445 void mainwin_repeat_pushed_cb(void) {
1446 mainwin_repeat_pushed(UI_SKINNED_BUTTON(mainwin_repeat)->inside);
1447 }
1448
1449 void mainwin_equalizer_pushed_cb(void) {
1450 mainwin_eq_pushed(UI_SKINNED_BUTTON(mainwin_eq)->inside);
1451 }
1452
1453 void mainwin_playlist_pushed_cb(void) {
1454 mainwin_pl_pushed(UI_SKINNED_BUTTON(mainwin_pl)->inside);
1455 }
1456
1457 void
1458 mainwin_eq_pushed(gboolean toggled)
1459 {
1460 #if 0
1461 equalizerwin_show(toggled);
1462 #endif
1463 }
1464
1465 void
1466 mainwin_pl_pushed(gboolean toggled)
1467 {
1468 #if 0
1469 if (toggled)
1470 playlistwin_show();
1471 else
1472 playlistwin_hide();
1473 #endif
1474 }
1475
1476 gint
1477 mainwin_spos_frame_cb(gint pos)
1478 {
1479 if (mainwin_sposition) {
1480 gint x = 0;
1481 if (pos < 6)
1482 x = 17;
1483 else if (pos < 9)
1484 x = 20;
1485 else
1486 x = 23;
1487
1488 UI_SKINNED_HORIZONTAL_SLIDER(mainwin_sposition)->knob_nx = x;
1489 UI_SKINNED_HORIZONTAL_SLIDER(mainwin_sposition)->knob_px = x;
1490 }
1491 return 1;
1492 }
1493
1494 void
1495 mainwin_spos_motion_cb(GtkWidget *widget, gint pos)
1496 {
1497 gint time;
1498 gchar *time_msg;
1499 Playlist *playlist = aud_playlist_get_active();
1500
1501 pos--;
1502
1503 time = ((aud_playlist_get_current_length(playlist) / 1000) * pos) / 12;
1504
1505 if (config.timer_mode == TIMER_REMAINING) {
1506 time = (aud_playlist_get_current_length(playlist) / 1000) - time;
1507 time_msg = g_strdup_printf("-%2.2d", time / 60);
1508 ui_skinned_textbox_set_text(mainwin_stime_min, time_msg);
1509 g_free(time_msg);
1510 }
1511 else {
1512 time_msg = g_strdup_printf(" %2.2d", time / 60);
1513 ui_skinned_textbox_set_text(mainwin_stime_min, time_msg);
1514 g_free(time_msg);
1515 }
1516
1517 time_msg = g_strdup_printf("%2.2d", time % 60);
1518 ui_skinned_textbox_set_text(mainwin_stime_sec, time_msg);
1519 g_free(time_msg);
1520 }
1521
1522 void
1523 mainwin_spos_release_cb(GtkWidget *widget, gint pos)
1524 {
1525 audacious_drct_seek(((aud_playlist_get_current_length(aud_playlist_get_active()) / 1000) *
1526 (pos - 1)) / 12);
1527 }
1528
1529 void
1530 mainwin_position_motion_cb(GtkWidget *widget, gint pos)
1531 {
1532 gint length, time;
1533 gchar *seek_msg;
1534
1535 length = aud_playlist_get_current_length(aud_playlist_get_active()) / 1000;
1536 time = (length * pos) / 219;
1537 seek_msg = g_strdup_printf(_("Seek to: %d:%-2.2d/%d:%-2.2d (%d%%)"),
1538 time / 60, time % 60,
1539 length / 60, length % 60,
1540 (length != 0) ? (time * 100) / length : 0);
1541 mainwin_lock_info_text(seek_msg);
1542 g_free(seek_msg);
1543 }
1544
1545 void
1546 mainwin_position_release_cb(GtkWidget *widget, gint pos)
1547 {
1548 gint length, time;
1549
1550 length = aud_playlist_get_current_length(aud_playlist_get_active()) / 1000;
1551 time = (length * pos) / 219;
1552 audacious_drct_seek(time);
1553 mainwin_release_info_text();
1554 }
1555
1556 gint
1557 mainwin_volume_frame_cb(gint pos)
1558 {
1559 return (gint) rint((pos / 52.0) * 28);
1560 }
1561
1562 void
1563 mainwin_adjust_volume_motion(gint v)
1564 {
1565 gchar *volume_msg;
1566
1567 volume_msg = g_strdup_printf(_("Volume: %d%%"), v);
1568 mainwin_lock_info_text(volume_msg);
1569 g_free(volume_msg);
1570
1571 if (balance < 0)
1572 audacious_drct_set_volume(v, (v * (100 - abs(balance))) / 100);
1573 else if (balance > 0)
1574 audacious_drct_set_volume((v * (100 - abs(balance))) / 100, v);
1575 else
1576 audacious_drct_set_volume(v, v);
1577 }
1578
1579 void
1580 mainwin_adjust_volume_release(void)
1581 {
1582 mainwin_release_info_text();
1583 }
1584
1585 void
1586 mainwin_adjust_balance_motion(gint b)
1587 {
1588 gchar *balance_msg;
1589 gint v, pvl, pvr;
1590
1591 balance = b;
1592 aud_input_get_volume(&pvl, &pvr);
1593 v = MAX(pvl, pvr);
1594 if (b < 0) {
1595 balance_msg = g_strdup_printf(_("Balance: %d%% left"), -b);
1596 audacious_drct_set_volume(v, (gint) rint(((100 + b) / 100.0) * v));
1597 }
1598 else if (b == 0) {
1599 balance_msg = g_strdup_printf(_("Balance: center"));
1600 audacious_drct_set_volume(v, v);
1601 }
1602 else { /* b > 0 */
1603 balance_msg = g_strdup_printf(_("Balance: %d%% right"), b);
1604 audacious_drct_set_volume((gint) rint(((100 - b) / 100.0) * v), v);
1605 }
1606 mainwin_lock_info_text(balance_msg);
1607 g_free(balance_msg);
1608 }
1609
1610 void
1611 mainwin_adjust_balance_release(void)
1612 {
1613 mainwin_release_info_text();
1614 }
1615
1616 void
1617 mainwin_set_volume_slider(gint percent)
1618 {
1619 ui_skinned_horizontal_slider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0));
1620 }
1621
1622 void
1623 mainwin_set_balance_slider(gint percent)
1624 {
1625 ui_skinned_horizontal_slider_set_position(mainwin_balance, (gint) rint(((percent * 12) / 100.0) + 12));
1626 }
1627
1628 void
1629 mainwin_volume_motion_cb(GtkWidget *widget, gint pos)
1630 {
1631
1632 gint vol = (pos * 100) / 51;
1633 mainwin_adjust_volume_motion(vol);
1634 #if 0
1635 equalizerwin_set_volume_slider(vol);
1636 #endif
1637 }
1638
1639 gboolean
1640 mainwin_volume_release_cb(GtkWidget *widget, gint pos)
1641 {
1642 mainwin_adjust_volume_release();
1643 return FALSE;
1644 }
1645
1646 gint
1647 mainwin_balance_frame_cb(gint pos)
1648 {
1649 return ((abs(pos - 12) * 28) / 13);
1650 }
1651
1652 void
1653 mainwin_balance_motion_cb(GtkWidget *widget, gint pos)
1654 {
1655 gint bal = ((pos - 12) * 100) / 12;
1656 mainwin_adjust_balance_motion(bal);
1657 #if 0
1658 equalizerwin_set_balance_slider(bal);
1659 #endif
1660 }
1661
1662 void
1663 mainwin_balance_release_cb(GtkWidget *widget, gint pos)
1664 {
1665 mainwin_adjust_volume_release();
1666 }
1667
1668 void
1669 mainwin_set_volume_diff(gint diff)
1670 {
1671 gint vl, vr, vol;
1672
1673 aud_input_get_volume(&vl, &vr);
1674 vol = MAX(vl, vr);
1675 vol = CLAMP(vol + diff, 0, 100);
1676
1677 mainwin_adjust_volume_motion(vol);
1678 mainwin_set_volume_slider(vol);
1679 #if 0
1680 equalizerwin_set_volume_slider(vol);
1681 #endif
1682 if (mainwin_volume_release_timeout)
1683 g_source_remove(mainwin_volume_release_timeout);
1684 mainwin_volume_release_timeout =
1685 g_timeout_add(700, (GSourceFunc)(mainwin_volume_release_cb), NULL);
1686 }
1687
1688 void
1689 mainwin_set_balance_diff(gint diff)
1690 {
1691 gint b;
1692 b = CLAMP(balance + diff, -100, 100);
1693 mainwin_adjust_balance_motion(b);
1694 mainwin_set_balance_slider(b);
1695 #if 0
1696 equalizerwin_set_balance_slider(b);
1697 #endif
1698 }
1699
1700 void
1701 mainwin_show(gboolean show)
1702 {
1703 if (show)
1704 mainwin_real_show();
1705 else
1706 mainwin_real_hide();
1707 }
1708
1709 void
1710 mainwin_real_show(void)
1711 {
1712 config.player_visible = TRUE;
1713 #if 0
1714 check_set( toggleaction_group_others , "show player" , TRUE );
1715 #endif
1716 if (config.player_shaded)
1717 ui_vis_clear_data(mainwin_vis);
1718
1719 if (config.show_wm_decorations) {
1720 if (config.player_x != -1 && config.save_window_position)
1721 gtk_window_move(GTK_WINDOW(mainwin), config.player_x, config.player_y);
1722
1723 gtk_widget_show(mainwin);
1724 return;
1725 }
1726
1727 if (config.player_x != -1 && config.save_window_position)
1728 gtk_window_move(GTK_WINDOW(mainwin), config.player_x, config.player_y);
1729
1730 mainwin_refresh_hints();
1731 gtk_window_present(GTK_WINDOW(mainwin));
1732 }
1733
1734 void
1735 mainwin_real_hide(void)
1736 {
1737 #if 0
1738 check_set( toggleaction_group_others , "show player", FALSE);
1739 #endif
1740 if (config.player_shaded)
1741 ui_svis_clear_data(mainwin_svis);
1742
1743 gtk_widget_hide(mainwin);
1744
1745 config.player_visible = FALSE;
1746 }
1747
1748
1749 void
1750 mainwin_set_stopaftersong(gboolean stop)
1751 {
1752 aud_cfg->stopaftersong = stop;
1753 #if 0
1754 check_set(toggleaction_group_others, "stop after current song", aud_cfg->stopaftersong);
1755 #endif
1756 }
1757
1758 void
1759 mainwin_set_noplaylistadvance(gboolean no_advance)
1760 {
1761 aud_cfg->no_playlist_advance = no_advance;
1762 #if 0
1763 check_set(toggleaction_group_others, "playback no playlist advance", aud_cfg->no_playlist_advance);
1764 #endif
1765 }
1766
1767 static void
1768 mainwin_set_scaled(gboolean scaled)
1769 {
1770 gint height;
1771
1772 if (config.player_shaded)
1773 height = MAINWIN_SHADED_HEIGHT;
1774 else
1775 height = aud_active_skin->properties.mainwin_height;
1776
1777 dock_window_resize(GTK_WINDOW(mainwin), config.player_shaded ? MAINWIN_SHADED_WIDTH : aud_active_skin->properties.mainwin_width,
1778 config.player_shaded ? MAINWIN_SHADED_HEIGHT : aud_active_skin->properties.mainwin_height,
1779 aud_active_skin->properties.mainwin_width * config.scale_factor , aud_active_skin->properties.mainwin_height * config.scale_factor);
1780
1781 GList *iter;
1782 for (iter = GTK_FIXED (SKINNED_WINDOW(mainwin)->fixed)->children; iter; iter = g_list_next (iter)) {
1783 GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
1784 GtkWidget *child = child_data->widget;
1785 g_signal_emit_by_name(child, "toggle-scaled");
1786 }
1787
1788 mainwin_refresh_hints();
1789 gtk_widget_shape_combine_mask(mainwin, skin_get_mask(aud_active_skin, SKIN_MASK_MAIN + config.player_shaded), 0, 0);
1790 }
1791
1792 void
1793 set_scaled(gboolean scaled)
1794 {
1795 config.scaled = scaled;
1796
1797 mainwin_set_scaled(scaled);
1798 #if 0
1799 if (config.eq_scaled_linked)
1800 equalizerwin_set_scaled(scaled);
1801 #endif
1802 }
1803
1804
1805
1806 void
1807 mainwin_general_menu_callback(gpointer data,
1808 guint action,
1809 GtkWidget * item)
1810 {
1811 #if 0
1812 Playlist *playlist = aud_playlist_get_active();
1813
1814 switch (action) {
1815 case MAINWIN_GENERAL_PREFS:
1816 show_prefs_window();
1817 break;
1818 case MAINWIN_GENERAL_ABOUT:
1819 show_about_window();
1820 break;
1821 case MAINWIN_GENERAL_PLAYFILE:
1822 run_filebrowser(NO_PLAY_BUTTON);
1823 break;
1824 case MAINWIN_GENERAL_PLAYLOCATION:
1825 mainwin_show_add_url_window();
1826 break;
1827 case MAINWIN_GENERAL_FILEINFO:
1828 ui_fileinfo_show_current(playlist);
1829 break;
1830 case MAINWIN_GENERAL_FOCUSPLWIN:
1831 gtk_window_present(GTK_WINDOW(playlistwin));
1832 break;
1833 case MAINWIN_GENERAL_SHOWMWIN:
1834 mainwin_show(GTK_CHECK_MENU_ITEM(item)->active);
1835 break;
1836 case MAINWIN_GENERAL_SHOWPLWIN:
1837 if (GTK_CHECK_MENU_ITEM(item)->active)
1838 playlistwin_show();
1839 else
1840 playlistwin_hide();
1841 break;
1842 case MAINWIN_GENERAL_SHOWEQWIN:
1843 if (GTK_CHECK_MENU_ITEM(item)->active)
1844 equalizerwin_real_show();
1845 else
1846 equalizerwin_real_hide();
1847 break;
1848 case MAINWIN_GENERAL_PREV:
1849 aud_playlist_prev(playlist);
1850 break;
1851 case MAINWIN_GENERAL_PLAY:
1852 mainwin_play_pushed();
1853 break;
1854 case MAINWIN_GENERAL_PAUSE:
1855 audacious_drct_pause();
1856 break;
1857 case MAINWIN_GENERAL_STOP:
1858 mainwin_stop_pushed();
1859 break;
1860 case MAINWIN_GENERAL_NEXT:
1861 aud_playlist_next(playlist);
1862 break;
1863 case MAINWIN_GENERAL_BACK5SEC:
1864 if (audacious_drct_get_playing()
1865 && aud_playlist_get_current_length(playlist) != -1)
1866 audacious_drct_seek_relative(-5);
1867 break;
1868 case MAINWIN_GENERAL_FWD5SEC:
1869 if (audacious_drct_get_playing()
1870 && aud_playlist_get_current_length(playlist) != -1)
1871 audacious_drct_seek_relative(5);
1872 break;
1873 case MAINWIN_GENERAL_START:
1874 aud_playlist_set_position(playlist, 0);
1875 break;
1876 case MAINWIN_GENERAL_JTT:
1877 mainwin_jump_to_time();
1878 break;
1879 case MAINWIN_GENERAL_JTF:
1880 ui_jump_to_track();
1881 break;
1882 case MAINWIN_GENERAL_EXIT:
1883 mainwin_quit_cb();
1884 break;
1885 case MAINWIN_GENERAL_SETAB:
1886 if (aud_playlist_get_current_length(playlist) != -1) {
1887 if (ab_position_a == -1) {
1888 ab_position_a = audacious_drct_get_time();
1889 ab_position_b = -1;
1890 mainwin_lock_info_text("'Loop-Point A Position' set.");
1891 } else if (ab_position_b == -1) {
1892 int time = audacious_drct_get_time();
1893 if (time > ab_position_a)
1894 ab_position_b = time;
1895 mainwin_release_info_text();
1896 } else {
1897 ab_position_a = audacious_drct_get_time();
1898 ab_position_b = -1;
1899 mainwin_lock_info_text("'Loop-Point A Position' reset.");
1900 }
1901 }
1902 break;
1903 case MAINWIN_GENERAL_CLEARAB:
1904 if (aud_playlist_get_current_length(playlist) != -1) {
1905 ab_position_a = ab_position_b = -1;
1906 mainwin_release_info_text();
1907 }
1908 break;
1909 case MAINWIN_GENERAL_NEW_PL:
1910 {
1911 Playlist *new_pl = playlist_new();
1912 playlist_add_playlist(new_pl);
1913 playlist_select_playlist(new_pl);
1914 }
1915 break;
1916 case MAINWIN_GENERAL_PREV_PL:
1917 playlist_select_prev();
1918 break;
1919 case MAINWIN_GENERAL_NEXT_PL:
1920 playlist_select_next();
1921 break;
1922 }
1923 #endif
1924 }
1925
1926 static void
1927 mainwin_mr_change(GtkWidget *widget, MenuRowItem i)
1928 {
1929 switch (i) {
1930 case MENUROW_OPTIONS:
1931 mainwin_lock_info_text(_("Options Menu"));
1932 break;
1933 case MENUROW_ALWAYS:
1934 if (UI_SKINNED_MENUROW(mainwin_menurow)->always_selected)
1935 mainwin_lock_info_text(_("Disable 'Always On Top'"));
1936 else
1937 mainwin_lock_info_text(_("Enable 'Always On Top'"));
1938 break;
1939 case MENUROW_FILEINFOBOX:
1940 mainwin_lock_info_text(_("File Info Box"));
1941 break;
1942 case MENUROW_SCALE:
1943 if (UI_SKINNED_MENUROW(mainwin_menurow)->scale_selected)
1944 mainwin_lock_info_text(_("Disable 'GUI Scaling'"));
1945 else
1946 mainwin_lock_info_text(_("Enable 'GUI Scaling'"));
1947 break;
1948 case MENUROW_VISUALIZATION:
1949 mainwin_lock_info_text(_("Visualization Menu"));
1950 break;
1951 case MENUROW_NONE:
1952 break;
1953 }
1954 }
1955
1956 static void
1957 mainwin_mr_release(GtkWidget *widget, MenuRowItem i, GdkEventButton *event)
1958 {
1959 #if 0
1960 switch (i) {
1961 case MENUROW_OPTIONS:
1962 ui_manager_popup_menu_show(GTK_MENU(mainwin_view_menu),
1963 event->x_root, event->y_root, 1,
1964 event->time);
1965 break;
1966 case MENUROW_ALWAYS:
1967 gtk_toggle_action_set_active(
1968 GTK_TOGGLE_ACTION(gtk_action_group_get_action(
1969 toggleaction_group_others , "view always on top" )) ,
1970 UI_SKINNED_MENUROW(mainwin_menurow)->always_selected );
1971 break;
1972 case MENUROW_FILEINFOBOX:
1973 ui_fileinfo_show_current(aud_playlist_get_active());
1974 break;
1975 case MENUROW_SCALE:
1976 gtk_toggle_action_set_active(
1977 GTK_TOGGLE_ACTION(gtk_action_group_get_action(
1978 toggleaction_group_others , "view scaled" )) ,
1979 UI_SKINNED_MENUROW(mainwin_menurow)->scale_selected );
1980 break;
1981 case MENUROW_VISUALIZATION:
1982 ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu),
1983 event->x_root, event->y_root, 1,
1984 event->time);
1985 break;
1986 case MENUROW_NONE:
1987 break;
1988 }
1989 #endif
1990 mainwin_release_info_text();
1991 }
1992
1993 void
1994 run_no_output_device_dialog(gpointer hook_data, gpointer user_data)
1995 {
1996 const gchar *markup =
1997 N_("<b><big>Couldn't open audio.</big></b>\n\n"
1998 "Please check that:\n"
1999 "1. You have the correct output plugin selected.\n"
2000 "2. No other programs is blocking the soundcard.\n"
2001 "3. Your soundcard is configured properly.\n");
2002
2003 GDK_THREADS_ENTER();
2004 GtkWidget *dialog =
2005 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
2006 GTK_DIALOG_DESTROY_WITH_PARENT,
2007 GTK_MESSAGE_ERROR,
2008 GTK_BUTTONS_OK,
2009 _(markup));
2010 gtk_dialog_run(GTK_DIALOG(dialog));
2011 gtk_widget_destroy(dialog);
2012 GDK_THREADS_LEAVE();
2013 }
2014
2015 void
2016 ui_main_set_initial_volume(void)
2017 {
2018 gint vl, vr, b, v;
2019
2020 aud_input_get_volume(&vl, &vr);
2021
2022 vl = CLAMP(vl, 0, 100);
2023 vr = CLAMP(vr, 0, 100);
2024 v = MAX(vl, vr);
2025 if (vl > vr)
2026 b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
2027 else if (vl < vr)
2028 b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
2029 else
2030 b = 0;
2031
2032 mainwin_set_volume_slider(v);
2033 #if 0
2034 equalizerwin_set_volume_slider(v);
2035 #endif
2036 mainwin_set_balance_slider(b);
2037 #if 0
2038 equalizerwin_set_balance_slider(b);
2039 #endif
2040 }
2041
2042 static void
2043 set_timer_mode(TimerMode mode)
2044 {
2045 #if 0
2046 if (mode == TIMER_ELAPSED)
2047 check_set(radioaction_group_viewtime, "view time elapsed", TRUE);
2048 else
2049 check_set(radioaction_group_viewtime, "view time remaining", TRUE);
2050 #endif
2051 }
2052
2053 static void
2054 set_timer_mode_menu_cb(TimerMode mode)
2055 {
2056 config.timer_mode = mode;
2057 }
2058
2059 gboolean
2060 change_timer_mode_cb(GtkWidget *widget, GdkEventButton *event)
2061 {
2062 if (event->button == 1) {
2063 change_timer_mode();
2064 } else if (event->button == 3)
2065 return FALSE;
2066
2067 return TRUE;
2068 }
2069
2070 static void change_timer_mode(void) {
2071 if (config.timer_mode == TIMER_ELAPSED)
2072 set_timer_mode(TIMER_REMAINING);
2073 else
2074 set_timer_mode(TIMER_ELAPSED);
2075 if (audacious_drct_get_playing())
2076 mainwin_update_song_info();
2077 }
2078
2079 static void
2080 mainwin_aud_playlist_prev(void)
2081 {
2082 aud_playlist_prev(aud_playlist_get_active());
2083 }
2084
2085 static void
2086 mainwin_aud_playlist_next(void)
2087 {
2088 aud_playlist_next(aud_playlist_get_active());
2089 }
2090
2091 void
2092 mainwin_setup_menus(void)
2093 {
2094 set_timer_mode(config.timer_mode);
2095
2096 /* View menu */
2097 #if 0
2098 check_set(toggleaction_group_others, "view always on top", config.always_on_top);
2099 check_set(toggleaction_group_others, "view put on all workspaces", config.sticky);
2100 check_set(toggleaction_group_others, "roll up player", config.player_shaded);
2101 check_set(toggleaction_group_others, "roll up playlist editor", config.playlist_shaded);
2102 check_set(toggleaction_group_others, "roll up equalizer", config.equalizer_shaded);
2103 check_set(toggleaction_group_others, "view easy move", config.easy_move);
2104 check_set(toggleaction_group_others, "view scaled", config.scaled);
2105
2106 /* Songname menu */
2107
2108 check_set(toggleaction_group_others, "autoscroll songname", config.autoscroll);
2109 check_set(toggleaction_group_others, "stop after current song", aud_cfg->stopaftersong);
2110
2111 /* Playback menu */
2112
2113 check_set(toggleaction_group_others, "playback repeat", aud_cfg->repeat);
2114 check_set(toggleaction_group_others, "playback shuffle", aud_cfg->shuffle);
2115 check_set(toggleaction_group_others, "playback no playlist advance", aud_cfg->no_playlist_advance);
2116
2117 /* Visualization menu */
2118
2119 switch ( config.vis_type )
2120 {
2121 case VIS_ANALYZER:
2122 check_set(radioaction_group_vismode, "vismode analyzer", TRUE);
2123 break;
2124 case VIS_SCOPE:
2125 check_set(radioaction_group_vismode, "vismode scope", TRUE);
2126 break;
2127 case VIS_VOICEPRINT:
2128 check_set(radioaction_group_vismode, "vismode voiceprint", TRUE);
2129 break;
2130 case VIS_OFF:
2131 default:
2132 check_set(radioaction_group_vismode, "vismode off", TRUE);
2133 break;
2134 }
2135
2136 switch ( config.analyzer_mode )
2137 {
2138 case ANALYZER_FIRE:
2139 check_set(radioaction_group_anamode, "anamode fire", TRUE);
2140 break;
2141 case ANALYZER_VLINES:
2142 check_set(radioaction_group_anamode, "anamode vertical lines", TRUE);
2143 break;
2144 case ANALYZER_NORMAL:
2145 default:
2146 check_set(radioaction_group_anamode, "anamode normal", TRUE);
2147 break;
2148 }
2149
2150 switch ( config.analyzer_type )
2151 {
2152 case ANALYZER_BARS:
2153 check_set(radioaction_group_anatype, "anatype bars", TRUE);
2154 break;
2155 case ANALYZER_LINES:
2156 default:
2157 check_set(radioaction_group_anatype, "anatype lines", TRUE);
2158 break;
2159 }
2160
2161 check_set(toggleaction_group_others, "anamode peaks", config.analyzer_peaks );
2162
2163 switch ( config.scope_mode )
2164 {
2165 case SCOPE_LINE:
2166 check_set(radioaction_group_scomode, "scomode line", TRUE);
2167 break;
2168 case SCOPE_SOLID:
2169 check_set(radioaction_group_scomode, "scomode solid", TRUE);
2170 break;
2171 case SCOPE_DOT:
2172 default:
2173 check_set(radioaction_group_scomode, "scomode dot", TRUE);
2174 break;
2175 }
2176
2177 switch ( config.voiceprint_mode )
2178 {
2179 case VOICEPRINT_FIRE:
2180 check_set(radioaction_group_vprmode, "vprmode fire", TRUE);
2181 break;
2182 case VOICEPRINT_ICE:
2183 check_set(radioaction_group_vprmode, "vprmode ice", TRUE);
2184 break;
2185 case VOICEPRINT_NORMAL:
2186 default:
2187 check_set(radioaction_group_vprmode, "vprmode normal", TRUE);
2188 break;
2189 }
2190
2191 switch ( config.vu_mode )
2192 {
2193 case VU_SMOOTH:
2194 check_set(radioaction_group_wshmode, "wshmode smooth", TRUE);
2195 break;
2196 case VU_NORMAL:
2197 default:
2198 check_set(radioaction_group_wshmode, "wshmode normal", TRUE);
2199 break;
2200 }
2201
2202 switch ( config.vis_refresh )
2203 {
2204 case REFRESH_HALF:
2205 check_set(radioaction_group_refrate, "refrate half", TRUE);
2206 break;
2207 case REFRESH_QUARTER:
2208 check_set(radioaction_group_refrate, "refrate quarter", TRUE);
2209 break;
2210 case REFRESH_EIGTH:
2211 check_set(radioaction_group_refrate, "refrate eighth", TRUE);
2212 break;
2213 case REFRESH_FULL:
2214 default:
2215 check_set(radioaction_group_refrate, "refrate full", TRUE);
2216 break;
2217 }
2218
2219 switch ( config.analyzer_falloff )
2220 {
2221 case FALLOFF_SLOW:
2222 check_set(radioaction_group_anafoff, "anafoff slow", TRUE);
2223 break;
2224 case FALLOFF_MEDIUM:
2225 check_set(radioaction_group_anafoff, "anafoff medium", TRUE);
2226 break;
2227 case FALLOFF_FAST:
2228 check_set(radioaction_group_anafoff, "anafoff fast", TRUE);
2229 break;
2230 case FALLOFF_FASTEST:
2231 check_set(radioaction_group_anafoff, "anafoff fastest", TRUE);
2232 break;
2233 case FALLOFF_SLOWEST:
2234 default:
2235 check_set(radioaction_group_anafoff, "anafoff slowest", TRUE);
2236 break;
2237 }
2238
2239 switch ( config.peaks_falloff )
2240 {
2241 case FALLOFF_SLOW:
2242 check_set(radioaction_group_peafoff, "peafoff slow", TRUE);
2243 break;
2244 case FALLOFF_MEDIUM:
2245 check_set(radioaction_group_peafoff, "peafoff medium", TRUE);
2246 break;
2247 case FALLOFF_FAST:
2248 check_set(radioaction_group_peafoff, "peafoff fast", TRUE);
2249 break;
2250 case FALLOFF_FASTEST:
2251 check_set(radioaction_group_peafoff, "peafoff fastest", TRUE);
2252 break;
2253 case FALLOFF_SLOWEST:
2254 default:
2255 check_set(radioaction_group_peafoff, "peafoff slowest", TRUE);
2256 break;
2257 }
2258 #endif
2259 }
2260
2261 static void mainwin_info_double_clicked_cb(void) {
2262 #if 0
2263 ui_fileinfo_show_current(aud_playlist_get_active());
2264 #endif
2265 }
2266
2267 static void
2268 mainwin_info_right_clicked_cb(GtkWidget *widget, GdkEventButton *event)
2269 {
2270 #if 0
2271 ui_manager_popup_menu_show(GTK_MENU(mainwin_songname_menu),
2272 event->x_root, event->y_root, 3, event->time);
2273 #endif
2274 }
2275
2276 static void
2277 mainwin_create_widgets(void)
2278 {
2279 mainwin_menubtn = ui_skinned_button_new();
2280 ui_skinned_push_button_setup(mainwin_menubtn, SKINNED_WINDOW(mainwin)->fixed,
2281 6, 3, 9, 9, 0, 0, 0, 9, SKIN_TITLEBAR);
2282 g_signal_connect(mainwin_menubtn, "clicked", mainwin_menubtn_cb, NULL );
2283
2284 mainwin_minimize = ui_skinned_button_new();
2285 ui_skinned_push_button_setup(mainwin_minimize, SKINNED_WINDOW(mainwin)->fixed,
2286 244, 3, 9, 9, 9, 0, 9, 9, SKIN_TITLEBAR);
2287 g_signal_connect(mainwin_minimize, "clicked", mainwin_minimize_cb, NULL );
2288
2289 mainwin_shade = ui_skinned_button_new();
2290 ui_skinned_push_button_setup(mainwin_shade, SKINNED_WINDOW(mainwin)->fixed,
2291 254, 3, 9, 9, 0,
2292 config.player_shaded ? 27 : 18, 9, config.player_shaded ? 27 : 18, SKIN_TITLEBAR);
2293 g_signal_connect(mainwin_shade, "clicked", mainwin_shade_toggle, NULL );
2294
2295 mainwin_close = ui_skinned_button_new();
2296 ui_skinned_push_button_setup(mainwin_close, SKINNED_WINDOW(mainwin)->fixed,
2297 264, 3, 9, 9, 18, 0, 18, 9, SKIN_TITLEBAR);
2298 g_signal_connect(mainwin_close, "clicked", mainwin_quit_cb, NULL );
2299
2300 mainwin_rew = ui_skinned_button_new();
2301 ui_skinned_push_button_setup(mainwin_rew, SKINNED_WINDOW(mainwin)->fixed,
2302 16, 88, 23, 18, 0, 0, 0, 18, SKIN_CBUTTONS);
2303 g_signal_connect(mainwin_rew, "pressed", mainwin_rev_pushed, NULL);
2304 g_signal_connect(mainwin_rew, "released", mainwin_rev_release, NULL);
2305
2306 mainwin_fwd = ui_skinned_button_new();
2307 ui_skinned_push_button_setup(mainwin_fwd, SKINNED_WINDOW(mainwin)->fixed,
2308 108, 88, 22, 18, 92, 0, 92, 18, SKIN_CBUTTONS);
2309 g_signal_connect(mainwin_fwd, "pressed", mainwin_fwd_pushed, NULL);
2310 g_signal_connect(mainwin_fwd, "released", mainwin_fwd_release, NULL);
2311
2312 mainwin_play = ui_skinned_button_new();
2313 ui_skinned_push_button_setup(mainwin_play, SKINNED_WINDOW(mainwin)->fixed,
2314 39, 88, 23, 18, 23, 0, 23, 18, SKIN_CBUTTONS);
2315 g_signal_connect(mainwin_play, "clicked", mainwin_play_pushed, NULL );
2316
2317 mainwin_pause = ui_skinned_button_new();
2318 ui_skinned_push_button_setup(mainwin_pause, SKINNED_WINDOW(mainwin)->fixed,
2319 62, 88, 23, 18, 46, 0, 46, 18, SKIN_CBUTTONS);
2320 g_signal_connect(mainwin_pause, "clicked", audacious_drct_pause, NULL );
2321
2322 mainwin_stop = ui_skinned_button_new();
2323 ui_skinned_push_button_setup(mainwin_stop, SKINNED_WINDOW(mainwin)->fixed,
2324 85, 88, 23, 18, 69, 0, 69, 18, SKIN_CBUTTONS);
2325 g_signal_connect(mainwin_stop, "clicked", mainwin_stop_pushed, NULL );
2326
2327 mainwin_eject = ui_skinned_button_new();
2328 ui_skinned_push_button_setup(mainwin_eject, SKINNED_WINDOW(mainwin)->fixed,
2329 136, 89, 22, 16, 114, 0, 114, 16, SKIN_CBUTTONS);
2330 g_signal_connect(mainwin_eject, "clicked", mainwin_eject_pushed, NULL);
2331
2332 mainwin_srew = ui_skinned_button_new();
2333 ui_skinned_small_button_setup(mainwin_srew, SKINNED_WINDOW(mainwin)->fixed, 169, 4, 8, 7);
2334 g_signal_connect(mainwin_srew, "clicked", mainwin_aud_playlist_prev, NULL);
2335
2336 mainwin_splay = ui_skinned_button_new();
2337 ui_skinned_small_button_setup(mainwin_splay, SKINNED_WINDOW(mainwin)->fixed, 177, 4, 10, 7);
2338 g_signal_connect(mainwin_splay, "clicked", mainwin_play_pushed, NULL);
2339
2340 mainwin_spause = ui_skinned_button_new();
2341 ui_skinned_small_button_setup(mainwin_spause, SKINNED_WINDOW(mainwin)->fixed, 187, 4, 10, 7);
2342 g_signal_connect(mainwin_spause, "clicked", audacious_drct_pause, NULL);
2343
2344 mainwin_sstop = ui_skinned_button_new();
2345 ui_skinned_small_button_setup(mainwin_sstop, SKINNED_WINDOW(mainwin)->fixed, 197, 4, 9, 7);
2346 g_signal_connect(mainwin_sstop, "clicked", mainwin_stop_pushed, NULL);
2347
2348 mainwin_sfwd = ui_skinned_button_new();
2349 ui_skinned_small_button_setup(mainwin_sfwd, SKINNED_WINDOW(mainwin)->fixed, 206, 4, 8, 7);
2350 g_signal_connect(mainwin_sfwd, "clicked", mainwin_aud_playlist_next, NULL);
2351
2352 mainwin_seject = ui_skinned_button_new();
2353 ui_skinned_small_button_setup(mainwin_seject, SKINNED_WINDOW(mainwin)->fixed, 216, 4, 9, 7);
2354 g_signal_connect(mainwin_seject, "clicked", mainwin_eject_pushed, NULL);
2355
2356 mainwin_shuffle = ui_skinned_button_new();
2357 ui_skinned_toggle_button_setup(mainwin_shuffle, SKINNED_WINDOW(mainwin)->fixed,
2358 164, 89, 46, 15, 28, 0, 28, 15, 28, 30, 28, 45, SKIN_SHUFREP);
2359 g_signal_connect(mainwin_shuffle, "clicked", mainwin_shuffle_pushed_cb, NULL);
2360
2361 mainwin_repeat = ui_skinned_button_new();
2362 ui_skinned_toggle_button_setup(mainwin_repeat, SKINNED_WINDOW(mainwin)->fixed,
2363 210, 89, 28, 15, 0, 0, 0, 15, 0, 30, 0, 45, SKIN_SHUFREP);
2364 g_signal_connect(mainwin_repeat, "clicked", mainwin_repeat_pushed_cb, NULL);
2365
2366 mainwin_eq = ui_skinned_button_new();
2367 ui_skinned_toggle_button_setup(mainwin_eq, SKINNED_WINDOW(mainwin)->fixed,
2368 219, 58, 23, 12, 0, 61, 46, 61, 0, 73, 46, 73, SKIN_SHUFREP);
2369 g_signal_connect(mainwin_eq, "clicked", mainwin_equalizer_pushed_cb, NULL);
2370 UI_SKINNED_BUTTON(mainwin_eq)->inside = config.equalizer_visible;
2371
2372 mainwin_pl = ui_skinned_button_new();
2373 ui_skinned_toggle_button_setup(mainwin_pl, SKINNED_WINDOW(mainwin)->fixed,
2374 242, 58, 23, 12, 23, 61, 69, 61, 23, 73, 69, 73, SKIN_SHUFREP);
2375 g_signal_connect(mainwin_pl, "clicked", mainwin_playlist_pushed_cb, NULL);
2376 UI_SKINNED_BUTTON(mainwin_pl)->inside = config.playlist_visible;
2377
2378 mainwin_info = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 112, 27, 153, 1, SKIN_TEXT);
2379 ui_skinned_textbox_set_scroll(mainwin_info, config.autoscroll);
2380 ui_skinned_textbox_set_xfont(mainwin_info, !config.mainwin_use_bitmapfont, aud_cfg->mainwin_font);
2381 g_signal_connect(mainwin_info, "double-clicked", mainwin_info_double_clicked_cb, NULL);
2382 g_signal_connect(mainwin_info, "right-clicked", G_CALLBACK(mainwin_info_right_clicked_cb), NULL);
2383
2384 mainwin_othertext = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 112, 43, 153, 1, SKIN_TEXT);
2385
2386 mainwin_rate_text = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 111, 43, 15, 0, SKIN_TEXT);
2387
2388 mainwin_freq_text = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 156, 43, 10, 0, SKIN_TEXT);
2389
2390 mainwin_menurow = ui_skinned_menurow_new(SKINNED_WINDOW(mainwin)->fixed, 10, 22, 304, 0, 304, 44, SKIN_TITLEBAR);
2391 g_signal_connect(mainwin_menurow, "change", G_CALLBACK(mainwin_mr_change), NULL);
2392 g_signal_connect(mainwin_menurow, "release", G_CALLBACK(mainwin_mr_release), NULL);
2393
2394 mainwin_volume = ui_skinned_horizontal_slider_new(SKINNED_WINDOW(mainwin)->fixed, 107, 57, 68,
2395 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51,
2396 mainwin_volume_frame_cb, SKIN_VOLUME);
2397 g_signal_connect(mainwin_volume, "motion", G_CALLBACK(mainwin_volume_motion_cb), NULL);
2398 g_signal_connect(mainwin_volume, "release", G_CALLBACK(mainwin_volume_release_cb), NULL);
2399
2400 mainwin_balance = ui_skinned_horizontal_slider_new(SKINNED_WINDOW(mainwin)->fixed, 177, 57, 38,
2401 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24,
2402 mainwin_balance_frame_cb, SKIN_BALANCE);
2403 g_signal_connect(mainwin_balance, "motion", G_CALLBACK(mainwin_balance_motion_cb), NULL);
2404 g_signal_connect(mainwin_balance, "release", G_CALLBACK(mainwin_balance_release_cb), NULL);
2405
2406 mainwin_monostereo = ui_skinned_monostereo_new(SKINNED_WINDOW(mainwin)->fixed, 212, 41, SKIN_MONOSTEREO);
2407
2408 mainwin_playstatus = ui_skinned_playstatus_new(SKINNED_WINDOW(mainwin)->fixed, 24, 28);
2409
2410 mainwin_minus_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 36, 26, SKIN_NUMBERS);
2411 g_signal_connect(mainwin_minus_num, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2412
2413 mainwin_10min_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 48, 26, SKIN_NUMBERS);
2414 g_signal_connect(mainwin_10min_num, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2415
2416 mainwin_min_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 60, 26, SKIN_NUMBERS);
2417 g_signal_connect(mainwin_min_num, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2418
2419 mainwin_10sec_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 78, 26, SKIN_NUMBERS);
2420 g_signal_connect(mainwin_10sec_num, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2421
2422 mainwin_sec_num = ui_skinned_number_new(SKINNED_WINDOW(mainwin)->fixed, 90, 26, SKIN_NUMBERS);
2423 g_signal_connect(mainwin_sec_num, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2424
2425 mainwin_about = ui_skinned_button_new();
2426 ui_skinned_small_button_setup(mainwin_about, SKINNED_WINDOW(mainwin)->fixed, 247, 83, 20, 25);
2427 #if 0
2428 g_signal_connect(mainwin_about, "clicked", show_about_window, NULL);
2429 #endif
2430 mainwin_vis = ui_vis_new(SKINNED_WINDOW(mainwin)->fixed, 24, 43, 76);
2431 g_signal_connect(mainwin_vis, "button-press-event", G_CALLBACK(mainwin_vis_cb), NULL);
2432 mainwin_svis = ui_svis_new(SKINNED_WINDOW(mainwin)->fixed, 79, 5);
2433 g_signal_connect(mainwin_svis, "button-press-event", G_CALLBACK(mainwin_vis_cb), NULL);
2434
2435 mainwin_position = ui_skinned_horizontal_slider_new(SKINNED_WINDOW(mainwin)->fixed, 16, 72, 248,
2436 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219,
2437 NULL, SKIN_POSBAR);
2438 g_signal_connect(mainwin_position, "motion", G_CALLBACK(mainwin_position_motion_cb), NULL);
2439 g_signal_connect(mainwin_position, "release", G_CALLBACK(mainwin_position_release_cb), NULL);
2440
2441 mainwin_sposition = ui_skinned_horizontal_slider_new(SKINNED_WINDOW(mainwin)->fixed, 226, 4, 17,
2442 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13,
2443 mainwin_spos_frame_cb, SKIN_TITLEBAR);
2444 g_signal_connect(mainwin_sposition, "motion", G_CALLBACK(mainwin_spos_motion_cb), NULL);
2445 g_signal_connect(mainwin_sposition, "release", G_CALLBACK(mainwin_spos_release_cb), NULL);
2446
2447 mainwin_stime_min = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 130, 4, 15, FALSE, SKIN_TEXT);
2448 g_signal_connect(mainwin_stime_min, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2449
2450 mainwin_stime_sec = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 147, 4, 10, FALSE, SKIN_TEXT);
2451 g_signal_connect(mainwin_stime_sec, "button-press-event", G_CALLBACK(change_timer_mode_cb), NULL);
2452
2453
2454 aud_hook_associate("playback audio error", (void *) mainwin_stop_pushed, NULL);
2455 aud_hook_associate("playback audio error", (void *) run_no_output_device_dialog, NULL);
2456
2457 aud_hook_associate("playback seek", (HookFunction) mainwin_update_song_info, NULL);
2458 }
2459
2460 static void
2461 mainwin_create_window(void)
2462 {
2463 gint width, height;
2464
2465 mainwin = ui_skinned_window_new("player");
2466 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious"));
2467 gtk_window_set_role(GTK_WINDOW(mainwin), "player");
2468 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE);
2469
2470 width = config.player_shaded ? MAINWIN_SHADED_WIDTH : aud_active_skin->properties.mainwin_width;
2471 height = config.player_shaded ? MAINWIN_SHADED_HEIGHT : aud_active_skin->properties.mainwin_height;
2472
2473 if (config.scaled) {
2474 width *= config.scale_factor;
2475 height *= config.scale_factor;
2476 }
2477
2478 gtk_widget_set_size_request(mainwin, width, height);
2479
2480 if (config.player_x != -1 && config.save_window_position)
2481 gtk_window_move(GTK_WINDOW(mainwin), config.player_x, config.player_y);
2482
2483 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL);
2484 g_signal_connect(mainwin, "button_press_event",
2485 G_CALLBACK(mainwin_mouse_button_press), NULL);
2486 g_signal_connect(mainwin, "scroll_event",
2487 G_CALLBACK(mainwin_scrolled), NULL);
2488 g_signal_connect(mainwin, "button_release_event",
2489 G_CALLBACK(mainwin_mouse_button_release), NULL);
2490 #if 0
2491 aud_drag_dest_set(mainwin);
2492
2493 g_signal_connect(mainwin, "key_press_event",
2494 G_CALLBACK(mainwin_keypress), NULL);
2495
2496 ui_main_evlistener_init();
2497 #endif
2498 }
2499
2500 void
2501 mainwin_create(void)
2502 {
2503 mainwin_create_window();
2504 #if 0
2505 gtk_window_add_accel_group( GTK_WINDOW(mainwin) , ui_manager_get_accel_group() );
2506 #endif
2507 mainwin_create_widgets();
2508 }
2509
2510 gboolean
2511 mainwin_update_song_info(void)
2512 {
2513 if (!audacious_drct_get_playing())
2514 return FALSE;
2515
2516 gint time = audacious_drct_get_time();
2517 gint length = audacious_drct_pl_get_length();
2518 gint t;
2519 gchar stime_prefix;
2520
2521 if (ab_position_a != -1 && ab_position_b != -1 && time > ab_position_b)
2522 audacious_drct_seek(ab_position_a/1000);
2523
2524 if (length == -1 && config.timer_mode == TIMER_REMAINING)
2525 config.timer_mode = TIMER_ELAPSED;
2526 #if 0
2527 playlistwin_set_time(time, length, config.timer_mode);
2528 #endif
2529 if (config.timer_mode == TIMER_REMAINING) {
2530 if (length != -1) {
2531 ui_skinned_number_set_number(mainwin_minus_num, 11);
2532 t = length - time;
2533 stime_prefix = '-';
2534 }
2535 else {
2536 ui_skinned_number_set_number(mainwin_minus_num, 10);
2537 t = time;
2538 stime_prefix = ' ';
2539 }
2540 }
2541 else {
2542 ui_skinned_number_set_number(mainwin_minus_num, 10);
2543 t = time;
2544 stime_prefix = ' ';
2545 }
2546 t /= 1000;
2547
2548 /* Show the time in the format HH:MM when we have more than 100
2549 * minutes. */
2550 if (t >= 100 * 60)
2551 t /= 60;
2552 ui_skinned_number_set_number(mainwin_10min_num, t / 600);
2553 ui_skinned_number_set_number(mainwin_min_num, (t / 60) % 10);
2554 ui_skinned_number_set_number(mainwin_10sec_num, (t / 10) % 6);
2555 ui_skinned_number_set_number(mainwin_sec_num, t % 10);
2556
2557 if (!UI_SKINNED_HORIZONTAL_SLIDER(mainwin_sposition)->pressed) {
2558 gchar *time_str;
2559
2560 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60);
2561 ui_skinned_textbox_set_text(mainwin_stime_min, time_str);
2562 g_free(time_str);
2563
2564 time_str = g_strdup_printf("%2.2d", t % 60);
2565 ui_skinned_textbox_set_text(mainwin_stime_sec, time_str);
2566 g_free(time_str);
2567 }
2568
2569 time /= 1000;
2570 length /= 1000;
2571 if (length > 0) {
2572 if (time > length) {
2573 ui_skinned_horizontal_slider_set_position(mainwin_position, 219);
2574 ui_skinned_horizontal_slider_set_position(mainwin_sposition, 13);
2575 }
2576 /* update the slider position ONLY if there is not a seek in progress */
2577 else if (seek_state == MAINWIN_SEEK_NIL) {
2578 ui_skinned_horizontal_slider_set_position(mainwin_position, (time * 219) / length);
2579 ui_skinned_horizontal_slider_set_position(mainwin_sposition,
2580 ((time * 12) / length) + 1);
2581 }
2582 }
2583 else {
2584 ui_skinned_horizontal_slider_set_position(mainwin_position, 0);
2585 ui_skinned_horizontal_slider_set_position(mainwin_sposition, 1);
2586 }
2587
2588 return TRUE;
2589 }
2590
2591 static gboolean
2592 mainwin_idle_func(gpointer data)
2593 {
2594 GDK_THREADS_ENTER();
2595
2596 /* tristate buttons seek */
2597 if ( seek_state != MAINWIN_SEEK_NIL )
2598 {
2599 GTimeVal now_time;
2600 GTimeVal delta_time;
2601 gulong now_dur;
2602 g_get_current_time(&now_time);
2603
2604 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec;
2605 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec;
2606
2607 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000));
2608
2609 if ( now_dur > TRISTATE_THRESHOLD )
2610 {
2611 gint np;
2612 if (seek_state == MAINWIN_SEEK_REV)
2613 np = seek_initial_pos - labs((gulong)(now_dur/100)); /* seek back */
2614 else
2615 np = seek_initial_pos + labs((gulong)(now_dur/100)); /* seek forward */
2616
2617 /* boundaries check */
2618 if (np < 0 )
2619 np = 0;
2620 else if ( np > 219 )
2621 np = 219;
2622
2623 ui_skinned_horizontal_slider_set_position( mainwin_position , np );
2624 mainwin_position_motion_cb( mainwin_position, np );
2625 }
2626 }
2627
2628 GDK_THREADS_LEAVE();
2629 return TRUE;
2630 }
2631
2632
2633 /* toggleactionentries actions */
2634
2635 void
2636 action_anamode_peaks( GtkToggleAction * action )
2637 {
2638 config.analyzer_peaks = gtk_toggle_action_get_active( action );
2639 }
2640
2641 void
2642 action_autoscroll_songname( GtkToggleAction * action )
2643 {
2644 mainwin_set_title_scroll(gtk_toggle_action_get_active(action));
2645 #if 0
2646 playlistwin_set_sinfo_scroll(config.autoscroll); /* propagate scroll setting to playlistwin_sinfo */
2647 #endif
2648 }
2649
2650 void
2651 action_playback_noplaylistadvance( GtkToggleAction * action )
2652 {
2653 aud_cfg->no_playlist_advance = gtk_toggle_action_get_active( action );
2654 }
2655
2656 void
2657 action_playback_repeat( GtkToggleAction * action )
2658 {
2659 aud_cfg->repeat = gtk_toggle_action_get_active( action );
2660 UI_SKINNED_BUTTON(mainwin_repeat)->inside = aud_cfg->repeat;
2661 gtk_widget_queue_draw(mainwin_repeat);
2662 }
2663
2664 void
2665 action_playback_shuffle( GtkToggleAction * action )
2666 {
2667 aud_cfg->shuffle = gtk_toggle_action_get_active( action );
2668 aud_playlist_set_shuffle(aud_cfg->shuffle);
2669 UI_SKINNED_BUTTON(mainwin_shuffle)->inside = aud_cfg->shuffle;
2670 gtk_widget_queue_draw(mainwin_shuffle);
2671 }
2672
2673 void
2674 action_stop_after_current_song( GtkToggleAction * action )
2675 {
2676 aud_cfg->stopaftersong = gtk_toggle_action_get_active( action );
2677 }
2678
2679 void
2680 action_view_always_on_top( GtkToggleAction * action )
2681 {
2682 UI_SKINNED_MENUROW(mainwin_menurow)->always_selected = gtk_toggle_action_get_active( action );
2683 config.always_on_top = UI_SKINNED_MENUROW(mainwin_menurow)->always_selected;
2684 gtk_widget_queue_draw(mainwin_menurow);
2685 #if 0
2686 hint_set_always(config.always_on_top);
2687 #endif
2688 }
2689
2690 void
2691 action_view_scaled( GtkToggleAction * action )
2692 {
2693 UI_SKINNED_MENUROW(mainwin_menurow)->scale_selected = gtk_toggle_action_get_active( action );
2694 gtk_widget_queue_draw(mainwin_menurow);
2695 set_scaled(UI_SKINNED_MENUROW(mainwin_menurow)->scale_selected);
2696 gdk_flush();
2697 }
2698
2699 void
2700 action_view_easymove( GtkToggleAction * action )
2701 {
2702 config.easy_move = gtk_toggle_action_get_active( action );
2703 }
2704
2705 void
2706 action_view_on_all_workspaces( GtkToggleAction * action )
2707 {
2708 #if 0
2709 config.sticky = gtk_toggle_action_get_active( action );
2710 hint_set_sticky(config.sticky);
2711 #endif
2712 }
2713
2714 void
2715 action_roll_up_equalizer( GtkToggleAction * action )
2716 {
2717 #if 0
2718 equalizerwin_set_shade_menu_cb(gtk_toggle_action_get_active(action));
2719 #endif
2720 }
2721
2722 void
2723 action_roll_up_player( GtkToggleAction * action )
2724 {
2725 mainwin_set_shade_menu_cb(gtk_toggle_action_get_active(action));
2726 }
2727
2728 void
2729 action_roll_up_playlist_editor( GtkToggleAction * action )
2730 {
2731 #if 0
2732 playlistwin_set_shade(gtk_toggle_action_get_active(action));
2733 #endif
2734 }
2735
2736 void
2737 action_show_equalizer( GtkToggleAction * action )
2738 {
2739 #if 0
2740 if (gtk_toggle_action_get_active(action))
2741 equalizerwin_real_show();
2742 else
2743 equalizerwin_real_hide();
2744 #endif
2745 }
2746
2747 void
2748 action_show_playlist_editor( GtkToggleAction * action )
2749 {
2750 #if 0
2751 if (gtk_toggle_action_get_active(action))
2752 playlistwin_show();
2753 else
2754 playlistwin_hide();
2755 #endif
2756 }
2757
2758 void
2759 action_show_player( GtkToggleAction * action )
2760 {
2761 mainwin_show(gtk_toggle_action_get_active(action));
2762 }
2763
2764
2765 /* radioactionentries actions (one callback for each radio group) */
2766
2767 void
2768 action_anafoff( GtkAction *action, GtkRadioAction *current )
2769 {
2770 mainwin_vis_set_afalloff(gtk_radio_action_get_current_value(current));
2771 }
2772
2773 void
2774 action_anamode( GtkAction *action, GtkRadioAction *current )
2775 {
2776 mainwin_vis_set_analyzer_mode(gtk_radio_action_get_current_value(current));
2777 }
2778
2779 void
2780 action_anatype( GtkAction *action, GtkRadioAction *current )
2781 {
2782 mainwin_vis_set_analyzer_type(gtk_radio_action_get_current_value(current));
2783 }
2784
2785 void
2786 action_peafoff( GtkAction *action, GtkRadioAction *current )
2787 {
2788 mainwin_vis_set_pfalloff(gtk_radio_action_get_current_value(current));
2789 }
2790
2791 void
2792 action_refrate( GtkAction *action, GtkRadioAction *current )
2793 {
2794 mainwin_vis_set_refresh(gtk_radio_action_get_current_value(current));
2795 }
2796
2797 void
2798 action_scomode( GtkAction *action, GtkRadioAction *current )
2799 {
2800 config.scope_mode = gtk_radio_action_get_current_value(current);
2801 }
2802
2803 void
2804 action_vismode( GtkAction *action, GtkRadioAction *current )
2805 {
2806 mainwin_vis_set_type_menu_cb(gtk_radio_action_get_current_value(current));
2807 }
2808
2809 void
2810 action_vprmode( GtkAction *action, GtkRadioAction *current )
2811 {
2812 config.voiceprint_mode = gtk_radio_action_get_current_value(current);
2813 }
2814
2815 void
2816 action_wshmode( GtkAction *action, GtkRadioAction *current )
2817 {
2818 config.vu_mode = gtk_radio_action_get_current_value(current);
2819 }
2820
2821 void
2822 action_viewtime( GtkAction *action, GtkRadioAction *current )
2823 {
2824 set_timer_mode_menu_cb(gtk_radio_action_get_current_value(current));
2825 }
2826
2827
2828 /* actionentries actions */
2829
2830 void
2831 action_about_audacious( void )
2832 {
2833 #if 0
2834 show_about_window();
2835 #endif
2836 }
2837
2838 void
2839 action_play_file( void )
2840 {
2841 #if 0
2842 run_filebrowser(PLAY_BUTTON);
2843 #endif
2844 }
2845
2846 void
2847 action_play_location( void )
2848 {
2849 mainwin_show_add_url_window();
2850 }
2851
2852 void
2853 action_ab_set( void )
2854 {
2855 Playlist *playlist = aud_playlist_get_active();
2856 if (aud_playlist_get_current_length(playlist) != -1)
2857 {
2858 if (ab_position_a == -1)
2859 {
2860 ab_position_a = audacious_drct_get_time();
2861 ab_position_b = -1;
2862 mainwin_lock_info_text("LOOP-POINT A POSITION SET.");
2863 }
2864 else if (ab_position_b == -1)
2865 {
2866 int time = audacious_drct_get_time();
2867 if (time > ab_position_a)
2868 ab_position_b = time;
2869 mainwin_release_info_text();
2870 }
2871 else
2872 {
2873 ab_position_a = audacious_drct_get_time();
2874 ab_position_b = -1;
2875 mainwin_lock_info_text("LOOP-POINT A POSITION RESET.");
2876 }
2877 }
2878 }
2879
2880 void
2881 action_ab_clear( void )
2882 {
2883 Playlist *playlist = aud_playlist_get_active();
2884 if (aud_playlist_get_current_length(playlist) != -1)
2885 {
2886 ab_position_a = ab_position_b = -1;
2887 mainwin_release_info_text();
2888 }
2889 }
2890
2891 void
2892 action_current_track_info( void )
2893 {
2894 #if 0
2895 ui_fileinfo_show_current(aud_playlist_get_active());
2896 #endif
2897 }
2898
2899 void
2900 action_jump_to_file( void )
2901 {
2902 #if 0
2903 ui_jump_to_track();
2904 #endif
2905 }
2906
2907 void
2908 action_jump_to_playlist_start( void )
2909 {
2910 Playlist *playlist = aud_playlist_get_active();
2911 aud_playlist_set_position(playlist, 0);
2912 }
2913
2914 void
2915 action_jump_to_time( void )
2916 {
2917 mainwin_jump_to_time();
2918 }
2919
2920 void
2921 action_playback_next( void )
2922 {
2923 Playlist *playlist = aud_playlist_get_active();
2924 aud_playlist_next(playlist);
2925 }
2926
2927 void
2928 action_playback_previous( void )
2929 {
2930 Playlist *playlist = aud_playlist_get_active();
2931 aud_playlist_prev(playlist);
2932 }
2933
2934 void
2935 action_playback_play( void )
2936 {
2937 mainwin_play_pushed();
2938 }
2939
2940 void
2941 action_playback_pause( void )
2942 {
2943 audacious_drct_pause();
2944 }
2945
2946 void
2947 action_playback_stop( void )
2948 {
2949 mainwin_stop_pushed();
2950 }
2951
2952 void
2953 action_preferences( void )
2954 {
2955 #if 0
2956 show_prefs_window();
2957 #endif
2958 }
2959
2960 void
2961 action_quit( void )
2962 {
2963 mainwin_quit_cb();
2964 }
2965
2966 void
2967 util_menu_main_show( gint x , gint y , guint button , guint time )
2968 {
2969 #if 0
2970 /* convenience function that shows the main popup menu wherever requested */
2971 ui_manager_popup_menu_show( GTK_MENU(mainwin_general_menu),
2972 x , y , button , time );
2973 return;
2974 #endif
2975 }