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