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