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