Mercurial > audlegacy
annotate src/audacious/ui_main.c @ 2363:d9208536e270 trunk
[svn] reformatting and g_return_if_fail()
author | mf0102 |
---|---|
date | Thu, 18 Jan 2007 13:21:57 -0800 |
parents | fea1b8594cd8 |
children | ad1d7687814c |
rev | line source |
---|---|
2313 | 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 2 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, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 | |
29 #include <glib.h> | |
30 #include <glib/gi18n.h> | |
31 #include <glib/gprintf.h> | |
32 #include <gtk/gtk.h> | |
33 #include <gtk/gtkmessagedialog.h> | |
34 | |
35 /* GDK including */ | |
36 #include "platform/smartinclude.h" | |
37 | |
38 #include <math.h> | |
39 #include <stdlib.h> | |
40 #include <string.h> | |
41 | |
42 #include <X11/Xlib.h> | |
43 | |
44 #include <sys/types.h> | |
45 | |
46 #if defined(USE_REGEX_ONIGURUMA) | |
47 #include <onigposix.h> | |
48 #elif defined(USE_REGEX_PCRE) | |
49 #include <pcreposix.h> | |
50 #else | |
51 #include <regex.h> | |
52 #endif | |
53 | |
54 #include "widgets/widgetcore.h" | |
55 #include "ui_main.h" | |
56 #include "icons-stock.h" | |
57 | |
58 #include "ui_manager.h" | |
59 #include "actions-mainwin.h" | |
60 | |
61 #include "main.h" | |
62 | |
63 #include "controlsocket.h" | |
64 #include "pluginenum.h" | |
65 | |
66 #include "ui_credits.h" | |
67 #include "dnd.h" | |
68 #include "dock.h" | |
69 #include "ui_equalizer.h" | |
70 #include "hints.h" | |
71 #include "input.h" | |
72 #include "ui_playlist.h" | |
73 #include "ui_preferences.h" | |
74 #include "ui_skinselector.h" | |
75 #include "genevent.h" | |
76 #include "playback.h" | |
77 #include "playlist.h" | |
78 #include "libaudacious/urldecode.h" | |
79 #include "util.h" | |
80 #include "visualization.h" | |
81 #include "libaudacious/configdb.h" | |
82 | |
83 static GTimeVal cb_time; /* click delay for tristate is defined by TRISTATE_THRESHOLD */ | |
84 | |
85 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>"} | |
86 #define TRISTATE_THRESHOLD 200 | |
87 | |
88 #define VOLSET_DISP_TIMES 5 | |
89 | |
90 enum { | |
91 MAINWIN_SEEK_REV = -1, | |
92 MAINWIN_SEEK_NIL, | |
93 MAINWIN_SEEK_FWD | |
94 }; | |
95 | |
96 enum { | |
97 MAINWIN_VIS_ACTIVE_MAINWIN, MAINWIN_VIS_ACTIVE_PLAYLISTWIN | |
98 }; | |
99 | |
100 | |
101 typedef struct _PlaybackInfo PlaybackInfo; | |
102 | |
103 struct _PlaybackInfo { | |
104 gchar *title; | |
105 gint bitrate; | |
106 gint frequency; | |
107 gint n_channels; | |
108 }; | |
109 | |
110 | |
111 GtkWidget *mainwin = NULL; | |
112 GtkWidget *err = NULL; /* an error dialog for miscellaneous error messages */ | |
113 | |
114 static GdkBitmap *nullmask; | |
115 static gint balance; | |
116 | |
117 GtkWidget *mainwin_jtf = NULL; | |
118 static GtkWidget *mainwin_jtt = NULL; | |
119 | |
120 gint seek_state = MAINWIN_SEEK_NIL; | |
121 gint seek_initial_pos = 0; | |
122 | |
123 GdkGC *mainwin_gc; | |
124 static GdkPixmap *mainwin_bg = NULL, *mainwin_bg_x2 = NULL; | |
125 | |
126 static PButton *mainwin_menubtn; | |
127 static PButton *mainwin_minimize, *mainwin_shade, *mainwin_close; | |
128 | |
129 static PButton *mainwin_rew, *mainwin_fwd; | |
130 static PButton *mainwin_eject; | |
131 static PButton *mainwin_play, *mainwin_pause, *mainwin_stop; | |
132 | |
133 TButton *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; | |
134 TextBox *mainwin_info; | |
135 TextBox *mainwin_stime_min, *mainwin_stime_sec; | |
136 | |
137 static TextBox *mainwin_rate_text, *mainwin_freq_text, | |
138 *mainwin_othertext; | |
139 | |
140 PlayStatus *mainwin_playstatus; | |
141 | |
142 Number *mainwin_minus_num, *mainwin_10min_num, *mainwin_min_num; | |
143 Number *mainwin_10sec_num, *mainwin_sec_num; | |
144 | |
145 static gboolean setting_volume = FALSE; | |
146 | |
147 Vis *active_vis; | |
148 Vis *mainwin_vis; | |
149 SVis *mainwin_svis; | |
150 | |
151 HSlider *mainwin_sposition = NULL; | |
152 | |
153 static MenuRow *mainwin_menurow; | |
154 static HSlider *mainwin_volume, *mainwin_balance, *mainwin_position; | |
155 static MonoStereo *mainwin_monostereo; | |
156 static SButton *mainwin_srew, *mainwin_splay, *mainwin_spause; | |
157 static SButton *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about; | |
158 | |
159 static GList *mainwin_wlist = NULL; | |
160 | |
161 static gint mainwin_timeout_id; | |
162 | |
163 G_LOCK_DEFINE_STATIC(mainwin_title); | |
164 | |
165 static gboolean mainwin_force_redraw = FALSE; | |
166 static gchar *mainwin_title_text = NULL; | |
167 static gboolean mainwin_info_text_locked = FALSE; | |
168 | |
169 static int ab_position_a = -1; | |
170 static int ab_position_b = -1; | |
171 | |
172 static PlaybackInfo playback_info = { NULL, 0, 0, 0 }; | |
173 | |
174 | |
175 static gint mainwin_idle_func(gpointer data); | |
176 | |
177 static void set_timer_mode_menu_cb(TimerMode mode); | |
178 static void set_timer_mode(TimerMode mode); | |
179 | |
180 static void mainwin_refresh_hints(void); | |
181 | |
182 void mainwin_position_motion_cb(gint pos); | |
183 void mainwin_position_release_cb(gint pos); | |
184 | |
185 void set_doublesize(gboolean doublesize); | |
186 | |
187 | |
188 | |
189 /* FIXME: placed here for now */ | |
190 void | |
191 playback_get_sample_params(gint * bitrate, | |
192 gint * frequency, | |
193 gint * n_channels) | |
194 { | |
195 if (bitrate) | |
196 *bitrate = playback_info.bitrate; | |
197 | |
198 if (frequency) | |
199 *frequency = playback_info.frequency; | |
200 | |
201 if (n_channels) | |
202 *n_channels = playback_info.n_channels; | |
203 } | |
204 | |
205 static void | |
206 playback_set_sample_params(gint bitrate, | |
207 gint frequency, | |
208 gint n_channels) | |
209 { | |
210 if (bitrate >= 0) | |
211 playback_info.bitrate = bitrate; | |
212 | |
213 if (frequency >= 0) | |
214 playback_info.frequency = frequency; | |
215 | |
216 if (n_channels >= 0) | |
217 playback_info.n_channels = n_channels; | |
218 } | |
219 | |
220 static void | |
221 mainwin_set_title_scroll(gboolean scroll) | |
222 { | |
223 cfg.autoscroll = scroll; | |
224 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
225 } | |
226 | |
227 | |
228 void | |
229 mainwin_set_always_on_top(gboolean always) | |
230 { | |
231 GtkAction *action = gtk_action_group_get_action( | |
232 toggleaction_group_others , "view always on top" ); | |
233 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , always ); | |
234 } | |
235 | |
236 static void | |
237 mainwin_set_shape_mask(void) | |
238 { | |
239 if (!cfg.player_visible) | |
240 return; | |
241 | |
242 if (cfg.doublesize == FALSE) | |
243 gtk_widget_shape_combine_mask(mainwin, | |
244 skin_get_mask(bmp_active_skin, | |
245 SKIN_MASK_MAIN), 0, 0); | |
246 else | |
247 gtk_widget_shape_combine_mask(mainwin, NULL, 0, 0); | |
248 } | |
249 | |
250 static void | |
251 mainwin_set_shade(gboolean shaded) | |
252 { | |
253 GtkAction *action = gtk_action_group_get_action( | |
254 toggleaction_group_others , "roll up player" ); | |
255 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
256 } | |
257 | |
258 static void | |
259 mainwin_set_shade_menu_cb(gboolean shaded) | |
260 { | |
261 cfg.player_shaded = shaded; | |
262 | |
263 mainwin_set_shape_mask(); | |
264 | |
265 if (shaded) { | |
266 dock_shade(dock_window_list, GTK_WINDOW(mainwin), | |
267 MAINWIN_SHADED_HEIGHT * (cfg.doublesize + 1)); | |
268 | |
269 widget_show(WIDGET(mainwin_svis)); | |
270 vis_clear_data(mainwin_vis); | |
271 | |
272 widget_show(WIDGET(mainwin_srew)); | |
273 widget_show(WIDGET(mainwin_splay)); | |
274 widget_show(WIDGET(mainwin_spause)); | |
275 widget_show(WIDGET(mainwin_sstop)); | |
276 widget_show(WIDGET(mainwin_sfwd)); | |
277 widget_show(WIDGET(mainwin_seject)); | |
278 | |
279 textbox_set_scroll(mainwin_info, FALSE); | |
280 if (playback_get_playing()) | |
281 { | |
282 widget_show(WIDGET(mainwin_sposition)); | |
283 widget_show(WIDGET(mainwin_stime_min)); | |
284 widget_show(WIDGET(mainwin_stime_sec)); | |
285 } | |
286 else | |
287 { | |
288 widget_hide(WIDGET(mainwin_sposition)); | |
289 widget_hide(WIDGET(mainwin_stime_min)); | |
290 widget_hide(WIDGET(mainwin_stime_sec)); | |
291 } | |
292 | |
293 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
294 } | |
295 else { | |
296 gint height = !bmp_active_skin->properties.mainwin_height ? MAINWIN_HEIGHT : | |
297 bmp_active_skin->properties.mainwin_height; | |
298 | |
299 dock_shade(dock_window_list, GTK_WINDOW(mainwin), height * (cfg.doublesize + 1)); | |
300 | |
301 widget_hide(WIDGET(mainwin_svis)); | |
302 svis_clear_data(mainwin_svis); | |
303 | |
304 widget_hide(WIDGET(mainwin_srew)); | |
305 widget_hide(WIDGET(mainwin_splay)); | |
306 widget_hide(WIDGET(mainwin_spause)); | |
307 widget_hide(WIDGET(mainwin_sstop)); | |
308 widget_hide(WIDGET(mainwin_sfwd)); | |
309 widget_hide(WIDGET(mainwin_seject)); | |
310 | |
311 widget_hide(WIDGET(mainwin_stime_min)); | |
312 widget_hide(WIDGET(mainwin_stime_sec)); | |
313 widget_hide(WIDGET(mainwin_sposition)); | |
314 | |
315 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
316 mainwin_shade->pb_ny = mainwin_shade->pb_py = 18; | |
317 } | |
318 | |
319 draw_main_window(TRUE); | |
320 } | |
321 | |
322 static void | |
323 mainwin_vis_set_active_vis(gint new_vis) | |
324 { | |
325 active_vis = mainwin_vis; | |
326 } | |
327 | |
328 static void | |
329 mainwin_vis_set_refresh(RefreshRate rate) | |
330 { | |
331 cfg.vis_refresh = rate; | |
332 } | |
333 | |
334 static void | |
335 mainwin_vis_set_afalloff(FalloffSpeed speed) | |
336 { | |
337 cfg.analyzer_falloff = speed; | |
338 } | |
339 | |
340 static void | |
341 mainwin_vis_set_pfalloff(FalloffSpeed speed) | |
342 { | |
343 cfg.peaks_falloff = speed; | |
344 } | |
345 | |
346 static void | |
347 mainwin_vis_set_analyzer_mode(AnalyzerMode mode) | |
348 { | |
349 cfg.analyzer_mode = mode; | |
350 } | |
351 | |
352 static void | |
353 mainwin_vis_set_analyzer_type(AnalyzerType mode) | |
354 { | |
355 cfg.analyzer_type = mode; | |
356 } | |
357 | |
358 void | |
359 mainwin_vis_set_type(VisType mode) | |
360 { | |
361 GtkAction *action; | |
362 | |
363 switch ( mode ) | |
364 { | |
365 case VIS_ANALYZER: | |
366 action = gtk_action_group_get_action( | |
367 radioaction_group_vismode , "vismode analyzer" ); | |
368 break; | |
369 case VIS_SCOPE: | |
370 action = gtk_action_group_get_action( | |
371 radioaction_group_vismode , "vismode scope" ); | |
372 break; | |
373 case VIS_VOICEPRINT: | |
374 action = gtk_action_group_get_action( | |
375 radioaction_group_vismode , "vismode voiceprint" ); | |
376 break; | |
377 case VIS_OFF: | |
378 default: | |
379 action = gtk_action_group_get_action( | |
380 radioaction_group_vismode , "vismode off" ); | |
381 break; | |
382 } | |
383 | |
384 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , TRUE ); | |
385 } | |
386 | |
387 static void | |
388 mainwin_vis_set_type_menu_cb(VisType mode) | |
389 { | |
390 cfg.vis_type = mode; | |
391 | |
392 if (mode == VIS_OFF) { | |
393 if (cfg.player_shaded && cfg.player_visible) | |
394 svis_clear(mainwin_svis); | |
395 else | |
396 vis_clear(active_vis); | |
397 } | |
398 if (mode == VIS_ANALYZER || mode == VIS_SCOPE || mode == VIS_VOICEPRINT) { | |
399 vis_clear_data(active_vis); | |
400 svis_clear_data(mainwin_svis); | |
401 } | |
402 } | |
403 | |
404 static void | |
405 mainwin_menubtn_cb(void) | |
406 { | |
407 gint x, y; | |
408 gtk_window_get_position(GTK_WINDOW(mainwin), &x, &y); | |
409 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), | |
410 x + 6 * (1 + cfg.doublesize), | |
411 y + MAINWIN_SHADED_HEIGHT * (1 + cfg.doublesize), | |
412 1, GDK_CURRENT_TIME); | |
413 } | |
414 | |
415 void | |
416 mainwin_minimize_cb(void) | |
417 { | |
418 if (!mainwin) | |
419 return; | |
420 | |
421 gtk_window_iconify(GTK_WINDOW(mainwin)); | |
422 } | |
423 | |
424 static void | |
425 mainwin_shade_toggle(void) | |
426 { | |
427 mainwin_set_shade(!cfg.player_shaded); | |
428 } | |
429 | |
430 void | |
431 mainwin_quit_cb(void) | |
432 { | |
433 GList *playlists = NULL, *playlists_top = NULL; | |
434 | |
435 gtk_widget_hide(equalizerwin); | |
436 gtk_widget_hide(playlistwin); | |
437 gtk_widget_hide(mainwin); | |
438 gdk_flush(); | |
439 | |
440 g_source_remove(mainwin_timeout_id); | |
441 | |
442 util_set_cursor(NULL); | |
443 | |
444 bmp_config_save(); | |
445 gtk_accel_map_save(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
446 | |
447 ctrlsocket_cleanup(); | |
448 | |
449 plugin_system_cleanup(); | |
450 | |
451 playlist_stop_get_info_thread(); | |
452 | |
453 /* free and clear each playlist */ | |
454 playlists = playlist_get_playlists(); | |
455 playlists_top = playlists; | |
456 while ( playlists != NULL ) | |
457 { | |
458 playlist_clear((Playlist*)playlists->data); | |
459 playlist_free((Playlist*)playlists->data); | |
460 playlists = g_list_next(playlists); | |
461 } | |
462 g_list_free( playlists_top ); | |
463 | |
464 gtk_main_quit(); | |
465 | |
466 exit(EXIT_SUCCESS); | |
467 } | |
468 | |
469 static void | |
470 mainwin_destroy(GtkWidget * widget, gpointer data) | |
471 { | |
472 mainwin_quit_cb(); | |
473 } | |
474 | |
475 static void | |
476 mainwin_draw_titlebar(gboolean focus) | |
477 { | |
478 skin_draw_mainwin_titlebar(bmp_active_skin, mainwin_bg, mainwin_gc, | |
479 cfg.player_shaded, focus || !cfg.dim_titlebar); | |
480 } | |
481 | |
482 void | |
483 draw_main_window(gboolean force) | |
484 { | |
485 GdkImage *img, *img2x; | |
486 GList *wl; | |
487 Widget *w; | |
488 gboolean redraw; | |
489 | |
490 if (!cfg.player_visible) | |
491 return; | |
492 | |
493 if (force) | |
494 mainwin_refresh_hints(); | |
495 | |
496 widget_list_lock(mainwin_wlist); | |
497 | |
498 if (force) { | |
499 if (!cfg.player_shaded) | |
500 skin_draw_pixmap(bmp_active_skin, mainwin_bg, mainwin_gc, | |
501 SKIN_MAIN, 0, 0, 0, 0, bmp_active_skin->properties.mainwin_width, | |
502 bmp_active_skin->properties.mainwin_height); | |
503 mainwin_draw_titlebar(gtk_window_has_toplevel_focus | |
504 (GTK_WINDOW(mainwin))); | |
505 } | |
506 | |
507 widget_list_draw(mainwin_wlist, &redraw, force); | |
508 | |
509 if (redraw || force) { | |
510 if (force) { | |
511 if (cfg.doublesize) { | |
512 img = gdk_drawable_get_image(mainwin_bg, 0, 0, bmp_active_skin->properties.mainwin_width, | |
513 cfg.player_shaded ? | |
514 MAINWIN_SHADED_HEIGHT : | |
515 bmp_active_skin->properties.mainwin_height); | |
516 img2x = create_dblsize_image(img); | |
517 gdk_draw_image(mainwin_bg_x2, mainwin_gc, img2x, 0, 0, | |
518 0, 0, bmp_active_skin->properties.mainwin_width * 2, | |
519 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT * | |
520 2 : bmp_active_skin->properties.mainwin_height * 2); | |
521 g_object_unref(img2x); | |
522 g_object_unref(img); | |
523 } | |
524 | |
525 gdk_window_clear(mainwin->window); | |
526 | |
527 } | |
528 else { | |
529 for (wl = mainwin_wlist; wl; wl = g_list_next(wl)) { | |
530 w = WIDGET(wl->data); | |
531 | |
532 if (!w->redraw || !w->visible) | |
533 continue; | |
534 | |
535 if (w->x > bmp_active_skin->properties.mainwin_width || | |
536 w->y > bmp_active_skin->properties.mainwin_height) | |
537 continue; | |
538 | |
539 if (cfg.doublesize) { | |
540 gint width, height; | |
541 | |
542 width = w->x + w->width <= bmp_active_skin->properties.mainwin_width ? w->width : (w->width - ((w->x + w->width) - bmp_active_skin->properties.mainwin_width)); | |
543 height = w->y + w->height <= bmp_active_skin->properties.mainwin_width ? w->height : (w->height - ((w->y + w->height) - bmp_active_skin->properties.mainwin_height)); | |
544 | |
545 img = gdk_drawable_get_image(mainwin_bg, w->x, w->y, | |
546 width, height); | |
547 img2x = create_dblsize_image(img); | |
548 gdk_draw_image(mainwin_bg_x2, mainwin_gc, | |
549 img2x, 0, 0, w->x << 1, w->y << 1, | |
550 width << 1, height << 1); | |
551 g_object_unref(img2x); | |
552 g_object_unref(img); | |
553 gdk_window_clear_area(mainwin->window, w->x << 1, | |
554 w->y << 1, width << 1, | |
555 height << 1); | |
556 } | |
557 else | |
558 gdk_window_clear_area(mainwin->window, w->x, w->y, | |
559 w->width, w->height); | |
560 w->redraw = FALSE; | |
561 } | |
562 } | |
563 | |
564 gdk_flush(); | |
565 } | |
566 | |
567 widget_list_unlock(mainwin_wlist); | |
568 } | |
569 | |
570 | |
571 void | |
572 mainwin_set_info_text(void) | |
573 { | |
574 gchar *text; | |
575 | |
576 if (mainwin_info_text_locked) | |
577 return; | |
578 | |
579 if ((text = input_get_info_text()) != NULL) { | |
580 textbox_set_text(mainwin_info, text); | |
581 g_free(text); | |
582 } | |
583 else if ((text = playlist_get_info_text(playlist_get_active())) != NULL) { | |
584 textbox_set_text(mainwin_info, text); | |
585 g_free(text); | |
586 } | |
587 } | |
588 | |
589 static gchar *mainwin_tb_old_text = NULL; | |
590 | |
591 void | |
592 mainwin_lock_info_text(const gchar * text) | |
593 { | |
594 if (mainwin_info_text_locked != TRUE) | |
595 mainwin_tb_old_text = g_strdup(bmp_active_skin->properties.mainwin_othertext_is_status ? | |
596 mainwin_othertext->tb_text : mainwin_info->tb_text); | |
597 | |
598 mainwin_info_text_locked = TRUE; | |
599 textbox_set_text(bmp_active_skin->properties.mainwin_othertext_is_status ? | |
600 mainwin_othertext : mainwin_info, text); | |
601 } | |
602 | |
603 void | |
604 mainwin_release_info_text(void) | |
605 { | |
606 mainwin_info_text_locked = FALSE; | |
607 | |
608 if (mainwin_tb_old_text != NULL) | |
609 { | |
610 textbox_set_text(bmp_active_skin->properties.mainwin_othertext_is_status ? | |
611 mainwin_othertext : mainwin_info, mainwin_tb_old_text); | |
612 g_free(mainwin_tb_old_text); | |
613 mainwin_tb_old_text = NULL; | |
614 } | |
615 else | |
616 mainwin_set_info_text(); /* XXX: best we can do */ | |
617 } | |
618 | |
619 | |
620 static gchar * | |
621 make_mainwin_title(const gchar * title) | |
622 { | |
623 if (title) | |
624 return g_strdup_printf(_("%s - Audacious"), title); | |
625 else | |
626 return g_strdup(_("Audacious")); | |
627 } | |
628 | |
629 void | |
630 mainwin_set_song_title(const gchar * title) | |
631 { | |
632 G_LOCK(mainwin_title); | |
633 g_free(mainwin_title_text); | |
634 mainwin_title_text = make_mainwin_title(title); | |
635 G_UNLOCK(mainwin_title); | |
636 } | |
637 | |
638 static void | |
639 mainwin_refresh_hints(void) | |
640 { | |
641 if (bmp_active_skin && bmp_active_skin->properties.mainwin_othertext | |
642 == TRUE) | |
643 { | |
644 widget_hide(WIDGET(mainwin_rate_text)); | |
645 widget_hide(WIDGET(mainwin_freq_text)); | |
646 widget_hide(WIDGET(mainwin_monostereo)); | |
647 | |
648 if (bmp_active_skin->properties.mainwin_othertext_visible) | |
649 widget_show(WIDGET(mainwin_othertext)); | |
650 } | |
651 else | |
652 { | |
653 widget_show(WIDGET(mainwin_rate_text)); | |
654 widget_show(WIDGET(mainwin_freq_text)); | |
655 widget_show(WIDGET(mainwin_monostereo)); | |
656 widget_hide(WIDGET(mainwin_othertext)); | |
657 } | |
658 | |
659 /* positioning and size attributes */ | |
660 if (bmp_active_skin->properties.mainwin_vis_x && bmp_active_skin->properties.mainwin_vis_y) | |
661 widget_move(WIDGET(mainwin_vis), bmp_active_skin->properties.mainwin_vis_x, | |
662 bmp_active_skin->properties.mainwin_vis_y); | |
663 | |
664 if (bmp_active_skin->properties.mainwin_vis_width) | |
665 widget_resize(WIDGET(mainwin_vis), bmp_active_skin->properties.mainwin_vis_width, | |
666 mainwin_vis->vs_widget.height); | |
667 | |
668 if (bmp_active_skin->properties.mainwin_text_x && bmp_active_skin->properties.mainwin_text_y) | |
669 widget_move(WIDGET(mainwin_info), bmp_active_skin->properties.mainwin_text_x, | |
670 bmp_active_skin->properties.mainwin_text_y); | |
671 | |
672 if (bmp_active_skin->properties.mainwin_text_width) | |
673 widget_resize(WIDGET(mainwin_info), bmp_active_skin->properties.mainwin_text_width, | |
674 mainwin_info->tb_widget.height); | |
675 | |
676 if (bmp_active_skin->properties.mainwin_infobar_x && bmp_active_skin->properties.mainwin_infobar_y) | |
677 widget_move(WIDGET(mainwin_othertext), bmp_active_skin->properties.mainwin_infobar_x, | |
678 bmp_active_skin->properties.mainwin_infobar_y); | |
679 | |
680 if (bmp_active_skin->properties.mainwin_number_0_x && bmp_active_skin->properties.mainwin_number_0_y) | |
681 widget_move(WIDGET(mainwin_minus_num), bmp_active_skin->properties.mainwin_number_0_x, | |
682 bmp_active_skin->properties.mainwin_number_0_y); | |
683 | |
684 if (bmp_active_skin->properties.mainwin_number_1_x && bmp_active_skin->properties.mainwin_number_1_y) | |
685 widget_move(WIDGET(mainwin_10min_num), bmp_active_skin->properties.mainwin_number_1_x, | |
686 bmp_active_skin->properties.mainwin_number_1_y); | |
687 | |
688 if (bmp_active_skin->properties.mainwin_number_2_x && bmp_active_skin->properties.mainwin_number_2_y) | |
689 widget_move(WIDGET(mainwin_min_num), bmp_active_skin->properties.mainwin_number_2_x, | |
690 bmp_active_skin->properties.mainwin_number_2_y); | |
691 | |
692 if (bmp_active_skin->properties.mainwin_number_3_x && bmp_active_skin->properties.mainwin_number_3_y) | |
693 widget_move(WIDGET(mainwin_10sec_num), bmp_active_skin->properties.mainwin_number_3_x, | |
694 bmp_active_skin->properties.mainwin_number_3_y); | |
695 | |
696 if (bmp_active_skin->properties.mainwin_number_4_x && bmp_active_skin->properties.mainwin_number_4_y) | |
697 widget_move(WIDGET(mainwin_sec_num), bmp_active_skin->properties.mainwin_number_4_x, | |
698 bmp_active_skin->properties.mainwin_number_4_y); | |
699 | |
700 if (bmp_active_skin->properties.mainwin_playstatus_x && bmp_active_skin->properties.mainwin_playstatus_y) | |
701 widget_move(WIDGET(mainwin_playstatus), bmp_active_skin->properties.mainwin_playstatus_x, | |
702 bmp_active_skin->properties.mainwin_playstatus_y); | |
703 | |
704 if (bmp_active_skin->properties.mainwin_volume_x && bmp_active_skin->properties.mainwin_volume_y) | |
705 widget_move(WIDGET(mainwin_volume), bmp_active_skin->properties.mainwin_volume_x, | |
706 bmp_active_skin->properties.mainwin_volume_y); | |
707 | |
708 if (bmp_active_skin->properties.mainwin_balance_x && bmp_active_skin->properties.mainwin_balance_y) | |
709 widget_move(WIDGET(mainwin_balance), bmp_active_skin->properties.mainwin_balance_x, | |
710 bmp_active_skin->properties.mainwin_balance_y); | |
711 | |
712 if (bmp_active_skin->properties.mainwin_position_x && bmp_active_skin->properties.mainwin_position_y) | |
713 widget_move(WIDGET(mainwin_position), bmp_active_skin->properties.mainwin_position_x, | |
714 bmp_active_skin->properties.mainwin_position_y); | |
715 | |
716 if (bmp_active_skin->properties.mainwin_previous_x && bmp_active_skin->properties.mainwin_previous_y) | |
717 widget_move(WIDGET(mainwin_rew), bmp_active_skin->properties.mainwin_previous_x, | |
718 bmp_active_skin->properties.mainwin_previous_y); | |
719 | |
720 if (bmp_active_skin->properties.mainwin_play_x && bmp_active_skin->properties.mainwin_play_y) | |
721 widget_move(WIDGET(mainwin_play), bmp_active_skin->properties.mainwin_play_x, | |
722 bmp_active_skin->properties.mainwin_play_y); | |
723 | |
724 if (bmp_active_skin->properties.mainwin_pause_x && bmp_active_skin->properties.mainwin_pause_y) | |
725 widget_move(WIDGET(mainwin_pause), bmp_active_skin->properties.mainwin_pause_x, | |
726 bmp_active_skin->properties.mainwin_pause_y); | |
727 | |
728 if (bmp_active_skin->properties.mainwin_stop_x && bmp_active_skin->properties.mainwin_stop_y) | |
729 widget_move(WIDGET(mainwin_stop), bmp_active_skin->properties.mainwin_stop_x, | |
730 bmp_active_skin->properties.mainwin_stop_y); | |
731 | |
732 if (bmp_active_skin->properties.mainwin_next_x && bmp_active_skin->properties.mainwin_next_y) | |
733 widget_move(WIDGET(mainwin_fwd), bmp_active_skin->properties.mainwin_next_x, | |
734 bmp_active_skin->properties.mainwin_next_y); | |
735 | |
736 if (bmp_active_skin->properties.mainwin_eject_x && bmp_active_skin->properties.mainwin_eject_y) | |
737 widget_move(WIDGET(mainwin_eject), bmp_active_skin->properties.mainwin_eject_x, | |
738 bmp_active_skin->properties.mainwin_eject_y); | |
739 | |
740 if (bmp_active_skin->properties.mainwin_eqbutton_x && bmp_active_skin->properties.mainwin_eqbutton_y) | |
741 widget_move(WIDGET(mainwin_eq), bmp_active_skin->properties.mainwin_eqbutton_x, | |
742 bmp_active_skin->properties.mainwin_eqbutton_y); | |
743 | |
744 if (bmp_active_skin->properties.mainwin_plbutton_x && bmp_active_skin->properties.mainwin_plbutton_y) | |
745 widget_move(WIDGET(mainwin_pl), bmp_active_skin->properties.mainwin_plbutton_x, | |
746 bmp_active_skin->properties.mainwin_plbutton_y); | |
747 | |
748 if (bmp_active_skin->properties.mainwin_shuffle_x && bmp_active_skin->properties.mainwin_shuffle_y) | |
749 widget_move(WIDGET(mainwin_shuffle), bmp_active_skin->properties.mainwin_shuffle_x, | |
750 bmp_active_skin->properties.mainwin_shuffle_y); | |
751 | |
752 if (bmp_active_skin->properties.mainwin_repeat_x && bmp_active_skin->properties.mainwin_repeat_y) | |
753 widget_move(WIDGET(mainwin_repeat), bmp_active_skin->properties.mainwin_repeat_x, | |
754 bmp_active_skin->properties.mainwin_repeat_y); | |
755 | |
756 if (bmp_active_skin->properties.mainwin_about_x && bmp_active_skin->properties.mainwin_about_y) | |
757 widget_move(WIDGET(mainwin_about), bmp_active_skin->properties.mainwin_about_x, | |
758 bmp_active_skin->properties.mainwin_about_y); | |
759 | |
760 if (bmp_active_skin->properties.mainwin_minimize_x && bmp_active_skin->properties.mainwin_minimize_y) | |
761 widget_move(WIDGET(mainwin_minimize), cfg.player_shaded ? 244 : bmp_active_skin->properties.mainwin_minimize_x, | |
762 cfg.player_shaded ? 3 : bmp_active_skin->properties.mainwin_minimize_y); | |
763 | |
764 if (bmp_active_skin->properties.mainwin_shade_x && bmp_active_skin->properties.mainwin_shade_y) | |
765 widget_move(WIDGET(mainwin_shade), cfg.player_shaded ? 254 : bmp_active_skin->properties.mainwin_shade_x, | |
766 cfg.player_shaded ? 3 : bmp_active_skin->properties.mainwin_shade_y); | |
767 | |
768 if (bmp_active_skin->properties.mainwin_close_x && bmp_active_skin->properties.mainwin_close_y) | |
769 widget_move(WIDGET(mainwin_close), cfg.player_shaded ? 264 : bmp_active_skin->properties.mainwin_close_x, | |
770 cfg.player_shaded ? 3 : bmp_active_skin->properties.mainwin_close_y); | |
771 | |
772 /* visibility attributes */ | |
773 if (bmp_active_skin->properties.mainwin_menurow_visible) | |
774 widget_show(WIDGET(mainwin_menurow)); | |
775 else | |
776 widget_hide(WIDGET(mainwin_menurow)); | |
777 | |
778 if (bmp_active_skin->properties.mainwin_text_visible) | |
779 widget_show(WIDGET(mainwin_info)); | |
780 else | |
781 widget_hide(WIDGET(mainwin_info)); | |
782 | |
783 if (bmp_active_skin->properties.mainwin_othertext_visible) | |
784 widget_show(WIDGET(mainwin_othertext)); | |
785 else | |
786 widget_hide(WIDGET(mainwin_othertext)); | |
787 | |
788 if (bmp_active_skin->properties.mainwin_vis_visible) | |
789 widget_show(WIDGET(mainwin_vis)); | |
790 else | |
791 widget_hide(WIDGET(mainwin_vis)); | |
792 | |
793 /* window size, mainwinWidth && mainwinHeight properties */ | |
794 if (bmp_active_skin->properties.mainwin_height && bmp_active_skin->properties.mainwin_width) | |
795 { | |
796 gint width, height; | |
797 | |
798 gdk_window_get_size(mainwin->window, &width, &height); | |
799 | |
800 if (width == bmp_active_skin->properties.mainwin_width * (cfg.doublesize + 1) && | |
801 height == bmp_active_skin->properties.mainwin_height * (cfg.doublesize + 1)) | |
802 return; | |
803 | |
804 dock_window_resize(GTK_WINDOW(mainwin), cfg.player_shaded ? MAINWIN_SHADED_WIDTH * (cfg.doublesize + 1) : bmp_active_skin->properties.mainwin_width * (cfg.doublesize + 1), | |
805 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT * (cfg.doublesize + 1) : bmp_active_skin->properties.mainwin_height * (cfg.doublesize + 1), | |
806 bmp_active_skin->properties.mainwin_width * (cfg.doublesize + 1), | |
807 bmp_active_skin->properties.mainwin_height * (cfg.doublesize + 1)); | |
808 | |
809 g_object_unref(mainwin_bg); | |
810 g_object_unref(mainwin_bg_x2); | |
811 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
812 bmp_active_skin->properties.mainwin_width, | |
813 bmp_active_skin->properties.mainwin_height, -1); | |
814 mainwin_bg_x2 = gdk_pixmap_new(mainwin->window, | |
815 bmp_active_skin->properties.mainwin_width * 2, | |
816 bmp_active_skin->properties.mainwin_height * 2, -1); | |
817 mainwin_set_back_pixmap(); | |
818 widget_list_change_pixmap(mainwin_wlist, mainwin_bg); | |
819 gdk_flush(); | |
820 } | |
821 } | |
822 | |
823 void | |
824 mainwin_set_song_info(gint bitrate, | |
825 gint frequency, | |
826 gint n_channels) | |
827 { | |
828 gchar text[512]; | |
829 gchar *title; | |
830 Playlist *playlist = playlist_get_active(); | |
831 | |
832 playback_set_sample_params(bitrate, frequency, n_channels); | |
833 | |
834 if (bitrate != -1) { | |
835 bitrate /= 1000; | |
836 | |
837 if (bitrate < 1000) { | |
838 /* Show bitrate in 1000s */ | |
839 g_snprintf(text, sizeof(text), "%3d", bitrate); | |
840 textbox_set_text(mainwin_rate_text, text); | |
841 } | |
842 else { | |
843 /* Show bitrate in 100,000s */ | |
844 g_snprintf(text, sizeof(text), "%2dH", bitrate / 100); | |
845 textbox_set_text(mainwin_rate_text, text); | |
846 } | |
847 } | |
848 else | |
849 textbox_set_text(mainwin_rate_text, _("VBR")); | |
850 | |
851 /* Show sampling frequency in kHz */ | |
852 g_snprintf(text, sizeof(text), "%2d", frequency / 1000); | |
853 textbox_set_text(mainwin_freq_text, text); | |
854 | |
855 monostereo_set_num_channels(mainwin_monostereo, n_channels); | |
856 | |
857 if (cfg.player_shaded) | |
858 { | |
859 widget_show(WIDGET(mainwin_stime_min)); | |
860 widget_show(WIDGET(mainwin_stime_sec)); | |
861 } | |
862 | |
863 widget_show(WIDGET(mainwin_minus_num)); | |
864 widget_show(WIDGET(mainwin_10min_num)); | |
865 widget_show(WIDGET(mainwin_min_num)); | |
866 widget_show(WIDGET(mainwin_10sec_num)); | |
867 widget_show(WIDGET(mainwin_sec_num)); | |
868 | |
869 if (!playback_get_paused() && mainwin_playstatus != NULL) | |
870 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
871 | |
872 if (playlist_get_current_length(playlist) != -1) { | |
873 if (cfg.player_shaded) | |
874 widget_show(WIDGET(mainwin_sposition)); | |
875 widget_show(WIDGET(mainwin_position)); | |
876 } | |
877 else { | |
878 widget_hide(WIDGET(mainwin_position)); | |
879 widget_hide(WIDGET(mainwin_sposition)); | |
880 mainwin_force_redraw = TRUE; | |
881 } | |
882 | |
883 if (bmp_active_skin && bmp_active_skin->properties.mainwin_othertext | |
884 == TRUE) | |
885 { | |
886 if (bitrate != -1) | |
887 g_snprintf(text, 512, "%d kbps, %0.1f kHz, %s", | |
888 bitrate, | |
889 (gfloat) frequency / 1000, | |
890 (n_channels > 1) ? _("stereo") : _("mono")); | |
891 else | |
892 g_snprintf(text, 512, "VBR, %0.1f kHz, %s", | |
893 (gfloat) frequency / 1000, | |
894 (n_channels > 1) ? _("stereo") : _("mono")); | |
895 | |
896 textbox_set_text(mainwin_othertext, text); | |
897 | |
898 widget_hide(WIDGET(mainwin_rate_text)); | |
899 widget_hide(WIDGET(mainwin_freq_text)); | |
900 widget_hide(WIDGET(mainwin_monostereo)); | |
901 | |
902 if (bmp_active_skin->properties.mainwin_othertext_visible) | |
903 widget_show(WIDGET(mainwin_othertext)); | |
904 } | |
905 else | |
906 { | |
907 widget_show(WIDGET(mainwin_rate_text)); | |
908 widget_show(WIDGET(mainwin_freq_text)); | |
909 widget_show(WIDGET(mainwin_monostereo)); | |
910 widget_hide(WIDGET(mainwin_othertext)); | |
911 } | |
912 | |
913 title = playlist_get_info_text(playlist); | |
914 mainwin_set_song_title(title); | |
915 g_free(title); | |
916 } | |
917 | |
918 void | |
919 mainwin_clear_song_info(void) | |
920 { | |
921 if (!mainwin) | |
922 return; | |
923 | |
924 /* clear title */ | |
925 G_LOCK(mainwin_title); | |
926 g_free(mainwin_title_text); | |
927 mainwin_title_text = NULL; | |
928 G_UNLOCK(mainwin_title); | |
929 | |
930 /* clear sampling parameters */ | |
931 playback_set_sample_params(0, 0, 0); | |
932 | |
933 mainwin_position->hs_pressed = FALSE; | |
934 mainwin_sposition->hs_pressed = FALSE; | |
935 | |
936 /* clear sampling parameter displays */ | |
937 textbox_set_text(mainwin_rate_text, " "); | |
938 textbox_set_text(mainwin_freq_text, " "); | |
939 monostereo_set_num_channels(mainwin_monostereo, 0); | |
940 | |
941 if (mainwin_playstatus != NULL) | |
942 playstatus_set_status(mainwin_playstatus, STATUS_STOP); | |
943 | |
944 /* hide playback time */ | |
945 widget_hide(WIDGET(mainwin_minus_num)); | |
946 widget_hide(WIDGET(mainwin_10min_num)); | |
947 widget_hide(WIDGET(mainwin_min_num)); | |
948 widget_hide(WIDGET(mainwin_10sec_num)); | |
949 widget_hide(WIDGET(mainwin_sec_num)); | |
950 | |
951 widget_hide(WIDGET(mainwin_stime_min)); | |
952 widget_hide(WIDGET(mainwin_stime_sec)); | |
953 | |
954 widget_hide(WIDGET(mainwin_position)); | |
955 widget_hide(WIDGET(mainwin_sposition)); | |
956 | |
957 widget_hide(WIDGET(mainwin_othertext)); | |
958 | |
959 playlistwin_hide_timer(); | |
960 draw_main_window(TRUE); | |
961 | |
962 vis_clear(active_vis); | |
963 } | |
964 | |
965 void | |
966 mainwin_disable_seekbar(void) | |
967 { | |
968 if (!mainwin) | |
969 return; | |
970 | |
971 /* | |
972 * We dont call draw_main_window() here so this will not | |
973 * remove them visually. It will only prevent us from sending | |
974 * any seek calls to the input plugin before the input plugin | |
975 * calls ->set_info(). | |
976 */ | |
977 widget_hide(WIDGET(mainwin_position)); | |
978 widget_hide(WIDGET(mainwin_sposition)); | |
979 } | |
980 | |
981 static gboolean | |
982 mainwin_mouse_button_release(GtkWidget * widget, | |
983 GdkEventButton * event, | |
984 gpointer callback_data) | |
985 { | |
986 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
987 | |
988 /* | |
989 * The gdk_flush() is just for making sure that the pointer really | |
990 * gets ungrabbed before calling any button callbacks | |
991 * | |
992 */ | |
993 | |
994 gdk_flush(); | |
995 | |
996 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
997 dock_move_release(GTK_WINDOW(mainwin)); | |
998 draw_playlist_window(TRUE); | |
999 } | |
1000 | |
1001 if (mainwin_menurow->mr_doublesize_selected) { | |
1002 event->x /= 2; | |
1003 event->y /= 2; | |
1004 } | |
1005 | |
1006 handle_release_cb(mainwin_wlist, widget, event); | |
1007 | |
1008 draw_main_window(FALSE); | |
1009 | |
1010 return FALSE; | |
1011 } | |
1012 | |
1013 static gboolean | |
1014 mainwin_motion(GtkWidget * widget, | |
1015 GdkEventMotion * event, | |
1016 gpointer callback_data) | |
1017 { | |
1018 int x, y; | |
1019 GdkModifierType state; | |
1020 | |
1021 if (event->is_hint != FALSE) | |
1022 { | |
1023 gdk_window_get_pointer(GDK_WINDOW(mainwin->window), | |
1024 &x, &y, &state); | |
1025 | |
1026 /* If it's a hint, we had to query X, so override the | |
1027 * information we we're given... it's probably useless... --nenolod | |
1028 */ | |
1029 event->x = x; | |
1030 event->y = y; | |
1031 event->state = state; | |
1032 } | |
1033 else | |
1034 { | |
1035 x = event->x; | |
1036 y = event->y; | |
1037 state = event->state; | |
1038 } | |
1039 if (cfg.doublesize) { | |
1040 event->x /= 2; | |
1041 event->y /= 2; | |
1042 } | |
1043 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
1044 dock_move_motion(GTK_WINDOW(mainwin), event); | |
1045 } | |
1046 else { | |
1047 handle_motion_cb(mainwin_wlist, widget, event); | |
1048 draw_main_window(FALSE); | |
1049 } | |
1050 | |
1051 gdk_flush(); | |
1052 | |
1053 return FALSE; | |
1054 } | |
1055 | |
1056 static gboolean | |
1057 inside_sensitive_widgets(gint x, gint y) | |
1058 { | |
1059 return (widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1060 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1061 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1062 || widget_contains(WIDGET(mainwin_close), x, y) | |
1063 || widget_contains(WIDGET(mainwin_rew), x, y) | |
1064 || widget_contains(WIDGET(mainwin_play), x, y) | |
1065 || widget_contains(WIDGET(mainwin_pause), x, y) | |
1066 || widget_contains(WIDGET(mainwin_stop), x, y) | |
1067 || widget_contains(WIDGET(mainwin_fwd), x, y) | |
1068 || widget_contains(WIDGET(mainwin_eject), x, y) | |
1069 || widget_contains(WIDGET(mainwin_shuffle), x, y) | |
1070 || widget_contains(WIDGET(mainwin_repeat), x, y) | |
1071 || widget_contains(WIDGET(mainwin_pl), x, y) | |
1072 || widget_contains(WIDGET(mainwin_eq), x, y) | |
1073 || widget_contains(WIDGET(mainwin_info), x, y) | |
1074 || widget_contains(WIDGET(mainwin_menurow), x, y) | |
1075 || widget_contains(WIDGET(mainwin_volume), x, y) | |
1076 || widget_contains(WIDGET(mainwin_balance), x, y) | |
1077 || (widget_contains(WIDGET(mainwin_position), x, y) && | |
1078 widget_is_visible(WIDGET(mainwin_position))) | |
1079 || widget_contains(WIDGET(mainwin_minus_num), x, y) | |
1080 || widget_contains(WIDGET(mainwin_10min_num), x, y) | |
1081 || widget_contains(WIDGET(mainwin_min_num), x, y) | |
1082 || widget_contains(WIDGET(mainwin_10sec_num), x, y) | |
1083 || widget_contains(WIDGET(mainwin_sec_num), x, y) | |
1084 || widget_contains(WIDGET(mainwin_vis), x, y) | |
1085 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1086 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1087 || widget_contains(WIDGET(mainwin_close), x, y) | |
1088 || widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1089 || widget_contains(WIDGET(mainwin_sposition), x, y) | |
1090 || widget_contains(WIDGET(mainwin_stime_min), x, y) | |
1091 || widget_contains(WIDGET(mainwin_stime_sec), x, y) | |
1092 || widget_contains(WIDGET(mainwin_srew), x, y) | |
1093 || widget_contains(WIDGET(mainwin_splay), x, y) | |
1094 || widget_contains(WIDGET(mainwin_spause), x, y) | |
1095 || widget_contains(WIDGET(mainwin_sstop), x, y) | |
1096 || widget_contains(WIDGET(mainwin_sfwd), x, y) | |
1097 || widget_contains(WIDGET(mainwin_seject), x, y) | |
1098 || widget_contains(WIDGET(mainwin_svis), x, y) | |
1099 || widget_contains(WIDGET(mainwin_about), x, y)); | |
1100 } | |
1101 | |
1102 void | |
1103 mainwin_scrolled(GtkWidget *widget, GdkEventScroll *event, | |
1104 gpointer callback_data) | |
1105 { | |
1106 Playlist *playlist = playlist_get_active(); | |
1107 | |
1108 switch (event->direction) { | |
1109 case GDK_SCROLL_UP: | |
1110 mainwin_set_volume_diff(cfg.mouse_change); | |
1111 break; | |
1112 case GDK_SCROLL_DOWN: | |
1113 mainwin_set_volume_diff(-cfg.mouse_change); | |
1114 break; | |
1115 case GDK_SCROLL_LEFT: | |
1116 if (playlist_get_current_length(playlist) != -1) | |
1117 playback_seek(CLAMP(playback_get_time() - 1000, | |
1118 0, playlist_get_current_length(playlist)) / 1000); | |
1119 break; | |
1120 case GDK_SCROLL_RIGHT: | |
1121 if (playlist_get_current_length(playlist) != -1) | |
1122 playback_seek(CLAMP(playback_get_time() + 1000, | |
1123 0, playlist_get_current_length(playlist)) / 1000); | |
1124 break; | |
1125 } | |
1126 } | |
1127 | |
1128 static gboolean | |
1129 mainwin_mouse_button_press(GtkWidget * widget, | |
1130 GdkEventButton * event, | |
1131 gpointer callback_data) | |
1132 { | |
1133 | |
1134 gboolean grab = TRUE; | |
1135 | |
1136 if (cfg.doublesize) { | |
1137 /* | |
1138 * A hack to make doublesize transparent to callbacks. | |
1139 * We should make a copy of this data instead of | |
1140 * tampering with the data we get from gtk+ | |
1141 */ | |
1142 event->x /= 2; | |
1143 event->y /= 2; | |
1144 } | |
1145 | |
1146 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1147 !inside_sensitive_widgets(event->x, event->y) && | |
1148 (cfg.easy_move || event->y < 14)) { | |
1149 if (0 && hint_move_resize_available()) { | |
1150 hint_move_resize(mainwin, event->x_root, event->y_root, TRUE); | |
1151 grab = FALSE; | |
1152 } | |
1153 else { | |
1154 gtk_window_present(GTK_WINDOW(mainwin)); | |
1155 dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, | |
1156 TRUE); | |
1157 } | |
1158 } | |
1159 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1160 event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) { | |
1161 mainwin_set_shade(!cfg.player_shaded); | |
1162 if (dock_is_moving(GTK_WINDOW(mainwin))) | |
1163 dock_move_release(GTK_WINDOW(mainwin)); | |
1164 } | |
1165 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1166 widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1167 playlist_fileinfo_current(playlist_get_active()); | |
1168 } | |
1169 else { | |
1170 handle_press_cb(mainwin_wlist, widget, event); | |
1171 draw_main_window(FALSE); | |
1172 } | |
1173 | |
1174 if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS && | |
1175 (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1176 widget_contains(WIDGET(mainwin_svis), event->x, event->y))) { | |
1177 | |
1178 cfg.vis_type++; | |
1179 | |
1180 if (cfg.vis_type > VIS_OFF) | |
1181 cfg.vis_type = VIS_ANALYZER; | |
1182 | |
1183 mainwin_vis_set_type(cfg.vis_type); | |
1184 } | |
1185 | |
1186 if (event->button == 3) { | |
1187 if (widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1188 ui_manager_popup_menu_show(GTK_MENU(mainwin_songname_menu), | |
1189 event->x_root, event->y_root, | |
1190 3, event->time); | |
1191 grab = FALSE; | |
1192 } | |
1193 else if (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1194 widget_contains(WIDGET(mainwin_svis), event->x, event->y)) { | |
1195 ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu), event->x_root, | |
1196 event->y_root, 3, event->time); | |
1197 grab = FALSE; | |
1198 } | |
1199 else if ( (event->y > 70) && (event->x < 128) ) | |
1200 { | |
1201 | |
1202 ui_manager_popup_menu_show(GTK_MENU(mainwin_playback_menu), | |
1203 event->x_root, | |
1204 event->y_root, 3, event->time); | |
1205 grab = FALSE; | |
1206 } else { | |
1207 /* | |
1208 * Pop up the main menu a few pixels down. | |
1209 * This will avoid that anything is selected | |
1210 * if one right-clicks to focus the window | |
1211 * without raising it. | |
1212 * | |
1213 ***MD I think the above is stupid, people don't expect this | |
1214 * | |
1215 */ | |
1216 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), | |
1217 event->x_root, | |
1218 event->y_root, 3, event->time); | |
1219 grab = FALSE; | |
1220 } | |
1221 } | |
1222 | |
1223 if (event->button == 1) | |
1224 { | |
1225 if (widget_contains(WIDGET(mainwin_minus_num), event->x, event->y) || | |
1226 widget_contains(WIDGET(mainwin_10min_num), event->x, event->y) || | |
1227 widget_contains(WIDGET(mainwin_min_num), event->x, event->y) || | |
1228 widget_contains(WIDGET(mainwin_10sec_num), event->x, event->y) || | |
1229 widget_contains(WIDGET(mainwin_sec_num), event->x, event->y) || | |
1230 widget_contains(WIDGET(mainwin_stime_min), event->x, event->y) || | |
1231 widget_contains(WIDGET(mainwin_stime_sec), event->x, event->y)) | |
1232 { | |
1233 if (cfg.timer_mode == TIMER_ELAPSED) | |
1234 set_timer_mode(TIMER_REMAINING); | |
1235 else | |
1236 set_timer_mode(TIMER_ELAPSED); | |
1237 } | |
1238 } | |
1239 | |
1240 if (grab) | |
1241 gdk_pointer_grab(mainwin->window, FALSE, | |
1242 GDK_BUTTON_MOTION_MASK | | |
1243 GDK_BUTTON_RELEASE_MASK, | |
1244 GDK_WINDOW(GDK_NONE), NULL, GDK_CURRENT_TIME); | |
1245 | |
1246 return FALSE; | |
1247 } | |
1248 | |
1249 static gboolean | |
1250 mainwin_focus_in(GtkWidget * window, | |
1251 GdkEventFocus * event, | |
1252 gpointer data) | |
1253 { | |
1254 mainwin_menubtn->pb_allow_draw = TRUE; | |
1255 mainwin_minimize->pb_allow_draw = TRUE; | |
1256 mainwin_shade->pb_allow_draw = TRUE; | |
1257 mainwin_close->pb_allow_draw = TRUE; | |
1258 draw_main_window(TRUE); | |
1259 | |
1260 return TRUE; | |
1261 } | |
1262 | |
1263 | |
1264 static gboolean | |
1265 mainwin_focus_out(GtkWidget * widget, | |
1266 GdkEventFocus * event, | |
1267 gpointer callback_data) | |
1268 { | |
1269 mainwin_menubtn->pb_allow_draw = FALSE; | |
1270 mainwin_minimize->pb_allow_draw = FALSE; | |
1271 mainwin_shade->pb_allow_draw = FALSE; | |
1272 mainwin_close->pb_allow_draw = FALSE; | |
1273 draw_main_window(TRUE); | |
1274 | |
1275 return TRUE; | |
1276 } | |
1277 | |
1278 static gboolean | |
1279 mainwin_keypress(GtkWidget * grab_widget, | |
1280 GdkEventKey * event, | |
1281 gpointer data) | |
1282 { | |
1283 Playlist *playlist = playlist_get_active(); | |
1284 | |
1285 switch (event->keyval) { | |
1286 | |
1287 case GDK_Up: | |
1288 case GDK_KP_Up: | |
1289 case GDK_KP_8: | |
1290 mainwin_set_volume_diff(2); | |
1291 break; | |
1292 case GDK_Down: | |
1293 case GDK_KP_Down: | |
1294 case GDK_KP_2: | |
1295 mainwin_set_volume_diff(-2); | |
1296 break; | |
1297 case GDK_Left: | |
1298 case GDK_KP_Left: | |
1299 case GDK_KP_7: | |
1300 if (playlist_get_current_length(playlist) != -1) | |
1301 playback_seek(CLAMP | |
1302 (playback_get_time() - 5000, 0, | |
1303 playlist_get_current_length(playlist)) / 1000); | |
1304 break; | |
1305 case GDK_Right: | |
1306 case GDK_KP_Right: | |
1307 case GDK_KP_9: | |
1308 if (playlist_get_current_length(playlist) != -1) | |
1309 playback_seek(CLAMP | |
1310 (playback_get_time() + 5000, 0, | |
1311 playlist_get_current_length(playlist)) / 1000); | |
1312 break; | |
1313 case GDK_KP_4: | |
1314 playlist_prev(playlist); | |
1315 break; | |
1316 case GDK_KP_6: | |
1317 playlist_next(playlist); | |
1318 break; | |
1319 case GDK_KP_Insert: | |
1320 mainwin_jump_to_file(); | |
1321 break; | |
1322 case GDK_KP_5: | |
1323 mainwin_play_pushed(); | |
1324 break; | |
1325 case GDK_Escape: | |
1326 mainwin_minimize_cb(); | |
1327 break; | |
1328 default: | |
1329 return FALSE; | |
1330 } | |
1331 | |
1332 return TRUE; | |
1333 } | |
1334 | |
1335 static void | |
1336 mainwin_jump_to_time_cb(GtkWidget * widget, | |
1337 GtkWidget * entry) | |
1338 { | |
1339 guint min = 0, sec = 0, params; | |
1340 gint time; | |
1341 Playlist *playlist = playlist_get_active(); | |
1342 | |
1343 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u", | |
1344 &min, &sec); | |
1345 if (params == 2) | |
1346 time = (min * 60) + sec; | |
1347 else if (params == 1) | |
1348 time = min; | |
1349 else | |
1350 return; | |
1351 | |
1352 if (playlist_get_current_length(playlist) > -1 && | |
1353 time <= (playlist_get_current_length(playlist) / 1000)) | |
1354 { | |
1355 playback_seek(time); | |
1356 gtk_widget_destroy(mainwin_jtt); | |
1357 } | |
1358 } | |
1359 | |
1360 | |
1361 void | |
1362 mainwin_jump_to_time(void) | |
1363 { | |
1364 GtkWidget *vbox, *hbox_new, *hbox_total; | |
1365 GtkWidget *time_entry, *label, *bbox, *jump, *cancel; | |
1366 guint tindex; | |
1367 gchar time_str[10]; | |
1368 | |
1369 if (!playback_get_playing()) { | |
1370 report_error("JIT can't be launched when no track is being played.\n"); | |
1371 return; | |
1372 } | |
1373 | |
1374 if (mainwin_jtt) { | |
1375 gtk_window_present(GTK_WINDOW(mainwin_jtt)); | |
1376 return; | |
1377 } | |
1378 | |
1379 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1380 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt), | |
1381 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1382 | |
1383 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time")); | |
1384 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER); | |
1385 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt), | |
1386 GTK_WINDOW(mainwin)); | |
1387 | |
1388 g_signal_connect(mainwin_jtt, "destroy", | |
1389 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt); | |
1390 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10); | |
1391 | |
1392 vbox = gtk_vbox_new(FALSE, 5); | |
1393 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox); | |
1394 | |
1395 hbox_new = gtk_hbox_new(FALSE, 0); | |
1396 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5); | |
1397 | |
1398 time_entry = gtk_entry_new(); | |
1399 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5); | |
1400 g_signal_connect(time_entry, "activate", | |
1401 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1402 | |
1403 gtk_widget_set_size_request(time_entry, 70, -1); | |
1404 label = gtk_label_new(_("minutes:seconds")); | |
1405 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5); | |
1406 | |
1407 hbox_total = gtk_hbox_new(FALSE, 0); | |
1408 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5); | |
1409 gtk_widget_show(hbox_total); | |
1410 | |
1411 /* FIXME: Disable display of current track length. It's not | |
1412 updated when track changes */ | |
1413 #if 0 | |
1414 label = gtk_label_new(_("Track length:")); | |
1415 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5); | |
1416 | |
1417 len = playlist_get_current_length() / 1000; | |
1418 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60); | |
1419 label = gtk_label_new(time_str); | |
1420 | |
1421 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10); | |
1422 #endif | |
1423 | |
1424 bbox = gtk_hbutton_box_new(); | |
1425 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); | |
1426 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1427 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1428 | |
1429 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1430 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1431 gtk_container_add(GTK_CONTAINER(bbox), cancel); | |
1432 g_signal_connect_swapped(cancel, "clicked", | |
1433 G_CALLBACK(gtk_widget_destroy), mainwin_jtt); | |
1434 | |
1435 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1436 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1437 gtk_container_add(GTK_CONTAINER(bbox), jump); | |
1438 g_signal_connect(jump, "clicked", | |
1439 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1440 | |
1441 tindex = playback_get_time() / 1000; | |
1442 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60, | |
1443 tindex % 60); | |
1444 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str); | |
1445 | |
1446 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str)); | |
1447 | |
1448 gtk_widget_show_all(mainwin_jtt); | |
1449 | |
1450 gtk_widget_grab_focus(time_entry); | |
1451 gtk_widget_grab_default(jump); | |
1452 } | |
1453 | |
1454 static void | |
1455 change_song(guint pos) | |
1456 { | |
1457 if (playback_get_playing()) | |
1458 playback_stop(); | |
1459 | |
1460 playlist_set_position(playlist_get_active(), pos); | |
1461 playback_initiate(); | |
1462 } | |
1463 | |
1464 static void | |
1465 mainwin_jump_to_file_jump(GtkTreeView * treeview) | |
1466 { | |
1467 GtkTreeModel *model; | |
1468 GtkTreeSelection *selection; | |
1469 GtkTreeIter iter; | |
1470 guint pos; | |
1471 | |
1472 model = gtk_tree_view_get_model(treeview); | |
1473 selection = gtk_tree_view_get_selection(treeview); | |
1474 | |
1475 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1476 return; | |
1477 | |
1478 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
1479 | |
1480 change_song(pos - 1); | |
1481 | |
1482 /* FIXME: should only hide window */ | |
1483 gtk_widget_destroy(mainwin_jtf); | |
1484 mainwin_jtf = NULL; | |
1485 } | |
1486 | |
1487 static void | |
1488 mainwin_jump_to_file_jump_cb(GtkTreeView * treeview, | |
1489 gpointer data) | |
1490 { | |
1491 mainwin_jump_to_file_jump(treeview); | |
1492 } | |
1493 | |
1494 static void | |
1495 mainwin_jump_to_file_set_queue_button_label(GtkButton * button, | |
1496 guint pos) | |
1497 { | |
1498 if (playlist_is_position_queued(playlist_get_active(), pos)) | |
1499 gtk_button_set_label(button, _("Un_queue")); | |
1500 else | |
1501 gtk_button_set_label(button, _("_Queue")); | |
1502 } | |
1503 | |
1504 static void | |
1505 mainwin_jump_to_file_queue_cb(GtkButton * button, | |
1506 gpointer data) | |
1507 { | |
1508 GtkTreeView *treeview; | |
1509 GtkTreeModel *model; | |
1510 GtkTreeSelection *selection; | |
1511 GtkTreeIter iter; | |
1512 guint pos; | |
1513 | |
1514 treeview = GTK_TREE_VIEW(data); | |
1515 model = gtk_tree_view_get_model(treeview); | |
1516 selection = gtk_tree_view_get_selection(treeview); | |
1517 | |
1518 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1519 return; | |
1520 | |
1521 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
1522 | |
1523 playlist_queue_position(playlist_get_active(), (pos - 1)); | |
1524 | |
1525 mainwin_jump_to_file_set_queue_button_label(button, (pos - 1)); | |
1526 } | |
1527 | |
1528 static void | |
1529 mainwin_jump_to_file_selection_changed_cb(GtkTreeSelection *treesel, | |
1530 gpointer data) | |
1531 { | |
1532 GtkTreeView *treeview; | |
1533 GtkTreeModel *model; | |
1534 GtkTreeSelection *selection; | |
1535 GtkTreeIter iter; | |
1536 guint pos; | |
1537 | |
1538 treeview = gtk_tree_selection_get_tree_view(treesel); | |
1539 model = gtk_tree_view_get_model(treeview); | |
1540 selection = gtk_tree_view_get_selection(treeview); | |
1541 | |
1542 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1543 return; | |
1544 | |
1545 gtk_tree_model_get(model, &iter, 0, &pos, -1); | |
1546 | |
1547 mainwin_jump_to_file_set_queue_button_label(GTK_BUTTON(data), (pos - 1)); | |
1548 } | |
1549 | |
1550 static gboolean | |
1551 mainwin_jump_to_file_edit_keypress_cb(GtkWidget * object, | |
1552 GdkEventKey * event, | |
1553 gpointer data) | |
1554 { | |
1555 switch (event->keyval) { | |
1556 case GDK_Return: | |
1557 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
1558 GTK_ENTRY (object)->need_im_reset = TRUE; | |
1559 return TRUE; | |
1560 } else { | |
1561 mainwin_jump_to_file_jump(GTK_TREE_VIEW(data)); | |
1562 return TRUE; | |
1563 } | |
1564 default: | |
1565 return FALSE; | |
1566 } | |
1567 } | |
1568 | |
1569 static gboolean | |
1570 mainwin_jump_to_file_keypress_cb(GtkWidget * object, | |
1571 GdkEventKey * event, | |
1572 gpointer data) | |
1573 { | |
1574 switch (event->keyval) { | |
1575 case GDK_Escape: | |
1576 /* FIXME: show only hide window */ | |
1577 gtk_widget_destroy(mainwin_jtf); | |
1578 mainwin_jtf = NULL; | |
1579 return TRUE; | |
1580 case GDK_KP_Enter: | |
1581 mainwin_jump_to_file_queue_cb(NULL, data); | |
1582 return TRUE; | |
1583 default: | |
1584 return FALSE; | |
1585 }; | |
1586 | |
1587 return FALSE; | |
1588 } | |
1589 | |
1590 static gboolean | |
1591 mainwin_jump_to_file_match(const gchar * song, GSList *regex_list) | |
1592 { | |
1593 gboolean rv = TRUE; | |
1594 | |
1595 if ( song == NULL ) | |
1596 return FALSE; | |
1597 | |
1598 for ( ; regex_list ; regex_list = g_slist_next(regex_list) ) | |
1599 { | |
1600 regex_t *regex = regex_list->data; | |
1601 if ( regexec( regex , song , 0 , NULL , 0 ) != 0 ) | |
1602 { | |
1603 rv = FALSE; | |
1604 break; | |
1605 } | |
1606 } | |
1607 | |
1608 return rv; | |
1609 } | |
1610 | |
1611 /* FIXME: Clear the entry when the list gets updated */ | |
1612 static void | |
1613 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
1614 { | |
1615 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
1616 * reading */ | |
1617 guint row; | |
1618 GList *playlist_glist; | |
1619 gchar *desc_buf = NULL; | |
1620 GtkTreeIter iter; | |
1621 GtkTreeSelection *selection; | |
1622 Playlist *playlist; | |
1623 | |
1624 GtkTreeModel *store; | |
1625 | |
1626 if (!mainwin_jtf) | |
1627 return; | |
1628 | |
1629 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
1630 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1631 | |
1632 row = 1; | |
1633 playlist = playlist_get_active(); | |
1634 for (playlist_glist = playlist->entries; playlist_glist; | |
1635 playlist_glist = g_list_next(playlist_glist)) { | |
1636 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
1637 | |
1638 if (entry->title) | |
1639 desc_buf = g_strdup(entry->title); | |
1640 else if (strchr(entry->filename, '/')) | |
1641 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
1642 else | |
1643 desc_buf = str_to_utf8(entry->filename); | |
1644 | |
1645 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
1646 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
1647 0, row, 1, desc_buf, -1); | |
1648 row++; | |
1649 | |
1650 if(desc_buf) { | |
1651 g_free(desc_buf); | |
1652 desc_buf = NULL; | |
1653 } | |
1654 } | |
1655 | |
1656 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1657 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
1658 gtk_tree_selection_select_iter(selection, &iter); | |
1659 } | |
1660 | |
1661 static void | |
1662 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
1663 { | |
1664 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
1665 GtkTreeSelection *selection; | |
1666 GtkTreeIter iter; | |
1667 | |
1668 GtkListStore *store; | |
1669 | |
1670 guint song_index = 0; | |
1671 gchar **words; | |
1672 GList *playlist_glist; | |
1673 Playlist *playlist; | |
1674 | |
1675 gboolean match = FALSE; | |
1676 | |
1677 GSList *regex_list = NULL, *regex_list_tmp = NULL; | |
1678 gint i = -1; | |
1679 | |
1680 /* Chop the key string into ' '-separated key regex-pattern strings */ | |
1681 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
1682 | |
1683 /* create a list of regex using the regex-pattern strings */ | |
1684 while ( words[++i] != NULL ) | |
1685 { | |
1686 regex_t *regex = g_malloc(sizeof(regex_t)); | |
1687 #if defined(USE_REGEX_PCRE) | |
1688 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) | |
1689 #else | |
1690 if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE ) == 0 ) | |
1691 #endif | |
1692 regex_list = g_slist_append( regex_list , regex ); | |
1693 } | |
1694 | |
1695 /* FIXME: Remove the connected signals before clearing | |
1696 * (row-selected will still eventually arrive once) */ | |
1697 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
1698 /* detach model from treeview */ | |
1699 g_object_ref( store ); | |
1700 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , NULL ); | |
1701 | |
1702 gtk_list_store_clear(store); | |
1703 | |
1704 playlist = playlist_get_active(); | |
1705 | |
1706 PLAYLIST_LOCK(playlist->mutex); | |
1707 | |
1708 for (playlist_glist = playlist->entries; playlist_glist; | |
1709 playlist_glist = g_list_next(playlist_glist)) { | |
1710 | |
1711 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
1712 const gchar *title; | |
1713 gchar *filename = NULL; | |
1714 | |
1715 title = entry->title; | |
1716 if (!title) { | |
1717 filename = str_to_utf8(entry->filename); | |
1718 | |
1719 if (strchr(filename, '/')) | |
1720 title = strrchr(filename, '/') + 1; | |
1721 else | |
1722 title = filename; | |
1723 } | |
1724 | |
1725 /* Compare the reg.expressions to the string - if all the | |
1726 regexp in regex_list match, add to the ListStore */ | |
1727 | |
1728 /* | |
1729 * FIXME: The search string should be adapted to the | |
1730 * current display setting, e.g. if the user has set it to | |
1731 * "%p - %t" then build the match string like that too, or | |
1732 * even better, search for each of the tags seperatly. | |
1733 * | |
1734 * In any case the string to match should _never_ contain | |
1735 * something the user can't actually see in the playlist. | |
1736 */ | |
1737 if (regex_list != NULL) | |
1738 match = mainwin_jump_to_file_match(title, regex_list); | |
1739 else | |
1740 match = TRUE; | |
1741 | |
1742 if (match) { | |
1743 gtk_list_store_append(store, &iter); | |
1744 gtk_list_store_set(store, &iter, 0, song_index + 1 , 1, title, -1); | |
1745 } | |
1746 | |
1747 song_index++; | |
1748 if (filename) { | |
1749 g_free(filename); | |
1750 filename = NULL; | |
1751 } | |
1752 } | |
1753 | |
1754 PLAYLIST_UNLOCK(playlist->mutex); | |
1755 | |
1756 /* attach the model again to the treeview */ | |
1757 gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , GTK_TREE_MODEL(store) ); | |
1758 g_object_unref( store ); | |
1759 | |
1760 if ( regex_list != NULL ) | |
1761 { | |
1762 regex_list_tmp = regex_list; | |
1763 while ( regex_list != NULL ) | |
1764 { | |
1765 regex_t *regex = regex_list->data; | |
1766 regfree( regex ); | |
1767 regex_list = g_slist_next(regex_list); | |
1768 } | |
1769 g_slist_free( regex_list_tmp ); | |
1770 } | |
1771 g_strfreev(words); | |
1772 | |
1773 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
1774 selection = gtk_tree_view_get_selection(treeview); | |
1775 gtk_tree_selection_select_iter(selection, &iter); | |
1776 } | |
1777 } | |
1778 | |
1779 void | |
1780 mainwin_jump_to_file(void) | |
1781 { | |
1782 GtkWidget *scrollwin; | |
1783 GtkWidget *vbox, *bbox, *sep; | |
1784 GtkWidget *jump, *queue, *cancel; | |
1785 GtkWidget *rescan, *edit; | |
1786 GtkWidget *search_label, *hbox; | |
1787 GList *playlist_glist; | |
1788 Playlist *playlist; | |
1789 gchar *desc_buf = NULL; | |
1790 guint row; | |
1791 | |
1792 GtkWidget *treeview; | |
1793 GtkListStore *jtf_store; | |
1794 | |
1795 GtkTreeIter iter; | |
1796 GtkCellRenderer *renderer; | |
1797 GtkTreeViewColumn *column; | |
1798 | |
1799 if (mainwin_jtf) { | |
1800 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
1801 return; | |
1802 } | |
1803 | |
1804 #if defined(USE_REGEX_ONIGURUMA) | |
1805 /* set encoding for Oniguruma regex to UTF-8 */ | |
1806 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); | |
1807 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); | |
1808 #endif | |
1809 | |
1810 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1811 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
1812 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1813 | |
1814 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
1815 | |
1816 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
1817 g_signal_connect(mainwin_jtf, "destroy", | |
1818 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
1819 | |
1820 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
1821 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
1822 | |
1823 vbox = gtk_vbox_new(FALSE, 5); | |
1824 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
1825 | |
1826 jtf_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING); | |
1827 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
1828 g_object_unref(jtf_store); | |
1829 | |
1830 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
1831 | |
1832 column = gtk_tree_view_column_new(); | |
1833 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
1834 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1835 | |
1836 renderer = gtk_cell_renderer_text_new(); | |
1837 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1838 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
1839 gtk_tree_view_column_set_spacing(column, 4); | |
1840 | |
1841 renderer = gtk_cell_renderer_text_new(); | |
1842 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1843 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
1844 gtk_tree_view_column_set_spacing(column, 4); | |
1845 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
1846 | |
1847 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
1848 | |
1849 g_signal_connect(treeview, "row-activated", | |
1850 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
1851 | |
1852 hbox = gtk_hbox_new(FALSE, 3); | |
1853 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
1854 | |
1855 search_label = gtk_label_new(_("Filter: ")); | |
1856 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), _("_Filter:")); | |
1857 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
1858 | |
1859 edit = gtk_entry_new(); | |
1860 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
1861 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
1862 g_signal_connect(edit, "changed", | |
1863 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
1864 | |
1865 g_signal_connect(edit, "key_press_event", | |
1866 G_CALLBACK(mainwin_jump_to_file_edit_keypress_cb), treeview); | |
1867 | |
1868 g_signal_connect(mainwin_jtf, "key_press_event", | |
1869 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
1870 | |
1871 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
1872 | |
1873 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
1874 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
1875 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
1876 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1877 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
1878 GTK_SHADOW_IN); | |
1879 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
1880 | |
1881 sep = gtk_hseparator_new(); | |
1882 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
1883 | |
1884 bbox = gtk_hbutton_box_new(); | |
1885 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1886 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1887 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1888 | |
1889 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
1890 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
1891 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
1892 g_signal_connect(queue, "clicked", | |
1893 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
1894 treeview); | |
1895 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
1896 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
1897 queue); | |
1898 | |
1899 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
1900 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
1901 g_signal_connect(rescan, "clicked", | |
1902 G_CALLBACK(mainwin_update_jtf), treeview); | |
1903 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
1904 gtk_widget_grab_default(rescan); | |
1905 | |
1906 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1907 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
1908 | |
1909 g_signal_connect_swapped(jump, "clicked", | |
1910 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
1911 treeview); | |
1912 | |
1913 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1914 gtk_widget_grab_default(jump); | |
1915 | |
1916 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
1917 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
1918 g_signal_connect_swapped(cancel, "clicked", | |
1919 G_CALLBACK(gtk_widget_destroy), | |
1920 mainwin_jtf); | |
1921 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1922 | |
1923 gtk_list_store_clear(jtf_store); | |
1924 | |
1925 row = 1; | |
1926 | |
1927 playlist = playlist_get_active(); | |
1928 | |
1929 PLAYLIST_LOCK(playlist->mutex); | |
1930 | |
1931 for (playlist_glist = playlist->entries; playlist_glist; | |
1932 playlist_glist = g_list_next(playlist_glist)) { | |
1933 | |
1934 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); | |
1935 | |
1936 if (entry->title) | |
1937 desc_buf = g_strdup(entry->title); | |
1938 else if (strchr(entry->filename, '/')) | |
1939 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
1940 else | |
1941 desc_buf = str_to_utf8(entry->filename); | |
1942 | |
1943 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
1944 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
1945 0, row, 1, desc_buf, -1); | |
1946 row++; | |
1947 | |
1948 if (desc_buf) { | |
1949 g_free(desc_buf); | |
1950 desc_buf = NULL; | |
1951 } | |
1952 } | |
1953 | |
1954 PLAYLIST_UNLOCK(playlist->mutex); | |
1955 | |
1956 gtk_widget_show_all(mainwin_jtf); | |
1957 } | |
1958 | |
1959 static gboolean | |
1960 mainwin_configure(GtkWidget * window, | |
1961 GdkEventConfigure * event, | |
1962 gpointer data) | |
1963 { | |
1964 if (!GTK_WIDGET_VISIBLE(window)) | |
1965 return FALSE; | |
1966 | |
1967 if (cfg.show_wm_decorations) | |
1968 gdk_window_get_root_origin(window->window, | |
1969 &cfg.player_x, &cfg.player_y); | |
1970 else | |
1971 gdk_window_get_deskrelative_origin(window->window, | |
1972 &cfg.player_x, &cfg.player_y); | |
1973 return FALSE; | |
1974 } | |
1975 | |
1976 void | |
1977 mainwin_set_back_pixmap(void) | |
1978 { | |
1979 if (cfg.doublesize) | |
1980 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg_x2, 0); | |
1981 else | |
1982 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
1983 gdk_window_clear(mainwin->window); | |
1984 } | |
1985 | |
1986 /* | |
1987 * Rewritten 09/13/06: | |
1988 * | |
1989 * Remove all of this flaky iter/sourcelist/strsplit stuff. | |
1990 * All we care about is the filepath. | |
1991 * | |
1992 * We can figure this out and easily pass it to xmms_urldecode_plain(). | |
1993 * - nenolod | |
1994 */ | |
1995 void | |
1996 mainwin_drag_data_received(GtkWidget * widget, | |
1997 GdkDragContext * context, | |
1998 gint x, | |
1999 gint y, | |
2000 GtkSelectionData * selection_data, | |
2001 guint info, | |
2002 guint time, | |
2003 gpointer user_data) | |
2004 { | |
2005 Playlist *playlist = playlist_get_active(); | |
2006 | |
2007 g_return_if_fail(selection_data != NULL); | |
2008 g_return_if_fail(selection_data->data != NULL); | |
2009 | |
2010 if (str_has_prefix_nocase((gchar *) selection_data->data, "fonts:///")) | |
2011 { | |
2012 gchar *path = (gchar *) selection_data->data + 9; /* skip fonts:/// */ | |
2013 gchar *decoded = xmms_urldecode_plain(path); | |
2014 | |
2015 cfg.playlist_font = g_strconcat(decoded, strrchr(cfg.playlist_font, ' '), NULL); | |
2016 playlist_list_set_font(cfg.playlist_font); | |
2017 playlistwin_update_list(playlist); | |
2018 | |
2019 g_free(decoded); | |
2020 | |
2021 return; | |
2022 } | |
2023 | |
2024 playlist_clear(playlist); | |
2025 playlist_add_url(playlist, (gchar *) selection_data->data); | |
2026 playback_initiate(); | |
2027 } | |
2028 | |
2029 static void | |
2030 on_add_url_add_clicked(GtkWidget * widget, | |
2031 GtkWidget * entry) | |
2032 { | |
2033 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2034 if (text && *text) | |
2035 playlist_add_url(playlist_get_active(), text); | |
2036 } | |
2037 | |
2038 static void | |
2039 on_add_url_ok_clicked(GtkWidget * widget, | |
2040 GtkWidget * entry) | |
2041 { | |
2042 Playlist *playlist = playlist_get_active(); | |
2043 | |
2044 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2045 if (text && *text) | |
2046 { | |
2047 playlist_clear(playlist); | |
2048 playlist_add_url(playlist, text); | |
2049 playback_initiate(); | |
2050 } | |
2051 } | |
2052 | |
2053 void | |
2054 mainwin_show_add_url_window(void) | |
2055 { | |
2056 static GtkWidget *url_window = NULL; | |
2057 | |
2058 if (!url_window) { | |
2059 url_window = | |
2060 util_add_url_dialog_new(_("Enter location to play:"), | |
2061 G_CALLBACK(on_add_url_ok_clicked), | |
2062 G_CALLBACK(on_add_url_add_clicked)); | |
2063 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
2064 GTK_WINDOW(mainwin)); | |
2065 g_signal_connect(url_window, "destroy", | |
2066 G_CALLBACK(gtk_widget_destroyed), | |
2067 &url_window); | |
2068 } | |
2069 | |
2070 gtk_window_present(GTK_WINDOW(url_window)); | |
2071 } | |
2072 | |
2073 static void | |
2074 check_set( GtkActionGroup * action_group , | |
2075 const gchar * action_name , | |
2076 gboolean is_on ) | |
2077 { | |
2078 /* check_set noew uses gtkaction */ | |
2079 GtkAction *action = gtk_action_group_get_action( action_group , action_name ); | |
2080 if ( action != NULL ) | |
2081 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , is_on ); | |
2082 return; | |
2083 } | |
2084 | |
2085 void | |
2086 mainwin_eject_pushed(void) | |
2087 { | |
2088 util_run_filebrowser(PLAY_BUTTON); | |
2089 } | |
2090 | |
2091 void | |
2092 mainwin_rev_pushed(void) | |
2093 { | |
2094 g_get_current_time(&cb_time); | |
2095 | |
2096 seek_initial_pos = hslider_get_position(mainwin_position); | |
2097 seek_state = MAINWIN_SEEK_REV; | |
2098 } | |
2099 | |
2100 void | |
2101 mainwin_rev_release(void) | |
2102 { | |
2103 GTimeVal now_time; | |
2104 GTimeVal delta_time; | |
2105 gulong now_dur; | |
2106 | |
2107 g_get_current_time(&now_time); | |
2108 | |
2109 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
2110 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
2111 | |
2112 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
2113 | |
2114 if ( now_dur <= TRISTATE_THRESHOLD ) | |
2115 { | |
2116 /* interpret as 'skip to previous song' */ | |
2117 playlist_prev(playlist_get_active()); | |
2118 } | |
2119 else | |
2120 { | |
2121 /* interpret as 'seek' */ | |
2122 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
2123 } | |
2124 | |
2125 seek_state = MAINWIN_SEEK_NIL; | |
2126 } | |
2127 | |
2128 void | |
2129 mainwin_fwd_pushed(void) | |
2130 { | |
2131 g_get_current_time(&cb_time); | |
2132 | |
2133 seek_initial_pos = hslider_get_position(mainwin_position); | |
2134 seek_state = MAINWIN_SEEK_FWD; | |
2135 } | |
2136 | |
2137 void | |
2138 mainwin_fwd_release(void) | |
2139 { | |
2140 GTimeVal now_time; | |
2141 GTimeVal delta_time; | |
2142 gulong now_dur; | |
2143 | |
2144 g_get_current_time(&now_time); | |
2145 | |
2146 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
2147 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
2148 | |
2149 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
2150 | |
2151 if ( now_dur <= TRISTATE_THRESHOLD ) | |
2152 { | |
2153 /* interpret as 'skip to previous song' */ | |
2154 playlist_next(playlist_get_active()); | |
2155 } | |
2156 else | |
2157 { | |
2158 /* interpret as 'seek' */ | |
2159 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
2160 } | |
2161 | |
2162 seek_state = MAINWIN_SEEK_NIL; | |
2163 } | |
2164 | |
2165 void | |
2166 mainwin_play_pushed(void) | |
2167 { | |
2168 if (ab_position_a != -1) | |
2169 playback_seek(ab_position_a / 1000); | |
2170 if (playback_get_paused()) { | |
2171 playback_pause(); | |
2172 return; | |
2173 } | |
2174 | |
2175 if (playlist_get_length(playlist_get_active())) | |
2176 playback_initiate(); | |
2177 else | |
2178 mainwin_eject_pushed(); | |
2179 } | |
2180 | |
2181 void | |
2182 mainwin_stop_pushed(void) | |
2183 { | |
2184 ip_data.stop = TRUE; | |
2185 mainwin_clear_song_info(); | |
2186 playback_stop(); | |
2187 ip_data.stop = FALSE; | |
2188 } | |
2189 | |
2190 void | |
2191 mainwin_shuffle_pushed(gboolean toggled) | |
2192 { | |
2193 check_set( toggleaction_group_others , "playback shuffle" , toggled ); | |
2194 } | |
2195 | |
2196 void | |
2197 mainwin_repeat_pushed(gboolean toggled) | |
2198 { | |
2199 check_set( toggleaction_group_others , "playback repeat" , toggled ); | |
2200 } | |
2201 | |
2202 void | |
2203 mainwin_pl_pushed(gboolean toggled) | |
2204 { | |
2205 if (toggled) | |
2206 playlistwin_show(); | |
2207 else | |
2208 playlistwin_hide(); | |
2209 } | |
2210 | |
2211 gint | |
2212 mainwin_spos_frame_cb(gint pos) | |
2213 { | |
2214 if (mainwin_sposition) { | |
2215 if (pos < 6) | |
2216 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2217 17; | |
2218 else if (pos < 9) | |
2219 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2220 20; | |
2221 else | |
2222 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2223 23; | |
2224 } | |
2225 return 1; | |
2226 } | |
2227 | |
2228 void | |
2229 mainwin_spos_motion_cb(gint pos) | |
2230 { | |
2231 gint time; | |
2232 gchar *time_msg; | |
2233 Playlist *playlist = playlist_get_active(); | |
2234 | |
2235 pos--; | |
2236 | |
2237 time = ((playlist_get_current_length(playlist) / 1000) * pos) / 12; | |
2238 | |
2239 if (cfg.timer_mode == TIMER_REMAINING) { | |
2240 time = (playlist_get_current_length(playlist) / 1000) - time; | |
2241 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
2242 textbox_set_text(mainwin_stime_min, time_msg); | |
2243 g_free(time_msg); | |
2244 } | |
2245 else { | |
2246 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
2247 textbox_set_text(mainwin_stime_min, time_msg); | |
2248 g_free(time_msg); | |
2249 } | |
2250 | |
2251 time_msg = g_strdup_printf("%2.2d", time % 60); | |
2252 textbox_set_text(mainwin_stime_sec, time_msg); | |
2253 g_free(time_msg); | |
2254 } | |
2255 | |
2256 void | |
2257 mainwin_spos_release_cb(gint pos) | |
2258 { | |
2259 playback_seek(((playlist_get_current_length(playlist_get_active()) / 1000) * | |
2260 (pos - 1)) / 12); | |
2261 } | |
2262 | |
2263 void | |
2264 mainwin_position_motion_cb(gint pos) | |
2265 { | |
2266 gint length, time; | |
2267 gchar *seek_msg; | |
2268 | |
2269 length = playlist_get_current_length(playlist_get_active()) / 1000; | |
2270 time = (length * pos) / 219; | |
2271 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
2272 time / 60, time % 60, | |
2273 length / 60, length % 60, | |
2274 (length != 0) ? (time * 100) / length : 0); | |
2275 mainwin_lock_info_text(seek_msg); | |
2276 g_free(seek_msg); | |
2277 } | |
2278 | |
2279 void | |
2280 mainwin_position_release_cb(gint pos) | |
2281 { | |
2282 gint length, time; | |
2283 | |
2284 length = playlist_get_current_length(playlist_get_active()) / 1000; | |
2285 time = (length * pos) / 219; | |
2286 playback_seek(time); | |
2287 mainwin_release_info_text(); | |
2288 } | |
2289 | |
2290 gint | |
2291 mainwin_volume_frame_cb(gint pos) | |
2292 { | |
2293 return (gint) rint((pos / 52.0) * 28); | |
2294 } | |
2295 | |
2296 void | |
2297 mainwin_adjust_volume_motion(gint v) | |
2298 { | |
2299 gchar *volume_msg; | |
2300 | |
2301 setting_volume = TRUE; | |
2302 | |
2303 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2304 mainwin_lock_info_text(volume_msg); | |
2305 g_free(volume_msg); | |
2306 | |
2307 if (balance < 0) | |
2308 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
2309 else if (balance > 0) | |
2310 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
2311 else | |
2312 input_set_volume(v, v); | |
2313 } | |
2314 | |
2315 void | |
2316 mainwin_adjust_volume_release(void) | |
2317 { | |
2318 mainwin_release_info_text(); | |
2319 setting_volume = FALSE; | |
2320 read_volume(VOLUME_ADJUSTED); | |
2321 } | |
2322 | |
2323 void | |
2324 mainwin_adjust_balance_motion(gint b) | |
2325 { | |
2326 gchar *balance_msg; | |
2327 gint v, pvl, pvr; | |
2328 | |
2329 setting_volume = TRUE; | |
2330 balance = b; | |
2331 input_get_volume(&pvl, &pvr); | |
2332 v = MAX(pvl, pvr); | |
2333 if (b < 0) { | |
2334 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2335 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
2336 } | |
2337 else if (b == 0) { | |
2338 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
2339 input_set_volume(v, v); | |
2340 } | |
2341 else { /* b > 0 */ | |
2342 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2343 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
2344 } | |
2345 mainwin_lock_info_text(balance_msg); | |
2346 g_free(balance_msg); | |
2347 } | |
2348 | |
2349 void | |
2350 mainwin_adjust_balance_release(void) | |
2351 { | |
2352 mainwin_release_info_text(); | |
2353 setting_volume = FALSE; | |
2354 read_volume(VOLUME_ADJUSTED); | |
2355 } | |
2356 | |
2357 void | |
2358 mainwin_set_volume_slider(gint percent) | |
2359 { | |
2360 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
2361 } | |
2362 | |
2363 void | |
2364 mainwin_set_balance_slider(gint percent) | |
2365 { | |
2366 hslider_set_position(mainwin_balance, | |
2367 (gint) rint(((percent * 12) / 100.0) + 12)); | |
2368 } | |
2369 | |
2370 void | |
2371 mainwin_volume_motion_cb(gint pos) | |
2372 { | |
2373 gint vol = (pos * 100) / 51; | |
2374 mainwin_adjust_volume_motion(vol); | |
2375 equalizerwin_set_volume_slider(vol); | |
2376 } | |
2377 | |
2378 void | |
2379 mainwin_volume_release_cb(gint pos) | |
2380 { | |
2381 mainwin_adjust_volume_release(); | |
2382 } | |
2383 | |
2384 gint | |
2385 mainwin_balance_frame_cb(gint pos) | |
2386 { | |
2387 return ((abs(pos - 12) * 28) / 13); | |
2388 } | |
2389 | |
2390 void | |
2391 mainwin_balance_motion_cb(gint pos) | |
2392 { | |
2393 gint bal = ((pos - 12) * 100) / 12; | |
2394 mainwin_adjust_balance_motion(bal); | |
2395 equalizerwin_set_balance_slider(bal); | |
2396 } | |
2397 | |
2398 void | |
2399 mainwin_balance_release_cb(gint pos) | |
2400 { | |
2401 mainwin_adjust_volume_release(); | |
2402 } | |
2403 | |
2404 void | |
2405 mainwin_set_volume_diff(gint diff) | |
2406 { | |
2407 gint vl, vr, vol; | |
2408 | |
2409 input_get_volume(&vl, &vr); | |
2410 vol = MAX(vl, vr); | |
2411 vol = CLAMP(vol + diff, 0, 100); | |
2412 | |
2413 mainwin_adjust_volume_motion(vol); | |
2414 setting_volume = FALSE; | |
2415 mainwin_set_volume_slider(vol); | |
2416 equalizerwin_set_volume_slider(vol); | |
2417 read_volume(VOLUME_SET); | |
2418 } | |
2419 | |
2420 void | |
2421 mainwin_set_balance_diff(gint diff) | |
2422 { | |
2423 gint b; | |
2424 b = CLAMP(balance + diff, -100, 100); | |
2425 mainwin_adjust_balance_motion(b); | |
2426 setting_volume = FALSE; | |
2427 mainwin_set_balance_slider(b); | |
2428 equalizerwin_set_balance_slider(b); | |
2429 read_volume(VOLUME_SET); | |
2430 } | |
2431 | |
2432 void | |
2433 mainwin_show(gboolean show) | |
2434 { | |
2435 if (show) | |
2436 mainwin_real_show(); | |
2437 else | |
2438 mainwin_real_hide(); | |
2439 } | |
2440 | |
2441 void | |
2442 mainwin_real_show(void) | |
2443 { | |
2444 cfg.player_visible = TRUE; | |
2445 | |
2446 check_set( toggleaction_group_others , "show player" , TRUE ); | |
2447 | |
2448 if (cfg.player_shaded) | |
2449 vis_clear_data(active_vis); | |
2450 | |
2451 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
2452 mainwin_set_shape_mask(); | |
2453 | |
2454 if (cfg.show_wm_decorations) { | |
2455 if (!pposition_broken && cfg.player_x != -1 | |
2456 && cfg.save_window_position) | |
2457 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2458 | |
2459 gtk_widget_show(mainwin); | |
2460 | |
2461 if (pposition_broken && cfg.player_x != -1 | |
2462 && cfg.save_window_position) | |
2463 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2464 | |
2465 return; | |
2466 } | |
2467 | |
2354
fea1b8594cd8
[svn] - removed other obsolete (and annoying) gdk_window_set_hints calls
giacomo
parents:
2353
diff
changeset
|
2468 if (cfg.player_x != -1 && cfg.player_y != -1) |
fea1b8594cd8
[svn] - removed other obsolete (and annoying) gdk_window_set_hints calls
giacomo
parents:
2353
diff
changeset
|
2469 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); |
fea1b8594cd8
[svn] - removed other obsolete (and annoying) gdk_window_set_hints calls
giacomo
parents:
2353
diff
changeset
|
2470 |
2313 | 2471 gtk_widget_show_all(mainwin); |
2472 | |
2345
0fb47429ad7e
[svn] - in mainwin_real_show, do not return if a nullmask doesn't exist
giacomo
parents:
2339
diff
changeset
|
2473 if (nullmask) |
0fb47429ad7e
[svn] - in mainwin_real_show, do not return if a nullmask doesn't exist
giacomo
parents:
2339
diff
changeset
|
2474 { |
0fb47429ad7e
[svn] - in mainwin_real_show, do not return if a nullmask doesn't exist
giacomo
parents:
2339
diff
changeset
|
2475 g_object_unref(nullmask); |
0fb47429ad7e
[svn] - in mainwin_real_show, do not return if a nullmask doesn't exist
giacomo
parents:
2339
diff
changeset
|
2476 nullmask = NULL; |
0fb47429ad7e
[svn] - in mainwin_real_show, do not return if a nullmask doesn't exist
giacomo
parents:
2339
diff
changeset
|
2477 } |
2313 | 2478 |
2479 gtk_window_resize(GTK_WINDOW(mainwin), | |
2480 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : | |
2481 bmp_active_skin->properties.mainwin_width, | |
2482 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : | |
2483 bmp_active_skin->properties.mainwin_height); | |
2484 | |
2485 draw_main_window(TRUE); | |
2486 | |
2487 gtk_window_present(GTK_WINDOW(mainwin)); | |
2488 } | |
2489 | |
2490 void | |
2491 mainwin_real_hide(void) | |
2492 { | |
2493 GdkGC *gc; | |
2494 GdkColor pattern; | |
2495 | |
2496 check_set( toggleaction_group_others , "show player", FALSE); | |
2497 | |
2498 if (cfg.player_shaded) | |
2499 svis_clear_data(mainwin_svis); | |
2500 | |
2501 if (!cfg.show_wm_decorations) { | |
2502 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
2503 gc = gdk_gc_new(nullmask); | |
2504 pattern.pixel = 0; | |
2505 gdk_gc_set_foreground(gc, &pattern); | |
2506 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
2507 g_object_unref(gc); | |
2508 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
2509 } | |
2510 | |
2511 gtk_widget_hide(mainwin); | |
2512 | |
2513 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
2514 cfg.player_visible = FALSE; | |
2515 } | |
2516 | |
2517 | |
2518 void | |
2519 mainwin_set_stopaftersong(gboolean stop) | |
2520 { | |
2521 cfg.stopaftersong = stop; | |
2522 check_set(toggleaction_group_others, "stop after current song", cfg.stopaftersong); | |
2523 } | |
2524 | |
2525 | |
2526 static void | |
2527 mainwin_set_doublesize(gboolean doublesize) | |
2528 { | |
2529 gint height; | |
2530 | |
2531 if (cfg.player_shaded) | |
2532 height = MAINWIN_SHADED_HEIGHT; | |
2533 else | |
2534 height = bmp_active_skin->properties.mainwin_height; | |
2535 | |
2536 mainwin_set_shape_mask(); | |
2537 | |
2538 dock_window_resize(GTK_WINDOW(mainwin), cfg.player_shaded ? MAINWIN_SHADED_WIDTH : bmp_active_skin->properties.mainwin_width, | |
2539 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, | |
2540 bmp_active_skin->properties.mainwin_width * 2, bmp_active_skin->properties.mainwin_height * 2); | |
2541 | |
2542 if (cfg.doublesize) { | |
2543 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg_x2, 0); | |
2544 } | |
2545 else { | |
2546 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
2547 } | |
2548 | |
2549 draw_main_window(TRUE); | |
2550 vis_set_doublesize(mainwin_vis, doublesize); | |
2551 } | |
2552 | |
2553 void | |
2554 set_doublesize(gboolean doublesize) | |
2555 { | |
2556 cfg.doublesize = doublesize; | |
2557 | |
2558 mainwin_set_doublesize(doublesize); | |
2559 | |
2560 if (cfg.eq_doublesize_linked) | |
2561 equalizerwin_set_doublesize(doublesize); | |
2562 } | |
2563 | |
2564 | |
2565 | |
2566 void | |
2567 mainwin_general_menu_callback(gpointer data, | |
2568 guint action, | |
2569 GtkWidget * item) | |
2570 { | |
2571 Playlist *playlist = playlist_get_active(); | |
2572 | |
2573 switch (action) { | |
2574 case MAINWIN_GENERAL_PREFS: | |
2575 show_prefs_window(); | |
2576 break; | |
2577 case MAINWIN_GENERAL_ABOUT: | |
2578 show_about_window(); | |
2579 break; | |
2580 case MAINWIN_GENERAL_PLAYFILE: | |
2581 util_run_filebrowser(NO_PLAY_BUTTON); | |
2582 break; | |
2583 case MAINWIN_GENERAL_PLAYCD: | |
2584 play_medium(); | |
2585 break; | |
2586 case MAINWIN_GENERAL_ADDCD: | |
2587 add_medium(); | |
2588 break; | |
2589 case MAINWIN_GENERAL_PLAYLOCATION: | |
2590 mainwin_show_add_url_window(); | |
2591 break; | |
2592 case MAINWIN_GENERAL_FILEINFO: | |
2593 playlist_fileinfo_current(playlist); | |
2594 break; | |
2595 case MAINWIN_GENERAL_FOCUSPLWIN: | |
2596 gtk_window_present(GTK_WINDOW(playlistwin)); | |
2597 break; | |
2598 case MAINWIN_GENERAL_SHOWMWIN: | |
2599 mainwin_show(GTK_CHECK_MENU_ITEM(item)->active); | |
2600 break; | |
2601 case MAINWIN_GENERAL_SHOWPLWIN: | |
2602 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2603 playlistwin_show(); | |
2604 else | |
2605 playlistwin_hide(); | |
2606 break; | |
2607 case MAINWIN_GENERAL_SHOWEQWIN: | |
2608 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2609 equalizerwin_real_show(); | |
2610 else | |
2611 equalizerwin_real_hide(); | |
2612 break; | |
2613 case MAINWIN_GENERAL_PREV: | |
2614 playlist_prev(playlist); | |
2615 break; | |
2616 case MAINWIN_GENERAL_PLAY: | |
2617 mainwin_play_pushed(); | |
2618 break; | |
2619 case MAINWIN_GENERAL_PAUSE: | |
2620 playback_pause(); | |
2621 break; | |
2622 case MAINWIN_GENERAL_STOP: | |
2623 mainwin_stop_pushed(); | |
2624 break; | |
2625 case MAINWIN_GENERAL_NEXT: | |
2626 playlist_next(playlist); | |
2627 break; | |
2628 case MAINWIN_GENERAL_BACK5SEC: | |
2629 if (playback_get_playing() | |
2630 && playlist_get_current_length(playlist) != -1) | |
2631 playback_seek_relative(-5); | |
2632 break; | |
2633 case MAINWIN_GENERAL_FWD5SEC: | |
2634 if (playback_get_playing() | |
2635 && playlist_get_current_length(playlist) != -1) | |
2636 playback_seek_relative(5); | |
2637 break; | |
2638 case MAINWIN_GENERAL_START: | |
2639 playlist_set_position(playlist, 0); | |
2640 break; | |
2641 case MAINWIN_GENERAL_JTT: | |
2642 mainwin_jump_to_time(); | |
2643 break; | |
2644 case MAINWIN_GENERAL_JTF: | |
2645 mainwin_jump_to_file(); | |
2646 break; | |
2647 case MAINWIN_GENERAL_EXIT: | |
2648 mainwin_quit_cb(); | |
2649 break; | |
2650 case MAINWIN_GENERAL_SETAB: | |
2651 if (playlist_get_current_length(playlist) != -1) { | |
2652 if (ab_position_a == -1) { | |
2653 ab_position_a = playback_get_time(); | |
2654 ab_position_b = -1; | |
2655 mainwin_lock_info_text("LOOP-POINT A POSITION SET."); | |
2656 } else if (ab_position_b == -1) { | |
2657 int time = playback_get_time(); | |
2658 if (time > ab_position_a) | |
2659 ab_position_b = time; | |
2660 mainwin_release_info_text(); | |
2661 } else { | |
2662 ab_position_a = playback_get_time(); | |
2663 ab_position_b = -1; | |
2664 mainwin_lock_info_text("LOOP-POINT A POSITION RESET."); | |
2665 } | |
2666 } | |
2667 break; | |
2668 case MAINWIN_GENERAL_CLEARAB: | |
2669 if (playlist_get_current_length(playlist) != -1) { | |
2670 ab_position_a = ab_position_b = -1; | |
2671 mainwin_release_info_text(); | |
2672 } | |
2673 break; | |
2674 case MAINWIN_GENERAL_NEW_PL: | |
2675 { | |
2676 Playlist *new_pl = playlist_new(); | |
2677 playlist_add_playlist(new_pl); | |
2678 playlist_select_playlist(new_pl); | |
2679 } | |
2680 break; | |
2681 case MAINWIN_GENERAL_PREV_PL: | |
2682 playlist_select_prev(); | |
2683 break; | |
2684 case MAINWIN_GENERAL_NEXT_PL: | |
2685 playlist_select_next(); | |
2686 break; | |
2687 } | |
2688 } | |
2689 | |
2690 static void | |
2691 mainwin_mr_change(MenuRowItem i) | |
2692 { | |
2693 switch (i) { | |
2694 case MENUROW_NONE: | |
2695 mainwin_set_info_text(); | |
2696 break; | |
2697 case MENUROW_OPTIONS: | |
2698 mainwin_lock_info_text(_("OPTIONS MENU")); | |
2699 break; | |
2700 case MENUROW_ALWAYS: | |
2701 if (mainwin_menurow->mr_always_selected) | |
2702 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); | |
2703 else | |
2704 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
2705 break; | |
2706 case MENUROW_FILEINFOBOX: | |
2707 mainwin_lock_info_text(_("FILE INFO BOX")); | |
2708 break; | |
2709 case MENUROW_DOUBLESIZE: | |
2710 if (mainwin_menurow->mr_doublesize_selected) | |
2711 mainwin_lock_info_text(_("DISABLE DOUBLESIZE")); | |
2712 else | |
2713 mainwin_lock_info_text(_("ENABLE DOUBLESIZE")); | |
2714 break; | |
2715 case MENUROW_VISUALIZATION: | |
2716 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
2717 break; | |
2718 } | |
2719 } | |
2720 | |
2721 static void | |
2722 mainwin_mr_release(MenuRowItem i) | |
2723 { | |
2724 GdkModifierType modmask; | |
2725 gint x, y; | |
2726 | |
2727 switch (i) { | |
2728 case MENUROW_OPTIONS: | |
2729 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2730 ui_manager_popup_menu_show(GTK_MENU(mainwin_view_menu), x, y, 1, | |
2731 GDK_CURRENT_TIME); | |
2732 break; | |
2733 case MENUROW_ALWAYS: | |
2734 gtk_toggle_action_set_active( | |
2735 GTK_TOGGLE_ACTION(gtk_action_group_get_action( | |
2736 toggleaction_group_others , "view always on top" )) , | |
2737 mainwin_menurow->mr_always_selected ); | |
2738 break; | |
2739 case MENUROW_FILEINFOBOX: | |
2740 playlist_fileinfo_current(playlist_get_active()); | |
2741 break; | |
2742 case MENUROW_DOUBLESIZE: | |
2743 gtk_toggle_action_set_active( | |
2744 GTK_TOGGLE_ACTION(gtk_action_group_get_action( | |
2745 toggleaction_group_others , "view doublesize" )) , | |
2746 mainwin_menurow->mr_doublesize_selected ); | |
2747 break; | |
2748 case MENUROW_VISUALIZATION: | |
2749 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2750 ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu), x, y, 1, GDK_CURRENT_TIME); | |
2751 break; | |
2752 case MENUROW_NONE: | |
2753 break; | |
2754 } | |
2755 mainwin_release_info_text(); | |
2756 } | |
2757 | |
2758 static void | |
2759 run_no_audiocd_dialog(void) | |
2760 { | |
2761 const gchar *markup = | |
2762 N_("<b><big>No playable CD found.</big></b>\n\n" | |
2763 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
2764 | |
2765 GtkWidget *dialog = | |
2766 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2767 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2768 GTK_MESSAGE_ERROR, | |
2769 GTK_BUTTONS_OK, | |
2770 _(markup)); | |
2771 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2772 gtk_widget_destroy(dialog); | |
2773 } | |
2774 | |
2775 static void | |
2776 run_no_output_device_dialog(void) | |
2777 { | |
2778 const gchar *markup = | |
2779 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
2780 "Please check that:\n" | |
2781 "1. You have the correct output plugin selected.\n" | |
2782 "2. No other programs is blocking the soundcard.\n" | |
2783 "3. Your soundcard is configured properly.\n"); | |
2784 | |
2785 GtkWidget *dialog = | |
2786 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2787 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2788 GTK_MESSAGE_ERROR, | |
2789 GTK_BUTTONS_OK, | |
2790 _(markup)); | |
2791 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2792 gtk_widget_destroy(dialog); | |
2793 } | |
2794 | |
2795 | |
2796 void | |
2797 add_medium(void) | |
2798 { | |
2799 GList *list, *node; | |
2800 gchar *filename; | |
2801 gchar *path; | |
2802 ConfigDb *db; | |
2803 | |
2804 db = bmp_cfg_db_open(); | |
2805 | |
2806 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2807 bmp_cfg_db_close(db); | |
2808 | |
2809 if (!(list = input_scan_dir(path))) { | |
2810 run_no_audiocd_dialog(); | |
2811 return; | |
2812 } | |
2813 | |
2814 for (node = list; node; node = g_list_next(node)) { | |
2815 filename = g_build_filename(path, node->data, NULL); | |
2816 playlist_add(playlist_get_active(), filename); | |
2817 g_free(filename); | |
2818 g_free(node->data); | |
2819 } | |
2820 | |
2821 g_free(path); | |
2822 g_list_free(list); | |
2823 | |
2824 } | |
2825 | |
2826 void | |
2827 play_medium(void) | |
2828 { | |
2829 GList *list, *node; | |
2830 gchar *filename; | |
2831 gchar *path; | |
2832 ConfigDb *db; | |
2833 Playlist *playlist = playlist_get_active(); | |
2834 | |
2835 db = bmp_cfg_db_open(); | |
2836 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2837 bmp_cfg_db_close(db); | |
2838 | |
2839 if (!(list = input_scan_dir(path))) { | |
2840 run_no_audiocd_dialog(); | |
2841 return; | |
2842 } | |
2843 | |
2844 playlist_clear(playlist); | |
2845 | |
2846 for (node = list; node; node = g_list_next(node)) { | |
2847 filename = g_build_filename(path, node->data, NULL); | |
2848 playlist_add(playlist, filename); | |
2849 g_free(filename); | |
2850 g_free(node->data); | |
2851 } | |
2852 | |
2853 g_free(path); | |
2854 g_list_free(list); | |
2855 | |
2856 playlist_set_position(playlist, 0); | |
2857 playback_initiate(); | |
2858 } | |
2859 | |
2860 void | |
2861 read_volume(gint when) | |
2862 { | |
2863 static gint pvl = 0, pvr = 0; | |
2864 static gint times = VOLSET_DISP_TIMES; | |
2865 static gboolean changing = FALSE; | |
2866 | |
2867 gint vl, vr, b, v; | |
2868 | |
2869 input_get_volume(&vl, &vr); | |
2870 | |
2871 switch (when) { | |
2872 case VOLSET_STARTUP: | |
2873 vl = CLAMP(vl, 0, 100); | |
2874 vr = CLAMP(vr, 0, 100); | |
2875 pvl = vl; | |
2876 pvr = vr; | |
2877 v = MAX(vl, vr); | |
2878 if (vl > vr) | |
2879 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2880 else if (vl < vr) | |
2881 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2882 else | |
2883 b = 0; | |
2884 | |
2885 balance = b; | |
2886 mainwin_set_volume_slider(v); | |
2887 equalizerwin_set_volume_slider(v); | |
2888 mainwin_set_balance_slider(b); | |
2889 equalizerwin_set_balance_slider(b); | |
2890 return; | |
2891 | |
2892 case VOLSET_UPDATE: | |
2893 if (vl == -1 || vr == -1) | |
2894 return; | |
2895 | |
2896 if (setting_volume) { | |
2897 pvl = vl; | |
2898 pvr = vr; | |
2899 return; | |
2900 } | |
2901 | |
2902 if (pvr == vr && pvl == vl && changing) { | |
2903 if (times < VOLSET_DISP_TIMES) | |
2904 times++; | |
2905 else { | |
2906 mainwin_release_info_text(); | |
2907 changing = FALSE; | |
2908 } | |
2909 } | |
2910 else if (pvr != vr || pvl != vl) { | |
2911 gchar *tmp; | |
2912 | |
2913 v = MAX(vl, vr); | |
2914 if (vl > vr) | |
2915 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2916 else if (vl < vr) | |
2917 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2918 else | |
2919 b = 0; | |
2920 | |
2921 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
2922 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2923 else { | |
2924 if (vl > vr) { | |
2925 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2926 } | |
2927 else if (vr == vl) | |
2928 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
2929 else { /* (vl < vr) */ | |
2930 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2931 } | |
2932 } | |
2933 mainwin_lock_info_text(tmp); | |
2934 g_free(tmp); | |
2935 | |
2936 pvr = vr; | |
2937 pvl = vl; | |
2938 times = 0; | |
2939 changing = TRUE; | |
2940 mainwin_set_volume_slider(v); | |
2941 equalizerwin_set_volume_slider(v); | |
2942 | |
2943 /* Don't change the balance slider if the volume has been | |
2944 * set to zero. The balance can be anything, and our best | |
2945 * guess is what is was before. */ | |
2946 if (v > 0) { | |
2947 balance = b; | |
2948 mainwin_set_balance_slider(b); | |
2949 equalizerwin_set_balance_slider(b); | |
2950 } | |
2951 } | |
2952 break; | |
2953 | |
2954 case VOLUME_ADJUSTED: | |
2955 pvl = vl; | |
2956 pvr = vr; | |
2957 break; | |
2958 | |
2959 case VOLUME_SET: | |
2960 times = 0; | |
2961 changing = TRUE; | |
2962 pvl = vl; | |
2963 pvr = vr; | |
2964 break; | |
2965 } | |
2966 } | |
2967 | |
2968 | |
2969 /* TODO: HAL! */ | |
2970 gboolean | |
2971 can_play_cd(void) | |
2972 { | |
2973 GList *ilist; | |
2974 | |
2975 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
2976 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
2977 | |
2978 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
2979 PLUGIN_FILENAME("cdaudio"))) { | |
2980 return TRUE; | |
2981 } | |
2982 } | |
2983 | |
2984 return FALSE; | |
2985 } | |
2986 | |
2987 | |
2988 static void | |
2989 set_timer_mode(TimerMode mode) | |
2990 { | |
2991 if (mode == TIMER_ELAPSED) | |
2992 check_set(radioaction_group_viewtime, "view time elapsed", TRUE); | |
2993 else | |
2994 check_set(radioaction_group_viewtime, "view time remaining", TRUE); | |
2995 } | |
2996 | |
2997 static void | |
2998 set_timer_mode_menu_cb(TimerMode mode) | |
2999 { | |
3000 cfg.timer_mode = mode; | |
3001 } | |
3002 | |
3003 static void | |
3004 mainwin_playlist_prev(void) | |
3005 { | |
3006 playlist_prev(playlist_get_active()); | |
3007 } | |
3008 | |
3009 static void | |
3010 mainwin_playlist_next(void) | |
3011 { | |
3012 playlist_next(playlist_get_active()); | |
3013 } | |
3014 | |
3015 void | |
3016 mainwin_setup_menus(void) | |
3017 { | |
3018 set_timer_mode(cfg.timer_mode); | |
3019 | |
3020 /* View menu */ | |
3021 | |
3022 check_set(toggleaction_group_others, "view always on top", cfg.always_on_top); | |
3023 check_set(toggleaction_group_others, "view put on all workspaces", cfg.sticky); | |
3024 check_set(toggleaction_group_others, "roll up player", cfg.player_shaded); | |
3025 check_set(toggleaction_group_others, "roll up playlist editor", cfg.playlist_shaded); | |
3026 check_set(toggleaction_group_others, "roll up equalizer", cfg.equalizer_shaded); | |
3027 check_set(toggleaction_group_others, "view easy move", cfg.easy_move); | |
3028 check_set(toggleaction_group_others, "view doublesize", cfg.doublesize); | |
3029 | |
3030 /* Songname menu */ | |
3031 | |
3032 check_set(toggleaction_group_others, "autoscroll songname", cfg.autoscroll); | |
3033 check_set(toggleaction_group_others, "stop after current song", cfg.stopaftersong); | |
3034 | |
3035 /* Playback menu */ | |
3036 | |
3037 check_set(toggleaction_group_others, "playback repeat", cfg.repeat); | |
3038 check_set(toggleaction_group_others, "playback shuffle", cfg.shuffle); | |
3039 check_set(toggleaction_group_others, "playback no playlist advance", cfg.no_playlist_advance); | |
3040 | |
3041 /* Visualization menu */ | |
3042 | |
3043 switch ( cfg.vis_type ) | |
3044 { | |
3045 case VIS_ANALYZER: | |
3046 check_set(radioaction_group_vismode, "vismode analyzer", TRUE); | |
3047 break; | |
3048 case VIS_SCOPE: | |
3049 check_set(radioaction_group_vismode, "vismode scope", TRUE); | |
3050 break; | |
3051 case VIS_VOICEPRINT: | |
3052 check_set(radioaction_group_vismode, "vismode voiceprint", TRUE); | |
3053 break; | |
3054 case VIS_OFF: | |
3055 default: | |
3056 check_set(radioaction_group_vismode, "vismode off", TRUE); | |
3057 break; | |
3058 } | |
3059 | |
3060 switch ( cfg.analyzer_mode ) | |
3061 { | |
3062 case ANALYZER_FIRE: | |
3063 check_set(radioaction_group_anamode, "anamode fire", TRUE); | |
3064 break; | |
3065 case ANALYZER_VLINES: | |
3066 check_set(radioaction_group_anamode, "anamode vertical lines", TRUE); | |
3067 break; | |
3068 case ANALYZER_NORMAL: | |
3069 default: | |
3070 check_set(radioaction_group_anamode, "anamode normal", TRUE); | |
3071 break; | |
3072 } | |
3073 | |
3074 switch ( cfg.analyzer_type ) | |
3075 { | |
3076 case ANALYZER_BARS: | |
3077 check_set(radioaction_group_anatype, "anatype bars", TRUE); | |
3078 break; | |
3079 case ANALYZER_LINES: | |
3080 default: | |
3081 check_set(radioaction_group_anatype, "anatype lines", TRUE); | |
3082 break; | |
3083 } | |
3084 | |
3085 check_set(toggleaction_group_others, "anamode peaks", cfg.analyzer_peaks ); | |
3086 | |
3087 switch ( cfg.scope_mode ) | |
3088 { | |
3089 case SCOPE_LINE: | |
3090 check_set(radioaction_group_scomode, "scomode line", TRUE); | |
3091 break; | |
3092 case SCOPE_SOLID: | |
3093 check_set(radioaction_group_scomode, "scomode solid", TRUE); | |
3094 break; | |
3095 case SCOPE_DOT: | |
3096 default: | |
3097 check_set(radioaction_group_scomode, "scomode dot", TRUE); | |
3098 break; | |
3099 } | |
3100 | |
3101 switch ( cfg.voiceprint_mode ) | |
3102 { | |
3103 case VOICEPRINT_FIRE: | |
3104 check_set(radioaction_group_vprmode, "vprmode fire", TRUE); | |
3105 break; | |
3106 case VOICEPRINT_ICE: | |
3107 check_set(radioaction_group_vprmode, "vprmode ice", TRUE); | |
3108 break; | |
3109 case VOICEPRINT_NORMAL: | |
3110 default: | |
3111 check_set(radioaction_group_vprmode, "vprmode normal", TRUE); | |
3112 break; | |
3113 } | |
3114 | |
3115 switch ( cfg.vu_mode ) | |
3116 { | |
3117 case VU_SMOOTH: | |
3118 check_set(radioaction_group_wshmode, "wshmode smooth", TRUE); | |
3119 break; | |
3120 case VU_NORMAL: | |
3121 default: | |
3122 check_set(radioaction_group_wshmode, "wshmode normal", TRUE); | |
3123 break; | |
3124 } | |
3125 | |
3126 switch ( cfg.vis_refresh ) | |
3127 { | |
3128 case REFRESH_HALF: | |
3129 check_set(radioaction_group_refrate, "refrate half", TRUE); | |
3130 break; | |
3131 case REFRESH_QUARTER: | |
3132 check_set(radioaction_group_refrate, "refrate quarter", TRUE); | |
3133 break; | |
3134 case REFRESH_EIGTH: | |
3135 check_set(radioaction_group_refrate, "refrate eighth", TRUE); | |
3136 break; | |
3137 case REFRESH_FULL: | |
3138 default: | |
3139 check_set(radioaction_group_refrate, "refrate full", TRUE); | |
3140 break; | |
3141 } | |
3142 | |
3143 switch ( cfg.analyzer_falloff ) | |
3144 { | |
3145 case FALLOFF_SLOW: | |
3146 check_set(radioaction_group_anafoff, "anafoff slow", TRUE); | |
3147 break; | |
3148 case FALLOFF_MEDIUM: | |
3149 check_set(radioaction_group_anafoff, "anafoff medium", TRUE); | |
3150 break; | |
3151 case FALLOFF_FAST: | |
3152 check_set(radioaction_group_anafoff, "anafoff fast", TRUE); | |
3153 break; | |
3154 case FALLOFF_FASTEST: | |
3155 check_set(radioaction_group_anafoff, "anafoff fastest", TRUE); | |
3156 break; | |
3157 case FALLOFF_SLOWEST: | |
3158 default: | |
3159 check_set(radioaction_group_anafoff, "anafoff slowest", TRUE); | |
3160 break; | |
3161 } | |
3162 | |
3163 switch ( cfg.peaks_falloff ) | |
3164 { | |
3165 case FALLOFF_SLOW: | |
3166 check_set(radioaction_group_peafoff, "peafoff slow", TRUE); | |
3167 break; | |
3168 case FALLOFF_MEDIUM: | |
3169 check_set(radioaction_group_peafoff, "peafoff medium", TRUE); | |
3170 break; | |
3171 case FALLOFF_FAST: | |
3172 check_set(radioaction_group_peafoff, "peafoff fast", TRUE); | |
3173 break; | |
3174 case FALLOFF_FASTEST: | |
3175 check_set(radioaction_group_peafoff, "peafoff fastest", TRUE); | |
3176 break; | |
3177 case FALLOFF_SLOWEST: | |
3178 default: | |
3179 check_set(radioaction_group_peafoff, "peafoff slowest", TRUE); | |
3180 break; | |
3181 } | |
3182 | |
3183 } | |
3184 | |
3185 static void | |
3186 mainwin_create_widgets(void) | |
3187 { | |
3188 mainwin_menubtn = | |
3189 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
3190 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
3191 mainwin_menubtn->pb_allow_draw = FALSE; | |
3192 mainwin_minimize = | |
3193 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
3194 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
3195 mainwin_minimize->pb_allow_draw = FALSE; | |
3196 mainwin_shade = | |
3197 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
3198 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
3199 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
3200 SKIN_TITLEBAR); | |
3201 mainwin_shade->pb_allow_draw = FALSE; | |
3202 mainwin_close = | |
3203 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
3204 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
3205 mainwin_close->pb_allow_draw = FALSE; | |
3206 | |
3207 mainwin_rew = | |
3208 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 88, 23, | |
3209 18, 0, 0, 0, 18, mainwin_rev_pushed, mainwin_rev_release, | |
3210 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
3211 mainwin_play = | |
3212 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
3213 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
3214 mainwin_pause = | |
3215 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
3216 18, 46, 0, 46, 18, playback_pause, SKIN_CBUTTONS); | |
3217 mainwin_stop = | |
3218 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
3219 18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS); | |
3220 #if 0 | |
3221 mainwin_fwd = | |
3222 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3223 18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS); | |
3224 #endif | |
3225 mainwin_fwd = | |
3226 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3227 18, 92, 0, 92, 18, mainwin_fwd_pushed, mainwin_fwd_release, | |
3228 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
3229 | |
3230 mainwin_eject = | |
3231 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
3232 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
3233 SKIN_CBUTTONS); | |
3234 | |
3235 mainwin_srew = | |
3236 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
3237 7, mainwin_playlist_prev); | |
3238 mainwin_splay = | |
3239 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
3240 7, mainwin_play_pushed); | |
3241 mainwin_spause = | |
3242 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
3243 7, playback_pause); | |
3244 mainwin_sstop = | |
3245 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
3246 7, mainwin_stop_pushed); | |
3247 mainwin_sfwd = | |
3248 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
3249 7, mainwin_playlist_next); | |
3250 mainwin_seject = | |
3251 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
3252 7, mainwin_eject_pushed); | |
3253 | |
3254 mainwin_shuffle = | |
3255 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
3256 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
3257 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
3258 | |
3259 mainwin_repeat = | |
3260 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
3261 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
3262 mainwin_repeat_pushed, SKIN_SHUFREP); | |
3263 | |
3264 mainwin_eq = | |
3265 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
3266 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
3267 SKIN_SHUFREP); | |
3268 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
3269 mainwin_pl = | |
3270 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
3271 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
3272 mainwin_pl_pushed, SKIN_SHUFREP); | |
3273 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
3274 | |
3275 mainwin_info = | |
3276 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
3277 153, 1, SKIN_TEXT); | |
3278 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
3279 textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); | |
3280 | |
3281 mainwin_othertext = | |
3282 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 43, | |
3283 153, 1, SKIN_TEXT); | |
3284 | |
3285 mainwin_rate_text = | |
3286 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
3287 0, SKIN_TEXT); | |
3288 mainwin_freq_text = | |
3289 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
3290 0, SKIN_TEXT); | |
3291 | |
3292 mainwin_menurow = | |
3293 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
3294 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
3295 SKIN_TITLEBAR); | |
3296 mainwin_menurow->mr_doublesize_selected = cfg.doublesize; | |
3297 mainwin_menurow->mr_always_selected = cfg.always_on_top; | |
3298 | |
3299 mainwin_volume = | |
3300 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
3301 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
3302 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
3303 mainwin_volume_release_cb, SKIN_VOLUME); | |
3304 mainwin_balance = | |
3305 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
3306 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
3307 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
3308 mainwin_balance_release_cb, SKIN_BALANCE); | |
3309 | |
3310 mainwin_monostereo = | |
3311 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
3312 SKIN_MONOSTEREO); | |
3313 | |
3314 mainwin_playstatus = | |
3315 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
3316 | |
3317 mainwin_minus_num = | |
3318 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
3319 SKIN_NUMBERS); | |
3320 widget_hide(WIDGET(mainwin_minus_num)); | |
3321 mainwin_10min_num = | |
3322 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
3323 SKIN_NUMBERS); | |
3324 widget_hide(WIDGET(mainwin_10min_num)); | |
3325 | |
3326 mainwin_min_num = | |
3327 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
3328 SKIN_NUMBERS); | |
3329 widget_hide(WIDGET(mainwin_min_num)); | |
3330 | |
3331 mainwin_10sec_num = | |
3332 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
3333 SKIN_NUMBERS); | |
3334 widget_hide(WIDGET(mainwin_10sec_num)); | |
3335 | |
3336 mainwin_sec_num = | |
3337 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
3338 SKIN_NUMBERS); | |
3339 widget_hide(WIDGET(mainwin_sec_num)); | |
3340 | |
3341 mainwin_about = | |
3342 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
3343 25, show_about_window); | |
3344 | |
3345 mainwin_vis = | |
3346 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
3347 24, 43, 76, cfg.doublesize); | |
3348 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); | |
3349 active_vis = mainwin_vis; | |
3350 | |
3351 mainwin_position = | |
3352 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
3353 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
3354 mainwin_position_motion_cb, | |
3355 mainwin_position_release_cb, SKIN_POSBAR); | |
3356 widget_hide(WIDGET(mainwin_position)); | |
3357 | |
3358 mainwin_sposition = | |
3359 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
3360 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
3361 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
3362 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
3363 widget_hide(WIDGET(mainwin_sposition)); | |
3364 | |
3365 mainwin_stime_min = | |
3366 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
3367 FALSE, SKIN_TEXT); | |
3368 mainwin_stime_sec = | |
3369 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
3370 FALSE, SKIN_TEXT); | |
3371 | |
3372 if (!cfg.player_shaded) { | |
3373 widget_hide(WIDGET(mainwin_svis)); | |
3374 widget_hide(WIDGET(mainwin_srew)); | |
3375 widget_hide(WIDGET(mainwin_splay)); | |
3376 widget_hide(WIDGET(mainwin_spause)); | |
3377 widget_hide(WIDGET(mainwin_sstop)); | |
3378 widget_hide(WIDGET(mainwin_sfwd)); | |
3379 widget_hide(WIDGET(mainwin_seject)); | |
3380 widget_hide(WIDGET(mainwin_stime_min)); | |
3381 widget_hide(WIDGET(mainwin_stime_sec)); | |
3382 } | |
3383 | |
3384 err = gtk_message_dialog_new(GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, | |
3385 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error in Audacious.")); | |
3386 | |
3387 | |
3388 gtk_window_set_position(GTK_WINDOW(err), GTK_WIN_POS_CENTER); | |
3389 /* Dang well better set an error message or you'll see this */ | |
3390 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), | |
3391 "Boo! Bad stuff! Booga Booga!"); | |
3392 | |
3393 } | |
3394 | |
3395 static void | |
3396 mainwin_create_window(void) | |
3397 { | |
3398 gint width, height; | |
3399 | |
3400 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3401 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
3402 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
3403 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
3404 | |
3405 width = cfg.player_shaded ? MAINWIN_SHADED_WIDTH : bmp_active_skin->properties.mainwin_width; | |
3406 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height; | |
3407 | |
3408 if (cfg.doublesize) { | |
3409 width *= 2; | |
3410 height *= 2; | |
3411 } | |
3412 | |
3413 gtk_widget_set_size_request(mainwin, width, height); | |
3414 gtk_widget_set_app_paintable(mainwin, TRUE); | |
3415 | |
3416 dock_window_list = dock_window_set_decorated(dock_window_list, | |
3417 GTK_WINDOW(mainwin), | |
3418 cfg.show_wm_decorations); | |
3419 | |
3420 if (cfg.player_x != -1 && cfg.save_window_position) | |
3421 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
3422 | |
3423 gtk_widget_add_events(mainwin, | |
3424 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
3425 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
3426 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
3427 GDK_VISIBILITY_NOTIFY_MASK); | |
3428 gtk_widget_realize(mainwin); | |
3429 | |
3430 util_set_cursor(mainwin); | |
3431 | |
3432 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
3433 g_signal_connect(mainwin, "button_press_event", | |
3434 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
3435 g_signal_connect(mainwin, "scroll_event", | |
3436 G_CALLBACK(mainwin_scrolled), NULL); | |
3437 g_signal_connect(mainwin, "button_release_event", | |
3438 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
3439 g_signal_connect(mainwin, "motion_notify_event", | |
3440 G_CALLBACK(mainwin_motion), NULL); | |
3441 g_signal_connect_after(mainwin, "focus_in_event", | |
3442 G_CALLBACK(mainwin_focus_in), NULL); | |
3443 g_signal_connect_after(mainwin, "focus_out_event", | |
3444 G_CALLBACK(mainwin_focus_out), NULL); | |
3445 g_signal_connect(mainwin, "configure_event", | |
3446 G_CALLBACK(mainwin_configure), NULL); | |
3447 g_signal_connect(mainwin, "style_set", | |
3448 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
3449 | |
3450 bmp_drag_dest_set(mainwin); | |
3451 | |
3452 g_signal_connect(mainwin, "key_press_event", | |
3453 G_CALLBACK(mainwin_keypress), NULL); | |
3454 } | |
3455 | |
3456 void | |
3457 mainwin_create(void) | |
3458 { | |
3459 mainwin_create_window(); | |
3460 | |
3461 gtk_window_add_accel_group( GTK_WINDOW(mainwin) , ui_manager_get_accel_group() ); | |
3462 | |
3463 mainwin_gc = gdk_gc_new(mainwin->window); | |
3464 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
3465 bmp_active_skin->properties.mainwin_width, | |
3466 bmp_active_skin->properties.mainwin_height, -1); | |
3467 mainwin_bg_x2 = gdk_pixmap_new(mainwin->window, | |
3468 bmp_active_skin->properties.mainwin_width * 2, | |
3469 bmp_active_skin->properties.mainwin_height * 2, -1); | |
3470 mainwin_set_back_pixmap(); | |
3471 mainwin_create_widgets(); | |
3472 | |
3473 vis_set_window(mainwin_vis, mainwin->window); | |
3474 } | |
3475 | |
3476 void | |
3477 mainwin_attach_idle_func(void) | |
3478 { | |
3479 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
3480 mainwin_idle_func, NULL); | |
3481 } | |
3482 | |
3483 static void | |
3484 idle_func_update_song_info(gint time) | |
3485 { | |
3486 gint length, t; | |
3487 gchar stime_prefix; | |
3488 | |
3489 if (ab_position_a != -1 && ab_position_b != -1 && time > ab_position_b) | |
3490 playback_seek(ab_position_a/1000); | |
3491 | |
3492 length = playlist_get_current_length(playlist_get_active()); | |
3493 if (playback_get_playing()) | |
3494 playlistwin_set_time(time, length, cfg.timer_mode); | |
3495 else | |
3496 playlistwin_hide_timer(); | |
3497 input_update_vis(time); | |
3498 | |
3499 if (cfg.timer_mode == TIMER_REMAINING) { | |
3500 if (length != -1) { | |
3501 number_set_number(mainwin_minus_num, 11); | |
3502 t = length - time; | |
3503 stime_prefix = '-'; | |
3504 } | |
3505 else { | |
3506 number_set_number(mainwin_minus_num, 10); | |
3507 t = time; | |
3508 stime_prefix = ' '; | |
3509 } | |
3510 } | |
3511 else { | |
3512 number_set_number(mainwin_minus_num, 10); | |
3513 t = time; | |
3514 stime_prefix = ' '; | |
3515 } | |
3516 t /= 1000; | |
3517 | |
3518 /* Show the time in the format HH:MM when we have more than 100 | |
3519 * minutes. */ | |
3520 if (t >= 100 * 60) | |
3521 t /= 60; | |
3522 number_set_number(mainwin_10min_num, t / 600); | |
3523 number_set_number(mainwin_min_num, (t / 60) % 10); | |
3524 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
3525 number_set_number(mainwin_sec_num, t % 10); | |
3526 | |
3527 if (!mainwin_sposition->hs_pressed) { | |
3528 gchar *time_str; | |
3529 | |
3530 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
3531 textbox_set_text(mainwin_stime_min, time_str); | |
3532 g_free(time_str); | |
3533 | |
3534 time_str = g_strdup_printf("%2.2d", t % 60); | |
3535 textbox_set_text(mainwin_stime_sec, time_str); | |
3536 g_free(time_str); | |
3537 } | |
3538 | |
3539 time /= 1000; | |
3540 length /= 1000; | |
3541 if (length > 0) { | |
3542 if (time > length) { | |
3543 hslider_set_position(mainwin_position, 219); | |
3544 hslider_set_position(mainwin_sposition, 13); | |
3545 } | |
3546 /* update the slider position ONLY if there is not a seek in progress */ | |
3547 else if (seek_state == MAINWIN_SEEK_NIL) { | |
3548 hslider_set_position(mainwin_position, (time * 219) / length); | |
3549 hslider_set_position(mainwin_sposition, | |
3550 ((time * 12) / length) + 1); | |
3551 } | |
3552 } | |
3553 else { | |
3554 hslider_set_position(mainwin_position, 0); | |
3555 hslider_set_position(mainwin_sposition, 1); | |
3556 } | |
3557 } | |
3558 | |
3559 static gboolean | |
3560 mainwin_idle_func(gpointer data) | |
3561 { | |
3562 static gint count = 0; | |
3563 gint time = 0; | |
3564 | |
3565 /* run audcore events, then run our own. --nenolod */ | |
3566 switch((time = audcore_generic_events())) | |
3567 { | |
3568 case -2: | |
3569 /* no usable output device */ | |
3570 GDK_THREADS_ENTER(); | |
3571 run_no_output_device_dialog(); | |
3572 mainwin_stop_pushed(); | |
3573 GDK_THREADS_LEAVE(); | |
3574 ev_waiting = FALSE; | |
3575 break; | |
3576 | |
3577 default: | |
3578 idle_func_update_song_info(time); | |
3579 /* nothing at this time */ | |
3580 } | |
3581 | |
3582 GDK_THREADS_ENTER(); | |
3583 | |
3584 if (playback_get_playing()) | |
3585 vis_playback_start(); | |
3586 else { | |
3587 vis_playback_stop(); | |
3588 ab_position_a = ab_position_b = -1; | |
3589 } | |
3590 | |
3591 draw_main_window(mainwin_force_redraw); | |
3592 | |
3593 if (!count) { | |
3594 read_volume(VOLSET_UPDATE); | |
3595 count = 10; | |
3596 } | |
3597 else | |
3598 count--; | |
3599 | |
3600 mainwin_force_redraw = FALSE; | |
3601 draw_equalizer_window(FALSE); | |
3602 draw_playlist_window(FALSE); | |
3603 | |
3604 if (mainwin_title_text) { | |
3605 G_LOCK(mainwin_title); | |
3606 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
3607 g_free(mainwin_title_text); | |
3608 mainwin_title_text = NULL; | |
3609 G_UNLOCK(mainwin_title); | |
3610 | |
3611 mainwin_set_info_text(); | |
3612 playlistwin_update_list(playlist_get_active()); | |
3613 } | |
3614 | |
3615 /* tristate buttons seek */ | |
3616 if ( seek_state != MAINWIN_SEEK_NIL ) | |
3617 { | |
3618 GTimeVal now_time; | |
3619 GTimeVal delta_time; | |
3620 gulong now_dur; | |
3621 g_get_current_time(&now_time); | |
3622 | |
3623 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
3624 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
3625 | |
3626 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
3627 | |
3628 if ( now_dur > TRISTATE_THRESHOLD ) | |
3629 { | |
3630 gint np; | |
3631 if (seek_state == MAINWIN_SEEK_REV) | |
3632 np = seek_initial_pos - labs((gulong)(now_dur/100)); /* seek back */ | |
3633 else | |
3634 np = seek_initial_pos + labs((gulong)(now_dur/100)); /* seek forward */ | |
3635 | |
3636 /* boundaries check */ | |
3637 if (np < 0 ) | |
3638 np = 0; | |
3639 else if ( np > 219 ) | |
3640 np = 219; | |
3641 | |
3642 hslider_set_position( mainwin_position , np ); | |
3643 mainwin_position_motion_cb( np ); | |
3644 } | |
3645 } | |
3646 | |
3647 GDK_THREADS_LEAVE(); | |
3648 | |
3649 /* | |
3650 if (seek_state == MAINWIN_SEEK_REV) | |
3651 playback_seek(CLAMP(playback_get_time() - 1000, 0, | |
3652 playlist_get_current_length()) / 1000); | |
3653 else if (seek_state == MAINWIN_SEEK_FWD) | |
3654 playback_seek(CLAMP(playback_get_time() + 1000, 0, | |
3655 playlist_get_current_length()) / 1000); | |
3656 */ | |
3657 | |
3658 return TRUE; | |
3659 } | |
3660 | |
3661 | |
2353
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3662 void |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3663 audacious_menu_main_show( gint x , gint y , guint button , guint time ) |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3664 { |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3665 /* convenience function that shows the main popup menu wherever requested */ |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3666 ui_manager_popup_menu_show( GTK_MENU(mainwin_general_menu), |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3667 x , y , button , time ); |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3668 return; |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3669 } |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3670 |
0fb258122933
[svn] - added audacious_menu_main_show(x,y,button,time) in util.h, convenience function to display the audacious main popup menu
giacomo
parents:
2345
diff
changeset
|
3671 |
2313 | 3672 /* toggleactionentries actions */ |
3673 | |
3674 void | |
3675 action_anamode_peaks( GtkToggleAction * action ) | |
3676 { | |
3677 cfg.analyzer_peaks = gtk_toggle_action_get_active( action ); | |
3678 } | |
3679 | |
3680 void | |
3681 action_autoscroll_songname( GtkToggleAction * action ) | |
3682 { | |
3683 mainwin_set_title_scroll(gtk_toggle_action_get_active(action)); | |
3684 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
3685 } | |
3686 | |
3687 void | |
3688 action_playback_noplaylistadvance( GtkToggleAction * action ) | |
3689 { | |
3690 cfg.no_playlist_advance = gtk_toggle_action_get_active( action ); | |
3691 } | |
3692 | |
3693 void | |
3694 action_playback_repeat( GtkToggleAction * action ) | |
3695 { | |
3696 cfg.repeat = gtk_toggle_action_get_active( action ); | |
3697 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
3698 } | |
3699 | |
3700 void | |
3701 action_playback_shuffle( GtkToggleAction * action ) | |
3702 { | |
3703 cfg.shuffle = gtk_toggle_action_get_active( action ); | |
3704 playlist_set_shuffle(cfg.shuffle); | |
3705 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
3706 } | |
3707 | |
3708 void | |
3709 action_stop_after_current_song( GtkToggleAction * action ) | |
3710 { | |
3711 cfg.stopaftersong = gtk_toggle_action_get_active( action ); | |
3712 } | |
3713 | |
3714 void | |
3715 action_view_always_on_top( GtkToggleAction * action ) | |
3716 { | |
3717 mainwin_menurow->mr_always_selected = gtk_toggle_action_get_active( action ); | |
3718 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
3719 widget_draw(WIDGET(mainwin_menurow)); | |
3720 | |
3721 if (starting_up == FALSE) | |
3722 hint_set_always(cfg.always_on_top); | |
3723 } | |
3724 | |
3725 void | |
3726 action_view_doublesize( GtkToggleAction * action ) | |
3727 { | |
3728 mainwin_menurow->mr_doublesize_selected = gtk_toggle_action_get_active( action ); | |
3729 widget_draw(WIDGET(mainwin_menurow)); | |
3730 set_doublesize(mainwin_menurow->mr_doublesize_selected); | |
3731 gdk_flush(); | |
3732 } | |
3733 | |
3734 void | |
3735 action_view_easymove( GtkToggleAction * action ) | |
3736 { | |
3737 cfg.easy_move = gtk_toggle_action_get_active( action ); | |
3738 } | |
3739 | |
3740 void | |
3741 action_view_on_all_workspaces( GtkToggleAction * action ) | |
3742 { | |
3743 cfg.sticky = gtk_toggle_action_get_active( action ); | |
3744 hint_set_sticky(cfg.sticky); | |
3745 } | |
3746 | |
3747 void | |
3748 action_roll_up_equalizer( GtkToggleAction * action ) | |
3749 { | |
3750 equalizerwin_set_shade_menu_cb(gtk_toggle_action_get_active(action)); | |
3751 } | |
3752 | |
3753 void | |
3754 action_roll_up_player( GtkToggleAction * action ) | |
3755 { | |
3756 mainwin_set_shade_menu_cb(gtk_toggle_action_get_active(action)); | |
3757 } | |
3758 | |
3759 void | |
3760 action_roll_up_playlist_editor( GtkToggleAction * action ) | |
3761 { | |
3762 playlistwin_set_shade(gtk_toggle_action_get_active(action)); | |
3763 } | |
3764 | |
3765 void | |
3766 action_show_equalizer( GtkToggleAction * action ) | |
3767 { | |
3768 if (gtk_toggle_action_get_active(action)) | |
3769 equalizerwin_real_show(); | |
3770 else | |
3771 equalizerwin_real_hide(); | |
3772 } | |
3773 | |
3774 void | |
3775 action_show_playlist_editor( GtkToggleAction * action ) | |
3776 { | |
3777 if (gtk_toggle_action_get_active(action)) | |
3778 playlistwin_show(); | |
3779 else | |
3780 playlistwin_hide(); | |
3781 } | |
3782 | |
3783 void | |
3784 action_show_player( GtkToggleAction * action ) | |
3785 { | |
3786 mainwin_show(gtk_toggle_action_get_active(action)); | |
3787 } | |
3788 | |
3789 | |
3790 /* radioactionentries actions (one callback for each radio group) */ | |
3791 | |
3792 void | |
3793 action_anafoff( GtkAction *action, GtkRadioAction *current ) | |
3794 { | |
3795 mainwin_vis_set_afalloff(gtk_radio_action_get_current_value(current)); | |
3796 } | |
3797 | |
3798 void | |
3799 action_anamode( GtkAction *action, GtkRadioAction *current ) | |
3800 { | |
3801 mainwin_vis_set_analyzer_mode(gtk_radio_action_get_current_value(current)); | |
3802 } | |
3803 | |
3804 void | |
3805 action_anatype( GtkAction *action, GtkRadioAction *current ) | |
3806 { | |
3807 mainwin_vis_set_analyzer_type(gtk_radio_action_get_current_value(current)); | |
3808 } | |
3809 | |
3810 void | |
3811 action_peafoff( GtkAction *action, GtkRadioAction *current ) | |
3812 { | |
3813 mainwin_vis_set_pfalloff(gtk_radio_action_get_current_value(current)); | |
3814 } | |
3815 | |
3816 void | |
3817 action_refrate( GtkAction *action, GtkRadioAction *current ) | |
3818 { | |
3819 mainwin_vis_set_refresh(gtk_radio_action_get_current_value(current)); | |
3820 } | |
3821 | |
3822 void | |
3823 action_scomode( GtkAction *action, GtkRadioAction *current ) | |
3824 { | |
3825 cfg.scope_mode = gtk_radio_action_get_current_value(current); | |
3826 } | |
3827 | |
3828 void | |
3829 action_vismode( GtkAction *action, GtkRadioAction *current ) | |
3830 { | |
3831 mainwin_vis_set_type_menu_cb(gtk_radio_action_get_current_value(current)); | |
3832 } | |
3833 | |
3834 void | |
3835 action_vprmode( GtkAction *action, GtkRadioAction *current ) | |
3836 { | |
3837 cfg.voiceprint_mode = gtk_radio_action_get_current_value(current); | |
3838 } | |
3839 | |
3840 void | |
3841 action_wshmode( GtkAction *action, GtkRadioAction *current ) | |
3842 { | |
3843 cfg.vu_mode = gtk_radio_action_get_current_value(current); | |
3844 } | |
3845 | |
3846 void | |
3847 action_viewtime( GtkAction *action, GtkRadioAction *current ) | |
3848 { | |
3849 set_timer_mode_menu_cb(gtk_radio_action_get_current_value(current)); | |
3850 } | |
3851 | |
3852 | |
3853 /* actionentries actions */ | |
3854 | |
3855 void | |
3856 action_about_audacious( void ) | |
3857 { | |
3858 show_about_window(); | |
3859 } | |
3860 | |
3861 void | |
3862 action_play_file( void ) | |
3863 { | |
3864 util_run_filebrowser(PLAY_BUTTON); | |
3865 } | |
3866 | |
3867 void | |
3868 action_play_location( void ) | |
3869 { | |
3870 mainwin_show_add_url_window(); | |
3871 } | |
3872 | |
3873 void | |
3874 action_ab_set( void ) | |
3875 { | |
3876 Playlist *playlist = playlist_get_active(); | |
3877 if (playlist_get_current_length(playlist) != -1) | |
3878 { | |
3879 if (ab_position_a == -1) | |
3880 { | |
3881 ab_position_a = playback_get_time(); | |
3882 ab_position_b = -1; | |
3883 mainwin_lock_info_text("LOOP-POINT A POSITION SET."); | |
3884 } | |
3885 else if (ab_position_b == -1) | |
3886 { | |
3887 int time = playback_get_time(); | |
3888 if (time > ab_position_a) | |
3889 ab_position_b = time; | |
3890 mainwin_release_info_text(); | |
3891 } | |
3892 else | |
3893 { | |
3894 ab_position_a = playback_get_time(); | |
3895 ab_position_b = -1; | |
3896 mainwin_lock_info_text("LOOP-POINT A POSITION RESET."); | |
3897 } | |
3898 } | |
3899 } | |
3900 | |
3901 void | |
3902 action_ab_clear( void ) | |
3903 { | |
3904 Playlist *playlist = playlist_get_active(); | |
3905 if (playlist_get_current_length(playlist) != -1) | |
3906 { | |
3907 ab_position_a = ab_position_b = -1; | |
3908 mainwin_release_info_text(); | |
3909 } | |
3910 } | |
3911 | |
3912 void | |
3913 action_current_track_info( void ) | |
3914 { | |
3915 playlist_fileinfo_current(playlist_get_active()); | |
3916 } | |
3917 | |
3918 void | |
3919 action_jump_to_file( void ) | |
3920 { | |
3921 mainwin_jump_to_file(); | |
3922 } | |
3923 | |
3924 void | |
3925 action_jump_to_playlist_start( void ) | |
3926 { | |
3927 Playlist *playlist = playlist_get_active(); | |
3928 playlist_set_position(playlist, 0); | |
3929 } | |
3930 | |
3931 void | |
3932 action_jump_to_time( void ) | |
3933 { | |
3934 mainwin_jump_to_time(); | |
3935 } | |
3936 | |
3937 void | |
3938 action_playback_next( void ) | |
3939 { | |
3940 Playlist *playlist = playlist_get_active(); | |
3941 playlist_next(playlist); | |
3942 } | |
3943 | |
3944 void | |
3945 action_playback_previous( void ) | |
3946 { | |
3947 Playlist *playlist = playlist_get_active(); | |
3948 playlist_prev(playlist); | |
3949 } | |
3950 | |
3951 void | |
3952 action_playback_play( void ) | |
3953 { | |
3954 mainwin_play_pushed(); | |
3955 } | |
3956 | |
3957 void | |
3958 action_playback_playcd( void ) | |
3959 { | |
3960 play_medium(); | |
3961 } | |
3962 | |
3963 void | |
3964 action_playback_pause( void ) | |
3965 { | |
3966 playback_pause(); | |
3967 } | |
3968 | |
3969 void | |
3970 action_playback_stop( void ) | |
3971 { | |
3972 mainwin_stop_pushed(); | |
3973 } | |
3974 | |
3975 void | |
3976 action_preferences( void ) | |
3977 { | |
3978 show_prefs_window(); | |
3979 } | |
3980 | |
3981 void | |
3982 action_quit( void ) | |
3983 { | |
3984 mainwin_quit_cb(); | |
3985 } |