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