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