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