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