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