Mercurial > audlegacy
comparison src/audacious/ui_main_evlisteners.c @ 4359:0becb809bdc9
moved most GUI-related functions from playback.c to ui_main_evlisteners.c
this change enables basic, working headless mode in X!
author | mf0102 <0102@gmx.at> |
---|---|
date | Mon, 17 Mar 2008 23:47:24 +0100 |
parents | 17bf734f8187 |
children | 313dd79a2d24 |
comparison
equal
deleted
inserted
replaced
4358:6478692415a0 | 4359:0becb809bdc9 |
---|---|
24 #include "hook.h" | 24 #include "hook.h" |
25 #include "playback.h" | 25 #include "playback.h" |
26 #include "playlist.h" | 26 #include "playlist.h" |
27 #include "playlist_evmessages.h" | 27 #include "playlist_evmessages.h" |
28 #include "playlist_evlisteners.h" | 28 #include "playlist_evlisteners.h" |
29 #include "visualization.h" | |
29 | 30 |
30 #include "ui_main.h" | 31 #include "ui_main.h" |
31 #include "ui_equalizer.h" | 32 #include "ui_equalizer.h" |
33 #include "ui_skinned_playstatus.h" | |
32 #include "ui_skinned_textbox.h" | 34 #include "ui_skinned_textbox.h" |
33 #include "ui_playlist.h" | 35 #include "ui_playlist.h" |
36 | |
37 static gint song_info_timeout_source = 0; | |
38 static gint update_vis_timeout_source = 0; | |
39 | |
40 /* XXX: there has to be a better way than polling here! */ | |
41 /* also: where should this function go? should it stay here? --mf0102 */ | |
42 static gboolean | |
43 update_vis_func(gpointer unused) | |
44 { | |
45 if (!playback_get_playing()) | |
46 return FALSE; | |
47 | |
48 input_update_vis(playback_get_time()); | |
49 | |
50 return TRUE; | |
51 } | |
34 | 52 |
35 static void | 53 static void |
36 ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data) | 54 ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data) |
37 { | 55 { |
38 gchar *text = (gchar *) hook_data; | 56 gchar *text = (gchar *) hook_data; |
74 ui_main_evlistener_playback_initiate(gpointer hook_data, gpointer user_data) | 92 ui_main_evlistener_playback_initiate(gpointer hook_data, gpointer user_data) |
75 { | 93 { |
76 playback_initiate(); | 94 playback_initiate(); |
77 } | 95 } |
78 | 96 |
97 static void | |
98 ui_main_evlistener_playback_begin(gpointer hook_data, gpointer user_data) | |
99 { | |
100 ui_vis_clear_data(mainwin_vis); | |
101 ui_svis_clear_data(mainwin_svis); | |
102 mainwin_disable_seekbar(); | |
103 mainwin_update_song_info(); | |
104 | |
105 /* FIXME: use g_timeout_add_seconds when glib-2.14 is required */ | |
106 song_info_timeout_source = g_timeout_add(1000, | |
107 (GSourceFunc) mainwin_update_song_info, NULL); | |
108 | |
109 if (cfg.player_shaded) { | |
110 gtk_widget_show(mainwin_stime_min); | |
111 gtk_widget_show(mainwin_stime_sec); | |
112 gtk_widget_show(mainwin_sposition); | |
113 } else { | |
114 gtk_widget_show(mainwin_minus_num); | |
115 gtk_widget_show(mainwin_10min_num); | |
116 gtk_widget_show(mainwin_min_num); | |
117 gtk_widget_show(mainwin_10sec_num); | |
118 gtk_widget_show(mainwin_sec_num); | |
119 gtk_widget_show(mainwin_position); | |
120 } | |
121 | |
122 update_vis_timeout_source = g_timeout_add(10, | |
123 (GSourceFunc) update_vis_func, NULL); | |
124 | |
125 vis_playback_start(); | |
126 | |
127 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
128 } | |
129 | |
130 static void | |
131 ui_main_evlistener_playback_stop(gpointer hook_data, gpointer user_data) | |
132 { | |
133 if (song_info_timeout_source) | |
134 g_source_remove(song_info_timeout_source); | |
135 | |
136 vis_playback_stop(); | |
137 free_vis_data(); | |
138 | |
139 ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE); | |
140 } | |
141 | |
142 static void | |
143 ui_main_evlistener_playback_pause(gpointer hook_data, gpointer user_data) | |
144 { | |
145 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); | |
146 } | |
147 | |
148 static void | |
149 ui_main_evlistener_playback_unpause(gpointer hook_data, gpointer user_data) | |
150 { | |
151 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
152 } | |
153 | |
154 static void | |
155 ui_main_evlistener_playback_seek(gpointer hook_data, gpointer user_data) | |
156 { | |
157 free_vis_data(); | |
158 } | |
159 | |
160 static void | |
161 ui_main_evlistener_playback_play_file(gpointer hook_data, gpointer user_data) | |
162 { | |
163 if (cfg.random_skin_on_play) | |
164 skin_set_random_skin(); | |
165 } | |
166 | |
167 static void | |
168 ui_main_evlistener_playlist_info_change(gpointer hook_data, gpointer user_data) | |
169 { | |
170 PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data; | |
171 | |
172 mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels); | |
173 | |
174 g_free(msg); | |
175 } | |
176 | |
79 void | 177 void |
80 ui_main_evlistener_init(void) | 178 ui_main_evlistener_init(void) |
81 { | 179 { |
82 hook_associate("title change", ui_main_evlistener_title_change, NULL); | 180 hook_associate("title change", ui_main_evlistener_title_change, NULL); |
83 hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL); | 181 hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL); |
84 hook_associate("volume set", ui_main_evlistener_volume_change, NULL); | 182 hook_associate("volume set", ui_main_evlistener_volume_change, NULL); |
85 hook_associate("playback initiate", ui_main_evlistener_playback_initiate, NULL); | 183 hook_associate("playback initiate", ui_main_evlistener_playback_initiate, NULL); |
184 hook_associate("playback begin", ui_main_evlistener_playback_begin, NULL); | |
185 hook_associate("playback stop", ui_main_evlistener_playback_stop, NULL); | |
186 hook_associate("playback pause", ui_main_evlistener_playback_pause, NULL); | |
187 hook_associate("playback unpause", ui_main_evlistener_playback_unpause, NULL); | |
188 hook_associate("playback seek", ui_main_evlistener_playback_seek, NULL); | |
189 hook_associate("playback play file", ui_main_evlistener_playback_play_file, NULL); | |
190 hook_associate("playlist info change", ui_main_evlistener_playlist_info_change, NULL); | |
86 } | 191 } |
87 | 192 |