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