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