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