Mercurial > audlegacy
annotate audacious/mainwin.c @ 439:3c43e25ddc7d trunk
[svn] Add `Apply' button to the presets window. Patch via NhJm.
author | nenolod |
---|---|
date | Sun, 15 Jan 2006 00:34:41 -0800 |
parents | d6051a60aae2 |
children | be82408a657d |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 # include "config.h" | |
24 #endif | |
25 | |
26 | |
27 #include <glib.h> | |
28 #include <glib/gi18n.h> | |
29 #include <glib/gprintf.h> | |
30 #include <gtk/gtk.h> | |
31 #include <gdk/gdkx.h> | |
32 #include <gdk/gdkkeysyms.h> | |
33 | |
34 #include <math.h> | |
35 #include <stdlib.h> | |
36 #include <string.h> | |
37 | |
38 #include <X11/Xlib.h> | |
39 | |
40 #include "textbox.h" | |
41 #include "mainwin.h" | |
42 #include "pixmaps.h" | |
43 | |
44 #include "main.h" | |
45 | |
46 #include "controlsocket.h" | |
47 #include "pluginenum.h" | |
48 | |
49 #include "about.h" | |
50 #include "dnd.h" | |
51 #include "dock.h" | |
52 #include "equalizer.h" | |
53 #include "hints.h" | |
54 #include "input.h" | |
383 | 55 #include "ui_playlist.h" |
0 | 56 #include "prefswin.h" |
57 #include "skinwin.h" | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
58 #include "genevent.h" |
0 | 59 #include "hslider.h" |
60 #include "menurow.h" | |
61 #include "monostereo.h" | |
62 #include "pbutton.h" | |
284 | 63 #include "libaudcore/playback.h" |
0 | 64 #include "playlist.h" |
65 #include "playlist_list.h" | |
66 #include "playstatus.h" | |
67 #include "sbutton.h" | |
68 #include "svis.h" | |
69 #include "textbox.h" | |
70 #include "urldecode.h" | |
71 #include "util.h" | |
72 #include "vis.h" | |
73 #include "visualization.h" | |
74 #include "libaudacious/configdb.h" | |
75 | |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
76 static GTimeVal cb_time; /* 150ms click delay for tristate --nenolod */ |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
77 |
0 | 78 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>"} |
79 | |
80 /* | |
81 * If you change the menu above change these defines also | |
82 */ | |
83 | |
84 #define MAINWIN_VIS_MENU_VIS_MODE 1 | |
85 #define MAINWIN_VIS_MENU_NUM_VIS_MODE 3 | |
86 #define MAINWIN_VIS_MENU_ANALYZER_MODE 5 | |
87 #define MAINWIN_VIS_MENU_NUM_ANALYZER_MODE 3 | |
88 #define MAINWIN_VIS_MENU_ANALYZER_TYPE 9 | |
89 #define MAINWIN_VIS_MENU_NUM_ANALYZER_TYPE 2 | |
90 #define MAINWIN_VIS_MENU_ANALYZER_PEAKS 12 | |
91 #define MAINWIN_VIS_MENU_SCOPE_MODE 14 | |
92 #define MAINWIN_VIS_MENU_NUM_SCOPE_MODE 3 | |
93 #define MAINWIN_VIS_MENU_WSHADEVU_MODE 18 | |
94 #define MAINWIN_VIS_MENU_NUM_WSHADEVU_MODE 2 | |
95 #define MAINWIN_VIS_MENU_REFRESH_RATE 21 | |
96 #define MAINWIN_VIS_MENU_NUM_REFRESH_RATE 4 | |
97 #define MAINWIN_VIS_MENU_AFALLOFF 26 | |
98 #define MAINWIN_VIS_MENU_NUM_AFALLOFF 5 | |
99 #define MAINWIN_VIS_MENU_PFALLOFF 32 | |
100 #define MAINWIN_VIS_MENU_NUM_PFALLOFF 5 | |
101 | |
102 #define VOLSET_DISP_TIMES 5 | |
103 | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
104 enum { |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
105 MAINWIN_SEEK_REV = -1, |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
106 MAINWIN_SEEK_NIL, |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
107 MAINWIN_SEEK_FWD |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
108 }; |
0 | 109 |
110 enum { | |
111 MAINWIN_SONGNAME_FILEINFO, | |
112 MAINWIN_SONGNAME_JTF, | |
113 MAINWIN_SONGNAME_JTT, | |
114 MAINWIN_SONGNAME_SCROLL | |
115 }; | |
116 | |
117 enum { | |
118 MAINWIN_OPT_SKIN, MAINWIN_OPT_RELOADSKIN, | |
119 MAINWIN_OPT_REPEAT, MAINWIN_OPT_SHUFFLE, MAINWIN_OPT_NPA, | |
120 MAINWIN_OPT_TELAPSED, MAINWIN_OPT_TREMAINING, | |
121 MAINWIN_OPT_ALWAYS, | |
122 MAINWIN_OPT_STICKY, | |
123 MAINWIN_OPT_WS, | |
124 MAINWIN_OPT_PWS, | |
125 MAINWIN_OPT_EQWS | |
126 }; | |
127 | |
128 enum { | |
129 MAINWIN_VIS_ANALYZER, MAINWIN_VIS_SCOPE, MAINWIN_VIS_OFF, | |
130 MAINWIN_VIS_ANALYZER_NORMAL, MAINWIN_VIS_ANALYZER_FIRE, | |
131 MAINWIN_VIS_ANALYZER_VLINES, | |
132 MAINWIN_VIS_ANALYZER_LINES, MAINWIN_VIS_ANALYZER_BARS, | |
133 MAINWIN_VIS_ANALYZER_PEAKS, | |
134 MAINWIN_VIS_SCOPE_DOT, MAINWIN_VIS_SCOPE_LINE, MAINWIN_VIS_SCOPE_SOLID, | |
135 MAINWIN_VIS_VU_NORMAL, MAINWIN_VIS_VU_SMOOTH, | |
136 MAINWIN_VIS_REFRESH_FULL, MAINWIN_VIS_REFRESH_HALF, | |
137 MAINWIN_VIS_REFRESH_QUARTER, MAINWIN_VIS_REFRESH_EIGHTH, | |
138 MAINWIN_VIS_AFALLOFF_SLOWEST, MAINWIN_VIS_AFALLOFF_SLOW, | |
139 MAINWIN_VIS_AFALLOFF_MEDIUM, MAINWIN_VIS_AFALLOFF_FAST, | |
140 MAINWIN_VIS_AFALLOFF_FASTEST, | |
141 MAINWIN_VIS_PFALLOFF_SLOWEST, MAINWIN_VIS_PFALLOFF_SLOW, | |
142 MAINWIN_VIS_PFALLOFF_MEDIUM, MAINWIN_VIS_PFALLOFF_FAST, | |
143 MAINWIN_VIS_PFALLOFF_FASTEST, | |
144 MAINWIN_VIS_PLUGINS | |
145 }; | |
146 | |
147 enum { | |
148 MAINWIN_VIS_ACTIVE_MAINWIN, MAINWIN_VIS_ACTIVE_PLAYLISTWIN | |
149 }; | |
150 | |
151 | |
152 typedef struct _PlaybackInfo PlaybackInfo; | |
153 | |
154 struct _PlaybackInfo { | |
155 gchar *title; | |
156 gint bitrate; | |
157 gint frequency; | |
158 gint n_channels; | |
159 }; | |
160 | |
161 | |
162 GtkWidget *mainwin = NULL; | |
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 | |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
174 gint seek_state = MAINWIN_SEEK_NIL; |
0 | 175 |
176 GdkGC *mainwin_gc; | |
177 static GdkPixmap *mainwin_bg = NULL; | |
178 | |
179 GtkAccelGroup *mainwin_accel = NULL; | |
180 | |
181 static PButton *mainwin_menubtn; | |
182 static PButton *mainwin_minimize, *mainwin_shade, *mainwin_close; | |
183 | |
184 static PButton *mainwin_rew, *mainwin_fwd; | |
185 static PButton *mainwin_eject; | |
186 static PButton *mainwin_play, *mainwin_pause, *mainwin_stop; | |
187 | |
188 TButton *mainwin_shuffle, *mainwin_repeat, *mainwin_eq, *mainwin_pl; | |
189 TextBox *mainwin_info; | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
190 TextBox *mainwin_stime_min, *mainwin_stime_sec; |
0 | 191 |
192 static TextBox *mainwin_rate_text, *mainwin_freq_text; | |
193 | |
194 PlayStatus *mainwin_playstatus; | |
195 | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
196 Number *mainwin_minus_num, *mainwin_10min_num, *mainwin_min_num; |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
197 Number *mainwin_10sec_num, *mainwin_sec_num; |
0 | 198 |
199 static gboolean setting_volume = FALSE; | |
200 | |
201 Vis *active_vis; | |
202 Vis *mainwin_vis; | |
203 SVis *mainwin_svis; | |
204 | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
205 HSlider *mainwin_sposition = NULL; |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
206 |
0 | 207 static MenuRow *mainwin_menurow; |
208 static HSlider *mainwin_volume, *mainwin_balance, *mainwin_position; | |
209 static MonoStereo *mainwin_monostereo; | |
210 static SButton *mainwin_srew, *mainwin_splay, *mainwin_spause; | |
211 static SButton *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about; | |
212 | |
213 static GList *mainwin_wlist = NULL; | |
214 | |
215 static gint mainwin_timeout_id; | |
216 | |
217 G_LOCK_DEFINE_STATIC(mainwin_title); | |
218 | |
219 static gboolean mainwin_force_redraw = FALSE; | |
220 static gchar *mainwin_title_text = NULL; | |
221 static gboolean mainwin_info_text_locked = FALSE; | |
222 | |
223 | |
224 static void mainwin_songname_menu_callback(gpointer user_data, | |
225 guint action, | |
226 GtkWidget * widget); | |
227 | |
228 static void mainwin_vis_menu_callback(gpointer user_data, | |
229 guint action, | |
230 GtkWidget * widget); | |
231 | |
232 static void mainwin_view_menu_callback(gpointer user_data, | |
233 guint action, | |
234 GtkWidget * widget); | |
235 | |
236 static void mainwin_play_menu_callback(gpointer user_data, | |
237 guint action, | |
238 GtkWidget * widget); | |
239 | |
240 /* Song name area menu */ | |
241 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
242 GtkItemFactoryEntry mainwin_songname_menu_entries[] = { |
0 | 243 {N_("/View Track Details"), "<alt>i", mainwin_general_menu_callback, |
244 MAINWIN_GENERAL_FILEINFO, "<ImageItem>", my_pixbuf}, | |
245 {"/-", NULL, NULL, 0, "<Separator>"}, | |
246 {N_("/Autoscroll Songname"), NULL, mainwin_songname_menu_callback, | |
247 MAINWIN_SONGNAME_SCROLL, "<ToggleItem>"}, | |
248 }; | |
249 | |
250 static gint mainwin_songname_menu_entries_num = | |
251 G_N_ELEMENTS(mainwin_songname_menu_entries); | |
252 | |
253 /* Mini-visualizer area menu */ | |
254 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
255 GtkItemFactoryEntry mainwin_vis_menu_entries[] = { |
0 | 256 {N_("/Visualization Mode"), NULL, NULL, 0, "<Branch>"}, |
257 {N_("/Visualization Mode/Analyzer"), NULL, mainwin_vis_menu_callback, | |
258 MAINWIN_VIS_ANALYZER, "<RadioItem>"}, | |
259 {N_("/Visualization Mode/Scope"), NULL, mainwin_vis_menu_callback, | |
260 MAINWIN_VIS_SCOPE, "/Visualization Mode/Analyzer"}, | |
261 {N_("/Visualization Mode/Off"), NULL, mainwin_vis_menu_callback, | |
262 MAINWIN_VIS_OFF, "/Visualization Mode/Analyzer"}, | |
263 {N_("/Analyzer Mode"), NULL, NULL, 0, "<Branch>"}, | |
264 {N_("/Analyzer Mode/Normal"), NULL, mainwin_vis_menu_callback, | |
265 MAINWIN_VIS_ANALYZER_NORMAL, "<RadioItem>"}, | |
266 {N_("/Analyzer Mode/Fire"), NULL, mainwin_vis_menu_callback, | |
267 MAINWIN_VIS_ANALYZER_FIRE, "/Analyzer Mode/Normal"}, | |
268 {N_("/Analyzer Mode/Vertical Lines"), NULL, mainwin_vis_menu_callback, | |
269 MAINWIN_VIS_ANALYZER_VLINES, "/Analyzer Mode/Normal"}, | |
270 {"/Analyzer Mode/-", NULL, NULL, 0, "<Separator>"}, | |
271 {N_("/Analyzer Mode/Lines"), NULL, mainwin_vis_menu_callback, | |
272 MAINWIN_VIS_ANALYZER_LINES, "<RadioItem>"}, | |
273 {N_("/Analyzer Mode/Bars"), NULL, mainwin_vis_menu_callback, | |
274 MAINWIN_VIS_ANALYZER_BARS, "/Analyzer Mode/Lines"}, | |
275 {"/Analyzer Mode/-", NULL, NULL, 0, "<Separator>"}, | |
276 {N_("/Analyzer Mode/Peaks"), NULL, mainwin_vis_menu_callback, | |
277 MAINWIN_VIS_ANALYZER_PEAKS, "<ToggleItem>"}, | |
278 {N_("/Scope Mode"), NULL, NULL, 0, "<Branch>"}, | |
279 {N_("/Scope Mode/Dot Scope"), NULL, mainwin_vis_menu_callback, | |
280 MAINWIN_VIS_SCOPE_DOT, "<RadioItem>"}, | |
281 {N_("/Scope Mode/Line Scope"), NULL, mainwin_vis_menu_callback, | |
282 MAINWIN_VIS_SCOPE_LINE, "/Scope Mode/Dot Scope"}, | |
283 {N_("/Scope Mode/Solid Scope"), NULL, mainwin_vis_menu_callback, | |
284 MAINWIN_VIS_SCOPE_SOLID, "/Scope Mode/Dot Scope"}, | |
285 {N_("/WindowShade VU Mode"), NULL, NULL, 0, "<Branch>"}, | |
286 {N_("/WindowShade VU Mode/Normal"), NULL, mainwin_vis_menu_callback, | |
287 MAINWIN_VIS_VU_NORMAL, "<RadioItem>"}, | |
288 {N_("/WindowShade VU Mode/Smooth"), NULL, mainwin_vis_menu_callback, | |
289 MAINWIN_VIS_VU_SMOOTH, "/WindowShade VU Mode/Normal"}, | |
290 {N_("/Refresh Rate"), NULL, NULL, 0, "<Branch>"}, | |
291 {N_("/Refresh Rate/Full (~50 fps)"), NULL, mainwin_vis_menu_callback, | |
292 MAINWIN_VIS_REFRESH_FULL, "<RadioItem>"}, | |
293 {N_("/Refresh Rate/Half (~25 fps)"), NULL, mainwin_vis_menu_callback, | |
294 MAINWIN_VIS_REFRESH_HALF, "/Refresh Rate/Full (~50 fps)"}, | |
295 {N_("/Refresh Rate/Quarter (~13 fps)"), NULL, mainwin_vis_menu_callback, | |
296 MAINWIN_VIS_REFRESH_QUARTER, "/Refresh Rate/Full (~50 fps)"}, | |
297 {N_("/Refresh Rate/Eighth (~6 fps)"), NULL, mainwin_vis_menu_callback, | |
298 MAINWIN_VIS_REFRESH_EIGHTH, "/Refresh Rate/Full (~50 fps)"}, | |
299 {N_("/Analyzer Falloff"), NULL, NULL, 0, "<Branch>"}, | |
300 {N_("/Analyzer Falloff/Slowest"), NULL, mainwin_vis_menu_callback, | |
301 MAINWIN_VIS_AFALLOFF_SLOWEST, "<RadioItem>"}, | |
302 {N_("/Analyzer Falloff/Slow"), NULL, mainwin_vis_menu_callback, | |
303 MAINWIN_VIS_AFALLOFF_SLOW, "/Analyzer Falloff/Slowest"}, | |
304 {N_("/Analyzer Falloff/Medium"), NULL, mainwin_vis_menu_callback, | |
305 MAINWIN_VIS_AFALLOFF_MEDIUM, "/Analyzer Falloff/Slowest"}, | |
306 {N_("/Analyzer Falloff/Fast"), NULL, mainwin_vis_menu_callback, | |
307 MAINWIN_VIS_AFALLOFF_FAST, "/Analyzer Falloff/Slowest"}, | |
308 {N_("/Analyzer Falloff/Fastest"), NULL, mainwin_vis_menu_callback, | |
309 MAINWIN_VIS_AFALLOFF_FASTEST, "/Analyzer Falloff/Slowest"}, | |
310 {N_("/Peaks Falloff"), NULL, NULL, 0, "<Branch>"}, | |
311 {N_("/Peaks Falloff/Slowest"), NULL, mainwin_vis_menu_callback, | |
312 MAINWIN_VIS_PFALLOFF_SLOWEST, "<RadioItem>"}, | |
313 {N_("/Peaks Falloff/Slow"), NULL, mainwin_vis_menu_callback, | |
314 MAINWIN_VIS_PFALLOFF_SLOW, "/Peaks Falloff/Slowest"}, | |
315 {N_("/Peaks Falloff/Medium"), NULL, mainwin_vis_menu_callback, | |
316 MAINWIN_VIS_PFALLOFF_MEDIUM, "/Peaks Falloff/Slowest"}, | |
317 {N_("/Peaks Falloff/Fast"), NULL, mainwin_vis_menu_callback, | |
318 MAINWIN_VIS_PFALLOFF_FAST, "/Peaks Falloff/Slowest"}, | |
319 {N_("/Peaks Falloff/Fastest"), NULL, mainwin_vis_menu_callback, | |
320 MAINWIN_VIS_PFALLOFF_FASTEST, "/Peaks Falloff/Slowest"} | |
321 }; | |
322 | |
323 static const gint mainwin_vis_menu_entries_num = | |
324 G_N_ELEMENTS(mainwin_vis_menu_entries); | |
325 | |
326 /* Playback menu (now used only for accelerators) */ | |
327 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
328 GtkItemFactoryEntry mainwin_playback_menu_entries[] = { |
0 | 329 {N_("/Play CD"), "<alt>C", mainwin_general_menu_callback, |
330 MAINWIN_GENERAL_PLAYCD, "<StockItem>", GTK_STOCK_CDROM}, | |
331 {"/-", NULL, NULL, 0, "<Separator>"}, | |
332 {N_("/Repeat"), "R", mainwin_play_menu_callback, | |
333 MAINWIN_OPT_REPEAT, "<ToggleItem>"}, | |
334 {N_("/Shuffle"), "S", mainwin_play_menu_callback, | |
335 MAINWIN_OPT_SHUFFLE, "<ToggleItem>"}, | |
336 {N_("/No Playlist Advance"), "<control>N", mainwin_play_menu_callback, | |
337 MAINWIN_OPT_NPA, "<ToggleItem>"}, | |
338 {"/-", NULL, NULL, 0, "<Separator>"}, | |
339 {N_("/Play"), "x", mainwin_general_menu_callback, | |
340 MAINWIN_GENERAL_PLAY, "<Item>"}, | |
341 {N_("/Pause"), "c", mainwin_general_menu_callback, | |
342 MAINWIN_GENERAL_PAUSE, "<Item>"}, | |
343 {N_("/Stop"), "v", mainwin_general_menu_callback, | |
344 MAINWIN_GENERAL_STOP, "<StockItem>", GTK_STOCK_STOP}, | |
345 {N_("/Previous"), "z", mainwin_general_menu_callback, | |
346 MAINWIN_GENERAL_PREV, "<StockItem>", GTK_STOCK_GO_BACK}, | |
347 {N_("/Next"), "b", mainwin_general_menu_callback, | |
348 MAINWIN_GENERAL_NEXT, "<StockItem>", GTK_STOCK_GO_FORWARD}, | |
349 {"/-", NULL, NULL, 0, "<Separator>"}, | |
350 {N_("/Jump to Playlist Start"), "<control>Z", mainwin_general_menu_callback, | |
351 MAINWIN_GENERAL_START, "<StockItem>", GTK_STOCK_GOTO_TOP}, | |
352 {"/-", NULL, NULL, 0, "<Separator>"}, | |
353 {N_("/Jump to File"), "J", mainwin_general_menu_callback, | |
354 MAINWIN_GENERAL_JTF, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
355 {N_("/Jump to Time"), "<control>J", mainwin_general_menu_callback, | |
356 MAINWIN_GENERAL_JTT, "<StockItem>", GTK_STOCK_JUMP_TO}, | |
88
db2d1d193e56
[svn] Fix the missing separator in the playback menu. (oops)
nenolod
parents:
87
diff
changeset
|
357 {"/-", NULL, NULL, 0, "<Separator>"}, |
87 | 358 {N_("/View Track Details"), "<alt>I", mainwin_general_menu_callback, |
359 MAINWIN_GENERAL_FILEINFO, "<ImageItem>", my_pixbuf} | |
0 | 360 }; |
361 | |
362 static const gint mainwin_playback_menu_entries_num = | |
363 G_N_ELEMENTS(mainwin_playback_menu_entries); | |
364 | |
365 /* Main menu */ | |
366 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
367 GtkItemFactoryEntry mainwin_general_menu_entries[] = { |
86 | 368 {N_("/About Audacious"), NULL, mainwin_general_menu_callback, |
369 MAINWIN_GENERAL_ABOUT, "<StockItem>", GTK_STOCK_DIALOG_INFO}, | |
370 {"/-", NULL, NULL, 0, "<Separator>"}, | |
371 {N_("/Play File"), "L", mainwin_general_menu_callback, | |
372 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN}, | |
373 {N_("/Play Location"), "<control>L", mainwin_general_menu_callback, | |
374 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
375 {"/-", NULL, NULL, 0, "<Separator>"}, | |
87 | 376 {N_("/V_isualization"), NULL, NULL, 0, "<Item>"}, |
377 {N_("/_Playback"), NULL, NULL, 0, "<Item>"}, | |
378 {N_("/_View"), NULL, NULL, 0, "<Item>"}, | |
0 | 379 {"/-", NULL, NULL, 0, "<Separator>"}, |
380 {N_("/Preferences"), "<control>P", mainwin_general_menu_callback, | |
381 MAINWIN_GENERAL_PREFS, "<StockItem>", GTK_STOCK_PREFERENCES}, | |
382 {N_("/_Quit"), NULL, mainwin_general_menu_callback, | |
383 MAINWIN_GENERAL_EXIT, "<StockItem>", GTK_STOCK_QUIT} | |
384 }; | |
385 | |
386 static const gint mainwin_general_menu_entries_num = | |
387 G_N_ELEMENTS(mainwin_general_menu_entries); | |
388 | |
389 /* Add submenu */ | |
390 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
391 GtkItemFactoryEntry mainwin_add_menu_entries[] = { |
0 | 392 {N_("/Files..."), "f", mainwin_general_menu_callback, |
393 MAINWIN_GENERAL_PLAYFILE, "<StockItem>", GTK_STOCK_OPEN}, | |
394 {N_("/Internet location..."), "<control>h", mainwin_general_menu_callback, | |
395 MAINWIN_GENERAL_PLAYLOCATION, "<StockItem>", GTK_STOCK_NETWORK}, | |
396 }; | |
397 | |
398 static const gint mainwin_add_menu_entries_num = | |
399 G_N_ELEMENTS(mainwin_add_menu_entries); | |
400 | |
401 /* View submenu */ | |
402 | |
85
8c8a20f72ace
[svn] s/static GTKItemFactoryEntry/GTKItemFactoryEntry/g.
nenolod
parents:
0
diff
changeset
|
403 GtkItemFactoryEntry mainwin_view_menu_entries[] = { |
0 | 404 {N_("/Show Playlist Editor"), "<alt>E", mainwin_general_menu_callback, |
405 MAINWIN_GENERAL_SHOWPLWIN, "<ToggleItem>"}, | |
406 {N_("/Show Equalizer"), "<alt>G", mainwin_general_menu_callback, | |
407 MAINWIN_GENERAL_SHOWEQWIN, "<ToggleItem>"}, | |
408 {"/-", NULL, NULL, 0, "<Separator>"}, | |
409 {N_("/Time Elapsed"), "<control>E", mainwin_view_menu_callback, | |
410 MAINWIN_OPT_TELAPSED, "<RadioItem>"}, | |
411 {N_("/Time Remaining"), "<control>R", mainwin_view_menu_callback, | |
412 MAINWIN_OPT_TREMAINING, "/Time Elapsed"}, | |
413 {"/-", NULL, NULL, 0, "<Separator>"}, | |
414 {N_("/Always On Top"), "<control>o", mainwin_view_menu_callback, | |
415 MAINWIN_OPT_ALWAYS, "<ToggleItem>"}, | |
416 {N_("/Put on All Workspaces"), "<control>S", | |
417 mainwin_view_menu_callback, MAINWIN_OPT_STICKY, "<ToggleItem>"}, | |
418 {"/-", NULL, NULL, 0, "<Separator>"}, | |
419 {N_("/Roll up Player"), "<control>W", mainwin_view_menu_callback, | |
420 MAINWIN_OPT_WS, "<ToggleItem>"}, | |
421 {N_("/Roll up Playlist Editor"), "<control><shift>W", mainwin_view_menu_callback, | |
422 MAINWIN_OPT_PWS, "<ToggleItem>"}, | |
423 {N_("/Roll up Equalizer"), "<control><alt>W", mainwin_view_menu_callback, | |
424 MAINWIN_OPT_EQWS, "<ToggleItem>"} | |
425 }; | |
426 | |
427 static const gint mainwin_view_menu_entries_num = | |
428 G_N_ELEMENTS(mainwin_view_menu_entries); | |
429 | |
430 | |
431 static PlaybackInfo playback_info = { NULL, 0, 0, 0 }; | |
432 | |
433 | |
434 static gint mainwin_idle_func(gpointer data); | |
435 | |
436 static void set_timer_mode_menu_cb(TimerMode mode); | |
437 static void set_timer_mode(TimerMode mode); | |
438 | |
439 | |
440 /* FIXME: placed here for now */ | |
441 void | |
442 playback_get_sample_params(gint * bitrate, | |
443 gint * frequency, | |
444 gint * n_channels) | |
445 { | |
446 if (bitrate) | |
447 *bitrate = playback_info.bitrate; | |
448 | |
449 if (frequency) | |
450 *frequency = playback_info.frequency; | |
451 | |
452 if (n_channels) | |
453 *n_channels = playback_info.n_channels; | |
454 } | |
455 | |
456 static void | |
457 playback_set_sample_params(gint bitrate, | |
458 gint frequency, | |
459 gint n_channels) | |
460 { | |
461 if (bitrate >= 0) | |
462 playback_info.bitrate = bitrate; | |
463 | |
464 if (frequency >= 0) | |
465 playback_info.frequency = frequency; | |
466 | |
467 if (n_channels >= 0) | |
468 playback_info.n_channels = n_channels; | |
469 } | |
470 | |
471 static void | |
472 mainwin_set_title_scroll(gboolean scroll) | |
473 { | |
474 cfg.autoscroll = scroll; | |
475 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
476 } | |
477 | |
478 | |
479 void | |
480 mainwin_set_always_on_top(gboolean always) | |
481 { | |
482 GtkWidget *widget = gtk_item_factory_get_widget(mainwin_view_menu, | |
483 "/Always On Top"); | |
484 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
485 mainwin_menurow->mr_always_selected); | |
486 } | |
487 | |
488 static void | |
489 mainwin_set_shape_mask(void) | |
490 { | |
491 GdkBitmap *mask; | |
492 | |
493 if (!cfg.player_visible) | |
494 return; | |
495 | |
496 mask = skin_get_mask(bmp_active_skin, SKIN_MASK_MAIN + cfg.player_shaded); | |
497 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0); | |
498 } | |
499 | |
500 static void | |
501 mainwin_set_shade(gboolean shaded) | |
502 { | |
503 GtkWidget *widget; | |
504 widget = gtk_item_factory_get_widget(mainwin_view_menu, | |
505 "/Roll up Player"); | |
506 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), shaded); | |
507 } | |
508 | |
509 static void | |
510 mainwin_set_shade_menu_cb(gboolean shaded) | |
511 { | |
512 cfg.player_shaded = shaded; | |
513 | |
514 mainwin_set_shape_mask(); | |
515 | |
516 if (shaded) { | |
517 dock_shade(dock_window_list, GTK_WINDOW(mainwin), | |
518 MAINWIN_SHADED_HEIGHT); | |
519 | |
520 widget_show(WIDGET(mainwin_svis)); | |
521 vis_clear_data(mainwin_vis); | |
522 | |
523 widget_show(WIDGET(mainwin_srew)); | |
524 widget_show(WIDGET(mainwin_splay)); | |
525 widget_show(WIDGET(mainwin_spause)); | |
526 widget_show(WIDGET(mainwin_sstop)); | |
527 widget_show(WIDGET(mainwin_sfwd)); | |
528 widget_show(WIDGET(mainwin_seject)); | |
529 | |
530 widget_show(WIDGET(mainwin_stime_min)); | |
531 widget_show(WIDGET(mainwin_stime_sec)); | |
532 | |
533 textbox_set_scroll(mainwin_info, FALSE); | |
534 if (bmp_playback_get_playing() | |
535 && playlist_get_current_length() != -1) | |
536 widget_show(WIDGET(mainwin_sposition)); | |
537 | |
538 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
539 } | |
540 else { | |
541 dock_shade(dock_window_list, GTK_WINDOW(mainwin), MAINWIN_HEIGHT); | |
542 | |
543 widget_hide(WIDGET(mainwin_svis)); | |
544 svis_clear_data(mainwin_svis); | |
545 | |
546 widget_hide(WIDGET(mainwin_srew)); | |
547 widget_hide(WIDGET(mainwin_splay)); | |
548 widget_hide(WIDGET(mainwin_spause)); | |
549 widget_hide(WIDGET(mainwin_sstop)); | |
550 widget_hide(WIDGET(mainwin_sfwd)); | |
551 widget_hide(WIDGET(mainwin_seject)); | |
552 | |
553 widget_hide(WIDGET(mainwin_stime_min)); | |
554 widget_hide(WIDGET(mainwin_stime_sec)); | |
555 widget_hide(WIDGET(mainwin_sposition)); | |
556 | |
557 textbox_set_scroll(mainwin_info, TRUE); | |
558 mainwin_shade->pb_ny = mainwin_shade->pb_py = 18; | |
559 } | |
560 | |
561 draw_main_window(TRUE); | |
562 } | |
563 | |
564 static void | |
565 mainwin_vis_set_active_vis(gint new_vis) | |
566 { | |
567 switch (new_vis) { | |
568 case MAINWIN_VIS_ACTIVE_MAINWIN: | |
569 playlistwin_vis_disable(); | |
570 active_vis = mainwin_vis; | |
571 break; | |
572 case MAINWIN_VIS_ACTIVE_PLAYLISTWIN: | |
573 playlistwin_vis_enable(); | |
574 active_vis = playlistwin_vis; | |
575 break; | |
576 } | |
577 } | |
578 | |
579 static void | |
580 mainwin_vis_set_refresh(RefreshRate rate) | |
581 { | |
582 cfg.vis_refresh = rate; | |
583 } | |
584 | |
585 static void | |
586 mainwin_vis_set_afalloff(FalloffSpeed speed) | |
587 { | |
588 cfg.analyzer_falloff = speed; | |
589 } | |
590 | |
591 static void | |
592 mainwin_vis_set_pfalloff(FalloffSpeed speed) | |
593 { | |
594 cfg.peaks_falloff = speed; | |
595 } | |
596 | |
597 static void | |
598 mainwin_vis_set_analyzer_mode(AnalyzerMode mode) | |
599 { | |
600 cfg.analyzer_mode = mode; | |
601 } | |
602 | |
603 static void | |
604 mainwin_vis_set_analyzer_type(AnalyzerType mode) | |
605 { | |
606 cfg.analyzer_type = mode; | |
607 } | |
608 | |
609 void | |
610 mainwin_vis_set_type(VisType mode) | |
611 { | |
612 gchar *path = | |
613 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + mode].path; | |
614 GtkWidget *widget = gtk_item_factory_get_widget(mainwin_vis_menu, path); | |
615 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), TRUE); | |
616 } | |
617 | |
618 static void | |
619 mainwin_vis_set_type_menu_cb(VisType mode) | |
620 { | |
621 cfg.vis_type = mode; | |
622 | |
623 if (mode == VIS_OFF) { | |
624 if (cfg.player_shaded && cfg.player_visible) | |
625 svis_clear(mainwin_svis); | |
626 else | |
627 vis_clear(active_vis); | |
628 } | |
629 if (mode == VIS_ANALYZER) { | |
630 vis_clear_data(active_vis); | |
631 svis_clear_data(mainwin_svis); | |
632 } | |
633 } | |
634 | |
635 static void | |
636 mainwin_menubtn_cb(void) | |
637 { | |
638 gint x, y; | |
639 gtk_window_get_position(GTK_WINDOW(mainwin), &x, &y); | |
640 util_item_factory_popup(mainwin_general_menu, | |
641 x + 6, | |
642 y + MAINWIN_SHADED_HEIGHT, | |
643 1, GDK_CURRENT_TIME); | |
644 } | |
645 | |
646 void | |
647 mainwin_minimize_cb(void) | |
648 { | |
649 if (!mainwin) | |
650 return; | |
651 | |
652 gtk_window_iconify(GTK_WINDOW(mainwin)); | |
653 } | |
654 | |
655 static void | |
656 mainwin_shade_toggle(void) | |
657 { | |
658 mainwin_set_shade(!cfg.player_shaded); | |
659 } | |
660 | |
661 void | |
662 mainwin_quit_cb(void) | |
663 { | |
664 gtk_widget_hide(equalizerwin); | |
665 gtk_widget_hide(playlistwin); | |
666 gtk_widget_hide(mainwin); | |
667 gdk_flush(); | |
668 | |
669 g_source_remove(mainwin_timeout_id); | |
670 | |
671 util_set_cursor(NULL); | |
672 | |
673 bmp_config_save(); | |
674 gtk_accel_map_save(bmp_paths[BMP_PATH_ACCEL_FILE]); | |
675 | |
676 ctrlsocket_cleanup(); | |
677 | |
678 playlist_stop_get_info_thread(); | |
679 playlist_clear(); | |
680 | |
681 plugin_system_cleanup(); | |
682 | |
683 gtk_main_quit(); | |
196 | 684 |
685 exit(EXIT_SUCCESS); | |
0 | 686 } |
687 | |
688 static void | |
689 mainwin_destroy(GtkWidget * widget, gpointer data) | |
690 { | |
691 mainwin_quit_cb(); | |
692 } | |
693 | |
694 static void | |
695 mainwin_draw_titlebar(gboolean focus) | |
696 { | |
697 skin_draw_mainwin_titlebar(bmp_active_skin, mainwin_bg, mainwin_gc, | |
698 cfg.player_shaded, focus || !cfg.dim_titlebar); | |
699 } | |
700 | |
701 void | |
702 draw_main_window(gboolean force) | |
703 { | |
704 GList *wl; | |
705 Widget *w; | |
706 gboolean redraw; | |
707 | |
708 if (!cfg.player_visible) | |
709 return; | |
710 | |
711 widget_list_lock(mainwin_wlist); | |
712 | |
713 if (force) { | |
714 if (!cfg.player_shaded) | |
715 skin_draw_pixmap(bmp_active_skin, mainwin_bg, mainwin_gc, | |
716 SKIN_MAIN, 0, 0, 0, 0, MAINWIN_WIDTH, | |
717 MAINWIN_HEIGHT); | |
718 mainwin_draw_titlebar(gtk_window_has_toplevel_focus | |
719 (GTK_WINDOW(mainwin))); | |
720 } | |
721 | |
722 widget_list_draw(mainwin_wlist, &redraw, force); | |
723 | |
724 if (redraw || force) { | |
725 if (force) { | |
726 gdk_window_clear(mainwin->window); | |
727 } | |
728 else { | |
729 for (wl = mainwin_wlist; wl; wl = g_list_next(wl)) { | |
730 w = WIDGET(wl->data); | |
731 | |
732 if (!w->redraw || !w->visible) | |
733 continue; | |
734 | |
735 gdk_window_clear_area(mainwin->window, w->x, w->y, | |
736 w->width, w->height); | |
737 w->redraw = FALSE; | |
738 } | |
739 } | |
740 | |
741 gdk_flush(); | |
742 } | |
743 | |
744 widget_list_unlock(mainwin_wlist); | |
745 } | |
746 | |
747 | |
748 void | |
749 mainwin_set_info_text(void) | |
750 { | |
751 gchar *text; | |
752 | |
753 if (mainwin_info_text_locked) | |
754 return; | |
755 | |
756 if ((text = input_get_info_text()) != NULL) { | |
757 textbox_set_text(mainwin_info, text); | |
758 g_free(text); | |
759 } | |
760 else if ((text = playlist_get_info_text()) != NULL) { | |
761 textbox_set_text(mainwin_info, text); | |
762 g_free(text); | |
763 } | |
764 } | |
765 | |
766 void | |
767 mainwin_lock_info_text(const gchar * text) | |
768 { | |
769 mainwin_info_text_locked = TRUE; | |
770 textbox_set_text(mainwin_info, text); | |
771 } | |
772 | |
773 void | |
774 mainwin_release_info_text(void) | |
775 { | |
776 mainwin_info_text_locked = FALSE; | |
777 mainwin_set_info_text(); | |
778 } | |
779 | |
780 | |
781 static gchar * | |
782 make_mainwin_title(const gchar * title) | |
783 { | |
784 if (title) | |
785 return g_strdup_printf(_("%s - Audacious"), title); | |
786 else | |
787 return g_strdup(_("Audacious")); | |
788 } | |
789 | |
790 void | |
791 mainwin_set_song_title(const gchar * title) | |
792 { | |
793 G_LOCK(mainwin_title); | |
794 g_free(mainwin_title_text); | |
795 mainwin_title_text = make_mainwin_title(title); | |
796 G_UNLOCK(mainwin_title); | |
797 } | |
798 | |
799 void | |
800 mainwin_set_song_info(gint bitrate, | |
801 gint frequency, | |
802 gint n_channels) | |
803 { | |
804 gchar text[10]; | |
805 gchar *title; | |
806 | |
807 playback_set_sample_params(bitrate, frequency, n_channels); | |
808 | |
809 if (bitrate != -1) { | |
810 bitrate /= 1000; | |
811 | |
812 if (bitrate < 1000) { | |
813 /* Show bitrate in 1000s */ | |
814 g_snprintf(text, sizeof(text), "%3d", bitrate); | |
815 textbox_set_text(mainwin_rate_text, text); | |
816 } | |
817 else { | |
818 /* Show bitrate in 100,000s */ | |
819 bitrate /= 100; | |
820 g_snprintf(text, sizeof(text), "%2dH", bitrate); | |
821 textbox_set_text(mainwin_rate_text, text); | |
822 } | |
823 } | |
824 else | |
825 textbox_set_text(mainwin_rate_text, _("VBR")); | |
826 | |
827 /* Show sampling frequency in kHz */ | |
828 g_snprintf(text, sizeof(text), "%2d", frequency / 1000); | |
829 textbox_set_text(mainwin_freq_text, text); | |
830 | |
831 monostereo_set_num_channels(mainwin_monostereo, n_channels); | |
832 | |
833 widget_show(WIDGET(mainwin_minus_num)); | |
834 widget_show(WIDGET(mainwin_10min_num)); | |
835 widget_show(WIDGET(mainwin_min_num)); | |
836 widget_show(WIDGET(mainwin_10sec_num)); | |
837 widget_show(WIDGET(mainwin_sec_num)); | |
838 | |
839 if (!bmp_playback_get_paused()) | |
840 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
841 | |
842 if (playlist_get_current_length() != -1) { | |
843 if (cfg.player_shaded) | |
844 widget_show(WIDGET(mainwin_sposition)); | |
845 widget_show(WIDGET(mainwin_position)); | |
846 } | |
847 else { | |
848 widget_hide(WIDGET(mainwin_position)); | |
849 widget_hide(WIDGET(mainwin_sposition)); | |
850 mainwin_force_redraw = TRUE; | |
851 } | |
852 | |
853 title = playlist_get_info_text(); | |
854 mainwin_set_song_title(title); | |
855 g_free(title); | |
856 } | |
857 | |
858 void | |
859 mainwin_clear_song_info(void) | |
860 { | |
196 | 861 if (!mainwin) |
862 return; | |
863 | |
0 | 864 /* clear title */ |
865 G_LOCK(mainwin_title); | |
866 g_free(mainwin_title_text); | |
867 mainwin_title_text = NULL; | |
868 G_UNLOCK(mainwin_title); | |
869 | |
870 /* clear sampling parameters */ | |
871 playback_set_sample_params(0, 0, 0); | |
872 | |
873 mainwin_position->hs_pressed = FALSE; | |
874 mainwin_sposition->hs_pressed = FALSE; | |
875 | |
876 /* clear sampling parameter displays */ | |
877 textbox_set_text(mainwin_rate_text, " "); | |
878 textbox_set_text(mainwin_freq_text, " "); | |
879 monostereo_set_num_channels(mainwin_monostereo, 0); | |
880 | |
881 playstatus_set_status(mainwin_playstatus, STATUS_STOP); | |
882 | |
883 /* hide playback time */ | |
884 widget_hide(WIDGET(mainwin_minus_num)); | |
885 widget_hide(WIDGET(mainwin_10min_num)); | |
886 widget_hide(WIDGET(mainwin_min_num)); | |
887 widget_hide(WIDGET(mainwin_10sec_num)); | |
888 widget_hide(WIDGET(mainwin_sec_num)); | |
889 | |
890 textbox_set_text(mainwin_stime_min, " "); | |
891 textbox_set_text(mainwin_stime_sec, " "); | |
892 | |
893 widget_hide(WIDGET(mainwin_position)); | |
894 widget_hide(WIDGET(mainwin_sposition)); | |
895 | |
896 playlistwin_hide_timer(); | |
897 draw_main_window(TRUE); | |
898 | |
899 vis_clear(active_vis); | |
900 } | |
901 | |
902 void | |
903 mainwin_disable_seekbar(void) | |
904 { | |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
905 if (!mainwin) |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
906 return; |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
907 |
0 | 908 /* |
909 * We dont call draw_main_window() here so this will not | |
910 * remove them visually. It will only prevent us from sending | |
911 * any seek calls to the input plugin before the input plugin | |
912 * calls ->set_info(). | |
913 */ | |
914 widget_hide(WIDGET(mainwin_position)); | |
915 widget_hide(WIDGET(mainwin_sposition)); | |
916 } | |
917 | |
918 static gboolean | |
919 mainwin_mouse_button_release(GtkWidget * widget, | |
920 GdkEventButton * event, | |
921 gpointer callback_data) | |
922 { | |
923 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
924 | |
925 /* | |
926 * The gdk_flush() is just for making sure that the pointer really | |
927 * gets ungrabbed before calling any button callbacks | |
928 * | |
929 */ | |
930 | |
931 gdk_flush(); | |
932 | |
933 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
934 dock_move_release(GTK_WINDOW(mainwin)); | |
935 } | |
936 | |
937 if (mainwin_menurow->mr_doublesize_selected) { | |
938 event->x /= 2; | |
939 event->y /= 2; | |
940 } | |
941 | |
942 handle_release_cb(mainwin_wlist, widget, event); | |
943 | |
944 draw_main_window(FALSE); | |
945 | |
946 return FALSE; | |
947 } | |
948 | |
949 static gboolean | |
950 mainwin_motion(GtkWidget * widget, | |
951 GdkEventMotion * event, | |
952 gpointer callback_data) | |
953 { | |
954 XEvent ev; | |
955 gint i = 0; | |
956 | |
957 XSync(GDK_DISPLAY(), False); | |
958 | |
959 while (XCheckTypedEvent(GDK_DISPLAY(), MotionNotify, &ev)) { | |
960 event->x = ev.xmotion.x; | |
961 event->y = ev.xmotion.y; | |
962 i++; | |
963 } | |
964 | |
965 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
966 dock_move_motion(GTK_WINDOW(mainwin), event); | |
967 } | |
968 else { | |
969 handle_motion_cb(mainwin_wlist, widget, event); | |
970 draw_main_window(FALSE); | |
971 } | |
972 gdk_flush(); | |
973 | |
974 return FALSE; | |
975 } | |
976 | |
977 static gboolean | |
978 inside_sensitive_widgets(gint x, gint y) | |
979 { | |
980 return (widget_contains(WIDGET(mainwin_menubtn), x, y) | |
981 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
982 || widget_contains(WIDGET(mainwin_shade), x, y) | |
983 || widget_contains(WIDGET(mainwin_close), x, y) | |
984 || widget_contains(WIDGET(mainwin_rew), x, y) | |
985 || widget_contains(WIDGET(mainwin_play), x, y) | |
986 || widget_contains(WIDGET(mainwin_pause), x, y) | |
987 || widget_contains(WIDGET(mainwin_stop), x, y) | |
988 || widget_contains(WIDGET(mainwin_fwd), x, y) | |
989 || widget_contains(WIDGET(mainwin_eject), x, y) | |
990 || widget_contains(WIDGET(mainwin_shuffle), x, y) | |
991 || widget_contains(WIDGET(mainwin_repeat), x, y) | |
992 || widget_contains(WIDGET(mainwin_pl), x, y) | |
993 || widget_contains(WIDGET(mainwin_eq), x, y) | |
994 || widget_contains(WIDGET(mainwin_info), x, y) | |
995 || widget_contains(WIDGET(mainwin_menurow), x, y) | |
996 || widget_contains(WIDGET(mainwin_volume), x, y) | |
997 || widget_contains(WIDGET(mainwin_balance), x, y) | |
998 || (widget_contains(WIDGET(mainwin_position), x, y) && | |
999 widget_is_visible(WIDGET(mainwin_position))) | |
1000 || widget_contains(WIDGET(mainwin_minus_num), x, y) | |
1001 || widget_contains(WIDGET(mainwin_10min_num), x, y) | |
1002 || widget_contains(WIDGET(mainwin_min_num), x, y) | |
1003 || widget_contains(WIDGET(mainwin_10sec_num), x, y) | |
1004 || widget_contains(WIDGET(mainwin_sec_num), x, y) | |
1005 || widget_contains(WIDGET(mainwin_vis), x, y) | |
1006 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1007 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1008 || widget_contains(WIDGET(mainwin_close), x, y) | |
1009 || widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1010 || widget_contains(WIDGET(mainwin_sposition), x, y) | |
1011 || widget_contains(WIDGET(mainwin_stime_min), x, y) | |
1012 || widget_contains(WIDGET(mainwin_stime_sec), x, y) | |
1013 || widget_contains(WIDGET(mainwin_srew), x, y) | |
1014 || widget_contains(WIDGET(mainwin_splay), x, y) | |
1015 || widget_contains(WIDGET(mainwin_spause), x, y) | |
1016 || widget_contains(WIDGET(mainwin_sstop), x, y) | |
1017 || widget_contains(WIDGET(mainwin_sfwd), x, y) | |
1018 || widget_contains(WIDGET(mainwin_seject), x, y) | |
1019 || widget_contains(WIDGET(mainwin_svis), x, y) | |
1020 || widget_contains(WIDGET(mainwin_about), x, y)); | |
1021 } | |
1022 | |
1023 void | |
1024 mainwin_scrolled(GtkWidget * widget, | |
1025 GdkEventScroll * event, | |
1026 gpointer callback_data) | |
1027 { | |
1028 gint d = cfg.mouse_change; | |
1029 if (event->direction == GDK_SCROLL_DOWN) | |
1030 d *= -1; | |
1031 mainwin_set_volume_diff(d); | |
1032 } | |
1033 | |
1034 | |
1035 static gboolean | |
1036 mainwin_mouse_button_press(GtkWidget * widget, | |
1037 GdkEventButton * event, | |
1038 gpointer callback_data) | |
1039 { | |
1040 | |
1041 gboolean grab = TRUE; | |
1042 | |
1043 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1044 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) { | |
1045 if (0 && hint_move_resize_available()) { | |
1046 hint_move_resize(mainwin, event->x_root, event->y_root, TRUE); | |
1047 grab = FALSE; | |
1048 } | |
1049 else { | |
1050 gtk_window_present(GTK_WINDOW(mainwin)); | |
1051 dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, | |
1052 TRUE); | |
1053 } | |
1054 } | |
1055 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1056 event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) { | |
1057 mainwin_set_shade(!cfg.player_shaded); | |
1058 if (dock_is_moving(GTK_WINDOW(mainwin))) | |
1059 dock_move_release(GTK_WINDOW(mainwin)); | |
1060 } | |
1061 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1062 widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1063 playlist_fileinfo_current(); | |
1064 } | |
1065 else { | |
1066 handle_press_cb(mainwin_wlist, widget, event); | |
1067 draw_main_window(FALSE); | |
1068 } | |
1069 | |
1070 if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS && | |
1071 (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1072 widget_contains(WIDGET(mainwin_svis), event->x, event->y))) { | |
1073 | |
1074 cfg.vis_type++; | |
1075 | |
1076 if (cfg.vis_type > VIS_OFF) | |
1077 cfg.vis_type = VIS_ANALYZER; | |
1078 | |
1079 mainwin_vis_set_type(cfg.vis_type); | |
1080 } | |
1081 | |
1082 if (event->button == 3) { | |
1083 if (widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1084 util_item_factory_popup(mainwin_songname_menu, | |
1085 event->x_root, event->y_root, | |
1086 3, event->time); | |
1087 grab = FALSE; | |
1088 } | |
1089 else if (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1090 widget_contains(WIDGET(mainwin_svis), event->x, event->y)) { | |
1091 util_item_factory_popup(mainwin_vis_menu, event->x_root, | |
1092 event->y_root, 3, event->time); | |
1093 grab = FALSE; | |
1094 } | |
1095 else if ( (event->y > 70) && (event->x < 128) ) | |
1096 { | |
1097 | |
1098 util_item_factory_popup(mainwin_play_menu, | |
1099 event->x_root, | |
1100 event->y_root, 3, event->time); | |
1101 grab = FALSE; | |
1102 } else { | |
1103 /* | |
1104 * Pop up the main menu a few pixels down. | |
1105 * This will avoid that anything is selected | |
1106 * if one right-clicks to focus the window | |
1107 * without raising it. | |
1108 * | |
1109 ***MD I think the above is stupid, people don't expect this | |
1110 * | |
1111 */ | |
1112 util_item_factory_popup(mainwin_general_menu, | |
1113 event->x_root, | |
1114 event->y_root, 3, event->time); | |
1115 grab = FALSE; | |
1116 } | |
1117 } | |
1118 if (event->button == 1) { | |
1119 if ((event->x > 35 && event->x < 100 && | |
1120 event->y > 25 && event->y < 40) || | |
1121 widget_contains(WIDGET(mainwin_stime_min), event->x, event->y) || | |
1122 widget_contains(WIDGET(mainwin_stime_sec), event->x, event->y)) { | |
1123 | |
1124 if (cfg.timer_mode == TIMER_ELAPSED) | |
1125 set_timer_mode(TIMER_REMAINING); | |
1126 else | |
1127 set_timer_mode(TIMER_ELAPSED); | |
1128 } | |
1129 | |
1130 } | |
1131 | |
1132 if (grab) | |
1133 gdk_pointer_grab(mainwin->window, FALSE, | |
1134 GDK_BUTTON_MOTION_MASK | | |
1135 GDK_BUTTON_RELEASE_MASK, | |
1136 GDK_WINDOW(GDK_NONE), NULL, GDK_CURRENT_TIME); | |
1137 | |
1138 return FALSE; | |
1139 } | |
1140 | |
1141 static gboolean | |
1142 mainwin_focus_in(GtkWidget * window, | |
1143 GdkEventFocus * event, | |
1144 gpointer data) | |
1145 { | |
1146 mainwin_menubtn->pb_allow_draw = TRUE; | |
1147 mainwin_minimize->pb_allow_draw = TRUE; | |
1148 mainwin_shade->pb_allow_draw = TRUE; | |
1149 mainwin_close->pb_allow_draw = TRUE; | |
1150 draw_main_window(TRUE); | |
1151 | |
1152 return TRUE; | |
1153 } | |
1154 | |
1155 | |
1156 static gboolean | |
1157 mainwin_focus_out(GtkWidget * widget, | |
1158 GdkEventFocus * event, | |
1159 gpointer callback_data) | |
1160 { | |
1161 mainwin_menubtn->pb_allow_draw = FALSE; | |
1162 mainwin_minimize->pb_allow_draw = FALSE; | |
1163 mainwin_shade->pb_allow_draw = FALSE; | |
1164 mainwin_close->pb_allow_draw = FALSE; | |
1165 draw_main_window(TRUE); | |
1166 | |
1167 return TRUE; | |
1168 } | |
1169 | |
1170 static gboolean | |
1171 mainwin_keypress(GtkWidget * grab_widget, | |
1172 GdkEventKey * event, | |
1173 gpointer data) | |
1174 { | |
1175 | |
1176 switch (event->keyval) { | |
1177 | |
1178 case GDK_Up: | |
1179 case GDK_KP_Up: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1180 case GDK_KP_8: |
0 | 1181 mainwin_set_volume_diff(2); |
1182 break; | |
1183 case GDK_Down: | |
1184 case GDK_KP_Down: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1185 case GDK_KP_2: |
0 | 1186 mainwin_set_volume_diff(-2); |
1187 break; | |
1188 case GDK_Left: | |
1189 case GDK_KP_Left: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1190 case GDK_KP_7: |
0 | 1191 if (playlist_get_current_length() != -1) |
1192 bmp_playback_seek(CLAMP | |
435
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
1193 (bmp_playback_get_time() - 1000, 0, |
0 | 1194 playlist_get_current_length()) / 1000); |
1195 break; | |
1196 case GDK_Right: | |
1197 case GDK_KP_Right: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1198 case GDK_KP_9: |
0 | 1199 if (playlist_get_current_length() != -1) |
1200 bmp_playback_seek(CLAMP | |
435
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
1201 (bmp_playback_get_time() + 1000, 0, |
0 | 1202 playlist_get_current_length()) / 1000); |
1203 break; | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1204 case GDK_KP_4: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1205 playlist_prev(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1206 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1207 case GDK_KP_6: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1208 playlist_next(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1209 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1210 case GDK_KP_Insert: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1211 mainwin_jump_to_file(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1212 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1213 case GDK_KP_5: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1214 mainwin_play_pushed(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1215 break; |
0 | 1216 case GDK_Escape: |
1217 mainwin_minimize_cb(); | |
1218 break; | |
1219 default: | |
1220 return FALSE; | |
1221 } | |
1222 | |
1223 return TRUE; | |
1224 } | |
1225 | |
1226 static void | |
1227 mainwin_jump_to_time_cb(GtkWidget * widget, | |
1228 GtkWidget * entry) | |
1229 { | |
1230 guint min = 0, sec = 0, params, time; | |
1231 | |
1232 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u", | |
1233 &min, &sec); | |
1234 if (params == 2) | |
1235 time = (min * 60) + sec; | |
1236 else if (params == 1) | |
1237 time = min; | |
1238 else | |
1239 return; | |
1240 | |
1241 if (playlist_get_current_length() > -1 && | |
1242 time <= (playlist_get_current_length() / 1000)) { | |
1243 bmp_playback_seek(time); | |
1244 gtk_widget_destroy(mainwin_jtt); | |
1245 } | |
1246 } | |
1247 | |
1248 | |
1249 void | |
1250 mainwin_jump_to_time(void) | |
1251 { | |
1252 GtkWidget *vbox, *hbox_new, *hbox_total; | |
1253 GtkWidget *time_entry, *label, *bbox, *jump, *cancel; | |
1254 guint tindex; | |
1255 gchar time_str[10]; | |
1256 | |
1257 if (!bmp_playback_get_playing()) { | |
1258 /* FIXME: pop an error dialog and/or disable menu option to | |
1259 indicate JTT can't be launched when no track is being | |
1260 played */ | |
1261 return; | |
1262 } | |
1263 | |
1264 if (mainwin_jtt) { | |
1265 gtk_window_present(GTK_WINDOW(mainwin_jtt)); | |
1266 return; | |
1267 } | |
1268 | |
1269 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1270 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt), | |
1271 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1272 | |
1273 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time")); | |
1274 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER); | |
1275 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt), | |
1276 GTK_WINDOW(mainwin)); | |
1277 | |
1278 g_signal_connect(mainwin_jtt, "destroy", | |
1279 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt); | |
1280 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10); | |
1281 | |
1282 vbox = gtk_vbox_new(FALSE, 5); | |
1283 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox); | |
1284 | |
1285 hbox_new = gtk_hbox_new(FALSE, 0); | |
1286 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5); | |
1287 | |
1288 time_entry = gtk_entry_new(); | |
1289 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5); | |
1290 g_signal_connect(time_entry, "activate", | |
1291 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1292 | |
1293 gtk_widget_set_size_request(time_entry, 70, -1); | |
1294 label = gtk_label_new(_("minutes:seconds")); | |
1295 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5); | |
1296 | |
1297 hbox_total = gtk_hbox_new(FALSE, 0); | |
1298 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5); | |
1299 gtk_widget_show(hbox_total); | |
1300 | |
1301 /* FIXME: Disable display of current track length. It's not | |
1302 updated when track changes */ | |
1303 #if 0 | |
1304 label = gtk_label_new(_("Track length:")); | |
1305 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5); | |
1306 | |
1307 len = playlist_get_current_length() / 1000; | |
1308 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60); | |
1309 label = gtk_label_new(time_str); | |
1310 | |
1311 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10); | |
1312 #endif | |
1313 | |
1314 bbox = gtk_hbutton_box_new(); | |
1315 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); | |
1316 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1317 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1318 | |
1319 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1320 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1321 gtk_container_add(GTK_CONTAINER(bbox), cancel); | |
1322 g_signal_connect_swapped(cancel, "clicked", | |
1323 G_CALLBACK(gtk_widget_destroy), mainwin_jtt); | |
1324 | |
1325 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1326 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1327 gtk_container_add(GTK_CONTAINER(bbox), jump); | |
1328 g_signal_connect(jump, "clicked", | |
1329 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1330 | |
1331 tindex = bmp_playback_get_time() / 1000; | |
1332 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60, | |
1333 tindex % 60); | |
1334 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str); | |
1335 | |
1336 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str)); | |
1337 | |
1338 gtk_widget_show_all(mainwin_jtt); | |
1339 | |
1340 gtk_widget_grab_focus(time_entry); | |
1341 gtk_widget_grab_default(jump); | |
1342 } | |
1343 | |
1344 static void | |
1345 change_song(guint pos) | |
1346 { | |
1347 if (bmp_playback_get_playing()) | |
1348 bmp_playback_stop(); | |
1349 | |
1350 playlist_set_position(pos); | |
1351 bmp_playback_initiate(); | |
1352 } | |
1353 | |
1354 static void | |
1355 mainwin_jump_to_file_jump(GtkTreeView * treeview) | |
1356 { | |
1357 GtkTreeModel *model; | |
1358 GtkTreeSelection *selection; | |
1359 GtkTreeIter iter; | |
1360 gchar *pos_str; | |
1361 guint pos; | |
1362 | |
1363 model = gtk_tree_view_get_model(treeview); | |
1364 selection = gtk_tree_view_get_selection(treeview); | |
1365 | |
1366 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1367 return; | |
1368 | |
1369 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1370 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1371 | |
1372 change_song(pos); | |
1373 | |
1374 /* FIXME: should only hide window */ | |
1375 gtk_widget_destroy(mainwin_jtf); | |
1376 mainwin_jtf = NULL; | |
1377 } | |
1378 | |
1379 static void | |
1380 mainwin_jump_to_file_jump_cb(GtkTreeView * treeview, | |
1381 gpointer data) | |
1382 { | |
1383 mainwin_jump_to_file_jump(treeview); | |
1384 } | |
1385 | |
1386 static void | |
1387 mainwin_jump_to_file_set_queue_button_label(GtkButton * button, | |
1388 guint pos) | |
1389 { | |
1390 if (playlist_is_position_queued(pos)) | |
1391 gtk_button_set_label(button, _("Un_queue")); | |
1392 else | |
1393 gtk_button_set_label(button, _("_Queue")); | |
1394 } | |
1395 | |
1396 static void | |
1397 mainwin_jump_to_file_queue_cb(GtkButton * button, | |
1398 gpointer data) | |
1399 { | |
1400 GtkTreeView *treeview; | |
1401 GtkTreeModel *model; | |
1402 GtkTreeSelection *selection; | |
1403 GtkTreeIter iter; | |
1404 gchar *pos_str; | |
1405 guint pos; | |
1406 | |
1407 treeview = GTK_TREE_VIEW(data); | |
1408 model = gtk_tree_view_get_model(treeview); | |
1409 selection = gtk_tree_view_get_selection(treeview); | |
1410 | |
1411 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1412 return; | |
1413 | |
1414 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1415 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1416 | |
1417 playlist_queue_position(pos); | |
1418 | |
1419 mainwin_jump_to_file_set_queue_button_label(button, pos); | |
1420 } | |
1421 | |
1422 static void | |
1423 mainwin_jump_to_file_selection_changed_cb(GtkTreeSelection *treesel, | |
1424 gpointer data) | |
1425 { | |
1426 GtkTreeView *treeview; | |
1427 GtkTreeModel *model; | |
1428 GtkTreeSelection *selection; | |
1429 GtkTreeIter iter; | |
1430 gchar *pos_str; | |
1431 guint pos; | |
1432 | |
1433 treeview = gtk_tree_selection_get_tree_view(treesel); | |
1434 model = gtk_tree_view_get_model(treeview); | |
1435 selection = gtk_tree_view_get_selection(treeview); | |
1436 | |
1437 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1438 return; | |
1439 | |
1440 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1441 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1442 | |
1443 mainwin_jump_to_file_set_queue_button_label(GTK_BUTTON(data), pos); | |
1444 } | |
1445 | |
1446 static gboolean | |
1447 mainwin_jump_to_file_keypress_cb(GtkWidget * object, | |
1448 GdkEventKey * event, | |
1449 gpointer data) | |
1450 { | |
1451 switch (event->keyval) { | |
1452 case GDK_Escape: | |
1453 /* FIXME: show only hide window */ | |
1454 gtk_widget_destroy(mainwin_jtf); | |
1455 mainwin_jtf = NULL; | |
1456 return TRUE; | |
1457 case GDK_Return: | |
1458 mainwin_jump_to_file_jump(GTK_TREE_VIEW(data)); | |
1459 return TRUE; | |
1460 default: | |
1461 return FALSE; | |
1462 }; | |
1463 } | |
1464 | |
1465 static gboolean | |
1466 mainwin_jump_to_file_match(const gchar * song, gchar ** keys) | |
1467 { | |
1468 gint i = 0; | |
1469 gchar *key; | |
1470 gchar *song_lc; | |
1471 | |
1472 song_lc = g_ascii_strdown(song, -1); | |
1473 | |
1474 while (keys[i]) { | |
1475 key = g_ascii_strdown(keys[i], -1); | |
1476 if (!g_strrstr(song_lc, key)) { | |
1477 g_free(key); | |
1478 g_free(song_lc); | |
1479 return FALSE; | |
1480 } | |
1481 | |
1482 g_free(key); | |
1483 i++; | |
1484 } | |
1485 | |
1486 g_free(song_lc); | |
1487 | |
1488 return TRUE; | |
1489 } | |
1490 | |
1491 /* FIXME: Clear the entry when the list gets updated */ | |
1492 static void | |
1493 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
1494 { | |
1495 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
1496 * reading */ | |
1497 gint row; | |
1498 GList *playlist; | |
1499 gchar *desc_buf; | |
1500 gchar *row_str; | |
1501 GtkTreeIter iter; | |
1502 GtkTreeSelection *selection; | |
1503 | |
1504 GtkTreeModel *store; | |
1505 | |
1506 if (!mainwin_jtf) | |
1507 return; | |
1508 | |
1509 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
1510 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1511 | |
1512 row = 1; | |
1513 for (playlist = playlist_get(); playlist; | |
1514 playlist = g_list_next(playlist)) { | |
1515 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1516 | |
1517 if (entry->title) | |
1518 desc_buf = entry->title; | |
1519 else if (strchr(entry->filename, '/')) | |
1520 desc_buf = strrchr(entry->filename, '/') + 1; | |
1521 else | |
1522 desc_buf = entry->filename; | |
1523 | |
1524 row_str = g_strdup_printf("%d", row++); | |
1525 | |
1526 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
1527 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
1528 0, row_str, 1, desc_buf, -1); | |
1529 | |
1530 g_free(row_str); | |
1531 } | |
1532 | |
1533 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1534 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
1535 gtk_tree_selection_select_iter(selection, &iter); | |
1536 } | |
1537 | |
1538 static void | |
1539 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
1540 { | |
1541 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
1542 GtkTreeSelection *selection; | |
1543 GtkTreeIter iter; | |
1544 | |
1545 GtkListStore *store; | |
1546 | |
1547 gint song_index = 0; | |
1548 gchar **words; | |
1549 GList *playlist; | |
1550 | |
1551 gboolean match = FALSE; | |
1552 | |
1553 /* Chop the key string into ' '-separated key words */ | |
1554 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
1555 | |
1556 /* FIXME: Remove the connected signals before clearing | |
1557 * (row-selected will still eventually arrive once) */ | |
1558 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
1559 gtk_list_store_clear(store); | |
1560 | |
1561 PLAYLIST_LOCK(); | |
1562 | |
1563 for (playlist = playlist_get(); playlist; | |
1564 playlist = g_list_next(playlist)) { | |
1565 | |
1566 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1567 const gchar *title, *filename; | |
1568 | |
1569 title = entry->title; | |
1570 if (!title) { | |
1571 filename = entry->filename; | |
1572 | |
1573 if (strchr(filename, '/')) | |
1574 title = strrchr(filename, '/') + 1; | |
1575 else | |
1576 title = filename; | |
1577 } | |
1578 | |
1579 /* Compare the key words to the string - if all the words | |
1580 match, add to the ListStore */ | |
1581 | |
1582 /* | |
1583 * FIXME: The search string should be adapted to the | |
1584 * current display setting, e.g. if the user has set it to | |
1585 * "%p - %t" then build the match string like that too, or | |
1586 * even better, search for each of the tags seperatly. | |
1587 * | |
1588 * In any case the string to match should _never_ contain | |
1589 * something the user can't actually see in the playlist. | |
1590 */ | |
1591 if (words[0]) | |
1592 match = mainwin_jump_to_file_match(title, words); | |
1593 else | |
1594 match = TRUE; | |
1595 | |
1596 if (match) { | |
1597 gchar *song_index_str = g_strdup_printf("%d", song_index + 1); | |
1598 gtk_list_store_append(store, &iter); | |
1599 gtk_list_store_set(store, &iter, 0, song_index_str, 1, title, -1); | |
1600 g_free(song_index_str); | |
1601 } | |
1602 | |
1603 song_index++; | |
1604 } | |
1605 | |
1606 PLAYLIST_UNLOCK(); | |
1607 | |
1608 g_strfreev(words); | |
1609 | |
1610 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
1611 selection = gtk_tree_view_get_selection(treeview); | |
1612 gtk_tree_selection_select_iter(selection, &iter); | |
1613 } | |
1614 } | |
1615 | |
1616 void | |
1617 mainwin_jump_to_file(void) | |
1618 { | |
1619 GtkWidget *scrollwin; | |
1620 GtkWidget *vbox, *bbox, *sep; | |
1621 GtkWidget *jump, *queue, *cancel; | |
1622 GtkWidget *rescan, *edit; | |
1623 GtkWidget *search_label, *hbox; | |
1624 GList *playlist; | |
1625 gchar *desc_buf; | |
1626 gchar *row_str; | |
1627 gint row; | |
1628 | |
1629 GtkWidget *treeview; | |
1630 GtkListStore *jtf_store; | |
1631 | |
1632 GtkTreeIter iter; | |
1633 GtkCellRenderer *renderer; | |
1634 GtkTreeViewColumn *column; | |
1635 | |
1636 if (mainwin_jtf) { | |
1637 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
1638 return; | |
1639 } | |
1640 | |
1641 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1642 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
1643 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1644 | |
1645 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
1646 | |
1647 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
1648 g_signal_connect(mainwin_jtf, "destroy", | |
1649 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
1650 | |
1651 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
1652 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
1653 | |
1654 vbox = gtk_vbox_new(FALSE, 5); | |
1655 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
1656 | |
1657 jtf_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
1658 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
1659 g_object_unref(jtf_store); | |
1660 | |
1661 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
1662 | |
1663 column = gtk_tree_view_column_new(); | |
1664 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
1665 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1666 | |
1667 renderer = gtk_cell_renderer_text_new(); | |
1668 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1669 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
1670 gtk_tree_view_column_set_spacing(column, 4); | |
1671 | |
1672 renderer = gtk_cell_renderer_text_new(); | |
1673 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1674 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
1675 gtk_tree_view_column_set_spacing(column, 4); | |
1676 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
1677 | |
1678 g_signal_connect(treeview, "row-activated", | |
1679 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
1680 | |
1681 hbox = gtk_hbox_new(FALSE, 3); | |
1682 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
1683 | |
1684 search_label = gtk_label_new(_("Filter: ")); | |
1685 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), "_Filter:"); | |
1686 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
1687 | |
1688 edit = gtk_entry_new(); | |
1689 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
1690 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
1691 g_signal_connect(edit, "changed", | |
1692 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
1693 | |
1694 g_signal_connect(mainwin_jtf, "key_press_event", | |
1695 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
1696 | |
1697 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
1698 | |
1699 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
1700 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
1701 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
1702 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1703 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
1704 GTK_SHADOW_IN); | |
1705 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
1706 | |
1707 sep = gtk_hseparator_new(); | |
1708 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
1709 | |
1710 bbox = gtk_hbutton_box_new(); | |
1711 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1712 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1713 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1714 | |
1715 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
1716 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
1717 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
1718 g_signal_connect(queue, "clicked", | |
1719 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
1720 treeview); | |
1721 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
1722 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
1723 queue); | |
1724 | |
1725 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
1726 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
1727 g_signal_connect(rescan, "clicked", | |
1728 G_CALLBACK(mainwin_update_jtf), treeview); | |
1729 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
1730 gtk_widget_grab_default(rescan); | |
1731 | |
1732 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1733 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
1734 | |
1735 g_signal_connect_swapped(jump, "clicked", | |
1736 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
1737 treeview); | |
1738 | |
1739 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1740 gtk_widget_grab_default(jump); | |
1741 | |
1742 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
1743 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
1744 g_signal_connect_swapped(cancel, "clicked", | |
1745 G_CALLBACK(gtk_widget_destroy), | |
1746 mainwin_jtf); | |
1747 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1748 | |
1749 gtk_list_store_clear(jtf_store); | |
1750 | |
1751 row = 1; | |
1752 | |
1753 PLAYLIST_LOCK(); | |
1754 | |
1755 for (playlist = playlist_get(); playlist; | |
1756 playlist = g_list_next(playlist)) { | |
1757 | |
1758 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1759 | |
1760 if (entry->title) | |
1761 desc_buf = entry->title; | |
1762 else if (strchr(entry->filename, '/')) | |
1763 desc_buf = strrchr(entry->filename, '/') + 1; | |
1764 else | |
1765 desc_buf = entry->filename; | |
1766 | |
1767 row_str = g_strdup_printf("%d", row++); | |
1768 | |
1769 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
1770 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
1771 0, row_str, 1, desc_buf, -1); | |
1772 | |
1773 g_free(row_str); | |
1774 } | |
1775 | |
1776 PLAYLIST_UNLOCK(); | |
1777 | |
1778 gtk_widget_show_all(mainwin_jtf); | |
1779 } | |
1780 | |
1781 static gboolean | |
1782 mainwin_configure(GtkWidget * window, | |
1783 GdkEventConfigure * event, | |
1784 gpointer data) | |
1785 { | |
1786 if (!GTK_WIDGET_VISIBLE(window)) | |
1787 return FALSE; | |
1788 | |
1789 if (cfg.show_wm_decorations) | |
1790 gdk_window_get_root_origin(window->window, | |
1791 &cfg.player_x, &cfg.player_y); | |
1792 else | |
1793 gdk_window_get_deskrelative_origin(window->window, | |
1794 &cfg.player_x, &cfg.player_y); | |
1795 return FALSE; | |
1796 } | |
1797 | |
1798 void | |
1799 mainwin_set_back_pixmap(void) | |
1800 { | |
1801 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
1802 gdk_window_clear(mainwin->window); | |
1803 } | |
1804 | |
1805 void | |
1806 mainwin_drag_data_received(GtkWidget * widget, | |
1807 GdkDragContext * context, | |
1808 gint x, | |
1809 gint y, | |
1810 GtkSelectionData * selection_data, | |
1811 guint info, | |
1812 guint time, | |
1813 gpointer user_data) | |
1814 { | |
289
8eab873f20a8
[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups...
nenolod
parents:
284
diff
changeset
|
1815 gchar **iter, **sourcelist, *path; |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1816 gchar *decoded; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1817 gboolean not_font = FALSE; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1818 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1819 if (!selection_data->data) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1820 { |
0 | 1821 g_warning("DND data string is NULL"); |
1822 return; | |
1823 } | |
1824 | |
289
8eab873f20a8
[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups...
nenolod
parents:
284
diff
changeset
|
1825 iter = sourcelist = g_strsplit((gchar *)(selection_data->data),"\r\n",-1); |
8eab873f20a8
[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups...
nenolod
parents:
284
diff
changeset
|
1826 |
358
70075730e187
[svn] Checking path for NULL wont work in the for() loop, so we have to check elsewhere.
nenolod
parents:
331
diff
changeset
|
1827 for (path = *sourcelist; *path; path = *(++sourcelist)) |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1828 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1829 if (str_has_prefix_nocase(path, "fonts:///")) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1830 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1831 path += 8; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1832 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1833 /* plain, since we already stripped the first URI part */ |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1834 decoded = xmms_urldecode_plain(path); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1835 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1836 /* Get the old font's size, and add it to the dropped |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1837 * font's name |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1838 */ |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1839 cfg.playlist_font = g_strconcat(decoded + 1, |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1840 strrchr(cfg.playlist_font, ' '), |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1841 NULL); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1842 playlist_list_set_font(cfg.playlist_font); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1843 playlistwin_update_list(); |
0 | 1844 |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1845 g_free(decoded); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1846 return; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1847 } |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1848 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1849 if (str_has_prefix_nocase(path,"file:///")) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1850 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1851 if (not_font == FALSE) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1852 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1853 playlist_clear(); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1854 not_font = TRUE; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1855 } |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1856 playlist_add_url(path); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1857 } |
358
70075730e187
[svn] Checking path for NULL wont work in the for() loop, so we have to check elsewhere.
nenolod
parents:
331
diff
changeset
|
1858 |
70075730e187
[svn] Checking path for NULL wont work in the for() loop, so we have to check elsewhere.
nenolod
parents:
331
diff
changeset
|
1859 if (path == NULL) /* damn konqueror */ |
70075730e187
[svn] Checking path for NULL wont work in the for() loop, so we have to check elsewhere.
nenolod
parents:
331
diff
changeset
|
1860 break; |
0 | 1861 } |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1862 |
289
8eab873f20a8
[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups...
nenolod
parents:
284
diff
changeset
|
1863 g_strfreev(iter); |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1864 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1865 if (not_font) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1866 bmp_playback_initiate(); |
0 | 1867 } |
1868 | |
1869 static void | |
1870 on_add_url_add_clicked(GtkWidget * widget, | |
1871 GtkWidget * entry) | |
1872 { | |
1873 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1874 if (text && *text) | |
1875 playlist_add_url(text); | |
1876 } | |
1877 | |
86 | 1878 static void |
1879 on_add_url_ok_clicked(GtkWidget * widget, | |
1880 GtkWidget * entry) | |
1881 { | |
1882 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1883 if (text && *text) | |
1884 { | |
1885 playlist_clear(); | |
1886 playlist_add_url(text); | |
1887 bmp_playback_initiate(); | |
1888 } | |
1889 } | |
1890 | |
0 | 1891 void |
1892 mainwin_show_add_url_window(void) | |
1893 { | |
1894 static GtkWidget *url_window = NULL; | |
1895 | |
1896 if (!url_window) { | |
1897 url_window = | |
86 | 1898 util_add_url_dialog_new(_("Enter location to play:"), |
1899 G_CALLBACK(on_add_url_ok_clicked), | |
0 | 1900 G_CALLBACK(on_add_url_add_clicked)); |
1901 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
1902 GTK_WINDOW(mainwin)); | |
1903 g_signal_connect(url_window, "destroy", | |
1904 G_CALLBACK(gtk_widget_destroyed), | |
1905 &url_window); | |
1906 } | |
1907 | |
1908 gtk_window_present(GTK_WINDOW(url_window)); | |
1909 } | |
1910 | |
1911 static void | |
1912 check_set(GtkItemFactory * factory, | |
1913 const gchar * path, | |
1914 gboolean active) | |
1915 { | |
1916 GtkWidget *item = gtk_item_factory_get_widget(factory, path); | |
1917 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active); | |
1918 } | |
1919 | |
1920 void | |
1921 mainwin_eject_pushed(void) | |
1922 { | |
1923 util_run_filebrowser(PLAY_BUTTON); | |
1924 } | |
1925 | |
1926 void | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1927 mainwin_rev_pushed(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1928 { |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1929 g_get_current_time(&cb_time); |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1930 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1931 seek_state = MAINWIN_SEEK_REV; |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1932 } |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1933 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1934 void |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1935 mainwin_rev_release(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1936 { |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1937 GTimeVal now_time; |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1938 GTimeVal delta_time; |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1939 glong now_dur; |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1940 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1941 g_get_current_time(&now_time); |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1942 |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1943 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; |
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1944 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; |
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1945 |
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1946 now_dur = (delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000); |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1947 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1948 if (now_dur <= 150 && now_dur >= -150) |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1949 playlist_prev(); |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1950 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1951 seek_state = MAINWIN_SEEK_NIL; |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1952 } |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1953 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1954 void |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1955 mainwin_fwd_pushed(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1956 { |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1957 g_get_current_time(&cb_time); |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1958 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1959 seek_state = MAINWIN_SEEK_FWD; |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1960 } |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1961 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1962 void |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1963 mainwin_fwd_release(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1964 { |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1965 GTimeVal now_time; |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1966 GTimeVal delta_time; |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1967 glong now_dur; |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1968 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1969 g_get_current_time(&now_time); |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1970 |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1971 delta_time.tv_usec = now_time.tv_usec - cb_time.tv_usec; |
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1972 delta_time.tv_sec = now_time.tv_sec - cb_time.tv_sec; |
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1973 |
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
1974 now_dur = (delta_time.tv_sec * 1000) + (glong) (delta_time.tv_usec / 1000); |
434
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1975 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1976 if (now_dur <= 150 && now_dur >= -150) |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1977 playlist_next(); |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1978 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
1979 seek_state = MAINWIN_SEEK_NIL; |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1980 } |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1981 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
1982 void |
0 | 1983 mainwin_play_pushed(void) |
1984 { | |
1985 if (bmp_playback_get_paused()) { | |
1986 bmp_playback_pause(); | |
1987 return; | |
1988 } | |
1989 | |
1990 if (playlist_get_length()) | |
1991 bmp_playback_initiate(); | |
1992 else | |
1993 mainwin_eject_pushed(); | |
1994 } | |
1995 | |
1996 void | |
1997 mainwin_stop_pushed(void) | |
1998 { | |
1999 mainwin_clear_song_info(); | |
2000 bmp_playback_stop(); | |
2001 } | |
2002 | |
2003 void | |
2004 mainwin_shuffle_pushed(gboolean toggled) | |
2005 { | |
2006 check_set(mainwin_play_menu, "/Shuffle", toggled); | |
2007 } | |
2008 | |
2009 void | |
2010 mainwin_repeat_pushed(gboolean toggled) | |
2011 { | |
2012 check_set(mainwin_play_menu, "/Repeat", toggled); | |
2013 } | |
2014 | |
2015 void | |
2016 mainwin_pl_pushed(gboolean toggled) | |
2017 { | |
2018 if (toggled) | |
2019 playlistwin_show(); | |
2020 else | |
2021 playlistwin_hide(); | |
2022 } | |
2023 | |
2024 gint | |
2025 mainwin_spos_frame_cb(gint pos) | |
2026 { | |
2027 if (mainwin_sposition) { | |
2028 if (pos < 6) | |
2029 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2030 17; | |
2031 else if (pos < 9) | |
2032 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2033 20; | |
2034 else | |
2035 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2036 23; | |
2037 } | |
2038 return 1; | |
2039 } | |
2040 | |
2041 void | |
2042 mainwin_spos_motion_cb(gint pos) | |
2043 { | |
2044 gint time; | |
2045 gchar *time_msg; | |
2046 | |
2047 pos--; | |
2048 | |
2049 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
2050 | |
2051 if (cfg.timer_mode == TIMER_REMAINING) { | |
2052 time = (playlist_get_current_length() / 1000) - time; | |
2053 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
2054 textbox_set_text(mainwin_stime_min, time_msg); | |
2055 g_free(time_msg); | |
2056 } | |
2057 else { | |
2058 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
2059 textbox_set_text(mainwin_stime_min, time_msg); | |
2060 g_free(time_msg); | |
2061 } | |
2062 | |
2063 time_msg = g_strdup_printf("%2.2d", time % 60); | |
2064 textbox_set_text(mainwin_stime_sec, time_msg); | |
2065 g_free(time_msg); | |
2066 } | |
2067 | |
2068 void | |
2069 mainwin_spos_release_cb(gint pos) | |
2070 { | |
2071 bmp_playback_seek(((playlist_get_current_length() / 1000) * | |
2072 (pos - 1)) / 12); | |
2073 } | |
2074 | |
2075 void | |
2076 mainwin_position_motion_cb(gint pos) | |
2077 { | |
2078 gint length, time; | |
2079 gchar *seek_msg; | |
2080 | |
2081 length = playlist_get_current_length() / 1000; | |
2082 time = (length * pos) / 219; | |
2083 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
2084 time / 60, time % 60, | |
2085 length / 60, length % 60, | |
2086 (length != 0) ? (time * 100) / length : 0); | |
2087 mainwin_lock_info_text(seek_msg); | |
2088 g_free(seek_msg); | |
2089 } | |
2090 | |
2091 void | |
2092 mainwin_position_release_cb(gint pos) | |
2093 { | |
2094 gint length, time; | |
2095 | |
2096 length = playlist_get_current_length() / 1000; | |
2097 time = (length * pos) / 219; | |
2098 bmp_playback_seek(time); | |
2099 mainwin_release_info_text(); | |
2100 } | |
2101 | |
2102 gint | |
2103 mainwin_volume_frame_cb(gint pos) | |
2104 { | |
2105 return (gint) rint((pos / 52.0) * 28); | |
2106 } | |
2107 | |
2108 void | |
2109 mainwin_adjust_volume_motion(gint v) | |
2110 { | |
2111 gchar *volume_msg; | |
2112 | |
2113 setting_volume = TRUE; | |
2114 | |
2115 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2116 mainwin_lock_info_text(volume_msg); | |
2117 g_free(volume_msg); | |
2118 | |
2119 if (balance < 0) | |
2120 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
2121 else if (balance > 0) | |
2122 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
2123 else | |
2124 input_set_volume(v, v); | |
2125 } | |
2126 | |
2127 void | |
2128 mainwin_adjust_volume_release(void) | |
2129 { | |
2130 mainwin_release_info_text(); | |
2131 setting_volume = FALSE; | |
2132 read_volume(VOLUME_ADJUSTED); | |
2133 } | |
2134 | |
2135 void | |
2136 mainwin_adjust_balance_motion(gint b) | |
2137 { | |
2138 gchar *balance_msg; | |
2139 gint v, pvl, pvr; | |
2140 | |
2141 setting_volume = TRUE; | |
2142 balance = b; | |
2143 input_get_volume(&pvl, &pvr); | |
2144 v = MAX(pvl, pvr); | |
2145 if (b < 0) { | |
2146 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2147 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
2148 } | |
2149 else if (b == 0) { | |
2150 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
2151 input_set_volume(v, v); | |
2152 } | |
2153 else { /* b > 0 */ | |
2154 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2155 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
2156 } | |
2157 mainwin_lock_info_text(balance_msg); | |
2158 g_free(balance_msg); | |
2159 } | |
2160 | |
2161 void | |
2162 mainwin_adjust_balance_release(void) | |
2163 { | |
2164 mainwin_release_info_text(); | |
2165 setting_volume = FALSE; | |
2166 read_volume(VOLUME_ADJUSTED); | |
2167 } | |
2168 | |
2169 void | |
2170 mainwin_set_volume_slider(gint percent) | |
2171 { | |
2172 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
2173 } | |
2174 | |
2175 void | |
2176 mainwin_set_balance_slider(gint percent) | |
2177 { | |
2178 hslider_set_position(mainwin_balance, | |
2179 (gint) rint(((percent * 12) / 100.0) + 12)); | |
2180 } | |
2181 | |
2182 void | |
2183 mainwin_volume_motion_cb(gint pos) | |
2184 { | |
2185 gint vol = (pos * 100) / 51; | |
2186 mainwin_adjust_volume_motion(vol); | |
2187 equalizerwin_set_volume_slider(vol); | |
2188 } | |
2189 | |
2190 void | |
2191 mainwin_volume_release_cb(gint pos) | |
2192 { | |
2193 mainwin_adjust_volume_release(); | |
2194 } | |
2195 | |
2196 gint | |
2197 mainwin_balance_frame_cb(gint pos) | |
2198 { | |
2199 return ((abs(pos - 12) * 28) / 13); | |
2200 } | |
2201 | |
2202 void | |
2203 mainwin_balance_motion_cb(gint pos) | |
2204 { | |
2205 gint bal = ((pos - 12) * 100) / 12; | |
2206 mainwin_adjust_balance_motion(bal); | |
2207 equalizerwin_set_balance_slider(bal); | |
2208 } | |
2209 | |
2210 void | |
2211 mainwin_balance_release_cb(gint pos) | |
2212 { | |
2213 mainwin_adjust_volume_release(); | |
2214 } | |
2215 | |
2216 void | |
2217 mainwin_set_volume_diff(gint diff) | |
2218 { | |
2219 gint vl, vr, vol; | |
2220 | |
2221 input_get_volume(&vl, &vr); | |
2222 vol = MAX(vl, vr); | |
2223 vol = CLAMP(vol + diff, 0, 100); | |
2224 | |
2225 mainwin_adjust_volume_motion(vol); | |
2226 setting_volume = FALSE; | |
2227 mainwin_set_volume_slider(vol); | |
2228 equalizerwin_set_volume_slider(vol); | |
2229 read_volume(VOLUME_SET); | |
2230 } | |
2231 | |
2232 void | |
2233 mainwin_set_balance_diff(gint diff) | |
2234 { | |
2235 gint b; | |
2236 b = CLAMP(balance + diff, -100, 100); | |
2237 mainwin_adjust_balance_motion(b); | |
2238 setting_volume = FALSE; | |
2239 mainwin_set_balance_slider(b); | |
2240 equalizerwin_set_balance_slider(b); | |
2241 read_volume(VOLUME_SET); | |
2242 } | |
2243 | |
2244 void | |
2245 mainwin_show(gboolean show) | |
2246 { | |
2247 if (show) | |
2248 mainwin_real_show(); | |
2249 else | |
2250 mainwin_real_hide(); | |
2251 } | |
2252 | |
2253 void | |
2254 mainwin_real_show(void) | |
2255 { | |
2256 cfg.player_visible = TRUE; | |
2257 | |
2258 if (cfg.player_shaded) | |
2259 vis_clear_data(active_vis); | |
2260 | |
2261 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
2262 mainwin_set_shape_mask(); | |
2263 | |
2264 if (cfg.show_wm_decorations) { | |
2265 if (!pposition_broken && cfg.player_x != -1 | |
2266 && cfg.save_window_position) | |
2267 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2268 | |
2269 gtk_widget_show(mainwin); | |
2270 | |
2271 if (pposition_broken && cfg.player_x != -1 | |
2272 && cfg.save_window_position) | |
2273 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2274 | |
2275 return; | |
2276 } | |
2277 | |
2278 gtk_widget_show_all(mainwin); | |
2279 | |
2280 if (!nullmask) | |
2281 return; | |
2282 | |
2283 g_object_unref(nullmask); | |
2284 nullmask = NULL; | |
2285 | |
2286 gdk_window_set_hints(mainwin->window, 0, 0, | |
2287 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2288 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2289 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2290 gtk_window_resize(GTK_WINDOW(mainwin), PLAYER_WIDTH, PLAYER_HEIGHT); | |
2291 | |
2292 if (cfg.player_x != -1 && cfg.player_y != -1) | |
2293 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2294 | |
2295 draw_main_window(TRUE); | |
2296 | |
2297 gtk_window_present(GTK_WINDOW(mainwin)); | |
2298 } | |
2299 | |
2300 void | |
2301 mainwin_real_hide(void) | |
2302 { | |
2303 GdkGC *gc; | |
2304 GdkColor pattern; | |
2305 | |
2306 if (cfg.player_shaded) { | |
2307 svis_clear_data(mainwin_svis); | |
2308 vis_clear_data(playlistwin_vis); | |
2309 } | |
2310 | |
2311 if (!cfg.show_wm_decorations) { | |
2312 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
2313 gc = gdk_gc_new(nullmask); | |
2314 pattern.pixel = 0; | |
2315 gdk_gc_set_foreground(gc, &pattern); | |
2316 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
2317 gdk_gc_destroy(gc); | |
2318 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
2319 | |
2320 gdk_window_set_hints(mainwin->window, 0, 0, 0, 0, 0, 0, | |
2321 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2322 gdk_window_resize(mainwin->window, 0, 0); | |
2323 } | |
2324 | |
2325 gtk_widget_hide(mainwin); | |
2326 | |
2327 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
2328 cfg.player_visible = FALSE; | |
2329 } | |
2330 | |
2331 static void | |
2332 mainwin_songname_menu_callback(gpointer data, | |
2333 guint action, | |
2334 GtkWidget * item) | |
2335 { | |
2336 GtkCheckMenuItem *check; | |
2337 | |
2338 switch (action) { | |
2339 case MAINWIN_SONGNAME_FILEINFO: | |
2340 playlist_fileinfo_current(); | |
2341 break; | |
2342 case MAINWIN_SONGNAME_JTF: | |
2343 mainwin_jump_to_file(); | |
2344 break; | |
2345 case MAINWIN_SONGNAME_JTT: | |
2346 mainwin_jump_to_time(); | |
2347 break; | |
2348 case MAINWIN_SONGNAME_SCROLL: | |
2349 check = GTK_CHECK_MENU_ITEM(item); | |
2350 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
2351 break; | |
2352 } | |
2353 } | |
2354 | |
2355 static void | |
2356 mainwin_play_menu_callback(gpointer data, | |
2357 guint action, | |
2358 GtkWidget * item) | |
2359 { | |
2360 GtkCheckMenuItem *check; | |
2361 | |
2362 switch (action) { | |
2363 case MAINWIN_OPT_SHUFFLE: | |
2364 check = GTK_CHECK_MENU_ITEM(item); | |
2365 cfg.shuffle = gtk_check_menu_item_get_active(check); | |
2366 playlist_set_shuffle(cfg.shuffle); | |
2367 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
2368 break; | |
2369 case MAINWIN_OPT_REPEAT: | |
2370 check = GTK_CHECK_MENU_ITEM(item); | |
2371 cfg.repeat = gtk_check_menu_item_get_active(check); | |
2372 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
2373 break; | |
2374 case MAINWIN_OPT_NPA: | |
2375 check = GTK_CHECK_MENU_ITEM(item); | |
2376 cfg.no_playlist_advance = gtk_check_menu_item_get_active(check); | |
2377 break; | |
2378 } | |
2379 } | |
2380 | |
2381 | |
2382 static void | |
2383 mainwin_view_menu_callback(gpointer data, | |
2384 guint action, | |
2385 GtkWidget * item) | |
2386 { | |
2387 switch (action) { | |
2388 case MAINWIN_OPT_TELAPSED: | |
2389 set_timer_mode_menu_cb(TIMER_ELAPSED); | |
2390 break; | |
2391 case MAINWIN_OPT_TREMAINING: | |
2392 set_timer_mode_menu_cb(TIMER_REMAINING); | |
2393 break; | |
2394 case MAINWIN_OPT_ALWAYS: | |
2395 mainwin_menurow->mr_always_selected = GTK_CHECK_MENU_ITEM(item)->active; | |
2396 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
2397 widget_draw(WIDGET(mainwin_menurow)); | |
2398 hint_set_always(cfg.always_on_top); | |
2399 break; | |
2400 case MAINWIN_OPT_STICKY: | |
2401 cfg.sticky = GTK_CHECK_MENU_ITEM(item)->active; | |
2402 hint_set_sticky(cfg.sticky); | |
2403 break; | |
2404 case MAINWIN_OPT_WS: | |
2405 mainwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2406 break; | |
2407 case MAINWIN_OPT_PWS: | |
2408 playlistwin_set_shade(GTK_CHECK_MENU_ITEM(item)->active); | |
2409 break; | |
2410 case MAINWIN_OPT_EQWS: | |
2411 equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2412 break; | |
2413 } | |
2414 } | |
2415 | |
2416 void | |
2417 mainwin_vis_menu_callback(gpointer data, | |
2418 guint action, | |
2419 GtkWidget * item) | |
2420 { | |
2421 switch (action) { | |
2422 case MAINWIN_VIS_ANALYZER: | |
2423 case MAINWIN_VIS_SCOPE: | |
2424 case MAINWIN_VIS_OFF: | |
2425 mainwin_vis_set_type_menu_cb(action - MAINWIN_VIS_ANALYZER); | |
2426 break; | |
2427 case MAINWIN_VIS_ANALYZER_NORMAL: | |
2428 case MAINWIN_VIS_ANALYZER_FIRE: | |
2429 case MAINWIN_VIS_ANALYZER_VLINES: | |
2430 mainwin_vis_set_analyzer_mode(action - MAINWIN_VIS_ANALYZER_NORMAL); | |
2431 break; | |
2432 case MAINWIN_VIS_ANALYZER_LINES: | |
2433 case MAINWIN_VIS_ANALYZER_BARS: | |
2434 mainwin_vis_set_analyzer_type(action - MAINWIN_VIS_ANALYZER_LINES); | |
2435 break; | |
2436 case MAINWIN_VIS_ANALYZER_PEAKS: | |
2437 cfg.analyzer_peaks = GTK_CHECK_MENU_ITEM(item)->active; | |
2438 break; | |
2439 case MAINWIN_VIS_SCOPE_DOT: | |
2440 case MAINWIN_VIS_SCOPE_LINE: | |
2441 case MAINWIN_VIS_SCOPE_SOLID: | |
2442 cfg.scope_mode = action - MAINWIN_VIS_SCOPE_DOT; | |
2443 break; | |
2444 case MAINWIN_VIS_VU_NORMAL: | |
2445 case MAINWIN_VIS_VU_SMOOTH: | |
2446 cfg.vu_mode = action - MAINWIN_VIS_VU_NORMAL; | |
2447 break; | |
2448 case MAINWIN_VIS_REFRESH_FULL: | |
2449 case MAINWIN_VIS_REFRESH_HALF: | |
2450 case MAINWIN_VIS_REFRESH_QUARTER: | |
2451 case MAINWIN_VIS_REFRESH_EIGHTH: | |
2452 mainwin_vis_set_refresh(action - MAINWIN_VIS_REFRESH_FULL); | |
2453 break; | |
2454 case MAINWIN_VIS_AFALLOFF_SLOWEST: | |
2455 case MAINWIN_VIS_AFALLOFF_SLOW: | |
2456 case MAINWIN_VIS_AFALLOFF_MEDIUM: | |
2457 case MAINWIN_VIS_AFALLOFF_FAST: | |
2458 case MAINWIN_VIS_AFALLOFF_FASTEST: | |
2459 mainwin_vis_set_afalloff(action - MAINWIN_VIS_AFALLOFF_SLOWEST); | |
2460 break; | |
2461 case MAINWIN_VIS_PFALLOFF_SLOWEST: | |
2462 case MAINWIN_VIS_PFALLOFF_SLOW: | |
2463 case MAINWIN_VIS_PFALLOFF_MEDIUM: | |
2464 case MAINWIN_VIS_PFALLOFF_FAST: | |
2465 case MAINWIN_VIS_PFALLOFF_FASTEST: | |
2466 mainwin_vis_set_pfalloff(action - MAINWIN_VIS_PFALLOFF_SLOWEST); | |
2467 break; | |
2468 } | |
2469 } | |
2470 | |
2471 void | |
2472 mainwin_general_menu_callback(gpointer data, | |
2473 guint action, | |
2474 GtkWidget * item) | |
2475 { | |
2476 switch (action) { | |
2477 case MAINWIN_GENERAL_PREFS: | |
2478 show_prefs_window(); | |
2479 break; | |
2480 case MAINWIN_GENERAL_ABOUT: | |
2481 show_about_window(); | |
2482 break; | |
2483 case MAINWIN_GENERAL_PLAYFILE: | |
2484 util_run_filebrowser(NO_PLAY_BUTTON); | |
2485 break; | |
2486 case MAINWIN_GENERAL_PLAYCD: | |
2487 play_medium(); | |
2488 break; | |
2489 case MAINWIN_GENERAL_ADDCD: | |
2490 add_medium(); | |
2491 break; | |
2492 case MAINWIN_GENERAL_PLAYLOCATION: | |
2493 mainwin_show_add_url_window(); | |
2494 break; | |
2495 case MAINWIN_GENERAL_FILEINFO: | |
2496 playlist_fileinfo_current(); | |
2497 break; | |
2498 case MAINWIN_GENERAL_FOCUSPLWIN: | |
2499 gtk_window_present(GTK_WINDOW(playlistwin)); | |
2500 break; | |
2501 case MAINWIN_GENERAL_SHOWPLWIN: | |
2502 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2503 playlistwin_show(); | |
2504 else | |
2505 playlistwin_hide(); | |
2506 break; | |
2507 case MAINWIN_GENERAL_SHOWEQWIN: | |
2508 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2509 equalizerwin_real_show(); | |
2510 else | |
2511 equalizerwin_real_hide(); | |
2512 break; | |
2513 case MAINWIN_GENERAL_PREV: | |
2514 playlist_prev(); | |
2515 break; | |
2516 case MAINWIN_GENERAL_PLAY: | |
2517 mainwin_play_pushed(); | |
2518 break; | |
2519 case MAINWIN_GENERAL_PAUSE: | |
2520 bmp_playback_pause(); | |
2521 break; | |
2522 case MAINWIN_GENERAL_STOP: | |
2523 mainwin_stop_pushed(); | |
2524 break; | |
2525 case MAINWIN_GENERAL_NEXT: | |
2526 playlist_next(); | |
2527 break; | |
2528 case MAINWIN_GENERAL_BACK5SEC: | |
2529 if (bmp_playback_get_playing() | |
2530 && playlist_get_current_length() != -1) | |
2531 bmp_playback_seek_relative(-5); | |
2532 break; | |
2533 case MAINWIN_GENERAL_FWD5SEC: | |
2534 if (bmp_playback_get_playing() | |
2535 && playlist_get_current_length() != -1) | |
2536 bmp_playback_seek_relative(5); | |
2537 break; | |
2538 case MAINWIN_GENERAL_START: | |
2539 playlist_set_position(0); | |
2540 break; | |
2541 case MAINWIN_GENERAL_JTT: | |
2542 mainwin_jump_to_time(); | |
2543 break; | |
2544 case MAINWIN_GENERAL_JTF: | |
2545 mainwin_jump_to_file(); | |
2546 break; | |
2547 case MAINWIN_GENERAL_EXIT: | |
2548 mainwin_quit_cb(); | |
2549 break; | |
2550 } | |
2551 } | |
2552 | |
2553 static void | |
2554 mainwin_mr_change(MenuRowItem i) | |
2555 { | |
2556 switch (i) { | |
2557 case MENUROW_NONE: | |
2558 mainwin_set_info_text(); | |
2559 break; | |
2560 case MENUROW_OPTIONS: | |
2561 mainwin_lock_info_text(_("OPTIONS MENU")); | |
2562 break; | |
2563 case MENUROW_ALWAYS: | |
2564 if (!hint_always_on_top_available()) { | |
2565 if (mainwin_menurow->mr_always_selected) | |
2566 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP (N/A)")); | |
2567 else | |
2568 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP (N/A)")); | |
2569 } | |
2570 else if (mainwin_menurow->mr_doublesize_selected) | |
2571 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); | |
2572 else | |
2573 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
2574 break; | |
2575 case MENUROW_FILEINFOBOX: | |
2576 mainwin_lock_info_text(_("FILE INFO BOX")); | |
2577 break; | |
2578 case MENUROW_DOUBLESIZE: | |
2579 mainwin_lock_info_text(_("** DOUBLESIZE HAS BEEN REMOVED **")); | |
2580 break; | |
2581 case MENUROW_VISUALIZATION: | |
2582 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
2583 break; | |
2584 } | |
2585 } | |
2586 | |
2587 static void | |
2588 mainwin_mr_release(MenuRowItem i) | |
2589 { | |
2590 GdkModifierType modmask; | |
2591 GtkWidget *widget; | |
2592 gint x, y; | |
2593 | |
2594 switch (i) { | |
2595 case MENUROW_OPTIONS: | |
2596 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2597 util_item_factory_popup(mainwin_view_menu, x, y, 1, | |
2598 GDK_CURRENT_TIME); | |
2599 break; | |
2600 case MENUROW_ALWAYS: | |
2601 widget = | |
2602 gtk_item_factory_get_widget(mainwin_view_menu, | |
2603 "/Always On Top"); | |
2604 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
2605 mainwin_menurow->mr_always_selected); | |
2606 break; | |
2607 case MENUROW_FILEINFOBOX: | |
2608 playlist_fileinfo_current(); | |
2609 break; | |
2610 case MENUROW_DOUBLESIZE: | |
2611 /* double size removed, do nothing */ | |
2612 break; | |
2613 case MENUROW_VISUALIZATION: | |
2614 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2615 util_item_factory_popup(mainwin_vis_menu, x, y, 1, GDK_CURRENT_TIME); | |
2616 break; | |
2617 case MENUROW_NONE: | |
2618 break; | |
2619 } | |
2620 mainwin_release_info_text(); | |
2621 } | |
2622 | |
2623 static void | |
2624 run_no_audiocd_dialog(void) | |
2625 { | |
2626 const gchar *markup = | |
2627 N_("<b><big>No playable CD found.</big></b>\n\n" | |
2628 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
2629 | |
2630 GtkWidget *dialog = | |
2631 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2632 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2633 GTK_MESSAGE_ERROR, | |
2634 GTK_BUTTONS_OK, | |
2635 _(markup)); | |
2636 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2637 gtk_widget_destroy(dialog); | |
2638 } | |
2639 | |
2640 static void | |
2641 run_no_output_device_dialog(void) | |
2642 { | |
2643 const gchar *markup = | |
2644 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
2645 "Please check that:\n" | |
2646 "1. You have the correct output plugin selected.\n" | |
2647 "2. No other programs is blocking the soundcard.\n" | |
2648 "3. Your soundcard is configured properly.\n"); | |
2649 | |
2650 GtkWidget *dialog = | |
2651 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2652 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2653 GTK_MESSAGE_ERROR, | |
2654 GTK_BUTTONS_OK, | |
2655 _(markup)); | |
2656 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2657 gtk_widget_destroy(dialog); | |
2658 } | |
2659 | |
2660 | |
2661 void | |
2662 add_medium(void) | |
2663 { | |
2664 GList *list, *node; | |
2665 gchar *filename; | |
2666 gchar *path; | |
2667 ConfigDb *db; | |
2668 | |
2669 db = bmp_cfg_db_open(); | |
2670 | |
2671 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2672 bmp_cfg_db_close(db); | |
2673 | |
2674 if (!(list = input_scan_dir(path))) { | |
2675 run_no_audiocd_dialog(); | |
2676 return; | |
2677 } | |
2678 | |
2679 for (node = list; node; node = g_list_next(node)) { | |
2680 filename = g_build_filename(path, node->data, NULL); | |
2681 playlist_add(filename); | |
2682 g_free(filename); | |
2683 g_free(node->data); | |
2684 } | |
2685 | |
2686 g_free(path); | |
2687 g_list_free(list); | |
2688 | |
2689 } | |
2690 | |
2691 void | |
2692 play_medium(void) | |
2693 { | |
2694 GList *list, *node; | |
2695 gchar *filename; | |
2696 gchar *path; | |
2697 ConfigDb *db; | |
2698 | |
2699 db = bmp_cfg_db_open(); | |
2700 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2701 bmp_cfg_db_close(db); | |
2702 | |
2703 if (!(list = input_scan_dir(path))) { | |
2704 run_no_audiocd_dialog(); | |
2705 return; | |
2706 } | |
2707 | |
2708 playlist_clear(); | |
2709 | |
2710 for (node = list; node; node = g_list_next(node)) { | |
2711 filename = g_build_filename(path, node->data, NULL); | |
2712 playlist_add(filename); | |
2713 g_free(filename); | |
2714 g_free(node->data); | |
2715 } | |
2716 | |
2717 g_free(path); | |
2718 g_list_free(list); | |
2719 | |
2720 playlist_set_position(0); | |
2721 bmp_playback_initiate(); | |
2722 } | |
2723 | |
2724 void | |
2725 read_volume(gint when) | |
2726 { | |
2727 static gint pvl = 0, pvr = 0; | |
2728 static gint times = VOLSET_DISP_TIMES; | |
2729 static gboolean changing = FALSE; | |
2730 | |
2731 gint vl, vr, b, v; | |
2732 | |
2733 input_get_volume(&vl, &vr); | |
2734 | |
2735 switch (when) { | |
2736 case VOLSET_STARTUP: | |
2737 vl = CLAMP(vl, 0, 100); | |
2738 vr = CLAMP(vr, 0, 100); | |
2739 pvl = vl; | |
2740 pvr = vr; | |
2741 v = MAX(vl, vr); | |
2742 if (vl > vr) | |
2743 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2744 else if (vl < vr) | |
2745 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2746 else | |
2747 b = 0; | |
2748 | |
2749 balance = b; | |
2750 mainwin_set_volume_slider(v); | |
2751 equalizerwin_set_volume_slider(v); | |
2752 mainwin_set_balance_slider(b); | |
2753 equalizerwin_set_balance_slider(b); | |
2754 return; | |
2755 | |
2756 case VOLSET_UPDATE: | |
2757 if (vl == -1 || vr == -1) | |
2758 return; | |
2759 | |
2760 if (setting_volume) { | |
2761 pvl = vl; | |
2762 pvr = vr; | |
2763 return; | |
2764 } | |
2765 | |
2766 if (pvr == vr && pvl == vl && changing) { | |
2767 if (times < VOLSET_DISP_TIMES) | |
2768 times++; | |
2769 else { | |
2770 mainwin_release_info_text(); | |
2771 changing = FALSE; | |
2772 } | |
2773 } | |
2774 else if (pvr != vr || pvl != vl) { | |
2775 gchar *tmp; | |
2776 | |
2777 v = MAX(vl, vr); | |
2778 if (vl > vr) | |
2779 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2780 else if (vl < vr) | |
2781 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2782 else | |
2783 b = 0; | |
2784 | |
2785 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
2786 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2787 else { | |
2788 if (vl > vr) { | |
2789 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2790 } | |
2791 else if (vr == vl) | |
2792 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
2793 else { /* (vl < vr) */ | |
2794 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2795 } | |
2796 } | |
2797 mainwin_lock_info_text(tmp); | |
2798 g_free(tmp); | |
2799 | |
2800 pvr = vr; | |
2801 pvl = vl; | |
2802 times = 0; | |
2803 changing = TRUE; | |
2804 mainwin_set_volume_slider(v); | |
2805 equalizerwin_set_volume_slider(v); | |
2806 | |
2807 /* Don't change the balance slider if the volume has been | |
2808 * set to zero. The balance can be anything, and our best | |
2809 * guess is what is was before. */ | |
2810 if (v > 0) { | |
2811 balance = b; | |
2812 mainwin_set_balance_slider(b); | |
2813 equalizerwin_set_balance_slider(b); | |
2814 } | |
2815 } | |
2816 break; | |
2817 | |
2818 case VOLUME_ADJUSTED: | |
2819 pvl = vl; | |
2820 pvr = vr; | |
2821 break; | |
2822 | |
2823 case VOLUME_SET: | |
2824 times = 0; | |
2825 changing = TRUE; | |
2826 pvl = vl; | |
2827 pvr = vr; | |
2828 break; | |
2829 } | |
2830 } | |
2831 | |
2832 | |
2833 /* TODO: HAL! */ | |
2834 gboolean | |
2835 can_play_cd(void) | |
2836 { | |
2837 GList *ilist; | |
2838 | |
2839 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
2840 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
2841 | |
2842 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
2843 PLUGIN_FILENAME("cdaudio"))) { | |
2844 return TRUE; | |
2845 } | |
2846 } | |
2847 | |
2848 return FALSE; | |
2849 } | |
2850 | |
2851 | |
2852 static void | |
2853 set_timer_mode(TimerMode mode) | |
2854 { | |
2855 if (mode == TIMER_ELAPSED) | |
2856 check_set(mainwin_view_menu, "/Time Elapsed", TRUE); | |
2857 else | |
2858 check_set(mainwin_view_menu, "/Time Remaining", TRUE); | |
2859 } | |
2860 | |
2861 static void | |
2862 set_timer_mode_menu_cb(TimerMode mode) | |
2863 { | |
2864 cfg.timer_mode = mode; | |
2865 } | |
2866 | |
2867 | |
2868 void | |
2869 mainwin_setup_menus(void) | |
2870 { | |
2871 set_timer_mode(cfg.timer_mode); | |
2872 | |
2873 /* View menu */ | |
2874 | |
2875 check_set(mainwin_view_menu, "/Always On Top", cfg.always_on_top); | |
2876 check_set(mainwin_view_menu, "/Put on All Workspaces", cfg.sticky); | |
2877 check_set(mainwin_view_menu, "/Roll up Player", cfg.player_shaded); | |
2878 check_set(mainwin_view_menu, "/Roll up Playlist Editor", cfg.playlist_shaded); | |
2879 check_set(mainwin_view_menu, "/Roll up Equalizer", cfg.equalizer_shaded); | |
2880 | |
2881 /* Songname menu */ | |
2882 | |
2883 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
2884 | |
2885 /* Playback menu */ | |
2886 | |
2887 check_set(mainwin_play_menu, "/Repeat", cfg.repeat); | |
2888 check_set(mainwin_play_menu, "/Shuffle", cfg.shuffle); | |
2889 | |
2890 /* Visualization menu */ | |
2891 | |
2892 check_set(mainwin_vis_menu, | |
2893 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + | |
2894 cfg.vis_type].path, TRUE); | |
2895 check_set(mainwin_vis_menu, | |
2896 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_MODE + | |
2897 cfg.analyzer_mode].path, TRUE); | |
2898 check_set(mainwin_vis_menu, | |
2899 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_TYPE + | |
2900 cfg.analyzer_type].path, TRUE); | |
2901 check_set(mainwin_vis_menu, | |
2902 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_PEAKS]. | |
2903 path, cfg.analyzer_peaks); | |
2904 check_set(mainwin_vis_menu, | |
2905 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_SCOPE_MODE + | |
2906 cfg.scope_mode].path, TRUE); | |
2907 check_set(mainwin_vis_menu, | |
2908 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_WSHADEVU_MODE + | |
2909 cfg.vu_mode].path, TRUE); | |
2910 check_set(mainwin_vis_menu, | |
2911 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_REFRESH_RATE + | |
2912 cfg.vis_refresh].path, TRUE); | |
2913 check_set(mainwin_vis_menu, | |
2914 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_AFALLOFF + | |
2915 cfg.analyzer_falloff].path, TRUE); | |
2916 check_set(mainwin_vis_menu, | |
2917 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_PFALLOFF + | |
2918 cfg.peaks_falloff].path, TRUE); | |
2919 } | |
2920 | |
2921 static void | |
2922 mainwin_create_widgets(void) | |
2923 { | |
2924 mainwin_menubtn = | |
2925 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
2926 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
2927 mainwin_menubtn->pb_allow_draw = FALSE; | |
2928 mainwin_minimize = | |
2929 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
2930 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
2931 mainwin_minimize->pb_allow_draw = FALSE; | |
2932 mainwin_shade = | |
2933 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
2934 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
2935 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
2936 SKIN_TITLEBAR); | |
2937 mainwin_shade->pb_allow_draw = FALSE; | |
2938 mainwin_close = | |
2939 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
2940 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
2941 mainwin_close->pb_allow_draw = FALSE; | |
2942 | |
2943 mainwin_rew = | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2944 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 88, 23, |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2945 18, 0, 0, 0, 18, mainwin_rev_pushed, mainwin_rev_release, |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2946 SKIN_CBUTTONS, SKIN_CBUTTONS); |
0 | 2947 mainwin_play = |
2948 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
2949 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
2950 mainwin_pause = | |
2951 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
2952 18, 46, 0, 46, 18, bmp_playback_pause, SKIN_CBUTTONS); | |
2953 mainwin_stop = | |
2954 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
2955 18, 69, 0, 69, 18, mainwin_stop_pushed, SKIN_CBUTTONS); | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2956 #if 0 |
0 | 2957 mainwin_fwd = |
2958 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
2959 18, 92, 0, 92, 18, playlist_next, SKIN_CBUTTONS); | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2960 #endif |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2961 mainwin_fwd = |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2962 create_pbutton_ex(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 23, |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2963 18, 92, 0, 92, 18, mainwin_fwd_pushed, mainwin_fwd_release, |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2964 SKIN_CBUTTONS, SKIN_CBUTTONS); |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2965 |
0 | 2966 mainwin_eject = |
2967 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
2968 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
2969 SKIN_CBUTTONS); | |
2970 | |
2971 mainwin_srew = | |
2972 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
2973 7, playlist_prev); | |
2974 mainwin_splay = | |
2975 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
2976 7, mainwin_play_pushed); | |
2977 mainwin_spause = | |
2978 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
2979 7, bmp_playback_pause); | |
2980 mainwin_sstop = | |
2981 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
2982 7, mainwin_stop_pushed); | |
2983 mainwin_sfwd = | |
2984 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
2985 7, playlist_next); | |
2986 mainwin_seject = | |
2987 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
2988 7, mainwin_eject_pushed); | |
2989 | |
2990 mainwin_shuffle = | |
2991 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
2992 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
2993 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
2994 | |
2995 mainwin_repeat = | |
2996 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
2997 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
2998 mainwin_repeat_pushed, SKIN_SHUFREP); | |
2999 | |
3000 mainwin_eq = | |
3001 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
3002 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
3003 SKIN_SHUFREP); | |
3004 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
3005 mainwin_pl = | |
3006 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
3007 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
3008 mainwin_pl_pushed, SKIN_SHUFREP); | |
3009 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
3010 | |
3011 mainwin_info = | |
3012 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
3013 153, 1, SKIN_TEXT); | |
3014 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
123
022d9717476f
[svn] Bring back support for winamp-style bitmap fonts. :)
nenolod
parents:
88
diff
changeset
|
3015 textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); |
0 | 3016 mainwin_rate_text = |
3017 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
3018 0, SKIN_TEXT); | |
3019 mainwin_freq_text = | |
3020 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
3021 0, SKIN_TEXT); | |
3022 | |
3023 mainwin_menurow = | |
3024 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
3025 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
3026 SKIN_TITLEBAR); | |
3027 mainwin_menurow->mr_doublesize_selected = FALSE; | |
3028 mainwin_menurow->mr_always_selected = cfg.always_on_top; | |
3029 | |
3030 mainwin_volume = | |
3031 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
3032 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
3033 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
3034 mainwin_volume_release_cb, SKIN_VOLUME); | |
3035 mainwin_balance = | |
3036 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
3037 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
3038 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
3039 mainwin_balance_release_cb, SKIN_BALANCE); | |
3040 | |
3041 mainwin_monostereo = | |
3042 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
3043 SKIN_MONOSTEREO); | |
3044 | |
3045 mainwin_playstatus = | |
3046 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
3047 | |
3048 mainwin_minus_num = | |
3049 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
3050 SKIN_NUMBERS); | |
3051 widget_hide(WIDGET(mainwin_minus_num)); | |
3052 mainwin_10min_num = | |
3053 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
3054 SKIN_NUMBERS); | |
3055 widget_hide(WIDGET(mainwin_10min_num)); | |
3056 | |
3057 mainwin_min_num = | |
3058 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
3059 SKIN_NUMBERS); | |
3060 widget_hide(WIDGET(mainwin_min_num)); | |
3061 | |
3062 mainwin_10sec_num = | |
3063 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
3064 SKIN_NUMBERS); | |
3065 widget_hide(WIDGET(mainwin_10sec_num)); | |
3066 | |
3067 mainwin_sec_num = | |
3068 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
3069 SKIN_NUMBERS); | |
3070 widget_hide(WIDGET(mainwin_sec_num)); | |
3071 | |
3072 mainwin_about = | |
3073 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
3074 25, show_about_window); | |
3075 | |
3076 mainwin_vis = | |
3077 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
3078 24, 43, 76); | |
3079 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); | |
3080 active_vis = mainwin_vis; | |
3081 | |
3082 mainwin_position = | |
3083 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
3084 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
3085 mainwin_position_motion_cb, | |
3086 mainwin_position_release_cb, SKIN_POSBAR); | |
3087 widget_hide(WIDGET(mainwin_position)); | |
3088 | |
3089 mainwin_sposition = | |
3090 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
3091 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
3092 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
3093 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
3094 widget_hide(WIDGET(mainwin_sposition)); | |
3095 | |
3096 mainwin_stime_min = | |
3097 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
3098 FALSE, SKIN_TEXT); | |
3099 mainwin_stime_sec = | |
3100 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
3101 FALSE, SKIN_TEXT); | |
3102 | |
3103 if (!cfg.player_shaded) { | |
3104 widget_hide(WIDGET(mainwin_svis)); | |
3105 widget_hide(WIDGET(mainwin_srew)); | |
3106 widget_hide(WIDGET(mainwin_splay)); | |
3107 widget_hide(WIDGET(mainwin_spause)); | |
3108 widget_hide(WIDGET(mainwin_sstop)); | |
3109 widget_hide(WIDGET(mainwin_sfwd)); | |
3110 widget_hide(WIDGET(mainwin_seject)); | |
3111 widget_hide(WIDGET(mainwin_stime_min)); | |
3112 widget_hide(WIDGET(mainwin_stime_sec)); | |
3113 } | |
3114 | |
3115 } | |
3116 | |
3117 static void | |
3118 mainwin_create_window(void) | |
3119 { | |
3120 gint width, height; | |
3121 | |
3122 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3123 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
3124 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
3125 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
3126 | |
3127 width = MAINWIN_WIDTH; | |
3128 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : MAINWIN_HEIGHT; | |
3129 | |
3130 gtk_widget_set_size_request(mainwin, width, height); | |
3131 gtk_widget_set_app_paintable(mainwin, TRUE); | |
3132 | |
3133 dock_window_list = dock_window_set_decorated(dock_window_list, | |
3134 GTK_WINDOW(mainwin), | |
3135 cfg.show_wm_decorations); | |
3136 | |
3137 if (cfg.player_x != -1 && cfg.save_window_position) | |
3138 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
3139 | |
3140 gtk_widget_add_events(mainwin, | |
3141 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
3142 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
3143 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
3144 GDK_VISIBILITY_NOTIFY_MASK); | |
3145 gtk_widget_realize(mainwin); | |
3146 | |
3147 util_set_cursor(mainwin); | |
3148 | |
3149 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
3150 g_signal_connect(mainwin, "button_press_event", | |
3151 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
3152 g_signal_connect(mainwin, "scroll_event", | |
3153 G_CALLBACK(mainwin_scrolled), NULL); | |
3154 g_signal_connect(mainwin, "button_release_event", | |
3155 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
3156 g_signal_connect(mainwin, "motion_notify_event", | |
3157 G_CALLBACK(mainwin_motion), NULL); | |
3158 g_signal_connect_after(mainwin, "focus_in_event", | |
3159 G_CALLBACK(mainwin_focus_in), NULL); | |
3160 g_signal_connect_after(mainwin, "focus_out_event", | |
3161 G_CALLBACK(mainwin_focus_out), NULL); | |
3162 g_signal_connect(mainwin, "configure_event", | |
3163 G_CALLBACK(mainwin_configure), NULL); | |
3164 g_signal_connect(mainwin, "style_set", | |
3165 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
3166 | |
3167 bmp_drag_dest_set(mainwin); | |
3168 | |
3169 g_signal_connect(mainwin, "key_press_event", | |
3170 G_CALLBACK(mainwin_keypress), NULL); | |
3171 } | |
3172 | |
3173 static void | |
3174 mainwin_create_menus(void) | |
3175 { | |
3176 mainwin_general_menu = create_menu(mainwin_general_menu_entries, | |
3177 mainwin_general_menu_entries_num, | |
3178 mainwin_accel); | |
3179 | |
3180 mainwin_play_menu = create_menu(mainwin_playback_menu_entries, | |
3181 mainwin_playback_menu_entries_num, | |
3182 mainwin_accel); | |
3183 | |
3184 mainwin_view_menu = create_menu(mainwin_view_menu_entries, | |
3185 mainwin_view_menu_entries_num, | |
3186 mainwin_accel); | |
3187 | |
3188 mainwin_songname_menu = create_menu(mainwin_songname_menu_entries, | |
3189 mainwin_songname_menu_entries_num, | |
3190 mainwin_accel); | |
3191 | |
3192 mainwin_add_menu = create_menu(mainwin_add_menu_entries, | |
3193 mainwin_add_menu_entries_num, | |
3194 mainwin_accel); | |
3195 | |
3196 mainwin_vis_menu = create_menu(mainwin_vis_menu_entries, | |
3197 mainwin_vis_menu_entries_num, | |
3198 mainwin_accel); | |
3199 | |
3200 make_submenu(mainwin_general_menu, "/View", mainwin_view_menu); | |
87 | 3201 make_submenu(mainwin_general_menu, "/Playback", mainwin_play_menu); |
3202 make_submenu(mainwin_general_menu, "/Visualization", mainwin_vis_menu); | |
0 | 3203 |
3204 gtk_window_add_accel_group(GTK_WINDOW(mainwin), mainwin_accel); | |
3205 } | |
3206 | |
3207 void | |
3208 mainwin_create(void) | |
3209 { | |
3210 mainwin_create_window(); | |
3211 | |
3212 mainwin_accel = gtk_accel_group_new(); | |
3213 mainwin_create_menus(); | |
3214 | |
3215 mainwin_gc = gdk_gc_new(mainwin->window); | |
3216 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
3217 MAINWIN_WIDTH, MAINWIN_HEIGHT, -1); | |
3218 mainwin_set_back_pixmap(); | |
3219 mainwin_create_widgets(); | |
3220 | |
3221 vis_set_window(mainwin_vis, mainwin->window); | |
3222 } | |
3223 | |
3224 void | |
3225 mainwin_attach_idle_func(void) | |
3226 { | |
3227 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
3228 mainwin_idle_func, NULL); | |
3229 } | |
3230 | |
3231 static void | |
3232 idle_func_update_song_info(gint time) | |
3233 { | |
3234 gint length, t; | |
3235 gchar stime_prefix; | |
3236 | |
3237 length = playlist_get_current_length(); | |
3238 playlistwin_set_time(time, length, cfg.timer_mode); | |
3239 input_update_vis(time); | |
3240 | |
3241 if (cfg.timer_mode == TIMER_REMAINING) { | |
3242 if (length != -1) { | |
3243 number_set_number(mainwin_minus_num, 11); | |
3244 t = length - time; | |
3245 stime_prefix = '-'; | |
3246 } | |
3247 else { | |
3248 number_set_number(mainwin_minus_num, 10); | |
3249 t = time; | |
3250 stime_prefix = ' '; | |
3251 } | |
3252 } | |
3253 else { | |
3254 number_set_number(mainwin_minus_num, 10); | |
3255 t = time; | |
3256 stime_prefix = ' '; | |
3257 } | |
3258 t /= 1000; | |
3259 | |
3260 /* Show the time in the format HH:MM when we have more than 100 | |
3261 * minutes. */ | |
3262 if (t >= 100 * 60) | |
3263 t /= 60; | |
3264 number_set_number(mainwin_10min_num, t / 600); | |
3265 number_set_number(mainwin_min_num, (t / 60) % 10); | |
3266 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
3267 number_set_number(mainwin_sec_num, t % 10); | |
3268 | |
3269 if (!mainwin_sposition->hs_pressed) { | |
3270 gchar *time_str; | |
3271 | |
3272 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
3273 textbox_set_text(mainwin_stime_min, time_str); | |
3274 g_free(time_str); | |
3275 | |
3276 time_str = g_strdup_printf("%2.2d", t % 60); | |
3277 textbox_set_text(mainwin_stime_sec, time_str); | |
3278 g_free(time_str); | |
3279 } | |
3280 | |
3281 time /= 1000; | |
3282 length /= 1000; | |
3283 if (length > 0) { | |
3284 if (time > length) { | |
3285 hslider_set_position(mainwin_position, 219); | |
3286 hslider_set_position(mainwin_sposition, 13); | |
3287 } | |
3288 else { | |
3289 hslider_set_position(mainwin_position, (time * 219) / length); | |
3290 hslider_set_position(mainwin_sposition, | |
3291 ((time * 12) / length) + 1); | |
3292 } | |
3293 } | |
3294 else { | |
3295 hslider_set_position(mainwin_position, 0); | |
3296 hslider_set_position(mainwin_sposition, 1); | |
3297 } | |
3298 } | |
3299 | |
3300 static gboolean | |
3301 mainwin_idle_func(gpointer data) | |
3302 { | |
3303 static gint count = 0; | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3304 gint time = 0; |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3305 |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3306 /* run audcore events, then run our own. --nenolod */ |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3307 switch((time = audcore_generic_events())) |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3308 { |
0 | 3309 case -2: |
3310 /* no usable output device */ | |
3311 GDK_THREADS_ENTER(); | |
3312 run_no_output_device_dialog(); | |
3313 mainwin_stop_pushed(); | |
3314 GDK_THREADS_LEAVE(); | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3315 ev_waiting = FALSE; |
0 | 3316 break; |
3317 | |
3318 default: | |
3319 idle_func_update_song_info(time); | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3320 /* nothing at this time */ |
0 | 3321 } |
3322 | |
3323 GDK_THREADS_ENTER(); | |
3324 | |
197
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3325 if (bmp_playback_get_playing()) |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3326 vis_playback_start(); |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3327 else |
ccd034857702
[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
nenolod
parents:
196
diff
changeset
|
3328 vis_playback_stop(); |
0 | 3329 |
3330 draw_main_window(mainwin_force_redraw); | |
3331 | |
3332 if (!count) { | |
3333 read_volume(VOLSET_UPDATE); | |
3334 count = 10; | |
3335 } | |
3336 else | |
3337 count--; | |
3338 | |
234 | 3339 draw_playlist_window(mainwin_force_redraw); |
3340 draw_equalizer_window(mainwin_force_redraw); | |
3341 | |
3342 /* what is this for? see below. --nenolod */ | |
233 | 3343 mainwin_force_redraw = FALSE; |
229
108cd7e58d5e
[svn] Always update the playlist information, regardless of whether it is shaded or not. To ensure this happens, I've attached playlistwin_update_list() to the GUI event loop,
nenolod
parents:
225
diff
changeset
|
3344 |
0 | 3345 if (mainwin_title_text) { |
3346 G_LOCK(mainwin_title); | |
3347 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
3348 g_free(mainwin_title_text); | |
3349 mainwin_title_text = NULL; | |
3350 G_UNLOCK(mainwin_title); | |
3351 | |
3352 mainwin_set_info_text(); | |
3353 playlistwin_update_list(); | |
234 | 3354 |
3355 /* set mainwin_force_redraw so that the windows are redrawn | |
3356 * when the title_text has changed. (new song), this should | |
3357 * enforce updates of the playlist window. --nenolod | |
3358 */ | |
3359 mainwin_force_redraw = TRUE; | |
3360 draw_playlist_window(mainwin_force_redraw); | |
0 | 3361 } |
3362 | |
3363 GDK_THREADS_LEAVE(); | |
3364 | |
435
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3365 if (seek_state == MAINWIN_SEEK_REV) |
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3366 bmp_playback_seek(CLAMP(bmp_playback_get_time() - 1000, 0, |
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3367 playlist_get_current_length()) / 1000); |
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3368 else if (seek_state == MAINWIN_SEEK_FWD) |
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3369 bmp_playback_seek(CLAMP(bmp_playback_get_time() + 1000, 0, |
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3370 playlist_get_current_length()) / 1000); |
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3371 |
0 | 3372 return TRUE; |
3373 } |