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