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