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