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