Mercurial > audlegacy
annotate audacious/mainwin.c @ 1781:06882533bf8f trunk
[svn] - default skin.hints:mainwinVisWidth value
author | nenolod |
---|---|
date | Wed, 04 Oct 2006 03:41:41 -0700 |
parents | be1de1dd7262 |
children | 641ee4092aea |
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 |
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
833 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
|
834 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
|
835 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
|
836 |
1780
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
837 if (bmp_active_skin->properties.mainwin_vis_width) |
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
838 widget_resize(WIDGET(mainwin_info), bmp_active_skin->properties.mainwin_vis_width, |
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
839 mainwin_vis->vs_widget.height); |
be1de1dd7262
[svn] - implement [skin.hints:mainwinVisWidth] property.
nenolod
parents:
1779
diff
changeset
|
840 |
1774
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
841 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
|
842 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
|
843 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
|
844 |
1777
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
845 if (bmp_active_skin->properties.mainwin_text_width) |
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
846 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
|
847 mainwin_info->tb_widget.height); |
17e38b5c8e2f
[svn] - support for the [skin.hints:mainwinTextWidth] property.
nenolod
parents:
1775
diff
changeset
|
848 |
1774
2d97cd03319e
[svn] - allow elements to be repositioned if they are mentioned in skin.hints
nenolod
parents:
1763
diff
changeset
|
849 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
|
850 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
|
851 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
|
852 |
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
853 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
|
854 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
|
855 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
|
856 |
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
857 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
|
858 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
|
859 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
|
860 |
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
861 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
|
862 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
|
863 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
|
864 |
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
865 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
|
866 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
|
867 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
|
868 |
1d3d05c541d3
[svn] - support for: [skin.hints:mainwinNumber(0-4)(X,Y)] properties.
nenolod
parents:
1777
diff
changeset
|
869 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
|
870 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
|
871 bmp_active_skin->properties.mainwin_number_4_y); |
1779
87d4da9b31ea
[svn] - implement [skin.hints:mainwinPlayStatus(X,Y)] properties.
nenolod
parents:
1778
diff
changeset
|
872 |
87d4da9b31ea
[svn] - implement [skin.hints:mainwinPlayStatus(X,Y)] properties.
nenolod
parents:
1778
diff
changeset
|
873 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
|
874 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
|
875 bmp_active_skin->properties.mainwin_playstatus_y); |
1653 | 876 } |
877 | |
878 void | |
879 mainwin_set_song_info(gint bitrate, | |
880 gint frequency, | |
881 gint n_channels) | |
882 { | |
883 gchar text[512]; | |
884 gchar *title; | |
885 | |
886 playback_set_sample_params(bitrate, frequency, n_channels); | |
887 | |
888 if (bitrate != -1) { | |
889 bitrate /= 1000; | |
890 | |
891 if (bitrate < 1000) { | |
892 /* Show bitrate in 1000s */ | |
893 g_snprintf(text, sizeof(text), "%3d", bitrate); | |
894 textbox_set_text(mainwin_rate_text, text); | |
895 } | |
896 else { | |
897 /* Show bitrate in 100,000s */ | |
898 g_snprintf(text, sizeof(text), "%2dH", bitrate / 100); | |
899 textbox_set_text(mainwin_rate_text, text); | |
900 } | |
901 } | |
902 else | |
903 textbox_set_text(mainwin_rate_text, _("VBR")); | |
904 | |
905 /* Show sampling frequency in kHz */ | |
906 g_snprintf(text, sizeof(text), "%2d", frequency / 1000); | |
907 textbox_set_text(mainwin_freq_text, text); | |
908 | |
909 monostereo_set_num_channels(mainwin_monostereo, n_channels); | |
910 | |
911 if (cfg.player_shaded) | |
912 { | |
913 widget_show(WIDGET(mainwin_stime_min)); | |
914 widget_show(WIDGET(mainwin_stime_sec)); | |
915 } | |
916 | |
917 widget_show(WIDGET(mainwin_minus_num)); | |
918 widget_show(WIDGET(mainwin_10min_num)); | |
919 widget_show(WIDGET(mainwin_min_num)); | |
920 widget_show(WIDGET(mainwin_10sec_num)); | |
921 widget_show(WIDGET(mainwin_sec_num)); | |
922 | |
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
|
923 if (!bmp_playback_get_paused() && mainwin_playstatus != NULL) |
1653 | 924 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); |
925 | |
926 if (playlist_get_current_length() != -1) { | |
927 if (cfg.player_shaded) | |
928 widget_show(WIDGET(mainwin_sposition)); | |
929 widget_show(WIDGET(mainwin_position)); | |
930 } | |
931 else { | |
932 widget_hide(WIDGET(mainwin_position)); | |
933 widget_hide(WIDGET(mainwin_sposition)); | |
934 mainwin_force_redraw = TRUE; | |
935 } | |
936 | |
937 if (bmp_active_skin && bmp_active_skin->properties.mainwin_othertext | |
938 == TRUE) | |
939 { | |
940 if (bitrate != -1) | |
941 g_snprintf(text, 512, "%d kbps, %0.1f kHz, %s", | |
942 bitrate, | |
943 (gfloat) frequency / 1000, | |
944 (n_channels > 1) ? _("stereo") : _("mono")); | |
945 else | |
946 g_snprintf(text, 512, "VBR, %0.1f kHz, %s", | |
947 (gfloat) frequency / 1000, | |
948 (n_channels > 1) ? _("stereo") : _("mono")); | |
949 | |
950 textbox_set_text(mainwin_othertext, text); | |
951 | |
952 widget_hide(WIDGET(mainwin_rate_text)); | |
953 widget_hide(WIDGET(mainwin_freq_text)); | |
954 widget_hide(WIDGET(mainwin_monostereo)); | |
955 widget_show(WIDGET(mainwin_othertext)); | |
956 } | |
957 else | |
958 { | |
959 widget_show(WIDGET(mainwin_rate_text)); | |
960 widget_show(WIDGET(mainwin_freq_text)); | |
961 widget_show(WIDGET(mainwin_monostereo)); | |
962 widget_hide(WIDGET(mainwin_othertext)); | |
963 } | |
964 | |
965 title = playlist_get_info_text(); | |
966 mainwin_set_song_title(title); | |
967 g_free(title); | |
968 } | |
969 | |
970 void | |
971 mainwin_clear_song_info(void) | |
972 { | |
973 if (!mainwin) | |
974 return; | |
975 | |
976 /* clear title */ | |
977 G_LOCK(mainwin_title); | |
978 g_free(mainwin_title_text); | |
979 mainwin_title_text = NULL; | |
980 G_UNLOCK(mainwin_title); | |
981 | |
982 /* clear sampling parameters */ | |
983 playback_set_sample_params(0, 0, 0); | |
984 | |
985 mainwin_position->hs_pressed = FALSE; | |
986 mainwin_sposition->hs_pressed = FALSE; | |
987 | |
988 /* clear sampling parameter displays */ | |
989 textbox_set_text(mainwin_rate_text, " "); | |
990 textbox_set_text(mainwin_freq_text, " "); | |
991 monostereo_set_num_channels(mainwin_monostereo, 0); | |
992 | |
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
|
993 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
|
994 playstatus_set_status(mainwin_playstatus, STATUS_STOP); |
1653 | 995 |
996 /* hide playback time */ | |
997 widget_hide(WIDGET(mainwin_minus_num)); | |
998 widget_hide(WIDGET(mainwin_10min_num)); | |
999 widget_hide(WIDGET(mainwin_min_num)); | |
1000 widget_hide(WIDGET(mainwin_10sec_num)); | |
1001 widget_hide(WIDGET(mainwin_sec_num)); | |
1002 | |
1003 widget_hide(WIDGET(mainwin_stime_min)); | |
1004 widget_hide(WIDGET(mainwin_stime_sec)); | |
1005 | |
1006 widget_hide(WIDGET(mainwin_position)); | |
1007 widget_hide(WIDGET(mainwin_sposition)); | |
1008 | |
1009 widget_hide(WIDGET(mainwin_othertext)); | |
1010 | |
1011 playlistwin_hide_timer(); | |
1012 draw_main_window(TRUE); | |
1013 | |
1014 vis_clear(active_vis); | |
1015 } | |
1016 | |
1017 void | |
1018 mainwin_disable_seekbar(void) | |
1019 { | |
1020 if (!mainwin) | |
1021 return; | |
1022 | |
1023 /* | |
1024 * We dont call draw_main_window() here so this will not | |
1025 * remove them visually. It will only prevent us from sending | |
1026 * any seek calls to the input plugin before the input plugin | |
1027 * calls ->set_info(). | |
1028 */ | |
1029 widget_hide(WIDGET(mainwin_position)); | |
1030 widget_hide(WIDGET(mainwin_sposition)); | |
1031 } | |
1032 | |
1033 static gboolean | |
1034 mainwin_mouse_button_release(GtkWidget * widget, | |
1035 GdkEventButton * event, | |
1036 gpointer callback_data) | |
1037 { | |
1038 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1039 | |
1040 /* | |
1041 * The gdk_flush() is just for making sure that the pointer really | |
1042 * gets ungrabbed before calling any button callbacks | |
1043 * | |
1044 */ | |
1045 | |
1046 gdk_flush(); | |
1047 | |
1048 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
1049 dock_move_release(GTK_WINDOW(mainwin)); | |
1050 draw_playlist_window(TRUE); | |
1051 } | |
1052 | |
1053 if (mainwin_menurow->mr_doublesize_selected) { | |
1054 event->x /= 2; | |
1055 event->y /= 2; | |
1056 } | |
1057 | |
1058 handle_release_cb(mainwin_wlist, widget, event); | |
1059 | |
1060 draw_main_window(FALSE); | |
1061 | |
1062 return FALSE; | |
1063 } | |
1064 | |
1065 static gboolean | |
1066 mainwin_motion(GtkWidget * widget, | |
1067 GdkEventMotion * event, | |
1068 gpointer callback_data) | |
1069 { | |
1070 int x, y; | |
1071 GdkModifierType state; | |
1072 | |
1073 if (event->is_hint != FALSE) | |
1074 { | |
1075 gdk_window_get_pointer(GDK_WINDOW(mainwin->window), | |
1076 &x, &y, &state); | |
1077 | |
1078 /* If it's a hint, we had to query X, so override the | |
1079 * information we we're given... it's probably useless... --nenolod | |
1080 */ | |
1081 event->x = x; | |
1082 event->y = y; | |
1083 event->state = state; | |
1084 } | |
1085 else | |
1086 { | |
1087 x = event->x; | |
1088 y = event->y; | |
1089 state = event->state; | |
1090 } | |
1091 | |
1092 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
1093 dock_move_motion(GTK_WINDOW(mainwin), event); | |
1094 } | |
1095 else { | |
1096 handle_motion_cb(mainwin_wlist, widget, event); | |
1097 draw_main_window(FALSE); | |
1098 } | |
1099 | |
1100 gdk_flush(); | |
1101 | |
1102 return FALSE; | |
1103 } | |
1104 | |
1105 static gboolean | |
1106 inside_sensitive_widgets(gint x, gint y) | |
1107 { | |
1108 return (widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1109 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1110 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1111 || widget_contains(WIDGET(mainwin_close), x, y) | |
1112 || widget_contains(WIDGET(mainwin_rew), x, y) | |
1113 || widget_contains(WIDGET(mainwin_play), x, y) | |
1114 || widget_contains(WIDGET(mainwin_pause), x, y) | |
1115 || widget_contains(WIDGET(mainwin_stop), x, y) | |
1116 || widget_contains(WIDGET(mainwin_fwd), x, y) | |
1117 || widget_contains(WIDGET(mainwin_eject), x, y) | |
1118 || widget_contains(WIDGET(mainwin_shuffle), x, y) | |
1119 || widget_contains(WIDGET(mainwin_repeat), x, y) | |
1120 || widget_contains(WIDGET(mainwin_pl), x, y) | |
1121 || widget_contains(WIDGET(mainwin_eq), x, y) | |
1122 || widget_contains(WIDGET(mainwin_info), x, y) | |
1123 || widget_contains(WIDGET(mainwin_menurow), x, y) | |
1124 || widget_contains(WIDGET(mainwin_volume), x, y) | |
1125 || widget_contains(WIDGET(mainwin_balance), x, y) | |
1126 || (widget_contains(WIDGET(mainwin_position), x, y) && | |
1127 widget_is_visible(WIDGET(mainwin_position))) | |
1128 || widget_contains(WIDGET(mainwin_minus_num), x, y) | |
1129 || widget_contains(WIDGET(mainwin_10min_num), x, y) | |
1130 || widget_contains(WIDGET(mainwin_min_num), x, y) | |
1131 || widget_contains(WIDGET(mainwin_10sec_num), x, y) | |
1132 || widget_contains(WIDGET(mainwin_sec_num), x, y) | |
1133 || widget_contains(WIDGET(mainwin_vis), x, y) | |
1134 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1135 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1136 || widget_contains(WIDGET(mainwin_close), x, y) | |
1137 || widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1138 || widget_contains(WIDGET(mainwin_sposition), x, y) | |
1139 || widget_contains(WIDGET(mainwin_stime_min), x, y) | |
1140 || widget_contains(WIDGET(mainwin_stime_sec), x, y) | |
1141 || widget_contains(WIDGET(mainwin_srew), x, y) | |
1142 || widget_contains(WIDGET(mainwin_splay), x, y) | |
1143 || widget_contains(WIDGET(mainwin_spause), x, y) | |
1144 || widget_contains(WIDGET(mainwin_sstop), x, y) | |
1145 || widget_contains(WIDGET(mainwin_sfwd), x, y) | |
1146 || widget_contains(WIDGET(mainwin_seject), x, y) | |
1147 || widget_contains(WIDGET(mainwin_svis), x, y) | |
1148 || widget_contains(WIDGET(mainwin_about), x, y)); | |
1149 } | |
1150 | |
1151 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
|
1152 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
|
1153 gpointer callback_data) |
1653 | 1154 { |
1676
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1155 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
|
1156 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
|
1157 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
|
1158 break; |
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1159 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
|
1160 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
|
1161 break; |
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 break; |
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1167 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
|
1168 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
|
1169 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
|
1170 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
|
1171 break; |
cf006d682cbe
[svn] 4-way scroll support in the main window (volume & seek) by Jonathan Schleifer <js@h3c.de>.
chainsaw
parents:
1673
diff
changeset
|
1172 } |
1653 | 1173 } |
1174 | |
1175 static gboolean | |
1176 mainwin_mouse_button_press(GtkWidget * widget, | |
1177 GdkEventButton * event, | |
1178 gpointer callback_data) | |
1179 { | |
1180 | |
1181 gboolean grab = TRUE; | |
1182 | |
1183 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1184 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) { | |
1185 if (0 && hint_move_resize_available()) { | |
1186 hint_move_resize(mainwin, event->x_root, event->y_root, TRUE); | |
1187 grab = FALSE; | |
1188 } | |
1189 else { | |
1190 gtk_window_present(GTK_WINDOW(mainwin)); | |
1191 dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, | |
1192 TRUE); | |
1193 } | |
1194 } | |
1195 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1196 event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) { | |
1197 mainwin_set_shade(!cfg.player_shaded); | |
1198 if (dock_is_moving(GTK_WINDOW(mainwin))) | |
1199 dock_move_release(GTK_WINDOW(mainwin)); | |
1200 } | |
1201 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1202 widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1203 playlist_fileinfo_current(); | |
1204 } | |
1205 else { | |
1206 handle_press_cb(mainwin_wlist, widget, event); | |
1207 draw_main_window(FALSE); | |
1208 } | |
1209 | |
1210 if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS && | |
1211 (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1212 widget_contains(WIDGET(mainwin_svis), event->x, event->y))) { | |
1213 | |
1214 cfg.vis_type++; | |
1215 | |
1216 if (cfg.vis_type > VIS_OFF) | |
1217 cfg.vis_type = VIS_ANALYZER; | |
1218 | |
1219 mainwin_vis_set_type(cfg.vis_type); | |
1220 } | |
1221 | |
1222 if (event->button == 3) { | |
1223 if (widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1224 util_item_factory_popup(mainwin_songname_menu, | |
1225 event->x_root, event->y_root, | |
1226 3, event->time); | |
1227 grab = FALSE; | |
1228 } | |
1229 else if (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1230 widget_contains(WIDGET(mainwin_svis), event->x, event->y)) { | |
1231 util_item_factory_popup(mainwin_vis_menu, event->x_root, | |
1232 event->y_root, 3, event->time); | |
1233 grab = FALSE; | |
1234 } | |
1235 else if ( (event->y > 70) && (event->x < 128) ) | |
1236 { | |
1237 | |
1238 util_item_factory_popup(mainwin_play_menu, | |
1239 event->x_root, | |
1240 event->y_root, 3, event->time); | |
1241 grab = FALSE; | |
1242 } else { | |
1243 /* | |
1244 * Pop up the main menu a few pixels down. | |
1245 * This will avoid that anything is selected | |
1246 * if one right-clicks to focus the window | |
1247 * without raising it. | |
1248 * | |
1249 ***MD I think the above is stupid, people don't expect this | |
1250 * | |
1251 */ | |
1252 util_item_factory_popup(mainwin_general_menu, | |
1253 event->x_root, | |
1254 event->y_root, 3, event->time); | |
1255 grab = FALSE; | |
1256 } | |
1257 } | |
1258 if (event->button == 1) { | |
1259 if ((event->x > 35 && event->x < 100 && | |
1260 event->y > 25 && event->y < 40) || | |
1261 widget_contains(WIDGET(mainwin_stime_min), event->x, event->y) || | |
1262 widget_contains(WIDGET(mainwin_stime_sec), event->x, event->y)) { | |
1263 | |
1264 if (cfg.timer_mode == TIMER_ELAPSED) | |
1265 set_timer_mode(TIMER_REMAINING); | |
1266 else | |
1267 set_timer_mode(TIMER_ELAPSED); | |
1268 } | |
1269 | |
1270 } | |
1271 | |
1272 if (grab) | |
1273 gdk_pointer_grab(mainwin->window, FALSE, | |
1274 GDK_BUTTON_MOTION_MASK | | |
1275 GDK_BUTTON_RELEASE_MASK, | |
1276 GDK_WINDOW(GDK_NONE), NULL, GDK_CURRENT_TIME); | |
1277 | |
1278 return FALSE; | |
1279 } | |
1280 | |
1281 static gboolean | |
1282 mainwin_focus_in(GtkWidget * window, | |
1283 GdkEventFocus * event, | |
1284 gpointer data) | |
1285 { | |
1286 mainwin_menubtn->pb_allow_draw = TRUE; | |
1287 mainwin_minimize->pb_allow_draw = TRUE; | |
1288 mainwin_shade->pb_allow_draw = TRUE; | |
1289 mainwin_close->pb_allow_draw = TRUE; | |
1290 draw_main_window(TRUE); | |
1291 | |
1292 return TRUE; | |
1293 } | |
1294 | |
1295 | |
1296 static gboolean | |
1297 mainwin_focus_out(GtkWidget * widget, | |
1298 GdkEventFocus * event, | |
1299 gpointer callback_data) | |
1300 { | |
1301 mainwin_menubtn->pb_allow_draw = FALSE; | |
1302 mainwin_minimize->pb_allow_draw = FALSE; | |
1303 mainwin_shade->pb_allow_draw = FALSE; | |
1304 mainwin_close->pb_allow_draw = FALSE; | |
1305 draw_main_window(TRUE); | |
1306 | |
1307 return TRUE; | |
1308 } | |
1309 | |
1310 static gboolean | |
1311 mainwin_keypress(GtkWidget * grab_widget, | |
1312 GdkEventKey * event, | |
1313 gpointer data) | |
1314 { | |
1315 | |
1316 switch (event->keyval) { | |
1317 | |
1318 case GDK_Up: | |
1319 case GDK_KP_Up: | |
1320 case GDK_KP_8: | |
1321 mainwin_set_volume_diff(2); | |
1322 break; | |
1323 case GDK_Down: | |
1324 case GDK_KP_Down: | |
1325 case GDK_KP_2: | |
1326 mainwin_set_volume_diff(-2); | |
1327 break; | |
1328 case GDK_Left: | |
1329 case GDK_KP_Left: | |
1330 case GDK_KP_7: | |
1331 if (playlist_get_current_length() != -1) | |
1332 bmp_playback_seek(CLAMP | |
1333 (bmp_playback_get_time() - 1000, 0, | |
1334 playlist_get_current_length()) / 1000); | |
1335 break; | |
1336 case GDK_Right: | |
1337 case GDK_KP_Right: | |
1338 case GDK_KP_9: | |
1339 if (playlist_get_current_length() != -1) | |
1340 bmp_playback_seek(CLAMP | |
1341 (bmp_playback_get_time() + 1000, 0, | |
1342 playlist_get_current_length()) / 1000); | |
1343 break; | |
1344 case GDK_KP_4: | |
1345 playlist_prev(); | |
1346 break; | |
1347 case GDK_KP_6: | |
1348 playlist_next(); | |
1349 break; | |
1350 case GDK_KP_Insert: | |
1351 mainwin_jump_to_file(); | |
1352 break; | |
1353 case GDK_KP_5: | |
1354 mainwin_play_pushed(); | |
1355 break; | |
1356 case GDK_Escape: | |
1357 mainwin_minimize_cb(); | |
1358 break; | |
1359 default: | |
1360 return FALSE; | |
1361 } | |
1362 | |
1363 return TRUE; | |
1364 } | |
1365 | |
1366 static void | |
1367 mainwin_jump_to_time_cb(GtkWidget * widget, | |
1368 GtkWidget * entry) | |
1369 { | |
1370 guint min = 0, sec = 0, params; | |
1371 gint time; | |
1372 | |
1373 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u", | |
1374 &min, &sec); | |
1375 if (params == 2) | |
1376 time = (min * 60) + sec; | |
1377 else if (params == 1) | |
1378 time = min; | |
1379 else | |
1380 return; | |
1381 | |
1382 if (playlist_get_current_length() > -1 && | |
1383 time <= (playlist_get_current_length() / 1000)) { | |
1384 bmp_playback_seek(time); | |
1385 gtk_widget_destroy(mainwin_jtt); | |
1386 } | |
1387 } | |
1388 | |
1389 | |
1390 void | |
1391 mainwin_jump_to_time(void) | |
1392 { | |
1393 GtkWidget *vbox, *hbox_new, *hbox_total; | |
1394 GtkWidget *time_entry, *label, *bbox, *jump, *cancel; | |
1395 guint tindex; | |
1396 gchar time_str[10]; | |
1397 | |
1398 if (!bmp_playback_get_playing()) { | |
1399 report_error("JIT can't be launched when no track is being played.\n"); | |
1400 return; | |
1401 } | |
1402 | |
1403 if (mainwin_jtt) { | |
1404 gtk_window_present(GTK_WINDOW(mainwin_jtt)); | |
1405 return; | |
1406 } | |
1407 | |
1408 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1409 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt), | |
1410 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1411 | |
1412 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time")); | |
1413 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER); | |
1414 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt), | |
1415 GTK_WINDOW(mainwin)); | |
1416 | |
1417 g_signal_connect(mainwin_jtt, "destroy", | |
1418 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt); | |
1419 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10); | |
1420 | |
1421 vbox = gtk_vbox_new(FALSE, 5); | |
1422 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox); | |
1423 | |
1424 hbox_new = gtk_hbox_new(FALSE, 0); | |
1425 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5); | |
1426 | |
1427 time_entry = gtk_entry_new(); | |
1428 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5); | |
1429 g_signal_connect(time_entry, "activate", | |
1430 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1431 | |
1432 gtk_widget_set_size_request(time_entry, 70, -1); | |
1433 label = gtk_label_new(_("minutes:seconds")); | |
1434 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5); | |
1435 | |
1436 hbox_total = gtk_hbox_new(FALSE, 0); | |
1437 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5); | |
1438 gtk_widget_show(hbox_total); | |
1439 | |
1440 /* FIXME: Disable display of current track length. It's not | |
1441 updated when track changes */ | |
1442 #if 0 | |
1443 label = gtk_label_new(_("Track length:")); | |
1444 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5); | |
1445 | |
1446 len = playlist_get_current_length() / 1000; | |
1447 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60); | |
1448 label = gtk_label_new(time_str); | |
1449 | |
1450 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10); | |
1451 #endif | |
1452 | |
1453 bbox = gtk_hbutton_box_new(); | |
1454 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); | |
1455 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1456 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1457 | |
1458 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1459 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1460 gtk_container_add(GTK_CONTAINER(bbox), cancel); | |
1461 g_signal_connect_swapped(cancel, "clicked", | |
1462 G_CALLBACK(gtk_widget_destroy), mainwin_jtt); | |
1463 | |
1464 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1465 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1466 gtk_container_add(GTK_CONTAINER(bbox), jump); | |
1467 g_signal_connect(jump, "clicked", | |
1468 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1469 | |
1470 tindex = bmp_playback_get_time() / 1000; | |
1471 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60, | |
1472 tindex % 60); | |
1473 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str); | |
1474 | |
1475 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str)); | |
1476 | |
1477 gtk_widget_show_all(mainwin_jtt); | |
1478 | |
1479 gtk_widget_grab_focus(time_entry); | |
1480 gtk_widget_grab_default(jump); | |
1481 } | |
1482 | |
1483 static void | |
1484 change_song(guint pos) | |
1485 { | |
1486 if (bmp_playback_get_playing()) | |
1487 bmp_playback_stop(); | |
1488 | |
1489 playlist_set_position(pos); | |
1490 bmp_playback_initiate(); | |
1491 } | |
1492 | |
1493 static void | |
1494 mainwin_jump_to_file_jump(GtkTreeView * treeview) | |
1495 { | |
1496 GtkTreeModel *model; | |
1497 GtkTreeSelection *selection; | |
1498 GtkTreeIter iter; | |
1499 gchar *pos_str; | |
1500 guint pos; | |
1501 | |
1502 model = gtk_tree_view_get_model(treeview); | |
1503 selection = gtk_tree_view_get_selection(treeview); | |
1504 | |
1505 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1506 return; | |
1507 | |
1508 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1509 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1510 g_free(pos_str); | |
1511 | |
1512 change_song(pos); | |
1513 | |
1514 /* FIXME: should only hide window */ | |
1515 gtk_widget_destroy(mainwin_jtf); | |
1516 mainwin_jtf = NULL; | |
1517 } | |
1518 | |
1519 static void | |
1520 mainwin_jump_to_file_jump_cb(GtkTreeView * treeview, | |
1521 gpointer data) | |
1522 { | |
1523 mainwin_jump_to_file_jump(treeview); | |
1524 } | |
1525 | |
1526 static void | |
1527 mainwin_jump_to_file_set_queue_button_label(GtkButton * button, | |
1528 guint pos) | |
1529 { | |
1530 if (playlist_is_position_queued(pos)) | |
1531 gtk_button_set_label(button, _("Un_queue")); | |
1532 else | |
1533 gtk_button_set_label(button, _("_Queue")); | |
1534 } | |
1535 | |
1536 static void | |
1537 mainwin_jump_to_file_queue_cb(GtkButton * button, | |
1538 gpointer data) | |
1539 { | |
1540 GtkTreeView *treeview; | |
1541 GtkTreeModel *model; | |
1542 GtkTreeSelection *selection; | |
1543 GtkTreeIter iter; | |
1544 gchar *pos_str; | |
1545 guint pos; | |
1546 | |
1547 treeview = GTK_TREE_VIEW(data); | |
1548 model = gtk_tree_view_get_model(treeview); | |
1549 selection = gtk_tree_view_get_selection(treeview); | |
1550 | |
1551 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1552 return; | |
1553 | |
1554 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1555 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1556 | |
1557 playlist_queue_position(pos); | |
1558 | |
1559 mainwin_jump_to_file_set_queue_button_label(button, pos); | |
1560 } | |
1561 | |
1562 static void | |
1563 mainwin_jump_to_file_selection_changed_cb(GtkTreeSelection *treesel, | |
1564 gpointer data) | |
1565 { | |
1566 GtkTreeView *treeview; | |
1567 GtkTreeModel *model; | |
1568 GtkTreeSelection *selection; | |
1569 GtkTreeIter iter; | |
1570 gchar *pos_str; | |
1571 guint pos; | |
1572 | |
1573 treeview = gtk_tree_selection_get_tree_view(treesel); | |
1574 model = gtk_tree_view_get_model(treeview); | |
1575 selection = gtk_tree_view_get_selection(treeview); | |
1576 | |
1577 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1578 return; | |
1579 | |
1580 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1581 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1582 g_free(pos_str); | |
1583 | |
1584 mainwin_jump_to_file_set_queue_button_label(GTK_BUTTON(data), pos); | |
1585 } | |
1586 | |
1587 static gboolean | |
1588 mainwin_jump_to_file_edit_keypress_cb(GtkWidget * object, | |
1589 GdkEventKey * event, | |
1590 gpointer data) | |
1591 { | |
1592 switch (event->keyval) { | |
1593 case GDK_Return: | |
1594 if (gtk_im_context_filter_keypress (GTK_ENTRY (object)->im_context, event)) { | |
1595 GTK_ENTRY (object)->need_im_reset = TRUE; | |
1596 return TRUE; | |
1597 } else { | |
1598 mainwin_jump_to_file_jump(GTK_TREE_VIEW(data)); | |
1599 return TRUE; | |
1600 } | |
1601 default: | |
1602 return FALSE; | |
1603 } | |
1604 } | |
1605 | |
1606 static gboolean | |
1607 mainwin_jump_to_file_keypress_cb(GtkWidget * object, | |
1608 GdkEventKey * event, | |
1609 gpointer data) | |
1610 { | |
1611 switch (event->keyval) { | |
1612 case GDK_Escape: | |
1613 /* FIXME: show only hide window */ | |
1614 gtk_widget_destroy(mainwin_jtf); | |
1615 mainwin_jtf = NULL; | |
1616 return TRUE; | |
1617 default: | |
1618 return FALSE; | |
1619 }; | |
1620 } | |
1621 | |
1622 static gboolean | |
1623 mainwin_jump_to_file_match(const gchar * song, gchar ** keys) | |
1624 { | |
1625 gint i = 0; | |
1626 gchar *key; | |
1627 gchar *song_lc; | |
1628 | |
1629 song_lc = g_ascii_strdown(song, -1); | |
1630 | |
1631 while (keys[i]) { | |
1632 key = g_ascii_strdown(keys[i], -1); | |
1633 if (!g_strrstr(song_lc, key)) { | |
1634 g_free(key); | |
1635 g_free(song_lc); | |
1636 return FALSE; | |
1637 } | |
1638 | |
1639 g_free(key); | |
1640 i++; | |
1641 } | |
1642 | |
1643 g_free(song_lc); | |
1644 | |
1645 return TRUE; | |
1646 } | |
1647 | |
1648 /* FIXME: Clear the entry when the list gets updated */ | |
1649 static void | |
1650 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
1651 { | |
1652 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
1653 * reading */ | |
1654 gint row; | |
1655 GList *playlist; | |
1656 gchar *desc_buf = NULL; | |
1657 gchar *row_str; | |
1658 GtkTreeIter iter; | |
1659 GtkTreeSelection *selection; | |
1660 | |
1661 GtkTreeModel *store; | |
1662 | |
1663 if (!mainwin_jtf) | |
1664 return; | |
1665 | |
1666 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
1667 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1668 | |
1669 row = 1; | |
1670 for (playlist = playlist_get(); playlist; | |
1671 playlist = g_list_next(playlist)) { | |
1672 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1673 | |
1674 if (entry->title) | |
1675 desc_buf = g_strdup(entry->title); | |
1676 else if (strchr(entry->filename, '/')) | |
1677 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
1678 else | |
1679 desc_buf = str_to_utf8(entry->filename); | |
1680 | |
1681 row_str = g_strdup_printf("%d", row++); | |
1682 | |
1683 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
1684 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
1685 0, row_str, 1, desc_buf, -1); | |
1686 | |
1687 if(desc_buf) { | |
1688 g_free(desc_buf); | |
1689 desc_buf = NULL; | |
1690 } | |
1691 | |
1692 g_free(row_str); | |
1693 } | |
1694 | |
1695 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1696 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
1697 gtk_tree_selection_select_iter(selection, &iter); | |
1698 } | |
1699 | |
1700 static void | |
1701 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
1702 { | |
1703 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
1704 GtkTreeSelection *selection; | |
1705 GtkTreeIter iter; | |
1706 | |
1707 GtkListStore *store; | |
1708 | |
1709 gint song_index = 0; | |
1710 gchar **words; | |
1711 GList *playlist; | |
1712 | |
1713 gboolean match = FALSE; | |
1714 | |
1715 /* Chop the key string into ' '-separated key words */ | |
1716 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
1717 | |
1718 /* FIXME: Remove the connected signals before clearing | |
1719 * (row-selected will still eventually arrive once) */ | |
1720 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
1721 gtk_list_store_clear(store); | |
1722 | |
1723 PLAYLIST_LOCK(); | |
1724 | |
1725 for (playlist = playlist_get(); playlist; | |
1726 playlist = g_list_next(playlist)) { | |
1727 | |
1728 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1729 const gchar *title; | |
1730 gchar *filename = NULL; | |
1731 | |
1732 title = entry->title; | |
1733 if (!title) { | |
1734 filename = str_to_utf8(entry->filename); | |
1735 | |
1736 if (strchr(filename, '/')) | |
1737 title = strrchr(filename, '/') + 1; | |
1738 else | |
1739 title = filename; | |
1740 } | |
1741 | |
1742 /* Compare the key words to the string - if all the words | |
1743 match, add to the ListStore */ | |
1744 | |
1745 /* | |
1746 * FIXME: The search string should be adapted to the | |
1747 * current display setting, e.g. if the user has set it to | |
1748 * "%p - %t" then build the match string like that too, or | |
1749 * even better, search for each of the tags seperatly. | |
1750 * | |
1751 * In any case the string to match should _never_ contain | |
1752 * something the user can't actually see in the playlist. | |
1753 */ | |
1754 if (words[0]) | |
1755 match = mainwin_jump_to_file_match(title, words); | |
1756 else | |
1757 match = TRUE; | |
1758 | |
1759 if (match) { | |
1760 gchar *song_index_str = g_strdup_printf("%d", song_index + 1); | |
1761 gtk_list_store_append(store, &iter); | |
1762 gtk_list_store_set(store, &iter, 0, song_index_str, 1, title, -1); | |
1763 g_free(song_index_str); | |
1764 } | |
1765 | |
1766 song_index++; | |
1767 if (filename) { | |
1768 g_free(filename); | |
1769 filename = NULL; | |
1770 } | |
1771 } | |
1772 | |
1773 PLAYLIST_UNLOCK(); | |
1774 | |
1775 g_strfreev(words); | |
1776 | |
1777 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
1778 selection = gtk_tree_view_get_selection(treeview); | |
1779 gtk_tree_selection_select_iter(selection, &iter); | |
1780 } | |
1781 } | |
1782 | |
1783 void | |
1784 mainwin_jump_to_file(void) | |
1785 { | |
1786 GtkWidget *scrollwin; | |
1787 GtkWidget *vbox, *bbox, *sep; | |
1788 GtkWidget *jump, *queue, *cancel; | |
1789 GtkWidget *rescan, *edit; | |
1790 GtkWidget *search_label, *hbox; | |
1791 GList *playlist; | |
1792 gchar *desc_buf = NULL; | |
1793 gchar *row_str; | |
1794 gint row; | |
1795 | |
1796 GtkWidget *treeview; | |
1797 GtkListStore *jtf_store; | |
1798 | |
1799 GtkTreeIter iter; | |
1800 GtkCellRenderer *renderer; | |
1801 GtkTreeViewColumn *column; | |
1802 | |
1803 if (mainwin_jtf) { | |
1804 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
1805 return; | |
1806 } | |
1807 | |
1808 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1809 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
1810 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1811 | |
1812 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
1813 | |
1814 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
1815 g_signal_connect(mainwin_jtf, "destroy", | |
1816 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
1817 | |
1818 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
1819 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
1820 | |
1821 vbox = gtk_vbox_new(FALSE, 5); | |
1822 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
1823 | |
1824 jtf_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
1825 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
1826 g_object_unref(jtf_store); | |
1827 | |
1828 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
1829 | |
1830 column = gtk_tree_view_column_new(); | |
1831 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
1832 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1833 | |
1834 renderer = gtk_cell_renderer_text_new(); | |
1835 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1836 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
1837 gtk_tree_view_column_set_spacing(column, 4); | |
1838 | |
1839 renderer = gtk_cell_renderer_text_new(); | |
1840 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1841 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
1842 gtk_tree_view_column_set_spacing(column, 4); | |
1843 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
1844 | |
1845 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
1846 | |
1847 g_signal_connect(treeview, "row-activated", | |
1848 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
1849 | |
1850 hbox = gtk_hbox_new(FALSE, 3); | |
1851 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
1852 | |
1853 search_label = gtk_label_new(_("Filter: ")); | |
1854 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), "_Filter:"); | |
1855 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
1856 | |
1857 edit = gtk_entry_new(); | |
1858 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
1859 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
1860 g_signal_connect(edit, "changed", | |
1861 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
1862 | |
1863 g_signal_connect(edit, "key_press_event", | |
1864 G_CALLBACK(mainwin_jump_to_file_edit_keypress_cb), treeview); | |
1865 | |
1866 g_signal_connect(mainwin_jtf, "key_press_event", | |
1867 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
1868 | |
1869 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
1870 | |
1871 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
1872 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
1873 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
1874 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1875 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
1876 GTK_SHADOW_IN); | |
1877 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
1878 | |
1879 sep = gtk_hseparator_new(); | |
1880 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
1881 | |
1882 bbox = gtk_hbutton_box_new(); | |
1883 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1884 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1885 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1886 | |
1887 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
1888 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
1889 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
1890 g_signal_connect(queue, "clicked", | |
1891 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
1892 treeview); | |
1893 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
1894 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
1895 queue); | |
1896 | |
1897 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
1898 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
1899 g_signal_connect(rescan, "clicked", | |
1900 G_CALLBACK(mainwin_update_jtf), treeview); | |
1901 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
1902 gtk_widget_grab_default(rescan); | |
1903 | |
1904 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1905 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
1906 | |
1907 g_signal_connect_swapped(jump, "clicked", | |
1908 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
1909 treeview); | |
1910 | |
1911 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1912 gtk_widget_grab_default(jump); | |
1913 | |
1914 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
1915 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
1916 g_signal_connect_swapped(cancel, "clicked", | |
1917 G_CALLBACK(gtk_widget_destroy), | |
1918 mainwin_jtf); | |
1919 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1920 | |
1921 gtk_list_store_clear(jtf_store); | |
1922 | |
1923 row = 1; | |
1924 | |
1925 PLAYLIST_LOCK(); | |
1926 | |
1927 for (playlist = playlist_get(); playlist; | |
1928 playlist = g_list_next(playlist)) { | |
1929 | |
1930 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1931 | |
1932 if (entry->title) | |
1933 desc_buf = g_strdup(entry->title); | |
1934 else if (strchr(entry->filename, '/')) | |
1935 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
1936 else | |
1937 desc_buf = str_to_utf8(entry->filename); | |
1938 | |
1939 row_str = g_strdup_printf("%d", row++); | |
1940 | |
1941 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
1942 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
1943 0, row_str, 1, desc_buf, -1); | |
1944 | |
1945 if (desc_buf) { | |
1946 g_free(desc_buf); | |
1947 desc_buf = NULL; | |
1948 } | |
1949 g_free(row_str); | |
1950 } | |
1951 | |
1952 PLAYLIST_UNLOCK(); | |
1953 | |
1954 gtk_widget_show_all(mainwin_jtf); | |
1955 } | |
1956 | |
1957 static gboolean | |
1958 mainwin_configure(GtkWidget * window, | |
1959 GdkEventConfigure * event, | |
1960 gpointer data) | |
1961 { | |
1962 if (!GTK_WIDGET_VISIBLE(window)) | |
1963 return FALSE; | |
1964 | |
1965 if (cfg.show_wm_decorations) | |
1966 gdk_window_get_root_origin(window->window, | |
1967 &cfg.player_x, &cfg.player_y); | |
1968 else | |
1969 gdk_window_get_deskrelative_origin(window->window, | |
1970 &cfg.player_x, &cfg.player_y); | |
1971 return FALSE; | |
1972 } | |
1973 | |
1974 void | |
1975 mainwin_set_back_pixmap(void) | |
1976 { | |
1977 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
1978 gdk_window_clear(mainwin->window); | |
1979 } | |
1980 | |
1673 | 1981 /* |
1982 * Rewritten 09/13/06: | |
1983 * | |
1984 * Remove all of this flaky iter/sourcelist/strsplit stuff. | |
1985 * All we care about is the filepath. | |
1986 * | |
1987 * We can figure this out and easily pass it to xmms_urldecode_plain(). | |
1988 * - nenolod | |
1989 */ | |
1653 | 1990 void |
1991 mainwin_drag_data_received(GtkWidget * widget, | |
1992 GdkDragContext * context, | |
1993 gint x, | |
1994 gint y, | |
1995 GtkSelectionData * selection_data, | |
1996 guint info, | |
1997 guint time, | |
1998 gpointer user_data) | |
1999 { | |
1673 | 2000 g_return_if_fail(selection_data != NULL); |
2001 g_return_if_fail(selection_data->data != NULL); | |
2002 | |
2003 if (str_has_prefix_nocase((gchar *) selection_data->data, "fonts:///")) | |
1653 | 2004 { |
1696 | 2005 gchar *path = (gchar *) selection_data->data + 9; /* skip fonts:/// */ |
1673 | 2006 gchar *decoded = xmms_urldecode_plain(path); |
2007 | |
1696 | 2008 cfg.playlist_font = g_strconcat(decoded, strrchr(cfg.playlist_font, ' '), NULL); |
1673 | 2009 playlist_list_set_font(cfg.playlist_font); |
2010 playlistwin_update_list(); | |
2011 | |
2012 g_free(decoded); | |
2013 | |
1653 | 2014 return; |
2015 } | |
2016 | |
1673 | 2017 playlist_clear(); |
2018 playlist_add_url((gchar *) selection_data->data); | |
2019 bmp_playback_initiate(); | |
1653 | 2020 } |
2021 | |
2022 static void | |
2023 on_add_url_add_clicked(GtkWidget * widget, | |
2024 GtkWidget * entry) | |
2025 { | |
2026 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2027 if (text && *text) | |
2028 playlist_add_url(text); | |
2029 } | |
2030 | |
2031 static void | |
2032 on_add_url_ok_clicked(GtkWidget * widget, | |
2033 GtkWidget * entry) | |
2034 { | |
2035 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2036 if (text && *text) | |
2037 { | |
2038 playlist_clear(); | |
2039 playlist_add_url(text); | |
2040 bmp_playback_initiate(); | |
2041 } | |
2042 } | |
2043 | |
2044 void | |
2045 mainwin_show_add_url_window(void) | |
2046 { | |
2047 static GtkWidget *url_window = NULL; | |
2048 | |
2049 if (!url_window) { | |
2050 url_window = | |
2051 util_add_url_dialog_new(_("Enter location to play:"), | |
2052 G_CALLBACK(on_add_url_ok_clicked), | |
2053 G_CALLBACK(on_add_url_add_clicked)); | |
2054 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
2055 GTK_WINDOW(mainwin)); | |
2056 g_signal_connect(url_window, "destroy", | |
2057 G_CALLBACK(gtk_widget_destroyed), | |
2058 &url_window); | |
2059 } | |
2060 | |
2061 gtk_window_present(GTK_WINDOW(url_window)); | |
2062 } | |
2063 | |
2064 static void | |
2065 check_set(GtkItemFactory * factory, | |
2066 const gchar * path, | |
2067 gboolean active) | |
2068 { | |
2069 GtkWidget *item = gtk_item_factory_get_widget(factory, path); | |
2070 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active); | |
2071 } | |
2072 | |
2073 void | |
2074 mainwin_eject_pushed(void) | |
2075 { | |
2076 util_run_filebrowser(PLAY_BUTTON); | |
2077 } | |
2078 | |
2079 void | |
2080 mainwin_rev_pushed(void) | |
2081 { | |
2082 g_get_current_time(&cb_time); | |
2083 | |
2084 seek_initial_pos = hslider_get_position(mainwin_position); | |
2085 seek_state = MAINWIN_SEEK_REV; | |
2086 } | |
2087 | |
2088 void | |
2089 mainwin_rev_release(void) | |
2090 { | |
2091 GTimeVal now_time; | |
2092 GTimeVal delta_time; | |
2093 gulong now_dur; | |
2094 | |
2095 g_get_current_time(&now_time); | |
2096 | |
2097 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
2098 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
2099 | |
2100 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
2101 | |
2102 if ( now_dur <= TRISTATE_THRESHOLD ) | |
2103 { | |
2104 /* interpret as 'skip to previous song' */ | |
2105 playlist_prev(); | |
2106 } | |
2107 else | |
2108 { | |
2109 /* interpret as 'seek' */ | |
2110 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
2111 } | |
2112 | |
2113 seek_state = MAINWIN_SEEK_NIL; | |
2114 } | |
2115 | |
2116 void | |
2117 mainwin_fwd_pushed(void) | |
2118 { | |
2119 g_get_current_time(&cb_time); | |
2120 | |
2121 seek_initial_pos = hslider_get_position(mainwin_position); | |
2122 seek_state = MAINWIN_SEEK_FWD; | |
2123 } | |
2124 | |
2125 void | |
2126 mainwin_fwd_release(void) | |
2127 { | |
2128 GTimeVal now_time; | |
2129 GTimeVal delta_time; | |
2130 gulong now_dur; | |
2131 | |
2132 g_get_current_time(&now_time); | |
2133 | |
2134 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
2135 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
2136 | |
2137 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
2138 | |
2139 if ( now_dur <= TRISTATE_THRESHOLD ) | |
2140 { | |
2141 /* interpret as 'skip to previous song' */ | |
2142 playlist_next(); | |
2143 } | |
2144 else | |
2145 { | |
2146 /* interpret as 'seek' */ | |
2147 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
2148 } | |
2149 | |
2150 seek_state = MAINWIN_SEEK_NIL; | |
2151 } | |
2152 | |
2153 void | |
2154 mainwin_play_pushed(void) | |
2155 { | |
2156 if (bmp_playback_get_paused()) { | |
2157 bmp_playback_pause(); | |
2158 return; | |
2159 } | |
2160 | |
2161 if (playlist_get_length()) | |
2162 bmp_playback_initiate(); | |
2163 else | |
2164 mainwin_eject_pushed(); | |
2165 } | |
2166 | |
2167 void | |
2168 mainwin_stop_pushed(void) | |
2169 { | |
2170 ip_data.stop = TRUE; | |
2171 mainwin_clear_song_info(); | |
2172 bmp_playback_stop(); | |
2173 ip_data.stop = FALSE; | |
2174 } | |
2175 | |
2176 void | |
2177 mainwin_shuffle_pushed(gboolean toggled) | |
2178 { | |
2179 check_set(mainwin_play_menu, "/Shuffle", toggled); | |
2180 } | |
2181 | |
2182 void | |
2183 mainwin_repeat_pushed(gboolean toggled) | |
2184 { | |
2185 check_set(mainwin_play_menu, "/Repeat", toggled); | |
2186 } | |
2187 | |
2188 void | |
2189 mainwin_pl_pushed(gboolean toggled) | |
2190 { | |
2191 if (toggled) | |
2192 playlistwin_show(); | |
2193 else | |
2194 playlistwin_hide(); | |
2195 } | |
2196 | |
2197 gint | |
2198 mainwin_spos_frame_cb(gint pos) | |
2199 { | |
2200 if (mainwin_sposition) { | |
2201 if (pos < 6) | |
2202 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2203 17; | |
2204 else if (pos < 9) | |
2205 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2206 20; | |
2207 else | |
2208 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2209 23; | |
2210 } | |
2211 return 1; | |
2212 } | |
2213 | |
2214 void | |
2215 mainwin_spos_motion_cb(gint pos) | |
2216 { | |
2217 gint time; | |
2218 gchar *time_msg; | |
2219 | |
2220 pos--; | |
2221 | |
2222 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
2223 | |
2224 if (cfg.timer_mode == TIMER_REMAINING) { | |
2225 time = (playlist_get_current_length() / 1000) - time; | |
2226 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
2227 textbox_set_text(mainwin_stime_min, time_msg); | |
2228 g_free(time_msg); | |
2229 } | |
2230 else { | |
2231 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
2232 textbox_set_text(mainwin_stime_min, time_msg); | |
2233 g_free(time_msg); | |
2234 } | |
2235 | |
2236 time_msg = g_strdup_printf("%2.2d", time % 60); | |
2237 textbox_set_text(mainwin_stime_sec, time_msg); | |
2238 g_free(time_msg); | |
2239 } | |
2240 | |
2241 void | |
2242 mainwin_spos_release_cb(gint pos) | |
2243 { | |
2244 bmp_playback_seek(((playlist_get_current_length() / 1000) * | |
2245 (pos - 1)) / 12); | |
2246 } | |
2247 | |
2248 void | |
2249 mainwin_position_motion_cb(gint pos) | |
2250 { | |
2251 gint length, time; | |
2252 gchar *seek_msg; | |
2253 | |
2254 length = playlist_get_current_length() / 1000; | |
2255 time = (length * pos) / 219; | |
2256 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
2257 time / 60, time % 60, | |
2258 length / 60, length % 60, | |
2259 (length != 0) ? (time * 100) / length : 0); | |
2260 mainwin_lock_info_text(seek_msg); | |
2261 g_free(seek_msg); | |
2262 } | |
2263 | |
2264 void | |
2265 mainwin_position_release_cb(gint pos) | |
2266 { | |
2267 gint length, time; | |
2268 | |
2269 length = playlist_get_current_length() / 1000; | |
2270 time = (length * pos) / 219; | |
2271 bmp_playback_seek(time); | |
2272 mainwin_release_info_text(); | |
2273 } | |
2274 | |
2275 gint | |
2276 mainwin_volume_frame_cb(gint pos) | |
2277 { | |
2278 return (gint) rint((pos / 52.0) * 28); | |
2279 } | |
2280 | |
2281 void | |
2282 mainwin_adjust_volume_motion(gint v) | |
2283 { | |
2284 gchar *volume_msg; | |
2285 | |
2286 setting_volume = TRUE; | |
2287 | |
2288 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2289 mainwin_lock_info_text(volume_msg); | |
2290 g_free(volume_msg); | |
2291 | |
2292 if (balance < 0) | |
2293 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
2294 else if (balance > 0) | |
2295 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
2296 else | |
2297 input_set_volume(v, v); | |
2298 } | |
2299 | |
2300 void | |
2301 mainwin_adjust_volume_release(void) | |
2302 { | |
2303 mainwin_release_info_text(); | |
2304 setting_volume = FALSE; | |
2305 read_volume(VOLUME_ADJUSTED); | |
2306 } | |
2307 | |
2308 void | |
2309 mainwin_adjust_balance_motion(gint b) | |
2310 { | |
2311 gchar *balance_msg; | |
2312 gint v, pvl, pvr; | |
2313 | |
2314 setting_volume = TRUE; | |
2315 balance = b; | |
2316 input_get_volume(&pvl, &pvr); | |
2317 v = MAX(pvl, pvr); | |
2318 if (b < 0) { | |
2319 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2320 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
2321 } | |
2322 else if (b == 0) { | |
2323 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
2324 input_set_volume(v, v); | |
2325 } | |
2326 else { /* b > 0 */ | |
2327 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2328 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
2329 } | |
2330 mainwin_lock_info_text(balance_msg); | |
2331 g_free(balance_msg); | |
2332 } | |
2333 | |
2334 void | |
2335 mainwin_adjust_balance_release(void) | |
2336 { | |
2337 mainwin_release_info_text(); | |
2338 setting_volume = FALSE; | |
2339 read_volume(VOLUME_ADJUSTED); | |
2340 } | |
2341 | |
2342 void | |
2343 mainwin_set_volume_slider(gint percent) | |
2344 { | |
2345 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
2346 } | |
2347 | |
2348 void | |
2349 mainwin_set_balance_slider(gint percent) | |
2350 { | |
2351 hslider_set_position(mainwin_balance, | |
2352 (gint) rint(((percent * 12) / 100.0) + 12)); | |
2353 } | |
2354 | |
2355 void | |
2356 mainwin_volume_motion_cb(gint pos) | |
2357 { | |
2358 gint vol = (pos * 100) / 51; | |
2359 mainwin_adjust_volume_motion(vol); | |
2360 equalizerwin_set_volume_slider(vol); | |
2361 } | |
2362 | |
2363 void | |
2364 mainwin_volume_release_cb(gint pos) | |
2365 { | |
2366 mainwin_adjust_volume_release(); | |
2367 } | |
2368 | |
2369 gint | |
2370 mainwin_balance_frame_cb(gint pos) | |
2371 { | |
2372 return ((abs(pos - 12) * 28) / 13); | |
2373 } | |
2374 | |
2375 void | |
2376 mainwin_balance_motion_cb(gint pos) | |
2377 { | |
2378 gint bal = ((pos - 12) * 100) / 12; | |
2379 mainwin_adjust_balance_motion(bal); | |
2380 equalizerwin_set_balance_slider(bal); | |
2381 } | |
2382 | |
2383 void | |
2384 mainwin_balance_release_cb(gint pos) | |
2385 { | |
2386 mainwin_adjust_volume_release(); | |
2387 } | |
2388 | |
2389 void | |
2390 mainwin_set_volume_diff(gint diff) | |
2391 { | |
2392 gint vl, vr, vol; | |
2393 | |
2394 input_get_volume(&vl, &vr); | |
2395 vol = MAX(vl, vr); | |
2396 vol = CLAMP(vol + diff, 0, 100); | |
2397 | |
2398 mainwin_adjust_volume_motion(vol); | |
2399 setting_volume = FALSE; | |
2400 mainwin_set_volume_slider(vol); | |
2401 equalizerwin_set_volume_slider(vol); | |
2402 read_volume(VOLUME_SET); | |
2403 } | |
2404 | |
2405 void | |
2406 mainwin_set_balance_diff(gint diff) | |
2407 { | |
2408 gint b; | |
2409 b = CLAMP(balance + diff, -100, 100); | |
2410 mainwin_adjust_balance_motion(b); | |
2411 setting_volume = FALSE; | |
2412 mainwin_set_balance_slider(b); | |
2413 equalizerwin_set_balance_slider(b); | |
2414 read_volume(VOLUME_SET); | |
2415 } | |
2416 | |
2417 void | |
2418 mainwin_show(gboolean show) | |
2419 { | |
2420 if (show) | |
2421 mainwin_real_show(); | |
2422 else | |
2423 mainwin_real_hide(); | |
2424 } | |
2425 | |
2426 void | |
2427 mainwin_real_show(void) | |
2428 { | |
2429 cfg.player_visible = TRUE; | |
2430 | |
2431 check_set(mainwin_view_menu, "/Show Player", TRUE); | |
2432 | |
2433 if (cfg.player_shaded) | |
2434 vis_clear_data(active_vis); | |
2435 | |
2436 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
2437 mainwin_set_shape_mask(); | |
2438 | |
2439 if (cfg.show_wm_decorations) { | |
2440 if (!pposition_broken && cfg.player_x != -1 | |
2441 && cfg.save_window_position) | |
2442 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2443 | |
2444 gtk_widget_show(mainwin); | |
2445 | |
2446 if (pposition_broken && cfg.player_x != -1 | |
2447 && cfg.save_window_position) | |
2448 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2449 | |
2450 return; | |
2451 } | |
2452 | |
2453 gtk_widget_show_all(mainwin); | |
2454 | |
2455 if (!nullmask) | |
2456 return; | |
2457 | |
2458 g_object_unref(nullmask); | |
2459 nullmask = NULL; | |
2460 | |
2461 gdk_window_set_hints(mainwin->window, 0, 0, | |
2462 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2463 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2464 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2465 gtk_window_resize(GTK_WINDOW(mainwin), PLAYER_WIDTH, PLAYER_HEIGHT); | |
2466 | |
2467 if (cfg.player_x != -1 && cfg.player_y != -1) | |
2468 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2469 | |
2470 draw_main_window(TRUE); | |
2471 | |
2472 gtk_window_present(GTK_WINDOW(mainwin)); | |
2473 } | |
2474 | |
2475 void | |
2476 mainwin_real_hide(void) | |
2477 { | |
2478 GdkGC *gc; | |
2479 GdkColor pattern; | |
2480 | |
2481 check_set(mainwin_view_menu, "/Show Player", FALSE); | |
2482 | |
2483 if (cfg.player_shaded) | |
2484 svis_clear_data(mainwin_svis); | |
2485 | |
2486 if (!cfg.show_wm_decorations) { | |
2487 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
2488 gc = gdk_gc_new(nullmask); | |
2489 pattern.pixel = 0; | |
2490 gdk_gc_set_foreground(gc, &pattern); | |
2491 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
2492 gdk_gc_destroy(gc); | |
2493 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
2494 | |
2495 gdk_window_set_hints(mainwin->window, 0, 0, 0, 0, 0, 0, | |
2496 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2497 gdk_window_resize(mainwin->window, 0, 0); | |
2498 } | |
2499 | |
2500 gtk_widget_hide(mainwin); | |
2501 | |
2502 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
2503 cfg.player_visible = FALSE; | |
2504 } | |
2505 | |
2506 static void | |
2507 mainwin_songname_menu_callback(gpointer data, | |
2508 guint action, | |
2509 GtkWidget * item) | |
2510 { | |
2511 GtkCheckMenuItem *check; | |
2512 | |
2513 switch (action) { | |
2514 case MAINWIN_SONGNAME_FILEINFO: | |
2515 playlist_fileinfo_current(); | |
2516 break; | |
2517 case MAINWIN_SONGNAME_JTF: | |
2518 mainwin_jump_to_file(); | |
2519 break; | |
2520 case MAINWIN_SONGNAME_JTT: | |
2521 mainwin_jump_to_time(); | |
2522 break; | |
2523 case MAINWIN_SONGNAME_SCROLL: | |
2524 check = GTK_CHECK_MENU_ITEM(item); | |
2525 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
1775 | 2526 check_set(mainwin_view_menu, "/Autoscroll Songname", cfg.autoscroll); |
2527 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
1653 | 2528 break; |
2529 case MAINWIN_SONGNAME_STOPAFTERSONG: | |
2530 check = GTK_CHECK_MENU_ITEM(item); | |
2531 cfg.stopaftersong = gtk_check_menu_item_get_active(check); | |
2532 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2533 check_set(mainwin_play_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2534 break; | |
2535 } | |
2536 } | |
2537 | |
2538 void | |
2539 mainwin_set_stopaftersong(gboolean stop) | |
2540 { | |
2541 cfg.stopaftersong = stop; | |
2542 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2543 } | |
2544 | |
2545 static void | |
2546 mainwin_play_menu_callback(gpointer data, | |
2547 guint action, | |
2548 GtkWidget * item) | |
2549 { | |
2550 GtkCheckMenuItem *check; | |
2551 | |
2552 switch (action) { | |
2553 case MAINWIN_OPT_SHUFFLE: | |
2554 check = GTK_CHECK_MENU_ITEM(item); | |
2555 cfg.shuffle = gtk_check_menu_item_get_active(check); | |
2556 playlist_set_shuffle(cfg.shuffle); | |
2557 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
2558 break; | |
2559 case MAINWIN_OPT_REPEAT: | |
2560 check = GTK_CHECK_MENU_ITEM(item); | |
2561 cfg.repeat = gtk_check_menu_item_get_active(check); | |
2562 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
2563 break; | |
2564 case MAINWIN_OPT_NPA: | |
2565 check = GTK_CHECK_MENU_ITEM(item); | |
2566 cfg.no_playlist_advance = gtk_check_menu_item_get_active(check); | |
2567 break; | |
2568 } | |
2569 } | |
2570 | |
2571 | |
2572 static void | |
2573 mainwin_view_menu_callback(gpointer data, | |
2574 guint action, | |
2575 GtkWidget * item) | |
2576 { | |
1775 | 2577 GtkCheckMenuItem *check; |
2578 | |
1653 | 2579 switch (action) { |
2580 case MAINWIN_OPT_TELAPSED: | |
2581 set_timer_mode_menu_cb(TIMER_ELAPSED); | |
2582 break; | |
2583 case MAINWIN_OPT_TREMAINING: | |
2584 set_timer_mode_menu_cb(TIMER_REMAINING); | |
2585 break; | |
2586 case MAINWIN_OPT_ALWAYS: | |
2587 mainwin_menurow->mr_always_selected = GTK_CHECK_MENU_ITEM(item)->active; | |
2588 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
2589 widget_draw(WIDGET(mainwin_menurow)); | |
2590 | |
2591 if (starting_up == FALSE) | |
2592 hint_set_always(cfg.always_on_top); | |
2593 | |
2594 break; | |
2595 case MAINWIN_OPT_STICKY: | |
2596 cfg.sticky = GTK_CHECK_MENU_ITEM(item)->active; | |
2597 hint_set_sticky(cfg.sticky); | |
2598 break; | |
2599 case MAINWIN_OPT_WS: | |
2600 mainwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2601 break; | |
2602 case MAINWIN_OPT_PWS: | |
2603 playlistwin_set_shade(GTK_CHECK_MENU_ITEM(item)->active); | |
2604 break; | |
2605 case MAINWIN_OPT_EQWS: | |
2606 equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2607 break; | |
1775 | 2608 case MAINWIN_SONGNAME_SCROLL: |
2609 check = GTK_CHECK_MENU_ITEM(item); | |
2610 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
2611 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
2612 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
2613 break; | |
1653 | 2614 } |
2615 } | |
2616 | |
2617 void | |
2618 mainwin_vis_menu_callback(gpointer data, | |
2619 guint action, | |
2620 GtkWidget * item) | |
2621 { | |
2622 switch (action) { | |
2623 case MAINWIN_VIS_ANALYZER: | |
2624 case MAINWIN_VIS_SCOPE: | |
2625 case MAINWIN_VIS_OFF: | |
2626 mainwin_vis_set_type_menu_cb(action - MAINWIN_VIS_ANALYZER); | |
2627 break; | |
2628 case MAINWIN_VIS_ANALYZER_NORMAL: | |
2629 case MAINWIN_VIS_ANALYZER_FIRE: | |
2630 case MAINWIN_VIS_ANALYZER_VLINES: | |
2631 mainwin_vis_set_analyzer_mode(action - MAINWIN_VIS_ANALYZER_NORMAL); | |
2632 break; | |
2633 case MAINWIN_VIS_ANALYZER_LINES: | |
2634 case MAINWIN_VIS_ANALYZER_BARS: | |
2635 mainwin_vis_set_analyzer_type(action - MAINWIN_VIS_ANALYZER_LINES); | |
2636 break; | |
2637 case MAINWIN_VIS_ANALYZER_PEAKS: | |
2638 cfg.analyzer_peaks = GTK_CHECK_MENU_ITEM(item)->active; | |
2639 break; | |
2640 case MAINWIN_VIS_SCOPE_DOT: | |
2641 case MAINWIN_VIS_SCOPE_LINE: | |
2642 case MAINWIN_VIS_SCOPE_SOLID: | |
2643 cfg.scope_mode = action - MAINWIN_VIS_SCOPE_DOT; | |
2644 break; | |
2645 case MAINWIN_VIS_VU_NORMAL: | |
2646 case MAINWIN_VIS_VU_SMOOTH: | |
2647 cfg.vu_mode = action - MAINWIN_VIS_VU_NORMAL; | |
2648 break; | |
2649 case MAINWIN_VIS_REFRESH_FULL: | |
2650 case MAINWIN_VIS_REFRESH_HALF: | |
2651 case MAINWIN_VIS_REFRESH_QUARTER: | |
2652 case MAINWIN_VIS_REFRESH_EIGHTH: | |
2653 mainwin_vis_set_refresh(action - MAINWIN_VIS_REFRESH_FULL); | |
2654 break; | |
2655 case MAINWIN_VIS_AFALLOFF_SLOWEST: | |
2656 case MAINWIN_VIS_AFALLOFF_SLOW: | |
2657 case MAINWIN_VIS_AFALLOFF_MEDIUM: | |
2658 case MAINWIN_VIS_AFALLOFF_FAST: | |
2659 case MAINWIN_VIS_AFALLOFF_FASTEST: | |
2660 mainwin_vis_set_afalloff(action - MAINWIN_VIS_AFALLOFF_SLOWEST); | |
2661 break; | |
2662 case MAINWIN_VIS_PFALLOFF_SLOWEST: | |
2663 case MAINWIN_VIS_PFALLOFF_SLOW: | |
2664 case MAINWIN_VIS_PFALLOFF_MEDIUM: | |
2665 case MAINWIN_VIS_PFALLOFF_FAST: | |
2666 case MAINWIN_VIS_PFALLOFF_FASTEST: | |
2667 mainwin_vis_set_pfalloff(action - MAINWIN_VIS_PFALLOFF_SLOWEST); | |
2668 break; | |
2669 } | |
2670 } | |
2671 | |
2672 void | |
2673 mainwin_general_menu_callback(gpointer data, | |
2674 guint action, | |
2675 GtkWidget * item) | |
2676 { | |
2677 switch (action) { | |
2678 case MAINWIN_GENERAL_PREFS: | |
2679 show_prefs_window(); | |
2680 break; | |
2681 case MAINWIN_GENERAL_ABOUT: | |
2682 show_about_window(); | |
2683 break; | |
2684 case MAINWIN_GENERAL_PLAYFILE: | |
2685 util_run_filebrowser(NO_PLAY_BUTTON); | |
2686 break; | |
2687 case MAINWIN_GENERAL_PLAYCD: | |
2688 play_medium(); | |
2689 break; | |
2690 case MAINWIN_GENERAL_ADDCD: | |
2691 add_medium(); | |
2692 break; | |
2693 case MAINWIN_GENERAL_PLAYLOCATION: | |
2694 mainwin_show_add_url_window(); | |
2695 break; | |
2696 case MAINWIN_GENERAL_FILEINFO: | |
2697 playlist_fileinfo_current(); | |
2698 break; | |
2699 case MAINWIN_GENERAL_FOCUSPLWIN: | |
2700 gtk_window_present(GTK_WINDOW(playlistwin)); | |
2701 break; | |
2702 case MAINWIN_GENERAL_SHOWMWIN: | |
2703 mainwin_show(GTK_CHECK_MENU_ITEM(item)->active); | |
2704 break; | |
2705 case MAINWIN_GENERAL_SHOWPLWIN: | |
2706 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2707 playlistwin_show(); | |
2708 else | |
2709 playlistwin_hide(); | |
2710 break; | |
2711 case MAINWIN_GENERAL_SHOWEQWIN: | |
2712 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2713 equalizerwin_real_show(); | |
2714 else | |
2715 equalizerwin_real_hide(); | |
2716 break; | |
2717 case MAINWIN_GENERAL_PREV: | |
2718 playlist_prev(); | |
2719 break; | |
2720 case MAINWIN_GENERAL_PLAY: | |
2721 mainwin_play_pushed(); | |
2722 break; | |
2723 case MAINWIN_GENERAL_PAUSE: | |
2724 bmp_playback_pause(); | |
2725 break; | |
2726 case MAINWIN_GENERAL_STOP: | |
2727 mainwin_stop_pushed(); | |
2728 break; | |
2729 case MAINWIN_GENERAL_NEXT: | |
2730 playlist_next(); | |
2731 break; | |
2732 case MAINWIN_GENERAL_BACK5SEC: | |
2733 if (bmp_playback_get_playing() | |
2734 && playlist_get_current_length() != -1) | |
2735 bmp_playback_seek_relative(-5); | |
2736 break; | |
2737 case MAINWIN_GENERAL_FWD5SEC: | |
2738 if (bmp_playback_get_playing() | |
2739 && playlist_get_current_length() != -1) | |
2740 bmp_playback_seek_relative(5); | |
2741 break; | |
2742 case MAINWIN_GENERAL_START: | |
2743 playlist_set_position(0); | |
2744 break; | |
2745 case MAINWIN_GENERAL_JTT: | |
2746 mainwin_jump_to_time(); | |
2747 break; | |
2748 case MAINWIN_GENERAL_JTF: | |
2749 mainwin_jump_to_file(); | |
2750 break; | |
2751 case MAINWIN_GENERAL_EXIT: | |
2752 mainwin_quit_cb(); | |
2753 break; | |
2754 } | |
2755 } | |
2756 | |
2757 static void | |
2758 mainwin_mr_change(MenuRowItem i) | |
2759 { | |
2760 switch (i) { | |
2761 case MENUROW_NONE: | |
2762 mainwin_set_info_text(); | |
2763 break; | |
2764 case MENUROW_OPTIONS: | |
2765 mainwin_lock_info_text(_("OPTIONS MENU")); | |
2766 break; | |
2767 case MENUROW_ALWAYS: | |
2768 if (mainwin_menurow->mr_always_selected) | |
2769 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); | |
2770 else | |
2771 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
2772 break; | |
2773 case MENUROW_FILEINFOBOX: | |
2774 mainwin_lock_info_text(_("FILE INFO BOX")); | |
2775 break; | |
2776 case MENUROW_DOUBLESIZE: | |
2777 mainwin_lock_info_text(_("** DOUBLESIZE HAS BEEN REMOVED **")); | |
2778 break; | |
2779 case MENUROW_VISUALIZATION: | |
2780 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
2781 break; | |
2782 } | |
2783 } | |
2784 | |
2785 static void | |
2786 mainwin_mr_release(MenuRowItem i) | |
2787 { | |
2788 GdkModifierType modmask; | |
2789 GtkWidget *widget; | |
2790 gint x, y; | |
2791 | |
2792 switch (i) { | |
2793 case MENUROW_OPTIONS: | |
2794 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2795 util_item_factory_popup(mainwin_view_menu, x, y, 1, | |
2796 GDK_CURRENT_TIME); | |
2797 break; | |
2798 case MENUROW_ALWAYS: | |
2799 widget = | |
2800 gtk_item_factory_get_widget(mainwin_view_menu, | |
2801 "/Always On Top"); | |
2802 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
2803 mainwin_menurow->mr_always_selected); | |
2804 break; | |
2805 case MENUROW_FILEINFOBOX: | |
2806 playlist_fileinfo_current(); | |
2807 break; | |
2808 case MENUROW_DOUBLESIZE: | |
2809 /* double size removed, do nothing */ | |
2810 break; | |
2811 case MENUROW_VISUALIZATION: | |
2812 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2813 util_item_factory_popup(mainwin_vis_menu, x, y, 1, GDK_CURRENT_TIME); | |
2814 break; | |
2815 case MENUROW_NONE: | |
2816 break; | |
2817 } | |
2818 mainwin_release_info_text(); | |
2819 } | |
2820 | |
2821 static void | |
2822 run_no_audiocd_dialog(void) | |
2823 { | |
2824 const gchar *markup = | |
2825 N_("<b><big>No playable CD found.</big></b>\n\n" | |
2826 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
2827 | |
2828 GtkWidget *dialog = | |
2829 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2830 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2831 GTK_MESSAGE_ERROR, | |
2832 GTK_BUTTONS_OK, | |
2833 _(markup)); | |
2834 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2835 gtk_widget_destroy(dialog); | |
2836 } | |
2837 | |
2838 static void | |
2839 run_no_output_device_dialog(void) | |
2840 { | |
2841 const gchar *markup = | |
2842 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
2843 "Please check that:\n" | |
2844 "1. You have the correct output plugin selected.\n" | |
2845 "2. No other programs is blocking the soundcard.\n" | |
2846 "3. Your soundcard is configured properly.\n"); | |
2847 | |
2848 GtkWidget *dialog = | |
2849 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2850 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2851 GTK_MESSAGE_ERROR, | |
2852 GTK_BUTTONS_OK, | |
2853 _(markup)); | |
2854 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2855 gtk_widget_destroy(dialog); | |
2856 } | |
2857 | |
2858 | |
2859 void | |
2860 add_medium(void) | |
2861 { | |
2862 GList *list, *node; | |
2863 gchar *filename; | |
2864 gchar *path; | |
2865 ConfigDb *db; | |
2866 | |
2867 db = bmp_cfg_db_open(); | |
2868 | |
2869 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2870 bmp_cfg_db_close(db); | |
2871 | |
2872 if (!(list = input_scan_dir(path))) { | |
2873 run_no_audiocd_dialog(); | |
2874 return; | |
2875 } | |
2876 | |
2877 for (node = list; node; node = g_list_next(node)) { | |
2878 filename = g_build_filename(path, node->data, NULL); | |
2879 playlist_add(filename); | |
2880 g_free(filename); | |
2881 g_free(node->data); | |
2882 } | |
2883 | |
2884 g_free(path); | |
2885 g_list_free(list); | |
2886 | |
2887 } | |
2888 | |
2889 void | |
2890 play_medium(void) | |
2891 { | |
2892 GList *list, *node; | |
2893 gchar *filename; | |
2894 gchar *path; | |
2895 ConfigDb *db; | |
2896 | |
2897 db = bmp_cfg_db_open(); | |
2898 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2899 bmp_cfg_db_close(db); | |
2900 | |
2901 if (!(list = input_scan_dir(path))) { | |
2902 run_no_audiocd_dialog(); | |
2903 return; | |
2904 } | |
2905 | |
2906 playlist_clear(); | |
2907 | |
2908 for (node = list; node; node = g_list_next(node)) { | |
2909 filename = g_build_filename(path, node->data, NULL); | |
2910 playlist_add(filename); | |
2911 g_free(filename); | |
2912 g_free(node->data); | |
2913 } | |
2914 | |
2915 g_free(path); | |
2916 g_list_free(list); | |
2917 | |
2918 playlist_set_position(0); | |
2919 bmp_playback_initiate(); | |
2920 } | |
2921 | |
2922 void | |
2923 read_volume(gint when) | |
2924 { | |
2925 static gint pvl = 0, pvr = 0; | |
2926 static gint times = VOLSET_DISP_TIMES; | |
2927 static gboolean changing = FALSE; | |
2928 | |
2929 gint vl, vr, b, v; | |
2930 | |
2931 input_get_volume(&vl, &vr); | |
2932 | |
2933 switch (when) { | |
2934 case VOLSET_STARTUP: | |
2935 vl = CLAMP(vl, 0, 100); | |
2936 vr = CLAMP(vr, 0, 100); | |
2937 pvl = vl; | |
2938 pvr = vr; | |
2939 v = MAX(vl, vr); | |
2940 if (vl > vr) | |
2941 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2942 else if (vl < vr) | |
2943 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2944 else | |
2945 b = 0; | |
2946 | |
2947 balance = b; | |
2948 mainwin_set_volume_slider(v); | |
2949 equalizerwin_set_volume_slider(v); | |
2950 mainwin_set_balance_slider(b); | |
2951 equalizerwin_set_balance_slider(b); | |
2952 return; | |
2953 | |
2954 case VOLSET_UPDATE: | |
2955 if (vl == -1 || vr == -1) | |
2956 return; | |
2957 | |
2958 if (setting_volume) { | |
2959 pvl = vl; | |
2960 pvr = vr; | |
2961 return; | |
2962 } | |
2963 | |
2964 if (pvr == vr && pvl == vl && changing) { | |
2965 if (times < VOLSET_DISP_TIMES) | |
2966 times++; | |
2967 else { | |
2968 mainwin_release_info_text(); | |
2969 changing = FALSE; | |
2970 } | |
2971 } | |
2972 else if (pvr != vr || pvl != vl) { | |
2973 gchar *tmp; | |
2974 | |
2975 v = MAX(vl, vr); | |
2976 if (vl > vr) | |
2977 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2978 else if (vl < vr) | |
2979 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2980 else | |
2981 b = 0; | |
2982 | |
2983 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
2984 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2985 else { | |
2986 if (vl > vr) { | |
2987 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2988 } | |
2989 else if (vr == vl) | |
2990 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
2991 else { /* (vl < vr) */ | |
2992 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2993 } | |
2994 } | |
2995 mainwin_lock_info_text(tmp); | |
2996 g_free(tmp); | |
2997 | |
2998 pvr = vr; | |
2999 pvl = vl; | |
3000 times = 0; | |
3001 changing = TRUE; | |
3002 mainwin_set_volume_slider(v); | |
3003 equalizerwin_set_volume_slider(v); | |
3004 | |
3005 /* Don't change the balance slider if the volume has been | |
3006 * set to zero. The balance can be anything, and our best | |
3007 * guess is what is was before. */ | |
3008 if (v > 0) { | |
3009 balance = b; | |
3010 mainwin_set_balance_slider(b); | |
3011 equalizerwin_set_balance_slider(b); | |
3012 } | |
3013 } | |
3014 break; | |
3015 | |
3016 case VOLUME_ADJUSTED: | |
3017 pvl = vl; | |
3018 pvr = vr; | |
3019 break; | |
3020 | |
3021 case VOLUME_SET: | |
3022 times = 0; | |
3023 changing = TRUE; | |
3024 pvl = vl; | |
3025 pvr = vr; | |
3026 break; | |
3027 } | |
3028 } | |
3029 | |
3030 | |
3031 /* TODO: HAL! */ | |
3032 gboolean | |
3033 can_play_cd(void) | |
3034 { | |
3035 GList *ilist; | |
3036 | |
3037 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
3038 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
3039 | |
3040 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
3041 PLUGIN_FILENAME("cdaudio"))) { | |
3042 return TRUE; | |
3043 } | |
3044 } | |
3045 | |
3046 return FALSE; | |
3047 } | |
3048 | |
3049 | |
3050 static void | |
3051 set_timer_mode(TimerMode mode) | |
3052 { | |
3053 if (mode == TIMER_ELAPSED) | |
3054 check_set(mainwin_view_menu, "/Time Elapsed", TRUE); | |
3055 else | |
3056 check_set(mainwin_view_menu, "/Time Remaining", TRUE); | |
3057 } | |
3058 | |
3059 static void | |
3060 set_timer_mode_menu_cb(TimerMode mode) | |
3061 { | |
3062 cfg.timer_mode = mode; | |
3063 } | |
3064 | |
3065 | |
3066 void | |
3067 mainwin_setup_menus(void) | |
3068 { | |
3069 set_timer_mode(cfg.timer_mode); | |
3070 | |
3071 /* View menu */ | |
3072 | |
3073 check_set(mainwin_view_menu, "/Always On Top", cfg.always_on_top); | |
3074 check_set(mainwin_view_menu, "/Put on All Workspaces", cfg.sticky); | |
3075 check_set(mainwin_view_menu, "/Roll up Player", cfg.player_shaded); | |
3076 check_set(mainwin_view_menu, "/Roll up Playlist Editor", cfg.playlist_shaded); | |
3077 check_set(mainwin_view_menu, "/Roll up Equalizer", cfg.equalizer_shaded); | |
3078 | |
3079 /* Songname menu */ | |
3080 | |
3081 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
3082 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
3083 | |
3084 /* Playback menu */ | |
3085 | |
3086 check_set(mainwin_play_menu, "/Repeat", cfg.repeat); | |
3087 check_set(mainwin_play_menu, "/Shuffle", cfg.shuffle); | |
3088 check_set(mainwin_play_menu, "/No Playlist Advance", cfg.no_playlist_advance); | |
3089 | |
3090 /* Visualization menu */ | |
3091 | |
3092 check_set(mainwin_vis_menu, | |
3093 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + | |
3094 cfg.vis_type].path, TRUE); | |
3095 check_set(mainwin_vis_menu, | |
3096 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_MODE + | |
3097 cfg.analyzer_mode].path, TRUE); | |
3098 check_set(mainwin_vis_menu, | |
3099 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_TYPE + | |
3100 cfg.analyzer_type].path, TRUE); | |
3101 check_set(mainwin_vis_menu, | |
3102 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_PEAKS]. | |
3103 path, cfg.analyzer_peaks); | |
3104 check_set(mainwin_vis_menu, | |
3105 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_SCOPE_MODE + | |
3106 cfg.scope_mode].path, TRUE); | |
3107 check_set(mainwin_vis_menu, | |
3108 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_WSHADEVU_MODE + | |
3109 cfg.vu_mode].path, TRUE); | |
3110 check_set(mainwin_vis_menu, | |
3111 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_REFRESH_RATE + | |
3112 cfg.vis_refresh].path, TRUE); | |
3113 check_set(mainwin_vis_menu, | |
3114 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_AFALLOFF + | |
3115 cfg.analyzer_falloff].path, TRUE); | |
3116 check_set(mainwin_vis_menu, | |
3117 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_PFALLOFF + | |
3118 cfg.peaks_falloff].path, TRUE); | |
3119 } | |
3120 | |
3121 static void | |
3122 mainwin_create_widgets(void) | |
3123 { | |
3124 mainwin_menubtn = | |
3125 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
3126 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
3127 mainwin_menubtn->pb_allow_draw = FALSE; | |
3128 mainwin_minimize = | |
3129 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
3130 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
3131 mainwin_minimize->pb_allow_draw = FALSE; | |
3132 mainwin_shade = | |
3133 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
3134 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
3135 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
3136 SKIN_TITLEBAR); | |
3137 mainwin_shade->pb_allow_draw = FALSE; | |
3138 mainwin_close = | |
3139 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
3140 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
3141 mainwin_close->pb_allow_draw = FALSE; | |
3142 | |
3143 mainwin_rew = | |
3144 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 88, 23, | |
3145 18, 0, 0, 0, 18, mainwin_rev_pushed, mainwin_rev_release, | |
3146 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
3147 mainwin_play = | |
3148 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
3149 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
3150 mainwin_pause = | |
3151 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
3152 18, 46, 0, 46, 18, bmp_playback_pause, SKIN_CBUTTONS); | |
3153 mainwin_stop = | |
3154 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
3155 18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS); | |
3156 #if 0 | |
3157 mainwin_fwd = | |
3158 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3159 18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS); | |
3160 #endif | |
3161 mainwin_fwd = | |
3162 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3163 18, 92, 0, 92, 18, mainwin_fwd_pushed, mainwin_fwd_release, | |
3164 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
3165 | |
3166 mainwin_eject = | |
3167 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
3168 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
3169 SKIN_CBUTTONS); | |
3170 | |
3171 mainwin_srew = | |
3172 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
3173 7, playlist_prev); | |
3174 mainwin_splay = | |
3175 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
3176 7, mainwin_play_pushed); | |
3177 mainwin_spause = | |
3178 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
3179 7, bmp_playback_pause); | |
3180 mainwin_sstop = | |
3181 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
3182 7, mainwin_stop_pushed); | |
3183 mainwin_sfwd = | |
3184 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
3185 7, playlist_next); | |
3186 mainwin_seject = | |
3187 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
3188 7, mainwin_eject_pushed); | |
3189 | |
3190 mainwin_shuffle = | |
3191 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
3192 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
3193 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
3194 | |
3195 mainwin_repeat = | |
3196 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
3197 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
3198 mainwin_repeat_pushed, SKIN_SHUFREP); | |
3199 | |
3200 mainwin_eq = | |
3201 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
3202 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
3203 SKIN_SHUFREP); | |
3204 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
3205 mainwin_pl = | |
3206 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
3207 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
3208 mainwin_pl_pushed, SKIN_SHUFREP); | |
3209 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
3210 | |
3211 mainwin_info = | |
3212 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
3213 153, 1, SKIN_TEXT); | |
3214 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
3215 textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); | |
3216 | |
3217 mainwin_othertext = | |
3218 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 43, | |
3219 153, 1, SKIN_TEXT); | |
3220 | |
3221 mainwin_rate_text = | |
3222 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
3223 0, SKIN_TEXT); | |
3224 mainwin_freq_text = | |
3225 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
3226 0, SKIN_TEXT); | |
3227 | |
3228 mainwin_menurow = | |
3229 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
3230 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
3231 SKIN_TITLEBAR); | |
3232 mainwin_menurow->mr_doublesize_selected = FALSE; | |
3233 mainwin_menurow->mr_always_selected = cfg.always_on_top; | |
3234 | |
3235 mainwin_volume = | |
3236 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
3237 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
3238 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
3239 mainwin_volume_release_cb, SKIN_VOLUME); | |
3240 mainwin_balance = | |
3241 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
3242 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
3243 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
3244 mainwin_balance_release_cb, SKIN_BALANCE); | |
3245 | |
3246 mainwin_monostereo = | |
3247 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
3248 SKIN_MONOSTEREO); | |
3249 | |
3250 mainwin_playstatus = | |
3251 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
3252 | |
3253 mainwin_minus_num = | |
3254 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
3255 SKIN_NUMBERS); | |
3256 widget_hide(WIDGET(mainwin_minus_num)); | |
3257 mainwin_10min_num = | |
3258 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
3259 SKIN_NUMBERS); | |
3260 widget_hide(WIDGET(mainwin_10min_num)); | |
3261 | |
3262 mainwin_min_num = | |
3263 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
3264 SKIN_NUMBERS); | |
3265 widget_hide(WIDGET(mainwin_min_num)); | |
3266 | |
3267 mainwin_10sec_num = | |
3268 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
3269 SKIN_NUMBERS); | |
3270 widget_hide(WIDGET(mainwin_10sec_num)); | |
3271 | |
3272 mainwin_sec_num = | |
3273 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
3274 SKIN_NUMBERS); | |
3275 widget_hide(WIDGET(mainwin_sec_num)); | |
3276 | |
3277 mainwin_about = | |
3278 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
3279 25, show_about_window); | |
3280 | |
3281 mainwin_vis = | |
3282 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
3283 24, 43, 76); | |
3284 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); | |
3285 active_vis = mainwin_vis; | |
3286 | |
3287 mainwin_position = | |
3288 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
3289 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
3290 mainwin_position_motion_cb, | |
3291 mainwin_position_release_cb, SKIN_POSBAR); | |
3292 widget_hide(WIDGET(mainwin_position)); | |
3293 | |
3294 mainwin_sposition = | |
3295 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
3296 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
3297 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
3298 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
3299 widget_hide(WIDGET(mainwin_sposition)); | |
3300 | |
3301 mainwin_stime_min = | |
3302 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
3303 FALSE, SKIN_TEXT); | |
3304 mainwin_stime_sec = | |
3305 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
3306 FALSE, SKIN_TEXT); | |
3307 | |
3308 if (!cfg.player_shaded) { | |
3309 widget_hide(WIDGET(mainwin_svis)); | |
3310 widget_hide(WIDGET(mainwin_srew)); | |
3311 widget_hide(WIDGET(mainwin_splay)); | |
3312 widget_hide(WIDGET(mainwin_spause)); | |
3313 widget_hide(WIDGET(mainwin_sstop)); | |
3314 widget_hide(WIDGET(mainwin_sfwd)); | |
3315 widget_hide(WIDGET(mainwin_seject)); | |
3316 widget_hide(WIDGET(mainwin_stime_min)); | |
3317 widget_hide(WIDGET(mainwin_stime_sec)); | |
3318 } | |
3319 | |
3320 err = gtk_message_dialog_new(GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, | |
3321 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,"Error in Audacious."); | |
3322 | |
3323 | |
3324 gtk_window_set_position(GTK_WINDOW(err), GTK_WIN_POS_CENTER); | |
3325 /* Dang well better set an error message or you'll see this */ | |
3326 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), | |
3327 "Boo! Bad stuff! Booga Booga!"); | |
3328 | |
3329 } | |
3330 | |
3331 static void | |
3332 mainwin_create_window(void) | |
3333 { | |
3334 gint width, height; | |
3335 | |
3336 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3337 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
3338 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
3339 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
3340 | |
3341 width = MAINWIN_WIDTH; | |
3342 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : MAINWIN_HEIGHT; | |
3343 | |
3344 gtk_widget_set_size_request(mainwin, width, height); | |
3345 gtk_widget_set_app_paintable(mainwin, TRUE); | |
3346 | |
3347 dock_window_list = dock_window_set_decorated(dock_window_list, | |
3348 GTK_WINDOW(mainwin), | |
3349 cfg.show_wm_decorations); | |
3350 | |
3351 if (cfg.player_x != -1 && cfg.save_window_position) | |
3352 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
3353 | |
3354 gtk_widget_add_events(mainwin, | |
3355 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
3356 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
3357 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
3358 GDK_VISIBILITY_NOTIFY_MASK); | |
3359 gtk_widget_realize(mainwin); | |
3360 | |
3361 util_set_cursor(mainwin); | |
3362 | |
3363 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
3364 g_signal_connect(mainwin, "button_press_event", | |
3365 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
3366 g_signal_connect(mainwin, "scroll_event", | |
3367 G_CALLBACK(mainwin_scrolled), NULL); | |
3368 g_signal_connect(mainwin, "button_release_event", | |
3369 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
3370 g_signal_connect(mainwin, "motion_notify_event", | |
3371 G_CALLBACK(mainwin_motion), NULL); | |
3372 g_signal_connect_after(mainwin, "focus_in_event", | |
3373 G_CALLBACK(mainwin_focus_in), NULL); | |
3374 g_signal_connect_after(mainwin, "focus_out_event", | |
3375 G_CALLBACK(mainwin_focus_out), NULL); | |
3376 g_signal_connect(mainwin, "configure_event", | |
3377 G_CALLBACK(mainwin_configure), NULL); | |
3378 g_signal_connect(mainwin, "style_set", | |
3379 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
3380 | |
3381 bmp_drag_dest_set(mainwin); | |
3382 | |
3383 g_signal_connect(mainwin, "key_press_event", | |
3384 G_CALLBACK(mainwin_keypress), NULL); | |
3385 } | |
3386 | |
3387 static void | |
3388 mainwin_create_menus(void) | |
3389 { | |
3390 mainwin_general_menu = create_menu(mainwin_general_menu_entries, | |
3391 mainwin_general_menu_entries_num, | |
3392 mainwin_accel); | |
3393 | |
3394 mainwin_play_menu = create_menu(mainwin_playback_menu_entries, | |
3395 mainwin_playback_menu_entries_num, | |
3396 mainwin_accel); | |
3397 | |
3398 mainwin_view_menu = create_menu(mainwin_view_menu_entries, | |
3399 mainwin_view_menu_entries_num, | |
3400 mainwin_accel); | |
3401 | |
3402 mainwin_songname_menu = create_menu(mainwin_songname_menu_entries, | |
3403 mainwin_songname_menu_entries_num, | |
3404 mainwin_accel); | |
3405 | |
3406 mainwin_add_menu = create_menu(mainwin_add_menu_entries, | |
3407 mainwin_add_menu_entries_num, | |
3408 mainwin_accel); | |
3409 | |
3410 mainwin_vis_menu = create_menu(mainwin_vis_menu_entries, | |
3411 mainwin_vis_menu_entries_num, | |
3412 mainwin_accel); | |
3413 | |
3414 make_submenu(mainwin_general_menu, "/View", mainwin_view_menu); | |
3415 make_submenu(mainwin_general_menu, "/Playback", mainwin_play_menu); | |
3416 make_submenu(mainwin_general_menu, "/Visualization", mainwin_vis_menu); | |
3417 | |
3418 gtk_window_add_accel_group(GTK_WINDOW(mainwin), mainwin_accel); | |
3419 } | |
3420 | |
3421 void | |
3422 mainwin_create(void) | |
3423 { | |
3424 mainwin_create_window(); | |
3425 | |
3426 mainwin_accel = gtk_accel_group_new(); | |
3427 mainwin_create_menus(); | |
3428 | |
3429 mainwin_gc = gdk_gc_new(mainwin->window); | |
3430 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
3431 MAINWIN_WIDTH, MAINWIN_HEIGHT, -1); | |
3432 mainwin_set_back_pixmap(); | |
3433 mainwin_create_widgets(); | |
3434 | |
3435 vis_set_window(mainwin_vis, mainwin->window); | |
3436 } | |
3437 | |
3438 void | |
3439 mainwin_attach_idle_func(void) | |
3440 { | |
3441 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
3442 mainwin_idle_func, NULL); | |
3443 } | |
3444 | |
3445 static void | |
3446 idle_func_update_song_info(gint time) | |
3447 { | |
3448 gint length, t; | |
3449 gchar stime_prefix; | |
3450 | |
3451 length = playlist_get_current_length(); | |
3452 if (bmp_playback_get_playing()) | |
3453 playlistwin_set_time(time, length, cfg.timer_mode); | |
3454 else | |
3455 playlistwin_hide_timer(); | |
3456 input_update_vis(time); | |
3457 | |
3458 if (cfg.timer_mode == TIMER_REMAINING) { | |
3459 if (length != -1) { | |
3460 number_set_number(mainwin_minus_num, 11); | |
3461 t = length - time; | |
3462 stime_prefix = '-'; | |
3463 } | |
3464 else { | |
3465 number_set_number(mainwin_minus_num, 10); | |
3466 t = time; | |
3467 stime_prefix = ' '; | |
3468 } | |
3469 } | |
3470 else { | |
3471 number_set_number(mainwin_minus_num, 10); | |
3472 t = time; | |
3473 stime_prefix = ' '; | |
3474 } | |
3475 t /= 1000; | |
3476 | |
3477 /* Show the time in the format HH:MM when we have more than 100 | |
3478 * minutes. */ | |
3479 if (t >= 100 * 60) | |
3480 t /= 60; | |
3481 number_set_number(mainwin_10min_num, t / 600); | |
3482 number_set_number(mainwin_min_num, (t / 60) % 10); | |
3483 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
3484 number_set_number(mainwin_sec_num, t % 10); | |
3485 | |
3486 if (!mainwin_sposition->hs_pressed) { | |
3487 gchar *time_str; | |
3488 | |
3489 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
3490 textbox_set_text(mainwin_stime_min, time_str); | |
3491 g_free(time_str); | |
3492 | |
3493 time_str = g_strdup_printf("%2.2d", t % 60); | |
3494 textbox_set_text(mainwin_stime_sec, time_str); | |
3495 g_free(time_str); | |
3496 } | |
3497 | |
3498 time /= 1000; | |
3499 length /= 1000; | |
3500 if (length > 0) { | |
3501 if (time > length) { | |
3502 hslider_set_position(mainwin_position, 219); | |
3503 hslider_set_position(mainwin_sposition, 13); | |
3504 } | |
3505 /* update the slider position ONLY if there is not a seek in progress */ | |
3506 else if (seek_state == MAINWIN_SEEK_NIL) { | |
3507 hslider_set_position(mainwin_position, (time * 219) / length); | |
3508 hslider_set_position(mainwin_sposition, | |
3509 ((time * 12) / length) + 1); | |
3510 } | |
3511 } | |
3512 else { | |
3513 hslider_set_position(mainwin_position, 0); | |
3514 hslider_set_position(mainwin_sposition, 1); | |
3515 } | |
3516 } | |
3517 | |
3518 static gboolean | |
3519 mainwin_idle_func(gpointer data) | |
3520 { | |
3521 static gint count = 0; | |
3522 gint time = 0; | |
3523 | |
3524 /* run audcore events, then run our own. --nenolod */ | |
3525 switch((time = audcore_generic_events())) | |
3526 { | |
3527 case -2: | |
3528 /* no usable output device */ | |
3529 GDK_THREADS_ENTER(); | |
3530 run_no_output_device_dialog(); | |
3531 mainwin_stop_pushed(); | |
3532 GDK_THREADS_LEAVE(); | |
3533 ev_waiting = FALSE; | |
3534 break; | |
3535 | |
3536 default: | |
3537 idle_func_update_song_info(time); | |
3538 /* nothing at this time */ | |
3539 } | |
3540 | |
3541 GDK_THREADS_ENTER(); | |
3542 | |
3543 if (bmp_playback_get_playing()) | |
3544 vis_playback_start(); | |
3545 else | |
3546 vis_playback_stop(); | |
3547 | |
3548 draw_main_window(mainwin_force_redraw); | |
3549 | |
3550 if (!count) { | |
3551 read_volume(VOLSET_UPDATE); | |
3552 count = 10; | |
3553 } | |
3554 else | |
3555 count--; | |
3556 | |
3557 mainwin_force_redraw = FALSE; | |
3558 draw_playlist_window(FALSE); | |
3559 draw_equalizer_window(FALSE); | |
3560 | |
3561 if (mainwin_title_text) { | |
3562 G_LOCK(mainwin_title); | |
3563 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
3564 g_free(mainwin_title_text); | |
3565 mainwin_title_text = NULL; | |
3566 G_UNLOCK(mainwin_title); | |
3567 | |
3568 mainwin_set_info_text(); | |
3569 playlistwin_update_list(); | |
3570 } | |
3571 | |
3572 /* tristate buttons seek */ | |
3573 if ( seek_state != MAINWIN_SEEK_NIL ) | |
3574 { | |
3575 GTimeVal now_time; | |
3576 GTimeVal delta_time; | |
3577 gulong now_dur; | |
3578 g_get_current_time(&now_time); | |
3579 | |
3580 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
3581 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
3582 | |
3583 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
3584 | |
3585 if ( now_dur > TRISTATE_THRESHOLD ) | |
3586 { | |
3587 gint np; | |
3588 if (seek_state == MAINWIN_SEEK_REV) | |
3589 np = seek_initial_pos - labs((gulong)(now_dur/100)); /* seek back */ | |
3590 else | |
3591 np = seek_initial_pos + labs((gulong)(now_dur/100)); /* seek forward */ | |
3592 | |
3593 /* boundaries check */ | |
3594 if (np < 0 ) | |
3595 np = 0; | |
3596 else if ( np > 219 ) | |
3597 np = 219; | |
3598 | |
3599 hslider_set_position( mainwin_position , np ); | |
3600 mainwin_position_motion_cb( np ); | |
3601 } | |
3602 } | |
3603 | |
3604 GDK_THREADS_LEAVE(); | |
3605 | |
3606 /* | |
3607 if (seek_state == MAINWIN_SEEK_REV) | |
3608 bmp_playback_seek(CLAMP(bmp_playback_get_time() - 1000, 0, | |
3609 playlist_get_current_length()) / 1000); | |
3610 else if (seek_state == MAINWIN_SEEK_FWD) | |
3611 bmp_playback_seek(CLAMP(bmp_playback_get_time() + 1000, 0, | |
3612 playlist_get_current_length()) / 1000); | |
3613 */ | |
3614 | |
3615 return TRUE; | |
3616 } |