Mercurial > audlegacy
annotate audacious/mainwin.c @ 1035:06ca2c6283f4 trunk
[svn] - remove comment
author | nenolod |
---|---|
date | Sat, 13 May 2006 11:20:11 -0700 |
parents | 314665261dbe |
children | f866da587845 |
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, |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
900 (gfloat) frequency / 1000, |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
901 (n_channels > 1) ? _("stereo") : _("mono")); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
902 else |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
903 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
|
904 (gfloat) frequency / 1000, |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
905 (n_channels > 1) ? _("stereo") : _("mono")); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
906 |
837
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
907 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
|
908 |
975
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
909 widget_hide(WIDGET(mainwin_rate_text)); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
910 widget_hide(WIDGET(mainwin_freq_text)); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
911 widget_hide(WIDGET(mainwin_monostereo)); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
912 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
|
913 } |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
914 else |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
915 { |
975
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
916 widget_show(WIDGET(mainwin_rate_text)); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
917 widget_show(WIDGET(mainwin_freq_text)); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
918 widget_show(WIDGET(mainwin_monostereo)); |
c9915a0559f7
[svn] - Correctly display >1000 kbps bitrates when using modern skins
nhjm449
parents:
925
diff
changeset
|
919 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
|
920 } |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
921 |
0 | 922 title = playlist_get_info_text(); |
923 mainwin_set_song_title(title); | |
924 g_free(title); | |
925 } | |
926 | |
927 void | |
928 mainwin_clear_song_info(void) | |
929 { | |
196 | 930 if (!mainwin) |
931 return; | |
932 | |
0 | 933 /* clear title */ |
934 G_LOCK(mainwin_title); | |
935 g_free(mainwin_title_text); | |
936 mainwin_title_text = NULL; | |
937 G_UNLOCK(mainwin_title); | |
938 | |
939 /* clear sampling parameters */ | |
940 playback_set_sample_params(0, 0, 0); | |
941 | |
942 mainwin_position->hs_pressed = FALSE; | |
943 mainwin_sposition->hs_pressed = FALSE; | |
944 | |
945 /* clear sampling parameter displays */ | |
946 textbox_set_text(mainwin_rate_text, " "); | |
947 textbox_set_text(mainwin_freq_text, " "); | |
948 monostereo_set_num_channels(mainwin_monostereo, 0); | |
949 | |
950 playstatus_set_status(mainwin_playstatus, STATUS_STOP); | |
951 | |
952 /* hide playback time */ | |
953 widget_hide(WIDGET(mainwin_minus_num)); | |
954 widget_hide(WIDGET(mainwin_10min_num)); | |
955 widget_hide(WIDGET(mainwin_min_num)); | |
956 widget_hide(WIDGET(mainwin_10sec_num)); | |
957 widget_hide(WIDGET(mainwin_sec_num)); | |
958 | |
632
6bc44654ebba
[svn] Do not show 00:00 when stopped in shaded mode, closes bug #390.
chainsaw
parents:
625
diff
changeset
|
959 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
|
960 widget_hide(WIDGET(mainwin_stime_sec)); |
0 | 961 |
962 widget_hide(WIDGET(mainwin_position)); | |
963 widget_hide(WIDGET(mainwin_sposition)); | |
964 | |
837
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
965 widget_hide(WIDGET(mainwin_othertext)); |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
966 |
0 | 967 playlistwin_hide_timer(); |
968 draw_main_window(TRUE); | |
969 | |
970 vis_clear(active_vis); | |
971 } | |
972 | |
973 void | |
974 mainwin_disable_seekbar(void) | |
975 { | |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
976 if (!mainwin) |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
977 return; |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
123
diff
changeset
|
978 |
0 | 979 /* |
980 * We dont call draw_main_window() here so this will not | |
981 * remove them visually. It will only prevent us from sending | |
982 * any seek calls to the input plugin before the input plugin | |
983 * calls ->set_info(). | |
984 */ | |
985 widget_hide(WIDGET(mainwin_position)); | |
986 widget_hide(WIDGET(mainwin_sposition)); | |
987 } | |
988 | |
989 static gboolean | |
990 mainwin_mouse_button_release(GtkWidget * widget, | |
991 GdkEventButton * event, | |
992 gpointer callback_data) | |
993 { | |
994 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
995 | |
996 /* | |
997 * The gdk_flush() is just for making sure that the pointer really | |
998 * gets ungrabbed before calling any button callbacks | |
999 * | |
1000 */ | |
1001 | |
1002 gdk_flush(); | |
1003 | |
1004 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
1005 dock_move_release(GTK_WINDOW(mainwin)); | |
1006 } | |
1007 | |
1008 if (mainwin_menurow->mr_doublesize_selected) { | |
1009 event->x /= 2; | |
1010 event->y /= 2; | |
1011 } | |
1012 | |
1013 handle_release_cb(mainwin_wlist, widget, event); | |
1014 | |
1015 draw_main_window(FALSE); | |
1016 | |
1017 return FALSE; | |
1018 } | |
1019 | |
1020 static gboolean | |
1021 mainwin_motion(GtkWidget * widget, | |
1022 GdkEventMotion * event, | |
1023 gpointer callback_data) | |
1024 { | |
484
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1025 int x, y; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1026 GdkModifierType state; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1027 |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1028 if (event->is_hint != FALSE) |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1029 { |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1030 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
|
1031 &x, &y, &state); |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1032 |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1033 /* If 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
|
1034 * 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
|
1035 */ |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1036 event->x = x; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1037 event->y = y; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1038 event->state = state; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1039 } |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1040 else |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1041 { |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1042 x = event->x; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1043 y = event->y; |
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1044 state = event->state; |
0 | 1045 } |
1046 | |
1047 if (dock_is_moving(GTK_WINDOW(mainwin))) { | |
1048 dock_move_motion(GTK_WINDOW(mainwin), event); | |
1049 } | |
1050 else { | |
1051 handle_motion_cb(mainwin_wlist, widget, event); | |
1052 draw_main_window(FALSE); | |
1053 } | |
484
fc968772e096
[svn] Remove ALL Xlib stuff from the skinning engine and use GDK where
nenolod
parents:
471
diff
changeset
|
1054 |
0 | 1055 gdk_flush(); |
1056 | |
1057 return FALSE; | |
1058 } | |
1059 | |
1060 static gboolean | |
1061 inside_sensitive_widgets(gint x, gint y) | |
1062 { | |
1063 return (widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1064 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1065 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1066 || widget_contains(WIDGET(mainwin_close), x, y) | |
1067 || widget_contains(WIDGET(mainwin_rew), x, y) | |
1068 || widget_contains(WIDGET(mainwin_play), x, y) | |
1069 || widget_contains(WIDGET(mainwin_pause), x, y) | |
1070 || widget_contains(WIDGET(mainwin_stop), x, y) | |
1071 || widget_contains(WIDGET(mainwin_fwd), x, y) | |
1072 || widget_contains(WIDGET(mainwin_eject), x, y) | |
1073 || widget_contains(WIDGET(mainwin_shuffle), x, y) | |
1074 || widget_contains(WIDGET(mainwin_repeat), x, y) | |
1075 || widget_contains(WIDGET(mainwin_pl), x, y) | |
1076 || widget_contains(WIDGET(mainwin_eq), x, y) | |
1077 || widget_contains(WIDGET(mainwin_info), x, y) | |
1078 || widget_contains(WIDGET(mainwin_menurow), x, y) | |
1079 || widget_contains(WIDGET(mainwin_volume), x, y) | |
1080 || widget_contains(WIDGET(mainwin_balance), x, y) | |
1081 || (widget_contains(WIDGET(mainwin_position), x, y) && | |
1082 widget_is_visible(WIDGET(mainwin_position))) | |
1083 || widget_contains(WIDGET(mainwin_minus_num), x, y) | |
1084 || widget_contains(WIDGET(mainwin_10min_num), x, y) | |
1085 || widget_contains(WIDGET(mainwin_min_num), x, y) | |
1086 || widget_contains(WIDGET(mainwin_10sec_num), x, y) | |
1087 || widget_contains(WIDGET(mainwin_sec_num), x, y) | |
1088 || widget_contains(WIDGET(mainwin_vis), x, y) | |
1089 || widget_contains(WIDGET(mainwin_minimize), x, y) | |
1090 || widget_contains(WIDGET(mainwin_shade), x, y) | |
1091 || widget_contains(WIDGET(mainwin_close), x, y) | |
1092 || widget_contains(WIDGET(mainwin_menubtn), x, y) | |
1093 || widget_contains(WIDGET(mainwin_sposition), x, y) | |
1094 || widget_contains(WIDGET(mainwin_stime_min), x, y) | |
1095 || widget_contains(WIDGET(mainwin_stime_sec), x, y) | |
1096 || widget_contains(WIDGET(mainwin_srew), x, y) | |
1097 || widget_contains(WIDGET(mainwin_splay), x, y) | |
1098 || widget_contains(WIDGET(mainwin_spause), x, y) | |
1099 || widget_contains(WIDGET(mainwin_sstop), x, y) | |
1100 || widget_contains(WIDGET(mainwin_sfwd), x, y) | |
1101 || widget_contains(WIDGET(mainwin_seject), x, y) | |
1102 || widget_contains(WIDGET(mainwin_svis), x, y) | |
1103 || widget_contains(WIDGET(mainwin_about), x, y)); | |
1104 } | |
1105 | |
1106 void | |
1107 mainwin_scrolled(GtkWidget * widget, | |
1108 GdkEventScroll * event, | |
1109 gpointer callback_data) | |
1110 { | |
1111 gint d = cfg.mouse_change; | |
1112 if (event->direction == GDK_SCROLL_DOWN) | |
1113 d *= -1; | |
1114 mainwin_set_volume_diff(d); | |
1115 } | |
1116 | |
1117 | |
1118 static gboolean | |
1119 mainwin_mouse_button_press(GtkWidget * widget, | |
1120 GdkEventButton * event, | |
1121 gpointer callback_data) | |
1122 { | |
1123 | |
1124 gboolean grab = TRUE; | |
1125 | |
1126 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
1127 !inside_sensitive_widgets(event->x, event->y) && event->y < 14) { | |
1128 if (0 && hint_move_resize_available()) { | |
1129 hint_move_resize(mainwin, event->x_root, event->y_root, TRUE); | |
1130 grab = FALSE; | |
1131 } | |
1132 else { | |
1133 gtk_window_present(GTK_WINDOW(mainwin)); | |
1134 dock_move_press(dock_window_list, GTK_WINDOW(mainwin), event, | |
1135 TRUE); | |
1136 } | |
1137 } | |
1138 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1139 event->y < 14 && !inside_sensitive_widgets(event->x, event->y)) { | |
1140 mainwin_set_shade(!cfg.player_shaded); | |
1141 if (dock_is_moving(GTK_WINDOW(mainwin))) | |
1142 dock_move_release(GTK_WINDOW(mainwin)); | |
1143 } | |
1144 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && | |
1145 widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1146 playlist_fileinfo_current(); | |
1147 } | |
1148 else { | |
1149 handle_press_cb(mainwin_wlist, widget, event); | |
1150 draw_main_window(FALSE); | |
1151 } | |
1152 | |
1153 if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS && | |
1154 (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1155 widget_contains(WIDGET(mainwin_svis), event->x, event->y))) { | |
1156 | |
1157 cfg.vis_type++; | |
1158 | |
1159 if (cfg.vis_type > VIS_OFF) | |
1160 cfg.vis_type = VIS_ANALYZER; | |
1161 | |
1162 mainwin_vis_set_type(cfg.vis_type); | |
1163 } | |
1164 | |
1165 if (event->button == 3) { | |
1166 if (widget_contains(WIDGET(mainwin_info), event->x, event->y)) { | |
1167 util_item_factory_popup(mainwin_songname_menu, | |
1168 event->x_root, event->y_root, | |
1169 3, event->time); | |
1170 grab = FALSE; | |
1171 } | |
1172 else if (widget_contains(WIDGET(mainwin_vis), event->x, event->y) || | |
1173 widget_contains(WIDGET(mainwin_svis), event->x, event->y)) { | |
1174 util_item_factory_popup(mainwin_vis_menu, event->x_root, | |
1175 event->y_root, 3, event->time); | |
1176 grab = FALSE; | |
1177 } | |
1178 else if ( (event->y > 70) && (event->x < 128) ) | |
1179 { | |
1180 | |
1181 util_item_factory_popup(mainwin_play_menu, | |
1182 event->x_root, | |
1183 event->y_root, 3, event->time); | |
1184 grab = FALSE; | |
1185 } else { | |
1186 /* | |
1187 * Pop up the main menu a few pixels down. | |
1188 * This will avoid that anything is selected | |
1189 * if one right-clicks to focus the window | |
1190 * without raising it. | |
1191 * | |
1192 ***MD I think the above is stupid, people don't expect this | |
1193 * | |
1194 */ | |
1195 util_item_factory_popup(mainwin_general_menu, | |
1196 event->x_root, | |
1197 event->y_root, 3, event->time); | |
1198 grab = FALSE; | |
1199 } | |
1200 } | |
1201 if (event->button == 1) { | |
1202 if ((event->x > 35 && event->x < 100 && | |
1203 event->y > 25 && event->y < 40) || | |
1204 widget_contains(WIDGET(mainwin_stime_min), event->x, event->y) || | |
1205 widget_contains(WIDGET(mainwin_stime_sec), event->x, event->y)) { | |
1206 | |
1207 if (cfg.timer_mode == TIMER_ELAPSED) | |
1208 set_timer_mode(TIMER_REMAINING); | |
1209 else | |
1210 set_timer_mode(TIMER_ELAPSED); | |
1211 } | |
1212 | |
1213 } | |
1214 | |
1215 if (grab) | |
1216 gdk_pointer_grab(mainwin->window, FALSE, | |
1217 GDK_BUTTON_MOTION_MASK | | |
1218 GDK_BUTTON_RELEASE_MASK, | |
1219 GDK_WINDOW(GDK_NONE), NULL, GDK_CURRENT_TIME); | |
1220 | |
1221 return FALSE; | |
1222 } | |
1223 | |
1224 static gboolean | |
1225 mainwin_focus_in(GtkWidget * window, | |
1226 GdkEventFocus * event, | |
1227 gpointer data) | |
1228 { | |
1229 mainwin_menubtn->pb_allow_draw = TRUE; | |
1230 mainwin_minimize->pb_allow_draw = TRUE; | |
1231 mainwin_shade->pb_allow_draw = TRUE; | |
1232 mainwin_close->pb_allow_draw = TRUE; | |
1233 draw_main_window(TRUE); | |
1234 | |
1235 return TRUE; | |
1236 } | |
1237 | |
1238 | |
1239 static gboolean | |
1240 mainwin_focus_out(GtkWidget * widget, | |
1241 GdkEventFocus * event, | |
1242 gpointer callback_data) | |
1243 { | |
1244 mainwin_menubtn->pb_allow_draw = FALSE; | |
1245 mainwin_minimize->pb_allow_draw = FALSE; | |
1246 mainwin_shade->pb_allow_draw = FALSE; | |
1247 mainwin_close->pb_allow_draw = FALSE; | |
1248 draw_main_window(TRUE); | |
1249 | |
1250 return TRUE; | |
1251 } | |
1252 | |
1253 static gboolean | |
1254 mainwin_keypress(GtkWidget * grab_widget, | |
1255 GdkEventKey * event, | |
1256 gpointer data) | |
1257 { | |
1258 | |
1259 switch (event->keyval) { | |
1260 | |
1261 case GDK_Up: | |
1262 case GDK_KP_Up: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1263 case GDK_KP_8: |
0 | 1264 mainwin_set_volume_diff(2); |
1265 break; | |
1266 case GDK_Down: | |
1267 case GDK_KP_Down: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1268 case GDK_KP_2: |
0 | 1269 mainwin_set_volume_diff(-2); |
1270 break; | |
1271 case GDK_Left: | |
1272 case GDK_KP_Left: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1273 case GDK_KP_7: |
0 | 1274 if (playlist_get_current_length() != -1) |
1275 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
|
1276 (bmp_playback_get_time() - 1000, 0, |
0 | 1277 playlist_get_current_length()) / 1000); |
1278 break; | |
1279 case GDK_Right: | |
1280 case GDK_KP_Right: | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1281 case GDK_KP_9: |
0 | 1282 if (playlist_get_current_length() != -1) |
1283 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
|
1284 (bmp_playback_get_time() + 1000, 0, |
0 | 1285 playlist_get_current_length()) / 1000); |
1286 break; | |
225
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1287 case GDK_KP_4: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1288 playlist_prev(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1289 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1290 case GDK_KP_6: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1291 playlist_next(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1292 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1293 case GDK_KP_Insert: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1294 mainwin_jump_to_file(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1295 break; |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1296 case GDK_KP_5: |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1297 mainwin_play_pushed(); |
bfee3129143e
[svn] Add Winamp-style numeric keypad shortcut key support.
nenolod
parents:
197
diff
changeset
|
1298 break; |
0 | 1299 case GDK_Escape: |
1300 mainwin_minimize_cb(); | |
1301 break; | |
1302 default: | |
1303 return FALSE; | |
1304 } | |
1305 | |
1306 return TRUE; | |
1307 } | |
1308 | |
1309 static void | |
1310 mainwin_jump_to_time_cb(GtkWidget * widget, | |
1311 GtkWidget * entry) | |
1312 { | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
1313 guint min = 0, sec = 0, params; |
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
561
diff
changeset
|
1314 gint time; |
0 | 1315 |
1316 params = sscanf(gtk_entry_get_text(GTK_ENTRY(entry)), "%u:%u", | |
1317 &min, &sec); | |
1318 if (params == 2) | |
1319 time = (min * 60) + sec; | |
1320 else if (params == 1) | |
1321 time = min; | |
1322 else | |
1323 return; | |
1324 | |
1325 if (playlist_get_current_length() > -1 && | |
1326 time <= (playlist_get_current_length() / 1000)) { | |
1327 bmp_playback_seek(time); | |
1328 gtk_widget_destroy(mainwin_jtt); | |
1329 } | |
1330 } | |
1331 | |
1332 | |
1333 void | |
1334 mainwin_jump_to_time(void) | |
1335 { | |
1336 GtkWidget *vbox, *hbox_new, *hbox_total; | |
1337 GtkWidget *time_entry, *label, *bbox, *jump, *cancel; | |
1338 guint tindex; | |
1339 gchar time_str[10]; | |
1340 | |
1341 if (!bmp_playback_get_playing()) { | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
654
diff
changeset
|
1342 report_error("JIT can't be launched when no track is being played.\n"); |
0 | 1343 return; |
1344 } | |
1345 | |
1346 if (mainwin_jtt) { | |
1347 gtk_window_present(GTK_WINDOW(mainwin_jtt)); | |
1348 return; | |
1349 } | |
1350 | |
1351 mainwin_jtt = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1352 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtt), | |
1353 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1354 | |
1355 gtk_window_set_title(GTK_WINDOW(mainwin_jtt), _("Jump to Time")); | |
1356 gtk_window_set_position(GTK_WINDOW(mainwin_jtt), GTK_WIN_POS_CENTER); | |
1357 gtk_window_set_transient_for(GTK_WINDOW(mainwin_jtt), | |
1358 GTK_WINDOW(mainwin)); | |
1359 | |
1360 g_signal_connect(mainwin_jtt, "destroy", | |
1361 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtt); | |
1362 gtk_container_border_width(GTK_CONTAINER(mainwin_jtt), 10); | |
1363 | |
1364 vbox = gtk_vbox_new(FALSE, 5); | |
1365 gtk_container_add(GTK_CONTAINER(mainwin_jtt), vbox); | |
1366 | |
1367 hbox_new = gtk_hbox_new(FALSE, 0); | |
1368 gtk_box_pack_start(GTK_BOX(vbox), hbox_new, TRUE, TRUE, 5); | |
1369 | |
1370 time_entry = gtk_entry_new(); | |
1371 gtk_box_pack_start(GTK_BOX(hbox_new), time_entry, FALSE, FALSE, 5); | |
1372 g_signal_connect(time_entry, "activate", | |
1373 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1374 | |
1375 gtk_widget_set_size_request(time_entry, 70, -1); | |
1376 label = gtk_label_new(_("minutes:seconds")); | |
1377 gtk_box_pack_start(GTK_BOX(hbox_new), label, FALSE, FALSE, 5); | |
1378 | |
1379 hbox_total = gtk_hbox_new(FALSE, 0); | |
1380 gtk_box_pack_start(GTK_BOX(vbox), hbox_total, TRUE, TRUE, 5); | |
1381 gtk_widget_show(hbox_total); | |
1382 | |
1383 /* FIXME: Disable display of current track length. It's not | |
1384 updated when track changes */ | |
1385 #if 0 | |
1386 label = gtk_label_new(_("Track length:")); | |
1387 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 5); | |
1388 | |
1389 len = playlist_get_current_length() / 1000; | |
1390 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", len / 60, len % 60); | |
1391 label = gtk_label_new(time_str); | |
1392 | |
1393 gtk_box_pack_start(GTK_BOX(hbox_total), label, FALSE, FALSE, 10); | |
1394 #endif | |
1395 | |
1396 bbox = gtk_hbutton_box_new(); | |
1397 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 0); | |
1398 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1399 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1400 | |
1401 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1402 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1403 gtk_container_add(GTK_CONTAINER(bbox), cancel); | |
1404 g_signal_connect_swapped(cancel, "clicked", | |
1405 G_CALLBACK(gtk_widget_destroy), mainwin_jtt); | |
1406 | |
1407 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1408 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1409 gtk_container_add(GTK_CONTAINER(bbox), jump); | |
1410 g_signal_connect(jump, "clicked", | |
1411 G_CALLBACK(mainwin_jump_to_time_cb), time_entry); | |
1412 | |
1413 tindex = bmp_playback_get_time() / 1000; | |
1414 g_snprintf(time_str, sizeof(time_str), "%u:%2.2u", tindex / 60, | |
1415 tindex % 60); | |
1416 gtk_entry_set_text(GTK_ENTRY(time_entry), time_str); | |
1417 | |
1418 gtk_entry_select_region(GTK_ENTRY(time_entry), 0, strlen(time_str)); | |
1419 | |
1420 gtk_widget_show_all(mainwin_jtt); | |
1421 | |
1422 gtk_widget_grab_focus(time_entry); | |
1423 gtk_widget_grab_default(jump); | |
1424 } | |
1425 | |
1426 static void | |
1427 change_song(guint pos) | |
1428 { | |
1429 if (bmp_playback_get_playing()) | |
1430 bmp_playback_stop(); | |
1431 | |
1432 playlist_set_position(pos); | |
1433 bmp_playback_initiate(); | |
1434 } | |
1435 | |
1436 static void | |
1437 mainwin_jump_to_file_jump(GtkTreeView * treeview) | |
1438 { | |
1439 GtkTreeModel *model; | |
1440 GtkTreeSelection *selection; | |
1441 GtkTreeIter iter; | |
1442 gchar *pos_str; | |
1443 guint pos; | |
1444 | |
1445 model = gtk_tree_view_get_model(treeview); | |
1446 selection = gtk_tree_view_get_selection(treeview); | |
1447 | |
1448 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1449 return; | |
1450 | |
1451 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1452 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
|
1453 g_free(pos_str); |
0 | 1454 |
1455 change_song(pos); | |
1456 | |
1457 /* FIXME: should only hide window */ | |
1458 gtk_widget_destroy(mainwin_jtf); | |
1459 mainwin_jtf = NULL; | |
1460 } | |
1461 | |
1462 static void | |
1463 mainwin_jump_to_file_jump_cb(GtkTreeView * treeview, | |
1464 gpointer data) | |
1465 { | |
1466 mainwin_jump_to_file_jump(treeview); | |
1467 } | |
1468 | |
1469 static void | |
1470 mainwin_jump_to_file_set_queue_button_label(GtkButton * button, | |
1471 guint pos) | |
1472 { | |
1473 if (playlist_is_position_queued(pos)) | |
1474 gtk_button_set_label(button, _("Un_queue")); | |
1475 else | |
1476 gtk_button_set_label(button, _("_Queue")); | |
1477 } | |
1478 | |
1479 static void | |
1480 mainwin_jump_to_file_queue_cb(GtkButton * button, | |
1481 gpointer data) | |
1482 { | |
1483 GtkTreeView *treeview; | |
1484 GtkTreeModel *model; | |
1485 GtkTreeSelection *selection; | |
1486 GtkTreeIter iter; | |
1487 gchar *pos_str; | |
1488 guint pos; | |
1489 | |
1490 treeview = GTK_TREE_VIEW(data); | |
1491 model = gtk_tree_view_get_model(treeview); | |
1492 selection = gtk_tree_view_get_selection(treeview); | |
1493 | |
1494 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1495 return; | |
1496 | |
1497 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1498 pos = g_ascii_strtoull(pos_str, NULL, 10) - 1; | |
1499 | |
1500 playlist_queue_position(pos); | |
1501 | |
1502 mainwin_jump_to_file_set_queue_button_label(button, pos); | |
1503 } | |
1504 | |
1505 static void | |
1506 mainwin_jump_to_file_selection_changed_cb(GtkTreeSelection *treesel, | |
1507 gpointer data) | |
1508 { | |
1509 GtkTreeView *treeview; | |
1510 GtkTreeModel *model; | |
1511 GtkTreeSelection *selection; | |
1512 GtkTreeIter iter; | |
1513 gchar *pos_str; | |
1514 guint pos; | |
1515 | |
1516 treeview = gtk_tree_selection_get_tree_view(treesel); | |
1517 model = gtk_tree_view_get_model(treeview); | |
1518 selection = gtk_tree_view_get_selection(treeview); | |
1519 | |
1520 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) | |
1521 return; | |
1522 | |
1523 gtk_tree_model_get(model, &iter, 0, &pos_str, -1); | |
1524 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
|
1525 g_free(pos_str); |
0 | 1526 |
1527 mainwin_jump_to_file_set_queue_button_label(GTK_BUTTON(data), pos); | |
1528 } | |
1529 | |
1530 static gboolean | |
1531 mainwin_jump_to_file_keypress_cb(GtkWidget * object, | |
1532 GdkEventKey * event, | |
1533 gpointer data) | |
1534 { | |
1535 switch (event->keyval) { | |
1536 case GDK_Escape: | |
1537 /* FIXME: show only hide window */ | |
1538 gtk_widget_destroy(mainwin_jtf); | |
1539 mainwin_jtf = NULL; | |
1540 return TRUE; | |
1541 case GDK_Return: | |
1542 mainwin_jump_to_file_jump(GTK_TREE_VIEW(data)); | |
1543 return TRUE; | |
1544 default: | |
1545 return FALSE; | |
1546 }; | |
1547 } | |
1548 | |
1549 static gboolean | |
1550 mainwin_jump_to_file_match(const gchar * song, gchar ** keys) | |
1551 { | |
1552 gint i = 0; | |
1553 gchar *key; | |
1554 gchar *song_lc; | |
1555 | |
1556 song_lc = g_ascii_strdown(song, -1); | |
1557 | |
1558 while (keys[i]) { | |
1559 key = g_ascii_strdown(keys[i], -1); | |
1560 if (!g_strrstr(song_lc, key)) { | |
1561 g_free(key); | |
1562 g_free(song_lc); | |
1563 return FALSE; | |
1564 } | |
1565 | |
1566 g_free(key); | |
1567 i++; | |
1568 } | |
1569 | |
1570 g_free(song_lc); | |
1571 | |
1572 return TRUE; | |
1573 } | |
1574 | |
1575 /* FIXME: Clear the entry when the list gets updated */ | |
1576 static void | |
1577 mainwin_update_jtf(GtkWidget * widget, gpointer user_data) | |
1578 { | |
1579 /* FIXME: Is not in sync with playlist due to delayed extinfo | |
1580 * reading */ | |
1581 gint row; | |
1582 GList *playlist; | |
1583 gchar *desc_buf; | |
1584 gchar *row_str; | |
1585 GtkTreeIter iter; | |
1586 GtkTreeSelection *selection; | |
1587 | |
1588 GtkTreeModel *store; | |
1589 | |
1590 if (!mainwin_jtf) | |
1591 return; | |
1592 | |
1593 store = gtk_tree_view_get_model(GTK_TREE_VIEW(user_data)); | |
1594 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1595 | |
1596 row = 1; | |
1597 for (playlist = playlist_get(); playlist; | |
1598 playlist = g_list_next(playlist)) { | |
1599 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1600 | |
1601 if (entry->title) | |
1602 desc_buf = entry->title; | |
1603 else if (strchr(entry->filename, '/')) | |
1604 desc_buf = strrchr(entry->filename, '/') + 1; | |
1605 else | |
1606 desc_buf = entry->filename; | |
1607 | |
1608 row_str = g_strdup_printf("%d", row++); | |
1609 | |
1610 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
1611 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
1612 0, row_str, 1, desc_buf, -1); | |
1613 | |
1614 g_free(row_str); | |
1615 } | |
1616 | |
1617 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); | |
1618 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data)); | |
1619 gtk_tree_selection_select_iter(selection, &iter); | |
1620 } | |
1621 | |
1622 static void | |
1623 mainwin_jump_to_file_edit_cb(GtkEntry * entry, gpointer user_data) | |
1624 { | |
1625 GtkTreeView *treeview = GTK_TREE_VIEW(user_data); | |
1626 GtkTreeSelection *selection; | |
1627 GtkTreeIter iter; | |
1628 | |
1629 GtkListStore *store; | |
1630 | |
1631 gint song_index = 0; | |
1632 gchar **words; | |
1633 GList *playlist; | |
1634 | |
1635 gboolean match = FALSE; | |
1636 | |
1637 /* Chop the key string into ' '-separated key words */ | |
1638 words = g_strsplit(gtk_entry_get_text(entry), " ", 0); | |
1639 | |
1640 /* FIXME: Remove the connected signals before clearing | |
1641 * (row-selected will still eventually arrive once) */ | |
1642 store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); | |
1643 gtk_list_store_clear(store); | |
1644 | |
1645 PLAYLIST_LOCK(); | |
1646 | |
1647 for (playlist = playlist_get(); playlist; | |
1648 playlist = g_list_next(playlist)) { | |
1649 | |
1650 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1651 const gchar *title, *filename; | |
1652 | |
1653 title = entry->title; | |
1654 if (!title) { | |
1655 filename = entry->filename; | |
1656 | |
1657 if (strchr(filename, '/')) | |
1658 title = strrchr(filename, '/') + 1; | |
1659 else | |
1660 title = filename; | |
1661 } | |
1662 | |
1663 /* Compare the key words to the string - if all the words | |
1664 match, add to the ListStore */ | |
1665 | |
1666 /* | |
1667 * FIXME: The search string should be adapted to the | |
1668 * current display setting, e.g. if the user has set it to | |
1669 * "%p - %t" then build the match string like that too, or | |
1670 * even better, search for each of the tags seperatly. | |
1671 * | |
1672 * In any case the string to match should _never_ contain | |
1673 * something the user can't actually see in the playlist. | |
1674 */ | |
1675 if (words[0]) | |
1676 match = mainwin_jump_to_file_match(title, words); | |
1677 else | |
1678 match = TRUE; | |
1679 | |
1680 if (match) { | |
1681 gchar *song_index_str = g_strdup_printf("%d", song_index + 1); | |
1682 gtk_list_store_append(store, &iter); | |
1683 gtk_list_store_set(store, &iter, 0, song_index_str, 1, title, -1); | |
1684 g_free(song_index_str); | |
1685 } | |
1686 | |
1687 song_index++; | |
1688 } | |
1689 | |
1690 PLAYLIST_UNLOCK(); | |
1691 | |
1692 g_strfreev(words); | |
1693 | |
1694 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) { | |
1695 selection = gtk_tree_view_get_selection(treeview); | |
1696 gtk_tree_selection_select_iter(selection, &iter); | |
1697 } | |
1698 } | |
1699 | |
1700 void | |
1701 mainwin_jump_to_file(void) | |
1702 { | |
1703 GtkWidget *scrollwin; | |
1704 GtkWidget *vbox, *bbox, *sep; | |
1705 GtkWidget *jump, *queue, *cancel; | |
1706 GtkWidget *rescan, *edit; | |
1707 GtkWidget *search_label, *hbox; | |
1708 GList *playlist; | |
1709 gchar *desc_buf; | |
1710 gchar *row_str; | |
1711 gint row; | |
1712 | |
1713 GtkWidget *treeview; | |
1714 GtkListStore *jtf_store; | |
1715 | |
1716 GtkTreeIter iter; | |
1717 GtkCellRenderer *renderer; | |
1718 GtkTreeViewColumn *column; | |
1719 | |
1720 if (mainwin_jtf) { | |
1721 gtk_window_present(GTK_WINDOW(mainwin_jtf)); | |
1722 return; | |
1723 } | |
1724 | |
1725 mainwin_jtf = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1726 gtk_window_set_type_hint(GTK_WINDOW(mainwin_jtf), | |
1727 GDK_WINDOW_TYPE_HINT_DIALOG); | |
1728 | |
1729 gtk_window_set_title(GTK_WINDOW(mainwin_jtf), _("Jump to Track")); | |
1730 | |
1731 gtk_window_set_position(GTK_WINDOW(mainwin_jtf), GTK_WIN_POS_CENTER); | |
1732 g_signal_connect(mainwin_jtf, "destroy", | |
1733 G_CALLBACK(gtk_widget_destroyed), &mainwin_jtf); | |
1734 | |
1735 gtk_container_border_width(GTK_CONTAINER(mainwin_jtf), 10); | |
1736 gtk_window_set_default_size(GTK_WINDOW(mainwin_jtf), 550, 350); | |
1737 | |
1738 vbox = gtk_vbox_new(FALSE, 5); | |
1739 gtk_container_add(GTK_CONTAINER(mainwin_jtf), vbox); | |
1740 | |
1741 jtf_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
1742 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(jtf_store)); | |
1743 g_object_unref(jtf_store); | |
1744 | |
1745 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
1746 | |
1747 column = gtk_tree_view_column_new(); | |
1748 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
1749 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1750 | |
1751 renderer = gtk_cell_renderer_text_new(); | |
1752 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1753 gtk_tree_view_column_set_attributes(column, renderer, "text", 0, NULL); | |
1754 gtk_tree_view_column_set_spacing(column, 4); | |
1755 | |
1756 renderer = gtk_cell_renderer_text_new(); | |
1757 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1758 gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL); | |
1759 gtk_tree_view_column_set_spacing(column, 4); | |
1760 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
1761 | |
1027
314665261dbe
[svn] - If GTK is going to show its own search box for the JTF treeview, at least make it search the correct column
nhjm449
parents:
975
diff
changeset
|
1762 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), 1); |
314665261dbe
[svn] - If GTK is going to show its own search box for the JTF treeview, at least make it search the correct column
nhjm449
parents:
975
diff
changeset
|
1763 |
0 | 1764 g_signal_connect(treeview, "row-activated", |
1765 G_CALLBACK(mainwin_jump_to_file_jump), NULL); | |
1766 | |
1767 hbox = gtk_hbox_new(FALSE, 3); | |
1768 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3); | |
1769 | |
1770 search_label = gtk_label_new(_("Filter: ")); | |
1771 gtk_label_set_markup_with_mnemonic(GTK_LABEL(search_label), "_Filter:"); | |
1772 gtk_box_pack_start(GTK_BOX(hbox), search_label, FALSE, FALSE, 0); | |
1773 | |
1774 edit = gtk_entry_new(); | |
1775 gtk_entry_set_editable(GTK_ENTRY(edit), TRUE); | |
1776 gtk_label_set_mnemonic_widget(GTK_LABEL(search_label), edit); | |
1777 g_signal_connect(edit, "changed", | |
1778 G_CALLBACK(mainwin_jump_to_file_edit_cb), treeview); | |
1779 | |
1780 g_signal_connect(mainwin_jtf, "key_press_event", | |
1781 G_CALLBACK(mainwin_jump_to_file_keypress_cb), treeview); | |
1782 | |
1783 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 3); | |
1784 | |
1785 scrollwin = gtk_scrolled_window_new(NULL, NULL); | |
1786 gtk_container_add(GTK_CONTAINER(scrollwin), treeview); | |
1787 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), | |
1788 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1789 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin), | |
1790 GTK_SHADOW_IN); | |
1791 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); | |
1792 | |
1793 sep = gtk_hseparator_new(); | |
1794 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
1795 | |
1796 bbox = gtk_hbutton_box_new(); | |
1797 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1798 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1799 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1800 | |
1801 queue = gtk_button_new_with_mnemonic(_("_Queue")); | |
1802 gtk_box_pack_start(GTK_BOX(bbox), queue, FALSE, FALSE, 0); | |
1803 GTK_WIDGET_SET_FLAGS(queue, GTK_CAN_DEFAULT); | |
1804 g_signal_connect(queue, "clicked", | |
1805 G_CALLBACK(mainwin_jump_to_file_queue_cb), | |
1806 treeview); | |
1807 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), "changed", | |
1808 G_CALLBACK(mainwin_jump_to_file_selection_changed_cb), | |
1809 queue); | |
1810 | |
1811 rescan = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | |
1812 gtk_box_pack_start(GTK_BOX(bbox), rescan, FALSE, FALSE, 0); | |
1813 g_signal_connect(rescan, "clicked", | |
1814 G_CALLBACK(mainwin_update_jtf), treeview); | |
1815 GTK_WIDGET_SET_FLAGS(rescan, GTK_CAN_DEFAULT); | |
1816 gtk_widget_grab_default(rescan); | |
1817 | |
1818 jump = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO); | |
1819 gtk_box_pack_start(GTK_BOX(bbox), jump, FALSE, FALSE, 0); | |
1820 | |
1821 g_signal_connect_swapped(jump, "clicked", | |
1822 G_CALLBACK(mainwin_jump_to_file_jump_cb), | |
1823 treeview); | |
1824 | |
1825 GTK_WIDGET_SET_FLAGS(jump, GTK_CAN_DEFAULT); | |
1826 gtk_widget_grab_default(jump); | |
1827 | |
1828 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
1829 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); | |
1830 g_signal_connect_swapped(cancel, "clicked", | |
1831 G_CALLBACK(gtk_widget_destroy), | |
1832 mainwin_jtf); | |
1833 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
1834 | |
1835 gtk_list_store_clear(jtf_store); | |
1836 | |
1837 row = 1; | |
1838 | |
1839 PLAYLIST_LOCK(); | |
1840 | |
1841 for (playlist = playlist_get(); playlist; | |
1842 playlist = g_list_next(playlist)) { | |
1843 | |
1844 PlaylistEntry *entry = PLAYLIST_ENTRY(playlist->data); | |
1845 | |
1846 if (entry->title) | |
1847 desc_buf = entry->title; | |
1848 else if (strchr(entry->filename, '/')) | |
1849 desc_buf = strrchr(entry->filename, '/') + 1; | |
1850 else | |
1851 desc_buf = entry->filename; | |
1852 | |
1853 row_str = g_strdup_printf("%d", row++); | |
1854 | |
1855 gtk_list_store_append(GTK_LIST_STORE(jtf_store), &iter); | |
1856 gtk_list_store_set(GTK_LIST_STORE(jtf_store), &iter, | |
1857 0, row_str, 1, desc_buf, -1); | |
1858 | |
1859 g_free(row_str); | |
1860 } | |
1861 | |
1862 PLAYLIST_UNLOCK(); | |
1863 | |
1864 gtk_widget_show_all(mainwin_jtf); | |
1865 } | |
1866 | |
1867 static gboolean | |
1868 mainwin_configure(GtkWidget * window, | |
1869 GdkEventConfigure * event, | |
1870 gpointer data) | |
1871 { | |
1872 if (!GTK_WIDGET_VISIBLE(window)) | |
1873 return FALSE; | |
1874 | |
1875 if (cfg.show_wm_decorations) | |
1876 gdk_window_get_root_origin(window->window, | |
1877 &cfg.player_x, &cfg.player_y); | |
1878 else | |
1879 gdk_window_get_deskrelative_origin(window->window, | |
1880 &cfg.player_x, &cfg.player_y); | |
1881 return FALSE; | |
1882 } | |
1883 | |
1884 void | |
1885 mainwin_set_back_pixmap(void) | |
1886 { | |
1887 gdk_window_set_back_pixmap(mainwin->window, mainwin_bg, 0); | |
1888 gdk_window_clear(mainwin->window); | |
1889 } | |
1890 | |
1891 void | |
1892 mainwin_drag_data_received(GtkWidget * widget, | |
1893 GdkDragContext * context, | |
1894 gint x, | |
1895 gint y, | |
1896 GtkSelectionData * selection_data, | |
1897 guint info, | |
1898 guint time, | |
1899 gpointer user_data) | |
1900 { | |
289
8eab873f20a8
[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups...
nenolod
parents:
284
diff
changeset
|
1901 gchar **iter, **sourcelist, *path; |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1902 gchar *decoded; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1903 gboolean not_font = FALSE; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1904 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1905 if (!selection_data->data) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1906 { |
0 | 1907 g_warning("DND data string is NULL"); |
1908 return; | |
1909 } | |
1910 | |
925
25963e82c40f
[svn] - konqueror hack was breaking standards here, fix a crash
nenolod
parents:
898
diff
changeset
|
1911 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
|
1912 |
358
70075730e187
[svn] Checking path for NULL wont work in the for() loop, so we have to check elsewhere.
nenolod
parents:
331
diff
changeset
|
1913 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
|
1914 { |
925
25963e82c40f
[svn] - konqueror hack was breaking standards here, fix a crash
nenolod
parents:
898
diff
changeset
|
1915 if (path == NULL) /* damn konqueror */ |
25963e82c40f
[svn] - konqueror hack was breaking standards here, fix a crash
nenolod
parents:
898
diff
changeset
|
1916 break; |
25963e82c40f
[svn] - konqueror hack was breaking standards here, fix a crash
nenolod
parents:
898
diff
changeset
|
1917 |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1918 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
|
1919 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1920 path += 8; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1921 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1922 /* 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
|
1923 decoded = xmms_urldecode_plain(path); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1924 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1925 /* 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
|
1926 * font's name |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1927 */ |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1928 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
|
1929 strrchr(cfg.playlist_font, ' '), |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1930 NULL); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1931 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
|
1932 playlistwin_update_list(); |
0 | 1933 |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1934 g_free(decoded); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1935 return; |
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 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1938 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
|
1939 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1940 if (not_font == FALSE) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1941 { |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1942 playlist_clear(); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1943 not_font = TRUE; |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1944 } |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1945 playlist_add_url(path); |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1946 } |
0 | 1947 } |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1948 |
289
8eab873f20a8
[svn] possible DND fix for konqueror. (cleaned up version of fixed version of my cleanups...
nenolod
parents:
284
diff
changeset
|
1949 g_strfreev(iter); |
274
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1950 |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1951 if (not_font) |
f6edd411a320
[svn] Merge a cleaned up version of the patch included with #383. Audacious
nenolod
parents:
234
diff
changeset
|
1952 bmp_playback_initiate(); |
0 | 1953 } |
1954 | |
1955 static void | |
1956 on_add_url_add_clicked(GtkWidget * widget, | |
1957 GtkWidget * entry) | |
1958 { | |
1959 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1960 if (text && *text) | |
1961 playlist_add_url(text); | |
1962 } | |
1963 | |
86 | 1964 static void |
1965 on_add_url_ok_clicked(GtkWidget * widget, | |
1966 GtkWidget * entry) | |
1967 { | |
1968 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1969 if (text && *text) | |
1970 { | |
1971 playlist_clear(); | |
1972 playlist_add_url(text); | |
1973 bmp_playback_initiate(); | |
1974 } | |
1975 } | |
1976 | |
0 | 1977 void |
1978 mainwin_show_add_url_window(void) | |
1979 { | |
1980 static GtkWidget *url_window = NULL; | |
1981 | |
1982 if (!url_window) { | |
1983 url_window = | |
86 | 1984 util_add_url_dialog_new(_("Enter location to play:"), |
1985 G_CALLBACK(on_add_url_ok_clicked), | |
0 | 1986 G_CALLBACK(on_add_url_add_clicked)); |
1987 gtk_window_set_transient_for(GTK_WINDOW(url_window), | |
1988 GTK_WINDOW(mainwin)); | |
1989 g_signal_connect(url_window, "destroy", | |
1990 G_CALLBACK(gtk_widget_destroyed), | |
1991 &url_window); | |
1992 } | |
1993 | |
1994 gtk_window_present(GTK_WINDOW(url_window)); | |
1995 } | |
1996 | |
1997 static void | |
1998 check_set(GtkItemFactory * factory, | |
1999 const gchar * path, | |
2000 gboolean active) | |
2001 { | |
2002 GtkWidget *item = gtk_item_factory_get_widget(factory, path); | |
2003 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active); | |
2004 } | |
2005 | |
2006 void | |
2007 mainwin_eject_pushed(void) | |
2008 { | |
2009 util_run_filebrowser(PLAY_BUTTON); | |
2010 } | |
2011 | |
2012 void | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2013 mainwin_rev_pushed(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2014 { |
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
|
2015 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
|
2016 |
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
|
2017 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
|
2018 seek_state = MAINWIN_SEEK_REV; |
433
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 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2021 void |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2022 mainwin_rev_release(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2023 { |
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
|
2024 GTimeVal now_time; |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
2025 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
|
2026 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
|
2027 |
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 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
|
2029 |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
2030 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
|
2031 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
|
2032 |
468 | 2033 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
|
2034 |
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 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
|
2036 { |
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 /* 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
|
2038 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
|
2039 } |
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 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
|
2041 { |
bd423985b2cf
[svn] seek with tristate prev/next buttons now works just like the seek bar (no seek until the button is released, no seek at all if it should move to the prev/next song)
giacomo
parents:
465
diff
changeset
|
2042 /* interpret as '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
|
2043 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
|
2044 } |
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
|
2045 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
2046 seek_state = MAINWIN_SEEK_NIL; |
433
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 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2049 void |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2050 mainwin_fwd_pushed(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2051 { |
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
|
2052 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
|
2053 |
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
|
2054 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
|
2055 seek_state = MAINWIN_SEEK_FWD; |
433
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 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2058 void |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2059 mainwin_fwd_release(void) |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2060 { |
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
|
2061 GTimeVal now_time; |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
2062 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
|
2063 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
|
2064 |
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 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
|
2066 |
438
d6051a60aae2
[svn] Smarter algorithm for detecting differentials between button presses, now takes seconds into account.
nenolod
parents:
437
diff
changeset
|
2067 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
|
2068 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
|
2069 |
468 | 2070 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
|
2071 |
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 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
|
2073 { |
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 /* 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
|
2075 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
|
2076 } |
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 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
|
2078 { |
bd423985b2cf
[svn] seek with tristate prev/next buttons now works just like the seek bar (no seek until the button is released, no seek at all if it should move to the prev/next song)
giacomo
parents:
465
diff
changeset
|
2079 /* interpret as '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
|
2080 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
|
2081 } |
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
|
2082 |
7ffecac12107
[svn] Logic stuff relating to tristate-seek. Now I just need to work it into the event loop.
nenolod
parents:
433
diff
changeset
|
2083 seek_state = MAINWIN_SEEK_NIL; |
433
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 |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
2086 void |
0 | 2087 mainwin_play_pushed(void) |
2088 { | |
2089 if (bmp_playback_get_paused()) { | |
2090 bmp_playback_pause(); | |
2091 return; | |
2092 } | |
2093 | |
2094 if (playlist_get_length()) | |
2095 bmp_playback_initiate(); | |
2096 else | |
2097 mainwin_eject_pushed(); | |
2098 } | |
2099 | |
2100 void | |
2101 mainwin_stop_pushed(void) | |
2102 { | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
889
diff
changeset
|
2103 ip_data.stop = TRUE; |
0 | 2104 mainwin_clear_song_info(); |
2105 bmp_playback_stop(); | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
889
diff
changeset
|
2106 ip_data.stop = FALSE; |
0 | 2107 } |
2108 | |
2109 void | |
2110 mainwin_shuffle_pushed(gboolean toggled) | |
2111 { | |
2112 check_set(mainwin_play_menu, "/Shuffle", toggled); | |
2113 } | |
2114 | |
2115 void | |
2116 mainwin_repeat_pushed(gboolean toggled) | |
2117 { | |
2118 check_set(mainwin_play_menu, "/Repeat", toggled); | |
2119 } | |
2120 | |
2121 void | |
2122 mainwin_pl_pushed(gboolean toggled) | |
2123 { | |
2124 if (toggled) | |
2125 playlistwin_show(); | |
2126 else | |
2127 playlistwin_hide(); | |
2128 } | |
2129 | |
2130 gint | |
2131 mainwin_spos_frame_cb(gint pos) | |
2132 { | |
2133 if (mainwin_sposition) { | |
2134 if (pos < 6) | |
2135 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2136 17; | |
2137 else if (pos < 9) | |
2138 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2139 20; | |
2140 else | |
2141 mainwin_sposition->hs_knob_nx = mainwin_sposition->hs_knob_px = | |
2142 23; | |
2143 } | |
2144 return 1; | |
2145 } | |
2146 | |
2147 void | |
2148 mainwin_spos_motion_cb(gint pos) | |
2149 { | |
2150 gint time; | |
2151 gchar *time_msg; | |
2152 | |
2153 pos--; | |
2154 | |
2155 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
2156 | |
2157 if (cfg.timer_mode == TIMER_REMAINING) { | |
2158 time = (playlist_get_current_length() / 1000) - time; | |
2159 time_msg = g_strdup_printf("-%2.2d", time / 60); | |
2160 textbox_set_text(mainwin_stime_min, time_msg); | |
2161 g_free(time_msg); | |
2162 } | |
2163 else { | |
2164 time_msg = g_strdup_printf(" %2.2d", time / 60); | |
2165 textbox_set_text(mainwin_stime_min, time_msg); | |
2166 g_free(time_msg); | |
2167 } | |
2168 | |
2169 time_msg = g_strdup_printf("%2.2d", time % 60); | |
2170 textbox_set_text(mainwin_stime_sec, time_msg); | |
2171 g_free(time_msg); | |
2172 } | |
2173 | |
2174 void | |
2175 mainwin_spos_release_cb(gint pos) | |
2176 { | |
2177 bmp_playback_seek(((playlist_get_current_length() / 1000) * | |
2178 (pos - 1)) / 12); | |
2179 } | |
2180 | |
2181 void | |
2182 mainwin_position_motion_cb(gint pos) | |
2183 { | |
2184 gint length, time; | |
2185 gchar *seek_msg; | |
2186 | |
2187 length = playlist_get_current_length() / 1000; | |
2188 time = (length * pos) / 219; | |
2189 seek_msg = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), | |
2190 time / 60, time % 60, | |
2191 length / 60, length % 60, | |
2192 (length != 0) ? (time * 100) / length : 0); | |
2193 mainwin_lock_info_text(seek_msg); | |
2194 g_free(seek_msg); | |
2195 } | |
2196 | |
2197 void | |
2198 mainwin_position_release_cb(gint pos) | |
2199 { | |
2200 gint length, time; | |
2201 | |
2202 length = playlist_get_current_length() / 1000; | |
2203 time = (length * pos) / 219; | |
2204 bmp_playback_seek(time); | |
2205 mainwin_release_info_text(); | |
2206 } | |
2207 | |
2208 gint | |
2209 mainwin_volume_frame_cb(gint pos) | |
2210 { | |
2211 return (gint) rint((pos / 52.0) * 28); | |
2212 } | |
2213 | |
2214 void | |
2215 mainwin_adjust_volume_motion(gint v) | |
2216 { | |
2217 gchar *volume_msg; | |
2218 | |
2219 setting_volume = TRUE; | |
2220 | |
2221 volume_msg = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2222 mainwin_lock_info_text(volume_msg); | |
2223 g_free(volume_msg); | |
2224 | |
2225 if (balance < 0) | |
2226 input_set_volume(v, (v * (100 - abs(balance))) / 100); | |
2227 else if (balance > 0) | |
2228 input_set_volume((v * (100 - abs(balance))) / 100, v); | |
2229 else | |
2230 input_set_volume(v, v); | |
2231 } | |
2232 | |
2233 void | |
2234 mainwin_adjust_volume_release(void) | |
2235 { | |
2236 mainwin_release_info_text(); | |
2237 setting_volume = FALSE; | |
2238 read_volume(VOLUME_ADJUSTED); | |
2239 } | |
2240 | |
2241 void | |
2242 mainwin_adjust_balance_motion(gint b) | |
2243 { | |
2244 gchar *balance_msg; | |
2245 gint v, pvl, pvr; | |
2246 | |
2247 setting_volume = TRUE; | |
2248 balance = b; | |
2249 input_get_volume(&pvl, &pvr); | |
2250 v = MAX(pvl, pvr); | |
2251 if (b < 0) { | |
2252 balance_msg = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2253 input_set_volume(v, (gint) rint(((100 + b) / 100.0) * v)); | |
2254 } | |
2255 else if (b == 0) { | |
2256 balance_msg = g_strdup_printf(_("BALANCE: CENTER")); | |
2257 input_set_volume(v, v); | |
2258 } | |
2259 else { /* b > 0 */ | |
2260 balance_msg = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2261 input_set_volume((gint) rint(((100 - b) / 100.0) * v), v); | |
2262 } | |
2263 mainwin_lock_info_text(balance_msg); | |
2264 g_free(balance_msg); | |
2265 } | |
2266 | |
2267 void | |
2268 mainwin_adjust_balance_release(void) | |
2269 { | |
2270 mainwin_release_info_text(); | |
2271 setting_volume = FALSE; | |
2272 read_volume(VOLUME_ADJUSTED); | |
2273 } | |
2274 | |
2275 void | |
2276 mainwin_set_volume_slider(gint percent) | |
2277 { | |
2278 hslider_set_position(mainwin_volume, (gint) rint((percent * 51) / 100.0)); | |
2279 } | |
2280 | |
2281 void | |
2282 mainwin_set_balance_slider(gint percent) | |
2283 { | |
2284 hslider_set_position(mainwin_balance, | |
2285 (gint) rint(((percent * 12) / 100.0) + 12)); | |
2286 } | |
2287 | |
2288 void | |
2289 mainwin_volume_motion_cb(gint pos) | |
2290 { | |
2291 gint vol = (pos * 100) / 51; | |
2292 mainwin_adjust_volume_motion(vol); | |
2293 equalizerwin_set_volume_slider(vol); | |
2294 } | |
2295 | |
2296 void | |
2297 mainwin_volume_release_cb(gint pos) | |
2298 { | |
2299 mainwin_adjust_volume_release(); | |
2300 } | |
2301 | |
2302 gint | |
2303 mainwin_balance_frame_cb(gint pos) | |
2304 { | |
2305 return ((abs(pos - 12) * 28) / 13); | |
2306 } | |
2307 | |
2308 void | |
2309 mainwin_balance_motion_cb(gint pos) | |
2310 { | |
2311 gint bal = ((pos - 12) * 100) / 12; | |
2312 mainwin_adjust_balance_motion(bal); | |
2313 equalizerwin_set_balance_slider(bal); | |
2314 } | |
2315 | |
2316 void | |
2317 mainwin_balance_release_cb(gint pos) | |
2318 { | |
2319 mainwin_adjust_volume_release(); | |
2320 } | |
2321 | |
2322 void | |
2323 mainwin_set_volume_diff(gint diff) | |
2324 { | |
2325 gint vl, vr, vol; | |
2326 | |
2327 input_get_volume(&vl, &vr); | |
2328 vol = MAX(vl, vr); | |
2329 vol = CLAMP(vol + diff, 0, 100); | |
2330 | |
2331 mainwin_adjust_volume_motion(vol); | |
2332 setting_volume = FALSE; | |
2333 mainwin_set_volume_slider(vol); | |
2334 equalizerwin_set_volume_slider(vol); | |
2335 read_volume(VOLUME_SET); | |
2336 } | |
2337 | |
2338 void | |
2339 mainwin_set_balance_diff(gint diff) | |
2340 { | |
2341 gint b; | |
2342 b = CLAMP(balance + diff, -100, 100); | |
2343 mainwin_adjust_balance_motion(b); | |
2344 setting_volume = FALSE; | |
2345 mainwin_set_balance_slider(b); | |
2346 equalizerwin_set_balance_slider(b); | |
2347 read_volume(VOLUME_SET); | |
2348 } | |
2349 | |
2350 void | |
2351 mainwin_show(gboolean show) | |
2352 { | |
2353 if (show) | |
2354 mainwin_real_show(); | |
2355 else | |
2356 mainwin_real_hide(); | |
2357 } | |
2358 | |
2359 void | |
2360 mainwin_real_show(void) | |
2361 { | |
2362 cfg.player_visible = TRUE; | |
2363 | |
2364 if (cfg.player_shaded) | |
2365 vis_clear_data(active_vis); | |
2366 | |
2367 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_MAINWIN); | |
2368 mainwin_set_shape_mask(); | |
2369 | |
2370 if (cfg.show_wm_decorations) { | |
2371 if (!pposition_broken && cfg.player_x != -1 | |
2372 && cfg.save_window_position) | |
2373 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2374 | |
2375 gtk_widget_show(mainwin); | |
2376 | |
2377 if (pposition_broken && cfg.player_x != -1 | |
2378 && cfg.save_window_position) | |
2379 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2380 | |
2381 return; | |
2382 } | |
2383 | |
2384 gtk_widget_show_all(mainwin); | |
2385 | |
2386 if (!nullmask) | |
2387 return; | |
2388 | |
2389 g_object_unref(nullmask); | |
2390 nullmask = NULL; | |
2391 | |
2392 gdk_window_set_hints(mainwin->window, 0, 0, | |
2393 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2394 PLAYER_WIDTH, PLAYER_HEIGHT, | |
2395 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2396 gtk_window_resize(GTK_WINDOW(mainwin), PLAYER_WIDTH, PLAYER_HEIGHT); | |
2397 | |
2398 if (cfg.player_x != -1 && cfg.player_y != -1) | |
2399 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
2400 | |
2401 draw_main_window(TRUE); | |
2402 | |
2403 gtk_window_present(GTK_WINDOW(mainwin)); | |
2404 } | |
2405 | |
2406 void | |
2407 mainwin_real_hide(void) | |
2408 { | |
2409 GdkGC *gc; | |
2410 GdkColor pattern; | |
2411 | |
561
2b9dc862967b
[svn] Remove the elusive playlistwin visualiser that we do not use.
nenolod
parents:
549
diff
changeset
|
2412 if (cfg.player_shaded) |
0 | 2413 svis_clear_data(mainwin_svis); |
2414 | |
2415 if (!cfg.show_wm_decorations) { | |
2416 nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1); | |
2417 gc = gdk_gc_new(nullmask); | |
2418 pattern.pixel = 0; | |
2419 gdk_gc_set_foreground(gc, &pattern); | |
2420 gdk_draw_rectangle(nullmask, gc, TRUE, 0, 0, 20, 20); | |
2421 gdk_gc_destroy(gc); | |
2422 gtk_widget_shape_combine_mask(mainwin, nullmask, 0, 0); | |
2423 | |
2424 gdk_window_set_hints(mainwin->window, 0, 0, 0, 0, 0, 0, | |
2425 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); | |
2426 gdk_window_resize(mainwin->window, 0, 0); | |
2427 } | |
2428 | |
2429 gtk_widget_hide(mainwin); | |
2430 | |
2431 mainwin_vis_set_active_vis(MAINWIN_VIS_ACTIVE_PLAYLISTWIN); | |
2432 cfg.player_visible = FALSE; | |
2433 } | |
2434 | |
2435 static void | |
2436 mainwin_songname_menu_callback(gpointer data, | |
2437 guint action, | |
2438 GtkWidget * item) | |
2439 { | |
2440 GtkCheckMenuItem *check; | |
2441 | |
2442 switch (action) { | |
2443 case MAINWIN_SONGNAME_FILEINFO: | |
2444 playlist_fileinfo_current(); | |
2445 break; | |
2446 case MAINWIN_SONGNAME_JTF: | |
2447 mainwin_jump_to_file(); | |
2448 break; | |
2449 case MAINWIN_SONGNAME_JTT: | |
2450 mainwin_jump_to_time(); | |
2451 break; | |
2452 case MAINWIN_SONGNAME_SCROLL: | |
2453 check = GTK_CHECK_MENU_ITEM(item); | |
2454 mainwin_set_title_scroll(gtk_check_menu_item_get_active(check)); | |
2455 break; | |
898 | 2456 case MAINWIN_SONGNAME_STOPAFTERSONG: |
2457 check = GTK_CHECK_MENU_ITEM(item); | |
2458 cfg.stopaftersong = gtk_check_menu_item_get_active(check); | |
2459 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2460 check_set(mainwin_play_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2461 break; | |
0 | 2462 } |
2463 } | |
2464 | |
898 | 2465 void |
2466 mainwin_set_stopaftersong(gboolean stop) | |
2467 { | |
2468 cfg.stopaftersong = stop; | |
2469 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); | |
2470 } | |
2471 | |
0 | 2472 static void |
2473 mainwin_play_menu_callback(gpointer data, | |
2474 guint action, | |
2475 GtkWidget * item) | |
2476 { | |
2477 GtkCheckMenuItem *check; | |
2478 | |
2479 switch (action) { | |
2480 case MAINWIN_OPT_SHUFFLE: | |
2481 check = GTK_CHECK_MENU_ITEM(item); | |
2482 cfg.shuffle = gtk_check_menu_item_get_active(check); | |
2483 playlist_set_shuffle(cfg.shuffle); | |
2484 tbutton_set_toggled(mainwin_shuffle, cfg.shuffle); | |
2485 break; | |
2486 case MAINWIN_OPT_REPEAT: | |
2487 check = GTK_CHECK_MENU_ITEM(item); | |
2488 cfg.repeat = gtk_check_menu_item_get_active(check); | |
2489 tbutton_set_toggled(mainwin_repeat, cfg.repeat); | |
2490 break; | |
2491 case MAINWIN_OPT_NPA: | |
2492 check = GTK_CHECK_MENU_ITEM(item); | |
2493 cfg.no_playlist_advance = gtk_check_menu_item_get_active(check); | |
2494 break; | |
2495 } | |
2496 } | |
2497 | |
2498 | |
2499 static void | |
2500 mainwin_view_menu_callback(gpointer data, | |
2501 guint action, | |
2502 GtkWidget * item) | |
2503 { | |
2504 switch (action) { | |
2505 case MAINWIN_OPT_TELAPSED: | |
2506 set_timer_mode_menu_cb(TIMER_ELAPSED); | |
2507 break; | |
2508 case MAINWIN_OPT_TREMAINING: | |
2509 set_timer_mode_menu_cb(TIMER_REMAINING); | |
2510 break; | |
2511 case MAINWIN_OPT_ALWAYS: | |
2512 mainwin_menurow->mr_always_selected = GTK_CHECK_MENU_ITEM(item)->active; | |
2513 cfg.always_on_top = mainwin_menurow->mr_always_selected; | |
2514 widget_draw(WIDGET(mainwin_menurow)); | |
486 | 2515 |
2516 if (starting_up == FALSE) | |
2517 hint_set_always(cfg.always_on_top); | |
2518 | |
0 | 2519 break; |
2520 case MAINWIN_OPT_STICKY: | |
2521 cfg.sticky = GTK_CHECK_MENU_ITEM(item)->active; | |
2522 hint_set_sticky(cfg.sticky); | |
2523 break; | |
2524 case MAINWIN_OPT_WS: | |
2525 mainwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2526 break; | |
2527 case MAINWIN_OPT_PWS: | |
2528 playlistwin_set_shade(GTK_CHECK_MENU_ITEM(item)->active); | |
2529 break; | |
2530 case MAINWIN_OPT_EQWS: | |
2531 equalizerwin_set_shade_menu_cb(GTK_CHECK_MENU_ITEM(item)->active); | |
2532 break; | |
2533 } | |
2534 } | |
2535 | |
2536 void | |
2537 mainwin_vis_menu_callback(gpointer data, | |
2538 guint action, | |
2539 GtkWidget * item) | |
2540 { | |
2541 switch (action) { | |
2542 case MAINWIN_VIS_ANALYZER: | |
2543 case MAINWIN_VIS_SCOPE: | |
2544 case MAINWIN_VIS_OFF: | |
2545 mainwin_vis_set_type_menu_cb(action - MAINWIN_VIS_ANALYZER); | |
2546 break; | |
2547 case MAINWIN_VIS_ANALYZER_NORMAL: | |
2548 case MAINWIN_VIS_ANALYZER_FIRE: | |
2549 case MAINWIN_VIS_ANALYZER_VLINES: | |
2550 mainwin_vis_set_analyzer_mode(action - MAINWIN_VIS_ANALYZER_NORMAL); | |
2551 break; | |
2552 case MAINWIN_VIS_ANALYZER_LINES: | |
2553 case MAINWIN_VIS_ANALYZER_BARS: | |
2554 mainwin_vis_set_analyzer_type(action - MAINWIN_VIS_ANALYZER_LINES); | |
2555 break; | |
2556 case MAINWIN_VIS_ANALYZER_PEAKS: | |
2557 cfg.analyzer_peaks = GTK_CHECK_MENU_ITEM(item)->active; | |
2558 break; | |
2559 case MAINWIN_VIS_SCOPE_DOT: | |
2560 case MAINWIN_VIS_SCOPE_LINE: | |
2561 case MAINWIN_VIS_SCOPE_SOLID: | |
2562 cfg.scope_mode = action - MAINWIN_VIS_SCOPE_DOT; | |
2563 break; | |
2564 case MAINWIN_VIS_VU_NORMAL: | |
2565 case MAINWIN_VIS_VU_SMOOTH: | |
2566 cfg.vu_mode = action - MAINWIN_VIS_VU_NORMAL; | |
2567 break; | |
2568 case MAINWIN_VIS_REFRESH_FULL: | |
2569 case MAINWIN_VIS_REFRESH_HALF: | |
2570 case MAINWIN_VIS_REFRESH_QUARTER: | |
2571 case MAINWIN_VIS_REFRESH_EIGHTH: | |
2572 mainwin_vis_set_refresh(action - MAINWIN_VIS_REFRESH_FULL); | |
2573 break; | |
2574 case MAINWIN_VIS_AFALLOFF_SLOWEST: | |
2575 case MAINWIN_VIS_AFALLOFF_SLOW: | |
2576 case MAINWIN_VIS_AFALLOFF_MEDIUM: | |
2577 case MAINWIN_VIS_AFALLOFF_FAST: | |
2578 case MAINWIN_VIS_AFALLOFF_FASTEST: | |
2579 mainwin_vis_set_afalloff(action - MAINWIN_VIS_AFALLOFF_SLOWEST); | |
2580 break; | |
2581 case MAINWIN_VIS_PFALLOFF_SLOWEST: | |
2582 case MAINWIN_VIS_PFALLOFF_SLOW: | |
2583 case MAINWIN_VIS_PFALLOFF_MEDIUM: | |
2584 case MAINWIN_VIS_PFALLOFF_FAST: | |
2585 case MAINWIN_VIS_PFALLOFF_FASTEST: | |
2586 mainwin_vis_set_pfalloff(action - MAINWIN_VIS_PFALLOFF_SLOWEST); | |
2587 break; | |
2588 } | |
2589 } | |
2590 | |
2591 void | |
2592 mainwin_general_menu_callback(gpointer data, | |
2593 guint action, | |
2594 GtkWidget * item) | |
2595 { | |
2596 switch (action) { | |
2597 case MAINWIN_GENERAL_PREFS: | |
2598 show_prefs_window(); | |
2599 break; | |
2600 case MAINWIN_GENERAL_ABOUT: | |
2601 show_about_window(); | |
2602 break; | |
2603 case MAINWIN_GENERAL_PLAYFILE: | |
2604 util_run_filebrowser(NO_PLAY_BUTTON); | |
2605 break; | |
2606 case MAINWIN_GENERAL_PLAYCD: | |
2607 play_medium(); | |
2608 break; | |
2609 case MAINWIN_GENERAL_ADDCD: | |
2610 add_medium(); | |
2611 break; | |
2612 case MAINWIN_GENERAL_PLAYLOCATION: | |
2613 mainwin_show_add_url_window(); | |
2614 break; | |
2615 case MAINWIN_GENERAL_FILEINFO: | |
2616 playlist_fileinfo_current(); | |
2617 break; | |
2618 case MAINWIN_GENERAL_FOCUSPLWIN: | |
2619 gtk_window_present(GTK_WINDOW(playlistwin)); | |
2620 break; | |
2621 case MAINWIN_GENERAL_SHOWPLWIN: | |
2622 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2623 playlistwin_show(); | |
2624 else | |
2625 playlistwin_hide(); | |
2626 break; | |
2627 case MAINWIN_GENERAL_SHOWEQWIN: | |
2628 if (GTK_CHECK_MENU_ITEM(item)->active) | |
2629 equalizerwin_real_show(); | |
2630 else | |
2631 equalizerwin_real_hide(); | |
2632 break; | |
2633 case MAINWIN_GENERAL_PREV: | |
2634 playlist_prev(); | |
2635 break; | |
2636 case MAINWIN_GENERAL_PLAY: | |
2637 mainwin_play_pushed(); | |
2638 break; | |
2639 case MAINWIN_GENERAL_PAUSE: | |
2640 bmp_playback_pause(); | |
2641 break; | |
2642 case MAINWIN_GENERAL_STOP: | |
2643 mainwin_stop_pushed(); | |
2644 break; | |
2645 case MAINWIN_GENERAL_NEXT: | |
2646 playlist_next(); | |
2647 break; | |
2648 case MAINWIN_GENERAL_BACK5SEC: | |
2649 if (bmp_playback_get_playing() | |
2650 && playlist_get_current_length() != -1) | |
2651 bmp_playback_seek_relative(-5); | |
2652 break; | |
2653 case MAINWIN_GENERAL_FWD5SEC: | |
2654 if (bmp_playback_get_playing() | |
2655 && playlist_get_current_length() != -1) | |
2656 bmp_playback_seek_relative(5); | |
2657 break; | |
2658 case MAINWIN_GENERAL_START: | |
2659 playlist_set_position(0); | |
2660 break; | |
2661 case MAINWIN_GENERAL_JTT: | |
2662 mainwin_jump_to_time(); | |
2663 break; | |
2664 case MAINWIN_GENERAL_JTF: | |
2665 mainwin_jump_to_file(); | |
2666 break; | |
2667 case MAINWIN_GENERAL_EXIT: | |
2668 mainwin_quit_cb(); | |
2669 break; | |
2670 } | |
2671 } | |
2672 | |
2673 static void | |
2674 mainwin_mr_change(MenuRowItem i) | |
2675 { | |
2676 switch (i) { | |
2677 case MENUROW_NONE: | |
2678 mainwin_set_info_text(); | |
2679 break; | |
2680 case MENUROW_OPTIONS: | |
2681 mainwin_lock_info_text(_("OPTIONS MENU")); | |
2682 break; | |
2683 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
|
2684 if (mainwin_menurow->mr_doublesize_selected) |
0 | 2685 mainwin_lock_info_text(_("DISABLE ALWAYS ON TOP")); |
2686 else | |
2687 mainwin_lock_info_text(_("ENABLE ALWAYS ON TOP")); | |
2688 break; | |
2689 case MENUROW_FILEINFOBOX: | |
2690 mainwin_lock_info_text(_("FILE INFO BOX")); | |
2691 break; | |
2692 case MENUROW_DOUBLESIZE: | |
2693 mainwin_lock_info_text(_("** DOUBLESIZE HAS BEEN REMOVED **")); | |
2694 break; | |
2695 case MENUROW_VISUALIZATION: | |
2696 mainwin_lock_info_text(_("VISUALIZATION MENU")); | |
2697 break; | |
2698 } | |
2699 } | |
2700 | |
2701 static void | |
2702 mainwin_mr_release(MenuRowItem i) | |
2703 { | |
2704 GdkModifierType modmask; | |
2705 GtkWidget *widget; | |
2706 gint x, y; | |
2707 | |
2708 switch (i) { | |
2709 case MENUROW_OPTIONS: | |
2710 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2711 util_item_factory_popup(mainwin_view_menu, x, y, 1, | |
2712 GDK_CURRENT_TIME); | |
2713 break; | |
2714 case MENUROW_ALWAYS: | |
2715 widget = | |
2716 gtk_item_factory_get_widget(mainwin_view_menu, | |
2717 "/Always On Top"); | |
2718 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | |
2719 mainwin_menurow->mr_always_selected); | |
2720 break; | |
2721 case MENUROW_FILEINFOBOX: | |
2722 playlist_fileinfo_current(); | |
2723 break; | |
2724 case MENUROW_DOUBLESIZE: | |
2725 /* double size removed, do nothing */ | |
2726 break; | |
2727 case MENUROW_VISUALIZATION: | |
2728 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
2729 util_item_factory_popup(mainwin_vis_menu, x, y, 1, GDK_CURRENT_TIME); | |
2730 break; | |
2731 case MENUROW_NONE: | |
2732 break; | |
2733 } | |
2734 mainwin_release_info_text(); | |
2735 } | |
2736 | |
2737 static void | |
2738 run_no_audiocd_dialog(void) | |
2739 { | |
2740 const gchar *markup = | |
2741 N_("<b><big>No playable CD found.</big></b>\n\n" | |
2742 "No CD inserted, or inserted CD is not an audio CD.\n"); | |
2743 | |
2744 GtkWidget *dialog = | |
2745 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2746 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2747 GTK_MESSAGE_ERROR, | |
2748 GTK_BUTTONS_OK, | |
2749 _(markup)); | |
2750 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2751 gtk_widget_destroy(dialog); | |
2752 } | |
2753 | |
2754 static void | |
2755 run_no_output_device_dialog(void) | |
2756 { | |
2757 const gchar *markup = | |
2758 N_("<b><big>Couldn't open audio.</big></b>\n\n" | |
2759 "Please check that:\n" | |
2760 "1. You have the correct output plugin selected.\n" | |
2761 "2. No other programs is blocking the soundcard.\n" | |
2762 "3. Your soundcard is configured properly.\n"); | |
2763 | |
2764 GtkWidget *dialog = | |
2765 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
2766 GTK_DIALOG_DESTROY_WITH_PARENT, | |
2767 GTK_MESSAGE_ERROR, | |
2768 GTK_BUTTONS_OK, | |
2769 _(markup)); | |
2770 gtk_dialog_run(GTK_DIALOG(dialog)); | |
2771 gtk_widget_destroy(dialog); | |
2772 } | |
2773 | |
2774 | |
2775 void | |
2776 add_medium(void) | |
2777 { | |
2778 GList *list, *node; | |
2779 gchar *filename; | |
2780 gchar *path; | |
2781 ConfigDb *db; | |
2782 | |
2783 db = bmp_cfg_db_open(); | |
2784 | |
2785 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2786 bmp_cfg_db_close(db); | |
2787 | |
2788 if (!(list = input_scan_dir(path))) { | |
2789 run_no_audiocd_dialog(); | |
2790 return; | |
2791 } | |
2792 | |
2793 for (node = list; node; node = g_list_next(node)) { | |
2794 filename = g_build_filename(path, node->data, NULL); | |
2795 playlist_add(filename); | |
2796 g_free(filename); | |
2797 g_free(node->data); | |
2798 } | |
2799 | |
2800 g_free(path); | |
2801 g_list_free(list); | |
2802 | |
2803 } | |
2804 | |
2805 void | |
2806 play_medium(void) | |
2807 { | |
2808 GList *list, *node; | |
2809 gchar *filename; | |
2810 gchar *path; | |
2811 ConfigDb *db; | |
2812 | |
2813 db = bmp_cfg_db_open(); | |
2814 bmp_cfg_db_get_string(db, "CDDA", "directory", &path); | |
2815 bmp_cfg_db_close(db); | |
2816 | |
2817 if (!(list = input_scan_dir(path))) { | |
2818 run_no_audiocd_dialog(); | |
2819 return; | |
2820 } | |
2821 | |
2822 playlist_clear(); | |
2823 | |
2824 for (node = list; node; node = g_list_next(node)) { | |
2825 filename = g_build_filename(path, node->data, NULL); | |
2826 playlist_add(filename); | |
2827 g_free(filename); | |
2828 g_free(node->data); | |
2829 } | |
2830 | |
2831 g_free(path); | |
2832 g_list_free(list); | |
2833 | |
2834 playlist_set_position(0); | |
2835 bmp_playback_initiate(); | |
2836 } | |
2837 | |
2838 void | |
2839 read_volume(gint when) | |
2840 { | |
2841 static gint pvl = 0, pvr = 0; | |
2842 static gint times = VOLSET_DISP_TIMES; | |
2843 static gboolean changing = FALSE; | |
2844 | |
2845 gint vl, vr, b, v; | |
2846 | |
2847 input_get_volume(&vl, &vr); | |
2848 | |
2849 switch (when) { | |
2850 case VOLSET_STARTUP: | |
2851 vl = CLAMP(vl, 0, 100); | |
2852 vr = CLAMP(vr, 0, 100); | |
2853 pvl = vl; | |
2854 pvr = vr; | |
2855 v = MAX(vl, vr); | |
2856 if (vl > vr) | |
2857 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2858 else if (vl < vr) | |
2859 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2860 else | |
2861 b = 0; | |
2862 | |
2863 balance = b; | |
2864 mainwin_set_volume_slider(v); | |
2865 equalizerwin_set_volume_slider(v); | |
2866 mainwin_set_balance_slider(b); | |
2867 equalizerwin_set_balance_slider(b); | |
2868 return; | |
2869 | |
2870 case VOLSET_UPDATE: | |
2871 if (vl == -1 || vr == -1) | |
2872 return; | |
2873 | |
2874 if (setting_volume) { | |
2875 pvl = vl; | |
2876 pvr = vr; | |
2877 return; | |
2878 } | |
2879 | |
2880 if (pvr == vr && pvl == vl && changing) { | |
2881 if (times < VOLSET_DISP_TIMES) | |
2882 times++; | |
2883 else { | |
2884 mainwin_release_info_text(); | |
2885 changing = FALSE; | |
2886 } | |
2887 } | |
2888 else if (pvr != vr || pvl != vl) { | |
2889 gchar *tmp; | |
2890 | |
2891 v = MAX(vl, vr); | |
2892 if (vl > vr) | |
2893 b = (gint) rint(((gdouble) vr / vl) * 100) - 100; | |
2894 else if (vl < vr) | |
2895 b = 100 - (gint) rint(((gdouble) vl / vr) * 100); | |
2896 else | |
2897 b = 0; | |
2898 | |
2899 if (MAX(vl, vr) != MAX(pvl, pvr)) | |
2900 tmp = g_strdup_printf(_("VOLUME: %d%%"), v); | |
2901 else { | |
2902 if (vl > vr) { | |
2903 tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b); | |
2904 } | |
2905 else if (vr == vl) | |
2906 tmp = g_strdup_printf(_("BALANCE: CENTER")); | |
2907 else { /* (vl < vr) */ | |
2908 tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b); | |
2909 } | |
2910 } | |
2911 mainwin_lock_info_text(tmp); | |
2912 g_free(tmp); | |
2913 | |
2914 pvr = vr; | |
2915 pvl = vl; | |
2916 times = 0; | |
2917 changing = TRUE; | |
2918 mainwin_set_volume_slider(v); | |
2919 equalizerwin_set_volume_slider(v); | |
2920 | |
2921 /* Don't change the balance slider if the volume has been | |
2922 * set to zero. The balance can be anything, and our best | |
2923 * guess is what is was before. */ | |
2924 if (v > 0) { | |
2925 balance = b; | |
2926 mainwin_set_balance_slider(b); | |
2927 equalizerwin_set_balance_slider(b); | |
2928 } | |
2929 } | |
2930 break; | |
2931 | |
2932 case VOLUME_ADJUSTED: | |
2933 pvl = vl; | |
2934 pvr = vr; | |
2935 break; | |
2936 | |
2937 case VOLUME_SET: | |
2938 times = 0; | |
2939 changing = TRUE; | |
2940 pvl = vl; | |
2941 pvr = vr; | |
2942 break; | |
2943 } | |
2944 } | |
2945 | |
2946 | |
2947 /* TODO: HAL! */ | |
2948 gboolean | |
2949 can_play_cd(void) | |
2950 { | |
2951 GList *ilist; | |
2952 | |
2953 for (ilist = get_input_list(); ilist; ilist = g_list_next(ilist)) { | |
2954 InputPlugin *ip = INPUT_PLUGIN(ilist->data); | |
2955 | |
2956 if (!g_ascii_strcasecmp(g_basename(ip->filename), | |
2957 PLUGIN_FILENAME("cdaudio"))) { | |
2958 return TRUE; | |
2959 } | |
2960 } | |
2961 | |
2962 return FALSE; | |
2963 } | |
2964 | |
2965 | |
2966 static void | |
2967 set_timer_mode(TimerMode mode) | |
2968 { | |
2969 if (mode == TIMER_ELAPSED) | |
2970 check_set(mainwin_view_menu, "/Time Elapsed", TRUE); | |
2971 else | |
2972 check_set(mainwin_view_menu, "/Time Remaining", TRUE); | |
2973 } | |
2974 | |
2975 static void | |
2976 set_timer_mode_menu_cb(TimerMode mode) | |
2977 { | |
2978 cfg.timer_mode = mode; | |
2979 } | |
2980 | |
2981 | |
2982 void | |
2983 mainwin_setup_menus(void) | |
2984 { | |
2985 set_timer_mode(cfg.timer_mode); | |
2986 | |
2987 /* View menu */ | |
2988 | |
2989 check_set(mainwin_view_menu, "/Always On Top", cfg.always_on_top); | |
2990 check_set(mainwin_view_menu, "/Put on All Workspaces", cfg.sticky); | |
2991 check_set(mainwin_view_menu, "/Roll up Player", cfg.player_shaded); | |
2992 check_set(mainwin_view_menu, "/Roll up Playlist Editor", cfg.playlist_shaded); | |
2993 check_set(mainwin_view_menu, "/Roll up Equalizer", cfg.equalizer_shaded); | |
2994 | |
2995 /* Songname menu */ | |
2996 | |
2997 check_set(mainwin_songname_menu, "/Autoscroll Songname", cfg.autoscroll); | |
898 | 2998 check_set(mainwin_songname_menu, "/Stop After Current Song", cfg.stopaftersong); |
0 | 2999 |
3000 /* Playback menu */ | |
3001 | |
3002 check_set(mainwin_play_menu, "/Repeat", cfg.repeat); | |
3003 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
|
3004 check_set(mainwin_play_menu, "/No Playlist Advance", cfg.no_playlist_advance); |
0 | 3005 |
3006 /* Visualization menu */ | |
3007 | |
3008 check_set(mainwin_vis_menu, | |
3009 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_VIS_MODE + | |
3010 cfg.vis_type].path, TRUE); | |
3011 check_set(mainwin_vis_menu, | |
3012 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_MODE + | |
3013 cfg.analyzer_mode].path, TRUE); | |
3014 check_set(mainwin_vis_menu, | |
3015 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_TYPE + | |
3016 cfg.analyzer_type].path, TRUE); | |
3017 check_set(mainwin_vis_menu, | |
3018 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_ANALYZER_PEAKS]. | |
3019 path, cfg.analyzer_peaks); | |
3020 check_set(mainwin_vis_menu, | |
3021 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_SCOPE_MODE + | |
3022 cfg.scope_mode].path, TRUE); | |
3023 check_set(mainwin_vis_menu, | |
3024 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_WSHADEVU_MODE + | |
3025 cfg.vu_mode].path, TRUE); | |
3026 check_set(mainwin_vis_menu, | |
3027 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_REFRESH_RATE + | |
3028 cfg.vis_refresh].path, TRUE); | |
3029 check_set(mainwin_vis_menu, | |
3030 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_AFALLOFF + | |
3031 cfg.analyzer_falloff].path, TRUE); | |
3032 check_set(mainwin_vis_menu, | |
3033 mainwin_vis_menu_entries[MAINWIN_VIS_MENU_PFALLOFF + | |
3034 cfg.peaks_falloff].path, TRUE); | |
3035 } | |
3036 | |
3037 static void | |
3038 mainwin_create_widgets(void) | |
3039 { | |
3040 mainwin_menubtn = | |
3041 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 6, 3, 9, 9, | |
3042 0, 0, 0, 9, mainwin_menubtn_cb, SKIN_TITLEBAR); | |
3043 mainwin_menubtn->pb_allow_draw = FALSE; | |
3044 mainwin_minimize = | |
3045 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 244, 3, 9, | |
3046 9, 9, 0, 9, 9, mainwin_minimize_cb, SKIN_TITLEBAR); | |
3047 mainwin_minimize->pb_allow_draw = FALSE; | |
3048 mainwin_shade = | |
3049 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 254, 3, 9, | |
3050 9, 0, cfg.player_shaded ? 27 : 18, 9, | |
3051 cfg.player_shaded ? 27 : 18, mainwin_shade_toggle, | |
3052 SKIN_TITLEBAR); | |
3053 mainwin_shade->pb_allow_draw = FALSE; | |
3054 mainwin_close = | |
3055 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 264, 3, 9, | |
3056 9, 18, 0, 18, 9, mainwin_quit_cb, SKIN_TITLEBAR); | |
3057 mainwin_close->pb_allow_draw = FALSE; | |
3058 | |
3059 mainwin_rew = | |
433
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
3060 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
|
3061 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
|
3062 SKIN_CBUTTONS, SKIN_CBUTTONS); |
0 | 3063 mainwin_play = |
3064 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 39, 88, 23, | |
3065 18, 23, 0, 23, 18, mainwin_play_pushed, SKIN_CBUTTONS); | |
3066 mainwin_pause = | |
3067 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 62, 88, 23, | |
3068 18, 46, 0, 46, 18, bmp_playback_pause, SKIN_CBUTTONS); | |
3069 mainwin_stop = | |
3070 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 85, 88, 23, | |
3071 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
|
3072 #if 0 |
0 | 3073 mainwin_fwd = |
3074 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 108, 88, 22, | |
3075 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
|
3076 #endif |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
3077 mainwin_fwd = |
465 | 3078 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
|
3079 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
|
3080 SKIN_CBUTTONS, SKIN_CBUTTONS); |
041bc95827be
[svn] Convert prev/next buttons to tristate, via create_pbutton_ex().
nenolod
parents:
383
diff
changeset
|
3081 |
0 | 3082 mainwin_eject = |
3083 create_pbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 136, 89, 22, | |
3084 16, 114, 0, 114, 16, mainwin_eject_pushed, | |
3085 SKIN_CBUTTONS); | |
3086 | |
3087 mainwin_srew = | |
3088 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 169, 4, 8, | |
3089 7, playlist_prev); | |
3090 mainwin_splay = | |
3091 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 4, 10, | |
3092 7, mainwin_play_pushed); | |
3093 mainwin_spause = | |
3094 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 187, 4, 10, | |
3095 7, bmp_playback_pause); | |
3096 mainwin_sstop = | |
3097 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 197, 4, 9, | |
3098 7, mainwin_stop_pushed); | |
3099 mainwin_sfwd = | |
3100 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 206, 4, 8, | |
3101 7, playlist_next); | |
3102 mainwin_seject = | |
3103 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 216, 4, 9, | |
3104 7, mainwin_eject_pushed); | |
3105 | |
3106 mainwin_shuffle = | |
3107 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 164, 89, 46, | |
3108 15, 28, 0, 28, 15, 28, 30, 28, 45, | |
3109 mainwin_shuffle_pushed, SKIN_SHUFREP); | |
3110 | |
3111 mainwin_repeat = | |
3112 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 210, 89, 28, | |
3113 15, 0, 0, 0, 15, 0, 30, 0, 45, | |
3114 mainwin_repeat_pushed, SKIN_SHUFREP); | |
3115 | |
3116 mainwin_eq = | |
3117 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 219, 58, 23, | |
3118 12, 0, 61, 46, 61, 0, 73, 46, 73, equalizerwin_show, | |
3119 SKIN_SHUFREP); | |
3120 tbutton_set_toggled(mainwin_eq, cfg.equalizer_visible); | |
3121 mainwin_pl = | |
3122 create_tbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 242, 58, 23, | |
3123 12, 23, 61, 69, 61, 23, 73, 69, 73, | |
3124 mainwin_pl_pushed, SKIN_SHUFREP); | |
3125 tbutton_set_toggled(mainwin_pl, cfg.playlist_visible); | |
3126 | |
3127 mainwin_info = | |
3128 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 27, | |
3129 153, 1, SKIN_TEXT); | |
3130 textbox_set_scroll(mainwin_info, cfg.autoscroll); | |
123
022d9717476f
[svn] Bring back support for winamp-style bitmap fonts. :)
nenolod
parents:
88
diff
changeset
|
3131 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
|
3132 |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
3133 mainwin_othertext = |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
3134 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
|
3135 153, 1, SKIN_TEXT); |
7d998597254e
[svn] - initial work on skin.hints support (the first step to modernizing our
nenolod
parents:
836
diff
changeset
|
3136 |
0 | 3137 mainwin_rate_text = |
3138 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, | |
3139 0, SKIN_TEXT); | |
3140 mainwin_freq_text = | |
3141 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 156, 43, 10, | |
3142 0, SKIN_TEXT); | |
3143 | |
3144 mainwin_menurow = | |
3145 create_menurow(&mainwin_wlist, mainwin_bg, mainwin_gc, 10, 22, 304, | |
3146 0, 304, 44, mainwin_mr_change, mainwin_mr_release, | |
3147 SKIN_TITLEBAR); | |
3148 mainwin_menurow->mr_doublesize_selected = FALSE; | |
3149 mainwin_menurow->mr_always_selected = cfg.always_on_top; | |
3150 | |
3151 mainwin_volume = | |
3152 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 107, 57, 68, | |
3153 13, 15, 422, 0, 422, 14, 11, 15, 0, 0, 51, | |
3154 mainwin_volume_frame_cb, mainwin_volume_motion_cb, | |
3155 mainwin_volume_release_cb, SKIN_VOLUME); | |
3156 mainwin_balance = | |
3157 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 177, 57, 38, | |
3158 13, 15, 422, 0, 422, 14, 11, 15, 9, 0, 24, | |
3159 mainwin_balance_frame_cb, mainwin_balance_motion_cb, | |
3160 mainwin_balance_release_cb, SKIN_BALANCE); | |
3161 | |
3162 mainwin_monostereo = | |
3163 create_monostereo(&mainwin_wlist, mainwin_bg, mainwin_gc, 212, 41, | |
3164 SKIN_MONOSTEREO); | |
3165 | |
3166 mainwin_playstatus = | |
3167 create_playstatus(&mainwin_wlist, mainwin_bg, mainwin_gc, 24, 28); | |
3168 | |
3169 mainwin_minus_num = | |
3170 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 36, 26, | |
3171 SKIN_NUMBERS); | |
3172 widget_hide(WIDGET(mainwin_minus_num)); | |
3173 mainwin_10min_num = | |
3174 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 48, 26, | |
3175 SKIN_NUMBERS); | |
3176 widget_hide(WIDGET(mainwin_10min_num)); | |
3177 | |
3178 mainwin_min_num = | |
3179 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 60, 26, | |
3180 SKIN_NUMBERS); | |
3181 widget_hide(WIDGET(mainwin_min_num)); | |
3182 | |
3183 mainwin_10sec_num = | |
3184 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 78, 26, | |
3185 SKIN_NUMBERS); | |
3186 widget_hide(WIDGET(mainwin_10sec_num)); | |
3187 | |
3188 mainwin_sec_num = | |
3189 create_number(&mainwin_wlist, mainwin_bg, mainwin_gc, 90, 26, | |
3190 SKIN_NUMBERS); | |
3191 widget_hide(WIDGET(mainwin_sec_num)); | |
3192 | |
3193 mainwin_about = | |
3194 create_sbutton(&mainwin_wlist, mainwin_bg, mainwin_gc, 247, 83, 20, | |
3195 25, show_about_window); | |
3196 | |
3197 mainwin_vis = | |
3198 create_vis(&mainwin_wlist, mainwin_bg, mainwin->window, mainwin_gc, | |
3199 24, 43, 76); | |
3200 mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, mainwin_gc, 79, 5); | |
3201 active_vis = mainwin_vis; | |
3202 | |
3203 mainwin_position = | |
3204 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 16, 72, 248, | |
3205 10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL, | |
3206 mainwin_position_motion_cb, | |
3207 mainwin_position_release_cb, SKIN_POSBAR); | |
3208 widget_hide(WIDGET(mainwin_position)); | |
3209 | |
3210 mainwin_sposition = | |
3211 create_hslider(&mainwin_wlist, mainwin_bg, mainwin_gc, 226, 4, 17, | |
3212 7, 17, 36, 17, 36, 3, 7, 36, 0, 1, 13, | |
3213 mainwin_spos_frame_cb, mainwin_spos_motion_cb, | |
3214 mainwin_spos_release_cb, SKIN_TITLEBAR); | |
3215 widget_hide(WIDGET(mainwin_sposition)); | |
3216 | |
3217 mainwin_stime_min = | |
3218 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 130, 4, 15, | |
3219 FALSE, SKIN_TEXT); | |
3220 mainwin_stime_sec = | |
3221 create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 147, 4, 10, | |
3222 FALSE, SKIN_TEXT); | |
3223 | |
3224 if (!cfg.player_shaded) { | |
3225 widget_hide(WIDGET(mainwin_svis)); | |
3226 widget_hide(WIDGET(mainwin_srew)); | |
3227 widget_hide(WIDGET(mainwin_splay)); | |
3228 widget_hide(WIDGET(mainwin_spause)); | |
3229 widget_hide(WIDGET(mainwin_sstop)); | |
3230 widget_hide(WIDGET(mainwin_sfwd)); | |
3231 widget_hide(WIDGET(mainwin_seject)); | |
3232 widget_hide(WIDGET(mainwin_stime_min)); | |
3233 widget_hide(WIDGET(mainwin_stime_sec)); | |
3234 } | |
3235 | |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
654
diff
changeset
|
3236 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
|
3237 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
|
3238 |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
654
diff
changeset
|
3239 |
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
654
diff
changeset
|
3240 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
|
3241 /* 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
|
3242 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
|
3243 "Boo! Bad stuff! Booga Booga!"); |
781
12c47704b4b5
[svn] Add error reporting for many places, patch by external contributor Derek
nenolod
parents:
654
diff
changeset
|
3244 |
0 | 3245 } |
3246 | |
3247 static void | |
3248 mainwin_create_window(void) | |
3249 { | |
3250 gint width, height; | |
3251 | |
3252 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3253 gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious")); | |
3254 gtk_window_set_role(GTK_WINDOW(mainwin), "player"); | |
3255 gtk_window_set_resizable(GTK_WINDOW(mainwin), FALSE); | |
3256 | |
3257 width = MAINWIN_WIDTH; | |
3258 height = cfg.player_shaded ? MAINWIN_SHADED_HEIGHT : MAINWIN_HEIGHT; | |
3259 | |
3260 gtk_widget_set_size_request(mainwin, width, height); | |
3261 gtk_widget_set_app_paintable(mainwin, TRUE); | |
3262 | |
3263 dock_window_list = dock_window_set_decorated(dock_window_list, | |
3264 GTK_WINDOW(mainwin), | |
3265 cfg.show_wm_decorations); | |
3266 | |
3267 if (cfg.player_x != -1 && cfg.save_window_position) | |
3268 gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y); | |
3269 | |
3270 gtk_widget_add_events(mainwin, | |
3271 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK | | |
3272 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | |
3273 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK | | |
3274 GDK_VISIBILITY_NOTIFY_MASK); | |
3275 gtk_widget_realize(mainwin); | |
3276 | |
3277 util_set_cursor(mainwin); | |
3278 | |
3279 g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL); | |
3280 g_signal_connect(mainwin, "button_press_event", | |
3281 G_CALLBACK(mainwin_mouse_button_press), NULL); | |
3282 g_signal_connect(mainwin, "scroll_event", | |
3283 G_CALLBACK(mainwin_scrolled), NULL); | |
3284 g_signal_connect(mainwin, "button_release_event", | |
3285 G_CALLBACK(mainwin_mouse_button_release), NULL); | |
3286 g_signal_connect(mainwin, "motion_notify_event", | |
3287 G_CALLBACK(mainwin_motion), NULL); | |
3288 g_signal_connect_after(mainwin, "focus_in_event", | |
3289 G_CALLBACK(mainwin_focus_in), NULL); | |
3290 g_signal_connect_after(mainwin, "focus_out_event", | |
3291 G_CALLBACK(mainwin_focus_out), NULL); | |
3292 g_signal_connect(mainwin, "configure_event", | |
3293 G_CALLBACK(mainwin_configure), NULL); | |
3294 g_signal_connect(mainwin, "style_set", | |
3295 G_CALLBACK(mainwin_set_back_pixmap), NULL); | |
3296 | |
3297 bmp_drag_dest_set(mainwin); | |
3298 | |
3299 g_signal_connect(mainwin, "key_press_event", | |
3300 G_CALLBACK(mainwin_keypress), NULL); | |
3301 } | |
3302 | |
3303 static void | |
3304 mainwin_create_menus(void) | |
3305 { | |
3306 mainwin_general_menu = create_menu(mainwin_general_menu_entries, | |
3307 mainwin_general_menu_entries_num, | |
3308 mainwin_accel); | |
3309 | |
3310 mainwin_play_menu = create_menu(mainwin_playback_menu_entries, | |
3311 mainwin_playback_menu_entries_num, | |
3312 mainwin_accel); | |
3313 | |
3314 mainwin_view_menu = create_menu(mainwin_view_menu_entries, | |
3315 mainwin_view_menu_entries_num, | |
3316 mainwin_accel); | |
3317 | |
3318 mainwin_songname_menu = create_menu(mainwin_songname_menu_entries, | |
3319 mainwin_songname_menu_entries_num, | |
3320 mainwin_accel); | |
3321 | |
3322 mainwin_add_menu = create_menu(mainwin_add_menu_entries, | |
3323 mainwin_add_menu_entries_num, | |
3324 mainwin_accel); | |
3325 | |
3326 mainwin_vis_menu = create_menu(mainwin_vis_menu_entries, | |
3327 mainwin_vis_menu_entries_num, | |
3328 mainwin_accel); | |
3329 | |
3330 make_submenu(mainwin_general_menu, "/View", mainwin_view_menu); | |
87 | 3331 make_submenu(mainwin_general_menu, "/Playback", mainwin_play_menu); |
3332 make_submenu(mainwin_general_menu, "/Visualization", mainwin_vis_menu); | |
0 | 3333 |
3334 gtk_window_add_accel_group(GTK_WINDOW(mainwin), mainwin_accel); | |
3335 } | |
3336 | |
3337 void | |
3338 mainwin_create(void) | |
3339 { | |
3340 mainwin_create_window(); | |
3341 | |
3342 mainwin_accel = gtk_accel_group_new(); | |
3343 mainwin_create_menus(); | |
3344 | |
3345 mainwin_gc = gdk_gc_new(mainwin->window); | |
3346 mainwin_bg = gdk_pixmap_new(mainwin->window, | |
3347 MAINWIN_WIDTH, MAINWIN_HEIGHT, -1); | |
3348 mainwin_set_back_pixmap(); | |
3349 mainwin_create_widgets(); | |
3350 | |
3351 vis_set_window(mainwin_vis, mainwin->window); | |
3352 } | |
3353 | |
3354 void | |
3355 mainwin_attach_idle_func(void) | |
3356 { | |
3357 mainwin_timeout_id = g_timeout_add(MAINWIN_UPDATE_INTERVAL, | |
3358 mainwin_idle_func, NULL); | |
3359 } | |
3360 | |
3361 static void | |
3362 idle_func_update_song_info(gint time) | |
3363 { | |
3364 gint length, t; | |
3365 gchar stime_prefix; | |
3366 | |
3367 length = playlist_get_current_length(); | |
3368 playlistwin_set_time(time, length, cfg.timer_mode); | |
3369 input_update_vis(time); | |
3370 | |
3371 if (cfg.timer_mode == TIMER_REMAINING) { | |
3372 if (length != -1) { | |
3373 number_set_number(mainwin_minus_num, 11); | |
3374 t = length - time; | |
3375 stime_prefix = '-'; | |
3376 } | |
3377 else { | |
3378 number_set_number(mainwin_minus_num, 10); | |
3379 t = time; | |
3380 stime_prefix = ' '; | |
3381 } | |
3382 } | |
3383 else { | |
3384 number_set_number(mainwin_minus_num, 10); | |
3385 t = time; | |
3386 stime_prefix = ' '; | |
3387 } | |
3388 t /= 1000; | |
3389 | |
3390 /* Show the time in the format HH:MM when we have more than 100 | |
3391 * minutes. */ | |
3392 if (t >= 100 * 60) | |
3393 t /= 60; | |
3394 number_set_number(mainwin_10min_num, t / 600); | |
3395 number_set_number(mainwin_min_num, (t / 60) % 10); | |
3396 number_set_number(mainwin_10sec_num, (t / 10) % 6); | |
3397 number_set_number(mainwin_sec_num, t % 10); | |
3398 | |
3399 if (!mainwin_sposition->hs_pressed) { | |
3400 gchar *time_str; | |
3401 | |
3402 time_str = g_strdup_printf("%c%2.2d", stime_prefix, t / 60); | |
3403 textbox_set_text(mainwin_stime_min, time_str); | |
3404 g_free(time_str); | |
3405 | |
3406 time_str = g_strdup_printf("%2.2d", t % 60); | |
3407 textbox_set_text(mainwin_stime_sec, time_str); | |
3408 g_free(time_str); | |
3409 } | |
3410 | |
3411 time /= 1000; | |
3412 length /= 1000; | |
3413 if (length > 0) { | |
3414 if (time > length) { | |
3415 hslider_set_position(mainwin_position, 219); | |
3416 hslider_set_position(mainwin_sposition, 13); | |
3417 } | |
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
|
3418 /* 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
|
3419 else if (seek_state == MAINWIN_SEEK_NIL) { |
0 | 3420 hslider_set_position(mainwin_position, (time * 219) / length); |
3421 hslider_set_position(mainwin_sposition, | |
3422 ((time * 12) / length) + 1); | |
3423 } | |
3424 } | |
3425 else { | |
3426 hslider_set_position(mainwin_position, 0); | |
3427 hslider_set_position(mainwin_sposition, 1); | |
3428 } | |
3429 } | |
3430 | |
3431 static gboolean | |
3432 mainwin_idle_func(gpointer data) | |
3433 { | |
3434 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
|
3435 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
|
3436 |
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 /* 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
|
3438 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
|
3439 { |
0 | 3440 case -2: |
3441 /* no usable output device */ | |
3442 GDK_THREADS_ENTER(); | |
3443 run_no_output_device_dialog(); | |
3444 mainwin_stop_pushed(); | |
3445 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
|
3446 ev_waiting = FALSE; |
0 | 3447 break; |
3448 | |
3449 default: | |
3450 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
|
3451 /* nothing at this time */ |
0 | 3452 } |
3453 | |
3454 GDK_THREADS_ENTER(); | |
3455 | |
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
|
3456 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
|
3457 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
|
3458 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
|
3459 vis_playback_stop(); |
0 | 3460 |
3461 draw_main_window(mainwin_force_redraw); | |
3462 | |
3463 if (!count) { | |
3464 read_volume(VOLSET_UPDATE); | |
3465 count = 10; | |
3466 } | |
3467 else | |
3468 count--; | |
3469 | |
233 | 3470 mainwin_force_redraw = FALSE; |
455
40bb32c3789a
[svn] Possibly play nicer with X11 in the skinning engine's event loop.
nenolod
parents:
454
diff
changeset
|
3471 draw_playlist_window(FALSE); |
40bb32c3789a
[svn] Possibly play nicer with X11 in the skinning engine's event loop.
nenolod
parents:
454
diff
changeset
|
3472 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
|
3473 |
0 | 3474 if (mainwin_title_text) { |
3475 G_LOCK(mainwin_title); | |
3476 gtk_window_set_title(GTK_WINDOW(mainwin), mainwin_title_text); | |
3477 g_free(mainwin_title_text); | |
3478 mainwin_title_text = NULL; | |
3479 G_UNLOCK(mainwin_title); | |
3480 | |
3481 mainwin_set_info_text(); | |
3482 playlistwin_update_list(); | |
3483 } | |
3484 | |
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
|
3485 /* 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
|
3486 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
|
3487 { |
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 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
|
3489 GTimeVal delta_time; |
468 | 3490 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
|
3491 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
|
3492 |
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_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
|
3494 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
|
3495 |
468 | 3496 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
|
3497 |
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 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
|
3499 { |
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 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
|
3501 if (seek_state == MAINWIN_SEEK_REV) |
468 | 3502 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
|
3503 else |
468 | 3504 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
|
3505 |
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 /* 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
|
3507 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
|
3508 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
|
3509 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
|
3510 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
|
3511 |
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 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
|
3513 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
|
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 } |
bd423985b2cf
[svn] seek with tristate prev/next buttons now works just like the seek bar (no seek until the button is released, no seek at all if it should move to the prev/next song)
giacomo
parents:
465
diff
changeset
|
3516 |
0 | 3517 GDK_THREADS_LEAVE(); |
3518 | |
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
|
3519 /* |
435
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3520 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
|
3521 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
|
3522 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
|
3523 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
|
3524 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
|
3525 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
|
3526 */ |
435
e3070cc55ab2
[svn] - Scroll by 1000 frames when using the keypad (7 && 9) inside the player window to
nenolod
parents:
434
diff
changeset
|
3527 |
0 | 3528 return TRUE; |
3529 } |