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