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