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