Mercurial > audlegacy
annotate audacious/mainwin.c @ 276:28b73b5595d1 trunk
[svn] Raise MAX_CODED_SUPERFRAME_SIZE to 16384 in accordance with ffmpeg CVS.
author | chainsaw |
---|---|
date | Sat, 10 Dec 2005 08:42:49 -0800 |
parents | f6edd411a320 |
children | 763afa52f416 |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 # include "config.h" | |
24 #endif | |
25 | |
26 | |
27 #include <glib.h> | |
28 #include <glib/gi18n.h> | |
29 #include <glib/gprintf.h> | |
30 #include <gtk/gtk.h> | |
31 #include <gdk/gdkx.h> | |
32 #include <gdk/gdkkeysyms.h> | |
33 | |
34 #include <math.h> | |
35 #include <stdlib.h> | |
36 #include <string.h> | |
37 | |
38 #include <X11/Xlib.h> | |
39 | |
40 #include "textbox.h" | |
41 #include "mainwin.h" | |
42 #include "pixmaps.h" | |
43 | |
44 #include "main.h" | |
45 | |
46 #include "controlsocket.h" | |
47 #include "pluginenum.h" | |
48 | |
49 #include "about.h" | |
50 #include "dnd.h" | |
51 #include "dock.h" | |
52 #include "equalizer.h" | |
53 #include "hints.h" | |
54 #include "input.h" | |
55 #include "playlistwin.h" | |
56 #include "prefswin.h" | |
57 #include "skinwin.h" | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
58 #include "genevent.h" |
0 | 59 #include "hslider.h" |
60 #include "menurow.h" | |
61 #include "monostereo.h" | |
62 #include "pbutton.h" | |
63 #include "playback.h" | |
64 #include "playlist.h" | |
65 #include "playlist_list.h" | |
66 #include "playstatus.h" | |
67 #include "sbutton.h" | |
68 #include "svis.h" | |
69 #include "textbox.h" | |
70 #include "urldecode.h" | |
71 #include "util.h" | |
72 #include "vis.h" | |
73 #include "visualization.h" | |
74 #include "libaudacious/configdb.h" | |
75 | |
76 | |
77 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>"} | |
78 | |
79 /* | |
80 * If you change the menu above change these defines also | |
81 */ | |
82 | |
83 #define MAINWIN_VIS_MENU_VIS_MODE 1 | |
84 #define MAINWIN_VIS_MENU_NUM_VIS_MODE 3 | |
85 #define MAINWIN_VIS_MENU_ANALYZER_MODE 5 | |
86 #define MAINWIN_VIS_MENU_NUM_ANALYZER_MODE 3 | |
87 #define MAINWIN_VIS_MENU_ANALYZER_TYPE 9 | |
88 #define MAINWIN_VIS_MENU_NUM_ANALYZER_TYPE 2 | |
89 #define MAINWIN_VIS_MENU_ANALYZER_PEAKS 12 | |
90 #define MAINWIN_VIS_MENU_SCOPE_MODE 14 | |
91 #define MAINWIN_VIS_MENU_NUM_SCOPE_MODE 3 | |
92 #define MAINWIN_VIS_MENU_WSHADEVU_MODE 18 | |
93 #define MAINWIN_VIS_MENU_NUM_WSHADEVU_MODE 2 | |
94 #define MAINWIN_VIS_MENU_REFRESH_RATE 21 | |
95 #define MAINWIN_VIS_MENU_NUM_REFRESH_RATE 4 | |
96 #define MAINWIN_VIS_MENU_AFALLOFF 26 | |
97 #define MAINWIN_VIS_MENU_NUM_AFALLOFF 5 | |
98 #define MAINWIN_VIS_MENU_PFALLOFF 32 | |
99 #define MAINWIN_VIS_MENU_NUM_PFALLOFF 5 | |
100 | |
101 #define VOLSET_DISP_TIMES 5 | |
102 | |
103 | |
104 enum { | |
105 MAINWIN_SONGNAME_FILEINFO, | |
106 MAINWIN_SONGNAME_JTF, | |
107 MAINWIN_SONGNAME_JTT, | |
108 MAINWIN_SONGNAME_SCROLL | |
109 }; | |
110 | |
111 enum { | |
112 MAINWIN_OPT_SKIN, MAINWIN_OPT_RELOADSKIN, | |
113 MAINWIN_OPT_REPEAT, MAINWIN_OPT_SHUFFLE, MAINWIN_OPT_NPA, | |
114 MAINWIN_OPT_TELAPSED, MAINWIN_OPT_TREMAINING, | |
115 MAINWIN_OPT_ALWAYS, | |
116 MAINWIN_OPT_STICKY, | |
117 MAINWIN_OPT_WS, | |
118 MAINWIN_OPT_PWS, | |
119 MAINWIN_OPT_EQWS | |
120 }; | |
121 | |
122 enum { | |
123 MAINWIN_VIS_ANALYZER, MAINWIN_VIS_SCOPE, MAINWIN_VIS_OFF, | |
124 MAINWIN_VIS_ANALYZER_NORMAL, MAINWIN_VIS_ANALYZER_FIRE, | |
125 MAINWIN_VIS_ANALYZER_VLINES, | |
126 MAINWIN_VIS_ANALYZER_LINES, MAINWIN_VIS_ANALYZER_BARS, | |
127 MAINWIN_VIS_ANALYZER_PEAKS, | |
128 MAINWIN_VIS_SCOPE_DOT, MAINWIN_VIS_SCOPE_LINE, MAINWIN_VIS_SCOPE_SOLID, | |
129 MAINWIN_VIS_VU_NORMAL, MAINWIN_VIS_VU_SMOOTH, | |
130 MAINWIN_VIS_REFRESH_FULL, MAINWIN_VIS_REFRESH_HALF, | |
131 MAINWIN_VIS_REFRESH_QUARTER, MAINWIN_VIS_REFRESH_EIGHTH, | |
132 MAINWIN_VIS_AFALLOFF_SLOWEST, MAINWIN_VIS_AFALLOFF_SLOW, | |
133 MAINWIN_VIS_AFALLOFF_MEDIUM, MAINWIN_VIS_AFALLOFF_FAST, | |
134 MAINWIN_VIS_AFALLOFF_FASTEST, | |
135 MAINWIN_VIS_PFALLOFF_SLOWEST, MAINWIN_VIS_PFALLOFF_SLOW, | |
136 MAINWIN_VIS_PFALLOFF_MEDIUM, MAINWIN_VIS_PFALLOFF_FAST, | |
137 MAINWIN_VIS_PFALLOFF_FASTEST, | |
138 MAINWIN_VIS_PLUGINS | |
139 }; | |
140 | |
141 enum { | |
142 MAINWIN_VIS_ACTIVE_MAINWIN, MAINWIN_VIS_ACTIVE_PLAYLISTWIN | |
143 }; | |
144 | |
145 | |
146 typedef struct _PlaybackInfo PlaybackInfo; | |
147 | |
148 struct _PlaybackInfo { | |
149 gchar *title; | |
150 gint bitrate; | |
151 gint frequency; | |
152 gint n_channels; | |
153 }; | |
154 | |
155 | |
156 GtkWidget *mainwin = NULL; | |
157 | |
158 static GdkBitmap *nullmask; | |
159 static gint balance; | |
160 | |
161 GtkWidget *mainwin_jtf = NULL; | |
162 static GtkWidget *mainwin_jtt = NULL; | |
163 | |
164 GtkItemFactory *mainwin_songname_menu, *mainwin_vis_menu; | |
165 GtkItemFactory *mainwin_general_menu, *mainwin_play_menu, *mainwin_add_menu; | |
166 GtkItemFactory *mainwin_view_menu; | |
167 | |
168 | |
169 GdkGC *mainwin_gc; | |
170 static GdkPixmap *mainwin_bg = NULL; | |
171 | |
172 GtkAccelGroup *mainwin_accel = NULL; | |
173 | |
174 static PButton *mainwin_menubtn; | |
175 static PButton *mainwin_minimize, *mainwin_shade, *mainwin_close; | |
176 | |
177 static PButton *mainwin_rew, *mainwin_fwd; | |
178 static PButton *mainwin_eject; | |
179 static PButton *mainwin_play, *mainwin_pause, *mainwin_stop; | |
180 | |
181 TButton *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; | |
182 TextBox *mainwin_info; | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
183 TextBox *mainwin_stime_min, *mainwin_stime_sec; |
0 | 184 |
185 static TextBox *mainwin_rate_text, *mainwin_freq_text; | |
186 | |
187 PlayStatus *mainwin_playstatus; | |
188 | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
189 Number *mainwin_minus_num, *mainwin_10min_num, *mainwin_min_num; |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
190 Number *mainwin_10sec_num, *mainwin_sec_num; |
0 | 191 |
192 static gboolean setting_volume = FALSE; | |
193 | |
194 Vis *active_vis; | |
195 Vis *mainwin_vis; | |
196 SVis *mainwin_svis; | |
197 | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
198 HSlider *mainwin_sposition = NULL; |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
199 |
0 | 200 static MenuRow *mainwin_menurow; |
201 static HSlider *mainwin_volume, *mainwin_balance, *mainwin_position; | |
202 static MonoStereo *mainwin_monostereo; | |
203 static SButton *mainwin_srew, *mainwin_splay, *mainwin_spause; | |
204 static SButton *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about; | |
205 | |
206 static GList *mainwin_wlist = NULL; | |
207 | |
208 static gint mainwin_timeout_id; | |
209 | |
210 G_LOCK_DEFINE_STATIC(mainwin_title); | |
211 | |
212 static gboolean mainwin_force_redraw = FALSE; | |
213 static gchar *mainwin_title_text = NULL; | |
214 static gboolean mainwin_info_text_locked = FALSE; | |
215 | |
216 | |
217 static void mainwin_songname_menu_callback(gpointer user_data, | |
218 guint action, | |
219 GtkWidget * widget); | |
220 | |
221 static void mainwin_vis_menu_callback(gpointer user_data, | |
222 guint action, | |
223 GtkWidget * widget); | |
224 | |
225 static void mainwin_view_menu_callback(gpointer user_data, | |
226 guint action, | |
227 GtkWidget * widget); | |
228 | |
229 static void mainwin_play_menu_callback(gpointer user_data, | |
230 guint action, | |
231 GtkWidget * widget); | |
232 | |
233 /* Song name area menu */ | |
234 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
235 GtkItemFactoryEntry mainwin_songname_menu_entries[] = { |
0 | 236 {N_("/View Track Details"), "<alt>i", mainwin_general_menu_callback, |
237 MAINWIN_GENERAL_FILEINFO, "<ImageItem>", my_pixbuf}, | |
238 {"/-", NULL, NULL, 0, "<Separator>"}, | |
239 {N_("/Autoscroll Songname"), NULL, mainwin_songname_menu_callback, | |
240 MAINWIN_SONGNAME_SCROLL, "<ToggleItem>"}, | |
241 }; | |
242 | |
243 static gint mainwin_songname_menu_entries_num = | |
244 G_N_ELEMENTS(mainwin_songname_menu_entries); | |
245 | |
246 /* Mini-visualizer area menu */ | |
247 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
248 GtkItemFactoryEntry mainwin_vis_menu_entries[] = { |
0 | 249 {N_("/Visualization Mode"), NULL, NULL, 0, "<Branch>"}, |
250 {N_("/Visualization Mode/Analyzer"), NULL, mainwin_vis_menu_callback, | |
251 MAINWIN_VIS_ANALYZER, "<RadioItem>"}, | |
252 {N_("/Visualization Mode/Scope"), NULL, mainwin_vis_menu_callback, | |
253 MAINWIN_VIS_SCOPE, "/Visualization Mode/Analyzer"}, | |
254 {N_("/Visualization Mode/Off"), NULL, mainwin_vis_menu_callback, | |
255 MAINWIN_VIS_OFF, "/Visualization Mode/Analyzer"}, | |
256 {N_("/Analyzer Mode"), NULL, NULL, 0, "<Branch>"}, | |
257 {N_("/Analyzer Mode/Normal"), NULL, mainwin_vis_menu_callback, | |
258 MAINWIN_VIS_ANALYZER_NORMAL, "<RadioItem>"}, | |
259 {N_("/Analyzer Mode/Fire"), NULL, mainwin_vis_menu_callback, | |
260 MAINWIN_VIS_ANALYZER_FIRE, "/Analyzer Mode/Normal"}, | |
261 {N_("/Analyzer Mode/Vertical Lines"), NULL, mainwin_vis_menu_callback, | |
262 MAINWIN_VIS_ANALYZER_VLINES, "/Analyzer Mode/Normal"}, | |
263 {"/Analyzer Mode/-", NULL, NULL, 0, "<Separator>"}, | |
264 {N_("/Analyzer Mode/Lines"), NULL, mainwin_vis_menu_callback, | |
265 MAINWIN_VIS_ANALYZER_LINES, "<RadioItem>"}, | |
266 {N_("/Analyzer Mode/Bars"), NULL, mainwin_vis_menu_callback, | |
267 MAINWIN_VIS_ANALYZER_BARS, "/Analyzer Mode/Lines"}, | |
268 {"/Analyzer Mode/-", NULL, NULL, 0, "<Separator>"}, | |
269 {N_("/Analyzer Mode/Peaks"), NULL, mainwin_vis_menu_callback, | |
270 MAINWIN_VIS_ANALYZER_PEAKS, "<ToggleItem>"}, | |
271 {N_("/Scope Mode"), NULL, NULL, 0, "<Branch>"}, | |
272 {N_("/Scope Mode/Dot Scope"), NULL, mainwin_vis_menu_callback, | |
273 MAINWIN_VIS_SCOPE_DOT, "<RadioItem>"}, | |
274 {N_("/Scope Mode/Line Scope"), NULL, mainwin_vis_menu_callback, | |
275 MAINWIN_VIS_SCOPE_LINE, "/Scope Mode/Dot Scope"}, | |
276 {N_("/Scope Mode/Solid Scope"), NULL, mainwin_vis_menu_callback, | |
277 MAINWIN_VIS_SCOPE_SOLID, "/Scope Mode/Dot Scope"}, | |
278 {N_("/WindowShade VU Mode"), NULL, NULL, 0, "<Branch>"}, | |
279 {N_("/WindowShade VU Mode/Normal"), NULL, mainwin_vis_menu_callback, | |
280 MAINWIN_VIS_VU_NORMAL, "<RadioItem>"}, | |
281 {N_("/WindowShade VU Mode/Smooth"), NULL, mainwin_vis_menu_callback, | |
282 MAINWIN_VIS_VU_SMOOTH, "/WindowShade VU Mode/Normal"}, | |
283 {N_("/Refresh Rate"), NULL, NULL, 0, "<Branch>"}, | |
284 {N_("/Refresh Rate/Full (~50 fps)"), NULL, mainwin_vis_menu_callback, | |
285 MAINWIN_VIS_REFRESH_FULL, "<RadioItem>"}, | |
286 {N_("/Refresh Rate/Half (~25 fps)"), NULL, mainwin_vis_menu_callback, | |
287 MAINWIN_VIS_REFRESH_HALF, "/Refresh Rate/Full (~50 fps)"}, | |
288 {N_("/Refresh Rate/Quarter (~13 fps)"), NULL, mainwin_vis_menu_callback, | |
289 MAINWIN_VIS_REFRESH_QUARTER, "/Refresh Rate/Full (~50 fps)"}, | |
290 {N_("/Refresh Rate/Eighth (~6 fps)"), NULL, mainwin_vis_menu_callback, | |
291 MAINWIN_VIS_REFRESH_EIGHTH, "/Refresh Rate/Full (~50 fps)"}, | |
292 {N_("/Analyzer Falloff"), NULL, NULL, 0, "<Branch>"}, | |
293 {N_("/Analyzer Falloff/Slowest"), NULL, mainwin_vis_menu_callback, | |
294 MAINWIN_VIS_AFALLOFF_SLOWEST, "<RadioItem>"}, | |
295 {N_("/Analyzer Falloff/Slow"), NULL, mainwin_vis_menu_callback, | |
296 MAINWIN_VIS_AFALLOFF_SLOW, "/Analyzer Falloff/Slowest"}, | |
297 {N_("/Analyzer Falloff/Medium"), NULL, mainwin_vis_menu_callback, | |
298 MAINWIN_VIS_AFALLOFF_MEDIUM, "/Analyzer Falloff/Slowest"}, | |
299 {N_("/Analyzer Falloff/Fast"), NULL, mainwin_vis_menu_callback, | |
300 MAINWIN_VIS_AFALLOFF_FAST, "/Analyzer Falloff/Slowest"}, | |
301 {N_("/Analyzer Falloff/Fastest"), NULL, mainwin_vis_menu_callback, | |
302 MAINWIN_VIS_AFALLOFF_FASTEST, "/Analyzer Falloff/Slowest"}, | |
303 {N_("/Peaks Falloff"), NULL, NULL, 0, "<Branch>"}, | |
304 {N_("/Peaks Falloff/Slowest"), NULL, mainwin_vis_menu_callback, | |
305 MAINWIN_VIS_PFALLOFF_SLOWEST, "<RadioItem>"}, | |
306 {N_("/Peaks Falloff/Slow"), NULL, mainwin_vis_menu_callback, | |
307 MAINWIN_VIS_PFALLOFF_SLOW, "/Peaks Falloff/Slowest"}, | |
308 {N_("/Peaks Falloff/Medium"), NULL, mainwin_vis_menu_callback, | |
309 MAINWIN_VIS_PFALLOFF_MEDIUM, "/Peaks Falloff/Slowest"}, | |
310 {N_("/Peaks Falloff/Fast"), NULL, mainwin_vis_menu_callback, | |
311 MAINWIN_VIS_PFALLOFF_FAST, "/Peaks Falloff/Slowest"}, | |
312 {N_("/Peaks Falloff/Fastest"), NULL, mainwin_vis_menu_callback, | |
313 MAINWIN_VIS_PFALLOFF_FASTEST, "/Peaks Falloff/Slowest"} | |
314 }; | |
315 | |
316 static const gint mainwin_vis_menu_entries_num = | |
317 G_N_ELEMENTS(mainwin_vis_menu_entries); | |
318 | |
319 /* Playback menu (now used only for accelerators) */ | |
320 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
321 GtkItemFactoryEntry mainwin_playback_menu_entries[] = { |
0 | 322 {N_("/Play CD"), "<alt>C", mainwin_general_menu_callback, |
323 MAINWIN_GENERAL_PLAYCD, "<StockItem>", GTK_STOCK_CDROM}, | |
324 {"/-", NULL, NULL, 0, "<Separator>"}, | |
325 {N_("/Repeat"), "R", mainwin_play_menu_callback, | |
326 MAINWIN_OPT_REPEAT, "<ToggleItem>"}, | |
327 {N_("/Shuffle"), "S", mainwin_play_menu_callback, | |
328 MAINWIN_OPT_SHUFFLE, "<ToggleItem>"}, | |
329 {N_("/No Playlist Advance"), "<control>N", mainwin_play_menu_callback, | |
330 MAINWIN_OPT_NPA, "<ToggleItem>"}, | |
331 {"/-", NULL, NULL, 0, "<Separator>"}, | |
332 {N_("/Play"), "x", mainwin_general_menu_callback, | |
333 MAINWIN_GENERAL_PLAY, "<Item>"}, | |
334 {N_("/Pause"), "c", mainwin_general_menu_callback, | |
335 MAINWIN_GENERAL_PAUSE, "<Item>"}, | |
336 {N_("/Stop"), "v", mainwin_general_menu_callback, | |
337 MAINWIN_GENERAL_STOP, "<StockItem>", GTK_STOCK_STOP}, | |
338 {N_("/Previous"), "z", mainwin_general_menu_callback, | |
339 MAINWIN_GENERAL_PREV, "<StockItem>", GTK_STOCK_GO_BACK}, | |
340 {N_("/Next"), "b", mainwin_general_menu_callback, | |
341 MAINWIN_GENERAL_NEXT, "<StockItem>", GTK_STOCK_GO_FORWARD}, | |
342 {"/-", NULL, NULL, 0, "<Separator>"}, | |
343 {N_("/Jump to Playlist Start"), "<control>Z", mainwin_general_menu_callback, | |
344 MAINWIN_GENERAL_START, "<StockItem>", GTK_STOCK_GOTO_TOP}, | |
345 {"/-", NULL, NULL, 0, "<Separator>"}, | |
346 {N_("/Jump to File"), "J", mainwin_general_menu_callback, | |
347 MAINWIN_GENERAL_JTF, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
348 {N_("/Jump to Time"), "<control>J", mainwin_general_menu_callback, | |
349 MAINWIN_GENERAL_JTT, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
88
db2d1d193e56
[svn] Fix the missing separator in the playback menu. (oops)
nenolod
parents:
87
diff
changeset
|
350 {"/-", NULL, NULL, 0, "<Separator>"}, |
87 | 351 {N_("/View Track Details"), "<alt>I", mainwin_general_menu_callback, |
352 MAINWIN_GENERAL_FILEINFO, "<ImageItem>", my_pixbuf} | |
0 | 353 }; |
354 | |
355 static const gint mainwin_playback_menu_entries_num = | |
356 G_N_ELEMENTS(mainwin_playback_menu_entries); | |
357 | |
358 /* Main menu */ | |
359 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
360 GtkItemFactoryEntry mainwin_general_menu_entries[] = { |
86 | 361 {N_("/About Audacious"), NULL, mainwin_general_menu_callback, |
362 MAINWIN_GENERAL_ABOUT, "<StockItem>", GTK_STOCK_DIALOG_INFO}, | |
363 {"/-", NULL, NULL, 0, "<Separator>"}, | |
364 {N_("/Play File"), "L", mainwin_general_menu_callback, | |
365 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN}, | |
366 {N_("/Play Directory"), "<shift>L", mainwin_general_menu_callback, | |
367 MAINWIN_GENERAL_PLAYDIRECTORY, "<Item>"}, | |
368 {N_("/Play Location"), "<control>L", mainwin_general_menu_callback, | |
369 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
370 {"/-", NULL, NULL, 0, "<Separator>"}, | |
87 | 371 {N_("/V_isualization"), NULL, NULL, 0, "<Item>"}, |
372 {N_("/_Playback"), NULL, NULL, 0, "<Item>"}, | |
373 {N_("/_View"), NULL, NULL, 0, "<Item>"}, | |
0 | 374 {"/-", NULL, NULL, 0, "<Separator>"}, |
375 {N_("/Preferences"), "<control>P", mainwin_general_menu_callback, | |
376 MAINWIN_GENERAL_PREFS, "<StockItem>", GTK_STOCK_PREFERENCES}, | |
377 {N_("/_Quit"), NULL, mainwin_general_menu_callback, | |
378 MAINWIN_GENERAL_EXIT, "<StockItem>", GTK_STOCK_QUIT} | |
379 }; | |
380 | |
381 static const gint mainwin_general_menu_entries_num = | |
382 G_N_ELEMENTS(mainwin_general_menu_entries); | |
383 | |
384 /* Add submenu */ | |
385 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
386 GtkItemFactoryEntry mainwin_add_menu_entries[] = { |
0 | 387 {N_("/Files..."), "f", mainwin_general_menu_callback, |
388 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN}, | |
389 /* | |
390 {N_("/Folders..."), "d", | |
391 mainwin_general_menu_callback, | |
392 MAINWIN_GENERAL_PLAYDIRECTORY, "<StockItem>", GTK_STOCK_OPEN}, | |
393 */ | |
394 {N_("/Internet location..."), "<control>h", mainwin_general_menu_callback, | |
395 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
396 }; | |
397 | |
398 static const gint mainwin_add_menu_entries_num = | |
399 G_N_ELEMENTS(mainwin_add_menu_entries); | |
400 | |
401 | |
402 /* | |
403 */ | |
404 | |
405 /* View submenu */ | |
406 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
407 GtkItemFactoryEntry mainwin_view_menu_entries[] = { |
0 | 408 {N_("/Show Playlist Editor"), "<alt>E", mainwin_general_menu_callback, |
409 MAINWIN_GENERAL_SHOWPLWIN, "<ToggleItem>"}, | |
410 {N_("/Show Equalizer"), "<alt>G", mainwin_general_menu_callback, | |
411 MAINWIN_GENERAL_SHOWEQWIN, "<ToggleItem>"}, | |
412 {"/-", NULL, NULL, 0, "<Separator>"}, | |
413 {N_("/Time Elapsed"), "<control>E", mainwin_view_menu_callback, | |
414 MAINWIN_OPT_TELAPSED, "<RadioItem>"}, | |
415 {N_("/Time Remaining"), "<control>R", mainwin_view_menu_callback, | |
416 MAINWIN_OPT_TREMAINING, "/Time Elapsed"}, | |
417 {"/-", NULL, NULL, 0, "<Separator>"}, | |
418 {N_("/Always On Top"), "<control>o", mainwin_view_menu_callback, | |
419 MAINWIN_OPT_ALWAYS, "<ToggleItem>"}, | |
420 {N_("/Put on All Workspaces"), "<control>S", | |
421 mainwin_view_menu_callback, MAINWIN_OPT_STICKY, "<ToggleItem>"}, | |
422 {"/-", NULL, NULL, 0, "<Separator>"}, | |
423 {N_("/Roll up Player"), "<control>W", mainwin_view_menu_callback, | |
424 MAINWIN_OPT_WS, "<ToggleItem>"}, | |
425 {N_("/Roll up Playlist Editor"), "<control><shift>W", mainwin_view_menu_callback, | |
426 MAINWIN_OPT_PWS, "<ToggleItem>"}, | |
427 {N_("/Roll up Equalizer"), "<control><alt>W", mainwin_view_menu_callback, | |
428 MAINWIN_OPT_EQWS, "<ToggleItem>"} | |
429 }; | |
430 | |
431 static const gint mainwin_view_menu_entries_num = | |
432 G_N_ELEMENTS(mainwin_view_menu_entries); | |
433 | |
434 | |
435 static PlaybackInfo playback_info = { NULL, 0, 0, 0 }; | |
436 | |
437 | |
438 static gint mainwin_idle_func(gpointer data); | |
439 | |
440 static void set_timer_mode_menu_cb(TimerMode mode); | |
441 static void set_timer_mode(TimerMode mode); | |
442 | |
443 | |
444 /* FIXME: placed here for now */ | |
445 void | |
446 playback_get_sample_params(gint * bitrate, | |
447 gint * frequency, | |
448 gint * n_channels) | |
449 { | |
450 if (bitrate) | |
451 *bitrate = playback_info.bitrate; | |
452 | |
453 if (frequency) | |
454 *frequency = playback_info.frequency; | |
455 | |
456 if (n_channels) | |
457 *n_channels = playback_info.n_channels; | |
458 } | |
459 | |
460 static void | |
461 playback_set_sample_params(gint bitrate, | |
462 gint frequency, | |
463 gint n_channels) | |
464 { | |
465 if (bitrate >= 0) | |
466 playback_info.bitrate = bitrate; | |
467 | |
468 if (frequency >= 0) | |
469 playback_info.frequency = frequency; | |
470 | |
471 if (n_channels >= 0) | |
472 playback_info.n_channels = n_channels; | |
473 } | |
474 | |
475 static void | |
476 mainwin_set_title_scroll(gboolean scroll) | |
477 { | |
478 cfg.autoscroll = scroll; | |
479 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
480 } | |
481 | |
482 | |
483 void | |
484 mainwin_set_always_on_top(gboolean always) | |
485 { | |
486 GtkWidget *widget = gtk_item_factory_get_widget(mainwin_view_menu, | |
487 "/Always On Top"); | |
488 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
489 mainwin_menurow->mr_always_selected); | |
490 } | |
491 | |
492 static void | |
493 mainwin_set_shape_mask(void) | |
494 { | |
495 GdkBitmap *mask; | |
496 | |
497 if (!cfg.player_visible) | |
498 return; | |
499 | |
500 mask = skin_get_mask(bmp_active_skin, SKIN_MASK_MAIN + cfg.player_shaded); | |
501 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0); | |
502 } | |
503 | |
504 static void | |
505 mainwin_set_shade(gboolean shaded) | |
506 { | |
507 GtkWidget *widget; | |
508 widget = gtk_item_factory_get_widget(mainwin_view_menu, | |
509 "/Roll up Player"); | |
510 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), shaded); | |
511 } | |
512 | |
513 static void | |
514 mainwin_set_shade_menu_cb(gboolean shaded) | |
515 { | |
516 cfg.player_shaded = shaded; | |
517 | |
518 mainwin_set_shape_mask(); | |
519 | |
520 if (shaded) { | |
521 dock_shade(dock_window_list, GTK_WINDOW(mainwin), | |
522 MAINWIN_SHADED_HEIGHT); | |
523 | |
524 widget_show(WIDGET(mainwin_svis)); | |
525 vis_clear_data(mainwin_vis); | |
526 | |
527 widget_show(WIDGET(mainwin_srew)); | |
528 widget_show(WIDGET(mainwin_splay)); | |
529 widget_show(WIDGET(mainwin_spause)); | |
530 widget_show(WIDGET(mainwin_sstop)); | |
531 widget_show(WIDGET(mainwin_sfwd)); | |
532 widget_show(WIDGET(mainwin_seject)); | |
533 | |
534 widget_show(WIDGET(mainwin_stime_min)); | |
535 widget_show(WIDGET(mainwin_stime_sec)); | |
536 | |
537 textbox_set_scroll(mainwin_info, FALSE); | |
538 if (bmp_playback_get_playing() | |
539 && playlist_get_current_length() != -1) | |
540 widget_show(WIDGET(mainwin_sposition)); | |
541 | |
542 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
543 } | |
544 else { | |
545 dock_shade(dock_window_list, GTK_WINDOW(mainwin), MAINWIN_HEIGHT); | |
546 | |
547 widget_hide(WIDGET(mainwin_svis)); | |
548 svis_clear_data(mainwin_svis); | |
549 | |
550 widget_hide(WIDGET(mainwin_srew)); | |
551 widget_hide(WIDGET(mainwin_splay)); | |
552 widget_hide(WIDGET(mainwin_spause)); | |
553 widget_hide(WIDGET(mainwin_sstop)); | |
554 widget_hide(WIDGET(mainwin_sfwd)); | |
555 widget_hide(WIDGET(mainwin_seject)); | |
556 | |
557 widget_hide(WIDGET(mainwin_stime_min)); | |
558 widget_hide(WIDGET(mainwin_stime_sec)); | |
559 widget_hide(WIDGET(mainwin_sposition)); | |
560 | |
561 textbox_set_scroll(mainwin_info, TRUE); | |
562 mainwin_shade->pb_ny = mainwin_shade->pb_py = 18; | |
563 } | |
564 | |
565 draw_main_window(TRUE); | |
566 } | |
567 | |
568 static void | |
569 mainwin_vis_set_active_vis(gint new_vis) | |
570 { | |
571 switch (new_vis) { | |
572 case MAINWIN_VIS_ACTIVE_MAINWIN: | |
573 playlistwin_vis_disable(); | |
574 active_vis = mainwin_vis; | |
575 break; | |
576 case MAINWIN_VIS_ACTIVE_PLAYLISTWIN: | |
577 playlistwin_vis_enable(); | |
578 active_vis = playlistwin_vis; | |
579 break; | |
580 } | |
581 } | |
582 | |
583 static void | |
584 mainwin_vis_set_refresh(RefreshRate rate) | |
585 { | |
586 cfg.vis_refresh = rate; | |
587 } | |
588 | |
589 static void | |
590 mainwin_vis_set_afalloff(FalloffSpeed speed) | |
591 { | |
592 cfg.analyzer_falloff = speed; | |
593 } | |
594 | |
595 static void | |
596 mainwin_vis_set_pfalloff(FalloffSpeed speed) | |
597 { | |
598 cfg.peaks_falloff = speed; | |
599 } | |
600 | |
601 static void | |
602 mainwin_vis_set_analyzer_mode(AnalyzerMode mode) | |
603 { | |
604 cfg.analyzer_mode = mode; | |
605 } | |
606 | |
607 static void | |
608 mainwin_vis_set_analyzer_type(AnalyzerType mode) | |
609 { | |
610 cfg.analyzer_type = mode; | |
611 } | |
612 | |
613 void | |
614 mainwin_vis_set_type(VisType mode) | |
615 { | |
616 gchar *path = | |
617 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + mode].path; | |
618 GtkWidget *widget = gtk_item_factory_get_widget(mainwin_vis_menu, path); | |
619 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), TRUE); | |
620 } | |
621 | |
622 static void | |
623 mainwin_vis_set_type_menu_cb(VisType mode) | |
624 { | |
625 cfg.vis_type = mode; | |
626 | |
627 if (mode == VIS_OFF) { | |
628 if (cfg.player_shaded && cfg.player_visible) | |
629 svis_clear(mainwin_svis); | |
630 else | |
631 vis_clear(active_vis); | |
632 } | |
633 if (mode == VIS_ANALYZER) { | |
634 vis_clear_data(active_vis); | |
635 svis_clear_data(mainwin_svis); | |
636 } | |
637 } | |
638 | |
639 static void | |
640 mainwin_menubtn_cb(void) | |
641 { | |
642 gint x, y; | |
643 gtk_window_get_position(GTK_WINDOW(mainwin), &x, &y); | |
644 util_item_factory_popup(mainwin_general_menu, | |
645 x + 6, | |
646 y + MAINWIN_SHADED_HEIGHT, | |
647 1, GDK_CURRENT_TIME); | |
648 } | |
649 | |
650 void | |
651 mainwin_minimize_cb(void) | |
652 { | |
653 if (!mainwin) | |
654 return; | |
655 | |
656 gtk_window_iconify(GTK_WINDOW(mainwin)); | |
657 } | |
658 | |
659 static void | |
660 mainwin_shade_toggle(void) | |
661 { | |
662 mainwin_set_shade(!cfg.player_shaded); | |
663 } | |
664 | |
665 void | |
666 mainwin_quit_cb(void) | |
667 { | |
668 gtk_widget_hide(equalizerwin); | |
669 gtk_widget_hide(playlistwin); | |
670 gtk_widget_hide(mainwin); | |
671 gdk_flush(); | |
672 | |
673 g_source_remove(mainwin_timeout_id); | |
674 | |
675 util_set_cursor(NULL); | |
676 | |
677 bmp_config_save(); | |
678 gtk_accel_map_save(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
679 | |
680 ctrlsocket_cleanup(); | |
681 | |
682 playlist_stop_get_info_thread(); | |
683 playlist_clear(); | |
684 | |
685 plugin_system_cleanup(); | |
686 | |
687 gtk_main_quit(); | |
196 | 688 |
689 exit(EXIT_SUCCESS); | |
0 | 690 } |
691 | |
692 static void | |
693 mainwin_destroy(GtkWidget * widget, gpointer data) | |
694 { | |
695 mainwin_quit_cb(); | |
696 } | |
697 | |
698 static void | |
699 mainwin_draw_titlebar(gboolean focus) | |
700 { | |
701 skin_draw_mainwin_titlebar(bmp_active_skin, mainwin_bg, mainwin_gc, | |
702 cfg.player_shaded, focus || !cfg.dim_titlebar); | |
703 } | |
704 | |
705 void | |
706 draw_main_window(gboolean force) | |
707 { | |
708 GList *wl; | |
709 Widget *w; | |
710 gboolean redraw; | |
711 | |
712 if (!cfg.player_visible) | |
713 return; | |
714 | |
715 widget_list_lock(mainwin_wlist); | |
716 | |
717 if (force) { | |
718 if (!cfg.player_shaded) | |
719 skin_draw_pixmap(bmp_active_skin, mainwin_bg, mainwin_gc, | |
720 SKIN_MAIN, 0, 0, 0, 0, MAINWIN_WIDTH, | |
721 MAINWIN_HEIGHT); | |
722 mainwin_draw_titlebar(gtk_window_has_toplevel_focus | |
723 (GTK_WINDOW(mainwin))); | |
724 } | |
725 | |
726 widget_list_draw(mainwin_wlist, &redraw, force); | |
727 | |
728 if (redraw || force) { | |
729 if (force) { | |
730 gdk_window_clear(mainwin->window); | |
731 } | |
732 else { | |
733 for (wl = mainwin_wlist; wl; wl = g_list_next(wl)) { | |
734 w = WIDGET(wl->data); | |
735 | |
736 if (!w->redraw || !w->visible) | |
737 continue; | |
738 | |
739 gdk_window_clear_area(mainwin->window, w->x, w->y, | |
740 w->width, w->height); | |
741 w->redraw = FALSE; | |
742 } | |
743 } | |
744 | |
745 gdk_flush(); | |
746 } | |
747 | |
748 widget_list_unlock(mainwin_wlist); | |
749 } | |
750 | |
751 | |
752 void | |
753 mainwin_set_info_text(void) | |
754 { | |
755 gchar *text; | |
756 | |
757 if (mainwin_info_text_locked) | |
758 return; | |
759 | |
760 if ((text = input_get_info_text()) != NULL) { | |
761 textbox_set_text(mainwin_info, text); | |
762 g_free(text); | |
763 } | |
764 else if ((text = playlist_get_info_text()) != NULL) { | |
765 textbox_set_text(mainwin_info, text); | |
766 g_free(text); | |
767 } | |
768 } | |
769 | |
770 void | |
771 mainwin_lock_info_text(const gchar * text) | |
772 { | |
773 mainwin_info_text_locked = TRUE; | |
774 textbox_set_text(mainwin_info, text); | |
775 } | |
776 | |
777 void | |
778 mainwin_release_info_text(void) | |
779 { | |
780 mainwin_info_text_locked = FALSE; | |
781 mainwin_set_info_text(); | |
782 } | |
783 | |
784 | |
785 static gchar * | |
786 make_mainwin_title(const gchar * title) | |
787 { | |
788 if (title) | |
789 return g_strdup_printf(_("%s - Audacious"), title); | |
790 else | |
791 return g_strdup(_("Audacious")); | |
792 } | |
793 | |
794 void | |
795 mainwin_set_song_title(const gchar * title) | |
796 { | |
797 G_LOCK(mainwin_title); | |
798 g_free(mainwin_title_text); | |
799 mainwin_title_text = make_mainwin_title(title); | |
800 G_UNLOCK(mainwin_title); | |
801 } | |
802 | |
803 void | |
804 mainwin_set_song_info(gint bitrate, | |
805 gint frequency, | |
806 gint n_channels) | |
807 { | |
808 gchar text[10]; | |
809 gchar *title; | |
810 | |
811 playback_set_sample_params(bitrate, frequency, n_channels); | |
812 | |
813 if (bitrate != -1) { | |
814 bitrate /= 1000; | |
815 | |
816 if (bitrate < 1000) { | |
817 /* Show bitrate in 1000s */ | |
818 g_snprintf(text, sizeof(text), "%3d", bitrate); | |
819 textbox_set_text(mainwin_rate_text, text); | |
820 } | |
821 else { | |
822 /* Show bitrate in 100,000s */ | |
823 bitrate /= 100; | |
824 g_snprintf(text, sizeof(text), "%2dH", bitrate); | |
825 textbox_set_text(mainwin_rate_text, text); | |
826 } | |
827 } | |
828 else | |
829 textbox_set_text(mainwin_rate_text, _("VBR")); | |
830 | |
831 /* Show sampling frequency in kHz */ | |
832 g_snprintf(text, sizeof(text), "%2d", frequency / 1000); | |
833 textbox_set_text(mainwin_freq_text, text); | |
834 | |
835 monostereo_set_num_channels(mainwin_monostereo, n_channels); | |
836 | |
837 widget_show(WIDGET(mainwin_minus_num)); | |
838 widget_show(WIDGET(mainwin_10min_num)); | |
839 widget_show(WIDGET(mainwin_min_num)); | |
840 widget_show(WIDGET(mainwin_10sec_num)); | |
841 widget_show(WIDGET(mainwin_sec_num)); | |
842 | |
843 if (!bmp_playback_get_paused()) | |
844 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
845 | |
846 if (playlist_get_current_length() != -1) { | |
847 if (cfg.player_shaded) | |
848 widget_show(WIDGET(mainwin_sposition)); | |
849 widget_show(WIDGET(mainwin_position)); | |
850 } | |
851 else { | |
852 widget_hide(WIDGET(mainwin_position)); | |
853 widget_hide(WIDGET(mainwin_sposition)); | |
854 mainwin_force_redraw = TRUE; | |
855 } | |
856 | |
857 title = playlist_get_info_text(); | |
858 mainwin_set_song_title(title); | |
859 g_free(title); | |
860 } | |
861 | |
862 void | |
863 mainwin_clear_song_info(void) | |
864 { | |
196 | 865 if (!mainwin) |
866 return; | |
867 | |
0 | 868 /* clear title */ |
869 G_LOCK(mainwin_title); | |
870 g_free(mainwin_title_text); | |
871 mainwin_title_text = NULL; | |
872 G_UNLOCK(mainwin_title); | |
873 | |
874 /* clear sampling parameters */ | |
875 playback_set_sample_params(0, 0, 0); | |
876 | |
877 mainwin_position->hs_pressed = FALSE; | |
878 mainwin_sposition->hs_pressed = FALSE; | |
879 | |
880 /* clear sampling parameter displays */ | |
881 textbox_set_text(mainwin_rate_text, " "); | |
882 textbox_set_text(mainwin_freq_text, " "); | |
883 monostereo_set_num_channels(mainwin_monostereo, 0); | |
884 | |
885 playstatus_set_status(mainwin_playstatus, STATUS_STOP); | |
886 | |
887 /* hide playback time */ | |
888 widget_hide(WIDGET(mainwin_minus_num)); | |
889 widget_hide(WIDGET(mainwin_10min_num)); | |
890 widget_hide(WIDGET(mainwin_min_num)); | |
891 widget_hide(WIDGET(mainwin_10sec_num)); | |
892 widget_hide(WIDGET(mainwin_sec_num)); | |
893 | |
894 textbox_set_text(mainwin_stime_min, " "); | |
895 textbox_set_text(mainwin_stime_sec, " "); | |
896 | |
897 widget_hide(WIDGET(mainwin_position)); | |
898 widget_hide(WIDGET(mainwin_sposition)); | |
899 | |
900 playlistwin_hide_timer(); | |
901 draw_main_window(TRUE); | |
902 | |
903 vis_clear(active_vis); | |
904 } | |
905 | |
906 void | |
907 mainwin_disable_seekbar(void) | |
908 { | |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
909 if (!mainwin) |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
910 return; |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
911 |
0 | 912 /* |
913 * We dont call draw_main_window() here so this will not | |
914 * remove them visually. It will only prevent us from sending | |
915 * any seek calls to the input plugin before the input plugin | |
916 * calls ->set_info(). | |
917 */ | |
918 widget_hide(WIDGET(mainwin_position)); | |
919 widget_hide(WIDGET(mainwin_sposition)); | |
920 } | |
921 | |
922 static gboolean | |
923 mainwin_mouse_button_release(GtkWidget * widget, | |
924 GdkEventButton * event, | |
925 gpointer callback_data) | |
926 { | |
927 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
928 | |
929 /* | |
930 * The gdk_flush() is just for making sure that the pointer really | |
931 * gets ungrabbed before calling any button callbacks | |
932 * | |
933 */ | |
934 | |
935 gdk_flush(); | |
936 | |
937 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
938 dock_move_release(GTK_WINDOW(mainwin)); | |
939 } | |
940 | |
941 if (mainwin_menurow->mr_doublesize_selected) { | |
942 event->x /= 2; | |
943 event->y /= 2; | |
944 } | |
945 | |
946 handle_release_cb(mainwin_wlist, widget, event); | |
947 | |
948 draw_main_window(FALSE); | |
949 | |
950 return FALSE; | |
951 } | |
952 | |
953 static gboolean | |
954 mainwin_motion(GtkWidget * widget, | |
955 GdkEventMotion * event, | |
956 gpointer callback_data) | |
957 { | |
958 XEvent ev; | |
959 gint i = 0; | |
960 | |
961 XSync(GDK_DISPLAY(), False); | |
962 | |
963 while (XCheckTypedEvent(GDK_DISPLAY(), MotionNotify, &ev)) { | |
964 event->x = ev.xmotion.x; | |
965 event->y = ev.xmotion.y; | |
966 i++; | |
967 } | |
968 | |
969 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
970 dock_move_motion(GTK_WINDOW(mainwin), event); | |
971 } | |
972 else { | |
973 handle_motion_cb(mainwin_wlist, widget, event); | |
974 draw_main_window(FALSE); | |
975 } | |
976 gdk_flush(); | |
977 | |
978 return FALSE; | |
979 } | |
980 | |
981 static gboolean | |
982 inside_sensitive_widgets(gint x, gint y) | |
983 { | |
984 return (widget_contains(WIDGET(mainwin_menubtn), x, y) | |
985 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
986 || widget_contains(WIDGET(mainwin_shade), x, y) | |
987 || widget_contains(WIDGET(mainwin_close), x, y) | |
988 || widget_contains(WIDGET(mainwin_rew), x, y) | |
989 || widget_contains(WIDGET(mainwin_play), x, y) | |
990 || widget_contains(WIDGET(mainwin_pause), x, y) | |
991 || widget_contains(WIDGET(mainwin_stop), x, y) | |
992 || widget_contains(WIDGET(mainwin_fwd), x, y) | |
993 || widget_contains(WIDGET(mainwin_eject), x, y) | |
994 || widget_contains(WIDGET(mainwin_shuffle), x, y) | |
995 || widget_contains(WIDGET(mainwin_repeat), x, y) | |
996 || widget_contains(WIDGET(mainwin_pl), x, y) | |
997 || widget_contains(WIDGET(mainwin_eq), x, y) | |
998 || widget_contains(WIDGET(mainwin_info), x, y) | |
999 || widget_contains(WIDGET(mainwin_menurow), x, y) | |
1000 || widget_contains(WIDGET(mainwin_volume), x, y) | |
1001 || widget_contains(WIDGET(mainwin_balance), x, y) | |
1002 || (widget_contains(WIDGET(mainwin_position), x, y) && | |
1003 widget_is_visible(WIDGET(mainwin_position))) | |
1004 || widget_contains(WIDGET(mainwin_minus_num), x, y) | |
1005 || widget_contains(WIDGET(mainwin_10min_num), x, y) | |
1006 || widget_contains(WIDGET(mainwin_min_num), x, y) | |
1007 || widget_contains(WIDGET(mainwin_10sec_num), x, y) | |
1008 || widget_contains(WIDGET(mainwin_sec_num), x, y) | |
1009 || widget_contains(WIDGET(mainwin_vis), x, y) | |
1010 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1011 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1012 || widget_contains(WIDGET(mainwin_close), x, y) | |
1013 || widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1014 || widget_contains(WIDGET(mainwin_sposition), x, y) | |
1015 || widget_contains(WIDGET(mainwin_stime_min), x, y) | |
1016 || widget_contains(WIDGET(mainwin_stime_sec), x, y) | |
1017 || widget_contains(WIDGET(mainwin_srew), x, y) | |
1018 || widget_contains(WIDGET(mainwin_splay), x, y) | |
1019 || widget_contains(WIDGET(mainwin_spause), x, y) | |
1020 || widget_contains(WIDGET(mainwin_sstop), x, y) | |
1021 || widget_contains(WIDGET(mainwin_sfwd), x, y) | |
1022 || widget_contains(WIDGET(mainwin_seject), x, y) | |
1023 || widget_contains(WIDGET(mainwin_svis), x, y) | |
1024 || widget_contains(WIDGET(mainwin_about), x, y)); | |
1025 } | |
1026 | |
1027 void | |
1028 mainwin_scrolled(GtkWidget * widget, | |
1029 GdkEventScroll * event, | |
1030 gpointer callback_data) | |
1031 { | |
1032 gint d = cfg.mouse_change; | |
1033 if (event->direction == GDK_SCROLL_DOWN) | |
1034 d *= -1; | |
1035 mainwin_set_volume_diff(d); | |
1036 } | |
1037 | |
1038 | |
1039 static gboolean | |
1040 mainwin_mouse_button_press(GtkWidget * widget, | |
1041 GdkEventButton * event, | |
1042 gpointer callback_data) | |
1043 { | |
1044 | |
1045 gboolean grab = TRUE; | |
1046 | |
1047 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1048 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) { | |
1049 if (0 && hint_move_resize_available()) { | |
1050 hint_move_resize(mainwin, event->x_root, event->y_root, TRUE); | |
1051 grab = FALSE; | |
1052 } | |
1053 else { | |
1054 gtk_window_present(GTK_WINDOW(mainwin)); | |
1055 dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, | |
1056 TRUE); | |
1057 } | |
1058 } | |
1059 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1060 event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) { | |
1061 mainwin_set_shade(!cfg.player_shaded); | |
1062 if (dock_is_moving(GTK_WINDOW(mainwin))) | |
1063 dock_move_release(GTK_WINDOW(mainwin)); | |
1064 } | |
1065 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1066 widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1067 playlist_fileinfo_current(); | |
1068 } | |
1069 else { | |
1070 handle_press_cb(mainwin_wlist, widget, event); | |
1071 draw_main_window(FALSE); | |
1072 } | |
1073 | |
1074 if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS && | |
1075 (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1076 widget_contains(WIDGET(mainwin_svis), event->x, event->y))) { | |
1077 | |
1078 cfg.vis_type++; | |
1079 | |
1080 if (cfg.vis_type > VIS_OFF) | |
1081 cfg.vis_type = VIS_ANALYZER; | |
1082 | |
1083 mainwin_vis_set_type(cfg.vis_type); | |
1084 } | |
1085 | |
1086 if (event->button == 3) { | |
1087 if (widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1088 util_item_factory_popup(mainwin_songname_menu, | |
1089 event->x_root, event->y_root, | |
1090 3, event->time); | |
1091 grab = FALSE; | |
1092 } | |
1093 else if (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1094 widget_contains(WIDGET(mainwin_svis), event->x, event->y)) { | |
1095 util_item_factory_popup(mainwin_vis_menu, event->x_root, | |
1096 event->y_root, 3, event->time); | |
1097 grab = FALSE; | |
1098 } | |
1099 else if ( (event->y > 70) && (event->x < 128) ) | |
1100 { | |
1101 | |
1102 util_item_factory_popup(mainwin_play_menu, | |
1103 event->x_root, | |
1104 event->y_root, 3, event->time); | |
1105 grab = FALSE; | |
1106 } else { | |
1107 /* | |
1108 * Pop up the main menu a few pixels down. | |
1109 * This will avoid that anything is selected | |
1110 * if one right-clicks to focus the window | |
1111 * without raising it. | |
1112 * | |
1113 ***MD I think the above is stupid, people don't expect this | |
1114 * | |
1115 */ | |
1116 util_item_factory_popup(mainwin_general_menu, | |
1117 event->x_root, | |
1118 event->y_root, 3, event->time); | |
1119 grab = FALSE; | |
1120 } | |
1121 } | |
1122 if (event->button == 1) { | |
1123 if ((event->x > 35 && event->x < 100 && | |
1124 event->y > 25 && event->y < 40) || | |
1125 widget_contains(WIDGET(mainwin_stime_min), event->x, event->y) || | |
1126 widget_contains(WIDGET(mainwin_stime_sec), event->x, event->y)) { | |
1127 | |
1128 if (cfg.timer_mode == TIMER_ELAPSED) | |
1129 set_timer_mode(TIMER_REMAINING); | |
1130 else | |
1131 set_timer_mode(TIMER_ELAPSED); | |
1132 } | |
1133 | |
1134 } | |
1135 | |
1136 if (grab) | |
1137 gdk_pointer_grab(mainwin->window, FALSE, | |
1138 GDK_BUTTON_MOTION_MASK | | |
1139 GDK_BUTTON_RELEASE_MASK, | |
1140 GDK_WINDOW(GDK_NONE), NULL, GDK_CURRENT_TIME); | |
1141 | |
1142 return FALSE; | |
1143 } | |
1144 | |
1145 static gboolean | |
1146 mainwin_focus_in(GtkWidget * window, | |
1147 GdkEventFocus * event, | |
1148 gpointer data) | |
1149 { | |
1150 mainwin_menubtn->pb_allow_draw = TRUE; | |
1151 mainwin_minimize->pb_allow_draw = TRUE; | |
1152 mainwin_shade->pb_allow_draw = TRUE; | |
1153 mainwin_close->pb_allow_draw = TRUE; | |
1154 draw_main_window(TRUE); | |
1155 | |
1156 return TRUE; | |
1157 } | |
1158 | |
1159 | |
1160 static gboolean | |
1161 mainwin_focus_out(GtkWidget * widget, | |
1162 GdkEventFocus * event, | |
1163 gpointer callback_data) | |
1164 { | |
1165 mainwin_menubtn->pb_allow_draw = FALSE; | |
1166 mainwin_minimize->pb_allow_draw = FALSE; | |
1167 mainwin_shade->pb_allow_draw = FALSE; | |
1168 mainwin_close->pb_allow_draw = FALSE; | |
1169 draw_main_window(TRUE); | |
1170 | |
1171 return TRUE; | |
1172 } | |
1173 | |
1174 static gboolean | |
1175 mainwin_keypress(GtkWidget * grab_widget, | |
1176 GdkEventKey * event, | |
1177 gpointer data) | |
1178 { | |
1179 | |
1180 switch (event->keyval) { | |
1181 | |
1182 case GDK_Up: | |
1183 case GDK_KP_Up: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1184 case GDK_KP_8: |
0 | 1185 mainwin_set_volume_diff(2); |
1186 break; | |
1187 case GDK_Down: | |
1188 case GDK_KP_Down: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1189 case GDK_KP_2: |
0 | 1190 mainwin_set_volume_diff(-2); |
1191 break; | |
1192 case GDK_Left: | |
1193 case GDK_KP_Left: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1194 case GDK_KP_7: |
0 | 1195 if (playlist_get_current_length() != -1) |
1196 bmp_playback_seek(CLAMP | |
1197 (bmp_playback_get_time() - 5000, 0, | |
1198 playlist_get_current_length()) / 1000); | |
1199 break; | |
1200 case GDK_Right: | |
1201 case GDK_KP_Right: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1202 case GDK_KP_9: |
0 | 1203 if (playlist_get_current_length() != -1) |
1204 bmp_playback_seek(CLAMP | |
1205 (bmp_playback_get_time() + 5000, 0, | |
1206 playlist_get_current_length()) / 1000); | |
1207 break; | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1208 case GDK_KP_4: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1209 playlist_prev(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1210 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1211 case GDK_KP_6: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1212 playlist_next(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1213 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1214 case GDK_KP_Insert: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1215 mainwin_jump_to_file(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1216 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1217 case GDK_KP_5: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1218 mainwin_play_pushed(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1219 break; |
0 | 1220 case GDK_Escape: |
1221 mainwin_minimize_cb(); | |
1222 break; | |
1223 default: | |
1224 return FALSE; | |
1225 } | |
1226 | |
1227 return TRUE; | |
1228 } | |
1229 | |
1230 static void | |
1231 mainwin_jump_to_time_cb(GtkWidget * widget, | |
1232 GtkWidget * entry) | |
1233 { | |
1234 guint min = 0, sec = 0, params, time; | |
1235 | |
1236 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u", | |
1237 &min, &sec); | |
1238 if (params == 2) | |
1239 time = (min * 60) + sec; | |
1240 else if (params == 1) | |
1241 time = min; | |
1242 else | |
1243 return; | |
1244 | |
1245 if (playlist_get_current_length() > -1 && | |
1246 time <= (playlist_get_current_length() / 1000)) { | |
1247 bmp_playback_seek(time); | |
1248 gtk_widget_destroy(mainwin_jtt); | |
1249 } | |
1250 } | |
1251 | |
1252 | |
1253 void | |
1254 mainwin_jump_to_time(void) | |
1255 { | |
1256 GtkWidget *vbox, *hbox_new, *hbox_total; | |
1257 GtkWidget *time_entry, *label, *bbox, *jump, *cancel; | |
1258 guint tindex; | |
1259 gchar time_str[10]; | |
1260 | |
1261 if (!bmp_playback_get_playing()) { | |
1262 /* FIXME: pop an error dialog and/or disable menu option to | |
1263 indicate JTT can't be launched when no track is being | |
1264 played */ | |
1265 return; | |
1266 } | |
1267 | |
1268 if (mainwin_jtt) { | |
1269 gtk_window_present(GTK_WINDOW(mainwin_jtt)); | |
1270 return; | |
1271 } | |
1272 | |
1273 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1274 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt), | |
1275 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1276 | |
1277 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time")); | |
1278 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER); | |
1279 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt), | |
1280 GTK_WINDOW(mainwin)); | |
1281 | |
1282 g_signal_connect(mainwin_jtt, "destroy", | |
1283 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt); | |
1284 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10); | |
1285 | |
1286 vbox = gtk_vbox_new(FALSE, 5); | |
1287 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox); | |
1288 | |
1289 hbox_new = gtk_hbox_new(FALSE, 0); | |
1290 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5); | |
1291 | |
1292 time_entry = gtk_entry_new(); | |
1293 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5); | |
1294 g_signal_connect(time_entry, "activate", | |
1295 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1296 | |
1297 gtk_widget_set_size_request(time_entry, 70, -1); | |
1298 label = gtk_label_new(_("minutes:seconds")); | |
1299 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5); | |
1300 | |
1301 hbox_total = gtk_hbox_new(FALSE, 0); | |
1302 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5); | |
1303 gtk_widget_show(hbox_total); | |
1304 | |
1305 /* FIXME: Disable display of current track length. It's not | |
1306 updated when track changes */ | |
1307 #if 0 | |
1308 label = gtk_label_new(_("Track length:")); | |
1309 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5); | |
1310 | |
1311 len = playlist_get_current_length() / 1000; | |
1312 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60); | |
1313 label = gtk_label_new(time_str); | |
1314 | |
1315 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10); | |
1316 #endif | |
1317 | |
1318 bbox = gtk_hbutton_box_new(); | |
1319 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); | |
1320 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1321 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1322 | |
1323 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1324 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1325 gtk_container_add(GTK_CONTAINER(bbox), cancel); | |
1326 g_signal_connect_swapped(cancel, "clicked", | |
1327 G_CALLBACK(gtk_widget_destroy), mainwin_jtt); | |
1328 | |
1329 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1330 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1331 gtk_container_add(GTK_CONTAINER(bbox), jump); | |
1332 g_signal_connect(jump, "clicked", | |
1333 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1334 | |
1335 tindex = bmp_playback_get_time() / 1000; | |
1336 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60, | |
1337 tindex % 60); | |
1338 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str); | |
1339 | |
1340 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str)); | |
1341 | |
1342 gtk_widget_show_all(mainwin_jtt); | |
1343 | |
1344 gtk_widget_grab_focus(time_entry); | |
1345 gtk_widget_grab_default(jump); | |
1346 } | |
1347 | |
1348 static void | |
1349 change_song(guint pos) | |
1350 { | |
1351 if (bmp_playback_get_playing()) | |
1352 bmp_playback_stop(); | |
1353 | |
1354 playlist_set_position(pos); | |
1355 bmp_playback_initiate(); | |
1356 } | |
1357 | |
1358 static void | |
1359 mainwin_jump_to_file_jump(GtkTreeView * treeview) | |
1360 { | |
1361 GtkTreeModel *model; | |
1362 GtkTreeSelection *selection; | |
1363 GtkTreeIter iter; | |
1364 gchar *pos_str; | |
1365 guint pos; | |
1366 | |
1367 model = gtk_tree_view_get_model(treeview); | |
1368 selection = gtk_tree_view_get_selection(treeview); | |
1369 | |
1370 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1371 return; | |
1372 | |
1373 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1374 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1375 | |
1376 change_song(pos); | |
1377 | |
1378 /* FIXME: should only hide window */ | |
1379 gtk_widget_destroy(mainwin_jtf); | |
1380 mainwin_jtf = NULL; | |
1381 } | |
1382 | |
1383 static void | |
1384 mainwin_jump_to_file_jump_cb(GtkTreeView * treeview, | |
1385 gpointer data) | |
1386 { | |
1387 mainwin_jump_to_file_jump(treeview); | |
1388 } | |
1389 | |
1390 static void | |
1391 mainwin_jump_to_file_set_queue_button_label(GtkButton * button, | |
1392 guint pos) | |
1393 { | |
1394 if (playlist_is_position_queued(pos)) | |
1395 gtk_button_set_label(button, _("Un_queue")); | |
1396 else | |
1397 gtk_button_set_label(button, _("_Queue")); | |
1398 } | |
1399 | |
1400 static void | |
1401 mainwin_jump_to_file_queue_cb(GtkButton * button, | |
1402 gpointer data) | |
1403 { | |
1404 GtkTreeView *treeview; | |
1405 GtkTreeModel *model; | |
1406 GtkTreeSelection *selection; | |
1407 GtkTreeIter iter; | |
1408 gchar *pos_str; | |
1409 guint pos; | |
1410 | |
1411 treeview = GTK_TREE_VIEW(data); | |
1412 model = gtk_tree_view_get_model(treeview); | |
1413 selection = gtk_tree_view_get_selection(treeview); | |
1414 | |
1415 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1416 return; | |
1417 | |
1418 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1419 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1420 | |
1421 playlist_queue_position(pos); | |
1422 | |
1423 mainwin_jump_to_file_set_queue_button_label(button, pos); | |
1424 } | |
1425 | |
1426 static void | |
1427 mainwin_jump_to_file_selection_changed_cb(GtkTreeSelection *treesel, | |
1428 gpointer data) | |
1429 { | |
1430 GtkTreeView *treeview; | |
1431 GtkTreeModel *model; | |
1432 GtkTreeSelection *selection; | |
1433 GtkTreeIter iter; | |
1434 gchar *pos_str; | |
1435 guint pos; | |
1436 | |
1437 treeview = gtk_tree_selection_get_tree_view(treesel); | |
1438 model = gtk_tree_view_get_model(treeview); | |
1439 selection = gtk_tree_view_get_selection(treeview); | |
1440 | |
1441 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1442 return; | |
1443 | |
1444 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1445 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1446 | |
1447 mainwin_jump_to_file_set_queue_button_label(GTK_BUTTON(data), pos); | |
1448 } | |
1449 | |
1450 static gboolean | |
1451 mainwin_jump_to_file_keypress_cb(GtkWidget * object, | |
1452 GdkEventKey * event, | |
1453 gpointer data) | |
1454 { | |
1455 switch (event->keyval) { | |
1456 case GDK_Escape: | |
1457 /* FIXME: show only hide window */ | |
1458 gtk_widget_destroy(mainwin_jtf); | |
1459 mainwin_jtf = NULL; | |
1460 return TRUE; | |
1461 case GDK_Return: | |
1462 mainwin_jump_to_file_jump(GTK_TREE_VIEW(data)); | |
1463 return TRUE; | |
1464 default: | |
1465 return FALSE; | |
1466 }; | |
1467 } | |
1468 | |
1469 static gboolean | |
1470 mainwin_jump_to_file_match(const gchar * song, gchar ** keys) | |
1471 { | |
1472 gint i = 0; | |
1473 gchar *key; | |
1474 gchar *song_lc; | |
1475 | |
1476 song_lc = g_ascii_strdown(song, -1); | |
1477 | |
1478 while (keys[i]) { | |
1479 key = g_ascii_strdown(keys[i], -1); | |
1480 if (!g_strrstr(song_lc, key)) { | |
1481 g_free(key); | |
1482 g_free(song_lc); | |
1483 return FALSE; | |
1484 } | |
1485 | |
1486 g_free(key); | |
1487 i++; | |
1488 } | |
1489 | |
1490 g_free(song_lc); | |
1491 | |
1492 return TRUE; | |
1493 } | |
1494 | |
1495 /* FIXME: Clear the entry when the list gets updated */ | |
1496 static void | |
1497 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
1498 { | |
1499 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
1500 * reading */ | |
1501 gint row; | |
1502 GList *playlist; | |
1503 gchar *desc_buf; | |
1504 gchar *row_str; | |
1505 GtkTreeIter iter; | |
1506 GtkTreeSelection *selection; | |
1507 | |
1508 GtkTreeModel *store; | |
1509 | |
1510 if (!mainwin_jtf) | |
1511 return; | |
1512 | |
1513 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
1514 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1515 | |
1516 row = 1; | |
1517 for (playlist = playlist_get(); playlist; | |
1518 playlist = g_list_next(playlist)) { | |
1519 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1520 | |
1521 if (entry->title) | |
1522 desc_buf = entry->title; | |
1523 else if (strchr(entry->filename, '/')) | |
1524 desc_buf = strrchr(entry->filename, '/') + 1; | |
1525 else | |
1526 desc_buf = entry->filename; | |
1527 | |
1528 row_str = g_strdup_printf("%d", row++); | |
1529 | |
1530 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
1531 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
1532 0, row_str, 1, desc_buf, -1); | |
1533 | |
1534 g_free(row_str); | |
1535 } | |
1536 | |
1537 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1538 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
1539 gtk_tree_selection_select_iter(selection, &iter); | |
1540 } | |
1541 | |
1542 static void | |
1543 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
1544 { | |
1545 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
1546 GtkTreeSelection *selection; | |
1547 GtkTreeIter iter; | |
1548 | |
1549 GtkListStore *store; | |
1550 | |
1551 gint song_index = 0; | |
1552 gchar **words; | |
1553 GList *playlist; | |
1554 | |
1555 gboolean match = FALSE; | |
1556 | |
1557 /* Chop the key string into ' '-separated key words */ | |
1558 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
1559 | |
1560 /* FIXME: Remove the connected signals before clearing | |
1561 * (row-selected will still eventually arrive once) */ | |
1562 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
1563 gtk_list_store_clear(store); | |
1564 | |
1565 PLAYLIST_LOCK(); | |
1566 | |
1567 for (playlist = playlist_get(); playlist; | |
1568 playlist = g_list_next(playlist)) { | |
1569 | |
1570 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1571 const gchar *title, *filename; | |
1572 | |
1573 title = entry->title; | |
1574 if (!title) { | |
1575 filename = entry->filename; | |
1576 | |
1577 if (strchr(filename, '/')) | |
1578 title = strrchr(filename, '/') + 1; | |
1579 else | |
1580 title = filename; | |
1581 } | |
1582 | |
1583 /* Compare the key words to the string - if all the words | |
1584 match, add to the ListStore */ | |
1585 | |
1586 /* | |
1587 * FIXME: The search string should be adapted to the | |
1588 * current display setting, e.g. if the user has set it to | |
1589 * "%p - %t" then build the match string like that too, or | |
1590 * even better, search for each of the tags seperatly. | |
1591 * | |
1592 * In any case the string to match should _never_ contain | |
1593 * something the user can't actually see in the playlist. | |
1594 */ | |
1595 if (words[0]) | |
1596 match = mainwin_jump_to_file_match(title, words); | |
1597 else | |
1598 match = TRUE; | |
1599 | |
1600 if (match) { | |
1601 gchar *song_index_str = g_strdup_printf("%d", song_index + 1); | |
1602 gtk_list_store_append(store, &iter); | |
1603 gtk_list_store_set(store, &iter, 0, song_index_str, 1, title, -1); | |
1604 g_free(song_index_str); | |
1605 } | |
1606 | |
1607 song_index++; | |
1608 } | |
1609 | |
1610 PLAYLIST_UNLOCK(); | |
1611 | |
1612 g_strfreev(words); | |
1613 | |
1614 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
1615 selection = gtk_tree_view_get_selection(treeview); | |
1616 gtk_tree_selection_select_iter(selection, &iter); | |
1617 } | |
1618 } | |
1619 | |
1620 void | |
1621 mainwin_jump_to_file(void) | |
1622 { | |
1623 GtkWidget *scrollwin; | |
1624 GtkWidget *vbox, *bbox, *sep; | |
1625 GtkWidget *jump, *queue, *cancel; | |
1626 GtkWidget *rescan, *edit; | |
1627 GtkWidget *search_label, *hbox; | |
1628 GList *playlist; | |
1629 gchar *desc_buf; | |
1630 gchar *row_str; | |
1631 gint row; | |
1632 | |
1633 GtkWidget *treeview; | |
1634 GtkListStore *jtf_store; | |
1635 | |
1636 GtkTreeIter iter; | |
1637 GtkCellRenderer *renderer; | |
1638 GtkTreeViewColumn *column; | |
1639 | |
1640 if (mainwin_jtf) { | |
1641 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
1642 return; | |
1643 } | |
1644 | |
1645 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1646 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
1647 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1648 | |
1649 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
1650 | |
1651 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
1652 g_signal_connect(mainwin_jtf, "destroy", | |
1653 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
1654 | |
1655 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
1656 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
1657 | |
1658 vbox = gtk_vbox_new(FALSE, 5); | |
1659 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
1660 | |
1661 jtf_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
1662 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
1663 g_object_unref(jtf_store); | |
1664 | |
1665 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
1666 | |
1667 column = gtk_tree_view_column_new(); | |
1668 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
1669 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1670 | |
1671 renderer = gtk_cell_renderer_text_new(); | |
1672 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1673 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
1674 gtk_tree_view_column_set_spacing(column, 4); | |
1675 | |
1676 renderer = gtk_cell_renderer_text_new(); | |
1677 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1678 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
1679 gtk_tree_view_column_set_spacing(column, 4); | |
1680 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
1681 | |
1682 g_signal_connect(treeview, "row-activated", | |
1683 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
1684 | |
1685 hbox = gtk_hbox_new(FALSE, 3); | |
1686 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
1687 | |
1688 search_label = gtk_label_new(_("Filter: ")); | |
1689 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), "_Filter:"); | |
1690 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
1691 | |
1692 edit = gtk_entry_new(); | |
1693 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
1694 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
1695 g_signal_connect(edit, "changed", | |
1696 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
1697 | |
1698 g_signal_connect(mainwin_jtf, "key_press_event", | |
1699 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
1700 | |
1701 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
1702 | |
1703 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
1704 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
1705 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
1706 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1707 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
1708 GTK_SHADOW_IN); | |
1709 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
1710 | |
1711 sep = gtk_hseparator_new(); | |
1712 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
1713 | |
1714 bbox = gtk_hbutton_box_new(); | |
1715 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1716 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1717 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1718 | |
1719 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
1720 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
1721 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
1722 g_signal_connect(queue, "clicked", | |
1723 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
1724 treeview); | |
1725 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
1726 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
1727 queue); | |
1728 | |
1729 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
1730 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
1731 g_signal_connect(rescan, "clicked", | |
1732 G_CALLBACK(mainwin_update_jtf), treeview); | |
1733 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
1734 gtk_widget_grab_default(rescan); | |
1735 | |
1736 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1737 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
1738 | |
1739 g_signal_connect_swapped(jump, "clicked", | |
1740 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
1741 treeview); | |
1742 | |
1743 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1744 gtk_widget_grab_default(jump); | |
1745 | |
1746 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
1747 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
1748 g_signal_connect_swapped(cancel, "clicked", | |
1749 G_CALLBACK(gtk_widget_destroy), | |
1750 mainwin_jtf); | |
1751 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1752 | |
1753 gtk_list_store_clear(jtf_store); | |
1754 | |
1755 row = 1; | |
1756 | |
1757 PLAYLIST_LOCK(); | |
1758 | |
1759 for (playlist = playlist_get(); playlist; | |
1760 playlist = g_list_next(playlist)) { | |
1761 | |
1762 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1763 | |
1764 if (entry->title) | |
1765 desc_buf = entry->title; | |
1766 else if (strchr(entry->filename, '/')) | |
1767 desc_buf = strrchr(entry->filename, '/') + 1; | |
1768 else | |
1769 desc_buf = entry->filename; | |
1770 | |
1771 row_str = g_strdup_printf("%d", row++); | |
1772 | |
1773 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
1774 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
1775 0, row_str, 1, desc_buf, -1); | |
1776 | |
1777 g_free(row_str); | |
1778 } | |
1779 | |
1780 PLAYLIST_UNLOCK(); | |
1781 | |
1782 gtk_widget_show_all(mainwin_jtf); | |
1783 } | |
1784 | |
1785 static gboolean | |
1786 mainwin_configure(GtkWidget * window, | |
1787 GdkEventConfigure * event, | |
1788 gpointer data) | |
1789 { | |
1790 if (!GTK_WIDGET_VISIBLE(window)) | |
1791 return FALSE; | |
1792 | |
1793 if (cfg.show_wm_decorations) | |
1794 gdk_window_get_root_origin(window->window, | |
1795 &cfg.player_x, &cfg.player_y); | |
1796 else | |
1797 gdk_window_get_deskrelative_origin(window->window, | |
1798 &cfg.player_x, &cfg.player_y); | |
1799 return FALSE; | |
1800 } | |
1801 | |
1802 void | |
1803 mainwin_set_back_pixmap(void) | |
1804 { | |
1805 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
1806 gdk_window_clear(mainwin->window); | |
1807 } | |
1808 | |
1809 void | |
1810 mainwin_drag_data_received(GtkWidget * widget, | |
1811 GdkDragContext * context, | |
1812 gint x, | |
1813 gint y, | |
1814 GtkSelectionData * selection_data, | |
1815 guint info, | |
1816 guint time, | |
1817 gpointer user_data) | |
1818 { | |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1819 gchar **sourcelist, *path; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1820 gchar *decoded; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1821 gboolean not_font = FALSE; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1822 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1823 if (!selection_data->data) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1824 { |
0 | 1825 g_warning("DND data string is NULL"); |
1826 return; | |
1827 } | |
1828 | |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1829 sourcelist = g_strsplit((gchar *)(selection_data->data),"\r\n",-1); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1830 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1831 for (path = *sourcelist; *path; path = *(++sourcelist)) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1832 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1833 if (str_has_prefix_nocase(path, "fonts:///")) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1834 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1835 path += 8; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1836 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1837 /* plain, since we already stripped the first URI part */ |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1838 decoded = xmms_urldecode_plain(path); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1839 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1840 /* Get the old font's size, and add it to the dropped |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1841 * font's name |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1842 */ |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1843 cfg.playlist_font = g_strconcat(decoded + 1, |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1844 strrchr(cfg.playlist_font, ' '), |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1845 NULL); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1846 playlist_list_set_font(cfg.playlist_font); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1847 playlistwin_update_list(); |
0 | 1848 |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1849 g_free(decoded); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1850 return; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1851 } |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1852 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1853 if (str_has_prefix_nocase(path,"file:///")) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1854 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1855 if (not_font == FALSE) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1856 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1857 playlist_clear(); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1858 not_font = TRUE; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1859 } |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1860 playlist_add_url(path); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1861 } |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1862 |
0 | 1863 } |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1864 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1865 g_strfreev(sourcelist); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1866 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1867 if (not_font) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1868 bmp_playback_initiate(); |
0 | 1869 } |
1870 | |
1871 static void | |
1872 dirbrowser_add_dir(const gchar * dir) | |
1873 { | |
1874 g_free(cfg.filesel_path); | |
1875 cfg.filesel_path = g_strdup(dir); | |
1876 playlist_add_dir(dir); | |
1877 } | |
1878 | |
1879 static void | |
1880 dirbrowser_on_response(GtkFileChooserDialog * dialog, | |
1881 gint result, | |
1882 gpointer data) | |
1883 { | |
1884 | |
1885 gchar *pathname; | |
1886 | |
1887 // gtk_widget_hide(GTK_WIDGET(dialog)); | |
1888 | |
1889 switch (result) { | |
1890 case GTK_RESPONSE_ACCEPT: | |
1891 pathname = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
1892 dirbrowser_add_dir(pathname); | |
1893 g_free(pathname); | |
1894 break; | |
1895 | |
1896 case GTK_RESPONSE_CLOSE: | |
1897 break; | |
1898 } | |
1899 | |
1900 } | |
1901 | |
1902 | |
1903 static GtkWidget * | |
1904 dirbrowser_new(const gchar * path) | |
1905 { | |
1906 GtkWidget *dialog; | |
1907 | |
1908 dialog = gtk_file_chooser_dialog_new(_("Add Folders"), | |
1909 GTK_WINDOW(mainwin), | |
1910 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, | |
1911 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
1912 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1913 NULL); | |
1914 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); | |
1915 | |
1916 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | |
1917 path); | |
1918 g_signal_connect(dialog, "response", | |
1919 G_CALLBACK(dirbrowser_on_response), | |
1920 NULL); | |
1921 | |
1922 return dialog; | |
1923 } | |
1924 | |
1925 void | |
1926 mainwin_run_dirbrowser(void) | |
1927 { | |
1928 static GtkWidget *browser = NULL; | |
1929 | |
1930 if (!browser) { | |
1931 browser = dirbrowser_new(cfg.filesel_path); | |
1932 | |
1933 g_signal_connect(browser, "destroy", | |
1934 G_CALLBACK(gtk_widget_destroyed), | |
1935 &browser); | |
1936 | |
1937 gtk_widget_show(GTK_WIDGET(browser)); | |
1938 } | |
1939 | |
1940 gtk_window_present(GTK_WINDOW(browser)); | |
1941 } | |
1942 | |
1943 static void | |
1944 on_add_url_add_clicked(GtkWidget * widget, | |
1945 GtkWidget * entry) | |
1946 { | |
1947 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1948 if (text && *text) | |
1949 playlist_add_url(text); | |
1950 } | |
1951 | |
86 | 1952 static void |
1953 on_add_url_ok_clicked(GtkWidget * widget, | |
1954 GtkWidget * entry) | |
1955 { | |
1956 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1957 if (text && *text) | |
1958 { | |
1959 playlist_clear(); | |
1960 playlist_add_url(text); | |
1961 bmp_playback_initiate(); | |
1962 } | |
1963 } | |
1964 | |
0 | 1965 void |
1966 mainwin_show_add_url_window(void) | |
1967 { | |
1968 static GtkWidget *url_window = NULL; | |
1969 | |
1970 if (!url_window) { | |
1971 url_window = | |
86 | 1972 util_add_url_dialog_new(_("Enter location to play:"), |
1973 G_CALLBACK(on_add_url_ok_clicked), | |
0 | 1974 G_CALLBACK(on_add_url_add_clicked)); |
1975 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
1976 GTK_WINDOW(mainwin)); | |
1977 g_signal_connect(url_window, "destroy", | |
1978 G_CALLBACK(gtk_widget_destroyed), | |
1979 &url_window); | |
1980 } | |
1981 | |
1982 gtk_window_present(GTK_WINDOW(url_window)); | |
1983 } | |
1984 | |
1985 static void | |
1986 check_set(GtkItemFactory * factory, | |
1987 const gchar * path, | |
1988 gboolean active) | |
1989 { | |
1990 GtkWidget *item = gtk_item_factory_get_widget(factory, path); | |
1991 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active); | |
1992 } | |
1993 | |
1994 void | |
1995 mainwin_eject_pushed(void) | |
1996 { | |
1997 util_run_filebrowser(PLAY_BUTTON); | |
1998 } | |
1999 | |
2000 void | |
2001 mainwin_play_pushed(void) | |
2002 { | |
2003 if (bmp_playback_get_paused()) { | |
2004 bmp_playback_pause(); | |
2005 return; | |
2006 } | |
2007 | |
2008 if (playlist_get_length()) | |
2009 bmp_playback_initiate(); | |
2010 else | |
2011 mainwin_eject_pushed(); | |
2012 } | |
2013 | |
2014 void | |
2015 mainwin_stop_pushed(void) | |
2016 { | |
2017 mainwin_clear_song_info(); | |
2018 bmp_playback_stop(); | |
2019 } | |
2020 | |
2021 void | |
2022 mainwin_shuffle_pushed(gboolean toggled) | |
2023 { | |
2024 check_set(mainwin_play_menu, "/Shuffle", toggled); | |
2025 } | |
2026 | |
2027 void | |
2028 mainwin_repeat_pushed(gboolean toggled) | |
2029 { | |
2030 check_set(mainwin_play_menu, "/Repeat", toggled); | |
2031 } | |
2032 | |
2033 void | |
2034 mainwin_pl_pushed(gboolean toggled) | |
2035 { | |
2036 if (toggled) | |
2037 playlistwin_show(); | |
2038 else | |
2039 playlistwin_hide(); | |
2040 } | |
2041 | |
2042 gint | |
2043 mainwin_spos_frame_cb(gint pos) | |
2044 { | |
2045 if (mainwin_sposition) { | |
2046 if (pos < 6) | |
2047 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2048 17; | |
2049 else if (pos < 9) | |
2050 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2051 20; | |
2052 else | |
2053 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2054 23; | |
2055 } | |
2056 return 1; | |
2057 } | |
2058 | |
2059 void | |
2060 mainwin_spos_motion_cb(gint pos) | |
2061 { | |
2062 gint time; | |
2063 gchar *time_msg; | |
2064 | |
2065 pos--; | |
2066 | |
2067 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
2068 | |
2069 if (cfg.timer_mode == TIMER_REMAINING) { | |
2070 time = (playlist_get_current_length() / 1000) - time; | |
2071 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
2072 textbox_set_text(mainwin_stime_min, time_msg); | |
2073 g_free(time_msg); | |
2074 } | |
2075 else { | |
2076 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
2077 textbox_set_text(mainwin_stime_min, time_msg); | |
2078 g_free(time_msg); | |
2079 } | |
2080 | |
2081 time_msg = g_strdup_printf("%2.2d", time % 60); | |
2082 textbox_set_text(mainwin_stime_sec, time_msg); | |
2083 g_free(time_msg); | |
2084 } | |
2085 | |
2086 void | |
2087 mainwin_spos_release_cb(gint pos) | |
2088 { | |
2089 bmp_playback_seek(((playlist_get_current_length() / 1000) * | |
2090 (pos - 1)) / 12); | |
2091 } | |
2092 | |
2093 void | |
2094 mainwin_position_motion_cb(gint pos) | |
2095 { | |
2096 gint length, time; | |
2097 gchar *seek_msg; | |
2098 | |
2099 length = playlist_get_current_length() / 1000; | |
2100 time = (length * pos) / 219; | |
2101 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
2102 time / 60, time % 60, | |
2103 length / 60, length % 60, | |
2104 (length != 0) ? (time * 100) / length : 0); | |
2105 mainwin_lock_info_text(seek_msg); | |
2106 g_free(seek_msg); | |
2107 } | |
2108 | |
2109 void | |
2110 mainwin_position_release_cb(gint pos) | |
2111 { | |
2112 gint length, time; | |
2113 | |
2114 length = playlist_get_current_length() / 1000; | |
2115 time = (length * pos) / 219; | |
2116 bmp_playback_seek(time); | |
2117 mainwin_release_info_text(); | |
2118 } | |
2119 | |
2120 gint | |
2121 mainwin_volume_frame_cb(gint pos) | |
2122 { | |
2123 return (gint) rint((pos / 52.0) * 28); | |
2124 } | |
2125 | |
2126 void | |
2127 mainwin_adjust_volume_motion(gint v) | |
2128 { | |
2129 gchar *volume_msg; | |
2130 | |
2131 setting_volume = TRUE; | |
2132 | |
2133 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2134 mainwin_lock_info_text(volume_msg); | |
2135 g_free(volume_msg); | |
2136 | |
2137 if (balance < 0) | |
2138 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
2139 else if (balance > 0) | |
2140 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
2141 else | |
2142 input_set_volume(v, v); | |
2143 } | |
2144 | |
2145 void | |
2146 mainwin_adjust_volume_release(void) | |
2147 { | |
2148 mainwin_release_info_text(); | |
2149 setting_volume = FALSE; | |
2150 read_volume(VOLUME_ADJUSTED); | |
2151 } | |
2152 | |
2153 void | |
2154 mainwin_adjust_balance_motion(gint b) | |
2155 { | |
2156 gchar *balance_msg; | |
2157 gint v, pvl, pvr; | |
2158 | |
2159 setting_volume = TRUE; | |
2160 balance = b; | |
2161 input_get_volume(&pvl, &pvr); | |
2162 v = MAX(pvl, pvr); | |
2163 if (b < 0) { | |
2164 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2165 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
2166 } | |
2167 else if (b == 0) { | |
2168 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
2169 input_set_volume(v, v); | |
2170 } | |
2171 else { /* b > 0 */ | |
2172 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2173 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
2174 } | |
2175 mainwin_lock_info_text(balance_msg); | |
2176 g_free(balance_msg); | |
2177 } | |
2178 | |
2179 void | |
2180 mainwin_adjust_balance_release(void) | |
2181 { | |
2182 mainwin_release_info_text(); | |
2183 setting_volume = FALSE; | |
2184 read_volume(VOLUME_ADJUSTED); | |
2185 } | |
2186 | |
2187 void | |
2188 mainwin_set_volume_slider(gint percent) | |
2189 { | |
2190 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
2191 } | |
2192 | |
2193 void | |
2194 mainwin_set_balance_slider(gint percent) | |
2195 { | |
2196 hslider_set_position(mainwin_balance, | |
2197 (gint) rint(((percent * 12) / 100.0) + 12)); | |
2198 } | |
2199 | |
2200 void | |
2201 mainwin_volume_motion_cb(gint pos) | |
2202 { | |
2203 gint vol = (pos * 100) / 51; | |
2204 mainwin_adjust_volume_motion(vol); | |
2205 equalizerwin_set_volume_slider(vol); | |
2206 } | |
2207 | |
2208 void | |
2209 mainwin_volume_release_cb(gint pos) | |
2210 { | |
2211 mainwin_adjust_volume_release(); | |
2212 } | |
2213 | |
2214 gint | |
2215 mainwin_balance_frame_cb(gint pos) | |
2216 { | |
2217 return ((abs(pos - 12) * 28) / 13); | |
2218 } | |
2219 | |
2220 void | |
2221 mainwin_balance_motion_cb(gint pos) | |
2222 { | |
2223 gint bal = ((pos - 12) * 100) / 12; | |
2224 mainwin_adjust_balance_motion(bal); | |
2225 equalizerwin_set_balance_slider(bal); | |
2226 } | |
2227 | |
2228 void | |
2229 mainwin_balance_release_cb(gint pos) | |
2230 { | |
2231 mainwin_adjust_volume_release(); | |
2232 } | |
2233 | |
2234 void | |
2235 mainwin_set_volume_diff(gint diff) | |
2236 { | |
2237 gint vl, vr, vol; | |
2238 | |
2239 input_get_volume(&vl, &vr); | |
2240 vol = MAX(vl, vr); | |
2241 vol = CLAMP(vol + diff, 0, 100); | |
2242 | |
2243 mainwin_adjust_volume_motion(vol); | |
2244 setting_volume = FALSE; | |
2245 mainwin_set_volume_slider(vol); | |
2246 equalizerwin_set_volume_slider(vol); | |
2247 read_volume(VOLUME_SET); | |
2248 } | |
2249 | |
2250 void | |
2251 mainwin_set_balance_diff(gint diff) | |
2252 { | |
2253 gint b; | |
2254 b = CLAMP(balance + diff, -100, 100); | |
2255 mainwin_adjust_balance_motion(b); | |
2256 setting_volume = FALSE; | |
2257 mainwin_set_balance_slider(b); | |
2258 equalizerwin_set_balance_slider(b); | |
2259 read_volume(VOLUME_SET); | |
2260 } | |
2261 | |
2262 void | |
2263 mainwin_show(gboolean show) | |
2264 { | |
2265 if (show) | |
2266 mainwin_real_show(); | |
2267 else | |
2268 mainwin_real_hide(); | |
2269 } | |
2270 | |
2271 void | |
2272 mainwin_real_show(void) | |
2273 { | |
2274 cfg.player_visible = TRUE; | |
2275 | |
2276 if (cfg.player_shaded) | |
2277 vis_clear_data(active_vis); | |
2278 | |
2279 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
2280 mainwin_set_shape_mask(); | |
2281 | |
2282 if (cfg.show_wm_decorations) { | |
2283 if (!pposition_broken && cfg.player_x != -1 | |
2284 && cfg.save_window_position) | |
2285 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2286 | |
2287 gtk_widget_show(mainwin); | |
2288 | |
2289 if (pposition_broken && cfg.player_x != -1 | |
2290 && cfg.save_window_position) | |
2291 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2292 | |
2293 return; | |
2294 } | |
2295 | |
2296 gtk_widget_show_all(mainwin); | |
2297 | |
2298 if (!nullmask) | |
2299 return; | |
2300 | |
2301 g_object_unref(nullmask); | |
2302 nullmask = NULL; | |
2303 | |
2304 gdk_window_set_hints(mainwin->window, 0, 0, | |
2305 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2306 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2307 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2308 gtk_window_resize(GTK_WINDOW(mainwin), PLAYER_WIDTH, PLAYER_HEIGHT); | |
2309 | |
2310 if (cfg.player_x != -1 && cfg.player_y != -1) | |
2311 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2312 | |
2313 draw_main_window(TRUE); | |
2314 | |
2315 gtk_window_present(GTK_WINDOW(mainwin)); | |
2316 } | |
2317 | |
2318 void | |
2319 mainwin_real_hide(void) | |
2320 { | |
2321 GdkGC *gc; | |
2322 GdkColor pattern; | |
2323 | |
2324 if (cfg.player_shaded) { | |
2325 svis_clear_data(mainwin_svis); | |
2326 vis_clear_data(playlistwin_vis); | |
2327 } | |
2328 | |
2329 if (!cfg.show_wm_decorations) { | |
2330 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
2331 gc = gdk_gc_new(nullmask); | |
2332 pattern.pixel = 0; | |
2333 gdk_gc_set_foreground(gc, &pattern); | |
2334 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
2335 gdk_gc_destroy(gc); | |
2336 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
2337 | |
2338 gdk_window_set_hints(mainwin->window, 0, 0, 0, 0, 0, 0, | |
2339 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2340 gdk_window_resize(mainwin->window, 0, 0); | |
2341 } | |
2342 | |
2343 gtk_widget_hide(mainwin); | |
2344 | |
2345 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
2346 cfg.player_visible = FALSE; | |
2347 } | |
2348 | |
2349 static void | |
2350 mainwin_songname_menu_callback(gpointer data, | |
2351 guint action, | |
2352 GtkWidget * item) | |
2353 { | |
2354 GtkCheckMenuItem *check; | |
2355 | |
2356 switch (action) { | |
2357 case MAINWIN_SONGNAME_FILEINFO: | |
2358 playlist_fileinfo_current(); | |
2359 break; | |
2360 case MAINWIN_SONGNAME_JTF: | |
2361 mainwin_jump_to_file(); | |
2362 break; | |
2363 case MAINWIN_SONGNAME_JTT: | |
2364 mainwin_jump_to_time(); | |
2365 break; | |
2366 case MAINWIN_SONGNAME_SCROLL: | |
2367 check = GTK_CHECK_MENU_ITEM(item); | |
2368 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
2369 break; | |
2370 } | |
2371 } | |
2372 | |
2373 static void | |
2374 mainwin_play_menu_callback(gpointer data, | |
2375 guint action, | |
2376 GtkWidget * item) | |
2377 { | |
2378 GtkCheckMenuItem *check; | |
2379 | |
2380 switch (action) { | |
2381 case MAINWIN_OPT_SHUFFLE: | |
2382 check = GTK_CHECK_MENU_ITEM(item); | |
2383 cfg.shuffle = gtk_check_menu_item_get_active(check); | |
2384 playlist_set_shuffle(cfg.shuffle); | |
2385 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
2386 break; | |
2387 case MAINWIN_OPT_REPEAT: | |
2388 check = GTK_CHECK_MENU_ITEM(item); | |
2389 cfg.repeat = gtk_check_menu_item_get_active(check); | |
2390 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
2391 break; | |
2392 case MAINWIN_OPT_NPA: | |
2393 check = GTK_CHECK_MENU_ITEM(item); | |
2394 cfg.no_playlist_advance = gtk_check_menu_item_get_active(check); | |
2395 break; | |
2396 } | |
2397 } | |
2398 | |
2399 | |
2400 static void | |
2401 mainwin_view_menu_callback(gpointer data, | |
2402 guint action, | |
2403 GtkWidget * item) | |
2404 { | |
2405 switch (action) { | |
2406 case MAINWIN_OPT_TELAPSED: | |
2407 set_timer_mode_menu_cb(TIMER_ELAPSED); | |
2408 break; | |
2409 case MAINWIN_OPT_TREMAINING: | |
2410 set_timer_mode_menu_cb(TIMER_REMAINING); | |
2411 break; | |
2412 case MAINWIN_OPT_ALWAYS: | |
2413 mainwin_menurow->mr_always_selected = GTK_CHECK_MENU_ITEM(item)->active; | |
2414 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
2415 widget_draw(WIDGET(mainwin_menurow)); | |
2416 hint_set_always(cfg.always_on_top); | |
2417 break; | |
2418 case MAINWIN_OPT_STICKY: | |
2419 cfg.sticky = GTK_CHECK_MENU_ITEM(item)->active; | |
2420 hint_set_sticky(cfg.sticky); | |
2421 break; | |
2422 case MAINWIN_OPT_WS: | |
2423 mainwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2424 break; | |
2425 case MAINWIN_OPT_PWS: | |
2426 playlistwin_set_shade(GTK_CHECK_MENU_ITEM(item)->active); | |
2427 break; | |
2428 case MAINWIN_OPT_EQWS: | |
2429 equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2430 break; | |
2431 } | |
2432 } | |
2433 | |
2434 void | |
2435 mainwin_vis_menu_callback(gpointer data, | |
2436 guint action, | |
2437 GtkWidget * item) | |
2438 { | |
2439 switch (action) { | |
2440 case MAINWIN_VIS_ANALYZER: | |
2441 case MAINWIN_VIS_SCOPE: | |
2442 case MAINWIN_VIS_OFF: | |
2443 mainwin_vis_set_type_menu_cb(action - MAINWIN_VIS_ANALYZER); | |
2444 break; | |
2445 case MAINWIN_VIS_ANALYZER_NORMAL: | |
2446 case MAINWIN_VIS_ANALYZER_FIRE: | |
2447 case MAINWIN_VIS_ANALYZER_VLINES: | |
2448 mainwin_vis_set_analyzer_mode(action - MAINWIN_VIS_ANALYZER_NORMAL); | |
2449 break; | |
2450 case MAINWIN_VIS_ANALYZER_LINES: | |
2451 case MAINWIN_VIS_ANALYZER_BARS: | |
2452 mainwin_vis_set_analyzer_type(action - MAINWIN_VIS_ANALYZER_LINES); | |
2453 break; | |
2454 case MAINWIN_VIS_ANALYZER_PEAKS: | |
2455 cfg.analyzer_peaks = GTK_CHECK_MENU_ITEM(item)->active; | |
2456 break; | |
2457 case MAINWIN_VIS_SCOPE_DOT: | |
2458 case MAINWIN_VIS_SCOPE_LINE: | |
2459 case MAINWIN_VIS_SCOPE_SOLID: | |
2460 cfg.scope_mode = action - MAINWIN_VIS_SCOPE_DOT; | |
2461 break; | |
2462 case MAINWIN_VIS_VU_NORMAL: | |
2463 case MAINWIN_VIS_VU_SMOOTH: | |
2464 cfg.vu_mode = action - MAINWIN_VIS_VU_NORMAL; | |
2465 break; | |
2466 case MAINWIN_VIS_REFRESH_FULL: | |
2467 case MAINWIN_VIS_REFRESH_HALF: | |
2468 case MAINWIN_VIS_REFRESH_QUARTER: | |
2469 case MAINWIN_VIS_REFRESH_EIGHTH: | |
2470 mainwin_vis_set_refresh(action - MAINWIN_VIS_REFRESH_FULL); | |
2471 break; | |
2472 case MAINWIN_VIS_AFALLOFF_SLOWEST: | |
2473 case MAINWIN_VIS_AFALLOFF_SLOW: | |
2474 case MAINWIN_VIS_AFALLOFF_MEDIUM: | |
2475 case MAINWIN_VIS_AFALLOFF_FAST: | |
2476 case MAINWIN_VIS_AFALLOFF_FASTEST: | |
2477 mainwin_vis_set_afalloff(action - MAINWIN_VIS_AFALLOFF_SLOWEST); | |
2478 break; | |
2479 case MAINWIN_VIS_PFALLOFF_SLOWEST: | |
2480 case MAINWIN_VIS_PFALLOFF_SLOW: | |
2481 case MAINWIN_VIS_PFALLOFF_MEDIUM: | |
2482 case MAINWIN_VIS_PFALLOFF_FAST: | |
2483 case MAINWIN_VIS_PFALLOFF_FASTEST: | |
2484 mainwin_vis_set_pfalloff(action - MAINWIN_VIS_PFALLOFF_SLOWEST); | |
2485 break; | |
2486 } | |
2487 } | |
2488 | |
2489 void | |
2490 mainwin_general_menu_callback(gpointer data, | |
2491 guint action, | |
2492 GtkWidget * item) | |
2493 { | |
2494 switch (action) { | |
2495 case MAINWIN_GENERAL_PREFS: | |
2496 show_prefs_window(); | |
2497 break; | |
2498 case MAINWIN_GENERAL_ABOUT: | |
2499 show_about_window(); | |
2500 break; | |
2501 case MAINWIN_GENERAL_PLAYFILE: | |
2502 util_run_filebrowser(NO_PLAY_BUTTON); | |
2503 break; | |
2504 case MAINWIN_GENERAL_PLAYDIRECTORY: | |
2505 mainwin_run_dirbrowser(); | |
2506 break; | |
2507 case MAINWIN_GENERAL_PLAYCD: | |
2508 play_medium(); | |
2509 break; | |
2510 case MAINWIN_GENERAL_ADDCD: | |
2511 add_medium(); | |
2512 break; | |
2513 case MAINWIN_GENERAL_PLAYLOCATION: | |
2514 mainwin_show_add_url_window(); | |
2515 break; | |
2516 case MAINWIN_GENERAL_FILEINFO: | |
2517 playlist_fileinfo_current(); | |
2518 break; | |
2519 case MAINWIN_GENERAL_FOCUSPLWIN: | |
2520 gtk_window_present(GTK_WINDOW(playlistwin)); | |
2521 break; | |
2522 case MAINWIN_GENERAL_SHOWPLWIN: | |
2523 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2524 playlistwin_show(); | |
2525 else | |
2526 playlistwin_hide(); | |
2527 break; | |
2528 case MAINWIN_GENERAL_SHOWEQWIN: | |
2529 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2530 equalizerwin_real_show(); | |
2531 else | |
2532 equalizerwin_real_hide(); | |
2533 break; | |
2534 case MAINWIN_GENERAL_PREV: | |
2535 playlist_prev(); | |
2536 break; | |
2537 case MAINWIN_GENERAL_PLAY: | |
2538 mainwin_play_pushed(); | |
2539 break; | |
2540 case MAINWIN_GENERAL_PAUSE: | |
2541 bmp_playback_pause(); | |
2542 break; | |
2543 case MAINWIN_GENERAL_STOP: | |
2544 mainwin_stop_pushed(); | |
2545 break; | |
2546 case MAINWIN_GENERAL_NEXT: | |
2547 playlist_next(); | |
2548 break; | |
2549 case MAINWIN_GENERAL_BACK5SEC: | |
2550 if (bmp_playback_get_playing() | |
2551 && playlist_get_current_length() != -1) | |
2552 bmp_playback_seek_relative(-5); | |
2553 break; | |
2554 case MAINWIN_GENERAL_FWD5SEC: | |
2555 if (bmp_playback_get_playing() | |
2556 && playlist_get_current_length() != -1) | |
2557 bmp_playback_seek_relative(5); | |
2558 break; | |
2559 case MAINWIN_GENERAL_START: | |
2560 playlist_set_position(0); | |
2561 break; | |
2562 case MAINWIN_GENERAL_JTT: | |
2563 mainwin_jump_to_time(); | |
2564 break; | |
2565 case MAINWIN_GENERAL_JTF: | |
2566 mainwin_jump_to_file(); | |
2567 break; | |
2568 case MAINWIN_GENERAL_EXIT: | |
2569 mainwin_quit_cb(); | |
2570 break; | |
2571 } | |
2572 } | |
2573 | |
2574 static void | |
2575 mainwin_mr_change(MenuRowItem i) | |
2576 { | |
2577 switch (i) { | |
2578 case MENUROW_NONE: | |
2579 mainwin_set_info_text(); | |
2580 break; | |
2581 case MENUROW_OPTIONS: | |
2582 mainwin_lock_info_text(_("OPTIONS MENU")); | |
2583 break; | |
2584 case MENUROW_ALWAYS: | |
2585 if (!hint_always_on_top_available()) { | |
2586 if (mainwin_menurow->mr_always_selected) | |
2587 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP (N/A)")); | |
2588 else | |
2589 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP (N/A)")); | |
2590 } | |
2591 else if (mainwin_menurow->mr_doublesize_selected) | |
2592 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); | |
2593 else | |
2594 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
2595 break; | |
2596 case MENUROW_FILEINFOBOX: | |
2597 mainwin_lock_info_text(_("FILE INFO BOX")); | |
2598 break; | |
2599 case MENUROW_DOUBLESIZE: | |
2600 mainwin_lock_info_text(_("** DOUBLESIZE HAS BEEN REMOVED **")); | |
2601 break; | |
2602 case MENUROW_VISUALIZATION: | |
2603 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
2604 break; | |
2605 } | |
2606 } | |
2607 | |
2608 static void | |
2609 mainwin_mr_release(MenuRowItem i) | |
2610 { | |
2611 GdkModifierType modmask; | |
2612 GtkWidget *widget; | |
2613 gint x, y; | |
2614 | |
2615 switch (i) { | |
2616 case MENUROW_OPTIONS: | |
2617 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2618 util_item_factory_popup(mainwin_view_menu, x, y, 1, | |
2619 GDK_CURRENT_TIME); | |
2620 break; | |
2621 case MENUROW_ALWAYS: | |
2622 widget = | |
2623 gtk_item_factory_get_widget(mainwin_view_menu, | |
2624 "/Always On Top"); | |
2625 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
2626 mainwin_menurow->mr_always_selected); | |
2627 break; | |
2628 case MENUROW_FILEINFOBOX: | |
2629 playlist_fileinfo_current(); | |
2630 break; | |
2631 case MENUROW_DOUBLESIZE: | |
2632 /* double size removed, do nothing */ | |
2633 break; | |
2634 case MENUROW_VISUALIZATION: | |
2635 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2636 util_item_factory_popup(mainwin_vis_menu, x, y, 1, GDK_CURRENT_TIME); | |
2637 break; | |
2638 case MENUROW_NONE: | |
2639 break; | |
2640 } | |
2641 mainwin_release_info_text(); | |
2642 } | |
2643 | |
2644 static void | |
2645 run_no_audiocd_dialog(void) | |
2646 { | |
2647 const gchar *markup = | |
2648 N_("<b><big>No playable CD found.</big></b>\n\n" | |
2649 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
2650 | |
2651 GtkWidget *dialog = | |
2652 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2653 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2654 GTK_MESSAGE_ERROR, | |
2655 GTK_BUTTONS_OK, | |
2656 _(markup)); | |
2657 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2658 gtk_widget_destroy(dialog); | |
2659 } | |
2660 | |
2661 static void | |
2662 run_no_output_device_dialog(void) | |
2663 { | |
2664 const gchar *markup = | |
2665 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
2666 "Please check that:\n" | |
2667 "1. You have the correct output plugin selected.\n" | |
2668 "2. No other programs is blocking the soundcard.\n" | |
2669 "3. Your soundcard is configured properly.\n"); | |
2670 | |
2671 GtkWidget *dialog = | |
2672 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2673 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2674 GTK_MESSAGE_ERROR, | |
2675 GTK_BUTTONS_OK, | |
2676 _(markup)); | |
2677 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2678 gtk_widget_destroy(dialog); | |
2679 } | |
2680 | |
2681 | |
2682 void | |
2683 add_medium(void) | |
2684 { | |
2685 GList *list, *node; | |
2686 gchar *filename; | |
2687 gchar *path; | |
2688 ConfigDb *db; | |
2689 | |
2690 db = bmp_cfg_db_open(); | |
2691 | |
2692 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2693 bmp_cfg_db_close(db); | |
2694 | |
2695 if (!(list = input_scan_dir(path))) { | |
2696 run_no_audiocd_dialog(); | |
2697 return; | |
2698 } | |
2699 | |
2700 for (node = list; node; node = g_list_next(node)) { | |
2701 filename = g_build_filename(path, node->data, NULL); | |
2702 playlist_add(filename); | |
2703 g_free(filename); | |
2704 g_free(node->data); | |
2705 } | |
2706 | |
2707 g_free(path); | |
2708 g_list_free(list); | |
2709 | |
2710 } | |
2711 | |
2712 void | |
2713 play_medium(void) | |
2714 { | |
2715 GList *list, *node; | |
2716 gchar *filename; | |
2717 gchar *path; | |
2718 ConfigDb *db; | |
2719 | |
2720 db = bmp_cfg_db_open(); | |
2721 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2722 bmp_cfg_db_close(db); | |
2723 | |
2724 if (!(list = input_scan_dir(path))) { | |
2725 run_no_audiocd_dialog(); | |
2726 return; | |
2727 } | |
2728 | |
2729 playlist_clear(); | |
2730 | |
2731 for (node = list; node; node = g_list_next(node)) { | |
2732 filename = g_build_filename(path, node->data, NULL); | |
2733 playlist_add(filename); | |
2734 g_free(filename); | |
2735 g_free(node->data); | |
2736 } | |
2737 | |
2738 g_free(path); | |
2739 g_list_free(list); | |
2740 | |
2741 playlist_set_position(0); | |
2742 bmp_playback_initiate(); | |
2743 } | |
2744 | |
2745 void | |
2746 read_volume(gint when) | |
2747 { | |
2748 static gint pvl = 0, pvr = 0; | |
2749 static gint times = VOLSET_DISP_TIMES; | |
2750 static gboolean changing = FALSE; | |
2751 | |
2752 gint vl, vr, b, v; | |
2753 | |
2754 input_get_volume(&vl, &vr); | |
2755 | |
2756 switch (when) { | |
2757 case VOLSET_STARTUP: | |
2758 vl = CLAMP(vl, 0, 100); | |
2759 vr = CLAMP(vr, 0, 100); | |
2760 pvl = vl; | |
2761 pvr = vr; | |
2762 v = MAX(vl, vr); | |
2763 if (vl > vr) | |
2764 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2765 else if (vl < vr) | |
2766 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2767 else | |
2768 b = 0; | |
2769 | |
2770 balance = b; | |
2771 mainwin_set_volume_slider(v); | |
2772 equalizerwin_set_volume_slider(v); | |
2773 mainwin_set_balance_slider(b); | |
2774 equalizerwin_set_balance_slider(b); | |
2775 return; | |
2776 | |
2777 case VOLSET_UPDATE: | |
2778 if (vl == -1 || vr == -1) | |
2779 return; | |
2780 | |
2781 if (setting_volume) { | |
2782 pvl = vl; | |
2783 pvr = vr; | |
2784 return; | |
2785 } | |
2786 | |
2787 if (pvr == vr && pvl == vl && changing) { | |
2788 if (times < VOLSET_DISP_TIMES) | |
2789 times++; | |
2790 else { | |
2791 mainwin_release_info_text(); | |
2792 changing = FALSE; | |
2793 } | |
2794 } | |
2795 else if (pvr != vr || pvl != vl) { | |
2796 gchar *tmp; | |
2797 | |
2798 v = MAX(vl, vr); | |
2799 if (vl > vr) | |
2800 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2801 else if (vl < vr) | |
2802 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2803 else | |
2804 b = 0; | |
2805 | |
2806 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
2807 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2808 else { | |
2809 if (vl > vr) { | |
2810 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2811 } | |
2812 else if (vr == vl) | |
2813 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
2814 else { /* (vl < vr) */ | |
2815 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2816 } | |
2817 } | |
2818 mainwin_lock_info_text(tmp); | |
2819 g_free(tmp); | |
2820 | |
2821 pvr = vr; | |
2822 pvl = vl; | |
2823 times = 0; | |
2824 changing = TRUE; | |
2825 mainwin_set_volume_slider(v); | |
2826 equalizerwin_set_volume_slider(v); | |
2827 | |
2828 /* Don't change the balance slider if the volume has been | |
2829 * set to zero. The balance can be anything, and our best | |
2830 * guess is what is was before. */ | |
2831 if (v > 0) { | |
2832 balance = b; | |
2833 mainwin_set_balance_slider(b); | |
2834 equalizerwin_set_balance_slider(b); | |
2835 } | |
2836 } | |
2837 break; | |
2838 | |
2839 case VOLUME_ADJUSTED: | |
2840 pvl = vl; | |
2841 pvr = vr; | |
2842 break; | |
2843 | |
2844 case VOLUME_SET: | |
2845 times = 0; | |
2846 changing = TRUE; | |
2847 pvl = vl; | |
2848 pvr = vr; | |
2849 break; | |
2850 } | |
2851 } | |
2852 | |
2853 | |
2854 /* TODO: HAL! */ | |
2855 gboolean | |
2856 can_play_cd(void) | |
2857 { | |
2858 GList *ilist; | |
2859 | |
2860 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
2861 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
2862 | |
2863 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
2864 PLUGIN_FILENAME("cdaudio"))) { | |
2865 return TRUE; | |
2866 } | |
2867 } | |
2868 | |
2869 return FALSE; | |
2870 } | |
2871 | |
2872 | |
2873 static void | |
2874 set_timer_mode(TimerMode mode) | |
2875 { | |
2876 if (mode == TIMER_ELAPSED) | |
2877 check_set(mainwin_view_menu, "/Time Elapsed", TRUE); | |
2878 else | |
2879 check_set(mainwin_view_menu, "/Time Remaining", TRUE); | |
2880 } | |
2881 | |
2882 static void | |
2883 set_timer_mode_menu_cb(TimerMode mode) | |
2884 { | |
2885 cfg.timer_mode = mode; | |
2886 } | |
2887 | |
2888 | |
2889 void | |
2890 mainwin_setup_menus(void) | |
2891 { | |
2892 set_timer_mode(cfg.timer_mode); | |
2893 | |
2894 /* View menu */ | |
2895 | |
2896 check_set(mainwin_view_menu, "/Always On Top", cfg.always_on_top); | |
2897 check_set(mainwin_view_menu, "/Put on All Workspaces", cfg.sticky); | |
2898 check_set(mainwin_view_menu, "/Roll up Player", cfg.player_shaded); | |
2899 check_set(mainwin_view_menu, "/Roll up Playlist Editor", cfg.playlist_shaded); | |
2900 check_set(mainwin_view_menu, "/Roll up Equalizer", cfg.equalizer_shaded); | |
2901 | |
2902 /* Songname menu */ | |
2903 | |
2904 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
2905 | |
2906 /* Playback menu */ | |
2907 | |
2908 check_set(mainwin_play_menu, "/Repeat", cfg.repeat); | |
2909 check_set(mainwin_play_menu, "/Shuffle", cfg.shuffle); | |
2910 | |
2911 /* Visualization menu */ | |
2912 | |
2913 check_set(mainwin_vis_menu, | |
2914 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + | |
2915 cfg.vis_type].path, TRUE); | |
2916 check_set(mainwin_vis_menu, | |
2917 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_MODE + | |
2918 cfg.analyzer_mode].path, TRUE); | |
2919 check_set(mainwin_vis_menu, | |
2920 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_TYPE + | |
2921 cfg.analyzer_type].path, TRUE); | |
2922 check_set(mainwin_vis_menu, | |
2923 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_PEAKS]. | |
2924 path, cfg.analyzer_peaks); | |
2925 check_set(mainwin_vis_menu, | |
2926 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_SCOPE_MODE + | |
2927 cfg.scope_mode].path, TRUE); | |
2928 check_set(mainwin_vis_menu, | |
2929 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_WSHADEVU_MODE + | |
2930 cfg.vu_mode].path, TRUE); | |
2931 check_set(mainwin_vis_menu, | |
2932 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_REFRESH_RATE + | |
2933 cfg.vis_refresh].path, TRUE); | |
2934 check_set(mainwin_vis_menu, | |
2935 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_AFALLOFF + | |
2936 cfg.analyzer_falloff].path, TRUE); | |
2937 check_set(mainwin_vis_menu, | |
2938 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_PFALLOFF + | |
2939 cfg.peaks_falloff].path, TRUE); | |
2940 } | |
2941 | |
2942 static void | |
2943 mainwin_create_widgets(void) | |
2944 { | |
2945 mainwin_menubtn = | |
2946 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
2947 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
2948 mainwin_menubtn->pb_allow_draw = FALSE; | |
2949 mainwin_minimize = | |
2950 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
2951 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
2952 mainwin_minimize->pb_allow_draw = FALSE; | |
2953 mainwin_shade = | |
2954 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
2955 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
2956 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
2957 SKIN_TITLEBAR); | |
2958 mainwin_shade->pb_allow_draw = FALSE; | |
2959 mainwin_close = | |
2960 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
2961 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
2962 mainwin_close->pb_allow_draw = FALSE; | |
2963 | |
2964 mainwin_rew = | |
2965 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 88, 23, | |
2966 18, 0, 0, 0, 18, playlist_prev, SKIN_CBUTTONS); | |
2967 mainwin_play = | |
2968 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
2969 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
2970 mainwin_pause = | |
2971 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
2972 18, 46, 0, 46, 18, bmp_playback_pause, SKIN_CBUTTONS); | |
2973 mainwin_stop = | |
2974 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
2975 18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS); | |
2976 mainwin_fwd = | |
2977 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
2978 18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS); | |
2979 mainwin_eject = | |
2980 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
2981 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
2982 SKIN_CBUTTONS); | |
2983 | |
2984 mainwin_srew = | |
2985 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
2986 7, playlist_prev); | |
2987 mainwin_splay = | |
2988 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
2989 7, mainwin_play_pushed); | |
2990 mainwin_spause = | |
2991 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
2992 7, bmp_playback_pause); | |
2993 mainwin_sstop = | |
2994 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
2995 7, mainwin_stop_pushed); | |
2996 mainwin_sfwd = | |
2997 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
2998 7, playlist_next); | |
2999 mainwin_seject = | |
3000 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
3001 7, mainwin_eject_pushed); | |
3002 | |
3003 mainwin_shuffle = | |
3004 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
3005 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
3006 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
3007 | |
3008 mainwin_repeat = | |
3009 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
3010 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
3011 mainwin_repeat_pushed, SKIN_SHUFREP); | |
3012 | |
3013 mainwin_eq = | |
3014 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
3015 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
3016 SKIN_SHUFREP); | |
3017 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
3018 mainwin_pl = | |
3019 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
3020 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
3021 mainwin_pl_pushed, SKIN_SHUFREP); | |
3022 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
3023 | |
3024 mainwin_info = | |
3025 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
3026 153, 1, SKIN_TEXT); | |
3027 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
123
022d9717476f
[svn] Bring back support for winamp-style bitmap fonts. :)
nenolod
parents:
88
diff
changeset
|
3028 textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); |
0 | 3029 mainwin_rate_text = |
3030 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
3031 0, SKIN_TEXT); | |
3032 mainwin_freq_text = | |
3033 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
3034 0, SKIN_TEXT); | |
3035 | |
3036 mainwin_menurow = | |
3037 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
3038 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
3039 SKIN_TITLEBAR); | |
3040 mainwin_menurow->mr_doublesize_selected = FALSE; | |
3041 mainwin_menurow->mr_always_selected = cfg.always_on_top; | |
3042 | |
3043 mainwin_volume = | |
3044 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
3045 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
3046 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
3047 mainwin_volume_release_cb, SKIN_VOLUME); | |
3048 mainwin_balance = | |
3049 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
3050 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
3051 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
3052 mainwin_balance_release_cb, SKIN_BALANCE); | |
3053 | |
3054 mainwin_monostereo = | |
3055 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
3056 SKIN_MONOSTEREO); | |
3057 | |
3058 mainwin_playstatus = | |
3059 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
3060 | |
3061 mainwin_minus_num = | |
3062 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
3063 SKIN_NUMBERS); | |
3064 widget_hide(WIDGET(mainwin_minus_num)); | |
3065 mainwin_10min_num = | |
3066 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
3067 SKIN_NUMBERS); | |
3068 widget_hide(WIDGET(mainwin_10min_num)); | |
3069 | |
3070 mainwin_min_num = | |
3071 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
3072 SKIN_NUMBERS); | |
3073 widget_hide(WIDGET(mainwin_min_num)); | |
3074 | |
3075 mainwin_10sec_num = | |
3076 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
3077 SKIN_NUMBERS); | |
3078 widget_hide(WIDGET(mainwin_10sec_num)); | |
3079 | |
3080 mainwin_sec_num = | |
3081 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
3082 SKIN_NUMBERS); | |
3083 widget_hide(WIDGET(mainwin_sec_num)); | |
3084 | |
3085 mainwin_about = | |
3086 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
3087 25, show_about_window); | |
3088 | |
3089 mainwin_vis = | |
3090 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
3091 24, 43, 76); | |
3092 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); | |
3093 active_vis = mainwin_vis; | |
3094 | |
3095 mainwin_position = | |
3096 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
3097 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
3098 mainwin_position_motion_cb, | |
3099 mainwin_position_release_cb, SKIN_POSBAR); | |
3100 widget_hide(WIDGET(mainwin_position)); | |
3101 | |
3102 mainwin_sposition = | |
3103 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
3104 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
3105 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
3106 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
3107 widget_hide(WIDGET(mainwin_sposition)); | |
3108 | |
3109 mainwin_stime_min = | |
3110 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
3111 FALSE, SKIN_TEXT); | |
3112 mainwin_stime_sec = | |
3113 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
3114 FALSE, SKIN_TEXT); | |
3115 | |
3116 if (!cfg.player_shaded) { | |
3117 widget_hide(WIDGET(mainwin_svis)); | |
3118 widget_hide(WIDGET(mainwin_srew)); | |
3119 widget_hide(WIDGET(mainwin_splay)); | |
3120 widget_hide(WIDGET(mainwin_spause)); | |
3121 widget_hide(WIDGET(mainwin_sstop)); | |
3122 widget_hide(WIDGET(mainwin_sfwd)); | |
3123 widget_hide(WIDGET(mainwin_seject)); | |
3124 widget_hide(WIDGET(mainwin_stime_min)); | |
3125 widget_hide(WIDGET(mainwin_stime_sec)); | |
3126 } | |
3127 | |
3128 } | |
3129 | |
3130 static void | |
3131 mainwin_create_window(void) | |
3132 { | |
3133 gint width, height; | |
3134 | |
3135 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3136 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
3137 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
3138 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
3139 | |
3140 width = MAINWIN_WIDTH; | |
3141 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : MAINWIN_HEIGHT; | |
3142 | |
3143 gtk_widget_set_size_request(mainwin, width, height); | |
3144 gtk_widget_set_app_paintable(mainwin, TRUE); | |
3145 | |
3146 dock_window_list = dock_window_set_decorated(dock_window_list, | |
3147 GTK_WINDOW(mainwin), | |
3148 cfg.show_wm_decorations); | |
3149 | |
3150 if (cfg.player_x != -1 && cfg.save_window_position) | |
3151 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
3152 | |
3153 gtk_widget_add_events(mainwin, | |
3154 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
3155 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
3156 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
3157 GDK_VISIBILITY_NOTIFY_MASK); | |
3158 gtk_widget_realize(mainwin); | |
3159 | |
3160 util_set_cursor(mainwin); | |
3161 | |
3162 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
3163 g_signal_connect(mainwin, "button_press_event", | |
3164 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
3165 g_signal_connect(mainwin, "scroll_event", | |
3166 G_CALLBACK(mainwin_scrolled), NULL); | |
3167 g_signal_connect(mainwin, "button_release_event", | |
3168 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
3169 g_signal_connect(mainwin, "motion_notify_event", | |
3170 G_CALLBACK(mainwin_motion), NULL); | |
3171 g_signal_connect_after(mainwin, "focus_in_event", | |
3172 G_CALLBACK(mainwin_focus_in), NULL); | |
3173 g_signal_connect_after(mainwin, "focus_out_event", | |
3174 G_CALLBACK(mainwin_focus_out), NULL); | |
3175 g_signal_connect(mainwin, "configure_event", | |
3176 G_CALLBACK(mainwin_configure), NULL); | |
3177 g_signal_connect(mainwin, "style_set", | |
3178 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
3179 | |
3180 bmp_drag_dest_set(mainwin); | |
3181 | |
3182 g_signal_connect(mainwin, "key_press_event", | |
3183 G_CALLBACK(mainwin_keypress), NULL); | |
3184 } | |
3185 | |
3186 static void | |
3187 mainwin_create_menus(void) | |
3188 { | |
3189 mainwin_general_menu = create_menu(mainwin_general_menu_entries, | |
3190 mainwin_general_menu_entries_num, | |
3191 mainwin_accel); | |
3192 | |
3193 mainwin_play_menu = create_menu(mainwin_playback_menu_entries, | |
3194 mainwin_playback_menu_entries_num, | |
3195 mainwin_accel); | |
3196 | |
3197 mainwin_view_menu = create_menu(mainwin_view_menu_entries, | |
3198 mainwin_view_menu_entries_num, | |
3199 mainwin_accel); | |
3200 | |
3201 mainwin_songname_menu = create_menu(mainwin_songname_menu_entries, | |
3202 mainwin_songname_menu_entries_num, | |
3203 mainwin_accel); | |
3204 | |
3205 mainwin_add_menu = create_menu(mainwin_add_menu_entries, | |
3206 mainwin_add_menu_entries_num, | |
3207 mainwin_accel); | |
3208 | |
3209 mainwin_vis_menu = create_menu(mainwin_vis_menu_entries, | |
3210 mainwin_vis_menu_entries_num, | |
3211 mainwin_accel); | |
3212 | |
3213 make_submenu(mainwin_general_menu, "/View", mainwin_view_menu); | |
87 | 3214 make_submenu(mainwin_general_menu, "/Playback", mainwin_play_menu); |
3215 make_submenu(mainwin_general_menu, "/Visualization", mainwin_vis_menu); | |
0 | 3216 |
3217 gtk_window_add_accel_group(GTK_WINDOW(mainwin), mainwin_accel); | |
3218 } | |
3219 | |
3220 void | |
3221 mainwin_create(void) | |
3222 { | |
3223 mainwin_create_window(); | |
3224 | |
3225 mainwin_accel = gtk_accel_group_new(); | |
3226 mainwin_create_menus(); | |
3227 | |
3228 mainwin_gc = gdk_gc_new(mainwin->window); | |
3229 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
3230 MAINWIN_WIDTH, MAINWIN_HEIGHT, -1); | |
3231 mainwin_set_back_pixmap(); | |
3232 mainwin_create_widgets(); | |
3233 | |
3234 vis_set_window(mainwin_vis, mainwin->window); | |
3235 } | |
3236 | |
3237 void | |
3238 mainwin_attach_idle_func(void) | |
3239 { | |
3240 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
3241 mainwin_idle_func, NULL); | |
3242 } | |
3243 | |
3244 static void | |
3245 idle_func_update_song_info(gint time) | |
3246 { | |
3247 gint length, t; | |
3248 gchar stime_prefix; | |
3249 | |
3250 length = playlist_get_current_length(); | |
3251 playlistwin_set_time(time, length, cfg.timer_mode); | |
3252 input_update_vis(time); | |
3253 | |
3254 if (cfg.timer_mode == TIMER_REMAINING) { | |
3255 if (length != -1) { | |
3256 number_set_number(mainwin_minus_num, 11); | |
3257 t = length - time; | |
3258 stime_prefix = '-'; | |
3259 } | |
3260 else { | |
3261 number_set_number(mainwin_minus_num, 10); | |
3262 t = time; | |
3263 stime_prefix = ' '; | |
3264 } | |
3265 } | |
3266 else { | |
3267 number_set_number(mainwin_minus_num, 10); | |
3268 t = time; | |
3269 stime_prefix = ' '; | |
3270 } | |
3271 t /= 1000; | |
3272 | |
3273 /* Show the time in the format HH:MM when we have more than 100 | |
3274 * minutes. */ | |
3275 if (t >= 100 * 60) | |
3276 t /= 60; | |
3277 number_set_number(mainwin_10min_num, t / 600); | |
3278 number_set_number(mainwin_min_num, (t / 60) % 10); | |
3279 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
3280 number_set_number(mainwin_sec_num, t % 10); | |
3281 | |
3282 if (!mainwin_sposition->hs_pressed) { | |
3283 gchar *time_str; | |
3284 | |
3285 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
3286 textbox_set_text(mainwin_stime_min, time_str); | |
3287 g_free(time_str); | |
3288 | |
3289 time_str = g_strdup_printf("%2.2d", t % 60); | |
3290 textbox_set_text(mainwin_stime_sec, time_str); | |
3291 g_free(time_str); | |
3292 } | |
3293 | |
3294 time /= 1000; | |
3295 length /= 1000; | |
3296 if (length > 0) { | |
3297 if (time > length) { | |
3298 hslider_set_position(mainwin_position, 219); | |
3299 hslider_set_position(mainwin_sposition, 13); | |
3300 } | |
3301 else { | |
3302 hslider_set_position(mainwin_position, (time * 219) / length); | |
3303 hslider_set_position(mainwin_sposition, | |
3304 ((time * 12) / length) + 1); | |
3305 } | |
3306 } | |
3307 else { | |
3308 hslider_set_position(mainwin_position, 0); | |
3309 hslider_set_position(mainwin_sposition, 1); | |
3310 } | |
3311 } | |
3312 | |
3313 static gboolean | |
3314 mainwin_idle_func(gpointer data) | |
3315 { | |
3316 static gint count = 0; | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3317 gint time = 0; |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3318 |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3319 /* run audcore events, then run our own. --nenolod */ |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3320 switch((time = audcore_generic_events())) |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3321 { |
0 | 3322 case -2: |
3323 /* no usable output device */ | |
3324 GDK_THREADS_ENTER(); | |
3325 run_no_output_device_dialog(); | |
3326 mainwin_stop_pushed(); | |
3327 GDK_THREADS_LEAVE(); | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3328 ev_waiting = FALSE; |
0 | 3329 break; |
3330 | |
3331 default: | |
3332 idle_func_update_song_info(time); | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3333 /* nothing at this time */ |
0 | 3334 } |
3335 | |
3336 GDK_THREADS_ENTER(); | |
3337 | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3338 if (bmp_playback_get_playing()) |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3339 vis_playback_start(); |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3340 else |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3341 vis_playback_stop(); |
0 | 3342 |
3343 draw_main_window(mainwin_force_redraw); | |
3344 | |
3345 if (!count) { | |
3346 read_volume(VOLSET_UPDATE); | |
3347 count = 10; | |
3348 } | |
3349 else | |
3350 count--; | |
3351 | |
234 | 3352 draw_playlist_window(mainwin_force_redraw); |
3353 draw_equalizer_window(mainwin_force_redraw); | |
3354 | |
3355 /* what is this for? see below. --nenolod */ | |
233 | 3356 mainwin_force_redraw = FALSE; |
229
108cd7e58d5e
[svn] Always update the playlist information, regardless of whether it is shaded or not. To ensure this happens, I've attached playlistwin_update_list() to the GUI event loop,
nenolod
parents:
225
diff
changeset
|
3357 |
0 | 3358 if (mainwin_title_text) { |
3359 G_LOCK(mainwin_title); | |
3360 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
3361 g_free(mainwin_title_text); | |
3362 mainwin_title_text = NULL; | |
3363 G_UNLOCK(mainwin_title); | |
3364 | |
3365 mainwin_set_info_text(); | |
3366 playlistwin_update_list(); | |
234 | 3367 |
3368 /* set mainwin_force_redraw so that the windows are redrawn | |
3369 * when the title_text has changed. (new song), this should | |
3370 * enforce updates of the playlist window. --nenolod | |
3371 */ | |
3372 mainwin_force_redraw = TRUE; | |
3373 draw_playlist_window(mainwin_force_redraw); | |
0 | 3374 } |
3375 | |
3376 GDK_THREADS_LEAVE(); | |
3377 | |
3378 return TRUE; | |
3379 } |