Mercurial > audlegacy
annotate audacious/mainwin.c @ 2006:beaeb1990cb4 trunk
[svn] - now filepopup can find newly added images immediately.
author | yaz |
---|---|
date | Sat, 25 Nov 2006 00:31:33 -0800 |
parents | 327bc75fb21a |
children | 99d652a3bf67 |
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 |
1940 | 1054 dock_window_resize(GTK_WINDOW(mainwin), cfg.player_shaded ? MAINWIN_SHADED_WIDTH : bmp_active_skin->properties.mainwin_width * (cfg.doublesize + 1), |
1055 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : 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 | |
1548 (bmp_playback_get_time() - 1000, 0, | |
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 | |
1556 (bmp_playback_get_time() + 1000, 0, | |
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; | |
1846 | |
1944 | 1847 for (i = 0; keys[i] != NULL; i++) |
1848 if (strstr(song, keys[i])) | |
1849 return TRUE; | |
1850 | |
1851 return FALSE; | |
1653 | 1852 } |
1853 | |
1854 /* FIXME: Clear the entry when the list gets updated */ | |
1855 static void | |
1856 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
1857 { | |
1858 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
1859 * reading */ | |
1860 gint row; | |
1861 GList *playlist; | |
1862 gchar *desc_buf = NULL; | |
1863 gchar *row_str; | |
1864 GtkTreeIter iter; | |
1865 GtkTreeSelection *selection; | |
1866 | |
1867 GtkTreeModel *store; | |
1868 | |
1869 if (!mainwin_jtf) | |
1870 return; | |
1871 | |
1872 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
1873 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1874 | |
1875 row = 1; | |
1876 for (playlist = playlist_get(); playlist; | |
1877 playlist = g_list_next(playlist)) { | |
1878 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1879 | |
1880 if (entry->title) | |
1881 desc_buf = g_strdup(entry->title); | |
1882 else if (strchr(entry->filename, '/')) | |
1883 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
1884 else | |
1885 desc_buf = str_to_utf8(entry->filename); | |
1886 | |
1887 row_str = g_strdup_printf("%d", row++); | |
1888 | |
1889 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
1890 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
1891 0, row_str, 1, desc_buf, -1); | |
1892 | |
1893 if(desc_buf) { | |
1894 g_free(desc_buf); | |
1895 desc_buf = NULL; | |
1896 } | |
1897 | |
1898 g_free(row_str); | |
1899 } | |
1900 | |
1901 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1902 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
1903 gtk_tree_selection_select_iter(selection, &iter); | |
1904 } | |
1905 | |
1906 static void | |
1907 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
1908 { | |
1909 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
1910 GtkTreeSelection *selection; | |
1911 GtkTreeIter iter; | |
1912 | |
1913 GtkListStore *store; | |
1914 | |
1915 gint song_index = 0; | |
1916 gchar **words; | |
1917 GList *playlist; | |
1918 | |
1919 gboolean match = FALSE; | |
1920 | |
1921 /* Chop the key string into ' '-separated key words */ | |
1922 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
1923 | |
1924 /* FIXME: Remove the connected signals before clearing | |
1925 * (row-selected will still eventually arrive once) */ | |
1926 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
1927 gtk_list_store_clear(store); | |
1928 | |
1929 PLAYLIST_LOCK(); | |
1930 | |
1931 for (playlist = playlist_get(); playlist; | |
1932 playlist = g_list_next(playlist)) { | |
1933 | |
1934 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1935 const gchar *title; | |
1936 gchar *filename = NULL; | |
1937 | |
1938 title = entry->title; | |
1939 if (!title) { | |
1940 filename = str_to_utf8(entry->filename); | |
1941 | |
1942 if (strchr(filename, '/')) | |
1943 title = strrchr(filename, '/') + 1; | |
1944 else | |
1945 title = filename; | |
1946 } | |
1947 | |
1948 /* Compare the key words to the string - if all the words | |
1949 match, add to the ListStore */ | |
1950 | |
1951 /* | |
1952 * FIXME: The search string should be adapted to the | |
1953 * current display setting, e.g. if the user has set it to | |
1954 * "%p - %t" then build the match string like that too, or | |
1955 * even better, search for each of the tags seperatly. | |
1956 * | |
1957 * In any case the string to match should _never_ contain | |
1958 * something the user can't actually see in the playlist. | |
1959 */ | |
1946
12bf555c8e47
[svn] - require at least 3 bytes of data to search
nenolod
parents:
1945
diff
changeset
|
1960 if (words[0] != NULL && strlen(words[0]) > 3) |
12bf555c8e47
[svn] - require at least 3 bytes of data to search
nenolod
parents:
1945
diff
changeset
|
1961 match = mainwin_jump_to_file_match(title, words); |
12bf555c8e47
[svn] - require at least 3 bytes of data to search
nenolod
parents:
1945
diff
changeset
|
1962 else |
1945
89e1e4b392b4
[svn] - optimize for single-character searches (dramatic JTF speedboost)
nenolod
parents:
1944
diff
changeset
|
1963 match = TRUE; |
1653 | 1964 |
1965 if (match) { | |
1966 gchar *song_index_str = g_strdup_printf("%d", song_index + 1); | |
1967 gtk_list_store_append(store, &iter); | |
1968 gtk_list_store_set(store, &iter, 0, song_index_str, 1, title, -1); | |
1969 g_free(song_index_str); | |
1970 } | |
1971 | |
1972 song_index++; | |
1973 if (filename) { | |
1974 g_free(filename); | |
1975 filename = NULL; | |
1976 } | |
1977 } | |
1978 | |
1979 PLAYLIST_UNLOCK(); | |
1980 | |
1981 g_strfreev(words); | |
1982 | |
1983 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
1984 selection = gtk_tree_view_get_selection(treeview); | |
1985 gtk_tree_selection_select_iter(selection, &iter); | |
1986 } | |
1987 } | |
1988 | |
1989 void | |
1990 mainwin_jump_to_file(void) | |
1991 { | |
1992 GtkWidget *scrollwin; | |
1993 GtkWidget *vbox, *bbox, *sep; | |
1994 GtkWidget *jump, *queue, *cancel; | |
1995 GtkWidget *rescan, *edit; | |
1996 GtkWidget *search_label, *hbox; | |
1997 GList *playlist; | |
1998 gchar *desc_buf = NULL; | |
1999 gchar *row_str; | |
2000 gint row; | |
2001 | |
2002 GtkWidget *treeview; | |
2003 GtkListStore *jtf_store; | |
2004 | |
2005 GtkTreeIter iter; | |
2006 GtkCellRenderer *renderer; | |
2007 GtkTreeViewColumn *column; | |
2008 | |
2009 if (mainwin_jtf) { | |
2010 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
2011 return; | |
2012 } | |
2013 | |
2014 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
2015 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
2016 GDK_WINDOW_TYPE_HINT_DIALOG); | |
2017 | |
2018 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
2019 | |
2020 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
2021 g_signal_connect(mainwin_jtf, "destroy", | |
2022 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
2023 | |
2024 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
2025 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
2026 | |
2027 vbox = gtk_vbox_new(FALSE, 5); | |
2028 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
2029 | |
2030 jtf_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
2031 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
2032 g_object_unref(jtf_store); | |
2033 | |
2034 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
2035 | |
2036 column = gtk_tree_view_column_new(); | |
2037 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
2038 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
2039 | |
2040 renderer = gtk_cell_renderer_text_new(); | |
2041 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
2042 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
2043 gtk_tree_view_column_set_spacing(column, 4); | |
2044 | |
2045 renderer = gtk_cell_renderer_text_new(); | |
2046 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
2047 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
2048 gtk_tree_view_column_set_spacing(column, 4); | |
2049 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
2050 | |
2051 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); | |
2052 | |
2053 g_signal_connect(treeview, "row-activated", | |
2054 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
2055 | |
2056 hbox = gtk_hbox_new(FALSE, 3); | |
2057 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
2058 | |
2059 search_label = gtk_label_new(_("Filter: ")); | |
2060 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), "_Filter:"); | |
2061 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
2062 | |
2063 edit = gtk_entry_new(); | |
2064 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
2065 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
2066 g_signal_connect(edit, "changed", | |
2067 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
2068 | |
2069 g_signal_connect(edit, "key_press_event", | |
2070 G_CALLBACK(mainwin_jump_to_file_edit_keypress_cb), treeview); | |
2071 | |
2072 g_signal_connect(mainwin_jtf, "key_press_event", | |
2073 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
2074 | |
2075 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
2076 | |
2077 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
2078 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
2079 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
2080 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2081 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
2082 GTK_SHADOW_IN); | |
2083 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
2084 | |
2085 sep = gtk_hseparator_new(); | |
2086 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2087 | |
2088 bbox = gtk_hbutton_box_new(); | |
2089 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
2090 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
2091 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
2092 | |
2093 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
2094 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
2095 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
2096 g_signal_connect(queue, "clicked", | |
2097 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
2098 treeview); | |
2099 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
2100 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
2101 queue); | |
2102 | |
2103 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
2104 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
2105 g_signal_connect(rescan, "clicked", | |
2106 G_CALLBACK(mainwin_update_jtf), treeview); | |
2107 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
2108 gtk_widget_grab_default(rescan); | |
2109 | |
2110 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
2111 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
2112 | |
2113 g_signal_connect_swapped(jump, "clicked", | |
2114 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
2115 treeview); | |
2116 | |
2117 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
2118 gtk_widget_grab_default(jump); | |
2119 | |
2120 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
2121 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
2122 g_signal_connect_swapped(cancel, "clicked", | |
2123 G_CALLBACK(gtk_widget_destroy), | |
2124 mainwin_jtf); | |
2125 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
2126 | |
2127 gtk_list_store_clear(jtf_store); | |
2128 | |
2129 row = 1; | |
2130 | |
2131 PLAYLIST_LOCK(); | |
2132 | |
2133 for (playlist = playlist_get(); playlist; | |
2134 playlist = g_list_next(playlist)) { | |
2135 | |
2136 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
2137 | |
2138 if (entry->title) | |
2139 desc_buf = g_strdup(entry->title); | |
2140 else if (strchr(entry->filename, '/')) | |
2141 desc_buf = str_to_utf8(strrchr(entry->filename, '/') + 1); | |
2142 else | |
2143 desc_buf = str_to_utf8(entry->filename); | |
2144 | |
2145 row_str = g_strdup_printf("%d", row++); | |
2146 | |
2147 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
2148 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
2149 0, row_str, 1, desc_buf, -1); | |
2150 | |
2151 if (desc_buf) { | |
2152 g_free(desc_buf); | |
2153 desc_buf = NULL; | |
2154 } | |
2155 g_free(row_str); | |
2156 } | |
2157 | |
2158 PLAYLIST_UNLOCK(); | |
2159 | |
2160 gtk_widget_show_all(mainwin_jtf); | |
2161 } | |
2162 | |
2163 static gboolean | |
2164 mainwin_configure(GtkWidget * window, | |
2165 GdkEventConfigure * event, | |
2166 gpointer data) | |
2167 { | |
2168 if (!GTK_WIDGET_VISIBLE(window)) | |
2169 return FALSE; | |
2170 | |
2171 if (cfg.show_wm_decorations) | |
2172 gdk_window_get_root_origin(window->window, | |
2173 &cfg.player_x, &cfg.player_y); | |
2174 else | |
2175 gdk_window_get_deskrelative_origin(window->window, | |
2176 &cfg.player_x, &cfg.player_y); | |
2177 return FALSE; | |
2178 } | |
2179 | |
2180 void | |
2181 mainwin_set_back_pixmap(void) | |
2182 { | |
1938 | 2183 if (cfg.doublesize) |
2184 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg_x2, 0); | |
2185 else | |
2186 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
1653 | 2187 gdk_window_clear(mainwin->window); |
2188 } | |
2189 | |
1673 | 2190 /* |
2191 * Rewritten 09/13/06: | |
2192 * | |
2193 * Remove all of this flaky iter/sourcelist/strsplit stuff. | |
2194 * All we care about is the filepath. | |
2195 * | |
2196 * We can figure this out and easily pass it to xmms_urldecode_plain(). | |
2197 * - nenolod | |
2198 */ | |
1653 | 2199 void |
2200 mainwin_drag_data_received(GtkWidget * widget, | |
2201 GdkDragContext * context, | |
2202 gint x, | |
2203 gint y, | |
2204 GtkSelectionData * selection_data, | |
2205 guint info, | |
2206 guint time, | |
2207 gpointer user_data) | |
2208 { | |
1673 | 2209 g_return_if_fail(selection_data != NULL); |
2210 g_return_if_fail(selection_data->data != NULL); | |
2211 | |
2212 if (str_has_prefix_nocase((gchar *) selection_data->data, "fonts:///")) | |
1653 | 2213 { |
1696 | 2214 gchar *path = (gchar *) selection_data->data + 9; /* skip fonts:/// */ |
1673 | 2215 gchar *decoded = xmms_urldecode_plain(path); |
2216 | |
1696 | 2217 cfg.playlist_font = g_strconcat(decoded, strrchr(cfg.playlist_font, ' '), NULL); |
1673 | 2218 playlist_list_set_font(cfg.playlist_font); |
2219 playlistwin_update_list(); | |
2220 | |
2221 g_free(decoded); | |
2222 | |
1653 | 2223 return; |
2224 } | |
2225 | |
1673 | 2226 playlist_clear(); |
2227 playlist_add_url((gchar *) selection_data->data); | |
2228 bmp_playback_initiate(); | |
1653 | 2229 } |
2230 | |
2231 static void | |
2232 on_add_url_add_clicked(GtkWidget * widget, | |
2233 GtkWidget * entry) | |
2234 { | |
2235 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2236 if (text && *text) | |
2237 playlist_add_url(text); | |
2238 } | |
2239 | |
2240 static void | |
2241 on_add_url_ok_clicked(GtkWidget * widget, | |
2242 GtkWidget * entry) | |
2243 { | |
2244 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
2245 if (text && *text) | |
2246 { | |
2247 playlist_clear(); | |
2248 playlist_add_url(text); | |
2249 bmp_playback_initiate(); | |
2250 } | |
2251 } | |
2252 | |
2253 void | |
2254 mainwin_show_add_url_window(void) | |
2255 { | |
2256 static GtkWidget *url_window = NULL; | |
2257 | |
2258 if (!url_window) { | |
2259 url_window = | |
2260 util_add_url_dialog_new(_("Enter location to play:"), | |
2261 G_CALLBACK(on_add_url_ok_clicked), | |
2262 G_CALLBACK(on_add_url_add_clicked)); | |
2263 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
2264 GTK_WINDOW(mainwin)); | |
2265 g_signal_connect(url_window, "destroy", | |
2266 G_CALLBACK(gtk_widget_destroyed), | |
2267 &url_window); | |
2268 } | |
2269 | |
2270 gtk_window_present(GTK_WINDOW(url_window)); | |
2271 } | |
2272 | |
2273 static void | |
2274 check_set(GtkItemFactory * factory, | |
2275 const gchar * path, | |
2276 gboolean active) | |
2277 { | |
2278 GtkWidget *item = gtk_item_factory_get_widget(factory, path); | |
2279 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active); | |
2280 } | |
2281 | |
2282 void | |
2283 mainwin_eject_pushed(void) | |
2284 { | |
2285 util_run_filebrowser(PLAY_BUTTON); | |
2286 } | |
2287 | |
2288 void | |
2289 mainwin_rev_pushed(void) | |
2290 { | |
2291 g_get_current_time(&cb_time); | |
2292 | |
2293 seek_initial_pos = hslider_get_position(mainwin_position); | |
2294 seek_state = MAINWIN_SEEK_REV; | |
2295 } | |
2296 | |
2297 void | |
2298 mainwin_rev_release(void) | |
2299 { | |
2300 GTimeVal now_time; | |
2301 GTimeVal delta_time; | |
2302 gulong now_dur; | |
2303 | |
2304 g_get_current_time(&now_time); | |
2305 | |
2306 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
2307 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
2308 | |
2309 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
2310 | |
2311 if ( now_dur <= TRISTATE_THRESHOLD ) | |
2312 { | |
2313 /* interpret as 'skip to previous song' */ | |
2314 playlist_prev(); | |
2315 } | |
2316 else | |
2317 { | |
2318 /* interpret as 'seek' */ | |
2319 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
2320 } | |
2321 | |
2322 seek_state = MAINWIN_SEEK_NIL; | |
2323 } | |
2324 | |
2325 void | |
2326 mainwin_fwd_pushed(void) | |
2327 { | |
2328 g_get_current_time(&cb_time); | |
2329 | |
2330 seek_initial_pos = hslider_get_position(mainwin_position); | |
2331 seek_state = MAINWIN_SEEK_FWD; | |
2332 } | |
2333 | |
2334 void | |
2335 mainwin_fwd_release(void) | |
2336 { | |
2337 GTimeVal now_time; | |
2338 GTimeVal delta_time; | |
2339 gulong now_dur; | |
2340 | |
2341 g_get_current_time(&now_time); | |
2342 | |
2343 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
2344 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
2345 | |
2346 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
2347 | |
2348 if ( now_dur <= TRISTATE_THRESHOLD ) | |
2349 { | |
2350 /* interpret as 'skip to previous song' */ | |
2351 playlist_next(); | |
2352 } | |
2353 else | |
2354 { | |
2355 /* interpret as 'seek' */ | |
2356 mainwin_position_release_cb( hslider_get_position(mainwin_position) ); | |
2357 } | |
2358 | |
2359 seek_state = MAINWIN_SEEK_NIL; | |
2360 } | |
2361 | |
2362 void | |
2363 mainwin_play_pushed(void) | |
2364 { | |
1893 | 2365 if (ab_position_a != -1) |
2366 bmp_playback_seek(ab_position_a / 1000); | |
1653 | 2367 if (bmp_playback_get_paused()) { |
2368 bmp_playback_pause(); | |
2369 return; | |
2370 } | |
2371 | |
2372 if (playlist_get_length()) | |
2373 bmp_playback_initiate(); | |
2374 else | |
2375 mainwin_eject_pushed(); | |
2376 } | |
2377 | |
2378 void | |
2379 mainwin_stop_pushed(void) | |
2380 { | |
2381 ip_data.stop = TRUE; | |
2382 mainwin_clear_song_info(); | |
2383 bmp_playback_stop(); | |
2384 ip_data.stop = FALSE; | |
2385 } | |
2386 | |
2387 void | |
2388 mainwin_shuffle_pushed(gboolean toggled) | |
2389 { | |
2390 check_set(mainwin_play_menu, "/Shuffle", toggled); | |
2391 } | |
2392 | |
2393 void | |
2394 mainwin_repeat_pushed(gboolean toggled) | |
2395 { | |
2396 check_set(mainwin_play_menu, "/Repeat", toggled); | |
2397 } | |
2398 | |
2399 void | |
2400 mainwin_pl_pushed(gboolean toggled) | |
2401 { | |
2402 if (toggled) | |
2403 playlistwin_show(); | |
2404 else | |
2405 playlistwin_hide(); | |
2406 } | |
2407 | |
2408 gint | |
2409 mainwin_spos_frame_cb(gint pos) | |
2410 { | |
2411 if (mainwin_sposition) { | |
2412 if (pos < 6) | |
2413 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2414 17; | |
2415 else if (pos < 9) | |
2416 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2417 20; | |
2418 else | |
2419 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2420 23; | |
2421 } | |
2422 return 1; | |
2423 } | |
2424 | |
2425 void | |
2426 mainwin_spos_motion_cb(gint pos) | |
2427 { | |
2428 gint time; | |
2429 gchar *time_msg; | |
2430 | |
2431 pos--; | |
2432 | |
2433 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
2434 | |
2435 if (cfg.timer_mode == TIMER_REMAINING) { | |
2436 time = (playlist_get_current_length() / 1000) - time; | |
2437 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
2438 textbox_set_text(mainwin_stime_min, time_msg); | |
2439 g_free(time_msg); | |
2440 } | |
2441 else { | |
2442 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
2443 textbox_set_text(mainwin_stime_min, time_msg); | |
2444 g_free(time_msg); | |
2445 } | |
2446 | |
2447 time_msg = g_strdup_printf("%2.2d", time % 60); | |
2448 textbox_set_text(mainwin_stime_sec, time_msg); | |
2449 g_free(time_msg); | |
2450 } | |
2451 | |
2452 void | |
2453 mainwin_spos_release_cb(gint pos) | |
2454 { | |
2455 bmp_playback_seek(((playlist_get_current_length() / 1000) * | |
2456 (pos - 1)) / 12); | |
2457 } | |
2458 | |
2459 void | |
2460 mainwin_position_motion_cb(gint pos) | |
2461 { | |
2462 gint length, time; | |
2463 gchar *seek_msg; | |
2464 | |
2465 length = playlist_get_current_length() / 1000; | |
2466 time = (length * pos) / 219; | |
2467 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
2468 time / 60, time % 60, | |
2469 length / 60, length % 60, | |
2470 (length != 0) ? (time * 100) / length : 0); | |
2471 mainwin_lock_info_text(seek_msg); | |
2472 g_free(seek_msg); | |
2473 } | |
2474 | |
2475 void | |
2476 mainwin_position_release_cb(gint pos) | |
2477 { | |
2478 gint length, time; | |
2479 | |
2480 length = playlist_get_current_length() / 1000; | |
2481 time = (length * pos) / 219; | |
2482 bmp_playback_seek(time); | |
2483 mainwin_release_info_text(); | |
2484 } | |
2485 | |
2486 gint | |
2487 mainwin_volume_frame_cb(gint pos) | |
2488 { | |
2489 return (gint) rint((pos / 52.0) * 28); | |
2490 } | |
2491 | |
2492 void | |
2493 mainwin_adjust_volume_motion(gint v) | |
2494 { | |
2495 gchar *volume_msg; | |
2496 | |
2497 setting_volume = TRUE; | |
2498 | |
2499 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2500 mainwin_lock_info_text(volume_msg); | |
2501 g_free(volume_msg); | |
2502 | |
2503 if (balance < 0) | |
2504 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
2505 else if (balance > 0) | |
2506 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
2507 else | |
2508 input_set_volume(v, v); | |
2509 } | |
2510 | |
2511 void | |
2512 mainwin_adjust_volume_release(void) | |
2513 { | |
2514 mainwin_release_info_text(); | |
2515 setting_volume = FALSE; | |
2516 read_volume(VOLUME_ADJUSTED); | |
2517 } | |
2518 | |
2519 void | |
2520 mainwin_adjust_balance_motion(gint b) | |
2521 { | |
2522 gchar *balance_msg; | |
2523 gint v, pvl, pvr; | |
2524 | |
2525 setting_volume = TRUE; | |
2526 balance = b; | |
2527 input_get_volume(&pvl, &pvr); | |
2528 v = MAX(pvl, pvr); | |
2529 if (b < 0) { | |
2530 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2531 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
2532 } | |
2533 else if (b == 0) { | |
2534 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
2535 input_set_volume(v, v); | |
2536 } | |
2537 else { /* b > 0 */ | |
2538 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2539 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
2540 } | |
2541 mainwin_lock_info_text(balance_msg); | |
2542 g_free(balance_msg); | |
2543 } | |
2544 | |
2545 void | |
2546 mainwin_adjust_balance_release(void) | |
2547 { | |
2548 mainwin_release_info_text(); | |
2549 setting_volume = FALSE; | |
2550 read_volume(VOLUME_ADJUSTED); | |
2551 } | |
2552 | |
2553 void | |
2554 mainwin_set_volume_slider(gint percent) | |
2555 { | |
2556 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
2557 } | |
2558 | |
2559 void | |
2560 mainwin_set_balance_slider(gint percent) | |
2561 { | |
2562 hslider_set_position(mainwin_balance, | |
2563 (gint) rint(((percent * 12) / 100.0) + 12)); | |
2564 } | |
2565 | |
2566 void | |
2567 mainwin_volume_motion_cb(gint pos) | |
2568 { | |
2569 gint vol = (pos * 100) / 51; | |
2570 mainwin_adjust_volume_motion(vol); | |
2571 equalizerwin_set_volume_slider(vol); | |
2572 } | |
2573 | |
2574 void | |
2575 mainwin_volume_release_cb(gint pos) | |
2576 { | |
2577 mainwin_adjust_volume_release(); | |
2578 } | |
2579 | |
2580 gint | |
2581 mainwin_balance_frame_cb(gint pos) | |
2582 { | |
2583 return ((abs(pos - 12) * 28) / 13); | |
2584 } | |
2585 | |
2586 void | |
2587 mainwin_balance_motion_cb(gint pos) | |
2588 { | |
2589 gint bal = ((pos - 12) * 100) / 12; | |
2590 mainwin_adjust_balance_motion(bal); | |
2591 equalizerwin_set_balance_slider(bal); | |
2592 } | |
2593 | |
2594 void | |
2595 mainwin_balance_release_cb(gint pos) | |
2596 { | |
2597 mainwin_adjust_volume_release(); | |
2598 } | |
2599 | |
2600 void | |
2601 mainwin_set_volume_diff(gint diff) | |
2602 { | |
2603 gint vl, vr, vol; | |
2604 | |
2605 input_get_volume(&vl, &vr); | |
2606 vol = MAX(vl, vr); | |
2607 vol = CLAMP(vol + diff, 0, 100); | |
2608 | |
2609 mainwin_adjust_volume_motion(vol); | |
2610 setting_volume = FALSE; | |
2611 mainwin_set_volume_slider(vol); | |
2612 equalizerwin_set_volume_slider(vol); | |
2613 read_volume(VOLUME_SET); | |
2614 } | |
2615 | |
2616 void | |
2617 mainwin_set_balance_diff(gint diff) | |
2618 { | |
2619 gint b; | |
2620 b = CLAMP(balance + diff, -100, 100); | |
2621 mainwin_adjust_balance_motion(b); | |
2622 setting_volume = FALSE; | |
2623 mainwin_set_balance_slider(b); | |
2624 equalizerwin_set_balance_slider(b); | |
2625 read_volume(VOLUME_SET); | |
2626 } | |
2627 | |
2628 void | |
2629 mainwin_show(gboolean show) | |
2630 { | |
2631 if (show) | |
2632 mainwin_real_show(); | |
2633 else | |
2634 mainwin_real_hide(); | |
2635 } | |
2636 | |
2637 void | |
2638 mainwin_real_show(void) | |
2639 { | |
2640 cfg.player_visible = TRUE; | |
2641 | |
2642 check_set(mainwin_view_menu, "/Show Player", TRUE); | |
2643 | |
2644 if (cfg.player_shaded) | |
2645 vis_clear_data(active_vis); | |
2646 | |
2647 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
2648 mainwin_set_shape_mask(); | |
2649 | |
2650 if (cfg.show_wm_decorations) { | |
2651 if (!pposition_broken && cfg.player_x != -1 | |
2652 && cfg.save_window_position) | |
2653 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2654 | |
2655 gtk_widget_show(mainwin); | |
2656 | |
2657 if (pposition_broken && cfg.player_x != -1 | |
2658 && cfg.save_window_position) | |
2659 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2660 | |
2661 return; | |
2662 } | |
2663 | |
2664 gtk_widget_show_all(mainwin); | |
2665 | |
2666 if (!nullmask) | |
2667 return; | |
2668 | |
2669 g_object_unref(nullmask); | |
2670 nullmask = NULL; | |
2671 | |
2672 gdk_window_set_hints(mainwin->window, 0, 0, | |
1805 | 2673 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : |
2674 bmp_active_skin->properties.mainwin_width, | |
2675 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : | |
2676 bmp_active_skin->properties.mainwin_height, | |
2677 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : | |
2678 bmp_active_skin->properties.mainwin_width, | |
2679 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : | |
2680 bmp_active_skin->properties.mainwin_height, | |
1653 | 2681 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
|
2682 gtk_window_resize(GTK_WINDOW(mainwin), |
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2683 !bmp_active_skin->properties.mainwin_width ? PLAYER_WIDTH : |
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2684 bmp_active_skin->properties.mainwin_width, |
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2685 !bmp_active_skin->properties.mainwin_height ? PLAYER_HEIGHT : |
ae21feb9459c
[svn] - make sure all size requests match the skin size
nenolod
parents:
1806
diff
changeset
|
2686 bmp_active_skin->properties.mainwin_height); |
1653 | 2687 if (cfg.player_x != -1 && cfg.player_y != -1) |
2688 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2689 | |
2690 draw_main_window(TRUE); | |
2691 | |
2692 gtk_window_present(GTK_WINDOW(mainwin)); | |
2693 } | |
2694 | |
2695 void | |
2696 mainwin_real_hide(void) | |
2697 { | |
2698 GdkGC *gc; | |
2699 GdkColor pattern; | |
2700 | |
2701 check_set(mainwin_view_menu, "/Show Player", FALSE); | |
2702 | |
2703 if (cfg.player_shaded) | |
2704 svis_clear_data(mainwin_svis); | |
2705 | |
2706 if (!cfg.show_wm_decorations) { | |
2707 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
2708 gc = gdk_gc_new(nullmask); | |
2709 pattern.pixel = 0; | |
2710 gdk_gc_set_foreground(gc, &pattern); | |
2711 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
2712 gdk_gc_destroy(gc); | |
2713 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
2714 | |
2715 gdk_window_set_hints(mainwin->window, 0, 0, 0, 0, 0, 0, | |
2716 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2717 gdk_window_resize(mainwin->window, 0, 0); | |
2718 } | |
2719 | |
2720 gtk_widget_hide(mainwin); | |
2721 | |
2722 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
2723 cfg.player_visible = FALSE; | |
2724 } | |
2725 | |
2726 static void | |
2727 mainwin_songname_menu_callback(gpointer data, | |
2728 guint action, | |
2729 GtkWidget * item) | |
2730 { | |
2731 GtkCheckMenuItem *check; | |
2732 | |
2733 switch (action) { | |
2734 case MAINWIN_SONGNAME_FILEINFO: | |
2735 playlist_fileinfo_current(); | |
2736 break; | |
2737 case MAINWIN_SONGNAME_JTF: | |
2738 mainwin_jump_to_file(); | |
2739 break; | |
2740 case MAINWIN_SONGNAME_JTT: | |
2741 mainwin_jump_to_time(); | |
2742 break; | |
2743 case MAINWIN_SONGNAME_SCROLL: | |
2744 check = GTK_CHECK_MENU_ITEM(item); | |
2745 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
1775 | 2746 check_set(mainwin_view_menu, "/Autoscroll Songname", cfg.autoscroll); |
2747 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
1653 | 2748 break; |
2749 case MAINWIN_SONGNAME_STOPAFTERSONG: | |
2750 check = GTK_CHECK_MENU_ITEM(item); | |
2751 cfg.stopaftersong = gtk_check_menu_item_get_active(check); | |
2752 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2753 check_set(mainwin_play_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2754 break; | |
2755 } | |
2756 } | |
2757 | |
2758 void | |
2759 mainwin_set_stopaftersong(gboolean stop) | |
2760 { | |
2761 cfg.stopaftersong = stop; | |
2762 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2763 } | |
2764 | |
2765 static void | |
2766 mainwin_play_menu_callback(gpointer data, | |
2767 guint action, | |
2768 GtkWidget * item) | |
2769 { | |
2770 GtkCheckMenuItem *check; | |
2771 | |
2772 switch (action) { | |
2773 case MAINWIN_OPT_SHUFFLE: | |
2774 check = GTK_CHECK_MENU_ITEM(item); | |
2775 cfg.shuffle = gtk_check_menu_item_get_active(check); | |
2776 playlist_set_shuffle(cfg.shuffle); | |
2777 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
2778 break; | |
2779 case MAINWIN_OPT_REPEAT: | |
2780 check = GTK_CHECK_MENU_ITEM(item); | |
2781 cfg.repeat = gtk_check_menu_item_get_active(check); | |
2782 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
2783 break; | |
2784 case MAINWIN_OPT_NPA: | |
2785 check = GTK_CHECK_MENU_ITEM(item); | |
2786 cfg.no_playlist_advance = gtk_check_menu_item_get_active(check); | |
2787 break; | |
2788 } | |
2789 } | |
2790 | |
1938 | 2791 static void |
2792 mainwin_set_doublesize(gboolean doublesize) | |
2793 { | |
2794 gint height; | |
2795 | |
2796 if (cfg.player_shaded) | |
2797 height = MAINWIN_SHADED_HEIGHT; | |
2798 else | |
2799 height = bmp_active_skin->properties.mainwin_height; | |
2800 | |
2801 mainwin_set_shape_mask(); | |
2802 | |
2803 dock_window_resize(GTK_WINDOW(mainwin), cfg.player_shaded ? MAINWIN_SHADED_WIDTH : bmp_active_skin->properties.mainwin_width, | |
2804 cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height, | |
2805 bmp_active_skin->properties.mainwin_width * 2, bmp_active_skin->properties.mainwin_height * 2); | |
2806 | |
2807 if (cfg.doublesize) { | |
2808 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg_x2, 0); | |
2809 } | |
2810 else { | |
2811 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
2812 } | |
2813 | |
2814 draw_main_window(TRUE); | |
2815 vis_set_doublesize(mainwin_vis, doublesize); | |
2816 } | |
2817 | |
2818 void | |
2819 set_doublesize(gboolean doublesize) | |
2820 { | |
2821 cfg.doublesize = doublesize; | |
2822 | |
2823 mainwin_set_doublesize(doublesize); | |
2824 | |
2825 if (cfg.eq_doublesize_linked) | |
2826 equalizerwin_set_doublesize(doublesize); | |
2827 } | |
2828 | |
1653 | 2829 |
2830 static void | |
2831 mainwin_view_menu_callback(gpointer data, | |
2832 guint action, | |
2833 GtkWidget * item) | |
2834 { | |
1775 | 2835 GtkCheckMenuItem *check; |
2836 | |
1653 | 2837 switch (action) { |
2838 case MAINWIN_OPT_TELAPSED: | |
2839 set_timer_mode_menu_cb(TIMER_ELAPSED); | |
2840 break; | |
2841 case MAINWIN_OPT_TREMAINING: | |
2842 set_timer_mode_menu_cb(TIMER_REMAINING); | |
2843 break; | |
2844 case MAINWIN_OPT_ALWAYS: | |
2845 mainwin_menurow->mr_always_selected = GTK_CHECK_MENU_ITEM(item)->active; | |
2846 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
2847 widget_draw(WIDGET(mainwin_menurow)); | |
2848 | |
2849 if (starting_up == FALSE) | |
2850 hint_set_always(cfg.always_on_top); | |
2851 | |
2852 break; | |
2853 case MAINWIN_OPT_STICKY: | |
2854 cfg.sticky = GTK_CHECK_MENU_ITEM(item)->active; | |
2855 hint_set_sticky(cfg.sticky); | |
2856 break; | |
2857 case MAINWIN_OPT_WS: | |
2858 mainwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2859 break; | |
2860 case MAINWIN_OPT_PWS: | |
2861 playlistwin_set_shade(GTK_CHECK_MENU_ITEM(item)->active); | |
2862 break; | |
2863 case MAINWIN_OPT_EQWS: | |
2864 equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2865 break; | |
1938 | 2866 case MAINWIN_OPT_DOUBLESIZE: |
2867 mainwin_menurow->mr_doublesize_selected = | |
2868 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget | |
2869 (mainwin_view_menu, | |
2870 "/DoubleSize"))->active; | |
2871 widget_draw(WIDGET(mainwin_menurow)); | |
2872 set_doublesize(mainwin_menurow->mr_doublesize_selected); | |
2873 gdk_flush(); | |
2874 break; | |
2875 case MAINWIN_OPT_EASY_MOVE: | |
2876 cfg.easy_move = | |
2877 GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget | |
2878 (mainwin_view_menu, "/Easy Move"))->active; | |
2879 break; | |
1775 | 2880 case MAINWIN_SONGNAME_SCROLL: |
2881 check = GTK_CHECK_MENU_ITEM(item); | |
2882 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
2883 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
2884 playlistwin_set_sinfo_scroll(cfg.autoscroll); /* propagate scroll setting to playlistwin_sinfo */ | |
2885 break; | |
1653 | 2886 } |
2887 } | |
2888 | |
2889 void | |
2890 mainwin_vis_menu_callback(gpointer data, | |
2891 guint action, | |
2892 GtkWidget * item) | |
2893 { | |
2894 switch (action) { | |
2895 case MAINWIN_VIS_ANALYZER: | |
2896 case MAINWIN_VIS_SCOPE: | |
2897 case MAINWIN_VIS_OFF: | |
2898 mainwin_vis_set_type_menu_cb(action - MAINWIN_VIS_ANALYZER); | |
2899 break; | |
2900 case MAINWIN_VIS_ANALYZER_NORMAL: | |
2901 case MAINWIN_VIS_ANALYZER_FIRE: | |
2902 case MAINWIN_VIS_ANALYZER_VLINES: | |
2903 mainwin_vis_set_analyzer_mode(action - MAINWIN_VIS_ANALYZER_NORMAL); | |
2904 break; | |
2905 case MAINWIN_VIS_ANALYZER_LINES: | |
2906 case MAINWIN_VIS_ANALYZER_BARS: | |
2907 mainwin_vis_set_analyzer_type(action - MAINWIN_VIS_ANALYZER_LINES); | |
2908 break; | |
2909 case MAINWIN_VIS_ANALYZER_PEAKS: | |
2910 cfg.analyzer_peaks = GTK_CHECK_MENU_ITEM(item)->active; | |
2911 break; | |
2912 case MAINWIN_VIS_SCOPE_DOT: | |
2913 case MAINWIN_VIS_SCOPE_LINE: | |
2914 case MAINWIN_VIS_SCOPE_SOLID: | |
2915 cfg.scope_mode = action - MAINWIN_VIS_SCOPE_DOT; | |
2916 break; | |
2917 case MAINWIN_VIS_VU_NORMAL: | |
2918 case MAINWIN_VIS_VU_SMOOTH: | |
2919 cfg.vu_mode = action - MAINWIN_VIS_VU_NORMAL; | |
2920 break; | |
2921 case MAINWIN_VIS_REFRESH_FULL: | |
2922 case MAINWIN_VIS_REFRESH_HALF: | |
2923 case MAINWIN_VIS_REFRESH_QUARTER: | |
2924 case MAINWIN_VIS_REFRESH_EIGHTH: | |
2925 mainwin_vis_set_refresh(action - MAINWIN_VIS_REFRESH_FULL); | |
2926 break; | |
2927 case MAINWIN_VIS_AFALLOFF_SLOWEST: | |
2928 case MAINWIN_VIS_AFALLOFF_SLOW: | |
2929 case MAINWIN_VIS_AFALLOFF_MEDIUM: | |
2930 case MAINWIN_VIS_AFALLOFF_FAST: | |
2931 case MAINWIN_VIS_AFALLOFF_FASTEST: | |
2932 mainwin_vis_set_afalloff(action - MAINWIN_VIS_AFALLOFF_SLOWEST); | |
2933 break; | |
2934 case MAINWIN_VIS_PFALLOFF_SLOWEST: | |
2935 case MAINWIN_VIS_PFALLOFF_SLOW: | |
2936 case MAINWIN_VIS_PFALLOFF_MEDIUM: | |
2937 case MAINWIN_VIS_PFALLOFF_FAST: | |
2938 case MAINWIN_VIS_PFALLOFF_FASTEST: | |
2939 mainwin_vis_set_pfalloff(action - MAINWIN_VIS_PFALLOFF_SLOWEST); | |
2940 break; | |
2941 } | |
2942 } | |
2943 | |
2944 void | |
2945 mainwin_general_menu_callback(gpointer data, | |
2946 guint action, | |
2947 GtkWidget * item) | |
2948 { | |
2949 switch (action) { | |
2950 case MAINWIN_GENERAL_PREFS: | |
2951 show_prefs_window(); | |
2952 break; | |
2953 case MAINWIN_GENERAL_ABOUT: | |
2954 show_about_window(); | |
2955 break; | |
2956 case MAINWIN_GENERAL_PLAYFILE: | |
2957 util_run_filebrowser(NO_PLAY_BUTTON); | |
2958 break; | |
2959 case MAINWIN_GENERAL_PLAYCD: | |
2960 play_medium(); | |
2961 break; | |
2962 case MAINWIN_GENERAL_ADDCD: | |
2963 add_medium(); | |
2964 break; | |
2965 case MAINWIN_GENERAL_PLAYLOCATION: | |
2966 mainwin_show_add_url_window(); | |
2967 break; | |
2968 case MAINWIN_GENERAL_FILEINFO: | |
2969 playlist_fileinfo_current(); | |
2970 break; | |
2971 case MAINWIN_GENERAL_FOCUSPLWIN: | |
2972 gtk_window_present(GTK_WINDOW(playlistwin)); | |
2973 break; | |
2974 case MAINWIN_GENERAL_SHOWMWIN: | |
2975 mainwin_show(GTK_CHECK_MENU_ITEM(item)->active); | |
2976 break; | |
2977 case MAINWIN_GENERAL_SHOWPLWIN: | |
2978 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2979 playlistwin_show(); | |
2980 else | |
2981 playlistwin_hide(); | |
2982 break; | |
2983 case MAINWIN_GENERAL_SHOWEQWIN: | |
2984 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2985 equalizerwin_real_show(); | |
2986 else | |
2987 equalizerwin_real_hide(); | |
2988 break; | |
2989 case MAINWIN_GENERAL_PREV: | |
2990 playlist_prev(); | |
2991 break; | |
2992 case MAINWIN_GENERAL_PLAY: | |
2993 mainwin_play_pushed(); | |
2994 break; | |
2995 case MAINWIN_GENERAL_PAUSE: | |
2996 bmp_playback_pause(); | |
2997 break; | |
2998 case MAINWIN_GENERAL_STOP: | |
2999 mainwin_stop_pushed(); | |
3000 break; | |
3001 case MAINWIN_GENERAL_NEXT: | |
3002 playlist_next(); | |
3003 break; | |
3004 case MAINWIN_GENERAL_BACK5SEC: | |
3005 if (bmp_playback_get_playing() | |
3006 && playlist_get_current_length() != -1) | |
3007 bmp_playback_seek_relative(-5); | |
3008 break; | |
3009 case MAINWIN_GENERAL_FWD5SEC: | |
3010 if (bmp_playback_get_playing() | |
3011 && playlist_get_current_length() != -1) | |
3012 bmp_playback_seek_relative(5); | |
3013 break; | |
3014 case MAINWIN_GENERAL_START: | |
3015 playlist_set_position(0); | |
3016 break; | |
3017 case MAINWIN_GENERAL_JTT: | |
3018 mainwin_jump_to_time(); | |
3019 break; | |
3020 case MAINWIN_GENERAL_JTF: | |
3021 mainwin_jump_to_file(); | |
3022 break; | |
3023 case MAINWIN_GENERAL_EXIT: | |
3024 mainwin_quit_cb(); | |
3025 break; | |
1893 | 3026 case MAINWIN_GENERAL_SETAB: |
3027 if (playlist_get_current_length() != -1) { | |
3028 if (ab_position_a == -1) { | |
3029 ab_position_a = bmp_playback_get_time(); | |
3030 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
|
3031 mainwin_lock_info_text("LOOP-POINT A POSITION SET."); |
1893 | 3032 } else if (ab_position_b == -1) { |
3033 int time = bmp_playback_get_time(); | |
3034 if (time > ab_position_a) | |
3035 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
|
3036 mainwin_release_info_text(); |
1893 | 3037 } else { |
3038 ab_position_a = bmp_playback_get_time(); | |
3039 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
|
3040 mainwin_lock_info_text("LOOP-POINT A POSITION RESET."); |
1893 | 3041 } |
3042 } | |
3043 break; | |
3044 case MAINWIN_GENERAL_CLEARAB: | |
3045 if (playlist_get_current_length() != -1) { | |
3046 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
|
3047 mainwin_release_info_text(); |
1893 | 3048 } |
3049 break; | |
1653 | 3050 } |
3051 } | |
3052 | |
3053 static void | |
3054 mainwin_mr_change(MenuRowItem i) | |
3055 { | |
3056 switch (i) { | |
3057 case MENUROW_NONE: | |
3058 mainwin_set_info_text(); | |
3059 break; | |
3060 case MENUROW_OPTIONS: | |
3061 mainwin_lock_info_text(_("OPTIONS MENU")); | |
3062 break; | |
3063 case MENUROW_ALWAYS: | |
3064 if (mainwin_menurow->mr_always_selected) | |
3065 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); | |
3066 else | |
3067 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
3068 break; | |
3069 case MENUROW_FILEINFOBOX: | |
3070 mainwin_lock_info_text(_("FILE INFO BOX")); | |
3071 break; | |
3072 case MENUROW_DOUBLESIZE: | |
1938 | 3073 if (mainwin_menurow->mr_doublesize_selected) |
3074 mainwin_lock_info_text(_("DISABLE DOUBLESIZE")); | |
3075 else | |
3076 mainwin_lock_info_text(_("ENABLE DOUBLESIZE")); | |
1653 | 3077 break; |
3078 case MENUROW_VISUALIZATION: | |
3079 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
3080 break; | |
3081 } | |
3082 } | |
3083 | |
3084 static void | |
3085 mainwin_mr_release(MenuRowItem i) | |
3086 { | |
3087 GdkModifierType modmask; | |
3088 GtkWidget *widget; | |
3089 gint x, y; | |
3090 | |
3091 switch (i) { | |
3092 case MENUROW_OPTIONS: | |
3093 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
3094 util_item_factory_popup(mainwin_view_menu, x, y, 1, | |
3095 GDK_CURRENT_TIME); | |
3096 break; | |
3097 case MENUROW_ALWAYS: | |
3098 widget = | |
3099 gtk_item_factory_get_widget(mainwin_view_menu, | |
3100 "/Always On Top"); | |
3101 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
3102 mainwin_menurow->mr_always_selected); | |
3103 break; | |
3104 case MENUROW_FILEINFOBOX: | |
3105 playlist_fileinfo_current(); | |
3106 break; | |
3107 case MENUROW_DOUBLESIZE: | |
1938 | 3108 widget = |
3109 gtk_item_factory_get_widget(mainwin_view_menu, "/DoubleSize"); | |
3110 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
3111 mainwin_menurow->mr_doublesize_selected); | |
1653 | 3112 break; |
3113 case MENUROW_VISUALIZATION: | |
3114 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
3115 util_item_factory_popup(mainwin_vis_menu, x, y, 1, GDK_CURRENT_TIME); | |
3116 break; | |
3117 case MENUROW_NONE: | |
3118 break; | |
3119 } | |
3120 mainwin_release_info_text(); | |
3121 } | |
3122 | |
3123 static void | |
3124 run_no_audiocd_dialog(void) | |
3125 { | |
3126 const gchar *markup = | |
3127 N_("<b><big>No playable CD found.</big></b>\n\n" | |
3128 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
3129 | |
3130 GtkWidget *dialog = | |
3131 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
3132 GTK_DIALOG_DESTROY_WITH_PARENT, | |
3133 GTK_MESSAGE_ERROR, | |
3134 GTK_BUTTONS_OK, | |
3135 _(markup)); | |
3136 gtk_dialog_run(GTK_DIALOG(dialog)); | |
3137 gtk_widget_destroy(dialog); | |
3138 } | |
3139 | |
3140 static void | |
3141 run_no_output_device_dialog(void) | |
3142 { | |
3143 const gchar *markup = | |
3144 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
3145 "Please check that:\n" | |
3146 "1. You have the correct output plugin selected.\n" | |
3147 "2. No other programs is blocking the soundcard.\n" | |
3148 "3. Your soundcard is configured properly.\n"); | |
3149 | |
3150 GtkWidget *dialog = | |
3151 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
3152 GTK_DIALOG_DESTROY_WITH_PARENT, | |
3153 GTK_MESSAGE_ERROR, | |
3154 GTK_BUTTONS_OK, | |
3155 _(markup)); | |
3156 gtk_dialog_run(GTK_DIALOG(dialog)); | |
3157 gtk_widget_destroy(dialog); | |
3158 } | |
3159 | |
3160 | |
3161 void | |
3162 add_medium(void) | |
3163 { | |
3164 GList *list, *node; | |
3165 gchar *filename; | |
3166 gchar *path; | |
3167 ConfigDb *db; | |
3168 | |
3169 db = bmp_cfg_db_open(); | |
3170 | |
3171 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
3172 bmp_cfg_db_close(db); | |
3173 | |
3174 if (!(list = input_scan_dir(path))) { | |
3175 run_no_audiocd_dialog(); | |
3176 return; | |
3177 } | |
3178 | |
3179 for (node = list; node; node = g_list_next(node)) { | |
3180 filename = g_build_filename(path, node->data, NULL); | |
3181 playlist_add(filename); | |
3182 g_free(filename); | |
3183 g_free(node->data); | |
3184 } | |
3185 | |
3186 g_free(path); | |
3187 g_list_free(list); | |
3188 | |
3189 } | |
3190 | |
3191 void | |
3192 play_medium(void) | |
3193 { | |
3194 GList *list, *node; | |
3195 gchar *filename; | |
3196 gchar *path; | |
3197 ConfigDb *db; | |
3198 | |
3199 db = bmp_cfg_db_open(); | |
3200 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
3201 bmp_cfg_db_close(db); | |
3202 | |
3203 if (!(list = input_scan_dir(path))) { | |
3204 run_no_audiocd_dialog(); | |
3205 return; | |
3206 } | |
3207 | |
3208 playlist_clear(); | |
3209 | |
3210 for (node = list; node; node = g_list_next(node)) { | |
3211 filename = g_build_filename(path, node->data, NULL); | |
3212 playlist_add(filename); | |
3213 g_free(filename); | |
3214 g_free(node->data); | |
3215 } | |
3216 | |
3217 g_free(path); | |
3218 g_list_free(list); | |
3219 | |
3220 playlist_set_position(0); | |
3221 bmp_playback_initiate(); | |
3222 } | |
3223 | |
3224 void | |
3225 read_volume(gint when) | |
3226 { | |
3227 static gint pvl = 0, pvr = 0; | |
3228 static gint times = VOLSET_DISP_TIMES; | |
3229 static gboolean changing = FALSE; | |
3230 | |
3231 gint vl, vr, b, v; | |
3232 | |
3233 input_get_volume(&vl, &vr); | |
3234 | |
3235 switch (when) { | |
3236 case VOLSET_STARTUP: | |
3237 vl = CLAMP(vl, 0, 100); | |
3238 vr = CLAMP(vr, 0, 100); | |
3239 pvl = vl; | |
3240 pvr = vr; | |
3241 v = MAX(vl, vr); | |
3242 if (vl > vr) | |
3243 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
3244 else if (vl < vr) | |
3245 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
3246 else | |
3247 b = 0; | |
3248 | |
3249 balance = b; | |
3250 mainwin_set_volume_slider(v); | |
3251 equalizerwin_set_volume_slider(v); | |
3252 mainwin_set_balance_slider(b); | |
3253 equalizerwin_set_balance_slider(b); | |
3254 return; | |
3255 | |
3256 case VOLSET_UPDATE: | |
3257 if (vl == -1 || vr == -1) | |
3258 return; | |
3259 | |
3260 if (setting_volume) { | |
3261 pvl = vl; | |
3262 pvr = vr; | |
3263 return; | |
3264 } | |
3265 | |
3266 if (pvr == vr && pvl == vl && changing) { | |
3267 if (times < VOLSET_DISP_TIMES) | |
3268 times++; | |
3269 else { | |
3270 mainwin_release_info_text(); | |
3271 changing = FALSE; | |
3272 } | |
3273 } | |
3274 else if (pvr != vr || pvl != vl) { | |
3275 gchar *tmp; | |
3276 | |
3277 v = MAX(vl, vr); | |
3278 if (vl > vr) | |
3279 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
3280 else if (vl < vr) | |
3281 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
3282 else | |
3283 b = 0; | |
3284 | |
3285 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
3286 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
3287 else { | |
3288 if (vl > vr) { | |
3289 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
3290 } | |
3291 else if (vr == vl) | |
3292 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
3293 else { /* (vl < vr) */ | |
3294 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
3295 } | |
3296 } | |
3297 mainwin_lock_info_text(tmp); | |
3298 g_free(tmp); | |
3299 | |
3300 pvr = vr; | |
3301 pvl = vl; | |
3302 times = 0; | |
3303 changing = TRUE; | |
3304 mainwin_set_volume_slider(v); | |
3305 equalizerwin_set_volume_slider(v); | |
3306 | |
3307 /* Don't change the balance slider if the volume has been | |
3308 * set to zero. The balance can be anything, and our best | |
3309 * guess is what is was before. */ | |
3310 if (v > 0) { | |
3311 balance = b; | |
3312 mainwin_set_balance_slider(b); | |
3313 equalizerwin_set_balance_slider(b); | |
3314 } | |
3315 } | |
3316 break; | |
3317 | |
3318 case VOLUME_ADJUSTED: | |
3319 pvl = vl; | |
3320 pvr = vr; | |
3321 break; | |
3322 | |
3323 case VOLUME_SET: | |
3324 times = 0; | |
3325 changing = TRUE; | |
3326 pvl = vl; | |
3327 pvr = vr; | |
3328 break; | |
3329 } | |
3330 } | |
3331 | |
3332 | |
3333 /* TODO: HAL! */ | |
3334 gboolean | |
3335 can_play_cd(void) | |
3336 { | |
3337 GList *ilist; | |
3338 | |
3339 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
3340 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
3341 | |
3342 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
3343 PLUGIN_FILENAME("cdaudio"))) { | |
3344 return TRUE; | |
3345 } | |
3346 } | |
3347 | |
3348 return FALSE; | |
3349 } | |
3350 | |
3351 | |
3352 static void | |
3353 set_timer_mode(TimerMode mode) | |
3354 { | |
3355 if (mode == TIMER_ELAPSED) | |
3356 check_set(mainwin_view_menu, "/Time Elapsed", TRUE); | |
3357 else | |
3358 check_set(mainwin_view_menu, "/Time Remaining", TRUE); | |
3359 } | |
3360 | |
3361 static void | |
3362 set_timer_mode_menu_cb(TimerMode mode) | |
3363 { | |
3364 cfg.timer_mode = mode; | |
3365 } | |
3366 | |
3367 void | |
3368 mainwin_setup_menus(void) | |
3369 { | |
3370 set_timer_mode(cfg.timer_mode); | |
3371 | |
3372 /* View menu */ | |
3373 | |
3374 check_set(mainwin_view_menu, "/Always On Top", cfg.always_on_top); | |
3375 check_set(mainwin_view_menu, "/Put on All Workspaces", cfg.sticky); | |
3376 check_set(mainwin_view_menu, "/Roll up Player", cfg.player_shaded); | |
3377 check_set(mainwin_view_menu, "/Roll up Playlist Editor", cfg.playlist_shaded); | |
3378 check_set(mainwin_view_menu, "/Roll up Equalizer", cfg.equalizer_shaded); | |
1938 | 3379 check_set(mainwin_view_menu, "/Easy Move", cfg.easy_move); |
3380 check_set(mainwin_view_menu, "/DoubleSize", cfg.doublesize); | |
1653 | 3381 |
3382 /* Songname menu */ | |
3383 | |
3384 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
3385 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
3386 | |
3387 /* Playback menu */ | |
3388 | |
3389 check_set(mainwin_play_menu, "/Repeat", cfg.repeat); | |
3390 check_set(mainwin_play_menu, "/Shuffle", cfg.shuffle); | |
3391 check_set(mainwin_play_menu, "/No Playlist Advance", cfg.no_playlist_advance); | |
3392 | |
3393 /* Visualization menu */ | |
3394 | |
3395 check_set(mainwin_vis_menu, | |
3396 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + | |
3397 cfg.vis_type].path, TRUE); | |
3398 check_set(mainwin_vis_menu, | |
3399 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_MODE + | |
3400 cfg.analyzer_mode].path, TRUE); | |
3401 check_set(mainwin_vis_menu, | |
3402 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_TYPE + | |
3403 cfg.analyzer_type].path, TRUE); | |
3404 check_set(mainwin_vis_menu, | |
3405 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_PEAKS]. | |
3406 path, cfg.analyzer_peaks); | |
3407 check_set(mainwin_vis_menu, | |
3408 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_SCOPE_MODE + | |
3409 cfg.scope_mode].path, TRUE); | |
3410 check_set(mainwin_vis_menu, | |
3411 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_WSHADEVU_MODE + | |
3412 cfg.vu_mode].path, TRUE); | |
3413 check_set(mainwin_vis_menu, | |
3414 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_REFRESH_RATE + | |
3415 cfg.vis_refresh].path, TRUE); | |
3416 check_set(mainwin_vis_menu, | |
3417 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_AFALLOFF + | |
3418 cfg.analyzer_falloff].path, TRUE); | |
3419 check_set(mainwin_vis_menu, | |
3420 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_PFALLOFF + | |
3421 cfg.peaks_falloff].path, TRUE); | |
3422 } | |
3423 | |
3424 static void | |
3425 mainwin_create_widgets(void) | |
3426 { | |
3427 mainwin_menubtn = | |
3428 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
3429 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
3430 mainwin_menubtn->pb_allow_draw = FALSE; | |
3431 mainwin_minimize = | |
3432 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
3433 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
3434 mainwin_minimize->pb_allow_draw = FALSE; | |
3435 mainwin_shade = | |
3436 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
3437 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
3438 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
3439 SKIN_TITLEBAR); | |
3440 mainwin_shade->pb_allow_draw = FALSE; | |
3441 mainwin_close = | |
3442 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
3443 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
3444 mainwin_close->pb_allow_draw = FALSE; | |
3445 | |
3446 mainwin_rew = | |
3447 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 88, 23, | |
3448 18, 0, 0, 0, 18, mainwin_rev_pushed, mainwin_rev_release, | |
3449 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
3450 mainwin_play = | |
3451 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
3452 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
3453 mainwin_pause = | |
3454 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
3455 18, 46, 0, 46, 18, bmp_playback_pause, SKIN_CBUTTONS); | |
3456 mainwin_stop = | |
3457 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
3458 18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS); | |
3459 #if 0 | |
3460 mainwin_fwd = | |
3461 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3462 18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS); | |
3463 #endif | |
3464 mainwin_fwd = | |
3465 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3466 18, 92, 0, 92, 18, mainwin_fwd_pushed, mainwin_fwd_release, | |
3467 SKIN_CBUTTONS, SKIN_CBUTTONS); | |
3468 | |
3469 mainwin_eject = | |
3470 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
3471 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
3472 SKIN_CBUTTONS); | |
3473 | |
3474 mainwin_srew = | |
3475 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
3476 7, playlist_prev); | |
3477 mainwin_splay = | |
3478 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
3479 7, mainwin_play_pushed); | |
3480 mainwin_spause = | |
3481 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
3482 7, bmp_playback_pause); | |
3483 mainwin_sstop = | |
3484 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
3485 7, mainwin_stop_pushed); | |
3486 mainwin_sfwd = | |
3487 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
3488 7, playlist_next); | |
3489 mainwin_seject = | |
3490 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
3491 7, mainwin_eject_pushed); | |
3492 | |
3493 mainwin_shuffle = | |
3494 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
3495 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
3496 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
3497 | |
3498 mainwin_repeat = | |
3499 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
3500 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
3501 mainwin_repeat_pushed, SKIN_SHUFREP); | |
3502 | |
3503 mainwin_eq = | |
3504 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
3505 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
3506 SKIN_SHUFREP); | |
3507 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
3508 mainwin_pl = | |
3509 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
3510 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
3511 mainwin_pl_pushed, SKIN_SHUFREP); | |
3512 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
3513 | |
3514 mainwin_info = | |
3515 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
3516 153, 1, SKIN_TEXT); | |
3517 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
3518 textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); | |
3519 | |
3520 mainwin_othertext = | |
3521 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 43, | |
3522 153, 1, SKIN_TEXT); | |
3523 | |
3524 mainwin_rate_text = | |
3525 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
3526 0, SKIN_TEXT); | |
3527 mainwin_freq_text = | |
3528 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
3529 0, SKIN_TEXT); | |
3530 | |
3531 mainwin_menurow = | |
3532 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
3533 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
3534 SKIN_TITLEBAR); | |
1938 | 3535 mainwin_menurow->mr_doublesize_selected = cfg.doublesize; |
1653 | 3536 mainwin_menurow->mr_always_selected = cfg.always_on_top; |
3537 | |
3538 mainwin_volume = | |
3539 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
3540 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
3541 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
3542 mainwin_volume_release_cb, SKIN_VOLUME); | |
3543 mainwin_balance = | |
3544 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
3545 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
3546 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
3547 mainwin_balance_release_cb, SKIN_BALANCE); | |
3548 | |
3549 mainwin_monostereo = | |
3550 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
3551 SKIN_MONOSTEREO); | |
3552 | |
3553 mainwin_playstatus = | |
3554 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
3555 | |
3556 mainwin_minus_num = | |
3557 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
3558 SKIN_NUMBERS); | |
3559 widget_hide(WIDGET(mainwin_minus_num)); | |
3560 mainwin_10min_num = | |
3561 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
3562 SKIN_NUMBERS); | |
3563 widget_hide(WIDGET(mainwin_10min_num)); | |
3564 | |
3565 mainwin_min_num = | |
3566 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
3567 SKIN_NUMBERS); | |
3568 widget_hide(WIDGET(mainwin_min_num)); | |
3569 | |
3570 mainwin_10sec_num = | |
3571 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
3572 SKIN_NUMBERS); | |
3573 widget_hide(WIDGET(mainwin_10sec_num)); | |
3574 | |
3575 mainwin_sec_num = | |
3576 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
3577 SKIN_NUMBERS); | |
3578 widget_hide(WIDGET(mainwin_sec_num)); | |
3579 | |
3580 mainwin_about = | |
3581 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
3582 25, show_about_window); | |
3583 | |
3584 mainwin_vis = | |
3585 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
1938 | 3586 24, 43, 76, cfg.doublesize); |
1653 | 3587 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); |
3588 active_vis = mainwin_vis; | |
3589 | |
3590 mainwin_position = | |
3591 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
3592 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
3593 mainwin_position_motion_cb, | |
3594 mainwin_position_release_cb, SKIN_POSBAR); | |
3595 widget_hide(WIDGET(mainwin_position)); | |
3596 | |
3597 mainwin_sposition = | |
3598 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
3599 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
3600 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
3601 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
3602 widget_hide(WIDGET(mainwin_sposition)); | |
3603 | |
3604 mainwin_stime_min = | |
3605 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
3606 FALSE, SKIN_TEXT); | |
3607 mainwin_stime_sec = | |
3608 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
3609 FALSE, SKIN_TEXT); | |
3610 | |
3611 if (!cfg.player_shaded) { | |
3612 widget_hide(WIDGET(mainwin_svis)); | |
3613 widget_hide(WIDGET(mainwin_srew)); | |
3614 widget_hide(WIDGET(mainwin_splay)); | |
3615 widget_hide(WIDGET(mainwin_spause)); | |
3616 widget_hide(WIDGET(mainwin_sstop)); | |
3617 widget_hide(WIDGET(mainwin_sfwd)); | |
3618 widget_hide(WIDGET(mainwin_seject)); | |
3619 widget_hide(WIDGET(mainwin_stime_min)); | |
3620 widget_hide(WIDGET(mainwin_stime_sec)); | |
3621 } | |
3622 | |
3623 err = gtk_message_dialog_new(GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, | |
3624 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,"Error in Audacious."); | |
3625 | |
3626 | |
3627 gtk_window_set_position(GTK_WINDOW(err), GTK_WIN_POS_CENTER); | |
3628 /* Dang well better set an error message or you'll see this */ | |
3629 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err), | |
3630 "Boo! Bad stuff! Booga Booga!"); | |
3631 | |
3632 } | |
3633 | |
3634 static void | |
3635 mainwin_create_window(void) | |
3636 { | |
3637 gint width, height; | |
3638 | |
3639 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3640 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
3641 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
3642 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
3643 | |
1878
f83d206f51b7
[svn] - Properly handle shading when mainwin_width is greater than the shaded width.
nhjm449
parents:
1857
diff
changeset
|
3644 width = cfg.player_shaded ? MAINWIN_SHADED_WIDTH : bmp_active_skin->properties.mainwin_width; |
1809 | 3645 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : bmp_active_skin->properties.mainwin_height; |
1653 | 3646 |
1938 | 3647 if (cfg.doublesize) { |
3648 width *= 2; | |
3649 height *= 2; | |
3650 } | |
3651 | |
1653 | 3652 gtk_widget_set_size_request(mainwin, width, height); |
3653 gtk_widget_set_app_paintable(mainwin, TRUE); | |
3654 | |
3655 dock_window_list = dock_window_set_decorated(dock_window_list, | |
3656 GTK_WINDOW(mainwin), | |
3657 cfg.show_wm_decorations); | |
3658 | |
3659 if (cfg.player_x != -1 && cfg.save_window_position) | |
3660 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
3661 | |
3662 gtk_widget_add_events(mainwin, | |
3663 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
3664 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
3665 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
3666 GDK_VISIBILITY_NOTIFY_MASK); | |
3667 gtk_widget_realize(mainwin); | |
3668 | |
3669 util_set_cursor(mainwin); | |
3670 | |
3671 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
3672 g_signal_connect(mainwin, "button_press_event", | |
3673 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
3674 g_signal_connect(mainwin, "scroll_event", | |
3675 G_CALLBACK(mainwin_scrolled), NULL); | |
3676 g_signal_connect(mainwin, "button_release_event", | |
3677 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
3678 g_signal_connect(mainwin, "motion_notify_event", | |
3679 G_CALLBACK(mainwin_motion), NULL); | |
3680 g_signal_connect_after(mainwin, "focus_in_event", | |
3681 G_CALLBACK(mainwin_focus_in), NULL); | |
3682 g_signal_connect_after(mainwin, "focus_out_event", | |
3683 G_CALLBACK(mainwin_focus_out), NULL); | |
3684 g_signal_connect(mainwin, "configure_event", | |
3685 G_CALLBACK(mainwin_configure), NULL); | |
3686 g_signal_connect(mainwin, "style_set", | |
3687 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
3688 | |
3689 bmp_drag_dest_set(mainwin); | |
3690 | |
3691 g_signal_connect(mainwin, "key_press_event", | |
3692 G_CALLBACK(mainwin_keypress), NULL); | |
3693 } | |
3694 | |
3695 static void | |
3696 mainwin_create_menus(void) | |
3697 { | |
3698 mainwin_general_menu = create_menu(mainwin_general_menu_entries, | |
3699 mainwin_general_menu_entries_num, | |
3700 mainwin_accel); | |
3701 | |
3702 mainwin_play_menu = create_menu(mainwin_playback_menu_entries, | |
3703 mainwin_playback_menu_entries_num, | |
3704 mainwin_accel); | |
3705 | |
3706 mainwin_view_menu = create_menu(mainwin_view_menu_entries, | |
3707 mainwin_view_menu_entries_num, | |
3708 mainwin_accel); | |
3709 | |
3710 mainwin_songname_menu = create_menu(mainwin_songname_menu_entries, | |
3711 mainwin_songname_menu_entries_num, | |
3712 mainwin_accel); | |
3713 | |
3714 mainwin_add_menu = create_menu(mainwin_add_menu_entries, | |
3715 mainwin_add_menu_entries_num, | |
3716 mainwin_accel); | |
3717 | |
3718 mainwin_vis_menu = create_menu(mainwin_vis_menu_entries, | |
3719 mainwin_vis_menu_entries_num, | |
3720 mainwin_accel); | |
3721 | |
3722 make_submenu(mainwin_general_menu, "/View", mainwin_view_menu); | |
3723 make_submenu(mainwin_general_menu, "/Playback", mainwin_play_menu); | |
3724 make_submenu(mainwin_general_menu, "/Visualization", mainwin_vis_menu); | |
3725 | |
3726 gtk_window_add_accel_group(GTK_WINDOW(mainwin), mainwin_accel); | |
3727 } | |
3728 | |
3729 void | |
3730 mainwin_create(void) | |
3731 { | |
3732 mainwin_create_window(); | |
3733 | |
3734 mainwin_accel = gtk_accel_group_new(); | |
3735 mainwin_create_menus(); | |
3736 | |
3737 mainwin_gc = gdk_gc_new(mainwin->window); | |
3738 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
|
3739 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
|
3740 bmp_active_skin->properties.mainwin_height, -1); |
1938 | 3741 mainwin_bg_x2 = gdk_pixmap_new(mainwin->window, |
3742 bmp_active_skin->properties.mainwin_width * 2, | |
3743 bmp_active_skin->properties.mainwin_height * 2, -1); | |
1653 | 3744 mainwin_set_back_pixmap(); |
3745 mainwin_create_widgets(); | |
3746 | |
3747 vis_set_window(mainwin_vis, mainwin->window); | |
3748 } | |
3749 | |
3750 void | |
3751 mainwin_attach_idle_func(void) | |
3752 { | |
3753 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
3754 mainwin_idle_func, NULL); | |
3755 } | |
3756 | |
3757 static void | |
3758 idle_func_update_song_info(gint time) | |
3759 { | |
3760 gint length, t; | |
3761 gchar stime_prefix; | |
3762 | |
1897
35fa6f69d802
[svn] - oops, missed a requirement (sorry about that)
nenolod
parents:
1896
diff
changeset
|
3763 if (ab_position_a != -1 && ab_position_b != -1 && time > ab_position_b) |
1896 | 3764 bmp_playback_seek(ab_position_a/1000); |
3765 | |
1653 | 3766 length = playlist_get_current_length(); |
3767 if (bmp_playback_get_playing()) | |
3768 playlistwin_set_time(time, length, cfg.timer_mode); | |
3769 else | |
3770 playlistwin_hide_timer(); | |
3771 input_update_vis(time); | |
3772 | |
3773 if (cfg.timer_mode == TIMER_REMAINING) { | |
3774 if (length != -1) { | |
3775 number_set_number(mainwin_minus_num, 11); | |
3776 t = length - time; | |
3777 stime_prefix = '-'; | |
3778 } | |
3779 else { | |
3780 number_set_number(mainwin_minus_num, 10); | |
3781 t = time; | |
3782 stime_prefix = ' '; | |
3783 } | |
3784 } | |
3785 else { | |
3786 number_set_number(mainwin_minus_num, 10); | |
3787 t = time; | |
3788 stime_prefix = ' '; | |
3789 } | |
3790 t /= 1000; | |
3791 | |
3792 /* Show the time in the format HH:MM when we have more than 100 | |
3793 * minutes. */ | |
3794 if (t >= 100 * 60) | |
3795 t /= 60; | |
3796 number_set_number(mainwin_10min_num, t / 600); | |
3797 number_set_number(mainwin_min_num, (t / 60) % 10); | |
3798 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
3799 number_set_number(mainwin_sec_num, t % 10); | |
3800 | |
3801 if (!mainwin_sposition->hs_pressed) { | |
3802 gchar *time_str; | |
3803 | |
3804 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
3805 textbox_set_text(mainwin_stime_min, time_str); | |
3806 g_free(time_str); | |
3807 | |
3808 time_str = g_strdup_printf("%2.2d", t % 60); | |
3809 textbox_set_text(mainwin_stime_sec, time_str); | |
3810 g_free(time_str); | |
3811 } | |
3812 | |
3813 time /= 1000; | |
3814 length /= 1000; | |
3815 if (length > 0) { | |
3816 if (time > length) { | |
3817 hslider_set_position(mainwin_position, 219); | |
3818 hslider_set_position(mainwin_sposition, 13); | |
3819 } | |
3820 /* update the slider position ONLY if there is not a seek in progress */ | |
3821 else if (seek_state == MAINWIN_SEEK_NIL) { | |
3822 hslider_set_position(mainwin_position, (time * 219) / length); | |
3823 hslider_set_position(mainwin_sposition, | |
3824 ((time * 12) / length) + 1); | |
3825 } | |
3826 } | |
3827 else { | |
3828 hslider_set_position(mainwin_position, 0); | |
3829 hslider_set_position(mainwin_sposition, 1); | |
3830 } | |
3831 } | |
3832 | |
3833 static gboolean | |
3834 mainwin_idle_func(gpointer data) | |
3835 { | |
3836 static gint count = 0; | |
3837 gint time = 0; | |
3838 | |
3839 /* run audcore events, then run our own. --nenolod */ | |
3840 switch((time = audcore_generic_events())) | |
3841 { | |
3842 case -2: | |
3843 /* no usable output device */ | |
3844 GDK_THREADS_ENTER(); | |
3845 run_no_output_device_dialog(); | |
3846 mainwin_stop_pushed(); | |
3847 GDK_THREADS_LEAVE(); | |
3848 ev_waiting = FALSE; | |
3849 break; | |
3850 | |
3851 default: | |
3852 idle_func_update_song_info(time); | |
3853 /* nothing at this time */ | |
3854 } | |
3855 | |
3856 GDK_THREADS_ENTER(); | |
3857 | |
3858 if (bmp_playback_get_playing()) | |
3859 vis_playback_start(); | |
1893 | 3860 else { |
1653 | 3861 vis_playback_stop(); |
1893 | 3862 ab_position_a = ab_position_b = -1; |
3863 } | |
1653 | 3864 |
3865 draw_main_window(mainwin_force_redraw); | |
3866 | |
3867 if (!count) { | |
3868 read_volume(VOLSET_UPDATE); | |
3869 count = 10; | |
3870 } | |
3871 else | |
3872 count--; | |
3873 | |
3874 mainwin_force_redraw = FALSE; | |
1821 | 3875 draw_equalizer_window(FALSE); |
3876 draw_playlist_window(FALSE); | |
1653 | 3877 |
3878 if (mainwin_title_text) { | |
3879 G_LOCK(mainwin_title); | |
3880 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
3881 g_free(mainwin_title_text); | |
3882 mainwin_title_text = NULL; | |
3883 G_UNLOCK(mainwin_title); | |
3884 | |
3885 mainwin_set_info_text(); | |
3886 playlistwin_update_list(); | |
3887 } | |
3888 | |
3889 /* tristate buttons seek */ | |
3890 if ( seek_state != MAINWIN_SEEK_NIL ) | |
3891 { | |
3892 GTimeVal now_time; | |
3893 GTimeVal delta_time; | |
3894 gulong now_dur; | |
3895 g_get_current_time(&now_time); | |
3896 | |
3897 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; | |
3898 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; | |
3899 | |
3900 now_dur = labs((delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000)); | |
3901 | |
3902 if ( now_dur > TRISTATE_THRESHOLD ) | |
3903 { | |
3904 gint np; | |
3905 if (seek_state == MAINWIN_SEEK_REV) | |
3906 np = seek_initial_pos - labs((gulong)(now_dur/100)); /* seek back */ | |
3907 else | |
3908 np = seek_initial_pos + labs((gulong)(now_dur/100)); /* seek forward */ | |
3909 | |
3910 /* boundaries check */ | |
3911 if (np < 0 ) | |
3912 np = 0; | |
3913 else if ( np > 219 ) | |
3914 np = 219; | |
3915 | |
3916 hslider_set_position( mainwin_position , np ); | |
3917 mainwin_position_motion_cb( np ); | |
3918 } | |
3919 } | |
3920 | |
3921 GDK_THREADS_LEAVE(); | |
3922 | |
3923 /* | |
3924 if (seek_state == MAINWIN_SEEK_REV) | |
3925 bmp_playback_seek(CLAMP(bmp_playback_get_time() - 1000, 0, | |
3926 playlist_get_current_length()) / 1000); | |
3927 else if (seek_state == MAINWIN_SEEK_FWD) | |
3928 bmp_playback_seek(CLAMP(bmp_playback_get_time() + 1000, 0, | |
3929 playlist_get_current_length()) / 1000); | |
3930 */ | |
3931 | |
3932 return TRUE; | |
3933 } |