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