annotate src/audacious/ui_main_evlisteners.c @ 4116:5853d43e539a

remember filter entry in jtf dialog is extremely useful when jtf deals with large playlist. now this feature is configurable.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Tue, 25 Dec 2007 19:15:44 +0900
parents 17bf734f8187
children 0becb809bdc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
1 /*
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
2 * Audacious
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
3 * Copyright (c) 2006-2007 Audacious development team.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
4 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
8 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
12 * GNU General Public License for more details.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
13 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
16 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
19 */
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
20
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
21 #include <glib.h>
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
22 #include <math.h>
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
23
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
24 #include "hook.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
25 #include "playback.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
26 #include "playlist.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
27 #include "playlist_evmessages.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
28 #include "playlist_evlisteners.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
29
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
30 #include "ui_main.h"
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
31 #include "ui_equalizer.h"
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
32 #include "ui_skinned_textbox.h"
3248
3cf247e4508c fix not updating playlist on title change
Tomasz Mon <desowin@gmail.com>
parents: 3197
diff changeset
33 #include "ui_playlist.h"
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
34
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
35 static void
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
36 ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data)
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
37 {
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
38 gchar *text = (gchar *) hook_data;
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
39
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
40 ui_skinned_textbox_set_text(mainwin_info, text);
3248
3cf247e4508c fix not updating playlist on title change
Tomasz Mon <desowin@gmail.com>
parents: 3197
diff changeset
41 playlistwin_update_list(playlist_get_active());
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
42 g_free(text);
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
43 }
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
44
3197
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
45 static void
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
46 ui_main_evlistener_hide_seekbar(gpointer hook_data, gpointer user_data)
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
47 {
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
48 mainwin_disable_seekbar();
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
49 }
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
50
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
51 static void
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
52 ui_main_evlistener_volume_change(gpointer hook_data, gpointer user_data)
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
53 {
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
54 gint *h_vol = (gint *) hook_data;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
55 gint vl, vr, b, v;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
56
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
57 vl = CLAMP(h_vol[0], 0, 100);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
58 vr = CLAMP(h_vol[1], 0, 100);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
59 v = MAX(vl, vr);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
60 if (vl > vr)
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
61 b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
62 else if (vl < vr)
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
63 b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
64 else
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
65 b = 0;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
66
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
67 mainwin_set_volume_slider(v);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
68 equalizerwin_set_volume_slider(v);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
69 mainwin_set_balance_slider(b);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
70 equalizerwin_set_balance_slider(b);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
71 }
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
72
4026
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
73 static void
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
74 ui_main_evlistener_playback_initiate(gpointer hook_data, gpointer user_data)
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
75 {
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
76 playback_initiate();
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
77 }
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
78
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
79 void
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
80 ui_main_evlistener_init(void)
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
81 {
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
82 hook_associate("title change", ui_main_evlistener_title_change, NULL);
3197
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
83 hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL);
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
84 hook_associate("volume set", ui_main_evlistener_volume_change, NULL);
4026
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
85 hook_associate("playback initiate", ui_main_evlistener_playback_initiate, NULL);
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
86 }
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
87